From d534a56d95bca7bdd812be024d9eacba4734e2b7 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 9 Nov 2012 17:20:11 +0000 Subject: Many changes: tabconv'd the C++ code, added a license, BSD, and docs. --- c++-libbu++/src/tests/clone.cpp | 21 ++++++++----- c++-libbu++/src/tests/dump.cpp | 41 +++++++++++++++----------- c++-libbu++/src/tests/int.cpp | 65 +++++++++++++++++++++++------------------ 3 files changed, 74 insertions(+), 53 deletions(-) (limited to 'c++-libbu++/src/tests') diff --git a/c++-libbu++/src/tests/clone.cpp b/c++-libbu++/src/tests/clone.cpp index 8533376..bfb7b27 100644 --- a/c++-libbu++/src/tests/clone.cpp +++ b/c++-libbu++/src/tests/clone.cpp @@ -1,3 +1,10 @@ +/* + * Copyright (C) 2007-2012 Xagasoft, All rights reserved. + * + * This file is part of the libgats library and is released under the + * terms of the license contained in the file LICENSE. + */ + #include "gats/types.h" #include @@ -6,17 +13,17 @@ using namespace Bu; int main( int argc, char *argv[] ) { - Gats::Object *pBase = Gats::Object::strToGats("{\"Thing\": 3.14159, \"bool\": true, \"list\":[\"string\",44,{\"Stuff\":{\"list\":[],\"what?\":false}}]}"); + Gats::Object *pBase = Gats::Object::strToGats("{\"Thing\": 3.14159, \"bool\": true, \"list\":[\"string\",44,{\"Stuff\":{\"list\":[],\"what?\":false}}]}"); - sio << *pBase << sio.nl; + sio << *pBase << sio.nl; - Gats::Object *pNew = pBase->clone(); - delete pBase; + Gats::Object *pNew = pBase->clone(); + delete pBase; - sio << *pNew << sio.nl; + sio << *pNew << sio.nl; - delete pNew; + delete pNew; - return 0; + return 0; } diff --git a/c++-libbu++/src/tests/dump.cpp b/c++-libbu++/src/tests/dump.cpp index e0dcb52..f1950b2 100644 --- a/c++-libbu++/src/tests/dump.cpp +++ b/c++-libbu++/src/tests/dump.cpp @@ -1,3 +1,10 @@ +/* + * Copyright (C) 2007-2012 Xagasoft, All rights reserved. + * + * This file is part of the libgats library and is released under the + * terms of the license contained in the file LICENSE. + */ + #include #include #include @@ -7,24 +14,24 @@ using namespace Bu; int main( int argc, char *argv[] ) { - File fIn( argv[1], File::Read ); - Gats::GatsStream gsIn( fIn ); + File fIn( argv[1], File::Read ); + Gats::GatsStream gsIn( fIn ); - for(;;) - { - sio << "Reading from file position: " << fIn.tell() << sio.nl; - Gats::Object *pObj = gsIn.readObject(); - if( !pObj ) - { - if( gsIn.hasReadBuffer() ) - { - sio << "Premature end of stream detected, have " - << gsIn.getReadBufferSize() << "b." << sio.nl; - } - return 0; - } + for(;;) + { + sio << "Reading from file position: " << fIn.tell() << sio.nl; + Gats::Object *pObj = gsIn.readObject(); + if( !pObj ) + { + if( gsIn.hasReadBuffer() ) + { + sio << "Premature end of stream detected, have " + << gsIn.getReadBufferSize() << "b." << sio.nl; + } + return 0; + } - sio << *pObj << sio.nl; - } + sio << *pObj << sio.nl; + } } diff --git a/c++-libbu++/src/tests/int.cpp b/c++-libbu++/src/tests/int.cpp index c19df9c..25ef831 100644 --- a/c++-libbu++/src/tests/int.cpp +++ b/c++-libbu++/src/tests/int.cpp @@ -1,3 +1,10 @@ +/* + * Copyright (C) 2007-2012 Xagasoft, All rights reserved. + * + * This file is part of the libgats library and is released under the + * terms of the license contained in the file LICENSE. + */ + #include "gats/integer.h" #include @@ -8,40 +15,40 @@ using namespace Bu; void hexdump( char *dat, int iSize ) { - static const char *hex="0123456789ABCDEF"; - printf("----\n"); - for( int j = 0; j < iSize; j += 8 ) - { - for( int k = j; /*k < iSize &&*/ k < j+8; k++ ) - printf((k>4)&0x0F], hex[dat[k]&0x0F] ); - printf("| "); - for( int k = j; k < iSize && k < j+8; k++ ) - printf("%c ", (dat[k]>13&&dat[k]<127)?(dat[k]):('.') ); - printf("\n"); - } - printf("----\n"); + static const char *hex="0123456789ABCDEF"; + printf("----\n"); + for( int j = 0; j < iSize; j += 8 ) + { + for( int k = j; /*k < iSize &&*/ k < j+8; k++ ) + printf((k>4)&0x0F], hex[dat[k]&0x0F] ); + printf("| "); + for( int k = j; k < iSize && k < j+8; k++ ) + printf("%c ", (dat[k]>13&&dat[k]<127)?(dat[k]):('.') ); + printf("\n"); + } + printf("----\n"); } int main( int argc, char *argv[] ) { - for( int j = 1; j < argc; j++ ) - { - int64_t i = strtoll( argv[j], NULL, 10 ); - MemBuf mb; - Gats::Integer::writePackedInt( mb, i ); - hexdump( mb.getString().getStr(), mb.getString().getSize() ); - } + for( int j = 1; j < argc; j++ ) + { + int64_t i = strtoll( argv[j], NULL, 10 ); + MemBuf mb; + Gats::Integer::writePackedInt( mb, i ); + hexdump( mb.getString().getStr(), mb.getString().getSize() ); + } /* - sio << "Before: " << i << sio.nl; - Gats::Integer::writePackedInt( mb, i ); - mb.write("aaa", 3 ); - mb.setPos( 0 ); - Gats::Integer::readPackedInt( mb, i ); - sio << "After: " << i << sio.nl; - char buf[4]; - buf[mb.read( buf, 3 )] = '\0'; - sio << "Extra: \"" << buf << "\"" << sio.nl; + sio << "Before: " << i << sio.nl; + Gats::Integer::writePackedInt( mb, i ); + mb.write("aaa", 3 ); + mb.setPos( 0 ); + Gats::Integer::readPackedInt( mb, i ); + sio << "After: " << i << sio.nl; + char buf[4]; + buf[mb.read( buf, 3 )] = '\0'; + sio << "Extra: \"" << buf << "\"" << sio.nl; */ - return 0; + return 0; } -- cgit v1.2.3