diff options
Diffstat (limited to 'c++-qt/src')
-rw-r--r-- | c++-qt/src/boolean.cpp | 8 | ||||
-rw-r--r-- | c++-qt/src/dictionary.cpp | 46 | ||||
-rw-r--r-- | c++-qt/src/float.cpp | 6 | ||||
-rw-r--r-- | c++-qt/src/gatsstream.cpp | 7 | ||||
-rw-r--r-- | c++-qt/src/integer.cpp | 7 | ||||
-rw-r--r-- | c++-qt/src/list.cpp | 28 | ||||
-rw-r--r-- | c++-qt/src/null.cpp | 7 | ||||
-rw-r--r-- | c++-qt/src/object.cpp | 1 | ||||
-rw-r--r-- | c++-qt/src/string.cpp | 26 |
9 files changed, 128 insertions, 8 deletions
diff --git a/c++-qt/src/boolean.cpp b/c++-qt/src/boolean.cpp index bd9bca1..8e7317a 100644 --- a/c++-qt/src/boolean.cpp +++ b/c++-qt/src/boolean.cpp | |||
@@ -40,7 +40,7 @@ void Gats::Boolean::write( QIODevice &rOut ) const | |||
40 | } | 40 | } |
41 | } | 41 | } |
42 | 42 | ||
43 | void Gats::Boolean::read( QIODevice &rIn, char cType ) | 43 | void Gats::Boolean::read( QIODevice & /*rIn*/, char cType ) |
44 | { | 44 | { |
45 | if( cType == '1' ) | 45 | if( cType == '1' ) |
46 | { | 46 | { |
@@ -51,6 +51,12 @@ void Gats::Boolean::read( QIODevice &rIn, char cType ) | |||
51 | bVal = false; | 51 | bVal = false; |
52 | } | 52 | } |
53 | } | 53 | } |
54 | |||
55 | QString Gats::Boolean::toString( int /*iIndent*/ ) const | ||
56 | { | ||
57 | return bVal?"true":"false"; | ||
58 | } | ||
59 | |||
54 | /* | 60 | /* |
55 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Boolean &b ) | 61 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Boolean &b ) |
56 | { | 62 | { |
diff --git a/c++-qt/src/dictionary.cpp b/c++-qt/src/dictionary.cpp index 10ec6c5..1d666ac 100644 --- a/c++-qt/src/dictionary.cpp +++ b/c++-qt/src/dictionary.cpp | |||
@@ -73,6 +73,52 @@ void Gats::Dictionary::read( QIODevice &rIn, char /*cType*/ ) | |||
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | QString Gats::Dictionary::toString( int iIndent ) const | ||
77 | { | ||
78 | if( count() == 0 ) | ||
79 | return "{ }"; | ||
80 | QString sRet("{"); | ||
81 | iIndent++; | ||
82 | for( const_iterator i = begin(); i != end(); i++ ) | ||
83 | { | ||
84 | if( i == begin() ) | ||
85 | { | ||
86 | sRet += "\n"; | ||
87 | } | ||
88 | else | ||
89 | { | ||
90 | sRet += ",\n"; | ||
91 | } | ||
92 | for( int j = 0; j < iIndent; j++ ) sRet += " "; | ||
93 | sRet += '"'; | ||
94 | for( QByteArray::const_iterator iS = i.key().begin(); | ||
95 | iS != i.key().end(); iS++ ) | ||
96 | { | ||
97 | switch( *iS ) | ||
98 | { | ||
99 | case '\\': | ||
100 | sRet += "\\"; | ||
101 | break; | ||
102 | |||
103 | case '\"': | ||
104 | sRet += "\\\""; | ||
105 | break; | ||
106 | |||
107 | default: | ||
108 | sRet += *iS; | ||
109 | break; | ||
110 | } | ||
111 | } | ||
112 | sRet += "\": "; | ||
113 | sRet += i.value()->toString( iIndent ); | ||
114 | } | ||
115 | iIndent--; | ||
116 | sRet += "\n"; | ||
117 | for( int j = 0; j < iIndent; j++ ) sRet += " "; | ||
118 | sRet += "}"; | ||
119 | return sRet; | ||
120 | } | ||
121 | |||
76 | void Gats::Dictionary::insert( const QByteArray &sKey, char i ) | 122 | void Gats::Dictionary::insert( const QByteArray &sKey, char i ) |
77 | { | 123 | { |
78 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 124 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
diff --git a/c++-qt/src/float.cpp b/c++-qt/src/float.cpp index 7f0d1a3..d4ec76e 100644 --- a/c++-qt/src/float.cpp +++ b/c++-qt/src/float.cpp | |||
@@ -126,6 +126,12 @@ void Gats::Float::read( QIODevice &rIn, char cType ) | |||
126 | if( bNeg ) fVal = -fVal; | 126 | if( bNeg ) fVal = -fVal; |
127 | } | 127 | } |
128 | } | 128 | } |
129 | |||
130 | QString Gats::Float::toString( int /*iIndent*/ ) const | ||
131 | { | ||
132 | return QString("%1").arg( fVal ); | ||
133 | } | ||
134 | |||
129 | /* | 135 | /* |
130 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Float &flt ) | 136 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Float &flt ) |
131 | { | 137 | { |
diff --git a/c++-qt/src/gatsstream.cpp b/c++-qt/src/gatsstream.cpp index cb6b53c..36b2ba8 100644 --- a/c++-qt/src/gatsstream.cpp +++ b/c++-qt/src/gatsstream.cpp | |||
@@ -42,8 +42,9 @@ Gats::Object *Gats::GatsStream::readObject() | |||
42 | } | 42 | } |
43 | } while( !skipReadNulls() ); | 43 | } while( !skipReadNulls() ); |
44 | 44 | ||
45 | uint8_t uVer; | 45 | // There's only one version, so...we don't need to do anything with this |
46 | uVer = qbRead[0]; | 46 | //uint8_t uVer; |
47 | //uVer = qbRead[0]; | ||
47 | 48 | ||
48 | int32_t iSize; | 49 | int32_t iSize; |
49 | memcpy( &iSize, qbRead.constData()+1, 4 ); | 50 | memcpy( &iSize, qbRead.constData()+1, 4 ); |
@@ -102,7 +103,7 @@ void Gats::GatsStream::writeObject( Gats::Object *pObject ) | |||
102 | pTmp->write( (const char *)&iSize, 4 ); | 103 | pTmp->write( (const char *)&iSize, 4 ); |
103 | pObject->write( *pTmp ); | 104 | pObject->write( *pTmp ); |
104 | iSize = htonl( pTmp->pos() ); | 105 | iSize = htonl( pTmp->pos() ); |
105 | uint64_t iEndPos = pTmp->pos(); | 106 | //uint64_t iEndPos = pTmp->pos(); |
106 | pTmp->seek( iSizePos ); | 107 | pTmp->seek( iSizePos ); |
107 | pTmp->write( (const char *)&iSize, 4 ); | 108 | pTmp->write( (const char *)&iSize, 4 ); |
108 | 109 | ||
diff --git a/c++-qt/src/integer.cpp b/c++-qt/src/integer.cpp index 967eb30..1c665b4 100644 --- a/c++-qt/src/integer.cpp +++ b/c++-qt/src/integer.cpp | |||
@@ -32,10 +32,15 @@ void Gats::Integer::write( QIODevice &rOut ) const | |||
32 | writePackedInt( rOut, iVal ); | 32 | writePackedInt( rOut, iVal ); |
33 | } | 33 | } |
34 | 34 | ||
35 | void Gats::Integer::read( QIODevice &rIn, char cType ) | 35 | void Gats::Integer::read( QIODevice &rIn, char /*cType*/ ) |
36 | { | 36 | { |
37 | readPackedInt( rIn, iVal ); | 37 | readPackedInt( rIn, iVal ); |
38 | } | 38 | } |
39 | |||
40 | QString Gats::Integer::toString( int /*iIndent*/ ) const | ||
41 | { | ||
42 | return QString("%1").arg( iVal ); | ||
43 | } | ||
39 | /* | 44 | /* |
40 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Integer &i ) | 45 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Integer &i ) |
41 | { | 46 | { |
diff --git a/c++-qt/src/list.cpp b/c++-qt/src/list.cpp index fae51d1..cca7c46 100644 --- a/c++-qt/src/list.cpp +++ b/c++-qt/src/list.cpp | |||
@@ -48,7 +48,7 @@ void Gats::List::write( QIODevice &rOut ) const | |||
48 | rOut.write("e", 1 ); | 48 | rOut.write("e", 1 ); |
49 | } | 49 | } |
50 | 50 | ||
51 | void Gats::List::read( QIODevice &rIn, char cType ) | 51 | void Gats::List::read( QIODevice &rIn, char /*cType*/ ) |
52 | { | 52 | { |
53 | for(;;) | 53 | for(;;) |
54 | { | 54 | { |
@@ -59,6 +59,32 @@ void Gats::List::read( QIODevice &rIn, char cType ) | |||
59 | } | 59 | } |
60 | } | 60 | } |
61 | 61 | ||
62 | QString Gats::List::toString( int iIndent ) const | ||
63 | { | ||
64 | if( count() == 0 ) | ||
65 | return "[ ]"; | ||
66 | QString sRet("["); | ||
67 | iIndent++; | ||
68 | for( const_iterator i = begin(); i != end(); i++ ) | ||
69 | { | ||
70 | if( i != begin() ) | ||
71 | { | ||
72 | sRet += ",\n"; | ||
73 | } | ||
74 | else | ||
75 | { | ||
76 | sRet += "\n"; | ||
77 | } | ||
78 | for( int j = 0; j < iIndent; j++ ) sRet += " "; | ||
79 | sRet += (*i)->toString( iIndent ); | ||
80 | } | ||
81 | sRet += "\n"; | ||
82 | iIndent--; | ||
83 | for( int j = 0; j < iIndent; j++ ) sRet += " "; | ||
84 | sRet += ']'; | ||
85 | return sRet; | ||
86 | } | ||
87 | |||
62 | void Gats::List::append( const char *s ) | 88 | void Gats::List::append( const char *s ) |
63 | { | 89 | { |
64 | QList<Gats::Object *>::append( new Gats::String( s ) ); | 90 | QList<Gats::Object *>::append( new Gats::String( s ) ); |
diff --git a/c++-qt/src/null.cpp b/c++-qt/src/null.cpp index 8bc87a6..5e3a19c 100644 --- a/c++-qt/src/null.cpp +++ b/c++-qt/src/null.cpp | |||
@@ -27,9 +27,14 @@ void Gats::Null::write( QIODevice &rOut ) const | |||
27 | rOut.write("n", 1 ); | 27 | rOut.write("n", 1 ); |
28 | } | 28 | } |
29 | 29 | ||
30 | void Gats::Null::read( QIODevice &rIn, char cType ) | 30 | void Gats::Null::read( QIODevice & /*rIn*/, char /*cType*/ ) |
31 | { | 31 | { |
32 | } | 32 | } |
33 | |||
34 | QString Gats::Null::toString( int /*iIndent*/ ) const | ||
35 | { | ||
36 | return "null"; | ||
37 | } | ||
33 | /* | 38 | /* |
34 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Null &b ) | 39 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Null &b ) |
35 | { | 40 | { |
diff --git a/c++-qt/src/object.cpp b/c++-qt/src/object.cpp index 8af203f..b0f0f12 100644 --- a/c++-qt/src/object.cpp +++ b/c++-qt/src/object.cpp | |||
@@ -88,6 +88,7 @@ const char *Gats::typeToStr( Gats::Type t ) | |||
88 | case Gats::typeInteger: return "integer"; | 88 | case Gats::typeInteger: return "integer"; |
89 | case Gats::typeFloat: return "float"; | 89 | case Gats::typeFloat: return "float"; |
90 | case Gats::typeBoolean: return "boolean"; | 90 | case Gats::typeBoolean: return "boolean"; |
91 | case Gats::typeNull: return "null"; | ||
91 | } | 92 | } |
92 | 93 | ||
93 | return "***unknown***"; | 94 | return "***unknown***"; |
diff --git a/c++-qt/src/string.cpp b/c++-qt/src/string.cpp index 1eddcf6..fd6cad1 100644 --- a/c++-qt/src/string.cpp +++ b/c++-qt/src/string.cpp | |||
@@ -57,13 +57,37 @@ void Gats::String::write( QIODevice &rOut ) const | |||
57 | rOut.write( constData(), iSize ); | 57 | rOut.write( constData(), iSize ); |
58 | } | 58 | } |
59 | 59 | ||
60 | void Gats::String::read( QIODevice &rIn, char cType ) | 60 | void Gats::String::read( QIODevice &rIn, char /*cType*/ ) |
61 | { | 61 | { |
62 | uint32_t iSize; | 62 | uint32_t iSize; |
63 | Gats::Integer::readPackedInt( rIn, iSize ); | 63 | Gats::Integer::readPackedInt( rIn, iSize ); |
64 | fill( '\0', iSize ); | 64 | fill( '\0', iSize ); |
65 | rIn.read( data(), iSize ); | 65 | rIn.read( data(), iSize ); |
66 | } | 66 | } |
67 | |||
68 | QString Gats::String::toString( int /*iIndent*/ ) const | ||
69 | { | ||
70 | QString sRet("\""); | ||
71 | for( const_iterator iS = begin(); iS != end(); iS++ ) | ||
72 | { | ||
73 | switch( *iS ) | ||
74 | { | ||
75 | case '\\': | ||
76 | sRet += "\\"; | ||
77 | break; | ||
78 | |||
79 | case '\"': | ||
80 | sRet += "\\\""; | ||
81 | break; | ||
82 | |||
83 | default: | ||
84 | sRet += *iS; | ||
85 | break; | ||
86 | } | ||
87 | } | ||
88 | sRet += "\""; | ||
89 | return sRet; | ||
90 | } | ||
67 | /* | 91 | /* |
68 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::String &s ) | 92 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::String &s ) |
69 | { | 93 | { |