diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-08-19 06:28:17 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-08-19 06:28:17 +0000 |
commit | 11b5a91c5884d496744911f261ed6c2b053b9940 (patch) | |
tree | 61ed65f187e0719f141d80d4e1e648aeff311024 /src/gatsstream.h | |
parent | 9dc8cc535ef5fc4ea78f967fe285fe4424ff4458 (diff) | |
download | libgats-11b5a91c5884d496744911f261ed6c2b053b9940.tar.gz libgats-11b5a91c5884d496744911f261ed6c2b053b9940.tar.bz2 libgats-11b5a91c5884d496744911f261ed6c2b053b9940.tar.xz libgats-11b5a91c5884d496744911f261ed6c2b053b9940.zip |
Wow, it pretty much all works. the float format is a little funny, I treat it
as a string, with a string header and then string data that is then turned into
a float. It's pretty much how it's going to work, unless I come up with
something revolutionary.
Diffstat (limited to 'src/gatsstream.h')
-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 | ||