aboutsummaryrefslogtreecommitdiff
path: root/src/variable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/variable.cpp')
-rw-r--r--src/variable.cpp1542
1 files changed, 771 insertions, 771 deletions
diff --git a/src/variable.cpp b/src/variable.cpp
index ffc41a6..bef0ca8 100644
--- a/src/variable.cpp
+++ b/src/variable.cpp
@@ -6,1036 +6,1036 @@ using Bu::sio;
6#include <stdlib.h> 6#include <stdlib.h>
7 7
8Variable::Variable() : 8Variable::Variable() :
9 eType( typeNone ) 9 eType( typeNone )
10{ 10{
11 memset( &uVal, 0, sizeof(uVal) ); 11 memset( &uVal, 0, sizeof(uVal) );
12} 12}
13 13
14Variable::Variable( Type t ) : 14Variable::Variable( Type t ) :
15 eType( t ) 15 eType( t )
16{ 16{
17 memset( &uVal, 0, sizeof(uVal) ); 17 memset( &uVal, 0, sizeof(uVal) );
18 if( eType == typeString || eType == typeRef ) 18 if( eType == typeString || eType == typeRef )
19 { 19 {
20 uVal.sVal = new Bu::String; 20 uVal.sVal = new Bu::String;
21 } 21 }
22 else if( eType == typeList ) 22 else if( eType == typeList )
23 { 23 {
24 uVal.lVal = new VarList; 24 uVal.lVal = new VarList;
25 } 25 }
26} 26}
27 27
28Variable::Variable( int iVal ) : 28Variable::Variable( int iVal ) :
29 eType( typeInt ) 29 eType( typeInt )
30{ 30{
31 memset( &uVal, 0, sizeof(uVal) ); 31 memset( &uVal, 0, sizeof(uVal) );
32 uVal.iVal = iVal; 32 uVal.iVal = iVal;
33} 33}
34 34
35Variable::Variable( double fVal ) : 35Variable::Variable( double fVal ) :
36 eType( typeFloat ) 36 eType( typeFloat )
37{ 37{
38 memset( &uVal, 0, sizeof(uVal) ); 38 memset( &uVal, 0, sizeof(uVal) );
39 uVal.fVal = fVal; 39 uVal.fVal = fVal;
40} 40}
41 41
42Variable::Variable( bool bVal ) : 42Variable::Variable( bool bVal ) :
43 eType( typeBool ) 43 eType( typeBool )
44{ 44{
45 memset( &uVal, 0, sizeof(uVal) ); 45 memset( &uVal, 0, sizeof(uVal) );
46 uVal.bVal = bVal; 46 uVal.bVal = bVal;
47} 47}
48 48
49Variable::Variable( const Bu::String &sVal ) : 49Variable::Variable( const Bu::String &sVal ) :
50 eType( typeString ) 50 eType( typeString )
51{ 51{
52 memset( &uVal, 0, sizeof(uVal) ); 52 memset( &uVal, 0, sizeof(uVal) );
53 uVal.sVal = new Bu::String( sVal ); 53 uVal.sVal = new Bu::String( sVal );
54} 54}
55 55
56Variable::Variable( const char *sVal ) : 56Variable::Variable( const char *sVal ) :
57 eType( typeString ) 57 eType( typeString )
58{ 58{
59 memset( &uVal, 0, sizeof(uVal) ); 59 memset( &uVal, 0, sizeof(uVal) );
60 uVal.sVal = new Bu::String( sVal ); 60 uVal.sVal = new Bu::String( sVal );
61} 61}
62 62
63Variable::Variable( const Variable &v ) : 63Variable::Variable( const Variable &v ) :
64 eType( v.eType ) 64 eType( v.eType )
65{ 65{
66 memset( &uVal, 0, sizeof(uVal) ); 66 memset( &uVal, 0, sizeof(uVal) );
67 if( eType == typeString || eType == typeRef ) 67 if( eType == typeString || eType == typeRef )
68 { 68 {
69 uVal.sVal = new Bu::String( *v.uVal.sVal ); 69 uVal.sVal = new Bu::String( *v.uVal.sVal );
70 } 70 }
71 else if( eType == typeList ) 71 else if( eType == typeList )
72 { 72 {
73 uVal.lVal = new VarList( *v.uVal.lVal ); 73 uVal.lVal = new VarList( *v.uVal.lVal );
74 } 74 }
75 else 75 else
76 { 76 {
77 uVal = v.uVal; 77 uVal = v.uVal;
78 } 78 }
79} 79}
80 80
81Variable::Variable( const class AstLeaf &l ) 81Variable::Variable( const class AstLeaf &l )
82{ 82{
83 switch( l.getDataType() ) 83 switch( l.getDataType() )
84 { 84 {
85 case AstNode::typeDataInt: 85 case AstNode::typeDataInt:
86 eType = typeInt; 86 eType = typeInt;
87 uVal.iVal = l.getIntValue(); 87 uVal.iVal = l.getIntValue();
88 break; 88 break;
89 89
90 case AstNode::typeDataFloat: 90 case AstNode::typeDataFloat:
91 eType = typeFloat; 91 eType = typeFloat;
92 uVal.fVal = l.getFloatValue(); 92 uVal.fVal = l.getFloatValue();
93 break; 93 break;
94 94
95 case AstNode::typeDataBool: 95 case AstNode::typeDataBool:
96 eType = typeBool; 96 eType = typeBool;
97 uVal.bVal = l.getBoolValue(); 97 uVal.bVal = l.getBoolValue();
98 break; 98 break;
99 99
100 case AstNode::typeDataString: 100 case AstNode::typeDataString:
101 eType = typeString; 101 eType = typeString;
102 uVal.sVal = new Bu::String( l.getStrValue() ); 102 uVal.sVal = new Bu::String( l.getStrValue() );
103 break; 103 break;
104 104
105 case AstNode::typeDataNone: 105 case AstNode::typeDataNone:
106 eType = typeNone; 106 eType = typeNone;
107 memset( &uVal, 0, sizeof(uVal) ); 107 memset( &uVal, 0, sizeof(uVal) );
108 break; 108 break;
109 109
110 default: 110 default:
111 sio << "Unhandled type <<!>>" << sio.nl << sio.nl; 111 sio << "Unhandled type <<!>>" << sio.nl << sio.nl;
112 break; 112 break;
113 } 113 }
114} 114}
115 115
116Variable::Variable( const StrList &lst ) 116Variable::Variable( const StrList &lst )
117{ 117{
118 if( lst.getSize() == 1 ) 118 if( lst.getSize() == 1 )
119 { 119 {
120 eType = typeString; 120 eType = typeString;
121 uVal.sVal = new Bu::String( lst.first() ); 121 uVal.sVal = new Bu::String( lst.first() );
122 } 122 }
123 else 123 else
124 { 124 {
125 eType = typeList; 125 eType = typeList;
126 uVal.lVal = new VarList(); 126 uVal.lVal = new VarList();
127 for( StrList::const_iterator i = lst.begin(); i; i++ ) 127 for( StrList::const_iterator i = lst.begin(); i; i++ )
128 { 128 {
129 uVal.lVal->append( Variable( *i ) ); 129 uVal.lVal->append( Variable( *i ) );
130 } 130 }
131 } 131 }
132} 132}
133 133
134Variable::Variable( const VarList &lst ) 134Variable::Variable( const VarList &lst )
135{ 135{
136 eType = typeList; 136 eType = typeList;
137 uVal.lVal = new VarList( lst ); 137 uVal.lVal = new VarList( lst );
138} 138}
139 139
140Variable::Variable( void *oVal ) : 140Variable::Variable( void *oVal ) :
141 eType( typeOpaque ) 141 eType( typeOpaque )
142{ 142{
143 memset( &uVal, 0, sizeof(uVal) ); 143 memset( &uVal, 0, sizeof(uVal) );
144 uVal.oVal = oVal; 144 uVal.oVal = oVal;
145} 145}
146 146
147Variable::~Variable() 147Variable::~Variable()
148{ 148{
149 if( eType == typeString || eType == typeRef ) 149 if( eType == typeString || eType == typeRef )
150 { 150 {
151 delete uVal.sVal; 151 delete uVal.sVal;
152 } 152 }
153 else if( eType == typeList ) 153 else if( eType == typeList )
154 { 154 {
155 delete uVal.lVal; 155 delete uVal.lVal;
156 } 156 }
157} 157}
158 158
159Variable Variable::mkRef( const Bu::String &sVal ) 159Variable Variable::mkRef( const Bu::String &sVal )
160{ 160{
161 Variable v( typeRef ); 161 Variable v( typeRef );
162 (*v.uVal.sVal) = sVal; 162 (*v.uVal.sVal) = sVal;
163 return v; 163 return v;
164} 164}
165 165
166Variable::Type Variable::getType() const 166Variable::Type Variable::getType() const
167{ 167{
168 return eType; 168 return eType;
169} 169}
170 170
171int Variable::getInt() const 171int Variable::getInt() const
172{ 172{
173 if( eType != typeInt ) throw Bu::ExceptionBase("Wrong variable type."); 173 if( eType != typeInt ) throw Bu::ExceptionBase("Wrong variable type.");
174 return uVal.iVal; 174 return uVal.iVal;
175} 175}
176 176
177double Variable::getFloat() const 177double Variable::getFloat() const
178{ 178{
179 if( eType != typeFloat ) throw Bu::ExceptionBase("Wrong variable type."); 179 if( eType != typeFloat ) throw Bu::ExceptionBase("Wrong variable type.");
180 return uVal.fVal; 180 return uVal.fVal;
181} 181}
182 182
183bool Variable::getBool() const 183bool Variable::getBool() const
184{ 184{
185 if( eType != typeBool ) throw Bu::ExceptionBase("Wrong variable type."); 185 if( eType != typeBool ) throw Bu::ExceptionBase("Wrong variable type.");
186 return uVal.bVal; 186 return uVal.bVal;
187} 187}
188 188
189const Bu::String &Variable::getString() const 189const Bu::String &Variable::getString() const
190{ 190{
191 if( eType != typeString && eType != typeRef ) throw Bu::ExceptionBase("Wrong variable type."); 191 if( eType != typeString && eType != typeRef ) throw Bu::ExceptionBase("Wrong variable type.");
192 return *uVal.sVal; 192 return *uVal.sVal;
193} 193}
194 194
195const VarList &Variable::getList() const 195const VarList &Variable::getList() const
196{ 196{
197 if( eType != typeList ) throw Bu::ExceptionBase("Wrong variable type."); 197 if( eType != typeList ) throw Bu::ExceptionBase("Wrong variable type.");
198 return *uVal.lVal; 198 return *uVal.lVal;
199} 199}
200 200
201const void *Variable::getOpaque() const 201const void *Variable::getOpaque() const
202{ 202{
203 if( eType != typeOpaque ) throw Bu::ExceptionBase("Wrong variable type."); 203 if( eType != typeOpaque ) throw Bu::ExceptionBase("Wrong variable type.");
204 return uVal.oVal; 204 return uVal.oVal;
205} 205}
206 206
207int Variable::toInt() const 207int Variable::toInt() const
208{ 208{
209 switch( eType ) 209 switch( eType )
210 { 210 {
211 case typeInt: 211 case typeInt:
212 return uVal.iVal; 212 return uVal.iVal;
213 213
214 case typeFloat: 214 case typeFloat:
215 return (int)uVal.fVal; 215 return (int)uVal.fVal;
216 216
217 case typeBool: 217 case typeBool:
218 return (uVal.bVal)?(1):(0); 218 return (uVal.bVal)?(1):(0);
219 219
220 case typeString: 220 case typeString:
221 case typeRef: 221 case typeRef:
222 return strtol( uVal.sVal->getStr(), NULL, 0 ); 222 return strtol( uVal.sVal->getStr(), NULL, 0 );
223 223
224 default: 224 default:
225 return 0; 225 return 0;
226 } 226 }
227 return 0; 227 return 0;
228} 228}
229 229
230double Variable::toFloat() const 230double Variable::toFloat() const
231{ 231{
232 switch( eType ) 232 switch( eType )
233 { 233 {
234 case typeInt: 234 case typeInt:
235 return (double)uVal.iVal; 235 return (double)uVal.iVal;
236 236
237 case typeFloat: 237 case typeFloat:
238 return uVal.fVal; 238 return uVal.fVal;
239 239
240 case typeBool: 240 case typeBool:
241 return (uVal.bVal)?(1.0):(0.0); 241 return (uVal.bVal)?(1.0):(0.0);
242 242
243 case typeString: 243 case typeString:
244 case typeRef: 244 case typeRef:
245 return strtod( uVal.sVal->getStr(), NULL ); 245 return strtod( uVal.sVal->getStr(), NULL );
246 246
247 default: 247 default:
248 return 0.0; 248 return 0.0;
249 } 249 }
250 return 0.0; 250 return 0.0;
251} 251}
252 252
253bool Variable::toBool() const 253bool Variable::toBool() const
254{ 254{
255 switch( eType ) 255 switch( eType )
256 { 256 {
257 case typeInt: 257 case typeInt:
258 return uVal.iVal != 0; 258 return uVal.iVal != 0;
259 259
260 case typeFloat: 260 case typeFloat:
261 return uVal.fVal != 0.0; 261 return uVal.fVal != 0.0;
262 262
263 case typeBool: 263 case typeBool:
264 return uVal.bVal; 264 return uVal.bVal;
265 265
266 case typeString: 266 case typeString:
267 case typeRef: 267 case typeRef:
268 return (*uVal.sVal) == "true"; 268 return (*uVal.sVal) == "true";
269 269
270 case typeList: 270 case typeList:
271 return !(*uVal.lVal).isEmpty(); 271 return !(*uVal.lVal).isEmpty();
272 272
273 default: 273 default:
274 return false; 274 return false;
275 } 275 }
276 return false; 276 return false;
277} 277}
278 278
279Bu::String Variable::toString() const 279Bu::String Variable::toString() const
280{ 280{
281 Bu::String sRet; 281 Bu::String sRet;
282 switch( eType ) 282 switch( eType )
283 { 283 {
284 case typeNone: 284 case typeNone:
285 // No type, no data, we return empty string 285 // No type, no data, we return empty string
286 break; 286 break;
287 287
288 case typeInt: 288 case typeInt:
289 sRet = Bu::String("%1").arg( uVal.iVal ); 289 sRet = Bu::String("%1").arg( uVal.iVal );
290 break; 290 break;
291 291
292 case typeFloat: 292 case typeFloat:
293 sRet = Bu::String("%1").arg( uVal.fVal ); 293 sRet = Bu::String("%1").arg( uVal.fVal );
294 break; 294 break;
295 295
296 case typeBool: 296 case typeBool:
297 sRet = (uVal.bVal)?("true"):("false"); 297 sRet = (uVal.bVal)?("true"):("false");
298 break; 298 break;
299 299
300 case typeString: 300 case typeString:
301 case typeRef: 301 case typeRef:
302 sRet = *uVal.sVal; 302 sRet = *uVal.sVal;
303 break; 303 break;
304 304
305 case typeList: 305 case typeList:
306 { 306 {
307 for( VarList::const_iterator i = uVal.lVal->begin(); i; i++ ) 307 for( VarList::const_iterator i = uVal.lVal->begin(); i; i++ )
308 { 308 {
309 if( i != uVal.lVal->begin() ) 309 if( i != uVal.lVal->begin() )
310 sRet += " "; 310 sRet += " ";
311 sRet += (*i).toString(); 311 sRet += (*i).toString();
312 } 312 }
313 } 313 }
314 break; 314 break;
315 315
316 case typeVersion: 316 case typeVersion:
317 break; 317 break;
318 318
319 case typeOpaque: 319 case typeOpaque:
320 sRet = Bu::String("<opaque:%1>").arg( uVal.oVal ); 320 sRet = Bu::String("<opaque:%1>").arg( uVal.oVal );
321 break; 321 break;
322 } 322 }
323 323
324 return sRet; 324 return sRet;
325} 325}
326 326
327VarList Variable::toList() const 327VarList Variable::toList() const
328{ 328{
329 if( eType == typeList ) 329 if( eType == typeList )
330 return *uVal.lVal; 330 return *uVal.lVal;
331 return VarList( *this ); 331 return VarList( *this );
332} 332}
333 333
334Variable Variable::toType( Type eNewType ) const 334Variable Variable::toType( Type eNewType ) const
335{ 335{
336 switch( eNewType ) 336 switch( eNewType )
337 { 337 {
338 case typeNone: 338 case typeNone:
339 return Variable(); 339 return Variable();
340 340
341 case typeBool: 341 case typeBool:
342 return Variable( toBool() ); 342 return Variable( toBool() );
343 343
344 case typeInt: 344 case typeInt:
345 return Variable( toInt() ); 345 return Variable( toInt() );
346 346
347 case typeFloat: 347 case typeFloat:
348 return Variable( toFloat() ); 348 return Variable( toFloat() );
349 349
350 case typeVersion: 350 case typeVersion:
351 return Variable(); 351 return Variable();
352 352
353 case typeString: 353 case typeString:
354 return Variable( toString() ); 354 return Variable( toString() );
355 355
356 case typeList: 356 case typeList:
357 return Variable( toList() ); 357 return Variable( toList() );
358 358
359 case typeRef: 359 case typeRef:
360 return Variable::mkRef( toString() ); 360 return Variable::mkRef( toString() );
361 361
362 case typeOpaque: 362 case typeOpaque:
363 throw Bu::ExceptionBase("Cannot convert opaque types."); 363 throw Bu::ExceptionBase("Cannot convert opaque types.");
364 } 364 }
365 throw Bu::ExceptionBase("Unhandled case in Variable toType"); 365 throw Bu::ExceptionBase("Unhandled case in Variable toType");
366} 366}
367 367
368void Variable::append( const Variable &v ) 368void Variable::append( const Variable &v )
369{ 369{
370 if( eType != typeList ) throw Bu::ExceptionBase("Wrong variable type."); 370 if( eType != typeList ) throw Bu::ExceptionBase("Wrong variable type.");
371 371
372 if( v.eType == typeList ) 372 if( v.eType == typeList )
373 { 373 {
374 uVal.lVal->append( *v.uVal.lVal ); 374 uVal.lVal->append( *v.uVal.lVal );
375 } 375 }
376 else 376 else
377 { 377 {
378 uVal.lVal->append( v ); 378 uVal.lVal->append( v );
379 } 379 }
380} 380}
381 381
382VarList::iterator Variable::begin() 382VarList::iterator Variable::begin()
383{ 383{
384 if( eType != typeList ) throw Bu::ExceptionBase("Wrong variable type."); 384 if( eType != typeList ) throw Bu::ExceptionBase("Wrong variable type.");
385 385
386 return uVal.lVal->begin(); 386 return uVal.lVal->begin();
387} 387}
388 388
389VarList::const_iterator Variable::begin() const 389VarList::const_iterator Variable::begin() const
390{ 390{
391 if( eType != typeList ) throw Bu::ExceptionBase("Wrong variable type."); 391 if( eType != typeList ) throw Bu::ExceptionBase("Wrong variable type.");
392 392
393 return const_cast<const VarList *>(uVal.lVal)->begin(); 393 return const_cast<const VarList *>(uVal.lVal)->begin();
394} 394}
395 395
396void Variable::doNegate() 396void Variable::doNegate()
397{ 397{
398 switch( eType ) 398 switch( eType )
399 { 399 {
400 case typeNone: 400 case typeNone:
401 break; 401 break;
402 402
403 case typeBool: 403 case typeBool:
404 throw Bu::ExceptionBase("You cannot negate boolean values."); 404 throw Bu::ExceptionBase("You cannot negate boolean values.");
405 405
406 case typeInt: 406 case typeInt:
407 uVal.iVal = -uVal.iVal; 407 uVal.iVal = -uVal.iVal;
408 break; 408 break;
409 409
410 case typeFloat: 410 case typeFloat:
411 uVal.fVal = -uVal.fVal; 411 uVal.fVal = -uVal.fVal;
412 break; 412 break;
413 413
414 case typeVersion: 414 case typeVersion:
415 throw Bu::ExceptionBase("You cannot negate version values."); 415 throw Bu::ExceptionBase("You cannot negate version values.");
416 416
417 case typeString: 417 case typeString:
418 throw Bu::ExceptionBase("You cannot negate string values."); 418 throw Bu::ExceptionBase("You cannot negate string values.");
419 419
420 case typeList: 420 case typeList:
421 throw Bu::ExceptionBase("You cannot negate list values."); 421 throw Bu::ExceptionBase("You cannot negate list values.");
422 422
423 case typeRef: 423 case typeRef:
424 throw Bu::ExceptionBase("You cannot negate reference values."); 424 throw Bu::ExceptionBase("You cannot negate reference values.");
425 425
426 case typeOpaque: 426 case typeOpaque:
427 throw Bu::ExceptionBase("You cannot negate opaque values."); 427 throw Bu::ExceptionBase("You cannot negate opaque values.");
428 } 428 }
429} 429}
430 430
431void Variable::doNot() 431void Variable::doNot()
432{ 432{
433 bool bVal = !toBool(); 433 bool bVal = !toBool();
434 reset( typeBool ); 434 reset( typeBool );
435 uVal.bVal = bVal; 435 uVal.bVal = bVal;
436} 436}
437 437
438const Variable &Variable::operator=( const Variable &rhs ) 438const Variable &Variable::operator=( const Variable &rhs )
439{ 439{
440 reset( rhs.eType ); 440 reset( rhs.eType );
441 if( rhs.eType == typeString || rhs.eType == typeRef ) 441 if( rhs.eType == typeString || rhs.eType == typeRef )
442 { 442 {
443 uVal.sVal = new Bu::String( *rhs.uVal.sVal ); 443 uVal.sVal = new Bu::String( *rhs.uVal.sVal );
444 } 444 }
445 else if( rhs.eType == typeList ) 445 else if( rhs.eType == typeList )
446 { 446 {
447 uVal.lVal = new VarList( *rhs.uVal.lVal ); 447 uVal.lVal = new VarList( *rhs.uVal.lVal );
448 } 448 }
449 else 449 else
450 { 450 {
451 uVal = rhs.uVal; 451 uVal = rhs.uVal;
452 } 452 }
453 453
454 return *this; 454 return *this;
455} 455}
456 456
457const Variable &Variable::operator=( const int &rhs ) 457const Variable &Variable::operator=( const int &rhs )
458{ 458{
459 reset( typeInt ); 459 reset( typeInt );
460 uVal.iVal = rhs; 460 uVal.iVal = rhs;
461 461
462 return *this; 462 return *this;
463} 463}
464 464
465const Variable &Variable::operator=( const double &rhs ) 465const Variable &Variable::operator=( const double &rhs )
466{ 466{
467 reset( typeFloat ); 467 reset( typeFloat );
468 uVal.fVal = rhs; 468 uVal.fVal = rhs;
469 469
470 return *this; 470 return *this;
471} 471}
472 472
473const Variable &Variable::operator=( const bool &rhs ) 473const Variable &Variable::operator=( const bool &rhs )
474{ 474{
475 reset( typeBool ); 475 reset( typeBool );
476 uVal.bVal = rhs; 476 uVal.bVal = rhs;
477 477
478 return *this; 478 return *this;
479} 479}
480 480
481const Variable &Variable::operator=( const Bu::String &rhs ) 481const Variable &Variable::operator=( const Bu::String &rhs )
482{ 482{
483 reset( typeString ); 483 reset( typeString );
484 uVal.sVal = new Bu::String( rhs ); 484 uVal.sVal = new Bu::String( rhs );
485 485
486 return *this; 486 return *this;
487} 487}
488 488
489const Variable &Variable::operator=( void *rhs ) 489const Variable &Variable::operator=( void *rhs )
490{ 490{
491 reset( typeOpaque ); 491 reset( typeOpaque );
492 uVal.oVal = rhs; 492 uVal.oVal = rhs;
493 493
494 return *this; 494 return *this;
495} 495}
496 496
497const Variable &Variable::operator+=( const Variable &rhs ) 497const Variable &Variable::operator+=( const Variable &rhs )
498{ 498{
499 switch( eType ) 499 switch( eType )
500 { 500 {
501 case typeNone: 501 case typeNone:
502 reset( rhs.eType ); 502 reset( rhs.eType );
503 if( eType == typeString || eType == typeRef ) 503 if( eType == typeString || eType == typeRef )
504 { 504 {
505 uVal.sVal = new Bu::String( *rhs.uVal.sVal ); 505 uVal.sVal = new Bu::String( *rhs.uVal.sVal );
506 } 506 }
507 else if( eType == typeList ) 507 else if( eType == typeList )
508 { 508 {
509 uVal.lVal = new VarList( *rhs.uVal.lVal ); 509 uVal.lVal = new VarList( *rhs.uVal.lVal );
510 } 510 }
511 else 511 else
512 { 512 {
513 uVal = rhs.uVal; 513 uVal = rhs.uVal;
514 } 514 }
515 break; 515 break;
516 516
517 case typeInt: 517 case typeInt:
518 uVal.iVal += rhs.getInt(); 518 uVal.iVal += rhs.getInt();
519 break; 519 break;
520 520
521 case typeFloat: 521 case typeFloat:
522 uVal.fVal += rhs.getFloat(); 522 uVal.fVal += rhs.getFloat();
523 break; 523 break;
524 524
525 case typeBool: 525 case typeBool:
526 throw Bu::ExceptionBase("Can't += with a boolean..."); 526 throw Bu::ExceptionBase("Can't += with a boolean...");
527 break; 527 break;
528 528
529 case typeString: 529 case typeString:
530 uVal.sVal->append(" "); 530 uVal.sVal->append(" ");
531 uVal.sVal->append( rhs.getString() ); 531 uVal.sVal->append( rhs.getString() );
532 break; 532 break;
533 533
534 case typeList: 534 case typeList:
535 uVal.lVal->append( rhs.getList() ); 535 uVal.lVal->append( rhs.getList() );
536 break; 536 break;
537 537
538 case typeVersion: 538 case typeVersion:
539 break; 539 break;
540 540
541 default: 541 default:
542 break; 542 break;
543 } 543 }
544 return *this; 544 return *this;
545} 545}
546 546
547const Variable &Variable::operator<<( const Variable &rhs ) 547const Variable &Variable::operator<<( const Variable &rhs )
548{ 548{
549 switch( eType ) 549 switch( eType )
550 { 550 {
551 case typeNone: 551 case typeNone:
552 reset( rhs.eType ); 552 reset( rhs.eType );
553 if( eType == typeString ) 553 if( eType == typeString )
554 { 554 {
555 uVal.sVal = new Bu::String( *rhs.uVal.sVal ); 555 uVal.sVal = new Bu::String( *rhs.uVal.sVal );
556 } 556 }
557 else if( eType == typeList ) 557 else if( eType == typeList )
558 { 558 {
559 uVal.lVal = new VarList( *rhs.uVal.lVal ); 559 uVal.lVal = new VarList( *rhs.uVal.lVal );
560 } 560 }
561 else 561 else
562 { 562 {
563 uVal = rhs.uVal; 563 uVal = rhs.uVal;
564 } 564 }
565 break; 565 break;
566 566
567 case typeString: 567 case typeString:
568 uVal.sVal->append( rhs.getString() ); 568 uVal.sVal->append( rhs.getString() );
569 break; 569 break;
570 570
571 case typeList: 571 case typeList:
572 uVal.lVal->append( rhs.getList() ); 572 uVal.lVal->append( rhs.getList() );
573 break; 573 break;
574 574
575 default: 575 default:
576 throw Bu::ExceptionBase("Can't << with non-string or non-list."); 576 throw Bu::ExceptionBase("Can't << with non-string or non-list.");
577 break; 577 break;
578 } 578 }
579 return *this; 579 return *this;
580} 580}
581 581
582bool Variable::operator==( const Variable &rhs ) const 582bool Variable::operator==( const Variable &rhs ) const
583{ 583{
584 if( eType != rhs.eType ) 584 if( eType != rhs.eType )
585 return false; 585 return false;
586 switch( eType ) 586 switch( eType )
587 { 587 {
588 case typeNone: 588 case typeNone:
589 return true; 589 return true;
590 590
591 case typeInt: 591 case typeInt:
592 return uVal.iVal == rhs.uVal.iVal; 592 return uVal.iVal == rhs.uVal.iVal;
593 593
594 case typeFloat: 594 case typeFloat:
595 return uVal.fVal == rhs.uVal.fVal; 595 return uVal.fVal == rhs.uVal.fVal;
596 596
597 case typeBool: 597 case typeBool:
598 return uVal.bVal == rhs.uVal.bVal; 598 return uVal.bVal == rhs.uVal.bVal;
599 599
600 case typeString: 600 case typeString:
601 case typeRef: 601 case typeRef:
602 return *uVal.sVal == *rhs.uVal.sVal; 602 return *uVal.sVal == *rhs.uVal.sVal;
603 603
604 case typeList: 604 case typeList:
605 return *uVal.lVal == *rhs.uVal.lVal; 605 return *uVal.lVal == *rhs.uVal.lVal;
606 606
607 case typeVersion: 607 case typeVersion:
608 return false; 608 return false;
609 609
610 case typeOpaque: 610 case typeOpaque:
611 return uVal.oVal == rhs.uVal.oVal; 611 return uVal.oVal == rhs.uVal.oVal;
612 } 612 }
613 613
614 return false; 614 return false;
615} 615}
616 616
617bool Variable::operator!=( const Variable &rhs ) const 617bool Variable::operator!=( const Variable &rhs ) const
618{ 618{
619 return !(*this == rhs); 619 return !(*this == rhs);
620} 620}
621 621
622bool Variable::operator<( const Variable &rhs ) const 622bool Variable::operator<( const Variable &rhs ) const
623{ 623{
624 Type eTop = Bu::buMax( eType, rhs.eType ); 624 Type eTop = Bu::buMax( eType, rhs.eType );
625 switch( eTop ) 625 switch( eTop )
626 { 626 {
627 case typeNone: 627 case typeNone:
628 return false; 628 return false;
629 629
630 case typeBool: 630 case typeBool:
631 throw Bu::ExceptionBase("You cannot < compare boolean values."); 631 throw Bu::ExceptionBase("You cannot < compare boolean values.");
632 632
633 case typeInt: 633 case typeInt:
634 return toInt() < rhs.toInt(); 634 return toInt() < rhs.toInt();
635 635
636 case typeFloat: 636 case typeFloat:
637 return toFloat() < rhs.toFloat(); 637 return toFloat() < rhs.toFloat();
638 638
639 case typeVersion: 639 case typeVersion:
640 return true; 640 return true;
641 641
642 case typeString: 642 case typeString:
643 return toString() < rhs.toString(); 643 return toString() < rhs.toString();
644 644
645 case typeList: 645 case typeList:
646 throw Bu::ExceptionBase("You cannot < compare list values."); 646 throw Bu::ExceptionBase("You cannot < compare list values.");
647 647
648 case typeRef: 648 case typeRef:
649 throw Bu::ExceptionBase("You cannot < compare reference values."); 649 throw Bu::ExceptionBase("You cannot < compare reference values.");
650 650
651 case typeOpaque: 651 case typeOpaque:
652 throw Bu::ExceptionBase("You cannot < compare opaque values."); 652 throw Bu::ExceptionBase("You cannot < compare opaque values.");
653 } 653 }
654 throw Bu::ExceptionBase("Unhandled case in Variable < compare"); 654 throw Bu::ExceptionBase("Unhandled case in Variable < compare");
655} 655}
656 656
657bool Variable::operator>( const Variable &rhs ) const 657bool Variable::operator>( const Variable &rhs ) const
658{ 658{
659 Type eTop = Bu::buMax( eType, rhs.eType ); 659 Type eTop = Bu::buMax( eType, rhs.eType );
660 switch( eTop ) 660 switch( eTop )
661 { 661 {
662 case typeNone: 662 case typeNone:
663 return false; 663 return false;
664 664
665 case typeBool: 665 case typeBool:
666 throw Bu::ExceptionBase("You cannot > compare boolean values."); 666 throw Bu::ExceptionBase("You cannot > compare boolean values.");
667 667
668 case typeInt: 668 case typeInt:
669 return toInt() > rhs.toInt(); 669 return toInt() > rhs.toInt();
670 670
671 case typeFloat: 671 case typeFloat:
672 return toFloat() > rhs.toFloat(); 672 return toFloat() > rhs.toFloat();
673 673
674 case typeVersion: 674 case typeVersion:
675 return true; 675 return true;
676 676
677 case typeString: 677 case typeString:
678 return toString() > rhs.toString(); 678 return toString() > rhs.toString();
679 679
680 case typeList: 680 case typeList:
681 throw Bu::ExceptionBase("You cannot > compare list values."); 681 throw Bu::ExceptionBase("You cannot > compare list values.");
682 682
683 case typeRef: 683 case typeRef:
684 throw Bu::ExceptionBase("You cannot > compare reference values."); 684 throw Bu::ExceptionBase("You cannot > compare reference values.");
685 685
686 case typeOpaque: 686 case typeOpaque:
687 throw Bu::ExceptionBase("You cannot > compare opaque values."); 687 throw Bu::ExceptionBase("You cannot > compare opaque values.");
688 } 688 }
689 throw Bu::ExceptionBase("Unhandled case in Variable > compare"); 689 throw Bu::ExceptionBase("Unhandled case in Variable > compare");
690} 690}
691 691
692bool Variable::operator<=( const Variable &rhs ) const 692bool Variable::operator<=( const Variable &rhs ) const
693{ 693{
694 Type eTop = Bu::buMax( eType, rhs.eType ); 694 Type eTop = Bu::buMax( eType, rhs.eType );
695 switch( eTop ) 695 switch( eTop )
696 { 696 {
697 case typeNone: 697 case typeNone:
698 return false; 698 return false;
699 699
700 case typeBool: 700 case typeBool:
701 throw Bu::ExceptionBase("You cannot <= compare boolean values."); 701 throw Bu::ExceptionBase("You cannot <= compare boolean values.");
702 702
703 case typeInt: 703 case typeInt:
704 return toInt() <= rhs.toInt(); 704 return toInt() <= rhs.toInt();
705 705
706 case typeFloat: 706 case typeFloat:
707 return toFloat() <= rhs.toFloat(); 707 return toFloat() <= rhs.toFloat();
708 708
709 case typeVersion: 709 case typeVersion:
710 return true; 710 return true;
711 711
712 case typeString: 712 case typeString:
713 return toString() <= rhs.toString(); 713 return toString() <= rhs.toString();
714 714
715 case typeList: 715 case typeList:
716 throw Bu::ExceptionBase("You cannot <= compare list values."); 716 throw Bu::ExceptionBase("You cannot <= compare list values.");
717 717
718 case typeRef: 718 case typeRef:
719 throw Bu::ExceptionBase("You cannot <= compare reference values."); 719 throw Bu::ExceptionBase("You cannot <= compare reference values.");
720 720
721 case typeOpaque: 721 case typeOpaque:
722 throw Bu::ExceptionBase("You cannot <= compare opaque values."); 722 throw Bu::ExceptionBase("You cannot <= compare opaque values.");
723 } 723 }
724 throw Bu::ExceptionBase("Unhandled case in Variable <= compare"); 724 throw Bu::ExceptionBase("Unhandled case in Variable <= compare");
725} 725}
726 726
727bool Variable::operator>=( const Variable &rhs ) const 727bool Variable::operator>=( const Variable &rhs ) const
728{ 728{
729 Type eTop = Bu::buMax( eType, rhs.eType ); 729 Type eTop = Bu::buMax( eType, rhs.eType );
730 switch( eTop ) 730 switch( eTop )
731 { 731 {
732 case typeNone: 732 case typeNone:
733 return false; 733 return false;
734 734
735 case typeBool: 735 case typeBool:
736 throw Bu::ExceptionBase("You cannot >= compare boolean values."); 736 throw Bu::ExceptionBase("You cannot >= compare boolean values.");
737 737
738 case typeInt: 738 case typeInt:
739 return toInt() >= rhs.toInt(); 739 return toInt() >= rhs.toInt();
740 740
741 case typeFloat: 741 case typeFloat:
742 return toFloat() >= rhs.toFloat(); 742 return toFloat() >= rhs.toFloat();
743 743
744 case typeVersion: 744 case typeVersion:
745 return true; 745 return true;
746 746
747 case typeString: 747 case typeString:
748 return toString() >= rhs.toString(); 748 return toString() >= rhs.toString();
749 749
750 case typeList: 750 case typeList:
751 throw Bu::ExceptionBase("You cannot >= compare list values."); 751 throw Bu::ExceptionBase("You cannot >= compare list values.");
752 752
753 case typeRef: 753 case typeRef:
754 throw Bu::ExceptionBase("You cannot >= compare reference values."); 754 throw Bu::ExceptionBase("You cannot >= compare reference values.");
755 755
756 case typeOpaque: 756 case typeOpaque:
757 throw Bu::ExceptionBase("You cannot >= compare opaque values."); 757 throw Bu::ExceptionBase("You cannot >= compare opaque values.");
758 } 758 }
759 throw Bu::ExceptionBase("Unhandled case in Variable >= compare"); 759 throw Bu::ExceptionBase("Unhandled case in Variable >= compare");
760} 760}
761 761
762Variable Variable::operator+( const Variable &rhs ) const 762Variable Variable::operator+( const Variable &rhs ) const
763{ 763{
764 Type eTop = Bu::buMax( eType, rhs.eType ); 764 Type eTop = Bu::buMax( eType, rhs.eType );
765 switch( eTop ) 765 switch( eTop )
766 { 766 {
767 case typeNone: 767 case typeNone:
768 return Variable(); 768 return Variable();
769 769
770 case typeBool: 770 case typeBool:
771 throw Bu::ExceptionBase("You cannot add boolean values."); 771 throw Bu::ExceptionBase("You cannot add boolean values.");
772 772
773 case typeInt: 773 case typeInt:
774 return Variable( toInt() + rhs.toInt() ); 774 return Variable( toInt() + rhs.toInt() );
775 775
776 case typeFloat: 776 case typeFloat:
777 return Variable( toFloat() + rhs.toFloat() ); 777 return Variable( toFloat() + rhs.toFloat() );
778 778
779 case typeVersion: 779 case typeVersion:
780 throw Bu::ExceptionBase("You cannot add version values."); 780 throw Bu::ExceptionBase("You cannot add version values.");
781 781
782 case typeString: 782 case typeString:
783 return Variable( toString() + rhs.toString() ); 783 return Variable( toString() + rhs.toString() );
784 784
785 case typeList: 785 case typeList:
786 return Variable( toList() + rhs.toList() ); 786 return Variable( toList() + rhs.toList() );
787 787
788 case typeRef: 788 case typeRef:
789 throw Bu::ExceptionBase("You cannot add reference values."); 789 throw Bu::ExceptionBase("You cannot add reference values.");
790 790
791 case typeOpaque: 791 case typeOpaque:
792 throw Bu::ExceptionBase("You cannot add opaque values."); 792 throw Bu::ExceptionBase("You cannot add opaque values.");
793 } 793 }
794 throw Bu::ExceptionBase("Unhandled case in Variable add"); 794 throw Bu::ExceptionBase("Unhandled case in Variable add");
795} 795}
796 796
797Variable Variable::operator-( const Variable &rhs ) const 797Variable Variable::operator-( const Variable &rhs ) const
798{ 798{
799 Type eTop = Bu::buMax( eType, rhs.eType ); 799 Type eTop = Bu::buMax( eType, rhs.eType );
800 switch( eTop ) 800 switch( eTop )
801 { 801 {
802 case typeNone: 802 case typeNone:
803 return Variable(); 803 return Variable();
804 804
805 case typeBool: 805 case typeBool:
806 throw Bu::ExceptionBase("You cannot subtract boolean values."); 806 throw Bu::ExceptionBase("You cannot subtract boolean values.");
807 807
808 case typeInt: 808 case typeInt:
809 return Variable( toInt() - rhs.toInt() ); 809 return Variable( toInt() - rhs.toInt() );
810 810
811 case typeFloat: 811 case typeFloat:
812 return Variable( toFloat() - rhs.toFloat() ); 812 return Variable( toFloat() - rhs.toFloat() );
813 813
814 case typeVersion: 814 case typeVersion:
815 throw Bu::ExceptionBase("You cannot subtract version values."); 815 throw Bu::ExceptionBase("You cannot subtract version values.");
816 816
817 case typeString: 817 case typeString:
818 throw Bu::ExceptionBase("You cannot subtract string values."); 818 throw Bu::ExceptionBase("You cannot subtract string values.");
819 819
820 case typeList: 820 case typeList:
821 return Variable( toList() - rhs.toList() ); 821 return Variable( toList() - rhs.toList() );
822 822
823 case typeRef: 823 case typeRef:
824 throw Bu::ExceptionBase("You cannot subtract reference values."); 824 throw Bu::ExceptionBase("You cannot subtract reference values.");
825 825
826 case typeOpaque: 826 case typeOpaque:
827 throw Bu::ExceptionBase("You cannot subtract opaque values."); 827 throw Bu::ExceptionBase("You cannot subtract opaque values.");
828 } 828 }
829 throw Bu::ExceptionBase("Unhandled case in Variable subtract"); 829 throw Bu::ExceptionBase("Unhandled case in Variable subtract");
830} 830}
831 831
832Variable Variable::operator*( const Variable &rhs ) const 832Variable Variable::operator*( const Variable &rhs ) const
833{ 833{
834 Type eTop = Bu::buMax( eType, rhs.eType ); 834 Type eTop = Bu::buMax( eType, rhs.eType );
835 switch( eTop ) 835 switch( eTop )
836 { 836 {
837 case typeNone: 837 case typeNone:
838 return Variable(); 838 return Variable();
839 839
840 case typeBool: 840 case typeBool:
841 throw Bu::ExceptionBase("You cannot multiply boolean values."); 841 throw Bu::ExceptionBase("You cannot multiply boolean values.");
842 842
843 case typeInt: 843 case typeInt:
844 return Variable( toInt() * rhs.toInt() ); 844 return Variable( toInt() * rhs.toInt() );
845 845
846 case typeFloat: 846 case typeFloat:
847 return Variable( toFloat() * rhs.toFloat() ); 847 return Variable( toFloat() * rhs.toFloat() );
848 848
849 case typeVersion: 849 case typeVersion:
850 throw Bu::ExceptionBase("You cannot multiply version values."); 850 throw Bu::ExceptionBase("You cannot multiply version values.");
851 851
852 case typeString: 852 case typeString:
853 throw Bu::ExceptionBase("You cannot multiply string values."); 853 throw Bu::ExceptionBase("You cannot multiply string values.");
854 854
855 case typeList: 855 case typeList:
856 throw Bu::ExceptionBase("You cannot multiply list values."); 856 throw Bu::ExceptionBase("You cannot multiply list values.");
857 857
858 case typeRef: 858 case typeRef:
859 throw Bu::ExceptionBase("You cannot multiply reference values."); 859 throw Bu::ExceptionBase("You cannot multiply reference values.");
860 860
861 case typeOpaque: 861 case typeOpaque:
862 throw Bu::ExceptionBase("You cannot multiply opaque values."); 862 throw Bu::ExceptionBase("You cannot multiply opaque values.");
863 } 863 }
864 throw Bu::ExceptionBase("Unhandled case in Variable multiply"); 864 throw Bu::ExceptionBase("Unhandled case in Variable multiply");
865} 865}
866 866
867Variable Variable::operator/( const Variable &rhs ) const 867Variable Variable::operator/( const Variable &rhs ) const
868{ 868{
869 Type eTop = Bu::buMax( eType, rhs.eType ); 869 Type eTop = Bu::buMax( eType, rhs.eType );
870 switch( eTop ) 870 switch( eTop )
871 { 871 {
872 case typeNone: 872 case typeNone:
873 return Variable(); 873 return Variable();
874 874
875 case typeBool: 875 case typeBool:
876 throw Bu::ExceptionBase("You cannot divide boolean values."); 876 throw Bu::ExceptionBase("You cannot divide boolean values.");
877 877
878 case typeInt: 878 case typeInt:
879 return Variable( toInt() / rhs.toInt() ); 879 return Variable( toInt() / rhs.toInt() );
880 880
881 case typeFloat: 881 case typeFloat:
882 return Variable( toFloat() / rhs.toFloat() ); 882 return Variable( toFloat() / rhs.toFloat() );
883 883
884 case typeVersion: 884 case typeVersion:
885 throw Bu::ExceptionBase("You cannot divide version values."); 885 throw Bu::ExceptionBase("You cannot divide version values.");
886 886
887 case typeString: 887 case typeString:
888 throw Bu::ExceptionBase("You cannot divide string values."); 888 throw Bu::ExceptionBase("You cannot divide string values.");
889 889
890 case typeList: 890 case typeList:
891 throw Bu::ExceptionBase("You cannot divide list values."); 891 throw Bu::ExceptionBase("You cannot divide list values.");
892 892
893 case typeRef: 893 case typeRef:
894 throw Bu::ExceptionBase("You cannot divide reference values."); 894 throw Bu::ExceptionBase("You cannot divide reference values.");
895 895
896 case typeOpaque: 896 case typeOpaque:
897 throw Bu::ExceptionBase("You cannot divide opaque values."); 897 throw Bu::ExceptionBase("You cannot divide opaque values.");
898 } 898 }
899 throw Bu::ExceptionBase("Unhandled case in Variable divide"); 899 throw Bu::ExceptionBase("Unhandled case in Variable divide");
900} 900}
901 901
902void Variable::reset( Type eNewType ) 902void Variable::reset( Type eNewType )
903{ 903{
904 if( eType == typeString || eType == typeRef ) 904 if( eType == typeString || eType == typeRef )
905 { 905 {
906 delete uVal.sVal; 906 delete uVal.sVal;
907 } 907 }
908 else if( eType == typeList ) 908 else if( eType == typeList )
909 { 909 {
910 delete uVal.lVal; 910 delete uVal.lVal;
911 } 911 }
912 memset( &uVal, 0, sizeof(uVal) ); 912 memset( &uVal, 0, sizeof(uVal) );
913 913
914 eType = eNewType; 914 eType = eNewType;
915} 915}
916 916
917Bu::Formatter &operator<<( Bu::Formatter &f, const Variable::Type &t ) 917Bu::Formatter &operator<<( Bu::Formatter &f, const Variable::Type &t )
918{ 918{
919 switch( t ) 919 switch( t )
920 { 920 {
921 case Variable::typeNone: f << "*typeless*"; break; 921 case Variable::typeNone: f << "*typeless*"; break;
922 case Variable::typeInt: f << "int"; break; 922 case Variable::typeInt: f << "int"; break;
923 case Variable::typeFloat: f << "double"; break; 923 case Variable::typeFloat: f << "double"; break;
924 case Variable::typeBool: f << "bool"; break; 924 case Variable::typeBool: f << "bool"; break;
925 case Variable::typeString: f << "string"; break; 925 case Variable::typeString: f << "string"; break;
926 case Variable::typeList: f << "list"; break; 926 case Variable::typeList: f << "list"; break;
927 case Variable::typeVersion: f << "version"; break; 927 case Variable::typeVersion: f << "version"; break;
928 case Variable::typeRef: f << "ref"; break; 928 case Variable::typeRef: f << "ref"; break;
929 case Variable::typeOpaque: f << "opaque"; break; 929 case Variable::typeOpaque: f << "opaque"; break;
930 } 930 }
931 return f; 931 return f;
932} 932}
933 933
934Bu::Formatter &operator<<( Bu::Formatter &f, const Variable &v ) 934Bu::Formatter &operator<<( Bu::Formatter &f, const Variable &v )
935{ 935{
936 f << "Variable(" << v.getType() << ") = "; 936 f << "Variable(" << v.getType() << ") = ";
937 switch( v.getType() ) 937 switch( v.getType() )
938 { 938 {
939 case Variable::typeNone: break; 939 case Variable::typeNone: break;
940 case Variable::typeInt: f << v.getInt(); break; 940 case Variable::typeInt: f << v.getInt(); break;
941 case Variable::typeFloat: f << v.getFloat(); break; 941 case Variable::typeFloat: f << v.getFloat(); break;
942 case Variable::typeBool: f << v.getBool(); break; 942 case Variable::typeBool: f << v.getBool(); break;
943 case Variable::typeString: f << v.getString(); break; 943 case Variable::typeString: f << v.getString(); break;
944 case Variable::typeList: f << v.getList(); break; 944 case Variable::typeList: f << v.getList(); break;
945 case Variable::typeVersion:/*f << v.getVersion();*/ break; 945 case Variable::typeVersion:/*f << v.getVersion();*/ break;
946 case Variable::typeRef: f << v.getString(); break; 946 case Variable::typeRef: f << v.getString(); break;
947 case Variable::typeOpaque: f << "<opaque:" << v.getOpaque() << ">"; 947 case Variable::typeOpaque: f << "<opaque:" << v.getOpaque() << ">";
948 break; 948 break;
949 } 949 }
950 950
951 return f; 951 return f;
952} 952}
953 953
954Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const Variable &v ) 954Bu::ArchiveBase &operator<<( Bu::ArchiveBase &ar, const Variable &v )
955{ 955{
956 ar << (int8_t)v.eType; 956 ar << (int8_t)v.eType;
957 switch( v.eType ) 957 switch( v.eType )
958 { 958 {
959 case Variable::typeNone: 959 case Variable::typeNone:
960 break; 960 break;
961 961
962 case Variable::typeBool: 962 case Variable::typeBool:
963 ar << v.uVal.bVal; 963 ar << v.uVal.bVal;
964 break; 964 break;
965 965
966 case Variable::typeInt: 966 case Variable::typeInt:
967 ar << v.uVal.iVal; 967 ar << v.uVal.iVal;
968 break; 968 break;
969 969
970 case Variable::typeFloat: 970 case Variable::typeFloat:
971 ar << v.uVal.fVal; 971 ar << v.uVal.fVal;
972 break; 972 break;
973 973
974 case Variable::typeVersion: 974 case Variable::typeVersion:
975 break; 975 break;
976 976
977 case Variable::typeString: 977 case Variable::typeString:
978 ar << *v.uVal.sVal; 978 ar << *v.uVal.sVal;
979 break; 979 break;
980 980
981 case Variable::typeList: 981 case Variable::typeList:
982 ar << *v.uVal.lVal; 982 ar << *v.uVal.lVal;
983 break; 983 break;
984 984
985 case Variable::typeRef: 985 case Variable::typeRef:
986 ar << *v.uVal.sVal; 986 ar << *v.uVal.sVal;
987 break; 987 break;
988 988
989 case Variable::typeOpaque: 989 case Variable::typeOpaque:
990 break; 990 break;
991 } 991 }
992 992
993 return ar; 993 return ar;
994} 994}
995 995
996Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, Variable &v ) 996Bu::ArchiveBase &operator>>( Bu::ArchiveBase &ar, Variable &v )
997{ 997{
998 int8_t t; 998 int8_t t;
999 ar >> t; 999 ar >> t;
1000 v.eType = (Variable::Type)t; 1000 v.eType = (Variable::Type)t;
1001 v.reset( v.eType ); 1001 v.reset( v.eType );
1002 switch( v.eType ) 1002 switch( v.eType )
1003 { 1003 {
1004 case Variable::typeNone: 1004 case Variable::typeNone:
1005 break; 1005 break;
1006 1006
1007 case Variable::typeBool: 1007 case Variable::typeBool:
1008 ar >> v.uVal.bVal; 1008 ar >> v.uVal.bVal;
1009 break; 1009 break;
1010 1010
1011 case Variable::typeInt: 1011 case Variable::typeInt:
1012 ar >> v.uVal.iVal; 1012 ar >> v.uVal.iVal;
1013 break; 1013 break;
1014 1014
1015 case Variable::typeFloat: 1015 case Variable::typeFloat:
1016 ar >> v.uVal.fVal; 1016 ar >> v.uVal.fVal;
1017 break; 1017 break;
1018 1018
1019 case Variable::typeVersion: 1019 case Variable::typeVersion:
1020 break; 1020 break;
1021 1021
1022 case Variable::typeString: 1022 case Variable::typeString:
1023 ar >> *v.uVal.sVal; 1023 ar >> *v.uVal.sVal;
1024 break; 1024 break;
1025 1025
1026 case Variable::typeList: 1026 case Variable::typeList:
1027 ar >> *v.uVal.lVal; 1027 ar >> *v.uVal.lVal;
1028 break; 1028 break;
1029 1029
1030 case Variable::typeRef: 1030 case Variable::typeRef:
1031 ar >> *v.uVal.sVal; 1031 ar >> *v.uVal.sVal;
1032 break; 1032 break;
1033 1033
1034 case Variable::typeOpaque: 1034 case Variable::typeOpaque:
1035 break; 1035 break;
1036 } 1036 }
1037 1037
1038 return ar; 1038 return ar;
1039} 1039}
1040 1040
1041VarList operator-( const VarList &rBase, const VarList &rSub ) 1041VarList operator-( const VarList &rBase, const VarList &rSub )