From 29e854354982dcdd8f548ca10b2f2f6b889b280c Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Fri, 9 Nov 2012 17:22:33 +0000 Subject: The attempt to use symlinks in place of the header files was silly. --- c++-qt/gats-qt/boolean.h | 42 +++++++++++++++++++- c++-qt/gats-qt/dictionary.h | 78 +++++++++++++++++++++++++++++++++++- c++-qt/gats-qt/float.h | 40 ++++++++++++++++++- c++-qt/gats-qt/gatsstream.h | 80 ++++++++++++++++++++++++++++++++++++- c++-qt/gats-qt/integer.h | 96 ++++++++++++++++++++++++++++++++++++++++++++- c++-qt/gats-qt/list.h | 67 ++++++++++++++++++++++++++++++- c++-qt/gats-qt/null.h | 36 ++++++++++++++++- c++-qt/gats-qt/object.h | 62 ++++++++++++++++++++++++++++- c++-qt/gats-qt/string.h | 42 +++++++++++++++++++- c++-qt/gats-qt/types.h | 16 +++++++- c++-qt/gats-qt/version.h | 1 - c++-qt/libgats.pro | 2 +- c++-qt/src/boolean.h | 41 ------------------- c++-qt/src/dictionary.h | 77 ------------------------------------ c++-qt/src/float.h | 39 ------------------ c++-qt/src/gatsstream.h | 79 ------------------------------------- c++-qt/src/integer.h | 95 -------------------------------------------- c++-qt/src/list.h | 66 ------------------------------- c++-qt/src/null.h | 35 ----------------- c++-qt/src/object.h | 61 ---------------------------- c++-qt/src/string.h | 41 ------------------- c++-qt/src/types.h | 15 ------- 22 files changed, 550 insertions(+), 561 deletions(-) mode change 120000 => 100644 c++-qt/gats-qt/boolean.h mode change 120000 => 100644 c++-qt/gats-qt/dictionary.h mode change 120000 => 100644 c++-qt/gats-qt/float.h mode change 120000 => 100644 c++-qt/gats-qt/gatsstream.h mode change 120000 => 100644 c++-qt/gats-qt/integer.h mode change 120000 => 100644 c++-qt/gats-qt/list.h mode change 120000 => 100644 c++-qt/gats-qt/null.h mode change 120000 => 100644 c++-qt/gats-qt/object.h mode change 120000 => 100644 c++-qt/gats-qt/string.h mode change 120000 => 100644 c++-qt/gats-qt/types.h delete mode 120000 c++-qt/gats-qt/version.h delete mode 100644 c++-qt/src/boolean.h delete mode 100644 c++-qt/src/dictionary.h delete mode 100644 c++-qt/src/float.h delete mode 100644 c++-qt/src/gatsstream.h delete mode 100644 c++-qt/src/integer.h delete mode 100644 c++-qt/src/list.h delete mode 100644 c++-qt/src/null.h delete mode 100644 c++-qt/src/object.h delete mode 100644 c++-qt/src/string.h delete mode 100644 c++-qt/src/types.h diff --git a/c++-qt/gats-qt/boolean.h b/c++-qt/gats-qt/boolean.h deleted file mode 120000 index 27e9ba3..0000000 --- a/c++-qt/gats-qt/boolean.h +++ /dev/null @@ -1 +0,0 @@ -../src/boolean.h \ No newline at end of file diff --git a/c++-qt/gats-qt/boolean.h b/c++-qt/gats-qt/boolean.h new file mode 100644 index 0000000..7e42981 --- /dev/null +++ b/c++-qt/gats-qt/boolean.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2007-2012 Xagasoft, All rights reserved. + * + * This file is part of the libgats library and is released under the + * terms of the license contained in the file LICENSE. + */ + +#ifndef GATS_BOOLEAN_H +#define GATS_BOOLEAN_H + +#include "gats-qt/object.h" + +class QIODevice; + +namespace Gats +{ + class Boolean : public Gats::Object + { + Q_OBJECT; + public: + Boolean(); + Boolean( bool bVal ); + virtual ~Boolean(); + + virtual Object *clone() const; + + virtual Type getType() const { return typeBoolean; } + bool getValue() const { return bVal; } + void setValue( bool b ) { bVal = b; } + + virtual void write( QIODevice &rOut ) const; + virtual void read( QIODevice &rIn, char cType ); + + private: + bool bVal; + }; +}; + +//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Boolean &b ); + +#endif diff --git a/c++-qt/gats-qt/dictionary.h b/c++-qt/gats-qt/dictionary.h deleted file mode 120000 index cdca1b6..0000000 --- a/c++-qt/gats-qt/dictionary.h +++ /dev/null @@ -1 +0,0 @@ -../src/dictionary.h \ No newline at end of file diff --git a/c++-qt/gats-qt/dictionary.h b/c++-qt/gats-qt/dictionary.h new file mode 100644 index 0000000..af1d436 --- /dev/null +++ b/c++-qt/gats-qt/dictionary.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2007-2012 Xagasoft, All rights reserved. + * + * This file is part of the libgats library and is released under the + * terms of the license contained in the file LICENSE. + */ + +#ifndef GATS_DICTIONARY_H +#define GATS_DICTIONARY_H + +#include "gats-qt/object.h" +#include "gats-qt/string.h" +#include + +namespace Gats +{ + class List; + + class Dictionary : public Gats::Object, + public QHash + { + Q_OBJECT; + public: + Dictionary(); + virtual ~Dictionary(); + + virtual Object *clone() const; + + virtual Type getType() const { return typeDictionary; } + virtual void write( QIODevice &rOut ) const; + virtual void read( QIODevice &rIn, char cType ); + + void insert( const QByteArray &sKey, const char *s ); + void insert( const QByteArray &sKey, const QByteArray &s ); + void insert( const QByteArray &sKey, char i ); + void insert( const QByteArray &sKey, unsigned char i ); + void insert( const QByteArray &sKey, signed char i ); + void insert( const QByteArray &sKey, unsigned short i ); + void insert( const QByteArray &sKey, signed short i ); + void insert( const QByteArray &sKey, unsigned int i ); + void insert( const QByteArray &sKey, signed int i ); + void insert( const QByteArray &sKey, unsigned long i ); + void insert( const QByteArray &sKey, signed long i ); + void insert( const QByteArray &sKey, unsigned long long i ); + void insert( const QByteArray &sKey, signed long long i ); + //void insert( const QByteArray &sKey, bool b ); + void insert( const QByteArray &sKey, float d ); + void insert( const QByteArray &sKey, double d ); + using QHash::insert; + void insertBool( const QByteArray &sKey, bool b ); + void insertInt( const QByteArray &sKey, int64_t i ); + void insertFloat( const QByteArray &sKey, double d ); + void insertStr( const QByteArray &sKey, const QByteArray &s ); + void insertList( const QByteArray &sKey, Gats::List *pL ); + void insertDict( const QByteArray &sKey, Gats::Dictionary *pD ); + Gats::List *insertList( const QByteArray &sKey ); + Gats::Dictionary *insertDict( const QByteArray &sKey ); + + bool valueBool( const QByteArray &sKey ); + int64_t valueInt( const QByteArray &sKey ); + double valueFloat( const QByteArray &sKey ); + QByteArray valueStr( const QByteArray &sKey ); + Gats::List *valueList( const QByteArray &sKey ); + Gats::Dictionary *valueDict( const QByteArray &sKey ); + + bool valueBool( const QByteArray &sKey ) const; + int64_t valueInt( const QByteArray &sKey ) const; + double valueFloat( const QByteArray &sKey ) const; + QByteArray valueStr( const QByteArray &sKey ) const; + Gats::List *valueList( const QByteArray &sKey ) const; + Gats::Dictionary *valueDict( const QByteArray &sKey ) const; + }; +}; + +//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Dictionary &d ); + +#endif diff --git a/c++-qt/gats-qt/float.h b/c++-qt/gats-qt/float.h deleted file mode 120000 index 6d057eb..0000000 --- a/c++-qt/gats-qt/float.h +++ /dev/null @@ -1 +0,0 @@ -../src/float.h \ No newline at end of file diff --git a/c++-qt/gats-qt/float.h b/c++-qt/gats-qt/float.h new file mode 100644 index 0000000..6cc9950 --- /dev/null +++ b/c++-qt/gats-qt/float.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2007-2012 Xagasoft, All rights reserved. + * + * This file is part of the libgats library and is released under the + * terms of the license contained in the file LICENSE. + */ + +#ifndef GATS_FLOAT_H +#define GATS_FLOAT_H + +#include "gats-qt/object.h" + +namespace Gats +{ + class Float : public Gats::Object + { + Q_OBJECT; + public: + Float(); + Float( double f ); + virtual ~Float(); + + virtual Object *clone() const; + + virtual Type getType() const { return typeFloat; } + double getValue() const { return fVal; } + + virtual void write( QIODevice &rOut ) const; + virtual void read( QIODevice &rIn, char cType ); + + private: + double fVal; + mutable QByteArray sWriteCache; + }; +} + +//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Float &flt ); + +#endif diff --git a/c++-qt/gats-qt/gatsstream.h b/c++-qt/gats-qt/gatsstream.h deleted file mode 120000 index 38d4d0e..0000000 --- a/c++-qt/gats-qt/gatsstream.h +++ /dev/null @@ -1 +0,0 @@ -../src/gatsstream.h \ No newline at end of file diff --git a/c++-qt/gats-qt/gatsstream.h b/c++-qt/gats-qt/gatsstream.h new file mode 100644 index 0000000..979ca60 --- /dev/null +++ b/c++-qt/gats-qt/gatsstream.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2007-2012 Xagasoft, All rights reserved. + * + * This file is part of the libgats library and is released under the + * terms of the license contained in the file LICENSE. + */ + +#ifndef GATS_STREAM_H +#define GATS_STREAM_H + +#include +#include + +namespace Gats +{ + class Object; + + class GatsStream : public QObject + { + Q_OBJECT; + public: + GatsStream( QIODevice &rStream ); + virtual ~GatsStream(); + + public slots: + /** + * Read an object packet from the assosiated stream. This will make + * every effort to only read exactly enough data to describe one packet, + * in case you want to do other things with your stream. It will + * automatically skip NULL byte spacing between packets, which makes + * a convinient padding method for encrypted data streams. Since + * sizing information is available in the packet header exact amounts + * of data can be read, however this function doesn't assume that it + * can read the entire object in one operation. If it fails to read + * a complete packet in one call, it will keep the data it's read so + * far buffered and return NULL, ready for another attempt. You can + * use the function hasReadBuffer() to deterimne if readObject() + * has read part of an object packet or not. If readObject returns + * non-null then hasReadBuffer should return false on it's next call. + */ + Gats::Object *readObject(); + + /** + * Works exactly like readObject, except it reads all pending objects + * and emits a objectRead signal for each one read. It doesn't return + * anything. This is perfect for connecting to a QIODevice's readRead + * signal. + */ + void readAllObjects(); + + public: + /** + * Write an object + */ + void writeObject( Gats::Object *pObject ); + + /** + * Tells you if there is data still in the read buffer, i.e. that a + * packet is part way through being read. If readObject has returned + * non-null in the most recent call, this should always be false. + */ + bool hasReadBuffer() { return qbRead.size() > 0; } + int getReadBufferSize() { return qbRead.size(); } + + QIODevice &getIODevice() { return rStream; } + + signals: + void objectRead( Gats::Object *pObj ); + + private: + bool skipReadNulls(); + + private: + QIODevice &rStream; + QByteArray qbRead; + }; +}; + +#endif diff --git a/c++-qt/gats-qt/integer.h b/c++-qt/gats-qt/integer.h deleted file mode 120000 index a2bfb2d..0000000 --- a/c++-qt/gats-qt/integer.h +++ /dev/null @@ -1 +0,0 @@ -../src/integer.h \ No newline at end of file diff --git a/c++-qt/gats-qt/integer.h b/c++-qt/gats-qt/integer.h new file mode 100644 index 0000000..9178796 --- /dev/null +++ b/c++-qt/gats-qt/integer.h @@ -0,0 +1,95 @@ +/* + * Copyright (C) 2007-2012 Xagasoft, All rights reserved. + * + * This file is part of the libgats library and is released under the + * terms of the license contained in the file LICENSE. + */ + +#ifndef GATS_INTEGER_H +#define GATS_INTEGER_H + +#include "gats-qt/object.h" + +#include + +#include + +namespace Gats +{ + class Integer : public Gats::Object + { + Q_OBJECT; + public: + Integer(); + Integer( int64_t iVal ); + virtual ~Integer(); + + virtual Object *clone() const; + + virtual Type getType() const { return typeInteger; } + int64_t getValue() const { return iVal; } + void setValue( int64_t iNewVal ) { iVal = iNewVal; } + + virtual void write( QIODevice &rOut ) const; + virtual void read( QIODevice &rIn, char cType ); + + template + static void readPackedInt( QIODevice &rStream, itype &rOut ) + { + int8_t b; + rOut = 0; + bool bNeg; + + rStream.read( (char *)&b, 1 ); + bNeg = ( b&0x40 ); + rOut |= (itype(b&0x3F)); + int c = 0; + while( (b&0x80) ) + { + rStream.read( (char *)&b, 1 ); + rOut |= (itype(b&0x7F)) << (6+7*(c++)); + } + if( bNeg ) rOut = -rOut; + } + + template + static void writePackedInt( QIODevice &rStream, itype iIn ) + { + uint8_t b; + + if( iIn < 0 ) + { + iIn = -iIn; + b = (iIn&0x3F); + if( iIn > b ) + b |= 0x80 | 0x40; + else + b |= 0x40; + } + else + { + b = (iIn&0x3F); + if( iIn > b ) + b |= 0x80; + } + rStream.write( (const char *)&b, 1 ); + iIn = iIn >> 6; + + while( iIn ) + { + b = (iIn&0x7F); + if( iIn > b ) + b |= 0x80; + rStream.write( (const char *)&b, 1 ); + iIn = iIn >> 7; + } + } + + private: + int64_t iVal; + }; +}; + +//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Integer &i ); + +#endif diff --git a/c++-qt/gats-qt/list.h b/c++-qt/gats-qt/list.h deleted file mode 120000 index 1a01fc0..0000000 --- a/c++-qt/gats-qt/list.h +++ /dev/null @@ -1 +0,0 @@ -../src/list.h \ No newline at end of file diff --git a/c++-qt/gats-qt/list.h b/c++-qt/gats-qt/list.h new file mode 100644 index 0000000..7577bad --- /dev/null +++ b/c++-qt/gats-qt/list.h @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2007-2012 Xagasoft, All rights reserved. + * + * This file is part of the libgats library and is released under the + * terms of the license contained in the file LICENSE. + */ + +#ifndef GATS_LIST_H +#define GATS_LIST_H + +#include "gats-qt/object.h" +#include + +namespace Gats +{ + class Dictionary; + + class List : public Gats::Object, public QList + { + Q_OBJECT; + public: + List(); + virtual ~List(); + + virtual Object *clone() const; + + virtual Type getType() const { return typeList; } + + virtual void write( QIODevice &rOut ) const; + virtual void read( QIODevice &rIn, char cType ); + + void append( const char *s ); + void append( const QByteArray &s ); + void append( int32_t i ); + void append( int64_t i ); + void append( double d ); + using QList::append; + void appendStr( const QByteArray &s ); + void appendInt( int64_t i ); + void appendFloat( double d ); + void appendBool( bool b ); + void appendList( Gats::List *pL ); + void appendDict( Gats::Dictionary *pD ); + Gats::List *appendList(); + Gats::Dictionary *appendDict(); + + void prepend( const char *s ); + void prepend( const QByteArray &s ); + void prepend( int32_t i ); + void prepend( int64_t i ); + void prepend( double d ); + using QList::prepend; + void prependStr( const QByteArray &s ); + void prependInt( int64_t i ); + void prependFloat( double d ); + void prependBool( bool b ); + void prependList( Gats::List *pL ); + void prependDict( Gats::Dictionary *pD ); + Gats::List *prependList(); + Gats::Dictionary *prependDict(); + }; +}; + +//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::List &l ); + +#endif diff --git a/c++-qt/gats-qt/null.h b/c++-qt/gats-qt/null.h deleted file mode 120000 index e80cf61..0000000 --- a/c++-qt/gats-qt/null.h +++ /dev/null @@ -1 +0,0 @@ -../src/null.h \ No newline at end of file diff --git a/c++-qt/gats-qt/null.h b/c++-qt/gats-qt/null.h new file mode 100644 index 0000000..f3ec45b --- /dev/null +++ b/c++-qt/gats-qt/null.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2007-2012 Xagasoft, All rights reserved. + * + * This file is part of the libgats library and is released under the + * terms of the license contained in the file LICENSE. + */ + +#ifndef GATS_NULL_H +#define GATS_NULL_H + +#include "gats-qt/object.h" + +class QIODevice; + +namespace Gats +{ + class Null : public Gats::Object + { + Q_OBJECT; + public: + Null(); + virtual ~Null(); + + virtual Object *clone() const; + + virtual Type getType() const { return typeNull; } + + virtual void write( QIODevice &rOut ) const; + virtual void read( QIODevice &rIn, char cType ); + }; +}; + +//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Null &b ); + +#endif diff --git a/c++-qt/gats-qt/object.h b/c++-qt/gats-qt/object.h deleted file mode 120000 index 04b70ec..0000000 --- a/c++-qt/gats-qt/object.h +++ /dev/null @@ -1 +0,0 @@ -../src/object.h \ No newline at end of file diff --git a/c++-qt/gats-qt/object.h b/c++-qt/gats-qt/object.h new file mode 100644 index 0000000..7e12b87 --- /dev/null +++ b/c++-qt/gats-qt/object.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2007-2012 Xagasoft, All rights reserved. + * + * This file is part of the libgats library and is released under the + * terms of the license contained in the file LICENSE. + */ + +#ifndef GATS_OBJECT_H +#define GATS_OBJECT_H + +#include +#include + +class QIODevice; + +namespace Gats +{ + enum Type + { + typeDictionary, + typeList, + typeString, + typeInteger, + typeFloat, + typeBoolean, + typeNull + }; + + /** + * The baseclass for every type that can be stored in a packet. + */ + class Object : public QObject + { + Q_OBJECT; + public: + Object(); + virtual ~Object(); + + virtual Object *clone() const=0; + + virtual Type getType() const =0; + + virtual void write( QIODevice &rOut ) const=0; + virtual void read( QIODevice &rIn, char cType )=0; + + static Object *read( QIODevice &rIn ); +// static Object *strToGats( const &sStr ); + + private: +// static Object *strToGats( QByteArray::const_iterator &i ); +// static QByteArray token( QByteArray::const_iterator &i ); +// static void skipWs( QByteArray::const_iterator &i ); + }; + + const char *typeToStr( Type t ); +}; + +//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Object &obj ); +//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Type &t ); + +#endif diff --git a/c++-qt/gats-qt/string.h b/c++-qt/gats-qt/string.h deleted file mode 120000 index ef7336d..0000000 --- a/c++-qt/gats-qt/string.h +++ /dev/null @@ -1 +0,0 @@ -../src/string.h \ No newline at end of file diff --git a/c++-qt/gats-qt/string.h b/c++-qt/gats-qt/string.h new file mode 100644 index 0000000..a679fc0 --- /dev/null +++ b/c++-qt/gats-qt/string.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2007-2012 Xagasoft, All rights reserved. + * + * This file is part of the libgats library and is released under the + * terms of the license contained in the file LICENSE. + */ + +#ifndef GATS_STRING_H +#define GATS_STRING_H + +#include "gats-qt/object.h" +#include + +namespace Gats +{ + class String : public Gats::Object, public QByteArray + { + Q_OBJECT; + public: + String(); + String( const char *s ); + String( const char *s, long iLength ); + String( long iLength ); + String( const String &s ); + String( const QByteArray &s ); + virtual ~String(); + + virtual Object *clone() const; + + virtual Type getType() const { return typeString; } + + virtual void write( QIODevice &rOut ) const; + virtual void read( QIODevice &rIn, char cType ); + + private: + }; +}; + +//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::String &s ); + +#endif diff --git a/c++-qt/gats-qt/types.h b/c++-qt/gats-qt/types.h deleted file mode 120000 index a21c97e..0000000 --- a/c++-qt/gats-qt/types.h +++ /dev/null @@ -1 +0,0 @@ -../src/types.h \ No newline at end of file diff --git a/c++-qt/gats-qt/types.h b/c++-qt/gats-qt/types.h new file mode 100644 index 0000000..1efdf26 --- /dev/null +++ b/c++-qt/gats-qt/types.h @@ -0,0 +1,15 @@ +/* + * Copyright (C) 2007-2012 Xagasoft, All rights reserved. + * + * This file is part of the libgats library and is released under the + * terms of the license contained in the file LICENSE. + */ + +#include "gats-qt/object.h" +#include "gats-qt/boolean.h" +#include "gats-qt/dictionary.h" +#include "gats-qt/float.h" +#include "gats-qt/integer.h" +#include "gats-qt/list.h" +#include "gats-qt/string.h" +#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 @@ -../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 win32:LIBS += -lwsock32 -HEADERS += src/*.h +HEADERS += gats-qt/*.h SOURCES += src/*.cpp 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 @@ -/* - * Copyright (C) 2007-2012 Xagasoft, All rights reserved. - * - * This file is part of the libgats library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#ifndef GATS_BOOLEAN_H -#define GATS_BOOLEAN_H - -#include "gats-qt/object.h" - -class QIODevice; - -namespace Gats -{ - class Boolean : public Gats::Object - { - Q_OBJECT; - public: - Boolean(); - Boolean( bool bVal ); - virtual ~Boolean(); - - virtual Object *clone() const; - - virtual Type getType() const { return typeBoolean; } - bool getValue() const { return bVal; } - void setValue( bool b ) { bVal = b; } - - virtual void write( QIODevice &rOut ) const; - virtual void read( QIODevice &rIn, char cType ); - - private: - bool bVal; - }; -}; - -//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Boolean &b ); - -#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 @@ -/* - * Copyright (C) 2007-2012 Xagasoft, All rights reserved. - * - * This file is part of the libgats library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#ifndef GATS_DICTIONARY_H -#define GATS_DICTIONARY_H - -#include "gats-qt/object.h" -#include "gats-qt/string.h" -#include - -namespace Gats -{ - class List; - - class Dictionary : public Gats::Object, - public QHash - { - Q_OBJECT; - public: - Dictionary(); - virtual ~Dictionary(); - - virtual Object *clone() const; - - virtual Type getType() const { return typeDictionary; } - virtual void write( QIODevice &rOut ) const; - virtual void read( QIODevice &rIn, char cType ); - - void insert( const QByteArray &sKey, const char *s ); - void insert( const QByteArray &sKey, const QByteArray &s ); - void insert( const QByteArray &sKey, char i ); - void insert( const QByteArray &sKey, unsigned char i ); - void insert( const QByteArray &sKey, signed char i ); - void insert( const QByteArray &sKey, unsigned short i ); - void insert( const QByteArray &sKey, signed short i ); - void insert( const QByteArray &sKey, unsigned int i ); - void insert( const QByteArray &sKey, signed int i ); - void insert( const QByteArray &sKey, unsigned long i ); - void insert( const QByteArray &sKey, signed long i ); - void insert( const QByteArray &sKey, unsigned long long i ); - void insert( const QByteArray &sKey, signed long long i ); - //void insert( const QByteArray &sKey, bool b ); - void insert( const QByteArray &sKey, float d ); - void insert( const QByteArray &sKey, double d ); - using QHash::insert; - void insertBool( const QByteArray &sKey, bool b ); - void insertInt( const QByteArray &sKey, int64_t i ); - void insertFloat( const QByteArray &sKey, double d ); - void insertStr( const QByteArray &sKey, const QByteArray &s ); - void insertList( const QByteArray &sKey, Gats::List *pL ); - void insertDict( const QByteArray &sKey, Gats::Dictionary *pD ); - Gats::List *insertList( const QByteArray &sKey ); - Gats::Dictionary *insertDict( const QByteArray &sKey ); - - bool valueBool( const QByteArray &sKey ); - int64_t valueInt( const QByteArray &sKey ); - double valueFloat( const QByteArray &sKey ); - QByteArray valueStr( const QByteArray &sKey ); - Gats::List *valueList( const QByteArray &sKey ); - Gats::Dictionary *valueDict( const QByteArray &sKey ); - - bool valueBool( const QByteArray &sKey ) const; - int64_t valueInt( const QByteArray &sKey ) const; - double valueFloat( const QByteArray &sKey ) const; - QByteArray valueStr( const QByteArray &sKey ) const; - Gats::List *valueList( const QByteArray &sKey ) const; - Gats::Dictionary *valueDict( const QByteArray &sKey ) const; - }; -}; - -//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Dictionary &d ); - -#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 @@ -/* - * Copyright (C) 2007-2012 Xagasoft, All rights reserved. - * - * This file is part of the libgats library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#ifndef GATS_FLOAT_H -#define GATS_FLOAT_H - -#include "gats-qt/object.h" - -namespace Gats -{ - class Float : public Gats::Object - { - Q_OBJECT; - public: - Float(); - Float( double f ); - virtual ~Float(); - - virtual Object *clone() const; - - virtual Type getType() const { return typeFloat; } - double getValue() const { return fVal; } - - virtual void write( QIODevice &rOut ) const; - virtual void read( QIODevice &rIn, char cType ); - - private: - double fVal; - mutable QByteArray sWriteCache; - }; -} - -//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Float &flt ); - -#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 @@ -/* - * Copyright (C) 2007-2012 Xagasoft, All rights reserved. - * - * This file is part of the libgats library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#ifndef GATS_STREAM_H -#define GATS_STREAM_H - -#include -#include - -namespace Gats -{ - class Object; - - class GatsStream : public QObject - { - Q_OBJECT; - public: - GatsStream( QIODevice &rStream ); - virtual ~GatsStream(); - - public slots: - /** - * Read an object packet from the assosiated stream. This will make - * every effort to only read exactly enough data to describe one packet, - * in case you want to do other things with your stream. It will - * automatically skip NULL byte spacing between packets, which makes - * a convinient padding method for encrypted data streams. Since - * sizing information is available in the packet header exact amounts - * of data can be read, however this function doesn't assume that it - * can read the entire object in one operation. If it fails to read - * a complete packet in one call, it will keep the data it's read so - * far buffered and return NULL, ready for another attempt. You can - * use the function hasReadBuffer() to deterimne if readObject() - * has read part of an object packet or not. If readObject returns - * non-null then hasReadBuffer should return false on it's next call. - */ - Gats::Object *readObject(); - - /** - * Works exactly like readObject, except it reads all pending objects - * and emits a objectRead signal for each one read. It doesn't return - * anything. This is perfect for connecting to a QIODevice's readRead - * signal. - */ - void readAllObjects(); - - public: - /** - * Write an object - */ - void writeObject( Gats::Object *pObject ); - - /** - * Tells you if there is data still in the read buffer, i.e. that a - * packet is part way through being read. If readObject has returned - * non-null in the most recent call, this should always be false. - */ - bool hasReadBuffer() { return qbRead.size() > 0; } - int getReadBufferSize() { return qbRead.size(); } - - QIODevice &getIODevice() { return rStream; } - - signals: - void objectRead( Gats::Object *pObj ); - - private: - bool skipReadNulls(); - - private: - QIODevice &rStream; - QByteArray qbRead; - }; -}; - -#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 @@ -/* - * Copyright (C) 2007-2012 Xagasoft, All rights reserved. - * - * This file is part of the libgats library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#ifndef GATS_INTEGER_H -#define GATS_INTEGER_H - -#include "gats-qt/object.h" - -#include - -#include - -namespace Gats -{ - class Integer : public Gats::Object - { - Q_OBJECT; - public: - Integer(); - Integer( int64_t iVal ); - virtual ~Integer(); - - virtual Object *clone() const; - - virtual Type getType() const { return typeInteger; } - int64_t getValue() const { return iVal; } - void setValue( int64_t iNewVal ) { iVal = iNewVal; } - - virtual void write( QIODevice &rOut ) const; - virtual void read( QIODevice &rIn, char cType ); - - template - static void readPackedInt( QIODevice &rStream, itype &rOut ) - { - int8_t b; - rOut = 0; - bool bNeg; - - rStream.read( (char *)&b, 1 ); - bNeg = ( b&0x40 ); - rOut |= (itype(b&0x3F)); - int c = 0; - while( (b&0x80) ) - { - rStream.read( (char *)&b, 1 ); - rOut |= (itype(b&0x7F)) << (6+7*(c++)); - } - if( bNeg ) rOut = -rOut; - } - - template - static void writePackedInt( QIODevice &rStream, itype iIn ) - { - uint8_t b; - - if( iIn < 0 ) - { - iIn = -iIn; - b = (iIn&0x3F); - if( iIn > b ) - b |= 0x80 | 0x40; - else - b |= 0x40; - } - else - { - b = (iIn&0x3F); - if( iIn > b ) - b |= 0x80; - } - rStream.write( (const char *)&b, 1 ); - iIn = iIn >> 6; - - while( iIn ) - { - b = (iIn&0x7F); - if( iIn > b ) - b |= 0x80; - rStream.write( (const char *)&b, 1 ); - iIn = iIn >> 7; - } - } - - private: - int64_t iVal; - }; -}; - -//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Integer &i ); - -#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 @@ -/* - * Copyright (C) 2007-2012 Xagasoft, All rights reserved. - * - * This file is part of the libgats library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#ifndef GATS_LIST_H -#define GATS_LIST_H - -#include "gats-qt/object.h" -#include - -namespace Gats -{ - class Dictionary; - - class List : public Gats::Object, public QList - { - Q_OBJECT; - public: - List(); - virtual ~List(); - - virtual Object *clone() const; - - virtual Type getType() const { return typeList; } - - virtual void write( QIODevice &rOut ) const; - virtual void read( QIODevice &rIn, char cType ); - - void append( const char *s ); - void append( const QByteArray &s ); - void append( int32_t i ); - void append( int64_t i ); - void append( double d ); - using QList::append; - void appendStr( const QByteArray &s ); - void appendInt( int64_t i ); - void appendFloat( double d ); - void appendBool( bool b ); - void appendList( Gats::List *pL ); - void appendDict( Gats::Dictionary *pD ); - Gats::List *appendList(); - Gats::Dictionary *appendDict(); - - void prepend( const char *s ); - void prepend( const QByteArray &s ); - void prepend( int32_t i ); - void prepend( int64_t i ); - void prepend( double d ); - using QList::prepend; - void prependStr( const QByteArray &s ); - void prependInt( int64_t i ); - void prependFloat( double d ); - void prependBool( bool b ); - void prependList( Gats::List *pL ); - void prependDict( Gats::Dictionary *pD ); - Gats::List *prependList(); - Gats::Dictionary *prependDict(); - }; -}; - -//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::List &l ); - -#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 @@ -/* - * Copyright (C) 2007-2012 Xagasoft, All rights reserved. - * - * This file is part of the libgats library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#ifndef GATS_NULL_H -#define GATS_NULL_H - -#include "gats-qt/object.h" - -class QIODevice; - -namespace Gats -{ - class Null : public Gats::Object - { - Q_OBJECT; - public: - Null(); - virtual ~Null(); - - virtual Object *clone() const; - - virtual Type getType() const { return typeNull; } - - virtual void write( QIODevice &rOut ) const; - virtual void read( QIODevice &rIn, char cType ); - }; -}; - -//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Null &b ); - -#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 @@ -/* - * Copyright (C) 2007-2012 Xagasoft, All rights reserved. - * - * This file is part of the libgats library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#ifndef GATS_OBJECT_H -#define GATS_OBJECT_H - -#include -#include - -class QIODevice; - -namespace Gats -{ - enum Type - { - typeDictionary, - typeList, - typeString, - typeInteger, - typeFloat, - typeBoolean, - typeNull - }; - - /** - * The baseclass for every type that can be stored in a packet. - */ - class Object : public QObject - { - Q_OBJECT; - public: - Object(); - virtual ~Object(); - - virtual Object *clone() const=0; - - virtual Type getType() const =0; - - virtual void write( QIODevice &rOut ) const=0; - virtual void read( QIODevice &rIn, char cType )=0; - - static Object *read( QIODevice &rIn ); -// static Object *strToGats( const &sStr ); - - private: -// static Object *strToGats( QByteArray::const_iterator &i ); -// static QByteArray token( QByteArray::const_iterator &i ); -// static void skipWs( QByteArray::const_iterator &i ); - }; - - const char *typeToStr( Type t ); -}; - -//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Object &obj ); -//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Type &t ); - -#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 @@ -/* - * Copyright (C) 2007-2012 Xagasoft, All rights reserved. - * - * This file is part of the libgats library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#ifndef GATS_STRING_H -#define GATS_STRING_H - -#include "gats-qt/object.h" -#include - -namespace Gats -{ - class String : public Gats::Object, public QByteArray - { - Q_OBJECT; - public: - String(); - String( const char *s ); - String( const char *s, long iLength ); - String( long iLength ); - String( const String &s ); - String( const QByteArray &s ); - virtual ~String(); - - virtual Object *clone() const; - - virtual Type getType() const { return typeString; } - - virtual void write( QIODevice &rOut ) const; - virtual void read( QIODevice &rIn, char cType ); - - private: - }; -}; - -//Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::String &s ); - -#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 @@ -/* - * Copyright (C) 2007-2012 Xagasoft, All rights reserved. - * - * This file is part of the libgats library and is released under the - * terms of the license contained in the file LICENSE. - */ - -#include "gats-qt/object.h" -#include "gats-qt/boolean.h" -#include "gats-qt/dictionary.h" -#include "gats-qt/float.h" -#include "gats-qt/integer.h" -#include "gats-qt/list.h" -#include "gats-qt/string.h" -#include "gats-qt/null.h" -- cgit v1.2.3