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