diff options
Diffstat (limited to '')
-rw-r--r-- | src/gatsstream.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/gatsstream.h b/src/gatsstream.h index d668c28..b5efb87 100644 --- a/src/gatsstream.h +++ b/src/gatsstream.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define GATS_STREAM_H | 2 | #define GATS_STREAM_H |
3 | 3 | ||
4 | #include <bu/stream.h> | 4 | #include <bu/stream.h> |
5 | #include <bu/queuebuf.h> | ||
5 | 6 | ||
6 | namespace Gats | 7 | namespace Gats |
7 | { | 8 | { |
@@ -13,11 +14,41 @@ namespace Gats | |||
13 | GatsStream( Bu::Stream &rStream ); | 14 | GatsStream( Bu::Stream &rStream ); |
14 | virtual ~GatsStream(); | 15 | virtual ~GatsStream(); |
15 | 16 | ||
17 | /** | ||
18 | * Read an object packet from the assosiated stream. This will make | ||
19 | * 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 | ||
21 | * automatically skip NULL byte spacing between packets, which makes | ||
22 | * a convinient padding method for encrypted data streams. Since | ||
23 | * sizing information is available in the packet header exact amounts | ||
24 | * 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 | ||
26 | * 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 | ||
28 | * use the function hasReadBuffer() to deterimne if readObject() | ||
29 | * 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. | ||
31 | */ | ||
16 | Gats::Object *readObject(); | 32 | Gats::Object *readObject(); |
33 | |||
34 | /** | ||
35 | * Write an object | ||
36 | */ | ||
17 | void writeObject( Gats::Object *pObject ); | 37 | void writeObject( Gats::Object *pObject ); |
18 | 38 | ||
39 | /** | ||
40 | * 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 | ||
42 | * non-null in the most recent call, this should always be false. | ||
43 | */ | ||
44 | bool hasReadBuffer() { return qbRead.getSize() > 0; } | ||
45 | |||
46 | private: | ||
47 | bool skipReadNulls(); | ||
48 | |||
19 | private: | 49 | private: |
20 | Bu::Stream &rStream; | 50 | Bu::Stream &rStream; |
51 | Bu::QueueBuf qbRead; | ||
21 | }; | 52 | }; |
22 | }; | 53 | }; |
23 | 54 | ||