summaryrefslogtreecommitdiffstats
path: root/cvar.cpp
blob: af64d66113cc5262ff82cbdf81de6a064e67ff57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
/*  Copyright 2008,2009,2010 Edwin Eefting (edwin@datux.nl) 

    This file is part of Synapse.

    Synapse is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Synapse is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Synapse.  If not, see <http://www.gnu.org/licenses/>. */













#include "cvar.h"
#include <iostream>
#include <boost/lexical_cast.hpp>
#include "clog.h"
#include <sstream>

#include "exception/cexception.h"


namespace synapse
{

/// COMMON STUFF

Cvar::Cvar()
{
	clear();
}


Cvar::~Cvar()
{
	
}

void Cvar::clear()
{
	value=(void *)NULL;
}

bool Cvar::isEmpty()
{
	return (value.which()==CVAR_EMPTY);
}

int Cvar::which()
{
	return (value.which());
}


string Cvar::getPrint(string prefix)
{
	stringstream print;
	switch (value.which())
	{
		case CVAR_EMPTY:
			print << "(empty)";
			break;
		case CVAR_LONG_DOUBLE:
			print << (long double)(*this) << " (long double)";
			break;
		case CVAR_STRING:
			print << (string)(*this) << " (string)";
			break;
		case CVAR_MAP:
			//show all keys of the map, and show the values recursively
			if (begin()!=end())
			{
				print << "(map:)";
				for (CvarMap::iterator varI=begin(); varI!=end(); varI++)
				{
					print << endl;
					print << prefix << varI->first << " = ";
					print << varI->second.getPrint(prefix+" |");
				}
			}
			else
			{
				print << "(empty map)";
			}

			break;
		case CVAR_LIST:
			//show all items of the list recursively
			if (list().begin()!=list().end())
			{
				print << "(list:)";
				for (CvarList::iterator varI=list().begin(); varI!=list().end(); varI++)
				{
					print << endl;
					print << prefix << varI->getPrint(prefix+" |");
				}
			}
			else
			{
				print << "(empty list)";
			}

			break;
		default:
			print << "? (unknown type)";
			break;
	}

	return print.str();
}

bool Cvar::operator==( Cvar & other)
{

	//wrong type
	if (value.which()!=other.value.which())
		return (false);


	switch (value.which())
	{
		case CVAR_EMPTY:
			return (true);
			break;
		case CVAR_LONG_DOUBLE:
			return ((long double)(*this)==(long double)other);
			break;
		case CVAR_STRING:
			return ((string)(*this)==(string)(other));
			break;
		case CVAR_MAP:
			//wrong count?
			if (((CvarMap)(*this)).size()!=((CvarMap)other).size())
				return (false);

			//recursively compare keys and values
			for (CvarMap::iterator varI=begin(); varI!=end(); varI++)
			{
				//key doesnt exists in other?
				if (!other.isSet(varI->first))
					return (false);

				//compare values (this recurses)
				if (varI->second!=other[varI->first])
					return (false);
			}
			return (true);
			break;
		case CVAR_LIST:
			//wrong count?
			if (list().size()!=other.list().size())
				return (false);

			{
				//recursively compare values (order has to be the same as well)
				CvarList::iterator otherVarI=other.list().begin();
				for (CvarList::iterator varI=list().begin(); varI!=list().end(); varI++)
				{
					//compare values (this recurses)
					if ((*varI)!=(*otherVarI))
						return false;
					otherVarI++;
				}
			}
			return (true);
			break;
		default:
			castError("trying to compare unknown types?");
			return (false);
			break;
	}
}

bool Cvar::operator!=( Cvar & other)
{
	return !(*this == other);
}




/// CVAR_STRING stuff
Cvar::Cvar(const string & value)
{
	this->value=value;
}

// Cvar::Cvar(const char * value)
// {
// 	this->value=string(value);
// }

string & Cvar::operator=(const string & value)
{
	this->value=value;
	return((string &)(*this));
}


void Cvar::castError(const char * txt)
{
	string s(txt);
	s+=": "+getPrint();
	throw(synapse::runtime_error(s.c_str()));
}

Cvar::operator string & ()
{
	if (value.which()==CVAR_LONG_DOUBLE)
	{
		try
		{
			//DEB("Cvar " << this << ": converting CVAR_LONG_DOUBLE to CVAR_STRING");
			value=lexical_cast<string>(get<long double>(value));
		}
		catch(...)
		{
			castError("casting error while converting to CVAR_STRING");
		}
	}
	else if (value.which()==CVAR_STRING)
	{
		//native type, dont need to do anything
	}
	else if (value.which()==CVAR_EMPTY)
	{
		//change it from really empty, to an empty string
		//DEB("Cvar " << this << ": converting CVAR_EMPTY to CVAR_STRING");
		value="";
	}
	else
	{
		castError("cannot convert this to CVAR_STRING");
	}

	return (get<string&>(value));
}

string & Cvar::str()
{
	return((string &)(*this));
}

bool Cvar::operator==(const string & other)
{
	return ((string)(*this)==(other));
}

bool Cvar::operator!=(const string & other)
{
	return ((string)(*this)!=(other));
}

//bool Cvar::operator==(const char * other)
//{
//	return ((string)(*this)==other);
//}
//
//bool Cvar::operator!=(const char * other)
//{
//	return ((string)(*this)!=other);
//}


/// CVAR_LONG_DOUBLE stuff

long double & Cvar::operator=(const long double & value)
{
	this->value=value;
	return((long double &)(*this));
}

 Cvar::Cvar(const long double & value)
{
	this->value=value;
}

Cvar::operator long double &()
{
	if (value.which()==CVAR_LONG_DOUBLE)
	{
		//native type, dont change anything
	}
	else if (value.which()==CVAR_STRING)
	{
		try
		{
			//convert string to long double
			//DEB("Cvar " << this << ": converting CVAR_STRING to CVAR_LONG_DOUBLE");
			value=lexical_cast<long double>(get<string>(value));
		}
		catch(...)
		{
			castError("casting error while converting to CVAR_LONG_DOUBLE");
		}
	}
	else if (value.which()==CVAR_EMPTY)
	{
		//change it from empty to 0
		//DEB("Cvar " << this << ": converting CVAR_EMPTY to CVAR_LONG_DOUBLE");
		value=0;
	}
	else
	{
		castError("cannot convert this to CVAR_LONG_DOUBLE");
	}
	return (get<long double&>(value));
}

//bool Cvar::operator==(long double & other)
//{
//	return ((long double)(*this)==other);
//
//}


/// CVAR_MAP stuff
Cvar::operator CvarMap & ()
{
	if (value.which()==CVAR_EMPTY)
	{
		//DEB("Cvar " << this << ": converting CVAR_EMPTY to CVAR_MAP"); 
		value=CvarMap();
	}
	else if (value.which()!=CVAR_MAP)
	{
		castError("cannot convert this to CVAR_MAP");
	}
	return (get<CvarMap&>(value));
}

CvarMap & Cvar::map()
{
	return ((CvarMap &)(*this));

}


Cvar & Cvar::operator[] (const string & key)
{
	return (((CvarMap&)(*this))[key]);
}

CvarMap::iterator Cvar::begin()
{
	return ((CvarMap &)(*this)).begin();
}

CvarMap::iterator Cvar::end()
{
	return ((CvarMap &)(*this)).end();
}

bool Cvar::isSet(const char * key)
{
	return(
		((CvarMap&)(*this)).find(key)!=((CvarMap&)(*this)).end()
	);
}

bool Cvar::isSet(const string & key)
{
	return(
		((CvarMap&)(*this)).find(key)!=((CvarMap&)(*this)).end()
	);
}

void Cvar::erase(const char * key)
{
	CvarMap::iterator I=((CvarMap&)(*this)).find(key);
	if (I!=((CvarMap&)(*this)).end())
		((CvarMap&)(*this)).erase(I);
}

/// CVAR_LIST stuff
Cvar::operator CvarList & ()
{
	if (value.which()==CVAR_EMPTY)
	{
		value=CvarList();
	}
	else if (value.which()!=CVAR_LIST)
	{
		castError("cannot convert this to CVAR_LIST");
	}
	return (get<CvarList&>(value));
}


CvarList & Cvar::list()
{
	return ((CvarList &)(*this));
}





/// JSON stuff

/** Recursively converts a json_spirit Value to this Cvar
*/
void Cvar::fromJsonSpirit(Value &spiritValue)
{
	switch(spiritValue.type())
	{
		case(null_type):
			clear();
			break;
		case(str_type):
			value=spiritValue.get_str();
			break;
		case(real_type):
			value=spiritValue.get_real();
			break;
		case(int_type):
			value=spiritValue.get_int();
			break;
		case(bool_type):
			value=spiritValue.get_bool();
			break;
		case(obj_type):
			value=CvarMap();
			//convert the Object(string,Value) pairs to a CvarMap 
			for (Object::iterator ObjectI=spiritValue.get_obj().begin(); ObjectI!=spiritValue.get_obj().end(); ObjectI++)
			{
				//recurse to convert the json_spirit pair into a CvarMap key->item.
				map()[ObjectI->name_].fromJsonSpirit(ObjectI->value_);
			}
			break;
		case(array_type):
			value=CvarList();
			//convert the Array items to CvarList
			for (Array::iterator ArrayI=spiritValue.get_array().begin(); ArrayI!=spiritValue.get_array().end(); ArrayI++)
			{
				//recurse to convert the json_spirit value item into a CvarList item
				Cvar v;
				v.fromJsonSpirit(*ArrayI);
				list().push_back(v);
			}
			break;
		default:
			DEB("Unknown jsonspirit type: " << spiritValue.type());
			castError("Cant convert this json spirit data to Cvar?");
			break;
	}
}


/** Recursively converts this Cvar to a json_spirit Value.
*/
void Cvar::toJsonSpirit(Value &spiritValue)
{
	int i;
	double d;

	switch(value.which())
	{
		case(CVAR_EMPTY):
			spiritValue=Value();
			break;
		case(CVAR_STRING):
			spiritValue=get<string&>(value);
			break;
		case(CVAR_LONG_DOUBLE):
			//work around to prevent numbers like 1.00000000000:
			i=(get<long double>(value));
			d=(get<long double>(value));
			if (d==i)
				spiritValue=i;
			else
				spiritValue=d;

			break;
		case(CVAR_MAP):
			//convert the CvarMap to a json_spirit Object with (String,Value) pairs 
			spiritValue=Object();
			for (CvarMap::iterator varI=begin(); varI!=end(); varI++)
			{
				Value subValue;
				//recurse to convert the map-value of the CvarMap into a json_spirit Value:
				varI->second.toJsonSpirit(subValue);
				
				//push the resulting Value onto the json_spirit Object
				spiritValue.get_obj().push_back(Pair(
					varI->first,
					subValue
				));
			}
			break;
		case(CVAR_LIST):
			//convert the CvarList to a json_spirit Array with (String,Value) pairs 
			spiritValue=Array();
			for (CvarList::iterator varI=list().begin(); varI!=list().end(); varI++)
			{
				Value subValue;
				//recurse to convert the list item of the CvarList into a json_spirit Value:
				varI->toJsonSpirit(subValue);
				
				//push the resulting Value onto the json_spirit Object
				spiritValue.get_array().push_back(subValue);
			}
			break;
		default:
			castError("Cant convert this Cvar type to json spirit?");
			break;
	}
}


/** converts this Cvar recursively into a json string
*/
void Cvar::toJson(string & jsonStr)
{
	Value spiritValue;
	toJsonSpirit(spiritValue);

	jsonStr=write(spiritValue);

}

//"better" version of json read that throws nicer exceptions
void Cvar::readJsonSpirit(const string & jsonStr, Value & spiritValue)
{
	//TODO:how safe is it actually to let json_spirit parse untrusted input? (regarding DoS, buffer overflows, etc)
	if (!json_spirit::read(jsonStr, spiritValue))
	{
		//this function is 3 times slower, but gives a nice exception with an error message
		try
		{
			json_spirit::read_or_throw(jsonStr, spiritValue);
		}
		catch(json_spirit::Error_position e)
		{
			//reformat the exception to something generic:
			stringstream s;
			s << "JSON parse error at line " << e.line_<< ", column " << e.column_ << ": " << e.reason_;
			throw(synapse::runtime_error(s.str()));
		}
	}


}


void Cvar::toJsonFormatted(string & jsonStr)
{
	Value spiritValue;
	toJsonSpirit(spiritValue);

	jsonStr=write_formatted(spiritValue);

}


void Cvar::fromJson(string & jsonStr)
{
	//parse json input
	Value spiritValue;
	readJsonSpirit(jsonStr,spiritValue);
	fromJsonSpirit(spiritValue);

}

//test functionality of Cvar class, returns false on failure.
//Its wise to also  run this small and fast test in the non-debug version, to detect strange problems with compiler optimizations or different compiler version.
bool Cvar::selfTest()
{
#define TEST(condition) if (!(condition)) return (false)
//tests if operation throws an exception.
//NOTE: dont forget to check if the value is still what it is supposed to be, AFTER the throw.
#define TESTTHROW(operation) \
		{ \
			bool ok=false; \
			try \
			{ \
				operation ; \
			} \
			catch (const synapse::runtime_error& e) \
			{ \
				ok=true; \
				DEB("exception: " << e.what()); \
			} \
			catch(...) \
			{ \
				ok=true; \
			} \
			if (!ok) ERROR("did not throw exception!"); \
			TEST(ok); \
		}



	{
		DEB("test: Selftesting CVAR_LONG_DOUBLE");

		DEB("test: empty long value");
		Cvar e;
		TEST((int)e==0);

		DEB("test: use long as boolean");
		e=1;
		TEST(e);

		DEB("test: long construct");
		Cvar a(2.12);
		TEST(a==2.12);

		DEB("test: long assignment");
		TEST((a=3.13) == 3.13);
		TEST(a==3.13);


		DEB("test: long assignment reference")
		Cvar b;
		TEST((a=b=5.15) == 5.15);
		TEST(a==5.15);
		TEST(b==5.15);

		DEB("test: int to string");
		a=6;
		TEST((string)a=="6");

		DEB("test: long to string");
		a=6.14;
		//actual value depends on the architecture you use, on arm its 6.1399999999999997
		TEST((string)a=="6.13999999999999968026" || (string)a=="6.1399999999999997");
		TEST(a.str()=="6.13999999999999968026" || a.str()=="6.1399999999999997");

		DEB("test: long to map");
		a=7;
		TESTTHROW((CvarMap)a);
		TESTTHROW(a.map());
		TEST(a==7);

		DEB("test: long to list");
		a=8;
		TESTTHROW(a.list());
		TEST(a==8);

		DEB("test long compare");
		Cvar c;
		c=a;
		TEST(a==c);

		DEB("test: long re-assign string");
		a=9;
		TEST(a==9);
		a="test";
		TEST(a.str()=="test");

		DEB("test: long re-assign list");
		a=9;
		TEST(a==9);
		Cvar l;
		l.list();
		a=l;
		TEST(a.list().size()==0);

		DEB("test: long re-assign map");
		a=9;
		TEST(a==9);
		Cvar m;
		m.map();
		a=m;
		TEST(a.map().size()==0);

		DEB("test: basic arithmetic");
		a=5;
		a=a+1;
		a=a-2;
		TEST(a==4);
	}

	{
		DEB("test: Selftesting CVAR_STRING");

		DEB("test: empty string value");
		Cvar e;
		TEST(e=="");

		DEB("test: use string as boolean");
		e="1";
		TEST(e);
		TEST(e=="1");

		DEB("test: use invalid string as boolean");
		e="blah";
		TESTTHROW(if (e););
		TEST(e=="blah");

		DEB("test: string construct from const char");
		Cvar a("first");
		TEST(a=="first");

		DEB("test: const char assignment");
		TEST((a="second") == "second");
		TEST(a=="second");

		DEB("test: const char assignment reference")
		Cvar b;
		TEST((a=b="third") == "third");
		TEST(a=="third");
		TEST(b=="third");

		DEB("test: valid string number to int");
		a="6";
		TEST(a==6);

		DEB("test: invalid string number to int");
		a="blah";
		TESTTHROW(a=a+6);
		TEST(a=="blah");

		DEB("test: string to map");
		a="fourth";
		TESTTHROW((CvarMap)a);
		TESTTHROW(a.map());
		TEST(a=="fourth");

		DEB("test: string to list");
		a="fifth";
		CvarList d;
		TESTTHROW(d=a);
		TESTTHROW(a.list());
		TEST(a=="fifth");

		DEB("test string compare");
		Cvar c;
		c=a;
		TEST(a==c);

		DEB("test: string re-assign long");
		a="sixth";
		TEST(a=="sixth");
		a=7;
		TEST(a==7);

		DEB("test: string re-assign list");
		a="sixth";
		TEST(a=="sixth");
		Cvar l;
		l.list();
		a=l;
		TEST(a.list().size()==0);

		DEB("test: string re-assign map");
		a="sixth";
		TEST(a=="sixth");
		Cvar m;
		m.map();
		a=m;
		TEST(a.map().size()==0);

	}


	{
		DEB("test: Selftesting CVAR_LIST");

		DEB("test: create basic list");
		Cvar a;
		a.list().push_back(Cvar("one"));
		a.list().push_back(2);
		TEST(a.list().front()=="one");
		TEST(a.list().back()==2);

		DEB("test: list to long");
		TESTTHROW(a=a+1);
		TEST(a.list().back()==2);

		DEB("test: list to string");
		TESTTHROW(a.str());
		TEST(a.list().back()==2);

		DEB("test: list to map");
		TESTTHROW(a.map());
		TEST(a.list().back()==2);

		DEB("test list compare");
		Cvar c;
		c=a;
		TEST(a==c);

		DEB("test: list re-assign long");
		a.clear();
		a.list();
		a=5;
		TEST(a==5);

		DEB("test: list re-assign string");
		a.clear();
		a.list();
		a="test";
		TEST(a=="test");

		DEB("test: list re-assign map");
		a.clear();
		a.list();
		Cvar b;
		b.map();
		a=b;
		TEST(a.map().size()==0);


	}

	{
		DEB("test: Selftesting CVAR_MAP");

		DEB("test: create basic map");
		Cvar a;
		a["first"]=1;
		a["second"]="two";
		TEST(a["first"]==1);
		TEST(a["second"]=="two");

		DEB("test: map to long");
		TESTTHROW(a=a+1);
		TEST(a["first"]==1);

		DEB("test: map to string");
		TESTTHROW(a.str());
		TEST(a["first"]==1);

		DEB("test: map to list");
		TESTTHROW(a.list());
		TEST(a["first"]==1);

		DEB("test map compare");
		Cvar c;
		c=a;
		TEST(a==c);

		DEB("test: map re-assign long");
		a.clear();
		a.map();
		a=5;
		TEST(a==5);

		DEB("test: map re-assign string");
		a.clear();
		a.map();
		a="test";
		TEST(a=="test");

		DEB("test: map re-assign list");
		a.clear();
		a.map();
		Cvar b;
		b.list();
		a=b;
		TEST(a.list().size()==0);


	}

	{
		DEB("test: Selftesting Cvar complex data structures");

		DEB("test: create complex structure");
		Cvar a;
		a["empty"];
		a["number"]=1;
		a["list"].list().push_back(1);
		a["list"].list().push_back(Cvar());
		a["string"]="text";
		a["map"]["number2"]=2;
		a["map"]["list2"].list().push_back(2);
		a["map"]["string2"]="text2";
		a["list"].list().back()["submap"].list().push_back(3);
		DEB("test: complex map layout:" << a.getPrint());

		DEB("test: convert to json and back");
		string s;
		a.toJson(s);
		Cvar b;
		b.fromJson(s);

		DEB("test: complex compare json result");
		TEST(a==b);
		//make a deep but small change:
		b["list"].list().back()["submap"].list().back()=4;
		TEST(a!=b);
		//change it back:
		b["list"].list().back()["submap"].list().back()=3;
		TEST(a==b);

		DEB("test: convert to formatted json and back");
		a.toJsonFormatted(s);
		b.fromJson(s);
		TEST(a==b);

	}

	DEB("test: all Cvar tests OK");
	return(true);
}


}