aboutsummaryrefslogtreecommitdiff
path: root/c++-qt/src/object.cpp
diff options
context:
space:
mode:
authorMike Buland <mike@xagasoft.com>2022-04-02 11:08:49 -0700
committerMike Buland <mike@xagasoft.com>2022-04-02 11:08:49 -0700
commitb522669649e81c61c6a5e390991b8fd70bfdeed9 (patch)
tree0f50f756a6b525945a6e4ae558aeee75cd957793 /c++-qt/src/object.cpp
parent70dc5d2d3bc9eb7d0a47685971e56a4767d09221 (diff)
downloadlibgats-b522669649e81c61c6a5e390991b8fd70bfdeed9.tar.gz
libgats-b522669649e81c61c6a5e390991b8fd70bfdeed9.tar.bz2
libgats-b522669649e81c61c6a5e390991b8fd70bfdeed9.tar.xz
libgats-b522669649e81c61c6a5e390991b8fd70bfdeed9.zip
Just removed a bunch of commented out code.
Diffstat (limited to '')
-rw-r--r--c++-qt/src/object.cpp229
1 files changed, 0 insertions, 229 deletions
diff --git a/c++-qt/src/object.cpp b/c++-qt/src/object.cpp
index d148774..8af203f 100644
--- a/c++-qt/src/object.cpp
+++ b/c++-qt/src/object.cpp
@@ -77,236 +77,7 @@ Gats::Object *Gats::Object::read( QIODevice &rIn )
77 77
78 return pObj; 78 return pObj;
79} 79}
80/*
81void Gats::Object::skipWs( QByteArray::const_iterator &i )
82{
83 for(; *i == ' ' || *i == '\t' || *i == '\r' || *i == '\n'; i++ ) { }
84}
85 80
86QByteArray Gats::Object::token( QByteArray::const_iterator &i )
87{
88 QByteArray sRet;
89 if( *i == '\"' )
90 {
91 for( i++; i && *i != '\"' ; i++ )
92 {
93 if( *i == '\\' )
94 i++;
95 sRet += i;
96 }
97 i++;
98 }
99 else
100 {
101 for(; i && *i != ' ' && *i != '\t' && *i != '\r' && *i != '\n' &&
102 *i != ',' && *i != ']' && *i != '}' && *i != '[' &&
103 *i != '{'; i++ )
104 {
105 sRet += i;
106 }
107 }
108
109 return sRet;
110}
111
112Gats::Object *Gats::Object::strToGats( QByteArray::const_iterator &i )
113{
114 skipWs( i );
115
116 switch( *i )
117 {
118 case '[':
119 {
120 Gats::List *pLst = new Gats::List();
121 i++;
122 for(;;)
123 {
124 Gats::Object *pObj = strToGats( i );
125 if( !pObj )
126 break;
127 pLst->append( pObj );
128 skipWs( i );
129 switch( *i )
130 {
131 case ',':
132 i++;
133 break;
134
135 case ']':
136 i++;
137 return pLst;
138
139 default:
140 throw "PUT GOOD EXCEPTION HERE";
141 }
142 }
143 }
144 break;
145
146 case '{':
147 {
148 Gats::Dictionary *pDict = new Gats::Dictionary();
149 i++;
150 for(;;)
151 {
152 skipWs( i );
153 if( *i != '\"' )
154 throw "PUT GOOD EXCEPTION HERE";
155 QByteArray sKey = token( i );
156 skipWs( i );
157 if( *i != ':' )
158 throw "PUT GOOD EXCEPTION HERE";
159 "seperated with colons.");
160 i++;
161 Gats::Object *pObj = strToGats( i );
162 if( !pObj )
163 throw "PUT GOOD EXCEPTION HERE";
164 pDict->insert( sKey, pObj );
165 skipWs( i );
166 switch( *i )
167 {
168 case ',':
169 i++;
170 break;
171
172 case '}':
173 i++;
174 return pDict;
175
176 default:
177 throw "PUT GOOD EXCEPTION HERE";
178 }
179 }
180 }
181 break;
182
183 case '\"':
184 return new Gats::String( token( i ) );
185 break;
186
187 case '0':
188 case '1':
189 case '2':
190 case '3':
191 case '4':
192 case '5':
193 case '6':
194 case '7':
195 case '8':
196 case '9':
197 case '.':
198 case '+':
199 case '-':
200 {
201 QByteArray s = token( i );
202 int iSize = s.getSize();
203 if( s[iSize-1] == 'i' )
204 {
205 return new Gats::Integer(
206 strtoll( s.getStr(), NULL, 10 )
207 );
208 }
209 else if( s[iSize-1] == 'f' )
210 {
211 return new Gats::Float(
212 strtod( s.getStr(), NULL )
213 );
214 }
215 else
216 {
217 for( QByteArray::iterator i = s.begin(); i; i++ )
218 {
219 if( *i == '.' )
220 return new Gats::Float(
221 strtod( s.getStr(), NULL )
222 );
223 }
224 return new Gats::Integer(
225 strtoll( s.getStr(), NULL, 10 )
226 );
227 }
228 }
229 break;
230
231 default:
232 {
233 QByteArray s = token( i );
234 int iSize = s.getSize();
235 // Test for explicit types first
236 if( iSize > 2 )
237 {
238 if( (s[0] >= '0' && s[0] <= '9') || s[0] == '+' || s[0] == '-' )
239 {
240 }
241 else
242 {
243 QByteArray st = s.toLower();
244 if( st == "true" )
245 {
246 return new Gats::Boolean( true );
247 }
248 else if( st == "false" )
249 {
250 return new Gats::Boolean( false );
251 }
252 }
253 }
254 }
255 break;
256 }
257
258 return NULL;
259}
260
261Gats::Object *Gats::Object::strToGats( const QByteArray &sStr )
262{
263 QByteArray::const_iterator i = sStr.begin();
264
265 return strToGats( i );
266}
267
268Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Object &obj )
269{
270 switch( obj.getType() )
271 {
272 case Gats::typeDictionary:
273 return f << dynamic_cast<const Gats::Dictionary &>(obj);
274
275 case Gats::typeList:
276 return f << dynamic_cast<const Gats::List &>(obj);
277
278 case Gats::typeString:
279 return f << dynamic_cast<const Gats::String &>(obj);
280
281 case Gats::typeInteger:
282 return f << dynamic_cast<const Gats::Integer &>(obj);
283
284 case Gats::typeFloat:
285 return f << dynamic_cast<const Gats::Float &>(obj);
286
287 case Gats::typeBoolean:
288 return f << dynamic_cast<const Gats::Boolean &>(obj);
289
290 default:
291 return f << "***ERROR: Bad Gats type***";
292 }
293}
294
295Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Type &t )
296{
297 switch( t )
298 {
299 case Gats::typeDictionary: return f << "dictionary";
300 case Gats::typeList: return f << "list";
301 case Gats::typeString: return f << "string";
302 case Gats::typeInteger: return f << "integer";
303 case Gats::typeFloat: return f << "float";
304 case Gats::typeBoolean: return f << "boolean";
305 }
306
307 return f << "***unknown***";
308}
309*/
310const char *Gats::typeToStr( Gats::Type t ) 81const char *Gats::typeToStr( Gats::Type t )
311{ 82{
312 switch( t ) 83 switch( t )