3 #include "StackWalker.h"
\r
6 #include "TypeParser.h"
\r
7 #include "ValueParser.h"
\r
9 #include "DataBoardRepository.h"
\r
10 #include "DataValueRepository.h"
\r
12 #include "RecordType.h"
\r
13 #include "Component.h"
\r
15 #include "RecordValue.h"
\r
16 #include "StringValue.h"
\r
17 #include "IntegerValue.h"
\r
18 #include "DoubleValue.h"
\r
19 #include "ArrayValue.h"
\r
21 #include "MapValue.h"
\r
22 #include "IntegerType.h"
\r
23 #include "StringType.h"
\r
24 #include "DataType.h"
\r
27 #include "NumberType.h"
\r
35 std::cout << "Output of dbt & dbv files:" << std::endl;
\r
37 Databoard::Type::DataBoardRepository* typeRepo = Databoard::Type::parse("input11.dbt");
\r
39 if(typeRepo == NULL)
\r
41 std::cerr << "type repository not found" << std::endl;
\r
46 Databoard::Type::DataType* type = typeRepo->getDataBoard("PBEparticle");
\r
50 std::cerr << "type not found" << std::endl;
\r
55 Databoard::Value::Value* value = Databoard::Value::parse("input12.dbv", type);
\r
59 std::cerr << "value not found" << std::endl;
\r
64 //Databoard::Type::RecordType* r = ((Databoard::Type::RecordType*)type);
\r
66 //std::cout << r->getComponentIndex("FractalIndex") << std::endl;
\r
67 //std::cout << r->getComponentIndex("Bondforce") << std::endl;
\r
68 //std::cout << r->getComponentIndex("Density") << std::endl;
\r
69 //std::cout << r->getComponentIndex("RefractiveIndex") << std::endl;
\r
70 //std::cout << r->getComponentIndex("UVabsorption") << std::endl;
\r
71 //std::cout << r->getComponentIndex("SurfacePotential") << std::endl;
\r
72 //std::cout << r->getComponentIndex("SurfaceCharge") << std::endl;
\r
73 //std::cout << r->getComponentIndex("RPermittivity") << std::endl;
\r
74 //std::cout << r->getComponentIndex("AvgRadius") << std::endl;
\r
76 //Databoard::Value::RecordValue* t = ((Databoard::Value::RecordValue*)value);
\r
78 //Databoard::Value::DoubleValue* f0 = (Databoard::Value::DoubleValue*)t->getField(0);
\r
79 //Databoard::Value::DoubleValue* f1 = (Databoard::Value::DoubleValue*)t->getField(1);
\r
80 //Databoard::Value::DoubleValue* f2 = (Databoard::Value::DoubleValue*)t->getField(2);
\r
81 //Databoard::Value::DoubleValue* f3 = (Databoard::Value::DoubleValue*)t->getField(3);
\r
82 //Databoard::Value::RecordValue* f4 = (Databoard::Value::RecordValue*)t->getField(4);
\r
83 //Databoard::Value::DoubleValue* f5 = (Databoard::Value::DoubleValue*)t->getField(5);
\r
84 //Databoard::Value::DoubleValue* f6 = (Databoard::Value::DoubleValue*)t->getField(6);
\r
85 //Databoard::Value::DoubleValue* f7 = (Databoard::Value::DoubleValue*)t->getField(7);
\r
86 //Databoard::Value::DoubleValue* f8 = (Databoard::Value::DoubleValue*)t->getField(8);
\r
88 //std::cout << f0->getValue() << std::endl;
\r
89 //std::cout << f1->getValue() << std::endl;
\r
90 //std::cout << f2->getValue() << std::endl;
\r
91 //std::cout << f3->getValue() << std::endl;
\r
93 //std::cout << ((Databoard::Value::DoubleValue*)f4->getField(0))->getValue() << std::endl;
\r
94 //std::cout << ((Databoard::Value::DoubleValue*)f4->getField(1))->getValue() << std::endl;
\r
96 //std::cout << f5->getValue() << std::endl;
\r
97 //std::cout << f6->getValue() << std::endl;
\r
98 //std::cout << f7->getValue() << std::endl;
\r
99 //std::cout << f8->getValue() << std::endl;
\r
101 std::cout << type->writeOut() << std::endl;
\r
102 std::cout << value->writeOut() << std::endl;
\r
107 std::cout << "..." << std::endl;
\r
112 std::cout << "Output of dbt & dbd(s) files:" << std::endl;
\r
114 Databoard::Type::DataBoardRepository* typeRepo = Databoard::Type::parse("input23.dbt");
\r
116 if(typeRepo == NULL)
\r
118 std::cerr << "type repository not found" << std::endl;
\r
123 Databoard::Value::DataValueRepository* valueRepo = NULL;
\r
124 Databoard::Value::parse("input24_1.dbd", valueRepo, typeRepo);
\r
125 Databoard::Value::parse("input24_2.dbd", valueRepo, typeRepo);
\r
127 const Databoard::Value::strDataValueDefinition* v1 = valueRepo->getDataValue("a");
\r
128 const Databoard::Value::strDataValueDefinition* v2 = valueRepo->getDataValue("b");
\r
130 std::cout << "... printing types:" << std::endl;
\r
132 for(int i = 0; i < typeRepo->count(); ++i)
\r
134 std::cout << "#" << i << ":" << std::endl;
\r
136 std::cout << typeRepo->getDataBoard(i).writeOut() << std::endl << std::endl;
\r
141 std::cout << "... printing value definition:" << std::endl;
\r
143 std::cout << v1->writeOut() << std::endl;
\r
145 std::string v = v1->value->isValid();
\r
149 std::cout << "type is invalid: " << v << std::endl;
\r
153 std::cout << "type is valid" << std::endl;
\r
159 std::cout << "... printing value definition:" << std::endl;
\r
161 std::cout << v2->writeOut() << std::endl;
\r
163 std::string v = v2->value->isValid();
\r
167 std::cout << "type is invalid: " << v << std::endl;
\r
171 std::cout << "type is valid" << std::endl;
\r
176 Databoard::Value::free(valueRepo);
\r
177 Databoard::Type::free(typeRepo);
\r
179 std::cout << "..." << std::endl;
\r
185 std::cout << "Output of dbt file:" << std::endl;
\r
187 Databoard::Type::DataBoardRepository* typeRepo = Databoard::Type::parse("input17.dbt");
\r
189 Databoard::Type::DataType* type = typeRepo->getDataBoard("Complex");
\r
193 std::cerr << "type not found" << std::endl;
\r
198 std::cout << type->writeOut() << std::endl;
\r
200 Databoard::Value::MapValue* mapValue = new Databoard::Value::MapValue(type);
\r
202 Databoard::Type::IntegerType* integerType = new Databoard::Type::IntegerType();
\r
203 Databoard::Type::StringType* stringType = new Databoard::Type::StringType();
\r
205 Databoard::Value::IntegerValue* k0 = new Databoard::Value::IntegerValue(integerType);
\r
206 Databoard::Value::IntegerValue* k1 = new Databoard::Value::IntegerValue(integerType);
\r
207 Databoard::Value::IntegerValue* k2 = new Databoard::Value::IntegerValue(integerType);
\r
208 Databoard::Value::IntegerValue* k3 = new Databoard::Value::IntegerValue(integerType);
\r
210 Databoard::Value::StringValue* v0 = new Databoard::Value::StringValue(stringType);
\r
211 Databoard::Value::StringValue* v1 = new Databoard::Value::StringValue(stringType);
\r
212 Databoard::Value::StringValue* v2 = new Databoard::Value::StringValue(stringType);
\r
213 Databoard::Value::StringValue* v3 = new Databoard::Value::StringValue(stringType);
\r
220 v0->setValue("asd0");
\r
221 v1->setValue("asd1");
\r
222 v2->setValue("asd2");
\r
223 v3->setValue("asd3");
\r
225 std::cout << "mappi:" << std::endl << mapValue->writeOut() << std::endl;
\r
226 mapValue->put(k0, v0);
\r
228 std::cout << "mappi:" << std::endl << mapValue->writeOut() << std::endl;
\r
229 mapValue->put(k1, v1);
\r
231 std::cout << "mappi:" << std::endl << mapValue->writeOut() << std::endl;
\r
232 mapValue->put(k2, v2);
\r
234 std::cout << "mappi:" << std::endl << mapValue->writeOut() << std::endl;
\r
235 mapValue->put(k3, v3);
\r
237 mapValue->removeRange(k0, k1);
\r
239 //Databoard::Value::Value* old = mapValue->remove(k0);
\r
245 delete integerType;
\r
248 Databoard::Type::free(typeRepo);
\r
253 std::cout << "Output of dbt & dbv files:" << std::endl;
\r
255 Databoard::Type::DataBoardRepository* typeRepo = Databoard::Type::parse("input25.dbt");
\r
257 if(typeRepo == NULL)
\r
259 std::cerr << "type repository not found" << std::endl;
\r
264 Databoard::Type::DataType* type = typeRepo->getDataBoard("AggreDist");
\r
268 std::cerr << "type not found" << std::endl;
\r
273 Databoard::Value::DataValueRepository* valueRepo = NULL;
\r
274 Databoard::Value::parse("input26_3.dbd", valueRepo, typeRepo);
\r
276 Databoard::Value::Value* value1 = Databoard::Value::parse("input26_1.dbv", type);
\r
280 std::cerr << "value not found" << std::endl;
\r
285 Databoard::Value::Value* value2 = Databoard::Value::parse("input26_2.dbv", type);
\r
289 std::cerr << "value not found" << std::endl;
\r
296 std::cout << "... printing value definition:" << std::endl;
\r
298 std::cout << value1->writeOut() << std::endl;
\r
300 std::string v = value1->isValid();
\r
304 std::cout << "type is invalid: " << v << std::endl;
\r
308 std::cout << "type is valid" << std::endl;
\r
316 std::cout << "... printing value definition:" << std::endl;
\r
318 std::cout << value2->writeOut() << std::endl;
\r
320 std::string v = value2->isValid();
\r
324 std::cout << "type is invalid: " << v << std::endl;
\r
328 std::cout << "type is valid" << std::endl;
\r
337 std::cout << "..." << std::endl;
\r
342 std::cout << "Output of dbt & dbv files:" << std::endl;
\r
344 Databoard::Type::DataBoardRepository* typeRepo = Databoard::Type::parse("input27.dbt");
\r
346 if(typeRepo == NULL)
\r
348 std::cerr << "type repository not found" << std::endl;
\r
353 Databoard::Type::DataType* type = typeRepo->getDataBoard("Complex");
\r
357 std::cerr << "type not found" << std::endl;
\r
362 Databoard::Value::Value* value = Databoard::Value::parse("input28.dbv", type);
\r
366 std::cerr << "value not found" << std::endl;
\r
371 std::cout << type->writeOut() << std::endl;
\r
372 std::cout << value->writeOut() << std::endl;
\r
377 std::cout << "..." << std::endl;
\r
382 std::cout << "Output of dbt & dbv files:" << std::endl;
\r
384 Databoard::Type::DataBoardRepository* typeRepo = Databoard::Type::parse("input29.dbt");
\r
386 if(typeRepo == NULL)
\r
388 std::cerr << "type repository not found" << std::endl;
\r
393 Databoard::Type::DataType* type = typeRepo->getDataBoard("T");
\r
397 std::cerr << "type not found" << std::endl;
\r
402 Databoard::Value::Value* value1 = Databoard::Value::parse("input30.dbv", type);
\r
406 std::cerr << "value not found" << std::endl;
\r
411 Databoard::Value::RecordValue* recordValue = dynamic_cast<Databoard::Value::RecordValue*>(value1);
\r
413 if(recordValue != NULL)
\r
415 for(int i = 0; i < recordValue->count(); ++i)
\r
417 Databoard::Value::Value* value = recordValue->getField(i);
\r
419 Databoard::Value::ArrayValue* arrayValue = dynamic_cast<Databoard::Value::ArrayValue*>(value);
\r
421 if(arrayValue != NULL)
\r
424 //for(int j = 0; j < arrayValue->count(); ++j)
\r
426 // Databoard::Value::Value* value = arrayValue->get(j);
\r
428 // std::cout << value->writeOut() << std::endl;
\r
432 std::vector<Databoard::Value::Value*> valueVector = arrayValue->getAll();
\r
434 std::cout << "Row count: " << (int)valueVector.size() << std::endl;
\r
436 for(int j = 0; j < (int)valueVector.size(); ++j)
\r
438 Databoard::Value::RecordValue* recordValue = (Databoard::Value::RecordValue*)valueVector.at(j);
\r
440 std::cout << "Element count: " << recordValue->count() << std::endl;
\r
442 for(int k = 0; k < recordValue->count(); ++k)
\r
444 Databoard::Value::DoubleValue* doubleValue = (Databoard::Value::DoubleValue*)recordValue->getField(k);
\r
446 std::cout << doubleValue->getValue() << std::endl;
\r
458 std::cout << "..." << std::endl;
\r
476 DeInitAllocCheck();
\r