aboutsummaryrefslogtreecommitdiff
path: root/c++-qt/src/gatsstream.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-03-31 17:34:11 +0000
committerMike Buland <eichlan@xagasoft.com>2012-03-31 17:34:11 +0000
commit82da0238a8171cf8bba6bb1c82d5abba207a10aa (patch)
tree83ff9b022b658e7a056fc85f132937b8bda4c1c3 /c++-qt/src/gatsstream.h
parent7dd5c386611e31930e7ccfb83cb585df27696881 (diff)
downloadlibgats-82da0238a8171cf8bba6bb1c82d5abba207a10aa.tar.gz
libgats-82da0238a8171cf8bba6bb1c82d5abba207a10aa.tar.bz2
libgats-82da0238a8171cf8bba6bb1c82d5abba207a10aa.tar.xz
libgats-82da0238a8171cf8bba6bb1c82d5abba207a10aa.zip
Gats for QT is here. It's a pretty basic conversion right now, it doesn't
support debugging formatting (Bu::sio), it doesn't support gats-text string parsing, and the exceptions need to be fixed to be real exceptions. The basic functions have been renamed to match the Qt API and we use QT types for everything (QHash, QList, QByteArray). It needs more testing, but it's a great start.
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