ROOTANA
Loading...
Searching...
No Matches
mxmlodb.cxx
Go to the documentation of this file.
1//
2// ALPHA ROOT analyzer
3//
4// Access to ODB stored in XML odb save file or ODB XML dump in MIDAS data file.
5//
6// Name: mxmlodb.cxx
7// Author: K.Olchanski, 11-July-2006
8// Author: K.Olchanski, 16-May-2019
9//
10
11#undef NDEBUG // midas required assert() to be always enabled
12
13#include <stdio.h>
14#include <assert.h>
15#include <stdlib.h>
16#include <string.h> // memset()
17
18#include "mvodb.h"
19#include "mxml.h"
20
21static std::string toString(int i)
22{
23 char buf[256];
24 snprintf(buf, sizeof(buf), "%d", i);
25 return buf;
26}
27
28static PMXML_NODE FindNode(PMXML_NODE dir, const char* name)
29{
30 for (int i=0; i<dir->n_children; i++) {
31 PMXML_NODE node = dir->child + i;
32 //printf("node name: \"%s\"\n",node->GetNodeName());
33 if (strcmp(node->name, name) == 0)
34 return node;
35
36 if (node->n_children > 0) {
37 PMXML_NODE found = FindNode(node, name);
38 if (found)
39 return found;
40 }
41 }
42
43 return NULL;
44}
45
46/// Return the name of the indexed attribute
47static const char* GetAttrName(PMXML_NODE node, int i)
48{
49 assert(i>=0);
50 assert(i<node->n_attributes);
51 return node->attribute_name + i*MXML_NAME_LENGTH;
52}
53
54/// Return the value of the indexed attribute
55static const char* GetAttrValue(PMXML_NODE node, int i)
56{
57 assert(i>=0);
58 assert(i<node->n_attributes);
59 return node->attribute_value[i];
60}
61
62/// Return the value of the named attribute
63static const char* GetAttr(PMXML_NODE node, const char* attrName)
64{
65 for (int i=0; i<node->n_attributes; i++) {
66 //printf("attribute name: \"%s\", value: \"%s\"\n",attr->GetName(),attr->GetValue());
67
68 if (strcmp(GetAttrName(node, i), attrName) == 0)
69 return GetAttrValue(node, i);
70 }
71 return NULL;
72}
73
74#if 0
75/// Print out the contents of the ODB tree
76static void DumpTree(PMXML_NODE node, int level = 0)
77{
78 assert(node);
79
80 for (int k=0; k<level; k++)
81 printf(" ");
82 printf("node name: \"%s\"\n", node->name);
83 for (int i=0; i<node->n_attributes; i++) {
84 for (int k=0; k<level; k++)
85 printf(" ");
86 printf("attribute name: \"%s\", value: \"%s\"\n", GetAttrName(node, i), GetAttrValue(node, i));
87 }
88 if (node->value) {
89 for (int k=0; k<level; k++)
90 printf(" ");
91 printf("node text: \"%s\"\n", node->value);
92 }
93 for (int i=0; i<node->n_children; i++)
94 DumpTree(node->child + i, level + 1);
95}
96
97/// Print out the directory structure of the ODB tree
98static void DumpDirTree(PMXML_NODE node, int level = 0)
99{
100 assert(node);
101
102 const char* name = node->name;
103
104 if (strcmp(name,"dir") != 0)
105 return;
106
107 for (int k=0; k<level; k++)
108 printf(" ");
109 printf("node name: \"%s\"\n", node->name);
110
111 for (int i=0; i<node->n_attributes; i++) {
112 for (int k=0; k<level; k++)
113 printf(" ");
114 printf("attribute name: \"%s\", value: \"%s\"\n", GetAttrName(node, i), GetAttrValue(node, i));
115 }
116
117 for (int i=0; i<node->n_children; i++) {
118 DumpDirTree(node->child + i, level + 1);
119 }
120}
121#endif
122
123template <typename T>
124static T GetXmlValue(const char* text);
125
126template<>
127int GetXmlValue<int>(const char* text)
128{
129 return atoi(text);
130}
131
132template<>
133double GetXmlValue<double>(const char* text)
134{
135 return atof(text);
136}
137
138template<>
139float GetXmlValue<float>(const char* text)
140{
141 return atof(text);
142}
143
144template<>
145bool GetXmlValue<bool>(const char* text)
146{
147 if (*text == 'n')
148 return false;
149 else
150 return true;
151}
152
153template<>
154uint16_t GetXmlValue<uint16_t>(const char* text)
155{
156 return 0xFFFF & strtoul(text, NULL, 0);
157}
158
159template<>
160uint32_t GetXmlValue<uint32_t>(const char* text)
161{
162 return strtoul(text, NULL, 0);
163}
164
165template<>
166uint64_t GetXmlValue<uint64_t>(const char* text)
167{
168 if (sizeof(uint64_t) == sizeof(long))
169 return strtoul(text, NULL, 0);
170 else if (sizeof(uint64_t) == sizeof(long long))
171 return strtoull(text, NULL, 0);
172 else
173 abort();
174}
175
176template<>
177std::string GetXmlValue<std::string>(const char* text)
178{
179 return text;
180}
181
182/// Access to ODB saved in XML format inside midas .mid files
183
184class XmlOdb : public MVOdb
185{
186public:
187 PMXML_NODE fRoot; // root of XML document
188 PMXML_NODE fDir; // current ODB directory
189 std::string fPath; // path to correct ODB directory
191
192public:
193 XmlOdb(PMXML_NODE root, PMXML_NODE dir, MVOdbError* error) // ctor
194 {
195 fPrintError = false;
196 fRoot = root;
197 fDir = dir;
198 fPath = "";
199
200 //DumpTree(fRoot);
201 //DumpTree(fDir);
202
203 SetOk(error);
204 }
205
206 ~XmlOdb() // dtor
207 {
208 if (fRoot) {
210 fRoot = NULL;
211 }
212 fDir = NULL;
213 }
214
215public:
216 void SetPrintError(bool v)
217 {
218 fPrintError = true;
219 }
220
221 bool GetPrintError() const
222 {
223 return fPrintError;
224 }
225
226 void SetNotFound(MVOdbError* error, const char* varname)
227 {
228 std::string path;
229 path += fPath;
230 path += "/";
231 path += varname;
232 std::string msg;
233 msg += "Cannot find ";
234 msg += "\"";
235 msg += path;
236 msg += "\"";
237 SetError(error, fPrintError, path, msg);
238 }
239
240 void SetNullValue(MVOdbError* error, const char* varname)
241 {
242 std::string path;
243 path += fPath;
244 path += "/";
245 path += varname;
246 std::string msg;
247 msg += "XML node for ";
248 msg += "\"";
249 msg += path;
250 msg += "\"";
251 msg += " is NULL";
252 SetError(error, fPrintError, path, msg);
253 }
254
255 bool IsReadOnly() const
256 {
257 return true;
258 }
259
260 /// Follow the ODB path through the XML DOM tree
261 static PMXML_NODE FindPath(PMXML_NODE dir, const char* path)
262 {
263 assert(dir);
264
265 while (1) {
266 // skip leading slashes
267 while (*path == '/')
268 path++;
269
270 if (*path == 0)
271 return dir;
272
273 std::string elem;
274
275 // copy the next path element into "elem"-
276 // copy "path" until we hit "/" or end of string
277 while (1) {
278 if (*path==0 || *path=='/')
279 break;
280 elem += *path++;
281 }
282
283 //printf("looking for \"%s\" more \"%s\"\n", elem.c_str(), path);
284
285 PMXML_NODE found = NULL;
286
287 for (int i=0; i<dir->n_children; i++) {
288 PMXML_NODE node = dir->child + i;
289
290 const char* nodename = node->name;
291 const char* namevalue = GetAttr(node, "name");
292
293 //printf("node name: \"%s\", \"name\" value: \"%s\"\n", node->name, namevalue);
294
295 bool isDir = strcmp(nodename, "dir") == 0;
296 bool isKey = strcmp(nodename, "key") == 0;
297 bool isKeyArray = strcmp(nodename, "keyarray") == 0;
298
299 if (!isKey && !isDir && !isKeyArray)
300 continue;
301
302 //
303 // compare directory names
304 //
305
306 if (strcasecmp(elem.c_str(), namevalue) == 0) {
307 if (isDir) {
308 // found the right subdirectory, descend into it
309 found = node;
310 break;
311 } else if (isKey || isKeyArray) {
312 return node;
313 }
314 }
315 }
316
317 if (!found)
318 return NULL;
319 dir = found;
320 }
321 }
322
323 MVOdb* Chdir(const char* subdir, bool create, MVOdbError* error)
324 {
325 PMXML_NODE node = FindPath(fDir, subdir);
326 if (!node) {
327 SetNotFound(error, subdir);
328 if (create) {
329 return MakeNullOdb();
330 } else {
331 return NULL;
332 }
333 }
334
335 if (strcmp(node->name, "dir") != 0) {
336 std::string msg;
337 msg += "\"";
338 msg += subdir;
339 msg += "\"";
340 msg += " XML node is ";
341 msg += "\"";
342 msg += node->name;
343 msg += "\"";
344 msg += " instead of \"dir\"";
345 SetError(error, fPrintError, fPath, msg);
346 if (create)
347 return MakeNullOdb();
348 else
349 return NULL;
350 }
351
352 //printf("Found subdir [%s]\n", subdir);
353 //DumpTree(node);
354
355 XmlOdb* x = new XmlOdb(NULL, node, error);
356 x->fPath = fPath + "/" + subdir;
357
358 SetOk(error);
359 return x;
360 }
361
362 void ReadKey(const char* varname, int *tid, int *num_values, int *total_size, int *item_size, MVOdbError* error)
363 {
364 if (tid) *tid = 0;
365 if (num_values) *num_values = 0;
366 if (total_size) *total_size = 0;
367 if (item_size) *item_size = 0;
368 // FIXME: not implemented
369 SetOk(error);
370 }
371
372 void ReadKeyLastWritten(const char* varname, int *last_written, MVOdbError* error)
373 {
374 if (last_written) *last_written = 0;
375 // FIXME: not implemented
376 SetOk(error);
377 }
378
379 void ReadDir(std::vector<std::string>* varname, std::vector<int> *tid, std::vector<int> *num_values, std::vector<int> *total_size, std::vector<int> *item_size, MVOdbError* error)
380 {
381 // FIXME: not implemented
382 SetOk(error);
383 }
384
385 void RB(const char* varname, bool *value, bool create, MVOdbError* error)
386 {
387 RBAI(varname, 0, value, error);
388 };
389
390 void RI(const char* varname, int *value, bool create, MVOdbError* error)
391 {
392 RIAI(varname, 0, value, error);
393 };
394
395 void RD(const char* varname, double *value, bool create, MVOdbError* error)
396 {
397 RDAI(varname, 0, value, error);
398 };
399
400 void RF(const char* varname, float *value, bool create, MVOdbError* error)
401 {
402 RFAI(varname, 0, value, error);
403 };
404
405 void RS(const char* varname, std::string *value, bool create, int create_string_length, MVOdbError* error)
406 {
407 RSAI(varname, 0, value, error);
408 };
409
410 void RU16(const char* varname, uint16_t *value, bool create, MVOdbError* error)
411 {
412 RU16AI(varname, 0, value, error);
413 };
414
415 void RU32(const char* varname, uint32_t *value, bool create, MVOdbError* error)
416 {
417 RU32AI(varname, 0, value, error);
418 };
419
420 void RU64(const char* varname, uint64_t *value, bool create, MVOdbError* error)
421 {
422 RU64AI(varname, 0, value, error);
423 };
424
425 PMXML_NODE FindXmlNode(PMXML_NODE dir, const char* varname, const char* type1, const char* type2, MVOdbError* error)
426 {
427 PMXML_NODE node = FindPath(dir, varname);
428 if (!node) {
429 SetNotFound(error, varname);
430 return NULL;
431 }
432
433 const char* attr_type = GetAttr(node, "type");
434
435 if (!attr_type) {
436 fprintf(stderr, "XmlOdb::FindXmlNode: Error: no type attribute in varname \"%s\"!\n", varname);
437 SetNullValue(error, varname);
438 return NULL;
439 }
440
441 if (strcmp(attr_type, type1) != 0) {
442 if (strcmp(attr_type, type2) != 0) {
443 fprintf(stderr, "XmlOdb::FindXmlNode: Error: type mismatch, wanted \"%s\" or \"%s\", got \"%s\"!\n", type1, type2, attr_type);
444 SetNullValue(error, varname);
445 return NULL;
446 }
447 }
448
449 return node;
450 }
451
452 template <typename T>
453 void RXA(const char* varname, const char* type1, const char* type2, std::vector<T> *value, MVOdbError* error)
454 {
455 if (!value) {
456 SetOk(error);
457 return;
458 }
459
460 PMXML_NODE node = FindXmlNode(fDir, varname, type1, type2, error);
461 if (!node)
462 return;
463
464 //DumpTree(node);
465
466 if (strcmp(node->name, "keyarray") == 0) {
467 const char* num_values_text = GetAttr(node, "num_values");
468 if (!num_values_text) {
469 fprintf(stderr, "no num_values!\n");
470 SetNullValue(error, varname);
471 return;
472 }
473
474 int num_values = atoi(num_values_text);
475
476 if (num_values != node->n_children) {
477 fprintf(stderr, "num_values mismatch %d vs %d children!\n", num_values, node->n_children);
478 SetNullValue(error, varname);
479 return;
480 }
481
482 value->clear();
483
484 for (int i=0; i<node->n_children; i++) {
485 PMXML_NODE elem = node->child+i;
486 const char* text = elem->value;
487 if (!text) {
488 SetNullValue(error, varname);
489 return;
490 }
491 T v = GetXmlValue<T>(text);
492 value->push_back(v);
493 }
494
495 SetOk(error);
496 return;
497 } else if (strcmp(node->name, "key") == 0) {
498 const char* text = node->value;
499 if (!text) {
500 SetNullValue(error, varname);
501 return;
502 }
503 value->clear();
504 T v = GetXmlValue<T>(text);
505 value->push_back(v);
506 SetOk(error);
507 return;
508 } else {
509 fprintf(stderr, "unexpected node %s\n", node->name);
510 SetNullValue(error, varname);
511 return;
512 }
513 };
514
515 void RBA(const char* varname, std::vector<bool> *value, bool create, int create_size, MVOdbError* error)
516 {
517 RXA(varname, "BOOL", "BOOL", value, error);
518 }
519
520 void RIA(const char* varname, std::vector<int> *value, bool create, int create_size, MVOdbError* error)
521 {
522 RXA(varname, "INT", "INT32", value, error);
523 }
524
525 void RDA(const char* varname, std::vector<double> *value, bool create, int create_size, MVOdbError* error)
526 {
527 RXA(varname, "DOUBLE", "DOUBLE", value, error);
528 }
529
530 void RFA(const char* varname, std::vector<float> *value, bool create, int create_size, MVOdbError* error)
531 {
532 RXA(varname, "FLOAT", "FLOAT", value, error);
533 }
534
535 void RSA(const char* varname, std::vector<std::string> *value, bool create, int create_size, int create_string_length, MVOdbError* error)
536 {
537 RXA(varname, "STRING", "STIRNG", value, error);
538 }
539
540 void RU16A(const char* varname, std::vector<uint16_t> *value, bool create, int create_size, MVOdbError* error)
541 {
542 RXA(varname, "WORD", "UINT16", value, error);
543 }
544
545 void RU32A(const char* varname, std::vector<uint32_t> *value, bool create, int create_size, MVOdbError* error)
546 {
547 RXA(varname, "DWORD", "UINT32", value, error);
548 }
549
550 void RU64A(const char* varname, std::vector<uint64_t> *value, bool create, int create_size, MVOdbError* error)
551 {
552 RXA(varname, "QWORD", "UINT64", value, error);
553 }
554
555 template <typename T>
556 void RXAI(const char* varname, int index, const char* type1, const char* type2, T* value, MVOdbError* error)
557 {
558 if (!value) {
559 SetOk(error);
560 return;
561 }
562
563 PMXML_NODE node = FindXmlNode(fDir, varname, type1, type2, error);
564 if (!node)
565 return;
566
567 //DumpTree(node);
568
569 if (strcmp(node->name, "keyarray") == 0) {
570 const char* num_values_text = GetAttr(node, "num_values");
571 if (!num_values_text) {
572 fprintf(stderr, "no num_values!\n");
573 SetNullValue(error, varname);
574 return;
575 }
576
577 int num_values = atoi(num_values_text);
578
579 if (num_values != node->n_children) {
580 fprintf(stderr, "num_values mismatch %d vs %d children!\n", num_values, node->n_children);
581 SetNullValue(error, varname);
582 return;
583 }
584
585 if (index < 0) {
586 fprintf(stderr, "bad index %d, num_values %d!\n", index, num_values);
587 SetNullValue(error, varname);
588 return;
589 }
590
591 if (index >= num_values) {
592 fprintf(stderr, "bad index %d, num_values %d!\n", index, num_values);
593 SetNullValue(error, varname);
594 return;
595 }
596
597 PMXML_NODE elem = node->child+index;
598 const char* text = elem->value;
599 if (!text) {
600 SetNullValue(error, varname);
601 return;
602 }
603
604 *value = GetXmlValue<T>(text);
605
606 SetOk(error);
607 return;
608 } else if (strcmp(node->name, "key") == 0) {
609
610 if (index != 0) {
611 fprintf(stderr, "non-zero index %d for non-array!\n", index);
612 SetNullValue(error, varname);
613 return;
614 }
615
616 const char* text = node->value;
617 if (!text) {
618 SetNullValue(error, varname);
619 return;
620 }
621
622 *value = GetXmlValue<T>(text);
623
624 SetOk(error);
625 return;
626 } else {
627 fprintf(stderr, "unexpected node %s\n", node->name);
628 SetNullValue(error, varname);
629 return;
630 }
631 }
632
633 void RBAI(const char* varname, int index, bool *value, MVOdbError* error)
634 {
635 RXAI(varname, index, "BOOL", "BOOL", value, error);
636 }
637
638 void RIAI(const char* varname, int index, int *value, MVOdbError* error)
639 {
640 RXAI(varname, index, "INT", "INT32", value, error);
641 }
642
643 void RDAI(const char* varname, int index, double *value, MVOdbError* error)
644 {
645 RXAI(varname, index, "DOUBLE", "DOUBLE", value, error);
646 }
647
648 void RFAI(const char* varname, int index, float *value, MVOdbError* error)
649 {
650 RXAI(varname, index, "FLOAT", "FLOAT", value, error);
651 }
652
653 void RSAI(const char* varname, int index, std::string *value, MVOdbError* error)
654 {
655 RXAI(varname, index, "STRING", "STRING", value, error);
656 }
657
658 void RU16AI(const char* varname, int index, uint16_t *value, MVOdbError* error)
659 {
660 RXAI(varname, index, "WORD", "UINT16", value, error);
661 }
662
663 void RU32AI(const char* varname, int index, uint32_t *value, MVOdbError* error)
664 {
665 RXAI(varname, index, "DWORD", "UINT32", value, error);
666 }
667
668 void RU64AI(const char* varname, int index, uint64_t *value, MVOdbError* error)
669 {
670 RXAI(varname, index, "QWORD", "UINT64", value, error);
671 }
672
673 // write functions do nothing
674
675 void WB(const char* varname, bool v, MVOdbError* error) { SetOk(error); };
676 void WI(const char* varname, int v, MVOdbError* error) { SetOk(error); };
677 void WD(const char* varname, double v, MVOdbError* error) { SetOk(error); };
678 void WF(const char* varname, float v, MVOdbError* error) { SetOk(error); };
679 void WS(const char* varname, const char* v, int string_length, MVOdbError* error) { SetOk(error); };
680 void WU16(const char* varname, uint16_t v, MVOdbError* error) { SetOk(error); };
681 void WU32(const char* varname, uint32_t v, MVOdbError* error) { SetOk(error); };
682 void WU64(const char* varname, uint64_t v, MVOdbError* error) { SetOk(error); };
683
684 void WBA(const char* varname, const std::vector<bool>& v, MVOdbError* error) { SetOk(error); };
685 void WIA(const char* varname, const std::vector<int>& v, MVOdbError* error) { SetOk(error); };
686 void WDA(const char* varname, const std::vector<double>& v, MVOdbError* error) { SetOk(error); };
687 void WFA(const char* varname, const std::vector<float>& v, MVOdbError* error) { SetOk(error); };
688 void WSA(const char* varname, const std::vector<std::string>& data, int odb_string_length, MVOdbError* error) { SetOk(error); };
689 void WU16A(const char* varname, const std::vector<uint16_t>& v, MVOdbError* error) { SetOk(error); };
690 void WU32A(const char* varname, const std::vector<uint32_t>& v, MVOdbError* error) { SetOk(error); };
691 void WU64A(const char* varname, const std::vector<uint64_t>& v, MVOdbError* error) { SetOk(error); };
692
693 void WBAI(const char* varname, int index, bool v, MVOdbError* error) { SetOk(error); };
694 void WIAI(const char* varname, int index, int v, MVOdbError* error) { SetOk(error); };
695 void WDAI(const char* varname, int index, double v, MVOdbError* error) { SetOk(error); };
696 void WFAI(const char* varname, int index, float v, MVOdbError* error) { SetOk(error); };
697 void WSAI(const char* varname, int index, const char* v, MVOdbError* error) { SetOk(error); };
698 void WU16AI(const char* varname, int index, uint16_t v, MVOdbError* error) { SetOk(error); };
699 void WU32AI(const char* varname, int index, uint32_t v, MVOdbError* error) { SetOk(error); };
700 void WU64AI(const char* varname, int index, uint64_t v, MVOdbError* error) { SetOk(error); };
701
702 // delete function does nothing
703
704 void Delete(const char* odbname, MVOdbError* error) { SetOk(error); };
705};
706
707#if 0
708int XmlOdb::odbReadArraySize(const char*name)
709{
710 PMXML_NODE node = FindPath(NULL, name);
711 if (!node)
712 return 0;
713 const char* num_values = GetAttr(node, "num_values");
714 if (!num_values)
715 return 1;
716 return atoi(num_values);
717}
718#endif
719
720MVOdb* MakeXmlFileOdb(const char* filename, MVOdbError* error)
721{
722 char err[256];
723 int err_line = 0;
724 PMXML_NODE node = mxml_parse_file(filename, err, sizeof(err), &err_line);
725 if (!node) {
726 std::string msg;
727 msg += "mxml_parse_file() error ";
728 msg += "\"";
729 msg += err;
730 msg += "\"";
731 msg += " file ";
732 msg += filename;
733 msg += " line ";
734 msg += toString(err_line);
735 SetError(error, true, filename, msg);
736 return MakeNullOdb();
737 }
738
739 PMXML_NODE odb_node = FindNode(node, "odb");
740
741 if (!odb_node) {
742 std::string msg;
743 msg += "invalid XML tree: no ODB tag";
744 SetError(error, true, filename, msg);
745 return MakeNullOdb();
746 }
747
748 return new XmlOdb(node, odb_node, error);
749}
750
751MVOdb* MakeXmlBufferOdb(const char* buf, int bufsize, MVOdbError* error)
752{
753#if 0
754 // note: this code was in the old XmlOdb.cxx file
755 // probably needed to clean up strange characters
756 // that upset the ROOT/libxml XML parser. Stefan's mxml
757 // XML parser probably does not need it, but if we see
758 // reports of XML parser failure where the old XmlOdb
759 // used to work, then we should put this code back. K.O.
760
761 char*buf = (char*)malloc(bufLength);
762 memcpy(buf, xbuf, bufLength);
763 for (int i=0; i<bufLength; i++)
764 if (!isascii(buf[i])) {
765 buf[i] = 'X';
766 } else if (buf[i]=='\n') {
767 } else if (buf[i]=='\r') {
768 } else if (!isprint(buf[i])) {
769 buf[i] = 'X';
770 } else if (buf[i] == 0x1D) {
771 buf[i] = 'X';
772 }
773
774 char* xend = strstr(buf,"odb>");
775 if (xend)
776 xend[4] = 0;
777#endif
778
779 char err[256];
780 int err_line = 0;
781 PMXML_NODE node = mxml_parse_buffer(buf, err, sizeof(err), &err_line);
782 if (!node) {
783 std::string msg;
784 msg += "mxml_parse_buffer() error ";
785 msg += "\"";
786 msg += err;
787 msg += "\"";
788 msg += " line ";
789 msg += toString(err_line);
790 SetError(error, true, "buffer", msg);
791 return MakeNullOdb();
792 }
793
794 PMXML_NODE odb_node = FindNode(node, "odb");
795
796 if (!odb_node) {
797 std::string msg;
798 msg += "invalid XML tree: no ODB tag";
799 SetError(error, true, "buffer", msg);
800 return MakeNullOdb();
801 }
802
803 return new XmlOdb(node, odb_node, error);
804}
805
806/* emacs
807 * Local Variables:
808 * tab-width: 8
809 * c-basic-offset: 3
810 * indent-tabs-mode: nil
811 * End:
812 */
Definition mvodb.h:21
Access to ODB saved in XML format inside midas .mid files.
Definition mxmlodb.cxx:185
void WSA(const char *varname, const std::vector< std::string > &data, int odb_string_length, MVOdbError *error)
Definition mxmlodb.cxx:688
void RU32A(const char *varname, std::vector< uint32_t > *value, bool create, int create_size, MVOdbError *error)
Definition mxmlodb.cxx:545
void WDA(const char *varname, const std::vector< double > &v, MVOdbError *error)
Definition mxmlodb.cxx:686
void WSAI(const char *varname, int index, const char *v, MVOdbError *error)
Definition mxmlodb.cxx:697
void Delete(const char *odbname, MVOdbError *error)
Definition mxmlodb.cxx:704
void WU16(const char *varname, uint16_t v, MVOdbError *error)
Definition mxmlodb.cxx:680
void RU16(const char *varname, uint16_t *value, bool create, MVOdbError *error)
Definition mxmlodb.cxx:410
void WI(const char *varname, int v, MVOdbError *error)
Definition mxmlodb.cxx:676
void RXA(const char *varname, const char *type1, const char *type2, std::vector< T > *value, MVOdbError *error)
Definition mxmlodb.cxx:453
void RU16A(const char *varname, std::vector< uint16_t > *value, bool create, int create_size, MVOdbError *error)
Definition mxmlodb.cxx:540
void WU16A(const char *varname, const std::vector< uint16_t > &v, MVOdbError *error)
Definition mxmlodb.cxx:689
void RU32AI(const char *varname, int index, uint32_t *value, MVOdbError *error)
Definition mxmlodb.cxx:663
std::string fPath
Definition mxmlodb.cxx:189
bool IsReadOnly() const
Definition mxmlodb.cxx:255
MVOdb * Chdir(const char *subdir, bool create, MVOdbError *error)
Definition mxmlodb.cxx:323
void WB(const char *varname, bool v, MVOdbError *error)
Definition mxmlodb.cxx:675
void RIAI(const char *varname, int index, int *value, MVOdbError *error)
Definition mxmlodb.cxx:638
PMXML_NODE fDir
Definition mxmlodb.cxx:188
void WF(const char *varname, float v, MVOdbError *error)
Definition mxmlodb.cxx:678
void WBAI(const char *varname, int index, bool v, MVOdbError *error)
Definition mxmlodb.cxx:693
void WFA(const char *varname, const std::vector< float > &v, MVOdbError *error)
Definition mxmlodb.cxx:687
void WIAI(const char *varname, int index, int v, MVOdbError *error)
Definition mxmlodb.cxx:694
void WIA(const char *varname, const std::vector< int > &v, MVOdbError *error)
Definition mxmlodb.cxx:685
void RFAI(const char *varname, int index, float *value, MVOdbError *error)
Definition mxmlodb.cxx:648
PMXML_NODE fRoot
Definition mxmlodb.cxx:187
void WU32A(const char *varname, const std::vector< uint32_t > &v, MVOdbError *error)
Definition mxmlodb.cxx:690
void RS(const char *varname, std::string *value, bool create, int create_string_length, MVOdbError *error)
Definition mxmlodb.cxx:405
void ReadKey(const char *varname, int *tid, int *num_values, int *total_size, int *item_size, MVOdbError *error)
Definition mxmlodb.cxx:362
void RFA(const char *varname, std::vector< float > *value, bool create, int create_size, MVOdbError *error)
Definition mxmlodb.cxx:530
void SetNotFound(MVOdbError *error, const char *varname)
Definition mxmlodb.cxx:226
void RDA(const char *varname, std::vector< double > *value, bool create, int create_size, MVOdbError *error)
Definition mxmlodb.cxx:525
void WDAI(const char *varname, int index, double v, MVOdbError *error)
Definition mxmlodb.cxx:695
void SetPrintError(bool v)
Definition mxmlodb.cxx:216
void RU64A(const char *varname, std::vector< uint64_t > *value, bool create, int create_size, MVOdbError *error)
Definition mxmlodb.cxx:550
void WU32(const char *varname, uint32_t v, MVOdbError *error)
Definition mxmlodb.cxx:681
void SetNullValue(MVOdbError *error, const char *varname)
Definition mxmlodb.cxx:240
void WU32AI(const char *varname, int index, uint32_t v, MVOdbError *error)
Definition mxmlodb.cxx:699
void ReadKeyLastWritten(const char *varname, int *last_written, MVOdbError *error)
Definition mxmlodb.cxx:372
XmlOdb(PMXML_NODE root, PMXML_NODE dir, MVOdbError *error)
Definition mxmlodb.cxx:193
void RI(const char *varname, int *value, bool create, MVOdbError *error)
Definition mxmlodb.cxx:390
void RB(const char *varname, bool *value, bool create, MVOdbError *error)
Definition mxmlodb.cxx:385
void ReadDir(std::vector< std::string > *varname, std::vector< int > *tid, std::vector< int > *num_values, std::vector< int > *total_size, std::vector< int > *item_size, MVOdbError *error)
Definition mxmlodb.cxx:379
void RIA(const char *varname, std::vector< int > *value, bool create, int create_size, MVOdbError *error)
Definition mxmlodb.cxx:520
void RXAI(const char *varname, int index, const char *type1, const char *type2, T *value, MVOdbError *error)
Definition mxmlodb.cxx:556
void WU64AI(const char *varname, int index, uint64_t v, MVOdbError *error)
Definition mxmlodb.cxx:700
void WU64(const char *varname, uint64_t v, MVOdbError *error)
Definition mxmlodb.cxx:682
void RDAI(const char *varname, int index, double *value, MVOdbError *error)
Definition mxmlodb.cxx:643
PMXML_NODE FindXmlNode(PMXML_NODE dir, const char *varname, const char *type1, const char *type2, MVOdbError *error)
Definition mxmlodb.cxx:425
void RU16AI(const char *varname, int index, uint16_t *value, MVOdbError *error)
Definition mxmlodb.cxx:658
void RF(const char *varname, float *value, bool create, MVOdbError *error)
Definition mxmlodb.cxx:400
void RBA(const char *varname, std::vector< bool > *value, bool create, int create_size, MVOdbError *error)
Definition mxmlodb.cxx:515
void RSA(const char *varname, std::vector< std::string > *value, bool create, int create_size, int create_string_length, MVOdbError *error)
Definition mxmlodb.cxx:535
void WBA(const char *varname, const std::vector< bool > &v, MVOdbError *error)
Definition mxmlodb.cxx:684
void WFAI(const char *varname, int index, float v, MVOdbError *error)
Definition mxmlodb.cxx:696
void RD(const char *varname, double *value, bool create, MVOdbError *error)
Definition mxmlodb.cxx:395
void RU64(const char *varname, uint64_t *value, bool create, MVOdbError *error)
Definition mxmlodb.cxx:420
void RBAI(const char *varname, int index, bool *value, MVOdbError *error)
Definition mxmlodb.cxx:633
~XmlOdb()
Definition mxmlodb.cxx:206
void RU32(const char *varname, uint32_t *value, bool create, MVOdbError *error)
Definition mxmlodb.cxx:415
static PMXML_NODE FindPath(PMXML_NODE dir, const char *path)
Follow the ODB path through the XML DOM tree.
Definition mxmlodb.cxx:261
void WD(const char *varname, double v, MVOdbError *error)
Definition mxmlodb.cxx:677
void RSAI(const char *varname, int index, std::string *value, MVOdbError *error)
Definition mxmlodb.cxx:653
void WU64A(const char *varname, const std::vector< uint64_t > &v, MVOdbError *error)
Definition mxmlodb.cxx:691
bool GetPrintError() const
Definition mxmlodb.cxx:221
void RU64AI(const char *varname, int index, uint64_t *value, MVOdbError *error)
Definition mxmlodb.cxx:668
bool fPrintError
Definition mxmlodb.cxx:190
void WS(const char *varname, const char *v, int string_length, MVOdbError *error)
Definition mxmlodb.cxx:679
void WU16AI(const char *varname, int index, uint16_t v, MVOdbError *error)
Definition mxmlodb.cxx:698
void SetError(MVOdbError *error, bool print, const std::string &path, const std::string &message)
Definition mvodb.cxx:72
MVOdb * MakeNullOdb()
Definition nullodb.cxx:137
void SetOk(MVOdbError *error)
Definition mvodb.cxx:33
void mxml_free_tree(PMXML_NODE tree)
Definition mxml.cxx:2305
PMXML_NODE mxml_parse_file(const char *file_name, char *error, int error_size, int *error_line)
Definition mxml.cxx:2070
#define MXML_NAME_LENGTH
Definition mxml.h:31
PMXML_NODE mxml_parse_buffer(const char *buffer, char *error, int error_size, int *error_line)
Definition mxml.cxx:1355
uint64_t GetXmlValue< uint64_t >(const char *text)
Definition mxmlodb.cxx:166
std::string GetXmlValue< std::string >(const char *text)
Definition mxmlodb.cxx:177
uint32_t GetXmlValue< uint32_t >(const char *text)
Definition mxmlodb.cxx:160
float GetXmlValue< float >(const char *text)
Definition mxmlodb.cxx:139
int GetXmlValue< int >(const char *text)
Definition mxmlodb.cxx:127
uint16_t GetXmlValue< uint16_t >(const char *text)
Definition mxmlodb.cxx:154
static T GetXmlValue(const char *text)
static const char * GetAttrValue(PMXML_NODE node, int i)
Return the value of the indexed attribute.
Definition mxmlodb.cxx:55
static const char * GetAttr(PMXML_NODE node, const char *attrName)
Return the value of the named attribute.
Definition mxmlodb.cxx:63
bool GetXmlValue< bool >(const char *text)
Definition mxmlodb.cxx:145
MVOdb * MakeXmlBufferOdb(const char *buf, int bufsize, MVOdbError *error)
Definition mxmlodb.cxx:751
double GetXmlValue< double >(const char *text)
Definition mxmlodb.cxx:133
static std::string toString(int i)
Definition mxmlodb.cxx:21
static PMXML_NODE FindNode(PMXML_NODE dir, const char *name)
Definition mxmlodb.cxx:28
static const char * GetAttrName(PMXML_NODE node, int i)
Return the name of the indexed attribute.
Definition mxmlodb.cxx:47
MVOdb * MakeXmlFileOdb(const char *filename, MVOdbError *error)
Definition mxmlodb.cxx:720
char * value
Definition mxml.h:68
int n_children
Definition mxml.h:75
char name[MXML_NAME_LENGTH]
Definition mxml.h:66
char * attribute_name
Definition mxml.h:70
char ** attribute_value
Definition mxml.h:71
int n_attributes
Definition mxml.h:69
PMXML_NODE child
Definition mxml.h:76