diff options
Diffstat (limited to '')
-rw-r--r-- | c++-qt/src/boolean.cpp | 47 | ||||
-rw-r--r-- | c++-qt/src/boolean.h | 47 | ||||
-rw-r--r-- | c++-qt/src/dictionary.cpp | 351 | ||||
-rw-r--r-- | c++-qt/src/dictionary.h | 109 | ||||
-rw-r--r-- | c++-qt/src/float.cpp | 193 | ||||
-rw-r--r-- | c++-qt/src/float.h | 47 | ||||
-rw-r--r-- | c++-qt/src/gatsstream.cpp | 195 | ||||
-rw-r--r-- | c++-qt/src/gatsstream.h | 113 | ||||
-rw-r--r-- | c++-qt/src/integer.cpp | 21 | ||||
-rw-r--r-- | c++-qt/src/integer.h | 151 | ||||
-rw-r--r-- | c++-qt/src/list.cpp | 139 | ||||
-rw-r--r-- | c++-qt/src/list.h | 99 | ||||
-rw-r--r-- | c++-qt/src/null.cpp | 13 | ||||
-rw-r--r-- | c++-qt/src/null.h | 29 | ||||
-rw-r--r-- | c++-qt/src/object.cpp | 463 | ||||
-rw-r--r-- | c++-qt/src/object.h | 83 | ||||
-rw-r--r-- | c++-qt/src/string.cpp | 41 | ||||
-rw-r--r-- | c++-qt/src/string.h | 49 | ||||
-rw-r--r-- | c++-qt/src/types.h | 7 |
19 files changed, 1165 insertions, 1032 deletions
diff --git a/c++-qt/src/boolean.cpp b/c++-qt/src/boolean.cpp index 3973607..1195bae 100644 --- a/c++-qt/src/boolean.cpp +++ b/c++-qt/src/boolean.cpp | |||
@@ -1,14 +1,21 @@ | |||
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 | |||
1 | #include "gats-qt/boolean.h" | 8 | #include "gats-qt/boolean.h" |
2 | 9 | ||
3 | #include <QIODevice> | 10 | #include <QIODevice> |
4 | 11 | ||
5 | Gats::Boolean::Boolean() : | 12 | Gats::Boolean::Boolean() : |
6 | bVal( false ) | 13 | bVal( false ) |
7 | { | 14 | { |
8 | } | 15 | } |
9 | 16 | ||
10 | Gats::Boolean::Boolean( bool bVal ) : | 17 | Gats::Boolean::Boolean( bool bVal ) : |
11 | bVal( bVal ) | 18 | bVal( bVal ) |
12 | { | 19 | { |
13 | } | 20 | } |
14 | 21 | ||
@@ -18,35 +25,35 @@ Gats::Boolean::~Boolean() | |||
18 | 25 | ||
19 | Gats::Object *Gats::Boolean::clone() const | 26 | Gats::Object *Gats::Boolean::clone() const |
20 | { | 27 | { |
21 | return new Gats::Boolean( bVal ); | 28 | return new Gats::Boolean( bVal ); |
22 | } | 29 | } |
23 | 30 | ||
24 | void Gats::Boolean::write( QIODevice &rOut ) const | 31 | void Gats::Boolean::write( QIODevice &rOut ) const |
25 | { | 32 | { |
26 | if( bVal ) | 33 | if( bVal ) |
27 | { | 34 | { |
28 | rOut.write("1", 1 ); | 35 | rOut.write("1", 1 ); |
29 | } | 36 | } |
30 | else | 37 | else |
31 | { | 38 | { |
32 | rOut.write("0", 1 ); | 39 | rOut.write("0", 1 ); |
33 | } | 40 | } |
34 | } | 41 | } |
35 | 42 | ||
36 | void Gats::Boolean::read( QIODevice &rIn, char cType ) | 43 | void Gats::Boolean::read( QIODevice &rIn, char cType ) |
37 | { | 44 | { |
38 | if( cType == '1' ) | 45 | if( cType == '1' ) |
39 | { | 46 | { |
40 | bVal = true; | 47 | bVal = true; |
41 | } | 48 | } |
42 | else | 49 | else |
43 | { | 50 | { |
44 | bVal = false; | 51 | bVal = false; |
45 | } | 52 | } |
46 | } | 53 | } |
47 | /* | 54 | /* |
48 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Boolean &b ) | 55 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Boolean &b ) |
49 | { | 56 | { |
50 | return f << "(bool) " << b.getValue(); | 57 | return f << "(bool) " << b.getValue(); |
51 | } | 58 | } |
52 | */ | 59 | */ |
diff --git a/c++-qt/src/boolean.h b/c++-qt/src/boolean.h index d707e4d..7e42981 100644 --- a/c++-qt/src/boolean.h +++ b/c++-qt/src/boolean.h | |||
@@ -1,3 +1,10 @@ | |||
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 | |||
1 | #ifndef GATS_BOOLEAN_H | 8 | #ifndef GATS_BOOLEAN_H |
2 | #define GATS_BOOLEAN_H | 9 | #define GATS_BOOLEAN_H |
3 | 10 | ||
@@ -7,26 +14,26 @@ class QIODevice; | |||
7 | 14 | ||
8 | namespace Gats | 15 | namespace Gats |
9 | { | 16 | { |
10 | class Boolean : public Gats::Object | 17 | class Boolean : public Gats::Object |
11 | { | 18 | { |
12 | Q_OBJECT; | 19 | Q_OBJECT; |
13 | public: | 20 | public: |
14 | Boolean(); | 21 | Boolean(); |
15 | Boolean( bool bVal ); | 22 | Boolean( bool bVal ); |
16 | virtual ~Boolean(); | 23 | virtual ~Boolean(); |
17 | 24 | ||
18 | virtual Object *clone() const; | 25 | virtual Object *clone() const; |
19 | 26 | ||
20 | virtual Type getType() const { return typeBoolean; } | 27 | virtual Type getType() const { return typeBoolean; } |
21 | bool getValue() const { return bVal; } | 28 | bool getValue() const { return bVal; } |
22 | void setValue( bool b ) { bVal = b; } | 29 | void setValue( bool b ) { bVal = b; } |
23 | 30 | ||
24 | virtual void write( QIODevice &rOut ) const; | 31 | virtual void write( QIODevice &rOut ) const; |
25 | virtual void read( QIODevice &rIn, char cType ); | 32 | virtual void read( QIODevice &rIn, char cType ); |
26 | 33 | ||
27 | private: | 34 | private: |
28 | bool bVal; | 35 | bool bVal; |
29 | }; | 36 | }; |
30 | }; | 37 | }; |
31 | 38 | ||
32 | //Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Boolean &b ); | 39 | //Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Boolean &b ); |
diff --git a/c++-qt/src/dictionary.cpp b/c++-qt/src/dictionary.cpp index edcbdb1..b2ef35e 100644 --- a/c++-qt/src/dictionary.cpp +++ b/c++-qt/src/dictionary.cpp | |||
@@ -1,3 +1,10 @@ | |||
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 | |||
1 | #include "gats-qt/dictionary.h" | 8 | #include "gats-qt/dictionary.h" |
2 | 9 | ||
3 | #include "gats-qt/boolean.h" | 10 | #include "gats-qt/boolean.h" |
@@ -12,352 +19,352 @@ Gats::Dictionary::Dictionary() | |||
12 | 19 | ||
13 | Gats::Dictionary::~Dictionary() | 20 | Gats::Dictionary::~Dictionary() |
14 | { | 21 | { |
15 | for( iterator i = begin(); i != end(); i++ ) | 22 | for( iterator i = begin(); i != end(); i++ ) |
16 | { | 23 | { |
17 | delete *i; | 24 | delete *i; |
18 | } | 25 | } |
19 | } | 26 | } |
20 | 27 | ||
21 | Gats::Object *Gats::Dictionary::clone() const | 28 | Gats::Object *Gats::Dictionary::clone() const |
22 | { | 29 | { |
23 | Gats::Dictionary *pClone = new Gats::Dictionary; | 30 | Gats::Dictionary *pClone = new Gats::Dictionary; |
24 | 31 | ||
25 | for( const_iterator i = begin(); i != end(); i++ ) | 32 | for( const_iterator i = begin(); i != end(); i++ ) |
26 | { | 33 | { |
27 | QByteArray bKey = i.key(); | 34 | QByteArray bKey = i.key(); |
28 | bKey.detach(); | 35 | bKey.detach(); |
29 | pClone->insert( bKey, (*i)->clone() ); | 36 | pClone->insert( bKey, (*i)->clone() ); |
30 | } | 37 | } |
31 | 38 | ||
32 | return pClone; | 39 | return pClone; |
33 | } | 40 | } |
34 | 41 | ||
35 | void Gats::Dictionary::write( QIODevice &rOut ) const | 42 | void Gats::Dictionary::write( QIODevice &rOut ) const |
36 | { | 43 | { |
37 | rOut.write("d", 1 ); | 44 | rOut.write("d", 1 ); |
38 | for( const_iterator i= begin(); i != end(); i++ ) | 45 | for( const_iterator i= begin(); i != end(); i++ ) |
39 | { | 46 | { |
40 | Gats::String s( i.key() ); | 47 | Gats::String s( i.key() ); |
41 | s.write( rOut ); | 48 | s.write( rOut ); |
42 | (*i)->write( rOut ); | 49 | (*i)->write( rOut ); |
43 | } | 50 | } |
44 | rOut.write("e", 1 ); | 51 | rOut.write("e", 1 ); |
45 | } | 52 | } |
46 | 53 | ||
47 | void Gats::Dictionary::read( QIODevice &rIn, char cType ) | 54 | void Gats::Dictionary::read( QIODevice &rIn, char cType ) |
48 | { | 55 | { |
49 | for(;;) | 56 | for(;;) |
50 | { | 57 | { |
51 | char cNext; | 58 | char cNext; |
52 | rIn.read( &cNext, 1 ); | 59 | rIn.read( &cNext, 1 ); |
53 | if( cNext == 'e' ) | 60 | if( cNext == 'e' ) |
54 | break; | 61 | break; |
55 | if( cNext != 's' ) | 62 | if( cNext != 's' ) |
56 | throw "PUT GOOD EXCEPTION HERE"; | 63 | throw "PUT GOOD EXCEPTION HERE"; |
57 | Gats::String sKey; | 64 | Gats::String sKey; |
58 | sKey.read( rIn, cNext ); | 65 | sKey.read( rIn, cNext ); |
59 | 66 | ||
60 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 67 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
61 | sKey, Gats::Object::read( rIn ) | 68 | sKey, Gats::Object::read( rIn ) |
62 | ); | 69 | ); |
63 | } | 70 | } |
64 | } | 71 | } |
65 | 72 | ||
66 | void Gats::Dictionary::insert( const QByteArray &sKey, char i ) | 73 | void Gats::Dictionary::insert( const QByteArray &sKey, char i ) |
67 | { | 74 | { |
68 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 75 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
69 | sKey, new Gats::Integer( i ) | 76 | sKey, new Gats::Integer( i ) |
70 | ); | 77 | ); |
71 | } | 78 | } |
72 | 79 | ||
73 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned char i ) | 80 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned char i ) |
74 | { | 81 | { |
75 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 82 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
76 | sKey, new Gats::Integer( i ) | 83 | sKey, new Gats::Integer( i ) |
77 | ); | 84 | ); |
78 | } | 85 | } |
79 | 86 | ||
80 | void Gats::Dictionary::insert( const QByteArray &sKey, signed char i ) | 87 | void Gats::Dictionary::insert( const QByteArray &sKey, signed char i ) |
81 | { | 88 | { |
82 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 89 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
83 | sKey, new Gats::Integer( i ) | 90 | sKey, new Gats::Integer( i ) |
84 | ); | 91 | ); |
85 | } | 92 | } |
86 | 93 | ||
87 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned short i ) | 94 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned short i ) |
88 | { | 95 | { |
89 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 96 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
90 | sKey, new Gats::Integer( i ) | 97 | sKey, new Gats::Integer( i ) |
91 | ); | 98 | ); |
92 | } | 99 | } |
93 | 100 | ||
94 | void Gats::Dictionary::insert( const QByteArray &sKey, signed short i ) | 101 | void Gats::Dictionary::insert( const QByteArray &sKey, signed short i ) |
95 | { | 102 | { |
96 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 103 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
97 | sKey, new Gats::Integer( i ) | 104 | sKey, new Gats::Integer( i ) |
98 | ); | 105 | ); |
99 | } | 106 | } |
100 | 107 | ||
101 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned int i ) | 108 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned int i ) |
102 | { | 109 | { |
103 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 110 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
104 | sKey, new Gats::Integer( i ) | 111 | sKey, new Gats::Integer( i ) |
105 | ); | 112 | ); |
106 | } | 113 | } |
107 | 114 | ||
108 | void Gats::Dictionary::insert( const QByteArray &sKey, signed int i ) | 115 | void Gats::Dictionary::insert( const QByteArray &sKey, signed int i ) |
109 | { | 116 | { |
110 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 117 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
111 | sKey, new Gats::Integer( i ) | 118 | sKey, new Gats::Integer( i ) |
112 | ); | 119 | ); |
113 | } | 120 | } |
114 | 121 | ||
115 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned long i ) | 122 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned long i ) |
116 | { | 123 | { |
117 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 124 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
118 | sKey, new Gats::Integer( i ) | 125 | sKey, new Gats::Integer( i ) |
119 | ); | 126 | ); |
120 | } | 127 | } |
121 | 128 | ||
122 | void Gats::Dictionary::insert( const QByteArray &sKey, signed long i ) | 129 | void Gats::Dictionary::insert( const QByteArray &sKey, signed long i ) |
123 | { | 130 | { |
124 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 131 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
125 | sKey, new Gats::Integer( i ) | 132 | sKey, new Gats::Integer( i ) |
126 | ); | 133 | ); |
127 | } | 134 | } |
128 | 135 | ||
129 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned long long i ) | 136 | void Gats::Dictionary::insert( const QByteArray &sKey, unsigned long long i ) |
130 | { | 137 | { |
131 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 138 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
132 | sKey, new Gats::Integer( i ) | 139 | sKey, new Gats::Integer( i ) |
133 | ); | 140 | ); |
134 | } | 141 | } |
135 | 142 | ||
136 | void Gats::Dictionary::insert( const QByteArray &sKey, signed long long i ) | 143 | void Gats::Dictionary::insert( const QByteArray &sKey, signed long long i ) |
137 | { | 144 | { |
138 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( | 145 | ((QHash<QByteArray, Gats::Object *> *)this)->insert( |
139 | sKey, new Gats::Integer( i ) | 146 | sKey, new Gats::Integer( i ) |
140 | ); | 147 | ); |
141 | } | 148 | } |
142 | /* | 149 | /* |
143 | void Gats::Dictionary::insert( const QByteArray &sKey, bool b ) | 150 | void Gats::Dictionary::insert( const QByteArray &sKey, bool b ) |
144 | { | 151 | { |
145 | QHash<QByteArray, Gats::Object *>::insert( | 152 | QHash<QByteArray, Gats::Object *>::insert( |
146 | sKey, new Gats::Boolean( b ) | 153 | sKey, new Gats::Boolean( b ) |
147 | ); | 154 | ); |
148 | }*/ | 155 | }*/ |
149 | 156 | ||
150 | void Gats::Dictionary::insert( const QByteArray &sKey, float d ) | 157 | void Gats::Dictionary::insert( const QByteArray &sKey, float d ) |
151 | { | 158 | { |
152 | QHash<QByteArray, Gats::Object *>::insert( | 159 | QHash<QByteArray, Gats::Object *>::insert( |
153 | sKey, new Gats::Float( d ) | 160 | sKey, new Gats::Float( d ) |
154 | ); | 161 | ); |
155 | } | 162 | } |
156 | 163 | ||
157 | void Gats::Dictionary::insert( const QByteArray &sKey, double d ) | 164 | void Gats::Dictionary::insert( const QByteArray &sKey, double d ) |
158 | { | 165 | { |
159 | QHash<QByteArray, Gats::Object *>::insert( | 166 | QHash<QByteArray, Gats::Object *>::insert( |
160 | sKey, new Gats::Float( d ) | 167 | sKey, new Gats::Float( d ) |
161 | ); | 168 | ); |
162 | } | 169 | } |
163 | 170 | ||
164 | void Gats::Dictionary::insert( const QByteArray &sKey, const char *s ) | 171 | void Gats::Dictionary::insert( const QByteArray &sKey, const char *s ) |
165 | { | 172 | { |
166 | QHash<QByteArray, Gats::Object *>::insert( | 173 | QHash<QByteArray, Gats::Object *>::insert( |
167 | sKey, new Gats::String( s ) | 174 | sKey, new Gats::String( s ) |
168 | ); | 175 | ); |
169 | } | 176 | } |
170 | 177 | ||
171 | void Gats::Dictionary::insert( const QByteArray &sKey, const QByteArray &s ) | 178 | void Gats::Dictionary::insert( const QByteArray &sKey, const QByteArray &s ) |
172 | { | 179 | { |
173 | QHash<QByteArray, Gats::Object *>::insert( | 180 | QHash<QByteArray, Gats::Object *>::insert( |
174 | sKey, new Gats::String( s ) | 181 | sKey, new Gats::String( s ) |
175 | ); | 182 | ); |
176 | } | 183 | } |
177 | 184 | ||
178 | void Gats::Dictionary::insertBool( const QByteArray &sKey, bool b ) | 185 | void Gats::Dictionary::insertBool( const QByteArray &sKey, bool b ) |
179 | { | 186 | { |
180 | QHash<QByteArray, Gats::Object *>::insert( | 187 | QHash<QByteArray, Gats::Object *>::insert( |
181 | sKey, new Gats::Boolean( b ) | 188 | sKey, new Gats::Boolean( b ) |
182 | ); | 189 | ); |
183 | } | 190 | } |
184 | 191 | ||
185 | void Gats::Dictionary::insertInt( const QByteArray &sKey, int64_t i ) | 192 | void Gats::Dictionary::insertInt( const QByteArray &sKey, int64_t i ) |
186 | { | 193 | { |
187 | QHash<QByteArray, Gats::Object *>::insert( | 194 | QHash<QByteArray, Gats::Object *>::insert( |
188 | sKey, new Gats::Integer( i ) | 195 | sKey, new Gats::Integer( i ) |
189 | ); | 196 | ); |
190 | } | 197 | } |
191 | 198 | ||
192 | void Gats::Dictionary::insertFloat( const QByteArray &sKey, double d ) | 199 | void Gats::Dictionary::insertFloat( const QByteArray &sKey, double d ) |
193 | { | 200 | { |
194 | QHash<QByteArray, Gats::Object *>::insert( | 201 | QHash<QByteArray, Gats::Object *>::insert( |
195 | sKey, new Gats::Float( d ) | 202 | sKey, new Gats::Float( d ) |
196 | ); | 203 | ); |
197 | } | 204 | } |
198 | 205 | ||
199 | void Gats::Dictionary::insertStr( const QByteArray &sKey, const QByteArray &s ) | 206 | void Gats::Dictionary::insertStr( const QByteArray &sKey, const QByteArray &s ) |
200 | { | 207 | { |
201 | QHash<QByteArray, Gats::Object *>::insert( | 208 | QHash<QByteArray, Gats::Object *>::insert( |
202 | sKey, new Gats::String( s ) | 209 | sKey, new Gats::String( s ) |
203 | ); | 210 | ); |
204 | } | 211 | } |
205 | 212 | ||
206 | void Gats::Dictionary::insertList( const QByteArray &sKey, Gats::List *pL ) | 213 | void Gats::Dictionary::insertList( const QByteArray &sKey, Gats::List *pL ) |
207 | { | 214 | { |
208 | QHash<QByteArray, Gats::Object *>::insert( | 215 | QHash<QByteArray, Gats::Object *>::insert( |
209 | sKey, pL | 216 | sKey, pL |
210 | ); | 217 | ); |
211 | } | 218 | } |
212 | 219 | ||
213 | void Gats::Dictionary::insertDict( const QByteArray &sKey, | 220 | void Gats::Dictionary::insertDict( const QByteArray &sKey, |
214 | Gats::Dictionary *pD ) | 221 | Gats::Dictionary *pD ) |
215 | { | 222 | { |
216 | QHash<QByteArray, Gats::Object *>::insert( | 223 | QHash<QByteArray, Gats::Object *>::insert( |
217 | sKey, pD | 224 | sKey, pD |
218 | ); | 225 | ); |
219 | } | 226 | } |
220 | 227 | ||
221 | Gats::List *Gats::Dictionary::insertList( const QByteArray &sKey ) | 228 | Gats::List *Gats::Dictionary::insertList( const QByteArray &sKey ) |
222 | { | 229 | { |
223 | Gats::List *pLst = new Gats::List(); | 230 | Gats::List *pLst = new Gats::List(); |
224 | insertList( sKey, pLst ); | 231 | insertList( sKey, pLst ); |
225 | return pLst; | 232 | return pLst; |
226 | } | 233 | } |
227 | 234 | ||
228 | Gats::Dictionary *Gats::Dictionary::insertDict( const QByteArray &sKey ) | 235 | Gats::Dictionary *Gats::Dictionary::insertDict( const QByteArray &sKey ) |
229 | { | 236 | { |
230 | Gats::Dictionary *pDict = new Gats::Dictionary(); | 237 | Gats::Dictionary *pDict = new Gats::Dictionary(); |
231 | insertDict( sKey, pDict ); | 238 | insertDict( sKey, pDict ); |
232 | return pDict; | 239 | return pDict; |
233 | } | 240 | } |
234 | 241 | ||
235 | bool Gats::Dictionary::valueBool( const QByteArray &sKey ) | 242 | bool Gats::Dictionary::valueBool( const QByteArray &sKey ) |
236 | { | 243 | { |
237 | Gats::Boolean *pOb = dynamic_cast<Gats::Boolean *>( value( sKey ) ); | 244 | Gats::Boolean *pOb = dynamic_cast<Gats::Boolean *>( value( sKey ) ); |
238 | if( !pOb ) | 245 | if( !pOb ) |
239 | throw "PUT GOOD EXCEPTION HERE"; | 246 | throw "PUT GOOD EXCEPTION HERE"; |
240 | 247 | ||
241 | return pOb->getValue(); | 248 | return pOb->getValue(); |
242 | } | 249 | } |
243 | 250 | ||
244 | int64_t Gats::Dictionary::valueInt( const QByteArray &sKey ) | 251 | int64_t Gats::Dictionary::valueInt( const QByteArray &sKey ) |
245 | { | 252 | { |
246 | Gats::Integer *pOb = dynamic_cast<Gats::Integer *>( value( sKey ) ); | 253 | Gats::Integer *pOb = dynamic_cast<Gats::Integer *>( value( sKey ) ); |
247 | if( !pOb ) | 254 | if( !pOb ) |
248 | throw "PUT GOOD EXCEPTION HERE"; | 255 | throw "PUT GOOD EXCEPTION HERE"; |
249 | 256 | ||
250 | return pOb->getValue(); | 257 | return pOb->getValue(); |
251 | } | 258 | } |
252 | 259 | ||
253 | double Gats::Dictionary::valueFloat( const QByteArray &sKey ) | 260 | double Gats::Dictionary::valueFloat( const QByteArray &sKey ) |
254 | { | 261 | { |
255 | Gats::Float *pOb = dynamic_cast<Gats::Float *>( value( sKey ) ); | 262 | Gats::Float *pOb = dynamic_cast<Gats::Float *>( value( sKey ) ); |
256 | if( !pOb ) | 263 | if( !pOb ) |
257 | throw "PUT GOOD EXCEPTION HERE"; | 264 | throw "PUT GOOD EXCEPTION HERE"; |
258 | 265 | ||
259 | return pOb->getValue(); | 266 | return pOb->getValue(); |
260 | } | 267 | } |
261 | 268 | ||
262 | QByteArray Gats::Dictionary::valueStr( const QByteArray &sKey ) | 269 | QByteArray Gats::Dictionary::valueStr( const QByteArray &sKey ) |
263 | { | 270 | { |
264 | Gats::String *pOb = dynamic_cast<Gats::String *>( value( sKey ) ); | 271 | Gats::String *pOb = dynamic_cast<Gats::String *>( value( sKey ) ); |
265 | if( !pOb ) | 272 | if( !pOb ) |
266 | throw "PUT GOOD EXCEPTION HERE"; | 273 | throw "PUT GOOD EXCEPTION HERE"; |
267 | 274 | ||
268 | return *pOb; | 275 | return *pOb; |
269 | } | 276 | } |
270 | 277 | ||
271 | Gats::List *Gats::Dictionary::valueList( const QByteArray &sKey ) | 278 | Gats::List *Gats::Dictionary::valueList( const QByteArray &sKey ) |
272 | { | 279 | { |
273 | Gats::List *pOb = dynamic_cast<Gats::List *>( value( sKey ) ); | 280 | Gats::List *pOb = dynamic_cast<Gats::List *>( value( sKey ) ); |
274 | if( !pOb ) | 281 | if( !pOb ) |
275 | throw "PUT GOOD EXCEPTION HERE"; | 282 | throw "PUT GOOD EXCEPTION HERE"; |
276 | 283 | ||
277 | return pOb; | 284 | return pOb; |
278 | } | 285 | } |
279 | 286 | ||
280 | Gats::Dictionary *Gats::Dictionary::valueDict( const QByteArray &sKey ) | 287 | Gats::Dictionary *Gats::Dictionary::valueDict( const QByteArray &sKey ) |
281 | { | 288 | { |
282 | Gats::Dictionary *pOb = dynamic_cast<Gats::Dictionary *>( value( sKey ) ); | 289 | Gats::Dictionary *pOb = dynamic_cast<Gats::Dictionary *>( value( sKey ) ); |
283 | if( !pOb ) | 290 | if( !pOb ) |
284 | throw "PUT GOOD EXCEPTION HERE"; | 291 | throw "PUT GOOD EXCEPTION HERE"; |
285 | 292 | ||
286 | return pOb; | 293 | return pOb; |
287 | } | 294 | } |
288 | 295 | ||
289 | bool Gats::Dictionary::valueBool( const QByteArray &sKey ) const | 296 | bool Gats::Dictionary::valueBool( const QByteArray &sKey ) const |
290 | { | 297 | { |
291 | Gats::Boolean *pOb = dynamic_cast<Gats::Boolean *>( value( sKey ) ); | 298 | Gats::Boolean *pOb = dynamic_cast<Gats::Boolean *>( value( sKey ) ); |
292 | if( !pOb ) | 299 | if( !pOb ) |
293 | throw "PUT GOOD EXCEPTION HERE"; | 300 | throw "PUT GOOD EXCEPTION HERE"; |
294 | 301 | ||
295 | return pOb->getValue(); | 302 | return pOb->getValue(); |
296 | } | 303 | } |
297 | 304 | ||
298 | int64_t Gats::Dictionary::valueInt( const QByteArray &sKey ) const | 305 | int64_t Gats::Dictionary::valueInt( const QByteArray &sKey ) const |
299 | { | 306 | { |
300 | Gats::Integer *pOb = dynamic_cast<Gats::Integer *>( value( sKey ) ); | 307 | Gats::Integer *pOb = dynamic_cast<Gats::Integer *>( value( sKey ) ); |
301 | if( !pOb ) | 308 | if( !pOb ) |
302 | throw "PUT GOOD EXCEPTION HERE"; | 309 | throw "PUT GOOD EXCEPTION HERE"; |
303 | 310 | ||
304 | return pOb->getValue(); | 311 | return pOb->getValue(); |
305 | } | 312 | } |
306 | 313 | ||
307 | double Gats::Dictionary::valueFloat( const QByteArray &sKey ) const | 314 | double Gats::Dictionary::valueFloat( const QByteArray &sKey ) const |
308 | { | 315 | { |
309 | Gats::Float *pOb = dynamic_cast<Gats::Float *>( value( sKey ) ); | 316 | Gats::Float *pOb = dynamic_cast<Gats::Float *>( value( sKey ) ); |
310 | if( !pOb ) | 317 | if( !pOb ) |
311 | throw "PUT GOOD EXCEPTION HERE"; | 318 | throw "PUT GOOD EXCEPTION HERE"; |
312 | 319 | ||
313 | return pOb->getValue(); | 320 | return pOb->getValue(); |
314 | } | 321 | } |
315 | 322 | ||
316 | QByteArray Gats::Dictionary::valueStr( const QByteArray &sKey ) const | 323 | QByteArray Gats::Dictionary::valueStr( const QByteArray &sKey ) const |
317 | { | 324 | { |
318 | Gats::String *pOb = dynamic_cast<Gats::String *>( value( sKey ) ); | 325 | Gats::String *pOb = dynamic_cast<Gats::String *>( value( sKey ) ); |
319 | if( !pOb ) | 326 | if( !pOb ) |
320 | throw "PUT GOOD EXCEPTION HERE"; | 327 | throw "PUT GOOD EXCEPTION HERE"; |
321 | 328 | ||
322 | return *pOb; | 329 | return *pOb; |
323 | } | 330 | } |
324 | 331 | ||
325 | Gats::List *Gats::Dictionary::valueList( const QByteArray &sKey ) const | 332 | Gats::List *Gats::Dictionary::valueList( const QByteArray &sKey ) const |
326 | { | 333 | { |
327 | Gats::List *pOb = dynamic_cast<Gats::List *>( value( sKey ) ); | 334 | Gats::List *pOb = dynamic_cast<Gats::List *>( value( sKey ) ); |
328 | if( !pOb ) | 335 | if( !pOb ) |
329 | throw "PUT GOOD EXCEPTION HERE"; | 336 | throw "PUT GOOD EXCEPTION HERE"; |
330 | 337 | ||
331 | return pOb; | 338 | return pOb; |
332 | } | 339 | } |
333 | 340 | ||
334 | Gats::Dictionary *Gats::Dictionary::valueDict( const QByteArray &sKey ) const | 341 | Gats::Dictionary *Gats::Dictionary::valueDict( const QByteArray &sKey ) const |
335 | { | 342 | { |
336 | Gats::Dictionary *pOb = dynamic_cast<Gats::Dictionary *>( value( sKey ) ); | 343 | Gats::Dictionary *pOb = dynamic_cast<Gats::Dictionary *>( value( sKey ) ); |
337 | if( !pOb ) | 344 | if( !pOb ) |
338 | throw "PUT GOOD EXCEPTION HERE"; | 345 | throw "PUT GOOD EXCEPTION HERE"; |
339 | 346 | ||
340 | return pOb; | 347 | return pOb; |
341 | } | 348 | } |
342 | /* | 349 | /* |
343 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Dictionary &d ) | 350 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Dictionary &d ) |
344 | { | 351 | { |
345 | f << "(dict) {"; | 352 | f << "(dict) {"; |
346 | f.incIndent(); | 353 | f.incIndent(); |
347 | int iMax = 0; | 354 | int iMax = 0; |
348 | for( Gats::Dictionary::const_iterator i = d.begin(); i; i++ ) | 355 | for( Gats::Dictionary::const_iterator i = d.begin(); i; i++ ) |
349 | { | 356 | { |
350 | if( i.valueKey().valueSize() > iMax ) | 357 | if( i.valueKey().valueSize() > iMax ) |
351 | iMax = i.valueKey().valueSize(); | 358 | iMax = i.valueKey().valueSize(); |
352 | } | 359 | } |
353 | iMax += 2; | 360 | iMax += 2; |
354 | for( Gats::Dictionary::const_iterator i = d.begin(); i; i++ ) | 361 | for( Gats::Dictionary::const_iterator i = d.begin(); i; i++ ) |
355 | { | 362 | { |
356 | f << f.nl << Bu::Fmt( iMax ) << i.valueKey() + ": " << *i.getValue(); | 363 | f << f.nl << Bu::Fmt( iMax ) << i.valueKey() + ": " << *i.getValue(); |
357 | } | 364 | } |
358 | f.decIndent(); | 365 | f.decIndent(); |
359 | f << f.nl << "}"; | 366 | f << f.nl << "}"; |
360 | 367 | ||
361 | return f; | 368 | return f; |
362 | } | 369 | } |
363 | */ | 370 | */ |
diff --git a/c++-qt/src/dictionary.h b/c++-qt/src/dictionary.h index 7f95cf1..af1d436 100644 --- a/c++-qt/src/dictionary.h +++ b/c++-qt/src/dictionary.h | |||
@@ -1,3 +1,10 @@ | |||
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 | |||
1 | #ifndef GATS_DICTIONARY_H | 8 | #ifndef GATS_DICTIONARY_H |
2 | #define GATS_DICTIONARY_H | 9 | #define GATS_DICTIONARY_H |
3 | 10 | ||
@@ -7,62 +14,62 @@ | |||
7 | 14 | ||
8 | namespace Gats | 15 | namespace Gats |
9 | { | 16 | { |
10 | class List; | 17 | class List; |
11 | 18 | ||
12 | class Dictionary : public Gats::Object, | 19 | class Dictionary : public Gats::Object, |
13 | public QHash<QByteArray, Gats::Object *> | 20 | public QHash<QByteArray, Gats::Object *> |
14 | { | 21 | { |
15 | Q_OBJECT; | 22 | Q_OBJECT; |
16 | public: | 23 | public: |
17 | Dictionary(); | 24 | Dictionary(); |
18 | virtual ~Dictionary(); | 25 | virtual ~Dictionary(); |
19 | 26 | ||
20 | virtual Object *clone() const; | 27 | virtual Object *clone() const; |
21 | 28 | ||
22 | virtual Type getType() const { return typeDictionary; } | 29 | virtual Type getType() const { return typeDictionary; } |
23 | virtual void write( QIODevice &rOut ) const; | 30 | virtual void write( QIODevice &rOut ) const; |
24 | virtual void read( QIODevice &rIn, char cType ); | 31 | virtual void read( QIODevice &rIn, char cType ); |
25 | 32 | ||
26 | void insert( const QByteArray &sKey, const char *s ); | 33 | void insert( const QByteArray &sKey, const char *s ); |
27 | void insert( const QByteArray &sKey, const QByteArray &s ); | 34 | void insert( const QByteArray &sKey, const QByteArray &s ); |
28 | void insert( const QByteArray &sKey, char i ); | 35 | void insert( const QByteArray &sKey, char i ); |
29 | void insert( const QByteArray &sKey, unsigned char i ); | 36 | void insert( const QByteArray &sKey, unsigned char i ); |
30 | void insert( const QByteArray &sKey, signed char i ); | 37 | void insert( const QByteArray &sKey, signed char i ); |
31 | void insert( const QByteArray &sKey, unsigned short i ); | 38 | void insert( const QByteArray &sKey, unsigned short i ); |
32 | void insert( const QByteArray &sKey, signed short i ); | 39 | void insert( const QByteArray &sKey, signed short i ); |
33 | void insert( const QByteArray &sKey, unsigned int i ); | 40 | void insert( const QByteArray &sKey, unsigned int i ); |
34 | void insert( const QByteArray &sKey, signed int i ); | 41 | void insert( const QByteArray &sKey, signed int i ); |
35 | void insert( const QByteArray &sKey, unsigned long i ); | 42 | void insert( const QByteArray &sKey, unsigned long i ); |
36 | void insert( const QByteArray &sKey, signed long i ); | 43 | void insert( const QByteArray &sKey, signed long i ); |
37 | void insert( const QByteArray &sKey, unsigned long long i ); | 44 | void insert( const QByteArray &sKey, unsigned long long i ); |
38 | void insert( const QByteArray &sKey, signed long long i ); | 45 | void insert( const QByteArray &sKey, signed long long i ); |
39 | //void insert( const QByteArray &sKey, bool b ); | 46 | //void insert( const QByteArray &sKey, bool b ); |
40 | void insert( const QByteArray &sKey, float d ); | 47 | void insert( const QByteArray &sKey, float d ); |
41 | void insert( const QByteArray &sKey, double d ); | 48 | void insert( const QByteArray &sKey, double d ); |
42 | using QHash<QByteArray, Gats::Object *>::insert; | 49 | using QHash<QByteArray, Gats::Object *>::insert; |
43 | void insertBool( const QByteArray &sKey, bool b ); | 50 | void insertBool( const QByteArray &sKey, bool b ); |
44 | void insertInt( const QByteArray &sKey, int64_t i ); | 51 | void insertInt( const QByteArray &sKey, int64_t i ); |
45 | void insertFloat( const QByteArray &sKey, double d ); | 52 | void insertFloat( const QByteArray &sKey, double d ); |
46 | void insertStr( const QByteArray &sKey, const QByteArray &s ); | 53 | void insertStr( const QByteArray &sKey, const QByteArray &s ); |
47 | void insertList( const QByteArray &sKey, Gats::List *pL ); | 54 | void insertList( const QByteArray &sKey, Gats::List *pL ); |
48 | void insertDict( const QByteArray &sKey, Gats::Dictionary *pD ); | 55 | void insertDict( const QByteArray &sKey, Gats::Dictionary *pD ); |
49 | Gats::List *insertList( const QByteArray &sKey ); | 56 | Gats::List *insertList( const QByteArray &sKey ); |
50 | Gats::Dictionary *insertDict( const QByteArray &sKey ); | 57 | Gats::Dictionary *insertDict( const QByteArray &sKey ); |
51 | 58 | ||
52 | bool valueBool( const QByteArray &sKey ); | 59 | bool valueBool( const QByteArray &sKey ); |
53 | int64_t valueInt( const QByteArray &sKey ); | 60 | int64_t valueInt( const QByteArray &sKey ); |
54 | double valueFloat( const QByteArray &sKey ); | 61 | double valueFloat( const QByteArray &sKey ); |
55 | QByteArray valueStr( const QByteArray &sKey ); | 62 | QByteArray valueStr( const QByteArray &sKey ); |
56 | Gats::List *valueList( const QByteArray &sKey ); | 63 | Gats::List *valueList( const QByteArray &sKey ); |
57 | Gats::Dictionary *valueDict( const QByteArray &sKey ); | 64 | Gats::Dictionary *valueDict( const QByteArray &sKey ); |
58 | 65 | ||
59 | bool valueBool( const QByteArray &sKey ) const; | 66 | bool valueBool( const QByteArray &sKey ) const; |
60 | int64_t valueInt( const QByteArray &sKey ) const; | 67 | int64_t valueInt( const QByteArray &sKey ) const; |
61 | double valueFloat( const QByteArray &sKey ) const; | 68 | double valueFloat( const QByteArray &sKey ) const; |
62 | QByteArray valueStr( const QByteArray &sKey ) const; | 69 | QByteArray valueStr( const QByteArray &sKey ) const; |
63 | Gats::List *valueList( const QByteArray &sKey ) const; | 70 | Gats::List *valueList( const QByteArray &sKey ) const; |
64 | Gats::Dictionary *valueDict( const QByteArray &sKey ) const; | 71 | Gats::Dictionary *valueDict( const QByteArray &sKey ) const; |
65 | }; | 72 | }; |
66 | }; | 73 | }; |
67 | 74 | ||
68 | //Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Dictionary &d ); | 75 | //Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Dictionary &d ); |
diff --git a/c++-qt/src/float.cpp b/c++-qt/src/float.cpp index fedecf3..03ff755 100644 --- a/c++-qt/src/float.cpp +++ b/c++-qt/src/float.cpp | |||
@@ -1,15 +1,22 @@ | |||
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 | |||
1 | #include "gats-qt/float.h" | 8 | #include "gats-qt/float.h" |
2 | #include "gats-qt/integer.h" | 9 | #include "gats-qt/integer.h" |
3 | 10 | ||
4 | #include <math.h> | 11 | #include <math.h> |
5 | 12 | ||
6 | Gats::Float::Float() : | 13 | Gats::Float::Float() : |
7 | fVal( 0.0 ) | 14 | fVal( 0.0 ) |
8 | { | 15 | { |
9 | } | 16 | } |
10 | 17 | ||
11 | Gats::Float::Float( double f ) : | 18 | Gats::Float::Float( double f ) : |
12 | fVal( f ) | 19 | fVal( f ) |
13 | { | 20 | { |
14 | } | 21 | } |
15 | 22 | ||
@@ -19,109 +26,109 @@ Gats::Float::~Float() | |||
19 | 26 | ||
20 | Gats::Object *Gats::Float::clone() const | 27 | Gats::Object *Gats::Float::clone() const |
21 | { | 28 | { |
22 | return new Gats::Float( fVal ); | 29 | return new Gats::Float( fVal ); |
23 | } | 30 | } |
24 | 31 | ||
25 | void Gats::Float::write( QIODevice &rOut ) const | 32 | void Gats::Float::write( QIODevice &rOut ) const |
26 | { | 33 | { |
27 | if( fVal == 0.0 ) | 34 | if( fVal == 0.0 ) |
28 | { | 35 | { |
29 | if( signbit( fVal ) ) | 36 | if( signbit( fVal ) ) |
30 | rOut.write("FZ", 2 ); | 37 | rOut.write("FZ", 2 ); |
31 | else | 38 | else |
32 | rOut.write("Fz", 2 ); | 39 | rOut.write("Fz", 2 ); |
33 | } | 40 | } |
34 | else if( !isfinite( fVal ) ) | 41 | else if( !isfinite( fVal ) ) |
35 | { | 42 | { |
36 | if( isnan( fVal ) ) | 43 | if( isnan( fVal ) ) |
37 | { | 44 | { |
38 | if( signbit( fVal ) ) | 45 | if( signbit( fVal ) ) |
39 | rOut.write("FN", 2 ); | 46 | rOut.write("FN", 2 ); |
40 | else | 47 | else |
41 | rOut.write("Fn", 2 ); | 48 | rOut.write("Fn", 2 ); |
42 | } | 49 | } |
43 | else | 50 | else |
44 | { | 51 | { |
45 | if( signbit( fVal ) ) | 52 | if( signbit( fVal ) ) |
46 | rOut.write("FI", 2 ); | 53 | rOut.write("FI", 2 ); |
47 | else | 54 | else |
48 | rOut.write("Fi", 2 ); | 55 | rOut.write("Fi", 2 ); |
49 | } | 56 | } |
50 | } | 57 | } |
51 | else | 58 | else |
52 | { | 59 | { |
53 | rOut.write("f", 1 ); | 60 | rOut.write("f", 1 ); |
54 | double d = fVal; | 61 | double d = fVal; |
55 | bool bNeg = false; | 62 | bool bNeg = false; |
56 | int64_t iScale=0; | 63 | int64_t iScale=0; |
57 | if( signbit( d ) ) | 64 | if( signbit( d ) ) |
58 | { | 65 | { |
59 | bNeg = true; | 66 | bNeg = true; |
60 | d = -d; | 67 | d = -d; |
61 | } | 68 | } |
62 | 69 | ||
63 | iScale = log( d ) / 0x1.62e42fefa39efp+2; // log( 256.0 ) | 70 | iScale = log( d ) / 0x1.62e42fefa39efp+2; // log( 256.0 ) |
64 | if( iScale < 0 ) iScale--; | 71 | if( iScale < 0 ) iScale--; |
65 | d /= pow( 256.0, iScale ); | 72 | d /= pow( 256.0, iScale ); |
66 | 73 | ||
67 | QByteArray s; | 74 | QByteArray s; |
68 | s += (uint8_t)(d); | 75 | s += (uint8_t)(d); |
69 | d -= (int)d; | 76 | d -= (int)d; |
70 | for( int j = 0; j < 150 && d; j++ ) | 77 | for( int j = 0; j < 150 && d; j++ ) |
71 | { | 78 | { |
72 | d = d*256.0; | 79 | d = d*256.0; |
73 | s += (uint8_t)d; | 80 | s += (uint8_t)d; |
74 | d -= (int)d; | 81 | d -= (int)d; |
75 | } | 82 | } |
76 | Gats::Integer::writePackedInt( rOut, bNeg?-s.size():s.size() ); | 83 | Gats::Integer::writePackedInt( rOut, bNeg?-s.size():s.size() ); |
77 | rOut.write( s.constData(), s.size() ); | 84 | rOut.write( s.constData(), s.size() ); |
78 | Gats::Integer::writePackedInt( rOut, iScale ); | 85 | Gats::Integer::writePackedInt( rOut, iScale ); |
79 | } | 86 | } |
80 | } | 87 | } |
81 | 88 | ||
82 | void Gats::Float::read( QIODevice &rIn, char cType ) | 89 | void Gats::Float::read( QIODevice &rIn, char cType ) |
83 | { | 90 | { |
84 | if( cType == 'F' ) | 91 | if( cType == 'F' ) |
85 | { | 92 | { |
86 | char buf; | 93 | char buf; |
87 | rIn.read( &buf, 1 ); | 94 | rIn.read( &buf, 1 ); |
88 | switch( buf ) | 95 | switch( buf ) |
89 | { | 96 | { |
90 | case 'N': fVal = -NAN; break; | 97 | case 'N': fVal = -NAN; break; |
91 | case 'n': fVal = NAN; break; | 98 | case 'n': fVal = NAN; break; |
92 | case 'I': fVal = -INFINITY; break; | 99 | case 'I': fVal = -INFINITY; break; |
93 | case 'i': fVal = INFINITY; break; | 100 | case 'i': fVal = INFINITY; break; |
94 | case 'Z': fVal = -0.0; break; | 101 | case 'Z': fVal = -0.0; break; |
95 | case 'z': fVal = 0.0; break; | 102 | case 'z': fVal = 0.0; break; |
96 | } | 103 | } |
97 | } | 104 | } |
98 | else if( cType == 'f' ) | 105 | else if( cType == 'f' ) |
99 | { | 106 | { |
100 | int64_t iStr; | 107 | int64_t iStr; |
101 | Gats::Integer::readPackedInt( rIn, iStr ); | 108 | Gats::Integer::readPackedInt( rIn, iStr ); |
102 | bool bNeg = false; | 109 | bool bNeg = false; |
103 | if( iStr < 0 ) | 110 | if( iStr < 0 ) |
104 | { | 111 | { |
105 | bNeg = true; | 112 | bNeg = true; |
106 | iStr = -iStr; | 113 | iStr = -iStr; |
107 | } | 114 | } |
108 | QByteArray s( iStr, '\0' ); | 115 | QByteArray s( iStr, '\0' ); |
109 | rIn.read( s.data(), iStr ); | 116 | rIn.read( s.data(), iStr ); |
110 | fVal = 0.0; | 117 | fVal = 0.0; |
111 | for( int j = iStr-1; j > 0; j-- ) | 118 | for( int j = iStr-1; j > 0; j-- ) |
112 | { | 119 | { |
113 | fVal = (fVal+(uint8_t)s[j])*0x1p-8; | 120 | fVal = (fVal+(uint8_t)s[j])*0x1p-8; |
114 | } | 121 | } |
115 | fVal += (uint8_t)s[0]; | 122 | fVal += (uint8_t)s[0]; |
116 | int64_t iScale; | 123 | int64_t iScale; |
117 | Gats::Integer::readPackedInt( rIn, iScale ); | 124 | Gats::Integer::readPackedInt( rIn, iScale ); |
118 | fVal *= pow( 256.0, iScale ); | 125 | fVal *= pow( 256.0, iScale ); |
119 | if( bNeg ) fVal = -fVal; | 126 | if( bNeg ) fVal = -fVal; |
120 | } | 127 | } |
121 | } | 128 | } |
122 | /* | 129 | /* |
123 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Float &flt ) | 130 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Float &flt ) |
124 | { | 131 | { |
125 | return f << "(float) " << flt.getValue(); | 132 | return f << "(float) " << flt.getValue(); |
126 | }*/ | 133 | }*/ |
127 | 134 | ||
diff --git a/c++-qt/src/float.h b/c++-qt/src/float.h index 93bfe18..6cc9950 100644 --- a/c++-qt/src/float.h +++ b/c++-qt/src/float.h | |||
@@ -1,3 +1,10 @@ | |||
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 | |||
1 | #ifndef GATS_FLOAT_H | 8 | #ifndef GATS_FLOAT_H |
2 | #define GATS_FLOAT_H | 9 | #define GATS_FLOAT_H |
3 | 10 | ||
@@ -5,26 +12,26 @@ | |||
5 | 12 | ||
6 | namespace Gats | 13 | namespace Gats |
7 | { | 14 | { |
8 | class Float : public Gats::Object | 15 | class Float : public Gats::Object |
9 | { | 16 | { |
10 | Q_OBJECT; | 17 | Q_OBJECT; |
11 | public: | 18 | public: |
12 | Float(); | 19 | Float(); |
13 | Float( double f ); | 20 | Float( double f ); |
14 | virtual ~Float(); | 21 | virtual ~Float(); |
15 | 22 | ||
16 | virtual Object *clone() const; | 23 | virtual Object *clone() const; |
17 | 24 | ||
18 | virtual Type getType() const { return typeFloat; } | 25 | virtual Type getType() const { return typeFloat; } |
19 | double getValue() const { return fVal; } | 26 | double getValue() const { return fVal; } |
20 | 27 | ||
21 | virtual void write( QIODevice &rOut ) const; | 28 | virtual void write( QIODevice &rOut ) const; |
22 | virtual void read( QIODevice &rIn, char cType ); | 29 | virtual void read( QIODevice &rIn, char cType ); |
23 | 30 | ||
24 | private: | 31 | private: |
25 | double fVal; | 32 | double fVal; |
26 | mutable QByteArray sWriteCache; | 33 | mutable QByteArray sWriteCache; |
27 | }; | 34 | }; |
28 | } | 35 | } |
29 | 36 | ||
30 | //Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Float &flt ); | 37 | //Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Float &flt ); |
diff --git a/c++-qt/src/gatsstream.cpp b/c++-qt/src/gatsstream.cpp index 920b2d6..f49fdb5 100644 --- a/c++-qt/src/gatsstream.cpp +++ b/c++-qt/src/gatsstream.cpp | |||
@@ -1,3 +1,10 @@ | |||
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 | |||
1 | #include "gats-qt/gatsstream.h" | 8 | #include "gats-qt/gatsstream.h" |
2 | #include "gats-qt/object.h" | 9 | #include "gats-qt/object.h" |
3 | 10 | ||
@@ -10,7 +17,7 @@ | |||
10 | #include <QBuffer> | 17 | #include <QBuffer> |
11 | 18 | ||
12 | Gats::GatsStream::GatsStream( QIODevice &rStream ) : | 19 | Gats::GatsStream::GatsStream( QIODevice &rStream ) : |
13 | rStream( rStream ) | 20 | rStream( rStream ) |
14 | { | 21 | { |
15 | } | 22 | } |
16 | 23 | ||
@@ -20,110 +27,110 @@ Gats::GatsStream::~GatsStream() | |||
20 | 27 | ||
21 | Gats::Object *Gats::GatsStream::readObject() | 28 | Gats::Object *Gats::GatsStream::readObject() |
22 | { | 29 | { |
23 | char buf[1500]; | 30 | char buf[1500]; |
24 | 31 | ||
25 | do | 32 | do |
26 | { | 33 | { |
27 | if( qbRead.size() < 5 ) | 34 | if( qbRead.size() < 5 ) |
28 | { | 35 | { |
29 | int iRead = rStream.read( buf, 5-qbRead.size() ); | 36 | int iRead = rStream.read( buf, 5-qbRead.size() ); |
30 | qbRead.append( buf, iRead ); | 37 | qbRead.append( buf, iRead ); |
31 | 38 | ||
32 | if( qbRead.size() < 5 ) | 39 | if( qbRead.size() < 5 ) |
33 | return NULL; | 40 | return NULL; |
34 | } | 41 | } |
35 | } while( !skipReadNulls() ); | 42 | } while( !skipReadNulls() ); |
36 | 43 | ||
37 | uint8_t uVer; | 44 | uint8_t uVer; |
38 | uVer = qbRead[0]; | 45 | uVer = qbRead[0]; |
39 | 46 | ||
40 | int32_t iSize; | 47 | int32_t iSize; |
41 | memcpy( &iSize, qbRead.constData()+1, 4 ); | 48 | memcpy( &iSize, qbRead.constData()+1, 4 ); |
42 | iSize = ntohl( iSize ); | 49 | iSize = ntohl( iSize ); |
43 | while( qbRead.size() < iSize ) | 50 | while( qbRead.size() < iSize ) |
44 | { | 51 | { |
45 | int32_t iRead = iSize - qbRead.size(); | 52 | int32_t iRead = iSize - qbRead.size(); |
46 | if( iRead > 1500 ) | 53 | if( iRead > 1500 ) |
47 | iRead = 1500; | 54 | iRead = 1500; |
48 | int32_t iReal = rStream.read( buf, iRead ); | 55 | int32_t iReal = rStream.read( buf, iRead ); |
49 | qbRead.append( buf, iReal ); | 56 | qbRead.append( buf, iReal ); |
50 | if( iReal < iRead ) | 57 | if( iReal < iRead ) |
51 | { | 58 | { |
52 | return NULL; | 59 | return NULL; |
53 | } | 60 | } |
54 | } | 61 | } |
55 | 62 | ||
56 | if( qbRead.size() < iSize ) | 63 | if( qbRead.size() < iSize ) |
57 | { | 64 | { |
58 | return NULL; | 65 | return NULL; |
59 | } | 66 | } |
60 | 67 | ||
61 | QBuffer rTmp( &qbRead ); | 68 | QBuffer rTmp( &qbRead ); |
62 | rTmp.open( QIODevice::ReadOnly ); | 69 | rTmp.open( QIODevice::ReadOnly ); |
63 | rTmp.seek( 5 ); | 70 | rTmp.seek( 5 ); |
64 | Gats::Object *pObj = Gats::Object::read( rTmp ); | 71 | Gats::Object *pObj = Gats::Object::read( rTmp ); |
65 | qbRead.clear(); | 72 | qbRead.clear(); |
66 | 73 | ||
67 | emit objectRead( pObj ); | 74 | emit objectRead( pObj ); |
68 | 75 | ||
69 | return pObj; | 76 | return pObj; |
70 | } | 77 | } |
71 | 78 | ||
72 | void Gats::GatsStream::readAllObjects() | 79 | void Gats::GatsStream::readAllObjects() |
73 | { | 80 | { |
74 | while( readObject() ) { } | 81 | while( readObject() ) { } |
75 | } | 82 | } |
76 | 83 | ||
77 | void Gats::GatsStream::writeObject( Gats::Object *pObject ) | 84 | void Gats::GatsStream::writeObject( Gats::Object *pObject ) |
78 | { | 85 | { |
79 | QIODevice *pTmp; | 86 | QIODevice *pTmp; |
80 | if( rStream.isSequential() ) | 87 | if( rStream.isSequential() ) |
81 | { | 88 | { |
82 | pTmp = new QBuffer(); | 89 | pTmp = new QBuffer(); |
83 | pTmp->open( QIODevice::WriteOnly ); | 90 | pTmp->open( QIODevice::WriteOnly ); |
84 | } | 91 | } |
85 | else | 92 | else |
86 | { | 93 | { |
87 | pTmp = &rStream; | 94 | pTmp = &rStream; |
88 | } | 95 | } |
89 | 96 | ||
90 | uint8_t uBuf = 1; | 97 | uint8_t uBuf = 1; |
91 | uint32_t iSize = 0; | 98 | uint32_t iSize = 0; |
92 | pTmp->write( (const char *)&uBuf, 1 ); | 99 | pTmp->write( (const char *)&uBuf, 1 ); |
93 | uint64_t iSizePos = pTmp->pos(); | 100 | uint64_t iSizePos = pTmp->pos(); |
94 | pTmp->write( (const char *)&iSize, 4 ); | 101 | pTmp->write( (const char *)&iSize, 4 ); |
95 | pObject->write( *pTmp ); | 102 | pObject->write( *pTmp ); |
96 | iSize = htonl( pTmp->pos() ); | 103 | iSize = htonl( pTmp->pos() ); |
97 | uint64_t iEndPos = pTmp->pos(); | 104 | uint64_t iEndPos = pTmp->pos(); |
98 | pTmp->seek( iSizePos ); | 105 | pTmp->seek( iSizePos ); |
99 | pTmp->write( (const char *)&iSize, 4 ); | 106 | pTmp->write( (const char *)&iSize, 4 ); |
100 | 107 | ||
101 | if( rStream.isSequential() ) | 108 | if( rStream.isSequential() ) |
102 | { | 109 | { |
103 | pTmp->close(); | 110 | pTmp->close(); |
104 | rStream.write( ((QBuffer *)pTmp)->data() ); | 111 | rStream.write( ((QBuffer *)pTmp)->data() ); |
105 | delete pTmp; | 112 | delete pTmp; |
106 | } | 113 | } |
107 | else | 114 | else |
108 | { | 115 | { |
109 | pTmp->seek( iSizePos ); | 116 | pTmp->seek( iSizePos ); |
110 | } | 117 | } |
111 | } | 118 | } |
112 | 119 | ||
113 | bool Gats::GatsStream::skipReadNulls() | 120 | bool Gats::GatsStream::skipReadNulls() |
114 | { | 121 | { |
115 | bool bHaveSeeked = false; | 122 | bool bHaveSeeked = false; |
116 | for(;;) | 123 | for(;;) |
117 | { | 124 | { |
118 | if( qbRead.size() == 0 ) | 125 | if( qbRead.size() == 0 ) |
119 | return false; | 126 | return false; |
120 | if( qbRead.at(0) != 0 ) | 127 | if( qbRead.at(0) != 0 ) |
121 | return !bHaveSeeked; //true; | 128 | return !bHaveSeeked; //true; |
122 | else | 129 | else |
123 | { | 130 | { |
124 | qbRead.remove( 0, 1 ); | 131 | qbRead.remove( 0, 1 ); |
125 | bHaveSeeked = true; | 132 | bHaveSeeked = true; |
126 | } | 133 | } |
127 | } | 134 | } |
128 | } | 135 | } |
129 | 136 | ||
diff --git a/c++-qt/src/gatsstream.h b/c++-qt/src/gatsstream.h index 90e0514..979ca60 100644 --- a/c++-qt/src/gatsstream.h +++ b/c++-qt/src/gatsstream.h | |||
@@ -1,3 +1,10 @@ | |||
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 | |||
1 | #ifndef GATS_STREAM_H | 8 | #ifndef GATS_STREAM_H |
2 | #define GATS_STREAM_H | 9 | #define GATS_STREAM_H |
3 | 10 | ||
@@ -6,67 +13,67 @@ | |||
6 | 13 | ||
7 | namespace Gats | 14 | namespace Gats |
8 | { | 15 | { |
9 | class Object; | 16 | class Object; |
10 | 17 | ||
11 | class GatsStream : public QObject | 18 | class GatsStream : public QObject |
12 | { | 19 | { |
13 | Q_OBJECT; | 20 | Q_OBJECT; |
14 | public: | 21 | public: |
15 | GatsStream( QIODevice &rStream ); | 22 | GatsStream( QIODevice &rStream ); |
16 | virtual ~GatsStream(); | 23 | virtual ~GatsStream(); |
17 | 24 | ||
18 | public slots: | 25 | public slots: |
19 | /** | 26 | /** |
20 | * Read an object packet from the assosiated stream. This will make | 27 | * Read an object packet from the assosiated stream. This will make |
21 | * every effort to only read exactly enough data to describe one packet, | 28 | * every effort to only read exactly enough data to describe one packet, |
22 | * in case you want to do other things with your stream. It will | 29 | * in case you want to do other things with your stream. It will |
23 | * automatically skip NULL byte spacing between packets, which makes | 30 | * automatically skip NULL byte spacing between packets, which makes |
24 | * a convinient padding method for encrypted data streams. Since | 31 | * a convinient padding method for encrypted data streams. Since |
25 | * sizing information is available in the packet header exact amounts | 32 | * sizing information is available in the packet header exact amounts |
26 | * of data can be read, however this function doesn't assume that it | 33 | * of data can be read, however this function doesn't assume that it |
27 | * can read the entire object in one operation. If it fails to read | 34 | * can read the entire object in one operation. If it fails to read |
28 | * a complete packet in one call, it will keep the data it's read so | 35 | * a complete packet in one call, it will keep the data it's read so |
29 | * far buffered and return NULL, ready for another attempt. You can | 36 | * far buffered and return NULL, ready for another attempt. You can |
30 | * use the function hasReadBuffer() to deterimne if readObject() | 37 | * use the function hasReadBuffer() to deterimne if readObject() |
31 | * has read part of an object packet or not. If readObject returns | 38 | * has read part of an object packet or not. If readObject returns |
32 | * non-null then hasReadBuffer should return false on it's next call. | 39 | * non-null then hasReadBuffer should return false on it's next call. |
33 | */ | 40 | */ |
34 | Gats::Object *readObject(); | 41 | Gats::Object *readObject(); |
35 | 42 | ||
36 | /** | 43 | /** |
37 | * Works exactly like readObject, except it reads all pending objects | 44 | * Works exactly like readObject, except it reads all pending objects |
38 | * and emits a objectRead signal for each one read. It doesn't return | 45 | * and emits a objectRead signal for each one read. It doesn't return |
39 | * anything. This is perfect for connecting to a QIODevice's readRead | 46 | * anything. This is perfect for connecting to a QIODevice's readRead |
40 | * signal. | 47 | * signal. |
41 | */ | 48 | */ |
42 | void readAllObjects(); | 49 | void readAllObjects(); |
43 | 50 | ||
44 | public: | 51 | public: |
45 | /** | 52 | /** |
46 | * Write an object | 53 | * Write an object |
47 | */ | 54 | */ |
48 | void writeObject( Gats::Object *pObject ); | 55 | void writeObject( Gats::Object *pObject ); |
49 | 56 | ||
50 | /** | 57 | /** |
51 | * Tells you if there is data still in the read buffer, i.e. that a | 58 | * Tells you if there is data still in the read buffer, i.e. that a |
52 | * packet is part way through being read. If readObject has returned | 59 | * packet is part way through being read. If readObject has returned |
53 | * non-null in the most recent call, this should always be false. | 60 | * non-null in the most recent call, this should always be false. |
54 | */ | 61 | */ |
55 | bool hasReadBuffer() { return qbRead.size() > 0; } | 62 | bool hasReadBuffer() { return qbRead.size() > 0; } |
56 | int getReadBufferSize() { return qbRead.size(); } | 63 | int getReadBufferSize() { return qbRead.size(); } |
57 | 64 | ||
58 | QIODevice &getIODevice() { return rStream; } | 65 | QIODevice &getIODevice() { return rStream; } |
59 | 66 | ||
60 | signals: | 67 | signals: |
61 | void objectRead( Gats::Object *pObj ); | 68 | void objectRead( Gats::Object *pObj ); |
62 | 69 | ||
63 | private: | 70 | private: |
64 | bool skipReadNulls(); | 71 | bool skipReadNulls(); |
65 | 72 | ||
66 | private: | 73 | private: |
67 | QIODevice &rStream; | 74 | QIODevice &rStream; |
68 | QByteArray qbRead; | 75 | QByteArray qbRead; |
69 | }; | 76 | }; |
70 | }; | 77 | }; |
71 | 78 | ||
72 | #endif | 79 | #endif |
diff --git a/c++-qt/src/integer.cpp b/c++-qt/src/integer.cpp index 82727f3..721c434 100644 --- a/c++-qt/src/integer.cpp +++ b/c++-qt/src/integer.cpp | |||
@@ -1,12 +1,19 @@ | |||
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 | |||
1 | #include "gats-qt/integer.h" | 8 | #include "gats-qt/integer.h" |
2 | 9 | ||
3 | Gats::Integer::Integer() : | 10 | Gats::Integer::Integer() : |
4 | iVal( 0 ) | 11 | iVal( 0 ) |
5 | { | 12 | { |
6 | } | 13 | } |
7 | 14 | ||
8 | Gats::Integer::Integer( int64_t iVal ) : | 15 | Gats::Integer::Integer( int64_t iVal ) : |
9 | iVal( iVal ) | 16 | iVal( iVal ) |
10 | { | 17 | { |
11 | } | 18 | } |
12 | 19 | ||
@@ -16,22 +23,22 @@ Gats::Integer::~Integer() | |||
16 | 23 | ||
17 | Gats::Object *Gats::Integer::clone() const | 24 | Gats::Object *Gats::Integer::clone() const |
18 | { | 25 | { |
19 | return new Gats::Integer( iVal ); | 26 | return new Gats::Integer( iVal ); |
20 | } | 27 | } |
21 | 28 | ||
22 | void Gats::Integer::write( QIODevice &rOut ) const | 29 | void Gats::Integer::write( QIODevice &rOut ) const |
23 | { | 30 | { |
24 | rOut.write("i", 1 ); | 31 | rOut.write("i", 1 ); |
25 | writePackedInt( rOut, iVal ); | 32 | writePackedInt( rOut, iVal ); |
26 | } | 33 | } |
27 | 34 | ||
28 | void Gats::Integer::read( QIODevice &rIn, char cType ) | 35 | void Gats::Integer::read( QIODevice &rIn, char cType ) |
29 | { | 36 | { |
30 | readPackedInt( rIn, iVal ); | 37 | readPackedInt( rIn, iVal ); |
31 | } | 38 | } |
32 | /* | 39 | /* |
33 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Integer &i ) | 40 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Integer &i ) |
34 | { | 41 | { |
35 | return f << "(int) " << i.getValue(); | 42 | return f << "(int) " << i.getValue(); |
36 | } | 43 | } |
37 | */ | 44 | */ |
diff --git a/c++-qt/src/integer.h b/c++-qt/src/integer.h index db36e30..9178796 100644 --- a/c++-qt/src/integer.h +++ b/c++-qt/src/integer.h | |||
@@ -1,3 +1,10 @@ | |||
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 | |||
1 | #ifndef GATS_INTEGER_H | 8 | #ifndef GATS_INTEGER_H |
2 | #define GATS_INTEGER_H | 9 | #define GATS_INTEGER_H |
3 | 10 | ||
@@ -9,78 +16,78 @@ | |||
9 | 16 | ||
10 | namespace Gats | 17 | namespace Gats |
11 | { | 18 | { |
12 | class Integer : public Gats::Object | 19 | class Integer : public Gats::Object |
13 | { | 20 | { |
14 | Q_OBJECT; | 21 | Q_OBJECT; |
15 | public: | 22 | public: |
16 | Integer(); | 23 | Integer(); |
17 | Integer( int64_t iVal ); | 24 | Integer( int64_t iVal ); |
18 | virtual ~Integer(); | 25 | virtual ~Integer(); |
19 | 26 | ||
20 | virtual Object *clone() const; | 27 | virtual Object *clone() const; |
21 | 28 | ||
22 | virtual Type getType() const { return typeInteger; } | 29 | virtual Type getType() const { return typeInteger; } |
23 | int64_t getValue() const { return iVal; } | 30 | int64_t getValue() const { return iVal; } |
24 | void setValue( int64_t iNewVal ) { iVal = iNewVal; } | 31 | void setValue( int64_t iNewVal ) { iVal = iNewVal; } |
25 | 32 | ||
26 | virtual void write( QIODevice &rOut ) const; | 33 | virtual void write( QIODevice &rOut ) const; |
27 | virtual void read( QIODevice &rIn, char cType ); | 34 | virtual void read( QIODevice &rIn, char cType ); |
28 | 35 | ||
29 | template<typename itype> | 36 | template<typename itype> |
30 | static void readPackedInt( QIODevice &rStream, itype &rOut ) | 37 | static void readPackedInt( QIODevice &rStream, itype &rOut ) |
31 | { | 38 | { |
32 | int8_t b; | 39 | int8_t b; |
33 | rOut = 0; | 40 | rOut = 0; |
34 | bool bNeg; | 41 | bool bNeg; |
35 | 42 | ||
36 | rStream.read( (char *)&b, 1 ); | 43 | rStream.read( (char *)&b, 1 ); |
37 | bNeg = ( b&0x40 ); | 44 | bNeg = ( b&0x40 ); |
38 | rOut |= (itype(b&0x3F)); | 45 | rOut |= (itype(b&0x3F)); |
39 | int c = 0; | 46 | int c = 0; |
40 | while( (b&0x80) ) | 47 | while( (b&0x80) ) |
41 | { | 48 | { |
42 | rStream.read( (char *)&b, 1 ); | 49 | rStream.read( (char *)&b, 1 ); |
43 | rOut |= (itype(b&0x7F)) << (6+7*(c++)); | 50 | rOut |= (itype(b&0x7F)) << (6+7*(c++)); |
44 | } | 51 | } |
45 | if( bNeg ) rOut = -rOut; | 52 | if( bNeg ) rOut = -rOut; |
46 | } | 53 | } |
47 | 54 | ||
48 | template<typename itype> | 55 | template<typename itype> |
49 | static void writePackedInt( QIODevice &rStream, itype iIn ) | 56 | static void writePackedInt( QIODevice &rStream, itype iIn ) |
50 | { | 57 | { |
51 | uint8_t b; | 58 | uint8_t b; |
52 | 59 | ||
53 | if( iIn < 0 ) | 60 | if( iIn < 0 ) |
54 | { | 61 | { |
55 | iIn = -iIn; | 62 | iIn = -iIn; |
56 | b = (iIn&0x3F); | 63 | b = (iIn&0x3F); |
57 | if( iIn > b ) | 64 | if( iIn > b ) |
58 | b |= 0x80 | 0x40; | 65 | b |= 0x80 | 0x40; |
59 | else | 66 | else |
60 | b |= 0x40; | 67 | b |= 0x40; |
61 | } | 68 | } |
62 | else | 69 | else |
63 | { | 70 | { |
64 | b = (iIn&0x3F); | 71 | b = (iIn&0x3F); |
65 | if( iIn > b ) | 72 | if( iIn > b ) |
66 | b |= 0x80; | 73 | b |= 0x80; |
67 | } | 74 | } |
68 | rStream.write( (const char *)&b, 1 ); | 75 | rStream.write( (const char *)&b, 1 ); |
69 | iIn = iIn >> 6; | 76 | iIn = iIn >> 6; |
70 | 77 | ||
71 | while( iIn ) | 78 | while( iIn ) |
72 | { | 79 | { |
73 | b = (iIn&0x7F); | 80 | b = (iIn&0x7F); |
74 | if( iIn > b ) | 81 | if( iIn > b ) |
75 | b |= 0x80; | 82 | b |= 0x80; |
76 | rStream.write( (const char *)&b, 1 ); | 83 | rStream.write( (const char *)&b, 1 ); |
77 | iIn = iIn >> 7; | 84 | iIn = iIn >> 7; |
78 | } | 85 | } |
79 | } | 86 | } |
80 | 87 | ||
81 | private: | 88 | private: |
82 | int64_t iVal; | 89 | int64_t iVal; |
83 | }; | 90 | }; |
84 | }; | 91 | }; |
85 | 92 | ||
86 | //Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Integer &i ); | 93 | //Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Integer &i ); |
diff --git a/c++-qt/src/list.cpp b/c++-qt/src/list.cpp index 8a648e9..158a7c1 100644 --- a/c++-qt/src/list.cpp +++ b/c++-qt/src/list.cpp | |||
@@ -1,3 +1,10 @@ | |||
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 | |||
1 | #include "gats-qt/list.h" | 8 | #include "gats-qt/list.h" |
2 | 9 | ||
3 | #include "gats-qt/string.h" | 10 | #include "gats-qt/string.h" |
@@ -12,193 +19,193 @@ Gats::List::List() | |||
12 | 19 | ||
13 | Gats::List::~List() | 20 | Gats::List::~List() |
14 | { | 21 | { |
15 | for( iterator i = begin(); i != end(); i++ ) | 22 | for( iterator i = begin(); i != end(); i++ ) |
16 | { | 23 | { |
17 | delete *i; | 24 | delete *i; |
18 | } | 25 | } |
19 | } | 26 | } |
20 | 27 | ||
21 | Gats::Object *Gats::List::clone() const | 28 | Gats::Object *Gats::List::clone() const |
22 | { | 29 | { |
23 | Gats::List *pClone = new Gats::List; | 30 | Gats::List *pClone = new Gats::List; |
24 | 31 | ||
25 | for( const_iterator i = begin(); i != end(); i++ ) | 32 | for( const_iterator i = begin(); i != end(); i++ ) |
26 | { | 33 | { |
27 | pClone->append( (*i)->clone() ); | 34 | pClone->append( (*i)->clone() ); |
28 | } | 35 | } |
29 | 36 | ||
30 | return pClone; | 37 | return pClone; |
31 | } | 38 | } |
32 | 39 | ||
33 | void Gats::List::write( QIODevice &rOut ) const | 40 | void Gats::List::write( QIODevice &rOut ) const |
34 | { | 41 | { |
35 | rOut.write("l", 1 ); | 42 | rOut.write("l", 1 ); |
36 | for( const_iterator i = begin(); i != end(); i++ ) | 43 | for( const_iterator i = begin(); i != end(); i++ ) |
37 | { | 44 | { |
38 | (*i)->write( rOut ); | 45 | (*i)->write( rOut ); |
39 | } | 46 | } |
40 | rOut.write("e", 1 ); | 47 | rOut.write("e", 1 ); |
41 | } | 48 | } |
42 | 49 | ||
43 | void Gats::List::read( QIODevice &rIn, char cType ) | 50 | void Gats::List::read( QIODevice &rIn, char cType ) |
44 | { | 51 | { |
45 | for(;;) | 52 | for(;;) |
46 | { | 53 | { |
47 | Gats::Object *pObj = Gats::Object::read( rIn ); | 54 | Gats::Object *pObj = Gats::Object::read( rIn ); |
48 | if( pObj == NULL ) | 55 | if( pObj == NULL ) |
49 | break; | 56 | break; |
50 | append( pObj ); | 57 | append( pObj ); |
51 | } | 58 | } |
52 | } | 59 | } |
53 | 60 | ||
54 | void Gats::List::append( const char *s ) | 61 | void Gats::List::append( const char *s ) |
55 | { | 62 | { |
56 | QList<Gats::Object *>::append( new Gats::String( s ) ); | 63 | QList<Gats::Object *>::append( new Gats::String( s ) ); |
57 | } | 64 | } |
58 | 65 | ||
59 | void Gats::List::append( const QByteArray &s ) | 66 | void Gats::List::append( const QByteArray &s ) |
60 | { | 67 | { |
61 | QList<Gats::Object *>::append( new Gats::String( s ) ); | 68 | QList<Gats::Object *>::append( new Gats::String( s ) ); |
62 | } | 69 | } |
63 | 70 | ||
64 | void Gats::List::append( int32_t i ) | 71 | void Gats::List::append( int32_t i ) |
65 | { | 72 | { |
66 | QList<Gats::Object *>::append( new Gats::Integer( i ) ); | 73 | QList<Gats::Object *>::append( new Gats::Integer( i ) ); |
67 | } | 74 | } |
68 | 75 | ||
69 | void Gats::List::append( int64_t i ) | 76 | void Gats::List::append( int64_t i ) |
70 | { | 77 | { |
71 | QList<Gats::Object *>::append( new Gats::Integer( i ) ); | 78 | QList<Gats::Object *>::append( new Gats::Integer( i ) ); |
72 | } | 79 | } |
73 | 80 | ||
74 | void Gats::List::append( double d ) | 81 | void Gats::List::append( double d ) |
75 | { | 82 | { |
76 | QList<Gats::Object *>::append( new Gats::Float( d ) ); | 83 | QList<Gats::Object *>::append( new Gats::Float( d ) ); |
77 | } | 84 | } |
78 | 85 | ||
79 | void Gats::List::appendStr( const QByteArray &s ) | 86 | void Gats::List::appendStr( const QByteArray &s ) |
80 | { | 87 | { |
81 | QList<Gats::Object *>::append( new Gats::String( s ) ); | 88 | QList<Gats::Object *>::append( new Gats::String( s ) ); |
82 | } | 89 | } |
83 | 90 | ||
84 | void Gats::List::appendInt( int64_t i ) | 91 | void Gats::List::appendInt( int64_t i ) |
85 | { | 92 | { |
86 | QList<Gats::Object *>::append( new Gats::Integer( i ) ); | 93 | QList<Gats::Object *>::append( new Gats::Integer( i ) ); |
87 | } | 94 | } |
88 | 95 | ||
89 | void Gats::List::appendFloat( double d ) | 96 | void Gats::List::appendFloat( double d ) |
90 | { | 97 | { |
91 | QList<Gats::Object *>::append( new Gats::Float( d ) ); | 98 | QList<Gats::Object *>::append( new Gats::Float( d ) ); |
92 | } | 99 | } |
93 | 100 | ||
94 | void Gats::List::appendBool( bool b ) | 101 | void Gats::List::appendBool( bool b ) |
95 | { | 102 | { |
96 | QList<Gats::Object *>::append( new Gats::Boolean( b ) ); | 103 | QList<Gats::Object *>::append( new Gats::Boolean( b ) ); |
97 | } | 104 | } |
98 | 105 | ||
99 | void Gats::List::appendList( Gats::List *pL ) | 106 | void Gats::List::appendList( Gats::List *pL ) |
100 | { | 107 | { |
101 | QList<Gats::Object *>::append( pL ); | 108 | QList<Gats::Object *>::append( pL ); |
102 | } | 109 | } |
103 | 110 | ||
104 | void Gats::List::appendDict( Gats::Dictionary *pD ) | 111 | void Gats::List::appendDict( Gats::Dictionary *pD ) |
105 | { | 112 | { |
106 | QList<Gats::Object *>::append( pD ); | 113 | QList<Gats::Object *>::append( pD ); |
107 | } | 114 | } |
108 | 115 | ||
109 | Gats::List *Gats::List::appendList() | 116 | Gats::List *Gats::List::appendList() |
110 | { | 117 | { |
111 | Gats::List *pLst = new Gats::List(); | 118 | Gats::List *pLst = new Gats::List(); |
112 | appendList( pLst ); | 119 | appendList( pLst ); |
113 | return pLst; | 120 | return pLst; |
114 | } | 121 | } |
115 | 122 | ||
116 | Gats::Dictionary *Gats::List::appendDict() | 123 | Gats::Dictionary *Gats::List::appendDict() |
117 | { | 124 | { |
118 | Gats::Dictionary *pDict = new Gats::Dictionary(); | 125 | Gats::Dictionary *pDict = new Gats::Dictionary(); |
119 | appendDict( pDict ); | 126 | appendDict( pDict ); |
120 | return pDict; | 127 | return pDict; |
121 | } | 128 | } |
122 | 129 | ||
123 | void Gats::List::prepend( const char *s ) | 130 | void Gats::List::prepend( const char *s ) |
124 | { | 131 | { |
125 | QList<Gats::Object *>::prepend( new Gats::String( s ) ); | 132 | QList<Gats::Object *>::prepend( new Gats::String( s ) ); |
126 | } | 133 | } |
127 | 134 | ||
128 | void Gats::List::prepend( const QByteArray &s ) | 135 | void Gats::List::prepend( const QByteArray &s ) |
129 | { | 136 | { |
130 | QList<Gats::Object *>::prepend( new Gats::String( s ) ); | 137 | QList<Gats::Object *>::prepend( new Gats::String( s ) ); |
131 | } | 138 | } |
132 | 139 | ||
133 | void Gats::List::prepend( int32_t i ) | 140 | void Gats::List::prepend( int32_t i ) |
134 | { | 141 | { |
135 | QList<Gats::Object *>::prepend( new Gats::Integer( i ) ); | 142 | QList<Gats::Object *>::prepend( new Gats::Integer( i ) ); |
136 | } | 143 | } |
137 | 144 | ||
138 | void Gats::List::prepend( int64_t i ) | 145 | void Gats::List::prepend( int64_t i ) |
139 | { | 146 | { |
140 | QList<Gats::Object *>::prepend( new Gats::Integer( i ) ); | 147 | QList<Gats::Object *>::prepend( new Gats::Integer( i ) ); |
141 | } | 148 | } |
142 | 149 | ||
143 | void Gats::List::prepend( double d ) | 150 | void Gats::List::prepend( double d ) |
144 | { | 151 | { |
145 | QList<Gats::Object *>::prepend( new Gats::Float( d ) ); | 152 | QList<Gats::Object *>::prepend( new Gats::Float( d ) ); |
146 | } | 153 | } |
147 | 154 | ||
148 | void Gats::List::prependStr( const QByteArray &s ) | 155 | void Gats::List::prependStr( const QByteArray &s ) |
149 | { | 156 | { |
150 | QList<Gats::Object *>::prepend( new Gats::String( s ) ); | 157 | QList<Gats::Object *>::prepend( new Gats::String( s ) ); |
151 | } | 158 | } |
152 | 159 | ||
153 | void Gats::List::prependInt( int64_t i ) | 160 | void Gats::List::prependInt( int64_t i ) |
154 | { | 161 | { |
155 | QList<Gats::Object *>::prepend( new Gats::Integer( i ) ); | 162 | QList<Gats::Object *>::prepend( new Gats::Integer( i ) ); |
156 | } | 163 | } |
157 | 164 | ||
158 | void Gats::List::prependFloat( double d ) | 165 | void Gats::List::prependFloat( double d ) |
159 | { | 166 | { |
160 | QList<Gats::Object *>::prepend( new Gats::Float( d ) ); | 167 | QList<Gats::Object *>::prepend( new Gats::Float( d ) ); |
161 | } | 168 | } |
162 | 169 | ||
163 | void Gats::List::prependBool( bool b ) | 170 | void Gats::List::prependBool( bool b ) |
164 | { | 171 | { |
165 | QList<Gats::Object *>::prepend( new Gats::Boolean( b ) ); | 172 | QList<Gats::Object *>::prepend( new Gats::Boolean( b ) ); |
166 | } | 173 | } |
167 | 174 | ||
168 | void Gats::List::prependList( Gats::List *pL ) | 175 | void Gats::List::prependList( Gats::List *pL ) |
169 | { | 176 | { |
170 | QList<Gats::Object *>::prepend( pL ); | 177 | QList<Gats::Object *>::prepend( pL ); |
171 | } | 178 | } |
172 | 179 | ||
173 | void Gats::List::prependDict( Gats::Dictionary *pD ) | 180 | void Gats::List::prependDict( Gats::Dictionary *pD ) |
174 | { | 181 | { |
175 | QList<Gats::Object *>::prepend( pD ); | 182 | QList<Gats::Object *>::prepend( pD ); |
176 | } | 183 | } |
177 | 184 | ||
178 | Gats::List *Gats::List::prependList() | 185 | Gats::List *Gats::List::prependList() |
179 | { | 186 | { |
180 | Gats::List *pLst = new Gats::List(); | 187 | Gats::List *pLst = new Gats::List(); |
181 | prependList( pLst ); | 188 | prependList( pLst ); |
182 | return pLst; | 189 | return pLst; |
183 | } | 190 | } |
184 | 191 | ||
185 | Gats::Dictionary *Gats::List::prependDict() | 192 | Gats::Dictionary *Gats::List::prependDict() |
186 | { | 193 | { |
187 | Gats::Dictionary *pDict = new Gats::Dictionary(); | 194 | Gats::Dictionary *pDict = new Gats::Dictionary(); |
188 | prependDict( pDict ); | 195 | prependDict( pDict ); |
189 | return pDict; | 196 | return pDict; |
190 | } | 197 | } |
191 | /* | 198 | /* |
192 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::List &l ) | 199 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::List &l ) |
193 | { | 200 | { |
194 | f << "(list) ["; | 201 | f << "(list) ["; |
195 | f.incIndent(); | 202 | f.incIndent(); |
196 | for( Gats::List::const_iterator i = l.begin(); i; i++ ) | 203 | for( Gats::List::const_iterator i = l.begin(); i; i++ ) |
197 | { | 204 | { |
198 | f << f.nl << **i; | 205 | f << f.nl << **i; |
199 | } | 206 | } |
200 | f.decIndent(); | 207 | f.decIndent(); |
201 | f << f.nl << "]"; | 208 | f << f.nl << "]"; |
202 | return f; | 209 | return f; |
203 | } | 210 | } |
204 | */ | 211 | */ |
diff --git a/c++-qt/src/list.h b/c++-qt/src/list.h index 6e5ac56..7577bad 100644 --- a/c++-qt/src/list.h +++ b/c++-qt/src/list.h | |||
@@ -1,3 +1,10 @@ | |||
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 | |||
1 | #ifndef GATS_LIST_H | 8 | #ifndef GATS_LIST_H |
2 | #define GATS_LIST_H | 9 | #define GATS_LIST_H |
3 | 10 | ||
@@ -6,52 +13,52 @@ | |||
6 | 13 | ||
7 | namespace Gats | 14 | namespace Gats |
8 | { | 15 | { |
9 | class Dictionary; | 16 | class Dictionary; |
10 | 17 | ||
11 | class List : public Gats::Object, public QList<Gats::Object *> | 18 | class List : public Gats::Object, public QList<Gats::Object *> |
12 | { | 19 | { |
13 | Q_OBJECT; | 20 | Q_OBJECT; |
14 | public: | 21 | public: |
15 | List(); | 22 | List(); |
16 | virtual ~List(); | 23 | virtual ~List(); |
17 | 24 | ||
18 | virtual Object *clone() const; | 25 | virtual Object *clone() const; |
19 | 26 | ||
20 | virtual Type getType() const { return typeList; } | 27 | virtual Type getType() const { return typeList; } |
21 | 28 | ||
22 | virtual void write( QIODevice &rOut ) const; | 29 | virtual void write( QIODevice &rOut ) const; |
23 | virtual void read( QIODevice &rIn, char cType ); | 30 | virtual void read( QIODevice &rIn, char cType ); |
24 | 31 | ||
25 | void append( const char *s ); | 32 | void append( const char *s ); |
26 | void append( const QByteArray &s ); | 33 | void append( const QByteArray &s ); |
27 | void append( int32_t i ); | 34 | void append( int32_t i ); |
28 | void append( int64_t i ); | 35 | void append( int64_t i ); |
29 | void append( double d ); | 36 | void append( double d ); |
30 | using QList<Gats::Object *>::append; | 37 | using QList<Gats::Object *>::append; |
31 | void appendStr( const QByteArray &s ); | 38 | void appendStr( const QByteArray &s ); |
32 | void appendInt( int64_t i ); | 39 | void appendInt( int64_t i ); |
33 | void appendFloat( double d ); | 40 | void appendFloat( double d ); |
34 | void appendBool( bool b ); | 41 | void appendBool( bool b ); |
35 | void appendList( Gats::List *pL ); | 42 | void appendList( Gats::List *pL ); |
36 | void appendDict( Gats::Dictionary *pD ); | 43 | void appendDict( Gats::Dictionary *pD ); |
37 | Gats::List *appendList(); | 44 | Gats::List *appendList(); |
38 | Gats::Dictionary *appendDict(); | 45 | Gats::Dictionary *appendDict(); |
39 | 46 | ||
40 | void prepend( const char *s ); | 47 | void prepend( const char *s ); |
41 | void prepend( const QByteArray &s ); | 48 | void prepend( const QByteArray &s ); |
42 | void prepend( int32_t i ); | 49 | void prepend( int32_t i ); |
43 | void prepend( int64_t i ); | 50 | void prepend( int64_t i ); |
44 | void prepend( double d ); | 51 | void prepend( double d ); |
45 | using QList<Gats::Object *>::prepend; | 52 | using QList<Gats::Object *>::prepend; |
46 | void prependStr( const QByteArray &s ); | 53 | void prependStr( const QByteArray &s ); |
47 | void prependInt( int64_t i ); | 54 | void prependInt( int64_t i ); |
48 | void prependFloat( double d ); | 55 | void prependFloat( double d ); |
49 | void prependBool( bool b ); | 56 | void prependBool( bool b ); |
50 | void prependList( Gats::List *pL ); | 57 | void prependList( Gats::List *pL ); |
51 | void prependDict( Gats::Dictionary *pD ); | 58 | void prependDict( Gats::Dictionary *pD ); |
52 | Gats::List *prependList(); | 59 | Gats::List *prependList(); |
53 | Gats::Dictionary *prependDict(); | 60 | Gats::Dictionary *prependDict(); |
54 | }; | 61 | }; |
55 | }; | 62 | }; |
56 | 63 | ||
57 | //Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::List &l ); | 64 | //Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::List &l ); |
diff --git a/c++-qt/src/null.cpp b/c++-qt/src/null.cpp index f259887..8d46250 100644 --- a/c++-qt/src/null.cpp +++ b/c++-qt/src/null.cpp | |||
@@ -1,3 +1,10 @@ | |||
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 | |||
1 | #include "gats-qt/null.h" | 8 | #include "gats-qt/null.h" |
2 | 9 | ||
3 | #include <QIODevice> | 10 | #include <QIODevice> |
@@ -12,12 +19,12 @@ Gats::Null::~Null() | |||
12 | 19 | ||
13 | Gats::Object *Gats::Null::clone() const | 20 | Gats::Object *Gats::Null::clone() const |
14 | { | 21 | { |
15 | return new Gats::Null(); | 22 | return new Gats::Null(); |
16 | } | 23 | } |
17 | 24 | ||
18 | void Gats::Null::write( QIODevice &rOut ) const | 25 | void Gats::Null::write( QIODevice &rOut ) const |
19 | { | 26 | { |
20 | rOut.write("n", 1 ); | 27 | rOut.write("n", 1 ); |
21 | } | 28 | } |
22 | 29 | ||
23 | void Gats::Null::read( QIODevice &rIn, char cType ) | 30 | void Gats::Null::read( QIODevice &rIn, char cType ) |
@@ -26,6 +33,6 @@ void Gats::Null::read( QIODevice &rIn, char cType ) | |||
26 | /* | 33 | /* |
27 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Null &b ) | 34 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Null &b ) |
28 | { | 35 | { |
29 | return f << "(bool) " << b.getValue(); | 36 | return f << "(bool) " << b.getValue(); |
30 | } | 37 | } |
31 | */ | 38 | */ |
diff --git a/c++-qt/src/null.h b/c++-qt/src/null.h index 354de12..f3ec45b 100644 --- a/c++-qt/src/null.h +++ b/c++-qt/src/null.h | |||
@@ -1,3 +1,10 @@ | |||
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 | |||
1 | #ifndef GATS_NULL_H | 8 | #ifndef GATS_NULL_H |
2 | #define GATS_NULL_H | 9 | #define GATS_NULL_H |
3 | 10 | ||
@@ -7,20 +14,20 @@ class QIODevice; | |||
7 | 14 | ||
8 | namespace Gats | 15 | namespace Gats |
9 | { | 16 | { |
10 | class Null : public Gats::Object | 17 | class Null : public Gats::Object |
11 | { | 18 | { |
12 | Q_OBJECT; | 19 | Q_OBJECT; |
13 | public: | 20 | public: |
14 | Null(); | 21 | Null(); |
15 | virtual ~Null(); | 22 | virtual ~Null(); |
16 | 23 | ||
17 | virtual Object *clone() const; | 24 | virtual Object *clone() const; |
18 | 25 | ||
19 | virtual Type getType() const { return typeNull; } | 26 | virtual Type getType() const { return typeNull; } |
20 | 27 | ||
21 | virtual void write( QIODevice &rOut ) const; | 28 | virtual void write( QIODevice &rOut ) const; |
22 | virtual void read( QIODevice &rIn, char cType ); | 29 | virtual void read( QIODevice &rIn, char cType ); |
23 | }; | 30 | }; |
24 | }; | 31 | }; |
25 | 32 | ||
26 | //Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Null &b ); | 33 | //Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Null &b ); |
diff --git a/c++-qt/src/object.cpp b/c++-qt/src/object.cpp index 4290e17..7c05228 100644 --- a/c++-qt/src/object.cpp +++ b/c++-qt/src/object.cpp | |||
@@ -1,3 +1,10 @@ | |||
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 | |||
1 | #include "gats-qt/object.h" | 8 | #include "gats-qt/object.h" |
2 | 9 | ||
3 | #include "gats-qt/integer.h" | 10 | #include "gats-qt/integer.h" |
@@ -22,126 +29,126 @@ Gats::Object::~Object() | |||
22 | 29 | ||
23 | Gats::Object *Gats::Object::read( QIODevice &rIn ) | 30 | Gats::Object *Gats::Object::read( QIODevice &rIn ) |
24 | { | 31 | { |
25 | char buf; | 32 | char buf; |
26 | rIn.read( &buf, 1 ); | 33 | rIn.read( &buf, 1 ); |
27 | Object *pObj = NULL; | 34 | Object *pObj = NULL; |
28 | switch( buf ) | 35 | switch( buf ) |
29 | { | 36 | { |
30 | case 'i': | 37 | case 'i': |
31 | pObj = new Gats::Integer(); | 38 | pObj = new Gats::Integer(); |
32 | break; | 39 | break; |
33 | 40 | ||
34 | case 's': | 41 | case 's': |
35 | pObj = new Gats::String(); | 42 | pObj = new Gats::String(); |
36 | break; | 43 | break; |
37 | 44 | ||
38 | case '0': | 45 | case '0': |
39 | case '1': | 46 | case '1': |
40 | pObj = new Gats::Boolean(); | 47 | pObj = new Gats::Boolean(); |
41 | break; | 48 | break; |
42 | 49 | ||
43 | case 'l': | 50 | case 'l': |
44 | pObj = new Gats::List(); | 51 | pObj = new Gats::List(); |
45 | break; | 52 | break; |
46 | 53 | ||
47 | case 'd': | 54 | case 'd': |
48 | pObj = new Gats::Dictionary(); | 55 | pObj = new Gats::Dictionary(); |
49 | break; | 56 | break; |
50 | 57 | ||
51 | case 'f': // Normal floats | 58 | case 'f': // Normal floats |
52 | case 'F': // Special float values | 59 | case 'F': // Special float values |
53 | pObj = new Gats::Float(); | 60 | pObj = new Gats::Float(); |
54 | break; | 61 | break; |
55 | 62 | ||
56 | case 'n': | 63 | case 'n': |
57 | pObj = new Gats::Null(); | 64 | pObj = new Gats::Null(); |
58 | break; | 65 | break; |
59 | 66 | ||
60 | case 'e': | 67 | case 'e': |
61 | return NULL; | 68 | return NULL; |
62 | 69 | ||
63 | default: | 70 | default: |
64 | throw "Invalid Gats type discovered: "; | 71 | throw "Invalid Gats type discovered: "; |
65 | } | 72 | } |
66 | 73 | ||
67 | pObj->read( rIn, buf ); | 74 | pObj->read( rIn, buf ); |
68 | 75 | ||
69 | return pObj; | 76 | return pObj; |
70 | } | 77 | } |
71 | /* | 78 | /* |
72 | void Gats::Object::skipWs( QByteArray::const_iterator &i ) | 79 | void Gats::Object::skipWs( QByteArray::const_iterator &i ) |
73 | { | 80 | { |
74 | for(; *i == ' ' || *i == '\t' || *i == '\r' || *i == '\n'; i++ ) { } | 81 | for(; *i == ' ' || *i == '\t' || *i == '\r' || *i == '\n'; i++ ) { } |
75 | } | 82 | } |
76 | 83 | ||
77 | QByteArray Gats::Object::token( QByteArray::const_iterator &i ) | 84 | QByteArray Gats::Object::token( QByteArray::const_iterator &i ) |
78 | { | 85 | { |
79 | QByteArray sRet; | 86 | QByteArray sRet; |
80 | if( *i == '\"' ) | 87 | if( *i == '\"' ) |
81 | { | 88 | { |
82 | for( i++; i && *i != '\"' ; i++ ) | 89 | for( i++; i && *i != '\"' ; i++ ) |
83 | { | 90 | { |
84 | if( *i == '\\' ) | 91 | if( *i == '\\' ) |
85 | i++; | 92 | i++; |
86 | sRet += i; | 93 | sRet += i; |
87 | } | 94 | } |
88 | i++; | 95 | i++; |
89 | } | 96 | } |
90 | else | 97 | else |
91 | { | 98 | { |
92 | for(; i && *i != ' ' && *i != '\t' && *i != '\r' && *i != '\n' && | 99 | for(; i && *i != ' ' && *i != '\t' && *i != '\r' && *i != '\n' && |
93 | *i != ',' && *i != ']' && *i != '}' && *i != '[' && | 100 | *i != ',' && *i != ']' && *i != '}' && *i != '[' && |
94 | *i != '{'; i++ ) | 101 | *i != '{'; i++ ) |
95 | { | 102 | { |
96 | sRet += i; | 103 | sRet += i; |
97 | } | 104 | } |
98 | } | 105 | } |
99 | 106 | ||
100 | return sRet; | 107 | return sRet; |
101 | } | 108 | } |
102 | 109 | ||
103 | Gats::Object *Gats::Object::strToGats( QByteArray::const_iterator &i ) | 110 | Gats::Object *Gats::Object::strToGats( QByteArray::const_iterator &i ) |
104 | { | 111 | { |
105 | skipWs( i ); | 112 | skipWs( i ); |
106 | 113 | ||
107 | switch( *i ) | 114 | switch( *i ) |
108 | { | 115 | { |
109 | case '[': | 116 | case '[': |
110 | { | 117 | { |
111 | Gats::List *pLst = new Gats::List(); | 118 | Gats::List *pLst = new Gats::List(); |
112 | i++; | 119 | i++; |
113 | for(;;) | 120 | for(;;) |
114 | { | 121 | { |
115 | Gats::Object *pObj = strToGats( i ); | 122 | Gats::Object *pObj = strToGats( i ); |
116 | if( !pObj ) | 123 | if( !pObj ) |
117 | break; | 124 | break; |
118 | pLst->append( pObj ); | 125 | pLst->append( pObj ); |
119 | skipWs( i ); | 126 | skipWs( i ); |
120 | switch( *i ) | 127 | switch( *i ) |
121 | { | 128 | { |
122 | case ',': | 129 | case ',': |
123 | i++; | 130 | i++; |
124 | break; | 131 | break; |
125 | 132 | ||
126 | case ']': | 133 | case ']': |
127 | i++; | 134 | i++; |
128 | return pLst; | 135 | return pLst; |
129 | 136 | ||
130 | default: | 137 | default: |
131 | throw "PUT GOOD EXCEPTION HERE"; | 138 | throw "PUT GOOD EXCEPTION HERE"; |
132 | } | 139 | } |
133 | } | 140 | } |
134 | } | 141 | } |
135 | break; | 142 | break; |
136 | 143 | ||
137 | case '{': | 144 | case '{': |
138 | { | 145 | { |
139 | Gats::Dictionary *pDict = new Gats::Dictionary(); | 146 | Gats::Dictionary *pDict = new Gats::Dictionary(); |
140 | i++; | 147 | i++; |
141 | for(;;) | 148 | for(;;) |
142 | { | 149 | { |
143 | skipWs( i ); | 150 | skipWs( i ); |
144 | if( *i != '\"' ) | 151 | if( *i != '\"' ) |
145 | throw "PUT GOOD EXCEPTION HERE"; | 152 | throw "PUT GOOD EXCEPTION HERE"; |
146 | QByteArray sKey = token( i ); | 153 | QByteArray sKey = token( i ); |
147 | skipWs( i ); | 154 | skipWs( i ); |
@@ -172,144 +179,144 @@ Gats::Object *Gats::Object::strToGats( QByteArray::const_iterator &i ) | |||
172 | break; | 179 | break; |
173 | 180 | ||
174 | case '\"': | 181 | case '\"': |
175 | return new Gats::String( token( i ) ); | 182 | return new Gats::String( token( i ) ); |
176 | break; | 183 | break; |
177 | 184 | ||
178 | case '0': | 185 | case '0': |
179 | case '1': | 186 | case '1': |
180 | case '2': | 187 | case '2': |
181 | case '3': | 188 | case '3': |
182 | case '4': | 189 | case '4': |
183 | case '5': | 190 | case '5': |
184 | case '6': | 191 | case '6': |
185 | case '7': | 192 | case '7': |
186 | case '8': | 193 | case '8': |
187 | case '9': | 194 | case '9': |
188 | case '.': | 195 | case '.': |
189 | case '+': | 196 | case '+': |
190 | case '-': | 197 | case '-': |
191 | { | 198 | { |
192 | QByteArray s = token( i ); | 199 | QByteArray s = token( i ); |
193 | int iSize = s.getSize(); | 200 | int iSize = s.getSize(); |
194 | if( s[iSize-1] == 'i' ) | 201 | if( s[iSize-1] == 'i' ) |
195 | { | 202 | { |
196 | return new Gats::Integer( | 203 | return new Gats::Integer( |
197 | strtoll( s.getStr(), NULL, 10 ) | 204 | strtoll( s.getStr(), NULL, 10 ) |
198 | ); | 205 | ); |
199 | } | 206 | } |
200 | else if( s[iSize-1] == 'f' ) | 207 | else if( s[iSize-1] == 'f' ) |
201 | { | 208 | { |
202 | return new Gats::Float( | 209 | return new Gats::Float( |
203 | strtod( s.getStr(), NULL ) | 210 | strtod( s.getStr(), NULL ) |
204 | ); | 211 | ); |
205 | } | 212 | } |
206 | else | 213 | else |
207 | { | 214 | { |
208 | for( QByteArray::iterator i = s.begin(); i; i++ ) | 215 | for( QByteArray::iterator i = s.begin(); i; i++ ) |
209 | { | 216 | { |
210 | if( *i == '.' ) | 217 | if( *i == '.' ) |
211 | return new Gats::Float( | 218 | return new Gats::Float( |
212 | strtod( s.getStr(), NULL ) | 219 | strtod( s.getStr(), NULL ) |
213 | ); | 220 | ); |
214 | } | 221 | } |
215 | return new Gats::Integer( | 222 | return new Gats::Integer( |
216 | strtoll( s.getStr(), NULL, 10 ) | 223 | strtoll( s.getStr(), NULL, 10 ) |
217 | ); | 224 | ); |
218 | } | 225 | } |
219 | } | 226 | } |
220 | break; | 227 | break; |
221 | 228 | ||
222 | default: | 229 | default: |
223 | { | 230 | { |
224 | QByteArray s = token( i ); | 231 | QByteArray s = token( i ); |
225 | int iSize = s.getSize(); | 232 | int iSize = s.getSize(); |
226 | // Test for explicit types first | 233 | // Test for explicit types first |
227 | if( iSize > 2 ) | 234 | if( iSize > 2 ) |
228 | { | 235 | { |
229 | if( (s[0] >= '0' && s[0] <= '9') || s[0] == '+' || s[0] == '-' ) | 236 | if( (s[0] >= '0' && s[0] <= '9') || s[0] == '+' || s[0] == '-' ) |
230 | { | 237 | { |
231 | } | 238 | } |
232 | else | 239 | else |
233 | { | 240 | { |
234 | QByteArray st = s.toLower(); | 241 | QByteArray st = s.toLower(); |
235 | if( st == "true" ) | 242 | if( st == "true" ) |
236 | { | 243 | { |
237 | return new Gats::Boolean( true ); | 244 | return new Gats::Boolean( true ); |
238 | } | 245 | } |
239 | else if( st == "false" ) | 246 | else if( st == "false" ) |
240 | { | 247 | { |
241 | return new Gats::Boolean( false ); | 248 | return new Gats::Boolean( false ); |
242 | } | 249 | } |
243 | } | 250 | } |
244 | } | 251 | } |
245 | } | 252 | } |
246 | break; | 253 | break; |
247 | } | 254 | } |
248 | 255 | ||
249 | return NULL; | 256 | return NULL; |
250 | } | 257 | } |
251 | 258 | ||
252 | Gats::Object *Gats::Object::strToGats( const QByteArray &sStr ) | 259 | Gats::Object *Gats::Object::strToGats( const QByteArray &sStr ) |
253 | { | 260 | { |
254 | QByteArray::const_iterator i = sStr.begin(); | 261 | QByteArray::const_iterator i = sStr.begin(); |
255 | 262 | ||
256 | return strToGats( i ); | 263 | return strToGats( i ); |
257 | } | 264 | } |
258 | 265 | ||
259 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Object &obj ) | 266 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Object &obj ) |
260 | { | 267 | { |
261 | switch( obj.getType() ) | 268 | switch( obj.getType() ) |
262 | { | 269 | { |
263 | case Gats::typeDictionary: | 270 | case Gats::typeDictionary: |
264 | return f << dynamic_cast<const Gats::Dictionary &>(obj); | 271 | return f << dynamic_cast<const Gats::Dictionary &>(obj); |
265 | 272 | ||
266 | case Gats::typeList: | 273 | case Gats::typeList: |
267 | return f << dynamic_cast<const Gats::List &>(obj); | 274 | return f << dynamic_cast<const Gats::List &>(obj); |
268 | 275 | ||
269 | case Gats::typeString: | 276 | case Gats::typeString: |
270 | return f << dynamic_cast<const Gats::String &>(obj); | 277 | return f << dynamic_cast<const Gats::String &>(obj); |
271 | 278 | ||
272 | case Gats::typeInteger: | 279 | case Gats::typeInteger: |
273 | return f << dynamic_cast<const Gats::Integer &>(obj); | 280 | return f << dynamic_cast<const Gats::Integer &>(obj); |
274 | 281 | ||
275 | case Gats::typeFloat: | 282 | case Gats::typeFloat: |
276 | return f << dynamic_cast<const Gats::Float &>(obj); | 283 | return f << dynamic_cast<const Gats::Float &>(obj); |
277 | 284 | ||
278 | case Gats::typeBoolean: | 285 | case Gats::typeBoolean: |
279 | return f << dynamic_cast<const Gats::Boolean &>(obj); | 286 | return f << dynamic_cast<const Gats::Boolean &>(obj); |
280 | 287 | ||
281 | default: | 288 | default: |
282 | return f << "***ERROR: Bad Gats type***"; | 289 | return f << "***ERROR: Bad Gats type***"; |
283 | } | 290 | } |
284 | } | 291 | } |
285 | 292 | ||
286 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Type &t ) | 293 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Type &t ) |
287 | { | 294 | { |
288 | switch( t ) | 295 | switch( t ) |
289 | { | 296 | { |
290 | case Gats::typeDictionary: return f << "dictionary"; | 297 | case Gats::typeDictionary: return f << "dictionary"; |
291 | case Gats::typeList: return f << "list"; | 298 | case Gats::typeList: return f << "list"; |
292 | case Gats::typeString: return f << "string"; | 299 | case Gats::typeString: return f << "string"; |
293 | case Gats::typeInteger: return f << "integer"; | 300 | case Gats::typeInteger: return f << "integer"; |
294 | case Gats::typeFloat: return f << "float"; | 301 | case Gats::typeFloat: return f << "float"; |
295 | case Gats::typeBoolean: return f << "boolean"; | 302 | case Gats::typeBoolean: return f << "boolean"; |
296 | } | 303 | } |
297 | 304 | ||
298 | return f << "***unknown***"; | 305 | return f << "***unknown***"; |
299 | } | 306 | } |
300 | */ | 307 | */ |
301 | const char *Gats::typeToStr( Gats::Type t ) | 308 | const char *Gats::typeToStr( Gats::Type t ) |
302 | { | 309 | { |
303 | switch( t ) | 310 | switch( t ) |
304 | { | 311 | { |
305 | case Gats::typeDictionary: return "dictionary"; | 312 | case Gats::typeDictionary: return "dictionary"; |
306 | case Gats::typeList: return "list"; | 313 | case Gats::typeList: return "list"; |
307 | case Gats::typeString: return "string"; | 314 | case Gats::typeString: return "string"; |
308 | case Gats::typeInteger: return "integer"; | 315 | case Gats::typeInteger: return "integer"; |
309 | case Gats::typeFloat: return "float"; | 316 | case Gats::typeFloat: return "float"; |
310 | case Gats::typeBoolean: return "boolean"; | 317 | case Gats::typeBoolean: return "boolean"; |
311 | } | 318 | } |
312 | 319 | ||
313 | return "***unknown***"; | 320 | return "***unknown***"; |
314 | } | 321 | } |
315 | 322 | ||
diff --git a/c++-qt/src/object.h b/c++-qt/src/object.h index 008ebef..7e12b87 100644 --- a/c++-qt/src/object.h +++ b/c++-qt/src/object.h | |||
@@ -1,3 +1,10 @@ | |||
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 | |||
1 | #ifndef GATS_OBJECT_H | 8 | #ifndef GATS_OBJECT_H |
2 | #define GATS_OBJECT_H | 9 | #define GATS_OBJECT_H |
3 | 10 | ||
@@ -8,44 +15,44 @@ class QIODevice; | |||
8 | 15 | ||
9 | namespace Gats | 16 | namespace Gats |
10 | { | 17 | { |
11 | enum Type | 18 | enum Type |
12 | { | 19 | { |
13 | typeDictionary, | 20 | typeDictionary, |
14 | typeList, | 21 | typeList, |
15 | typeString, | 22 | typeString, |
16 | typeInteger, | 23 | typeInteger, |
17 | typeFloat, | 24 | typeFloat, |
18 | typeBoolean, | 25 | typeBoolean, |
19 | typeNull | 26 | typeNull |
20 | }; | 27 | }; |
21 | 28 | ||
22 | /** | 29 | /** |
23 | * The baseclass for every type that can be stored in a packet. | 30 | * The baseclass for every type that can be stored in a packet. |
24 | */ | 31 | */ |
25 | class Object : public QObject | 32 | class Object : public QObject |
26 | { | 33 | { |
27 | Q_OBJECT; | 34 | Q_OBJECT; |
28 | public: | 35 | public: |
29 | Object(); | 36 | Object(); |
30 | virtual ~Object(); | 37 | virtual ~Object(); |
31 | 38 | ||
32 | virtual Object *clone() const=0; | 39 | virtual Object *clone() const=0; |
33 | 40 | ||
34 | virtual Type getType() const =0; | 41 | virtual Type getType() const =0; |
35 | 42 | ||
36 | virtual void write( QIODevice &rOut ) const=0; | 43 | virtual void write( QIODevice &rOut ) const=0; |
37 | virtual void read( QIODevice &rIn, char cType )=0; | 44 | virtual void read( QIODevice &rIn, char cType )=0; |
38 | 45 | ||
39 | static Object *read( QIODevice &rIn ); | 46 | static Object *read( QIODevice &rIn ); |
40 | // static Object *strToGats( const &sStr ); | 47 | // static Object *strToGats( const &sStr ); |
41 | 48 | ||
42 | private: | 49 | private: |
43 | // static Object *strToGats( QByteArray::const_iterator &i ); | 50 | // static Object *strToGats( QByteArray::const_iterator &i ); |
44 | // static QByteArray token( QByteArray::const_iterator &i ); | 51 | // static QByteArray token( QByteArray::const_iterator &i ); |
45 | // static void skipWs( QByteArray::const_iterator &i ); | 52 | // static void skipWs( QByteArray::const_iterator &i ); |
46 | }; | 53 | }; |
47 | 54 | ||
48 | const char *typeToStr( Type t ); | 55 | const char *typeToStr( Type t ); |
49 | }; | 56 | }; |
50 | 57 | ||
51 | //Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Object &obj ); | 58 | //Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Object &obj ); |
diff --git a/c++-qt/src/string.cpp b/c++-qt/src/string.cpp index ef23829..7d2d20f 100644 --- a/c++-qt/src/string.cpp +++ b/c++-qt/src/string.cpp | |||
@@ -1,3 +1,10 @@ | |||
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 | |||
1 | #include "gats-qt/string.h" | 8 | #include "gats-qt/string.h" |
2 | 9 | ||
3 | #include "gats-qt/integer.h" | 10 | #include "gats-qt/integer.h" |
@@ -7,27 +14,27 @@ Gats::String::String() | |||
7 | } | 14 | } |
8 | 15 | ||
9 | Gats::String::String( const char *s ) : | 16 | Gats::String::String( const char *s ) : |
10 | QByteArray( s ) | 17 | QByteArray( s ) |
11 | { | 18 | { |
12 | } | 19 | } |
13 | 20 | ||
14 | Gats::String::String( const char *s, long iLength ) : | 21 | Gats::String::String( const char *s, long iLength ) : |
15 | QByteArray( s, iLength ) | 22 | QByteArray( s, iLength ) |
16 | { | 23 | { |
17 | } | 24 | } |
18 | 25 | ||
19 | Gats::String::String( long iLength ) : | 26 | Gats::String::String( long iLength ) : |
20 | QByteArray( iLength, '\0' ) | 27 | QByteArray( iLength, '\0' ) |
21 | { | 28 | { |
22 | } | 29 | } |
23 | 30 | ||
24 | Gats::String::String( const String &s ) : | 31 | Gats::String::String( const String &s ) : |
25 | QByteArray( s ) | 32 | QByteArray( s ) |
26 | { | 33 | { |
27 | } | 34 | } |
28 | 35 | ||
29 | Gats::String::String( const QByteArray &s ) : | 36 | Gats::String::String( const QByteArray &s ) : |
30 | QByteArray( s ) | 37 | QByteArray( s ) |
31 | { | 38 | { |
32 | } | 39 | } |
33 | 40 | ||
@@ -37,29 +44,29 @@ Gats::String::~String() | |||
37 | 44 | ||
38 | Gats::Object *Gats::String::clone() const | 45 | Gats::Object *Gats::String::clone() const |
39 | { | 46 | { |
40 | QByteArray baClone = *this; | 47 | QByteArray baClone = *this; |
41 | baClone.detach(); | 48 | baClone.detach(); |
42 | return new Gats::String( baClone ); | 49 | return new Gats::String( baClone ); |
43 | } | 50 | } |
44 | 51 | ||
45 | void Gats::String::write( QIODevice &rOut ) const | 52 | void Gats::String::write( QIODevice &rOut ) const |
46 | { | 53 | { |
47 | rOut.write("s", 1 ); | 54 | rOut.write("s", 1 ); |
48 | uint32_t iSize = size(); | 55 | uint32_t iSize = size(); |
49 | Gats::Integer::writePackedInt( rOut, iSize ); | 56 | Gats::Integer::writePackedInt( rOut, iSize ); |
50 | rOut.write( constData(), iSize ); | 57 | rOut.write( constData(), iSize ); |
51 | } | 58 | } |
52 | 59 | ||
53 | void Gats::String::read( QIODevice &rIn, char cType ) | 60 | void Gats::String::read( QIODevice &rIn, char cType ) |
54 | { | 61 | { |
55 | uint32_t iSize; | 62 | uint32_t iSize; |
56 | Gats::Integer::readPackedInt( rIn, iSize ); | 63 | Gats::Integer::readPackedInt( rIn, iSize ); |
57 | fill( '\0', iSize ); | 64 | fill( '\0', iSize ); |
58 | rIn.read( data(), iSize ); | 65 | rIn.read( data(), iSize ); |
59 | } | 66 | } |
60 | /* | 67 | /* |
61 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::String &s ) | 68 | Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::String &s ) |
62 | { | 69 | { |
63 | return f << "(str) \"" << dynamic_cast<const QByteArray &>(s) << "\""; | 70 | return f << "(str) \"" << dynamic_cast<const QByteArray &>(s) << "\""; |
64 | } | 71 | } |
65 | */ | 72 | */ |
diff --git a/c++-qt/src/string.h b/c++-qt/src/string.h index 9bf6ce3..a679fc0 100644 --- a/c++-qt/src/string.h +++ b/c++-qt/src/string.h | |||
@@ -1,3 +1,10 @@ | |||
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 | |||
1 | #ifndef GATS_STRING_H | 8 | #ifndef GATS_STRING_H |
2 | #define GATS_STRING_H | 9 | #define GATS_STRING_H |
3 | 10 | ||
@@ -6,27 +13,27 @@ | |||
6 | 13 | ||
7 | namespace Gats | 14 | namespace Gats |
8 | { | 15 | { |
9 | class String : public Gats::Object, public QByteArray | 16 | class String : public Gats::Object, public QByteArray |
10 | { | 17 | { |
11 | Q_OBJECT; | 18 | Q_OBJECT; |
12 | public: | 19 | public: |
13 | String(); | 20 | String(); |
14 | String( const char *s ); | 21 | String( const char *s ); |
15 | String( const char *s, long iLength ); | 22 | String( const char *s, long iLength ); |
16 | String( long iLength ); | 23 | String( long iLength ); |
17 | String( const String &s ); | 24 | String( const String &s ); |
18 | String( const QByteArray &s ); | 25 | String( const QByteArray &s ); |
19 | virtual ~String(); | 26 | virtual ~String(); |
20 | 27 | ||
21 | virtual Object *clone() const; | 28 | virtual Object *clone() const; |
22 | 29 | ||
23 | virtual Type getType() const { return typeString; } | 30 | virtual Type getType() const { return typeString; } |
24 | 31 | ||
25 | virtual void write( QIODevice &rOut ) const; | 32 | virtual void write( QIODevice &rOut ) const; |
26 | virtual void read( QIODevice &rIn, char cType ); | 33 | virtual void read( QIODevice &rIn, char cType ); |
27 | 34 | ||
28 | private: | 35 | private: |
29 | }; | 36 | }; |
30 | }; | 37 | }; |
31 | 38 | ||
32 | //Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::String &s ); | 39 | //Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::String &s ); |
diff --git a/c++-qt/src/types.h b/c++-qt/src/types.h index bd1c8ae..1efdf26 100644 --- a/c++-qt/src/types.h +++ b/c++-qt/src/types.h | |||
@@ -1,3 +1,10 @@ | |||
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 | |||
1 | #include "gats-qt/object.h" | 8 | #include "gats-qt/object.h" |
2 | #include "gats-qt/boolean.h" | 9 | #include "gats-qt/boolean.h" |
3 | #include "gats-qt/dictionary.h" | 10 | #include "gats-qt/dictionary.h" |