diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-11-09 17:20:11 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-11-09 17:20:11 +0000 |
commit | d534a56d95bca7bdd812be024d9eacba4734e2b7 (patch) | |
tree | f9b98ee2b80e645a7b54e7934882be6c9f73c165 /c++-libbu++/src/gatsstream.h | |
parent | 61ccc86fdf06f12cb72a8b7e65286f812cf62154 (diff) | |
download | libgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.tar.gz libgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.tar.bz2 libgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.tar.xz libgats-d534a56d95bca7bdd812be024d9eacba4734e2b7.zip |
Many changes: tabconv'd the C++ code, added a license, BSD, and docs.
Diffstat (limited to '')
-rw-r--r-- | c++-libbu++/src/gatsstream.h | 97 |
1 files changed, 52 insertions, 45 deletions
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 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2012 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libgats library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
1 | #ifndef GATS_STREAM_H | 8 | #ifndef GATS_STREAM_H |
2 | #define GATS_STREAM_H | 9 | #define GATS_STREAM_H |
3 | 10 | ||
@@ -6,51 +13,51 @@ | |||
6 | 13 | ||
7 | namespace Gats | 14 | namespace Gats |
8 | { | 15 | { |
9 | class Object; | 16 | class Object; |
10 | 17 | ||
11 | class GatsStream | 18 | class GatsStream |
12 | { | 19 | { |
13 | public: | 20 | public: |
14 | GatsStream( Bu::Stream &rStream ); | 21 | GatsStream( Bu::Stream &rStream ); |
15 | virtual ~GatsStream(); | 22 | virtual ~GatsStream(); |
16 | 23 | ||
17 | /** | 24 | /** |
18 | * Read an object packet from the assosiated stream. This will make | 25 | * Read an object packet from the assosiated stream. This will make |
19 | * every effort to only read exactly enough data to describe one packet, | 26 | * every effort to only read exactly enough data to describe one packet, |
20 | * in case you want to do other things with your stream. It will | 27 | * in case you want to do other things with your stream. It will |
21 | * automatically skip NULL byte spacing between packets, which makes | 28 | * automatically skip NULL byte spacing between packets, which makes |
22 | * a convinient padding method for encrypted data streams. Since | 29 | * a convinient padding method for encrypted data streams. Since |
23 | * sizing information is available in the packet header exact amounts | 30 | * sizing information is available in the packet header exact amounts |
24 | * of data can be read, however this function doesn't assume that it | 31 | * of data can be read, however this function doesn't assume that it |
25 | * can read the entire object in one operation. If it fails to read | 32 | * can read the entire object in one operation. If it fails to read |
26 | * a complete packet in one call, it will keep the data it's read so | 33 | * a complete packet in one call, it will keep the data it's read so |
27 | * far buffered and return NULL, ready for another attempt. You can | 34 | * far buffered and return NULL, ready for another attempt. You can |
28 | * use the function hasReadBuffer() to deterimne if readObject() | 35 | * use the function hasReadBuffer() to deterimne if readObject() |
29 | * has read part of an object packet or not. If readObject returns | 36 | * has read part of an object packet or not. If readObject returns |
30 | * non-null then hasReadBuffer should return false on it's next call. | 37 | * non-null then hasReadBuffer should return false on it's next call. |
31 | */ | 38 | */ |
32 | Gats::Object *readObject(); | 39 | Gats::Object *readObject(); |
33 | 40 | ||
34 | /** | 41 | /** |
35 | * Write an object | 42 | * Write an object |
36 | */ | 43 | */ |
37 | void writeObject( Gats::Object *pObject ); | 44 | void writeObject( Gats::Object *pObject ); |
38 | 45 | ||
39 | /** | 46 | /** |
40 | * Tells you if there is data still in the read buffer, i.e. that a | 47 | * Tells you if there is data still in the read buffer, i.e. that a |
41 | * packet is part way through being read. If readObject has returned | 48 | * packet is part way through being read. If readObject has returned |
42 | * non-null in the most recent call, this should always be false. | 49 | * non-null in the most recent call, this should always be false. |
43 | */ | 50 | */ |
44 | bool hasReadBuffer() { return qbRead.getSize() > 0; } | 51 | bool hasReadBuffer() { return qbRead.getSize() > 0; } |
45 | int getReadBufferSize() { return qbRead.getSize(); } | 52 | int getReadBufferSize() { return qbRead.getSize(); } |
46 | 53 | ||
47 | private: | 54 | private: |
48 | bool skipReadNulls(); | 55 | bool skipReadNulls(); |
49 | 56 | ||
50 | private: | 57 | private: |
51 | Bu::Stream &rStream; | 58 | Bu::Stream &rStream; |
52 | Bu::QueueBuf qbRead; | 59 | Bu::QueueBuf qbRead; |
53 | }; | 60 | }; |
54 | }; | 61 | }; |
55 | 62 | ||
56 | #endif | 63 | #endif |