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/gatsstream.h | 97 ++++++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 45 deletions(-) (limited to 'c++-libbu++/src/gatsstream.h') diff --git a/c++-libbu++/src/gatsstream.h b/c++-libbu++/src/gatsstream.h index 39719cf..e318b3c 100644 --- a/c++-libbu++/src/gatsstream.h +++ b/c++-libbu++/src/gatsstream.h @@ -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. + */ + #ifndef GATS_STREAM_H #define GATS_STREAM_H @@ -6,51 +13,51 @@ namespace Gats { - class Object; - - class GatsStream - { - public: - GatsStream( Bu::Stream &rStream ); - virtual ~GatsStream(); - - /** - * Read an object packet from the assosiated stream. This will make - * every effort to only read exactly enough data to describe one packet, - * in case you want to do other things with your stream. It will - * automatically skip NULL byte spacing between packets, which makes - * a convinient padding method for encrypted data streams. Since - * sizing information is available in the packet header exact amounts - * of data can be read, however this function doesn't assume that it - * can read the entire object in one operation. If it fails to read - * a complete packet in one call, it will keep the data it's read so - * far buffered and return NULL, ready for another attempt. You can - * use the function hasReadBuffer() to deterimne if readObject() - * has read part of an object packet or not. If readObject returns - * non-null then hasReadBuffer should return false on it's next call. - */ - Gats::Object *readObject(); - - /** - * Write an object - */ - void writeObject( Gats::Object *pObject ); - - /** - * Tells you if there is data still in the read buffer, i.e. that a - * packet is part way through being read. If readObject has returned - * non-null in the most recent call, this should always be false. - */ - bool hasReadBuffer() { return qbRead.getSize() > 0; } - int getReadBufferSize() { return qbRead.getSize(); } - - private: - bool skipReadNulls(); - - private: - Bu::Stream &rStream; - Bu::QueueBuf qbRead; - }; + class Object; + + class GatsStream + { + public: + GatsStream( Bu::Stream &rStream ); + virtual ~GatsStream(); + + /** + * Read an object packet from the assosiated stream. This will make + * every effort to only read exactly enough data to describe one packet, + * in case you want to do other things with your stream. It will + * automatically skip NULL byte spacing between packets, which makes + * a convinient padding method for encrypted data streams. Since + * sizing information is available in the packet header exact amounts + * of data can be read, however this function doesn't assume that it + * can read the entire object in one operation. If it fails to read + * a complete packet in one call, it will keep the data it's read so + * far buffered and return NULL, ready for another attempt. You can + * use the function hasReadBuffer() to deterimne if readObject() + * has read part of an object packet or not. If readObject returns + * non-null then hasReadBuffer should return false on it's next call. + */ + Gats::Object *readObject(); + + /** + * Write an object + */ + void writeObject( Gats::Object *pObject ); + + /** + * Tells you if there is data still in the read buffer, i.e. that a + * packet is part way through being read. If readObject has returned + * non-null in the most recent call, this should always be false. + */ + bool hasReadBuffer() { return qbRead.getSize() > 0; } + int getReadBufferSize() { return qbRead.getSize(); } + + private: + bool skipReadNulls(); + + private: + Bu::Stream &rStream; + Bu::QueueBuf qbRead; + }; }; #endif -- cgit v1.2.3