aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--[l---------]c++-qt/gats-qt/boolean.h42
-rw-r--r--[l---------]c++-qt/gats-qt/dictionary.h78
-rw-r--r--[l---------]c++-qt/gats-qt/float.h40
-rw-r--r--[l---------]c++-qt/gats-qt/gatsstream.h80
-rw-r--r--[l---------]c++-qt/gats-qt/integer.h96
-rw-r--r--[l---------]c++-qt/gats-qt/list.h67
-rw-r--r--[l---------]c++-qt/gats-qt/null.h36
-rw-r--r--[l---------]c++-qt/gats-qt/object.h62
-rw-r--r--[l---------]c++-qt/gats-qt/string.h42
-rw-r--r--[l---------]c++-qt/gats-qt/types.h16
l---------c++-qt/gats-qt/version.h1
-rw-r--r--c++-qt/libgats.pro2
-rw-r--r--c++-qt/src/boolean.h41
-rw-r--r--c++-qt/src/dictionary.h77
-rw-r--r--c++-qt/src/float.h39
-rw-r--r--c++-qt/src/gatsstream.h79
-rw-r--r--c++-qt/src/integer.h95
-rw-r--r--c++-qt/src/list.h66
-rw-r--r--c++-qt/src/null.h35
-rw-r--r--c++-qt/src/object.h61
-rw-r--r--c++-qt/src/string.h41
-rw-r--r--c++-qt/src/types.h15
22 files changed, 550 insertions, 561 deletions
diff --git a/c++-qt/gats-qt/boolean.h b/c++-qt/gats-qt/boolean.h
index 27e9ba3..7e42981 120000..100644
--- a/c++-qt/gats-qt/boolean.h
+++ b/c++-qt/gats-qt/boolean.h
@@ -1 +1,41 @@
1../src/boolean.h \ No newline at end of file 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
8#ifndef GATS_BOOLEAN_H
9#define GATS_BOOLEAN_H
10
11#include "gats-qt/object.h"
12
13class QIODevice;
14
15namespace Gats
16{
17 class Boolean : public Gats::Object
18 {
19 Q_OBJECT;
20 public:
21 Boolean();
22 Boolean( bool bVal );
23 virtual ~Boolean();
24
25 virtual Object *clone() const;
26
27 virtual Type getType() const { return typeBoolean; }
28 bool getValue() const { return bVal; }
29 void setValue( bool b ) { bVal = b; }
30
31 virtual void write( QIODevice &rOut ) const;
32 virtual void read( QIODevice &rIn, char cType );
33
34 private:
35 bool bVal;
36 };
37};
38
39//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Boolean &b );
40
41#endif
diff --git a/c++-qt/gats-qt/dictionary.h b/c++-qt/gats-qt/dictionary.h
index cdca1b6..af1d436 120000..100644
--- a/c++-qt/gats-qt/dictionary.h
+++ b/c++-qt/gats-qt/dictionary.h
@@ -1 +1,77 @@
1../src/dictionary.h \ No newline at end of file 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
8#ifndef GATS_DICTIONARY_H
9#define GATS_DICTIONARY_H
10
11#include "gats-qt/object.h"
12#include "gats-qt/string.h"
13#include <QHash>
14
15namespace Gats
16{
17 class List;
18
19 class Dictionary : public Gats::Object,
20 public QHash<QByteArray, Gats::Object *>
21 {
22 Q_OBJECT;
23 public:
24 Dictionary();
25 virtual ~Dictionary();
26
27 virtual Object *clone() const;
28
29 virtual Type getType() const { return typeDictionary; }
30 virtual void write( QIODevice &rOut ) const;
31 virtual void read( QIODevice &rIn, char cType );
32
33 void insert( const QByteArray &sKey, const char *s );
34 void insert( const QByteArray &sKey, const QByteArray &s );
35 void insert( const QByteArray &sKey, char i );
36 void insert( const QByteArray &sKey, unsigned char i );
37 void insert( const QByteArray &sKey, signed char i );
38 void insert( const QByteArray &sKey, unsigned short i );
39 void insert( const QByteArray &sKey, signed short i );
40 void insert( const QByteArray &sKey, unsigned int i );
41 void insert( const QByteArray &sKey, signed int i );
42 void insert( const QByteArray &sKey, unsigned long i );
43 void insert( const QByteArray &sKey, signed long i );
44 void insert( const QByteArray &sKey, unsigned long long i );
45 void insert( const QByteArray &sKey, signed long long i );
46 //void insert( const QByteArray &sKey, bool b );
47 void insert( const QByteArray &sKey, float d );
48 void insert( const QByteArray &sKey, double d );
49 using QHash<QByteArray, Gats::Object *>::insert;
50 void insertBool( const QByteArray &sKey, bool b );
51 void insertInt( const QByteArray &sKey, int64_t i );
52 void insertFloat( const QByteArray &sKey, double d );
53 void insertStr( const QByteArray &sKey, const QByteArray &s );
54 void insertList( const QByteArray &sKey, Gats::List *pL );
55 void insertDict( const QByteArray &sKey, Gats::Dictionary *pD );
56 Gats::List *insertList( const QByteArray &sKey );
57 Gats::Dictionary *insertDict( const QByteArray &sKey );
58
59 bool valueBool( const QByteArray &sKey );
60 int64_t valueInt( const QByteArray &sKey );
61 double valueFloat( const QByteArray &sKey );
62 QByteArray valueStr( const QByteArray &sKey );
63 Gats::List *valueList( const QByteArray &sKey );
64 Gats::Dictionary *valueDict( const QByteArray &sKey );
65
66 bool valueBool( const QByteArray &sKey ) const;
67 int64_t valueInt( const QByteArray &sKey ) const;
68 double valueFloat( const QByteArray &sKey ) const;
69 QByteArray valueStr( const QByteArray &sKey ) const;
70 Gats::List *valueList( const QByteArray &sKey ) const;
71 Gats::Dictionary *valueDict( const QByteArray &sKey ) const;
72 };
73};
74
75//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Dictionary &d );
76
77#endif
diff --git a/c++-qt/gats-qt/float.h b/c++-qt/gats-qt/float.h
index 6d057eb..6cc9950 120000..100644
--- a/c++-qt/gats-qt/float.h
+++ b/c++-qt/gats-qt/float.h
@@ -1 +1,39 @@
1../src/float.h \ No newline at end of file 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
8#ifndef GATS_FLOAT_H
9#define GATS_FLOAT_H
10
11#include "gats-qt/object.h"
12
13namespace Gats
14{
15 class Float : public Gats::Object
16 {
17 Q_OBJECT;
18 public:
19 Float();
20 Float( double f );
21 virtual ~Float();
22
23 virtual Object *clone() const;
24
25 virtual Type getType() const { return typeFloat; }
26 double getValue() const { return fVal; }
27
28 virtual void write( QIODevice &rOut ) const;
29 virtual void read( QIODevice &rIn, char cType );
30
31 private:
32 double fVal;
33 mutable QByteArray sWriteCache;
34 };
35}
36
37//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Float &flt );
38
39#endif
diff --git a/c++-qt/gats-qt/gatsstream.h b/c++-qt/gats-qt/gatsstream.h
index 38d4d0e..979ca60 120000..100644
--- a/c++-qt/gats-qt/gatsstream.h
+++ b/c++-qt/gats-qt/gatsstream.h
@@ -1 +1,79 @@
1../src/gatsstream.h \ No newline at end of file 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
8#ifndef GATS_STREAM_H
9#define GATS_STREAM_H
10
11#include <QIODevice>
12#include <QByteArray>
13
14namespace Gats
15{
16 class Object;
17
18 class GatsStream : public QObject
19 {
20 Q_OBJECT;
21 public:
22 GatsStream( QIODevice &rStream );
23 virtual ~GatsStream();
24
25 public slots:
26 /**
27 * Read an object packet from the assosiated stream. This will make
28 * every effort to only read exactly enough data to describe one packet,
29 * in case you want to do other things with your stream. It will
30 * automatically skip NULL byte spacing between packets, which makes
31 * a convinient padding method for encrypted data streams. Since
32 * sizing information is available in the packet header exact amounts
33 * of data can be read, however this function doesn't assume that it
34 * can read the entire object in one operation. If it fails to read
35 * a complete packet in one call, it will keep the data it's read so
36 * far buffered and return NULL, ready for another attempt. You can
37 * use the function hasReadBuffer() to deterimne if readObject()
38 * has read part of an object packet or not. If readObject returns
39 * non-null then hasReadBuffer should return false on it's next call.
40 */
41 Gats::Object *readObject();
42
43 /**
44 * Works exactly like readObject, except it reads all pending objects
45 * and emits a objectRead signal for each one read. It doesn't return
46 * anything. This is perfect for connecting to a QIODevice's readRead
47 * signal.
48 */
49 void readAllObjects();
50
51 public:
52 /**
53 * Write an object
54 */
55 void writeObject( Gats::Object *pObject );
56
57 /**
58 * Tells you if there is data still in the read buffer, i.e. that a
59 * packet is part way through being read. If readObject has returned
60 * non-null in the most recent call, this should always be false.
61 */
62 bool hasReadBuffer() { return qbRead.size() > 0; }
63 int getReadBufferSize() { return qbRead.size(); }
64
65 QIODevice &getIODevice() { return rStream; }
66
67 signals:
68 void objectRead( Gats::Object *pObj );
69
70 private:
71 bool skipReadNulls();
72
73 private:
74 QIODevice &rStream;
75 QByteArray qbRead;
76 };
77};
78
79#endif
diff --git a/c++-qt/gats-qt/integer.h b/c++-qt/gats-qt/integer.h
index a2bfb2d..9178796 120000..100644
--- a/c++-qt/gats-qt/integer.h
+++ b/c++-qt/gats-qt/integer.h
@@ -1 +1,95 @@
1../src/integer.h \ No newline at end of file 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
8#ifndef GATS_INTEGER_H
9#define GATS_INTEGER_H
10
11#include "gats-qt/object.h"
12
13#include <stdint.h>
14
15#include <QIODevice>
16
17namespace Gats
18{
19 class Integer : public Gats::Object
20 {
21 Q_OBJECT;
22 public:
23 Integer();
24 Integer( int64_t iVal );
25 virtual ~Integer();
26
27 virtual Object *clone() const;
28
29 virtual Type getType() const { return typeInteger; }
30 int64_t getValue() const { return iVal; }
31 void setValue( int64_t iNewVal ) { iVal = iNewVal; }
32
33 virtual void write( QIODevice &rOut ) const;
34 virtual void read( QIODevice &rIn, char cType );
35
36 template<typename itype>
37 static void readPackedInt( QIODevice &rStream, itype &rOut )
38 {
39 int8_t b;
40 rOut = 0;
41 bool bNeg;
42
43 rStream.read( (char *)&b, 1 );
44 bNeg = ( b&0x40 );
45 rOut |= (itype(b&0x3F));
46 int c = 0;
47 while( (b&0x80) )
48 {
49 rStream.read( (char *)&b, 1 );
50 rOut |= (itype(b&0x7F)) << (6+7*(c++));
51 }
52 if( bNeg ) rOut = -rOut;
53 }
54
55 template<typename itype>
56 static void writePackedInt( QIODevice &rStream, itype iIn )
57 {
58 uint8_t b;
59
60 if( iIn < 0 )
61 {
62 iIn = -iIn;
63 b = (iIn&0x3F);
64 if( iIn > b )
65 b |= 0x80 | 0x40;
66 else
67 b |= 0x40;
68 }
69 else
70 {
71 b = (iIn&0x3F);
72 if( iIn > b )
73 b |= 0x80;
74 }
75 rStream.write( (const char *)&b, 1 );
76 iIn = iIn >> 6;
77
78 while( iIn )
79 {
80 b = (iIn&0x7F);
81 if( iIn > b )
82 b |= 0x80;
83 rStream.write( (const char *)&b, 1 );
84 iIn = iIn >> 7;
85 }
86 }
87
88 private:
89 int64_t iVal;
90 };
91};
92
93//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Integer &i );
94
95#endif
diff --git a/c++-qt/gats-qt/list.h b/c++-qt/gats-qt/list.h
index 1a01fc0..7577bad 120000..100644
--- a/c++-qt/gats-qt/list.h
+++ b/c++-qt/gats-qt/list.h
@@ -1 +1,66 @@
1../src/list.h \ No newline at end of file 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
8#ifndef GATS_LIST_H
9#define GATS_LIST_H
10
11#include "gats-qt/object.h"
12#include <QList>
13
14namespace Gats
15{
16 class Dictionary;
17
18 class List : public Gats::Object, public QList<Gats::Object *>
19 {
20 Q_OBJECT;
21 public:
22 List();
23 virtual ~List();
24
25 virtual Object *clone() const;
26
27 virtual Type getType() const { return typeList; }
28
29 virtual void write( QIODevice &rOut ) const;
30 virtual void read( QIODevice &rIn, char cType );
31
32 void append( const char *s );
33 void append( const QByteArray &s );
34 void append( int32_t i );
35 void append( int64_t i );
36 void append( double d );
37 using QList<Gats::Object *>::append;
38 void appendStr( const QByteArray &s );
39 void appendInt( int64_t i );
40 void appendFloat( double d );
41 void appendBool( bool b );
42 void appendList( Gats::List *pL );
43 void appendDict( Gats::Dictionary *pD );
44 Gats::List *appendList();
45 Gats::Dictionary *appendDict();
46
47 void prepend( const char *s );
48 void prepend( const QByteArray &s );
49 void prepend( int32_t i );
50 void prepend( int64_t i );
51 void prepend( double d );
52 using QList<Gats::Object *>::prepend;
53 void prependStr( const QByteArray &s );
54 void prependInt( int64_t i );
55 void prependFloat( double d );
56 void prependBool( bool b );
57 void prependList( Gats::List *pL );
58 void prependDict( Gats::Dictionary *pD );
59 Gats::List *prependList();
60 Gats::Dictionary *prependDict();
61 };
62};
63
64//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::List &l );
65
66#endif
diff --git a/c++-qt/gats-qt/null.h b/c++-qt/gats-qt/null.h
index e80cf61..f3ec45b 120000..100644
--- a/c++-qt/gats-qt/null.h
+++ b/c++-qt/gats-qt/null.h
@@ -1 +1,35 @@
1../src/null.h \ No newline at end of file 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
8#ifndef GATS_NULL_H
9#define GATS_NULL_H
10
11#include "gats-qt/object.h"
12
13class QIODevice;
14
15namespace Gats
16{
17 class Null : public Gats::Object
18 {
19 Q_OBJECT;
20 public:
21 Null();
22 virtual ~Null();
23
24 virtual Object *clone() const;
25
26 virtual Type getType() const { return typeNull; }
27
28 virtual void write( QIODevice &rOut ) const;
29 virtual void read( QIODevice &rIn, char cType );
30 };
31};
32
33//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Null &b );
34
35#endif
diff --git a/c++-qt/gats-qt/object.h b/c++-qt/gats-qt/object.h
index 04b70ec..7e12b87 120000..100644
--- a/c++-qt/gats-qt/object.h
+++ b/c++-qt/gats-qt/object.h
@@ -1 +1,61 @@
1../src/object.h \ No newline at end of file 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
8#ifndef GATS_OBJECT_H
9#define GATS_OBJECT_H
10
11#include <QObject>
12#include <QByteArray>
13
14class QIODevice;
15
16namespace Gats
17{
18 enum Type
19 {
20 typeDictionary,
21 typeList,
22 typeString,
23 typeInteger,
24 typeFloat,
25 typeBoolean,
26 typeNull
27 };
28
29 /**
30 * The baseclass for every type that can be stored in a packet.
31 */
32 class Object : public QObject
33 {
34 Q_OBJECT;
35 public:
36 Object();
37 virtual ~Object();
38
39 virtual Object *clone() const=0;
40
41 virtual Type getType() const =0;
42
43 virtual void write( QIODevice &rOut ) const=0;
44 virtual void read( QIODevice &rIn, char cType )=0;
45
46 static Object *read( QIODevice &rIn );
47// static Object *strToGats( const &sStr );
48
49 private:
50// static Object *strToGats( QByteArray::const_iterator &i );
51// static QByteArray token( QByteArray::const_iterator &i );
52// static void skipWs( QByteArray::const_iterator &i );
53 };
54
55 const char *typeToStr( Type t );
56};
57
58//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Object &obj );
59//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Type &t );
60
61#endif
diff --git a/c++-qt/gats-qt/string.h b/c++-qt/gats-qt/string.h
index ef7336d..a679fc0 120000..100644
--- a/c++-qt/gats-qt/string.h
+++ b/c++-qt/gats-qt/string.h
@@ -1 +1,41 @@
1../src/string.h \ No newline at end of file 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
8#ifndef GATS_STRING_H
9#define GATS_STRING_H
10
11#include "gats-qt/object.h"
12#include <QByteArray>
13
14namespace Gats
15{
16 class String : public Gats::Object, public QByteArray
17 {
18 Q_OBJECT;
19 public:
20 String();
21 String( const char *s );
22 String( const char *s, long iLength );
23 String( long iLength );
24 String( const String &s );
25 String( const QByteArray &s );
26 virtual ~String();
27
28 virtual Object *clone() const;
29
30 virtual Type getType() const { return typeString; }
31
32 virtual void write( QIODevice &rOut ) const;
33 virtual void read( QIODevice &rIn, char cType );
34
35 private:
36 };
37};
38
39//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::String &s );
40
41#endif
diff --git a/c++-qt/gats-qt/types.h b/c++-qt/gats-qt/types.h
index a21c97e..1efdf26 120000..100644
--- a/c++-qt/gats-qt/types.h
+++ b/c++-qt/gats-qt/types.h
@@ -1 +1,15 @@
1../src/types.h \ No newline at end of file 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
8#include "gats-qt/object.h"
9#include "gats-qt/boolean.h"
10#include "gats-qt/dictionary.h"
11#include "gats-qt/float.h"
12#include "gats-qt/integer.h"
13#include "gats-qt/list.h"
14#include "gats-qt/string.h"
15#include "gats-qt/null.h"
diff --git a/c++-qt/gats-qt/version.h b/c++-qt/gats-qt/version.h
deleted file mode 120000
index 0489181..0000000
--- a/c++-qt/gats-qt/version.h
+++ /dev/null
@@ -1 +0,0 @@
1../src/version.h \ No newline at end of file
diff --git a/c++-qt/libgats.pro b/c++-qt/libgats.pro
index 3b9e2b8..8eaac84 100644
--- a/c++-qt/libgats.pro
+++ b/c++-qt/libgats.pro
@@ -9,6 +9,6 @@ QMAKE_CXXFLAGS += -ggdb -W -Wall
9 9
10win32:LIBS += -lwsock32 10win32:LIBS += -lwsock32
11 11
12HEADERS += src/*.h 12HEADERS += gats-qt/*.h
13SOURCES += src/*.cpp 13SOURCES += src/*.cpp
14 14
diff --git a/c++-qt/src/boolean.h b/c++-qt/src/boolean.h
deleted file mode 100644
index 7e42981..0000000
--- a/c++-qt/src/boolean.h
+++ /dev/null
@@ -1,41 +0,0 @@
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
8#ifndef GATS_BOOLEAN_H
9#define GATS_BOOLEAN_H
10
11#include "gats-qt/object.h"
12
13class QIODevice;
14
15namespace Gats
16{
17 class Boolean : public Gats::Object
18 {
19 Q_OBJECT;
20 public:
21 Boolean();
22 Boolean( bool bVal );
23 virtual ~Boolean();
24
25 virtual Object *clone() const;
26
27 virtual Type getType() const { return typeBoolean; }
28 bool getValue() const { return bVal; }
29 void setValue( bool b ) { bVal = b; }
30
31 virtual void write( QIODevice &rOut ) const;
32 virtual void read( QIODevice &rIn, char cType );
33
34 private:
35 bool bVal;
36 };
37};
38
39//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Boolean &b );
40
41#endif
diff --git a/c++-qt/src/dictionary.h b/c++-qt/src/dictionary.h
deleted file mode 100644
index af1d436..0000000
--- a/c++-qt/src/dictionary.h
+++ /dev/null
@@ -1,77 +0,0 @@
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
8#ifndef GATS_DICTIONARY_H
9#define GATS_DICTIONARY_H
10
11#include "gats-qt/object.h"
12#include "gats-qt/string.h"
13#include <QHash>
14
15namespace Gats
16{
17 class List;
18
19 class Dictionary : public Gats::Object,
20 public QHash<QByteArray, Gats::Object *>
21 {
22 Q_OBJECT;
23 public:
24 Dictionary();
25 virtual ~Dictionary();
26
27 virtual Object *clone() const;
28
29 virtual Type getType() const { return typeDictionary; }
30 virtual void write( QIODevice &rOut ) const;
31 virtual void read( QIODevice &rIn, char cType );
32
33 void insert( const QByteArray &sKey, const char *s );
34 void insert( const QByteArray &sKey, const QByteArray &s );
35 void insert( const QByteArray &sKey, char i );
36 void insert( const QByteArray &sKey, unsigned char i );
37 void insert( const QByteArray &sKey, signed char i );
38 void insert( const QByteArray &sKey, unsigned short i );
39 void insert( const QByteArray &sKey, signed short i );
40 void insert( const QByteArray &sKey, unsigned int i );
41 void insert( const QByteArray &sKey, signed int i );
42 void insert( const QByteArray &sKey, unsigned long i );
43 void insert( const QByteArray &sKey, signed long i );
44 void insert( const QByteArray &sKey, unsigned long long i );
45 void insert( const QByteArray &sKey, signed long long i );
46 //void insert( const QByteArray &sKey, bool b );
47 void insert( const QByteArray &sKey, float d );
48 void insert( const QByteArray &sKey, double d );
49 using QHash<QByteArray, Gats::Object *>::insert;
50 void insertBool( const QByteArray &sKey, bool b );
51 void insertInt( const QByteArray &sKey, int64_t i );
52 void insertFloat( const QByteArray &sKey, double d );
53 void insertStr( const QByteArray &sKey, const QByteArray &s );
54 void insertList( const QByteArray &sKey, Gats::List *pL );
55 void insertDict( const QByteArray &sKey, Gats::Dictionary *pD );
56 Gats::List *insertList( const QByteArray &sKey );
57 Gats::Dictionary *insertDict( const QByteArray &sKey );
58
59 bool valueBool( const QByteArray &sKey );
60 int64_t valueInt( const QByteArray &sKey );
61 double valueFloat( const QByteArray &sKey );
62 QByteArray valueStr( const QByteArray &sKey );
63 Gats::List *valueList( const QByteArray &sKey );
64 Gats::Dictionary *valueDict( const QByteArray &sKey );
65
66 bool valueBool( const QByteArray &sKey ) const;
67 int64_t valueInt( const QByteArray &sKey ) const;
68 double valueFloat( const QByteArray &sKey ) const;
69 QByteArray valueStr( const QByteArray &sKey ) const;
70 Gats::List *valueList( const QByteArray &sKey ) const;
71 Gats::Dictionary *valueDict( const QByteArray &sKey ) const;
72 };
73};
74
75//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Dictionary &d );
76
77#endif
diff --git a/c++-qt/src/float.h b/c++-qt/src/float.h
deleted file mode 100644
index 6cc9950..0000000
--- a/c++-qt/src/float.h
+++ /dev/null
@@ -1,39 +0,0 @@
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
8#ifndef GATS_FLOAT_H
9#define GATS_FLOAT_H
10
11#include "gats-qt/object.h"
12
13namespace Gats
14{
15 class Float : public Gats::Object
16 {
17 Q_OBJECT;
18 public:
19 Float();
20 Float( double f );
21 virtual ~Float();
22
23 virtual Object *clone() const;
24
25 virtual Type getType() const { return typeFloat; }
26 double getValue() const { return fVal; }
27
28 virtual void write( QIODevice &rOut ) const;
29 virtual void read( QIODevice &rIn, char cType );
30
31 private:
32 double fVal;
33 mutable QByteArray sWriteCache;
34 };
35}
36
37//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Float &flt );
38
39#endif
diff --git a/c++-qt/src/gatsstream.h b/c++-qt/src/gatsstream.h
deleted file mode 100644
index 979ca60..0000000
--- a/c++-qt/src/gatsstream.h
+++ /dev/null
@@ -1,79 +0,0 @@
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
8#ifndef GATS_STREAM_H
9#define GATS_STREAM_H
10
11#include <QIODevice>
12#include <QByteArray>
13
14namespace Gats
15{
16 class Object;
17
18 class GatsStream : public QObject
19 {
20 Q_OBJECT;
21 public:
22 GatsStream( QIODevice &rStream );
23 virtual ~GatsStream();
24
25 public slots:
26 /**
27 * Read an object packet from the assosiated stream. This will make
28 * every effort to only read exactly enough data to describe one packet,
29 * in case you want to do other things with your stream. It will
30 * automatically skip NULL byte spacing between packets, which makes
31 * a convinient padding method for encrypted data streams. Since
32 * sizing information is available in the packet header exact amounts
33 * of data can be read, however this function doesn't assume that it
34 * can read the entire object in one operation. If it fails to read
35 * a complete packet in one call, it will keep the data it's read so
36 * far buffered and return NULL, ready for another attempt. You can
37 * use the function hasReadBuffer() to deterimne if readObject()
38 * has read part of an object packet or not. If readObject returns
39 * non-null then hasReadBuffer should return false on it's next call.
40 */
41 Gats::Object *readObject();
42
43 /**
44 * Works exactly like readObject, except it reads all pending objects
45 * and emits a objectRead signal for each one read. It doesn't return
46 * anything. This is perfect for connecting to a QIODevice's readRead
47 * signal.
48 */
49 void readAllObjects();
50
51 public:
52 /**
53 * Write an object
54 */
55 void writeObject( Gats::Object *pObject );
56
57 /**
58 * Tells you if there is data still in the read buffer, i.e. that a
59 * packet is part way through being read. If readObject has returned
60 * non-null in the most recent call, this should always be false.
61 */
62 bool hasReadBuffer() { return qbRead.size() > 0; }
63 int getReadBufferSize() { return qbRead.size(); }
64
65 QIODevice &getIODevice() { return rStream; }
66
67 signals:
68 void objectRead( Gats::Object *pObj );
69
70 private:
71 bool skipReadNulls();
72
73 private:
74 QIODevice &rStream;
75 QByteArray qbRead;
76 };
77};
78
79#endif
diff --git a/c++-qt/src/integer.h b/c++-qt/src/integer.h
deleted file mode 100644
index 9178796..0000000
--- a/c++-qt/src/integer.h
+++ /dev/null
@@ -1,95 +0,0 @@
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
8#ifndef GATS_INTEGER_H
9#define GATS_INTEGER_H
10
11#include "gats-qt/object.h"
12
13#include <stdint.h>
14
15#include <QIODevice>
16
17namespace Gats
18{
19 class Integer : public Gats::Object
20 {
21 Q_OBJECT;
22 public:
23 Integer();
24 Integer( int64_t iVal );
25 virtual ~Integer();
26
27 virtual Object *clone() const;
28
29 virtual Type getType() const { return typeInteger; }
30 int64_t getValue() const { return iVal; }
31 void setValue( int64_t iNewVal ) { iVal = iNewVal; }
32
33 virtual void write( QIODevice &rOut ) const;
34 virtual void read( QIODevice &rIn, char cType );
35
36 template<typename itype>
37 static void readPackedInt( QIODevice &rStream, itype &rOut )
38 {
39 int8_t b;
40 rOut = 0;
41 bool bNeg;
42
43 rStream.read( (char *)&b, 1 );
44 bNeg = ( b&0x40 );
45 rOut |= (itype(b&0x3F));
46 int c = 0;
47 while( (b&0x80) )
48 {
49 rStream.read( (char *)&b, 1 );
50 rOut |= (itype(b&0x7F)) << (6+7*(c++));
51 }
52 if( bNeg ) rOut = -rOut;
53 }
54
55 template<typename itype>
56 static void writePackedInt( QIODevice &rStream, itype iIn )
57 {
58 uint8_t b;
59
60 if( iIn < 0 )
61 {
62 iIn = -iIn;
63 b = (iIn&0x3F);
64 if( iIn > b )
65 b |= 0x80 | 0x40;
66 else
67 b |= 0x40;
68 }
69 else
70 {
71 b = (iIn&0x3F);
72 if( iIn > b )
73 b |= 0x80;
74 }
75 rStream.write( (const char *)&b, 1 );
76 iIn = iIn >> 6;
77
78 while( iIn )
79 {
80 b = (iIn&0x7F);
81 if( iIn > b )
82 b |= 0x80;
83 rStream.write( (const char *)&b, 1 );
84 iIn = iIn >> 7;
85 }
86 }
87
88 private:
89 int64_t iVal;
90 };
91};
92
93//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Integer &i );
94
95#endif
diff --git a/c++-qt/src/list.h b/c++-qt/src/list.h
deleted file mode 100644
index 7577bad..0000000
--- a/c++-qt/src/list.h
+++ /dev/null
@@ -1,66 +0,0 @@
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
8#ifndef GATS_LIST_H
9#define GATS_LIST_H
10
11#include "gats-qt/object.h"
12#include <QList>
13
14namespace Gats
15{
16 class Dictionary;
17
18 class List : public Gats::Object, public QList<Gats::Object *>
19 {
20 Q_OBJECT;
21 public:
22 List();
23 virtual ~List();
24
25 virtual Object *clone() const;
26
27 virtual Type getType() const { return typeList; }
28
29 virtual void write( QIODevice &rOut ) const;
30 virtual void read( QIODevice &rIn, char cType );
31
32 void append( const char *s );
33 void append( const QByteArray &s );
34 void append( int32_t i );
35 void append( int64_t i );
36 void append( double d );
37 using QList<Gats::Object *>::append;
38 void appendStr( const QByteArray &s );
39 void appendInt( int64_t i );
40 void appendFloat( double d );
41 void appendBool( bool b );
42 void appendList( Gats::List *pL );
43 void appendDict( Gats::Dictionary *pD );
44 Gats::List *appendList();
45 Gats::Dictionary *appendDict();
46
47 void prepend( const char *s );
48 void prepend( const QByteArray &s );
49 void prepend( int32_t i );
50 void prepend( int64_t i );
51 void prepend( double d );
52 using QList<Gats::Object *>::prepend;
53 void prependStr( const QByteArray &s );
54 void prependInt( int64_t i );
55 void prependFloat( double d );
56 void prependBool( bool b );
57 void prependList( Gats::List *pL );
58 void prependDict( Gats::Dictionary *pD );
59 Gats::List *prependList();
60 Gats::Dictionary *prependDict();
61 };
62};
63
64//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::List &l );
65
66#endif
diff --git a/c++-qt/src/null.h b/c++-qt/src/null.h
deleted file mode 100644
index f3ec45b..0000000
--- a/c++-qt/src/null.h
+++ /dev/null
@@ -1,35 +0,0 @@
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
8#ifndef GATS_NULL_H
9#define GATS_NULL_H
10
11#include "gats-qt/object.h"
12
13class QIODevice;
14
15namespace Gats
16{
17 class Null : public Gats::Object
18 {
19 Q_OBJECT;
20 public:
21 Null();
22 virtual ~Null();
23
24 virtual Object *clone() const;
25
26 virtual Type getType() const { return typeNull; }
27
28 virtual void write( QIODevice &rOut ) const;
29 virtual void read( QIODevice &rIn, char cType );
30 };
31};
32
33//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Null &b );
34
35#endif
diff --git a/c++-qt/src/object.h b/c++-qt/src/object.h
deleted file mode 100644
index 7e12b87..0000000
--- a/c++-qt/src/object.h
+++ /dev/null
@@ -1,61 +0,0 @@
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
8#ifndef GATS_OBJECT_H
9#define GATS_OBJECT_H
10
11#include <QObject>
12#include <QByteArray>
13
14class QIODevice;
15
16namespace Gats
17{
18 enum Type
19 {
20 typeDictionary,
21 typeList,
22 typeString,
23 typeInteger,
24 typeFloat,
25 typeBoolean,
26 typeNull
27 };
28
29 /**
30 * The baseclass for every type that can be stored in a packet.
31 */
32 class Object : public QObject
33 {
34 Q_OBJECT;
35 public:
36 Object();
37 virtual ~Object();
38
39 virtual Object *clone() const=0;
40
41 virtual Type getType() const =0;
42
43 virtual void write( QIODevice &rOut ) const=0;
44 virtual void read( QIODevice &rIn, char cType )=0;
45
46 static Object *read( QIODevice &rIn );
47// static Object *strToGats( const &sStr );
48
49 private:
50// static Object *strToGats( QByteArray::const_iterator &i );
51// static QByteArray token( QByteArray::const_iterator &i );
52// static void skipWs( QByteArray::const_iterator &i );
53 };
54
55 const char *typeToStr( Type t );
56};
57
58//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Object &obj );
59//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Type &t );
60
61#endif
diff --git a/c++-qt/src/string.h b/c++-qt/src/string.h
deleted file mode 100644
index a679fc0..0000000
--- a/c++-qt/src/string.h
+++ /dev/null
@@ -1,41 +0,0 @@
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
8#ifndef GATS_STRING_H
9#define GATS_STRING_H
10
11#include "gats-qt/object.h"
12#include <QByteArray>
13
14namespace Gats
15{
16 class String : public Gats::Object, public QByteArray
17 {
18 Q_OBJECT;
19 public:
20 String();
21 String( const char *s );
22 String( const char *s, long iLength );
23 String( long iLength );
24 String( const String &s );
25 String( const QByteArray &s );
26 virtual ~String();
27
28 virtual Object *clone() const;
29
30 virtual Type getType() const { return typeString; }
31
32 virtual void write( QIODevice &rOut ) const;
33 virtual void read( QIODevice &rIn, char cType );
34
35 private:
36 };
37};
38
39//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::String &s );
40
41#endif
diff --git a/c++-qt/src/types.h b/c++-qt/src/types.h
deleted file mode 100644
index 1efdf26..0000000
--- a/c++-qt/src/types.h
+++ /dev/null
@@ -1,15 +0,0 @@
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
8#include "gats-qt/object.h"
9#include "gats-qt/boolean.h"
10#include "gats-qt/dictionary.h"
11#include "gats-qt/float.h"
12#include "gats-qt/integer.h"
13#include "gats-qt/list.h"
14#include "gats-qt/string.h"
15#include "gats-qt/null.h"