-
Notifications
You must be signed in to change notification settings - Fork 0
/
Instance.c
681 lines (616 loc) · 19.4 KB
/
Instance.c
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
#include <stdlib.h>
#include "NamedElement.h"
#include "TypeDefinition.h"
#include "Dictionary.h"
#include "FragmentDictionary.h"
#include "Visitor.h"
#include "Instance.h"
#define DEBUG 0
#if DEBUG
#define PRINTF(...) printf(__VA_ARGS__)
#else
#define PRINTF(...)
#endif
NamedElement* newPoly_Instance()
{
Instance* pInstanceObj = NULL;
NamedElement* pObj = new_NamedElement();
/* Allocating memory */
pInstanceObj = (Instance*)malloc(sizeof(Instance));
if (pInstanceObj == NULL)
{
pObj->Delete(pObj);
return NULL;
}
pObj->pDerivedObj = pInstanceObj; /* Pointing to derived object */
pInstanceObj->path = NULL;
pInstanceObj->metaData = NULL;
pInstanceObj->started = -1;
pInstanceObj->typeDefinition = NULL;
pInstanceObj->dictionary = NULL;
pInstanceObj->fragmentDictionary = NULL;
pInstanceObj->FindFragmentDictionaryByID = Instance_FindFragmentDictionaryByID;
pInstanceObj->AddTypeDefinition = Instance_AddTypeDefinition;
pInstanceObj->AddDictionary = Instance_AddDictionary;
pInstanceObj->AddFragmentDictionary = Instance_AddFragmentDictionary;
pInstanceObj->RemoveTypeDefinition = Instance_RemoveTypeDefinition;
pInstanceObj->RemoveDictionary = Instance_RemoveDictionary;
pInstanceObj->RemoveFragmentDictionary = Instance_RemoveFragmentDictionary;
pObj->metaClassName = Instance_metaClassName;
pObj->internalGetKey = Instance_internalGetKey;
pObj->Delete = deletePoly_Instance;
pObj->VisitAttributes = Instance_VisitAttributes;
pObj->VisitPathAttributes = Instance_VisitPathAttributes;
pObj->VisitReferences = Instance_VisitReferences;
pObj->VisitPathReferences = Instance_VisitPathReferences;
pObj->FindByPath = Instance_FindByPath;
return pObj;
}
Instance* new_Instance()
{
Instance* pInstanceObj = NULL;
NamedElement* pObj = new_NamedElement();
/* Allocating memory */
pInstanceObj = (Instance*)malloc(sizeof(Instance));
if (pInstanceObj == NULL)
{
return NULL;
}
/*pObj->pDerivedObj = pInstanceObj; Pointing to derived object */
pInstanceObj->super = pObj;
pInstanceObj->path = NULL;
pInstanceObj->metaData = NULL;
pInstanceObj->started = -1;
pInstanceObj->typeDefinition = NULL;
pInstanceObj->dictionary = NULL;
pInstanceObj->fragmentDictionary = NULL;
pInstanceObj->FindFragmentDictionaryByID = Instance_FindFragmentDictionaryByID;
pInstanceObj->AddTypeDefinition = Instance_AddTypeDefinition;
pInstanceObj->AddDictionary = Instance_AddDictionary;
pInstanceObj->AddFragmentDictionary = Instance_AddFragmentDictionary;
pInstanceObj->RemoveTypeDefinition = Instance_RemoveTypeDefinition;
pInstanceObj->RemoveDictionary = Instance_RemoveDictionary;
pInstanceObj->RemoveFragmentDictionary = Instance_RemoveFragmentDictionary;
pInstanceObj->metaClassName = Instance_metaClassName;
pObj->metaClassName = pInstanceObj->metaClassName;
pInstanceObj->internalGetKey = Instance_internalGetKey;
pInstanceObj->Delete = delete_Instance;
pInstanceObj->VisitAttributes = Instance_VisitAttributes;
pInstanceObj->VisitPathAttributes = Instance_VisitPathAttributes;
pInstanceObj->VisitReferences = Instance_VisitReferences;
pInstanceObj->VisitPathReferences = Instance_VisitPathReferences;
pInstanceObj->FindByPath = Instance_FindByPath;
return pInstanceObj;
}
FragmentDictionary* Instance_FindFragmentDictionaryByID(Instance* const this, char* id)
{
FragmentDictionary* value = NULL;
if(this->fragmentDictionary != NULL)
{
if(hashmap_get(this->fragmentDictionary, id, (void**)(&value)) == MAP_OK)
return value;
else
return NULL;
}
else
{
return NULL;
}
}
void Instance_AddTypeDefinition(Instance* this, TypeDefinition* ptr)
{
this->typeDefinition = ptr;
}
void Instance_AddDictionary(Instance* const this, Dictionary* ptr)
{
this->dictionary = ptr;
ptr->eContainer = malloc(sizeof(char) * (strlen(this->path)) + 1);
strcpy(ptr->eContainer, this->path);
ptr->path = malloc(sizeof(char) * (strlen(this->path) + strlen("/dictionary[]") + strlen(ptr->internalGetKey(ptr))) + 1);
sprintf(ptr->path, "%s/dictionary[%s]", this->path, ptr->internalGetKey(ptr));
}
void Instance_AddFragmentDictionary(Instance* const this, FragmentDictionary* ptr)
{
FragmentDictionary* container = NULL;
char *internalKey = ptr->internalGetKey(ptr);
if(internalKey == NULL)
{
PRINTF("The FragmentDictionary cannot be added in Instance because the key is not defined\n");
}
else
{
if(this->fragmentDictionary == NULL)
{
this->fragmentDictionary = hashmap_new();
}
if(hashmap_get(this->fragmentDictionary, internalKey, (void**)(&container)) == MAP_MISSING)
{
/*container = (FragmentDictionary*)ptr;*/
if(hashmap_put(this->fragmentDictionary, internalKey, ptr) == MAP_OK)
{
ptr->eContainer = malloc(sizeof(char) * (strlen(this->path)) + 1);
strcpy(ptr->eContainer, this->path);
ptr->super->eContainer = ptr->eContainer;
ptr->path = malloc(sizeof(char) * (strlen(this->path) + strlen("/fragmentDictionary[]") + strlen(internalKey)) + 1);
sprintf(ptr->path, "%s/fragmentDictionary[%s]", this->path, internalKey);
ptr->super->path = ptr->path;
}
}
}
}
void Instance_RemoveTypeDefinition(Instance* const this, TypeDefinition* ptr)
{
this->typeDefinition = NULL;
}
void Instance_RemoveDictionary(Instance* const this, Dictionary* ptr)
{
free(ptr->eContainer);
ptr->eContainer = NULL;
this->dictionary = NULL;
}
void Instance_RemoveFragmentDictionary(Instance* const this, FragmentDictionary* ptr)
{
char *internalKey = ptr->internalGetKey(ptr);
if(internalKey == NULL)
{
PRINTF("The FragmentDictionary cannot be removed in Instance because the key is not defined\n");
}
else
{
hashmap_remove(this->fragmentDictionary, internalKey);
}
}
char* Instance_internalGetKey(void* const this)
{
Instance *pObj = (Instance*)this;
return pObj->super->internalGetKey(pObj->super);
}
char* Instance_metaClassName(void* const this)
{
char *name;
name = malloc(sizeof(char) * (strlen("Instance")) + 1);
if(name != NULL)
strcpy(name, "Instance");
else
return NULL;
return name;
}
void deletePoly_Instance(void * const this)
{
NamedElement *pObj = (NamedElement*)this;
Instance* pInstanceObj;
pInstanceObj = pObj->pDerivedObj;
/*destroy derived obj*/
free(pInstanceObj->metaData);
/*
free(pInstanceObj->typeDefinition);
free(pInstanceObj->dictionary);
*/
/*
* TODO verify NULLity
*/
hashmap_free(pInstanceObj->fragmentDictionary);
free(pInstanceObj);
/*destroy base Obj*/
delete_NamedElement(pObj);
}
void delete_Instance(void * const this)
{
Instance *pObj = (Instance*)this;
/* destroy base object */
delete_NamedElement(pObj->super);
/* destroy data memebers */
free(pObj->metaData);
/*
free(this->typeDefinition);
free(this->dictionary);
*/
/*
* TODO verify NULLity
*/
hashmap_free(pObj->fragmentDictionary);
free(pObj);
}
void Instance_VisitAttributes(void *const this, char *parent, Visitor *visitor, bool recursive)
{
char path[256];
memset(&path[0], 0, sizeof(path));
/* NamedElement attributes */
NamedElement_VisitAttributes(((Instance*)(this))->super, parent, visitor, recursive);
/* Local attributes */
if(recursive)
{
sprintf(path,"metaData");
visitor->action(path, STRING, ((Instance*)(this))->metaData);
visitor->action(NULL, COLON, NULL);
sprintf(path, "started");
visitor->action(path, BOOL, (void*)((Instance*)(this))->started);
visitor->action(NULL, COLON, NULL);
}
}
void Instance_VisitPathAttributes(void *const this, char *parent, Visitor *visitor, bool recursive)
{
char path[256];
memset(&path[0], 0, sizeof(path));
/* NamedElement attributes */
NamedElement_VisitPathAttributes(((Instance*)(this))->super, parent, visitor, recursive);
/* Local attributes */
if(recursive)
{
sprintf(path,"%s\\metaData", parent);
visitor->action(path, STRING, ((Instance*)(this))->metaData);
sprintf(path,"%s\\started", parent);
visitor->action(path, BOOL, (void*)((Instance*)(this))->started);
}
}
void Instance_VisitReferences(void *const this, char *parent, Visitor *visitor, bool recursive)
{
char path[256];
memset(&path[0], 0, sizeof(path));
if(recursive)
{
if(((Instance*)(this))->typeDefinition != NULL)
{
visitor->action("typeDefinition", SQBRACKET, NULL);
((Instance*)(this))->typeDefinition->VisitAttributes(((Instance*)(this))->typeDefinition, path, visitor, recursive);
((Instance*)(this))->typeDefinition->VisitReferences(((Instance*)(this))->typeDefinition, path, visitor, recursive);
visitor->action(NULL, CLOSESQBRACKETCOLON, NULL);
}
else
{
visitor->action("typeDefinition", SQBRACKET, NULL);
visitor->action(NULL, CLOSESQBRACKETCOLON, NULL);
}
if(((Instance*)(this))->dictionary != NULL)
{
visitor->action("dictionary", SQBRACKET, NULL);
visitor->action(NULL, BRACKET, NULL);
((Instance*)(this))->dictionary->VisitAttributes(((Instance*)(this))->dictionary, path, visitor, recursive);
((Instance*)(this))->dictionary->VisitReferences(((Instance*)(this))->dictionary, path, visitor, recursive);
visitor->action(NULL, CLOSEBRACKET, NULL);
visitor->action(NULL, CLOSESQBRACKETCOLON, NULL);
}
else
{
visitor->action("dictionary", SQBRACKET, NULL);
visitor->action(NULL, CLOSESQBRACKETCOLON, NULL);
}
hashmap_map* m = NULL;
int i;
if((m = (hashmap_map*) ((Instance*)(this))->fragmentDictionary) != NULL)
{
int length = hashmap_length(((Instance*)(this))->fragmentDictionary);
visitor->action("fragmentDictionary", SQBRACKET, NULL);
/* compare fragmentDictionary*/
for(i = 0; i< m->table_size; i++)
{
if(m->data[i].in_use != 0)
{
visitor->action(NULL, BRACKET, NULL);
any_t data = (any_t) (m->data[i].data);
FragmentDictionary* n = data;
n->VisitAttributes(n, path, visitor, recursive);
n->VisitReferences(n, path, visitor, recursive);
if(length > 1)
{
visitor->action(NULL, CLOSEBRACKETCOLON, NULL);
length--;
}
else
visitor->action(NULL, CLOSEBRACKET, NULL);
}
}
visitor->action(NULL, CLOSESQBRACKET, NULL);
}
else
{
visitor->action("fragmentDictionary", SQBRACKET, NULL);
visitor->action(NULL, CLOSESQBRACKET, NULL);
}
}
else
{
if(((Instance*)(this))->typeDefinition != NULL)
{
visitor->action("typeDefinition", SQBRACKET, NULL);
sprintf(path, "typeDefinitions[%s]", ((Instance*)(this))->typeDefinition->internalGetKey(((Instance*)(this))->typeDefinition));
visitor->action(path, STRREF, NULL);
visitor->action(NULL, RETURN, NULL);
visitor->action(NULL, CLOSESQBRACKETCOLON, NULL);
}
else
{
visitor->action("typeDefinition", SQBRACKET, NULL);
visitor->action(NULL, CLOSESQBRACKETCOLON, NULL);
}
if(((Instance*)(this))->dictionary != NULL)
{
visitor->action("dictionary", SQBRACKET, NULL);
visitor->action(NULL, BRACKET, NULL);
((Instance*)(this))->dictionary->VisitAttributes(((Instance*)(this))->dictionary, path, visitor, recursive);
((Instance*)(this))->dictionary->VisitReferences(((Instance*)(this))->dictionary, path, visitor, recursive);
visitor->action(NULL, CLOSEBRACKET, NULL);
visitor->action(NULL, CLOSESQBRACKETCOLON, NULL);
}
else
{
visitor->action("dictionary", SQBRACKET, NULL);
visitor->action(NULL, CLOSESQBRACKETCOLON, NULL);
}
hashmap_map* m = NULL;
int i;
if((m = (hashmap_map*) ((Instance*)(this))->fragmentDictionary) != NULL)
{
int length = hashmap_length(((Instance*)(this))->fragmentDictionary);
visitor->action("fragmentDictionary", SQBRACKET, NULL);
/* compare fragmentDictionary*/
for(i = 0; i< m->table_size; i++)
{
if(m->data[i].in_use != 0)
{
visitor->action(NULL, BRACKET, NULL);
any_t data = (any_t) (m->data[i].data);
FragmentDictionary* n = data;
n->VisitAttributes(n, path, visitor, recursive);
n->VisitReferences(n, path, visitor, recursive);
if(length > 1)
{
visitor->action(NULL, CLOSEBRACKETCOLON, NULL);
length--;
}
else
visitor->action(NULL, CLOSEBRACKET, NULL);
}
}
visitor->action(NULL, CLOSESQBRACKET, NULL);
}
else
{
visitor->action("fragmentDictionary", SQBRACKET, NULL);
visitor->action(NULL, CLOSESQBRACKET, NULL);
}
}
}
void Instance_VisitPathReferences(void *const this, char *parent, Visitor *visitor, bool recursive)
{
char path[256];
memset(&path[0], 0, sizeof(path));
if(recursive)
{
if(((Instance*)(this))->typeDefinition != NULL)
{
sprintf(path, "%s/typeDefinition[%s]", parent, ((Instance*)(this))->typeDefinition->internalGetKey(((Instance*)(this))->typeDefinition));
if (visitor->secondAction != NULL) {
if (visitor->secondAction(path, "typeDefinition")) {
((Instance*)(this))->typeDefinition->VisitPathAttributes(((Instance*)(this))->typeDefinition, path, visitor, recursive);
((Instance*)(this))->typeDefinition->VisitPathReferences(((Instance*)(this))->typeDefinition, path, visitor, recursive);
}
} else {
((Instance*)(this))->typeDefinition->VisitPathAttributes(((Instance*)(this))->typeDefinition, path, visitor, recursive);
((Instance*)(this))->typeDefinition->VisitPathReferences(((Instance*)(this))->typeDefinition, path, visitor, recursive);
}
}
if(((Instance*)(this))->dictionary != NULL)
{
sprintf(path, "%s/dictionary[%s]", parent, ((Instance*)(this))->dictionary->internalGetKey(((Instance*)(this))->dictionary));
if (visitor->secondAction != NULL) {
if (visitor->secondAction(path, "dictionary")) {
((Instance*)(this))->dictionary->VisitPathAttributes(((Instance*)(this))->dictionary, path, visitor, recursive);
((Instance*)(this))->dictionary->VisitPathReferences(((Instance*)(this))->dictionary, path, visitor, recursive);
} else {
((Instance*)(this))->dictionary->VisitPathAttributes(((Instance*)(this))->dictionary, path, visitor, recursive);
((Instance*)(this))->dictionary->VisitPathReferences(((Instance*)(this))->dictionary, path, visitor, recursive);
}
}
}
hashmap_map* m = NULL;
int i;
if((m = (hashmap_map*) ((Instance*)(this))->fragmentDictionary) != NULL)
{
PRINTF("Looking for fragmentDictionary\n");
/* compare fragmentDictionary*/
for(i = 0; i< m->table_size; i++)
{
if(m->data[i].in_use != 0)
{
any_t data = (any_t) (m->data[i].data);
FragmentDictionary* n = data;
sprintf(path, "%s/fragmentDictionary[%s]", parent, n->internalGetKey(n));
if (visitor->secondAction != NULL) {
if (visitor->secondAction(path, "fragmentDictionary")) {
n->VisitPathAttributes(n, path, visitor, recursive);
n->VisitPathReferences(n, path, visitor, recursive);
}
} else {
n->VisitPathAttributes(n, path, visitor, recursive);
n->VisitPathReferences(n, path, visitor, recursive);
}
}
}
}
}
else
{
if(((Instance*)(this))->typeDefinition != NULL)
{
sprintf(path, "%s/%s\\typeDefinition", parent, ((Instance*)(this))->typeDefinition->path);
/*((Instance*)(this))->typeDefinition->VisitPathAttributes(((Instance*)(this))->typeDefinition, path, visitor, recursive);*/
visitor->action(path, REFERENCE, parent);
}
if(((Instance*)(this))->dictionary != NULL)
{
sprintf(path, "%s/dictionary[%s]", parent, ((Instance*)(this))->dictionary->internalGetKey(((Instance*)(this))->dictionary));
if (visitor->secondAction != NULL) {
if (visitor->secondAction(path, "dictionary")) {
((Instance*)(this))->dictionary->VisitPathAttributes(((Instance*)(this))->dictionary, path, visitor, true);
((Instance*)(this))->dictionary->VisitPathReferences(((Instance*)(this))->dictionary, path, visitor, true);
} else {
((Instance*)(this))->dictionary->VisitPathAttributes(((Instance*)(this))->dictionary, path, visitor, true);
((Instance*)(this))->dictionary->VisitPathReferences(((Instance*)(this))->dictionary, path, visitor, true);
}
}
}
hashmap_map* m = NULL;
int i;
if((m = (hashmap_map*) ((Instance*)(this))->fragmentDictionary) != NULL)
{
/* compare fragmentDictionary*/
for(i = 0; i< m->table_size; i++)
{
if(m->data[i].in_use != 0)
{
any_t data = (any_t) (m->data[i].data);
FragmentDictionary* n = data;
sprintf(path, "%s/fragmentDictionary[%s]", parent, n->internalGetKey(n));
if (visitor->secondAction != NULL) {
if (visitor->secondAction(path, "fragmentDictionary")) {
n->VisitPathAttributes(n, path, visitor, true);
n->VisitPathReferences(n, path, visitor, true);
}
} else {
n->VisitPathAttributes(n, path, visitor, true);
n->VisitPathReferences(n, path, visitor, true);
}
}
}
}
}
}
void* Instance_FindByPath(char* attribute, void* const this)
{
Instance *pObj = (Instance*)this;
/* NamedElement attributes */
if(!strcmp("name", attribute))
{
return pObj->super->FindByPath(attribute, pObj->super);
}
/* Local attributes */
else if(!strcmp("metaData",attribute))
{
return pObj->metaData;
}
else if(!strcmp("started",attribute))
{
return (void*)pObj->started;
}
/* Local references */
else
{
char path[250];
memset(&path[0], 0, sizeof(path));
char token[100];
memset(&token[0], 0, sizeof(token));
char *obj = NULL;
char key[50];
memset(&key[0], 0, sizeof(key));
char nextPath[150];
memset(&nextPath[0], 0, sizeof(nextPath));
char *nextAttribute = NULL;
strcpy(path, attribute);
if(strchr(path, '[') != NULL)
{
obj = strdup(strtok(path, "["));
strcpy(path, attribute);
PRINTF("Object: %s\n", obj);
strcpy(token, strtok(path, "]"));
strcpy(path, attribute);
sprintf(token, "%s]", token);
PRINTF("Token: %s\n", token);
sscanf(token, "%*[^[][%[^]]", key);
PRINTF("Key: %s\n", key);
if((strchr(path, '\\')) != NULL)
{
nextAttribute = strtok(NULL, "\\");
PRINTF("Attribute: %s\n", nextAttribute);
if(strchr(nextAttribute, '['))
{
sprintf(nextPath, "%s\\%s", ++nextAttribute, strtok(NULL, "\\"));
PRINTF("Next Path: %s\n", nextPath);
}
else
{
strcpy(nextPath, nextAttribute);
PRINTF("Next Path: %s\n", nextPath);
}
}
else
{
nextAttribute = strtok(path, "]");
bool isFirst = true;
char *fragPath = NULL;
while ((fragPath = strtok(NULL, "]")) != NULL) {
PRINTF("Attribute: %s]\n", fragPath);
if (isFirst) {
sprintf(nextPath, "%s]", ++fragPath);
isFirst = false;
} else {
sprintf(nextPath, "%s/%s]", nextPath, ++fragPath);
}
PRINTF("Next Path: %s\n", nextPath);
}
if (strlen(nextPath) == 0) {
PRINTF("Attribute: NULL\n");
PRINTF("Next Path: NULL\n");
nextAttribute = NULL;
}
}
}
else
{
if ((nextAttribute = strtok(path, "\\")) != NULL) {
if ((nextAttribute = strtok(NULL, "\\")) != NULL) {
PRINTF("Attribute: %s\n", nextAttribute);
} else {
nextAttribute = strtok(path, "\\");
PRINTF("Attribute: %s\n", nextAttribute);
}
}
}
if(!strcmp("typeDefinitions", obj))
{
free(obj);
if(nextAttribute == NULL)
{
return pObj->typeDefinition;
}
else
{
return pObj->typeDefinition->FindByPath(nextPath, pObj->typeDefinition);
}
}
else if(!strcmp("dictionary", obj))
{
free(obj);
if(nextAttribute == NULL)
{
return pObj->dictionary;
}
else
{
return pObj->dictionary->FindByPath(nextPath, pObj->dictionary);
}
}
else if(!strcmp("fragmentDictionary", obj))
{
free(obj);
if(nextAttribute == NULL)
{
return pObj->FindFragmentDictionaryByID(pObj, key);
}
else
{
FragmentDictionary* value = pObj->FindFragmentDictionaryByID(pObj, key);
if(value != NULL)
return value->FindByPath(nextPath, value);
else
return NULL;
}
}
else
{
free(obj);
PRINTF("Wrong attribute or reference\n");
return NULL;
}
}
}