aboutsummaryrefslogtreecommitdiff
path: root/c++-qt/src/gatsstream.h
diff options
context:
space:
mode:
Diffstat (limited to 'c++-qt/src/gatsstream.h')
-rw-r--r--c++-qt/src/gatsstream.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/c++-qt/src/gatsstream.h b/c++-qt/src/gatsstream.h
new file mode 100644
index 0000000..3cf1081
--- /dev/null
+++ b/c++-qt/src/gatsstream.h
@@ -0,0 +1,57 @@
1#ifndef GATS_STREAM_H
2#define GATS_STREAM_H
3
4#include <QIODevice>
5#include <QByteArray>
6
7namespace Gats
8{
9 class Object;
10
11 class GatsStream : public QObject
12 {
13 Q_OBJECT;
14 public:
15 GatsStream( QIODevice &rStream );
16 virtual ~GatsStream();
17
18 /**
19 * Read an object packet from the assosiated stream. This will make
20 * every effort to only read exactly enough data to describe one packet,
21 * in case you want to do other things with your stream. It will
22 * automatically skip NULL byte spacing between packets, which makes
23 * a convinient padding method for encrypted data streams. Since
24 * sizing information is available in the packet header exact amounts
25 * of data can be read, however this function doesn't assume that it
26 * can read the entire object in one operation. If it fails to read
27 * a complete packet in one call, it will keep the data it's read so
28 * far buffered and return NULL, ready for another attempt. You can
29 * use the function hasReadBuffer() to deterimne if readObject()
30 * has read part of an object packet or not. If readObject returns
31 * non-null then hasReadBuffer should return false on it's next call.
32 */
33 Gats::Object *readObject();
34
35 /**
36 * Write an object
37 */
38 void writeObject( Gats::Object *pObject );
39
40 /**
41 * Tells you if there is data still in the read buffer, i.e. that a
42 * packet is part way through being read. If readObject has returned
43 * non-null in the most recent call, this should always be false.
44 */
45 bool hasReadBuffer() { return qbRead.size() > 0; }
46 int getReadBufferSize() { return qbRead.size(); }
47
48 private:
49 bool skipReadNulls();
50
51 private:
52 QIODevice &rStream;
53 QByteArray qbRead;
54 };
55};
56
57#endif