]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/cpp/DataBoardTest/DataBoard/DataValueRepository.cpp
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / cpp / DataBoardTest / DataBoard / DataValueRepository.cpp
1 #include <string>
2
3 #include "DataValueRepository.h"
4
5 #include "DataBoardRepository.h"
6 #include "Value.h"
7 #include "RecordValue.h"
8 #include "StringValue.h"
9 #include "IntegerValue.h"
10 #include "DoubleValue.h"
11 #include "BooleanValue.h"
12 #include "FloatValue.h"
13 #include "LongValue.h"
14 #include "MapValue.h"
15 #include "ArrayValue.h"
16 #include "OptionalValue.h"
17 #include "UnionValue.h"
18 #include "VariantValue.h"
19
20 #include "RecordType.h"
21 #include "Component.h"
22 #include "BooleanType.h"
23 #include "StringType.h"
24 #include "IntegerType.h"
25 #include "DoubleType.h"
26 #include "FloatType.h"
27 #include "LongType.h"
28 #include "MapType.h"
29 #include "ArrayType.h"
30 #include "OptionalType.h"
31 #include "UnionType.h"
32 #include "VariantType.h"
33
34 #include "Constants.h"
35
36 #include <string>
37 #include <iostream>
38 #include <sstream>
39
40 namespace Databoard {
41         namespace Value {
42
43                 std::string strDataValueDefinition::writeOut() const
44                 {
45                         std::string r;
46
47                         r += name + " : " + type + " = ";
48
49                         if(value != NULL)
50                         {
51                                 r += value->writeOut();
52                         }
53
54                         return r;
55                 }
56
57                 DataValueRepository::DataValueRepository()
58                 {
59                 }
60
61                 DataValueRepository::~DataValueRepository()
62                 {
63                         for(int i=0;i<(int)values.size();++i)
64                         {
65                                 delete values.at(i).value;
66                         }
67
68                         values.size();
69                 }
70
71                 void DataValueRepository::addDataValue(std::string name, std::string type, Value* dataValue)
72                 {
73                         strDataValueDefinition value_;
74
75                         value_.name = name;
76                         value_.type = type;
77                         value_.value = dataValue;
78
79                         values.push_back(value_);
80                 }
81
82                 const Databoard::Type::strTypeDefinition* DataValueRepository::parseTypeReference(pANTLR3_BASE_TREE tree)
83                 {
84                         switch(tree->getType(tree)) {
85                                 case TYPE_REFERENCE:
86
87                                         if(tree->getChildCount(tree) == 1)
88                                         {
89                                                 pANTLR3_BASE_TREE referenceName = (pANTLR3_BASE_TREE)tree->getChild(tree, 0);
90
91                                                 std::string id((char*)referenceName->getText(referenceName)->chars);
92
93                                                 const Databoard::Type::strTypeDefinition* dataBoard = dataBoardRepository->get(id);
94
95                                                 return dataBoard;
96                                         }
97
98                                         break;
99                                 default:
100                                         break;
101                         }
102
103                         return NULL;
104                 }
105
106                 Value* DataValueRepository::parseValues(pANTLR3_BASE_TREE tree, Databoard::Type::DataType* dataBoard, int indent)
107                 {
108                         if(dynamic_cast<Databoard::Type::OptionalType*>(dataBoard) != NULL)
109                         {
110                                 Databoard::Type::OptionalType* optionalType = (Databoard::Type::OptionalType*)dataBoard;
111
112                                 Value* value = parseValues(tree, optionalType->getComponentType(), indent + 1);
113
114                                 OptionalValue* optionalValue = new OptionalValue(optionalType);
115
116                                 optionalValue->setValue(value);
117
118                                 return optionalValue;
119                         }
120                         else if(dynamic_cast<Databoard::Type::StringType*>(dataBoard) != NULL)
121                         {
122                                 Databoard::Type::StringType* stringType = (Databoard::Type::StringType*)dataBoard;
123
124                                 StringValue* stringValue = new StringValue(dataBoard);
125
126                                 std::string value((char*)tree->getText(tree)->chars);
127
128                                 value = removeQuotes(value);
129
130                                 stringValue->setValue(value);
131
132                                 return stringValue;
133                         }
134                         else if(dynamic_cast<Databoard::Type::IntegerType*>(dataBoard) != NULL)
135                         {
136                                 Databoard::Type::IntegerType* integerType = (Databoard::Type::IntegerType*)dataBoard;
137
138                                 IntegerValue* integerValue = new IntegerValue(dataBoard);
139
140                                 std::istringstream iss((char*)tree->getText(tree)->chars);
141
142                                 int value;
143
144                                 iss >> value;
145
146                                 integerValue->setValue(value);
147
148                                 return integerValue;
149                         }
150                         else if(dynamic_cast<Databoard::Type::LongType*>(dataBoard) != NULL)
151                         {
152                                 Databoard::Type::LongType* longType = (Databoard::Type::LongType*)dataBoard;
153
154                                 LongValue* longValue = new LongValue(dataBoard);
155
156                                 std::istringstream iss((char*)tree->getText(tree)->chars);
157
158                                 long value;
159
160                                 iss >> value;
161
162                                 longValue->setValue(value);
163
164                                 return longValue;
165                         }
166                         else if(dynamic_cast<Databoard::Type::FloatType*>(dataBoard) != NULL)
167                         {
168                                 Databoard::Type::FloatType* floatType = (Databoard::Type::FloatType*)dataBoard;
169
170                                 FloatValue* floatValue = new FloatValue(dataBoard);
171
172                                 std::istringstream iss((char*)tree->getText(tree)->chars);
173
174                                 float value;
175
176                                 iss >> value;
177
178                                 floatValue->setValue(value);
179
180                                 return floatValue;
181                         }
182                         else if(dynamic_cast<Databoard::Type::DoubleType*>(dataBoard) != NULL)
183                         {
184                                 Databoard::Type::DoubleType* doubleType = (Databoard::Type::DoubleType*)dataBoard;
185
186                                 DoubleValue* doubleValue = new DoubleValue(dataBoard);
187
188                                 std::istringstream iss((char*)tree->getText(tree)->chars);
189
190                                 double value;
191
192                                 iss >> value;
193
194                                 doubleValue->setValue(value);
195
196                                 return doubleValue;
197                         }
198                         else if(dynamic_cast<Databoard::Type::RecordType*>(dataBoard) != NULL)
199                         {
200                                 if(tree->getType(tree) == TUPLE)
201                                 {
202                                         Databoard::Type::RecordType* recordType = (Databoard::Type::RecordType*)dataBoard;
203
204                                         RecordValue* recordValue = new RecordValue(recordType);
205
206                                         int i2 = (int)tree->getChildCount(tree);
207                                         int i3 = recordType->count();
208
209                                         if((int)tree->getChildCount(tree) == recordType->count())
210                                         {
211                                                 for(int i=0;i<(int)tree->getChildCount(tree);++i)
212                                                 {
213                                                         pANTLR3_BASE_TREE value = (pANTLR3_BASE_TREE)tree->getChild(tree, i);
214
215                                                         std::string strId((char*)value->getText(value)->chars);
216
217                                                         Databoard::Type::Component* component = recordType->getComponent(i);
218
219                                                         if(component != NULL)
220                                                         {
221                                                                 Databoard::Type::DataType* dataBoardType = component->getDataBoard();
222
223                                                                 Value* childValue = parseValues(value, dataBoardType, indent + 1);
224
225                                                                 recordValue->setField(i, childValue);
226                                                         }
227                                                 }
228
229                                                 return recordValue;
230                                         }
231                                         else
232                                         {
233                                                 std::cout << "mismatch in tuple count: " << (int)tree->getChildCount(tree) << " != " << recordType->count() << std::endl;
234                                                 return NULL;
235                                         }
236                                 }
237                                 else if(tree->getType(tree) == RECORD)
238                                 {
239                                         Databoard::Type::RecordType* recordType = (Databoard::Type::RecordType*)dataBoard;
240
241                                         RecordValue* recordValue = new RecordValue(recordType);
242
243                                         for(int i=0;i<(int)tree->getChildCount(tree);++i)
244                                         {
245                                                 pANTLR3_BASE_TREE assignment = (pANTLR3_BASE_TREE)tree->getChild(tree, i);
246
247                                                 if(assignment->getType(assignment) == ASSIGNMENT)
248                                                 {
249                                                         if(assignment->getChildCount(assignment) == 2)
250                                                         {
251                                                                 pANTLR3_BASE_TREE id = (pANTLR3_BASE_TREE)assignment->getChild(assignment, 0);
252                                                                 pANTLR3_BASE_TREE value = (pANTLR3_BASE_TREE)assignment->getChild(assignment, 1);
253
254                                                                 std::string strId((char*)id->getText(id)->chars);
255
256                                                                 Databoard::Type::Component* component = recordType->getComponent(strId);
257
258                                                                 if(component != NULL)
259                                                                 {
260                                                                         Databoard::Type::DataType* dataBoardType = component->getDataBoard();
261
262                                                                         if(dataBoardType != NULL)
263                                                                         {
264                                                                                 Value* childValue = parseValues(value, dataBoardType, indent + 1);
265
266                                                                                 int index = recordType->getComponentIndex(strId);
267
268                                                                                 recordValue->setField(index, childValue);
269                                                                         }
270                                                                 }
271                                                         }
272                                                 }
273                                         }
274
275                                         return recordValue;
276                                 }
277                         }
278                         else if(dynamic_cast<Databoard::Type::MapType*>(dataBoard) != NULL)
279                         {
280                                 Databoard::Type::MapType* mapType = (Databoard::Type::MapType*)dataBoard;
281
282                                 MapValue* mapValue = new MapValue(mapType);
283
284                                 int childCount = tree->getChildCount(tree);
285
286                                 if(childCount > 0)
287                                 {
288                                         for(int i = 0; i < childCount; ++i)
289                                         {
290                                                 pANTLR3_BASE_TREE assignment = (pANTLR3_BASE_TREE)tree->getChild(tree, i);
291
292                                                 if(assignment->getType(assignment) == ASSIGNMENT)
293                                                 {
294                                                         if(assignment->getChildCount(assignment) == 2)
295                                                         {
296                                                                 pANTLR3_BASE_TREE key = (pANTLR3_BASE_TREE)assignment->getChild(assignment, 0);
297                                                                 pANTLR3_BASE_TREE value = (pANTLR3_BASE_TREE)assignment->getChild(assignment, 1);
298
299                                                                 std::string strKey((char*)key->getText(key)->chars);
300                                                                 std::string strValue((char*)value->getText(value)->chars);
301
302                                                                 strKey = removeQuotes(strKey);
303                                                                 strValue = removeQuotes(strValue);
304
305                                                                 Value* keyValue = parseValues(key, mapType->getKeyType(), indent + 1);
306                                                                 Value* valueValue = parseValues(value, mapType->getValueType(), indent + 1);
307
308                                                                 if(keyValue != NULL && valueValue != NULL)
309                                                                 {
310                                                                         mapValue->put(keyValue, valueValue);
311                                                                 }
312                                                         }
313                                                 }
314                                         }
315                                 }
316
317                                 return mapValue;
318                         }
319                         else if(dynamic_cast<Databoard::Type::ArrayType*>(dataBoard) != NULL)
320                         {
321                                 Databoard::Type::ArrayType* arrayType = (Databoard::Type::ArrayType*)dataBoard;
322
323                                 ArrayValue* arrayValue = new ArrayValue(arrayType);
324
325                                 int childCount = tree->getChildCount(tree);
326
327                                 if(childCount > 0)
328                                 {
329                                         for(int i = 0; i < childCount; ++i)
330                                         {
331                                                 pANTLR3_BASE_TREE assignment = (pANTLR3_BASE_TREE)tree->getChild(tree, i);
332
333                                                 Databoard::Type::DataType* dataType = arrayType->getComponentType();
334
335                                                 Value* value = parseValues(assignment, dataType, indent + 1);
336
337                                                 arrayValue->add(value);
338
339
340                                                 //Value* keyValue = parseValues(key, dataType, indent + 1);
341
342
343                                                 //      if(assignment->getType(assignment) == ASSIGNMENT)
344                                                 //      {
345                                                 //              if(assignment->getChildCount(assignment) == 2)
346                                                 //              {
347                                                 //                      pANTLR3_BASE_TREE key = (pANTLR3_BASE_TREE)assignment->getChild(assignment, 0);
348                                                 //                      pANTLR3_BASE_TREE value = (pANTLR3_BASE_TREE)assignment->getChild(assignment, 1);
349
350                                                 //                      std::string strKey((char*)key->getText(key)->chars);
351                                                 //                      std::string strValue((char*)value->getText(value)->chars);
352
353                                                 //                      strKey = removeQuotes(strKey);
354                                                 //                      strValue = removeQuotes(strValue);
355
356                                                 //                      Value* keyValue = parseValues(key, mapType->getKeyType(), indent + 1);
357                                                 //                      Value* valueValue = parseValues(value, mapType->getValueType(), indent + 1);
358
359                                                 //                      if(keyValue != NULL && valueValue != NULL)
360                                                 //                      {
361                                                 //                              mapValue->put(keyValue, valueValue);
362                                                 //                      }
363                                                 //              }
364                                                 //      }
365                                         }
366                                 }
367
368                                 return arrayValue;
369                         }
370                         else if(dynamic_cast<Databoard::Type::BooleanType*>(dataBoard) != NULL)
371                         {
372                                 Databoard::Type::BooleanType* booleanType = (Databoard::Type::BooleanType*)dataBoard;
373
374                                 BooleanValue* booleanValue = new BooleanValue(dataBoard);
375
376                                 std::string value((char*)tree->getText(tree)->chars);
377
378                                 if(value == STR_TRUE)
379                                 {
380                                         booleanValue->setValue(true);
381                                 }
382                                 else
383                                 {
384                                         booleanValue->setValue(false);
385                                 }
386
387                                 return booleanValue;
388                         }
389                         else if(dynamic_cast<Databoard::Type::UnionType*>(dataBoard) != NULL)
390                         {
391                                 if(tree->getChildCount(tree) == 2)
392                                 {
393                                         pANTLR3_BASE_TREE id = (pANTLR3_BASE_TREE)tree->getChild(tree, 0);
394                                         pANTLR3_BASE_TREE type = (pANTLR3_BASE_TREE)tree->getChild(tree, 1);
395
396                                         Databoard::Type::UnionType* unionType = (Databoard::Type::UnionType*)dataBoard;
397
398                                         UnionValue* unionValue = new UnionValue(dataBoard);
399                                         
400
401                                         std::string strId((char*)id->getText(id)->chars);
402
403                                         int tag = unionType->getComponentIndex(strId);
404
405                                         Databoard::Type::Component* component = unionType->getComponent(tag);
406
407                                         if(component != NULL)
408                                         {
409                                                 Databoard::Type::DataType* dataType = component->getDataBoard();
410
411                                                 if(dataType != NULL)
412                                                 {
413                                                         Databoard::Value::Value* value = parseValues(type, dataType, indent);
414
415                                                         unionValue->setValue(tag, value);
416                                                 }
417                                         }
418
419                                         return unionValue;
420                                 }
421                         }
422                         else if(dynamic_cast<Databoard::Type::VariantType*>(dataBoard) != NULL)
423                         {
424                                 if(tree->getChildCount(tree) == 0)
425                                 {
426                                         std::string valueId((char*)tree->getText(tree)->chars);
427
428                                         // check the string
429                                         if(valueId.length() >= 2)
430                                         {
431                                                 if(valueId.at(0) == '"' && valueId.at(valueId.length()-1) == '"')
432                                                 {
433                                                         valueId = removeQuotes(valueId);
434
435                                                         Databoard::Type::StringType* stringType = new Databoard::Type::StringType();
436                                                         stringType->setNotBuiltIn();
437
438                                                         Databoard::Value::StringValue* stringValue = new Databoard::Value::StringValue(stringType);
439
440                                                         stringValue->setValue(valueId);
441
442                                                         Databoard::Value::VariantValue* variantValue = new VariantValue(dataBoard);
443                                                         variantValue->setValue(stringValue);
444
445                                                         return variantValue;
446                                                 }
447                                         }
448
449                                         if(strEquals((char*)tree->getText(tree)->chars, STR_TRUE) == true)
450                                         {
451                                                 Databoard::Type::BooleanType* booleanType = new Databoard::Type::BooleanType();
452                                                 booleanType->setNotBuiltIn();
453
454                                                 Databoard::Value::BooleanValue* booleanValue = new Databoard::Value::BooleanValue(booleanType);
455
456                                                 booleanValue->setValue(true);
457
458                                                 Databoard::Value::VariantValue* variantValue = new VariantValue(dataBoard);
459                                                 variantValue->setValue(booleanValue);
460
461                                                 return variantValue;
462                                         }
463                                         else if(strEquals((char*)tree->getText(tree)->chars, STR_FALSE) == true)
464                                         {
465                                                 Databoard::Type::BooleanType* booleanType = new Databoard::Type::BooleanType();
466                                                 booleanType->setNotBuiltIn();
467
468                                                 Databoard::Value::BooleanValue* booleanValue = new Databoard::Value::BooleanValue(booleanType);
469
470                                                 booleanValue->setValue(false);
471
472                                                 Databoard::Value::VariantValue* variantValue = new VariantValue(dataBoard);
473                                                 variantValue->setValue(booleanValue);
474
475                                                 return variantValue;
476                                         }
477
478                                         return NULL;
479                                 }
480                                 else if(tree->getChildCount(tree) == 2)
481                                 {
482                                         pANTLR3_BASE_TREE id = (pANTLR3_BASE_TREE)tree->getChild(tree, 0);
483                                         pANTLR3_BASE_TREE type = (pANTLR3_BASE_TREE)tree->getChild(tree, 1);
484
485                                         Databoard::Type::VariantType* variantType = (Databoard::Type::VariantType*)dataBoard;
486
487                                         Databoard::Type::temporaryname a(NULL);
488
489                                         Databoard::Type::DataType* dataType = a.parse(id);
490
491                                         
492                                         Databoard::Value::Value* value = parseValues(type, dataType, indent);
493
494                                         Databoard::Value::VariantValue* variantValue = new VariantValue(dataBoard);
495                                         variantValue->setValue(value);
496
497                                         return variantValue;
498                                 }
499                         }
500                         else
501                         {
502                                 std::cout << "unknown: " << tree->getType(tree) << std::endl;
503                         }
504
505                         return NULL;
506                 }
507
508                 Value* DataValueRepository::parse(pANTLR3_BASE_TREE tree, Value* parent, int indent)
509                 {
510                         switch(tree->getType(tree)) {
511                                 case VALUE_DEFINITIONS:
512                                         {
513                                                 for(int i=0;i<(int)tree->getChildCount(tree);++i)
514                                                 {
515                                                         Value* value = parse((pANTLR3_BASE_TREE)tree->getChild(tree, i), parent, indent + 1);
516                                                 }
517                                         }
518                                         break;
519                                 case VALUE_DEFINITION:
520                                         {
521                                                 if(tree->getChildCount(tree) == 3)
522                                                 {
523                                                         pANTLR3_BASE_TREE id = (pANTLR3_BASE_TREE)tree->getChild(tree, 0);
524                                                         pANTLR3_BASE_TREE type = (pANTLR3_BASE_TREE)tree->getChild(tree, 1);
525                                                         pANTLR3_BASE_TREE values = (pANTLR3_BASE_TREE)tree->getChild(tree, 2);
526
527                                                         //std::cout << id->getText(id)->chars << " : " << id->getType(id) << std::endl;
528                                                         //std::cout << type->getText(type)->chars << " : " << type->getType(type) << std::endl;
529                                                         //std::cout << values->getText(values)->chars << " : " << values->getType(values) << std::endl;
530
531                                                         const Databoard::Type::strTypeDefinition* dataBoard = parseTypeReference(type);
532
533                                                         Value* dataValue = parseValues(values, dataBoard->dataBoard, indent+1);
534
535                                                         std::string valueId((char*)id->getText(id)->chars);
536
537                                                         addDataValue(valueId, dataBoard->name, dataValue);
538
539                                                         //std::cout << "." << std::endl;
540                                                 }
541                                         }
542                                         break;
543                                 default:
544                                         break;
545                         }
546
547                         return NULL;
548                 }
549
550                 bool DataValueRepository::open(std::string fileName, Databoard::Type::DataBoardRepository* dataBoardRepository)
551                 {
552                         pANTLR3_INPUT_STREAM input = antlr3AsciiFileStreamNew((pANTLR3_UINT8)fileName.c_str());
553
554                         if ( input == NULL )
555                         {
556                                 ANTLR3_FPRINTF(stderr, "string: %s\n", fileName.c_str());
557                         }
558
559                         pSimanticsDataLexer lexer = SimanticsDataLexerNew(input);
560
561                         if ( lexer == NULL )
562                         {
563                                 ANTLR3_FPRINTF(stderr, "Unable to create the lexer due to malloc() failure1\n");
564                                 exit(ANTLR3_ERR_NOMEM);
565                         }
566
567                         pANTLR3_COMMON_TOKEN_STREAM tstream = antlr3CommonTokenStreamSourceNew(ANTLR3_SIZE_HINT, TOKENSOURCE(lexer));//->pLexer->tokSource);
568
569                         if (tstream == NULL)
570                         {
571                                 ANTLR3_FPRINTF(stderr, "Out of memory trying to allocate token stream\n");
572                                 exit(ANTLR3_ERR_NOMEM);
573                         }
574
575                         pSimanticsDataParser parser = SimanticsDataParserNew(tstream); // CParserNew is generated by ANTLR3
576
577                         if (parser == NULL)
578                         {
579                                 ANTLR3_FPRINTF(stderr, "Out of memory trying to allocate parser\n");
580                                 exit(ANTLR3_ERR_NOMEM);
581                         }
582
583                         SimanticsDataParser_valueDefinitions_return astValue = parser->valueDefinitions(parser);
584
585                         this->dataBoardRepository = dataBoardRepository;
586
587                         bool retValue = true;
588
589                         if(lexer->pLexer->rec->state->errorCount == 0)
590                         {
591                                 parse(astValue.tree);
592
593                                 //print(astValue.tree);
594                         }
595                         else
596                         {
597                                 retValue = false;
598                         }
599
600                         parser->free(parser);
601                         tstream->free(tstream);
602                         lexer->free(lexer);
603                         input->free(input);
604
605                         return retValue;
606                 }
607
608                 Value* DataValueRepository::open(std::string fileName, Databoard::Type::DataType* dataType)
609                 {
610                         pANTLR3_INPUT_STREAM input = antlr3AsciiFileStreamNew((pANTLR3_UINT8)fileName.c_str());
611
612                         if ( input == NULL )
613                         {
614                                 ANTLR3_FPRINTF(stderr, "string: %s\n", fileName.c_str());
615                         }
616
617                         pSimanticsDataLexer lexer = SimanticsDataLexerNew(input);
618
619                         if ( lexer == NULL )
620                         {
621                                 ANTLR3_FPRINTF(stderr, "Unable to create the lexer due to malloc() failure1\n");
622                                 exit(ANTLR3_ERR_NOMEM);
623                         }
624
625                         pANTLR3_COMMON_TOKEN_STREAM tstream = antlr3CommonTokenStreamSourceNew(ANTLR3_SIZE_HINT, TOKENSOURCE(lexer));//->pLexer->tokSource);
626
627                         if (tstream == NULL)
628                         {
629                                 ANTLR3_FPRINTF(stderr, "Out of memory trying to allocate token stream\n");
630                                 exit(ANTLR3_ERR_NOMEM);
631                         }
632
633                         pSimanticsDataParser parser = SimanticsDataParserNew(tstream); // CParserNew is generated by ANTLR3
634
635                         if (parser == NULL)
636                         {
637                                 ANTLR3_FPRINTF(stderr, "Out of memory trying to allocate parser\n");
638                                 exit(ANTLR3_ERR_NOMEM);
639                         }
640
641                         SimanticsDataParser_value_return astValue = parser->value(parser);
642
643                         Value* retValue = NULL;
644
645                         dataBoardRepository = NULL;
646
647                         if(lexer->pLexer->rec->state->errorCount == 0)
648                         {
649                                 retValue = parseValues(astValue.tree, dataType, 0);
650
651                                 //print(astValue.tree);
652                         }
653                         else
654                         {
655                                 retValue = false;
656                         }
657
658                         parser->free(parser);
659                         tstream->free(tstream);
660                         lexer->free(lexer);
661                         input->free(input);
662
663                         return retValue;
664                 }
665
666                 void DataValueRepository::print(pANTLR3_BASE_TREE tree, int indent)
667                 {
668                         for(int i=0;i<indent;++i)
669                                 std::cout << "  ";
670
671                         std::cout << tree->getText(tree)->chars << " " << 
672                                 tree->getType(tree) << std::endl;
673
674                         for(int i=0;i<(int)tree->getChildCount(tree);++i)
675                         {
676                                 print((pANTLR3_BASE_TREE)tree->getChild(tree, i), indent + 1);
677                         }
678                 }
679
680                 int DataValueRepository::count()
681                 {
682                         return (int)values.size();
683                 }
684
685                 const strDataValueDefinition* DataValueRepository::getDataValue(int i)
686                 {
687                         if(i >= 0 && i < (int)values.size())
688                         {
689                                 return &(values.at(i));
690                         }
691                         else
692                         {
693                                 return NULL;
694                         }
695                 }
696
697                 const strDataValueDefinition* DataValueRepository::getDataValue(std::string name)
698                 {
699                         for(int i = 0; i < (int)values.size(); ++i)
700                         {
701                                 if(values.at(i).name == name)
702                                 {
703                                         return &(values.at(i));
704                                 }
705                         }
706
707                         return NULL;
708                 }
709         }
710 }