ROOTANA
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 
19 static std::string toString(int i)
20 {
21  char buf[256];
22  sprintf(buf, "%d", i);
23  return buf;
24 }
25 
26 static 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
45 static 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
53 static 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
61 static 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
74 static 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
96 static 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 
121 template <typename T>
122 static T GetXmlValue(const char* text);
123 
124 template<>
125 int GetXmlValue<int>(const char* text)
126 {
127  return atoi(text);
128 }
129 
130 template<>
131 double GetXmlValue<double>(const char* text)
132 {
133  return atof(text);
134 }
135 
136 template<>
137 float GetXmlValue<float>(const char* text)
138 {
139  return atof(text);
140 }
141 
142 template<>
143 bool GetXmlValue<bool>(const char* text)
144 {
145  if (*text == 'n')
146  return false;
147  else
148  return true;
149 }
150 
151 template<>
152 uint16_t GetXmlValue<uint16_t>(const char* text)
153 {
154  return 0xFFFF & strtoul(text, NULL, 0);
155 }
156 
157 template<>
158 uint32_t GetXmlValue<uint32_t>(const char* text)
159 {
160  return strtoul(text, NULL, 0);
161 }
162 
163 template<>
164 std::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 
171 class XmlOdb : public MVOdb
172 {
173 public:
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 
179 public:
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 
202 public:
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 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)
360  {
361  // FIXME: not implemented
362  SetOk(error);
363  }
364 
365  void RB(const char* varname, bool *value, bool create, MVOdbError* error)
366  {
367  RBAI(varname, 0, value, error);
368  };
369 
370  void RI(const char* varname, int *value, bool create, MVOdbError* error)
371  {
372  RIAI(varname, 0, value, error);
373  };
374 
375  void RD(const char* varname, double *value, bool create, MVOdbError* error)
376  {
377  RDAI(varname, 0, value, error);
378  };
379 
380  void RF(const char* varname, float *value, bool create, MVOdbError* error)
381  {
382  RFAI(varname, 0, value, error);
383  };
384 
385  void RS(const char* varname, std::string *value, bool create, int create_string_length, MVOdbError* error)
386  {
387  RSAI(varname, 0, value, error);
388  };
389 
390  void RU16(const char* varname, uint16_t *value, bool create, MVOdbError* error)
391  {
392  RU16AI(varname, 0, value, error);
393  };
394 
395  void RU32(const char* varname, uint32_t *value, bool create, MVOdbError* error)
396  {
397  RU32AI(varname, 0, value, error);
398  };
399 
400  PMXML_NODE FindXmlNode(PMXML_NODE dir, const char* varname, const char* type1, const char* type2, MVOdbError* error)
401  {
402  PMXML_NODE node = FindPath(dir, varname);
403  if (!node) {
404  SetNotFound(error, varname);
405  return NULL;
406  }
407 
408  const char* attr_type = GetAttr(node, "type");
409 
410  if (!attr_type) {
411  fprintf(stderr, "XmlOdb::FindXmlNode: Error: no type attribute in varname \"%s\"!\n", varname);
412  SetNullValue(error, varname);
413  return NULL;
414  }
415 
416  if (strcmp(attr_type, type1) != 0) {
417  if (strcmp(attr_type, type2) != 0) {
418  fprintf(stderr, "XmlOdb::FindXmlNode: Error: type mismatch, wanted \"%s\" or \"%s\", got \"%s\"!\n", type1, type2, attr_type);
419  SetNullValue(error, varname);
420  return NULL;
421  }
422  }
423 
424  return node;
425  }
426 
427  template <typename T>
428  void RXA(const char* varname, const char* type1, const char* type2, std::vector<T> *value, MVOdbError* error)
429  {
430  if (!value) {
431  SetOk(error);
432  return;
433  }
434 
435  PMXML_NODE node = FindXmlNode(fDir, varname, type1, type2, error);
436  if (!node)
437  return;
438 
439  //DumpTree(node);
440 
441  if (strcmp(node->name, "keyarray") == 0) {
442  const char* num_values_text = GetAttr(node, "num_values");
443  if (!num_values_text) {
444  fprintf(stderr, "no num_values!\n");
445  SetNullValue(error, varname);
446  return;
447  }
448 
449  int num_values = atoi(num_values_text);
450 
451  if (num_values != node->n_children) {
452  fprintf(stderr, "num_values mismatch %d vs %d children!\n", num_values, node->n_children);
453  SetNullValue(error, varname);
454  return;
455  }
456 
457  value->clear();
458 
459  for (int i=0; i<node->n_children; i++) {
460  PMXML_NODE elem = node->child+i;
461  const char* text = elem->value;
462  if (!text) {
463  SetNullValue(error, varname);
464  return;
465  }
466  T v = GetXmlValue<T>(text);
467  value->push_back(v);
468  }
469 
470  SetOk(error);
471  return;
472  } else if (strcmp(node->name, "key") == 0) {
473  const char* text = node->value;
474  if (!text) {
475  SetNullValue(error, varname);
476  return;
477  }
478  value->clear();
479  T v = GetXmlValue<T>(text);
480  value->push_back(v);
481  SetOk(error);
482  return;
483  } else {
484  fprintf(stderr, "unexpected node %s\n", node->name);
485  SetNullValue(error, varname);
486  return;
487  }
488  };
489 
490  void RBA(const char* varname, std::vector<bool> *value, bool create, int create_size, MVOdbError* error)
491  {
492  RXA(varname, "BOOL", "BOOL", value, error);
493  }
494 
495  void RIA(const char* varname, std::vector<int> *value, bool create, int create_size, MVOdbError* error)
496  {
497  RXA(varname, "INT", "INT32", value, error);
498  }
499 
500  void RDA(const char* varname, std::vector<double> *value, bool create, int create_size, MVOdbError* error)
501  {
502  RXA(varname, "DOUBLE", "DOUBLE", value, error);
503  }
504 
505  void RFA(const char* varname, std::vector<float> *value, bool create, int create_size, MVOdbError* error)
506  {
507  RXA(varname, "FLOAT", "FLOAT", value, error);
508  }
509 
510  void RSA(const char* varname, std::vector<std::string> *value, bool create, int create_size, int create_string_length, MVOdbError* error)
511  {
512  RXA(varname, "STRING", "STIRNG", value, error);
513  }
514 
515  void RU16A(const char* varname, std::vector<uint16_t> *value, bool create, int create_size, MVOdbError* error)
516  {
517  RXA(varname, "WORD", "UINT16", value, error);
518  }
519 
520  void RU32A(const char* varname, std::vector<uint32_t> *value, bool create, int create_size, MVOdbError* error)
521  {
522  RXA(varname, "DWORD", "UINT32", value, error);
523  }
524 
525  template <typename T>
526  void RXAI(const char* varname, int index, const char* type1, const char* type2, T* value, MVOdbError* error)
527  {
528  if (!value) {
529  SetOk(error);
530  return;
531  }
532 
533  PMXML_NODE node = FindXmlNode(fDir, varname, type1, type2, error);
534  if (!node)
535  return;
536 
537  //DumpTree(node);
538 
539  if (strcmp(node->name, "keyarray") == 0) {
540  const char* num_values_text = GetAttr(node, "num_values");
541  if (!num_values_text) {
542  fprintf(stderr, "no num_values!\n");
543  SetNullValue(error, varname);
544  return;
545  }
546 
547  int num_values = atoi(num_values_text);
548 
549  if (num_values != node->n_children) {
550  fprintf(stderr, "num_values mismatch %d vs %d children!\n", num_values, node->n_children);
551  SetNullValue(error, varname);
552  return;
553  }
554 
555  if (index < 0) {
556  fprintf(stderr, "bad index %d, num_values %d!\n", index, num_values);
557  SetNullValue(error, varname);
558  return;
559  }
560 
561  if (index >= num_values) {
562  fprintf(stderr, "bad index %d, num_values %d!\n", index, num_values);
563  SetNullValue(error, varname);
564  return;
565  }
566 
567  PMXML_NODE elem = node->child+index;
568  const char* text = elem->value;
569  if (!text) {
570  SetNullValue(error, varname);
571  return;
572  }
573 
574  *value = GetXmlValue<T>(text);
575 
576  SetOk(error);
577  return;
578  } else if (strcmp(node->name, "key") == 0) {
579 
580  if (index != 0) {
581  fprintf(stderr, "non-zero index %d for non-array!\n", index);
582  SetNullValue(error, varname);
583  return;
584  }
585 
586  const char* text = node->value;
587  if (!text) {
588  SetNullValue(error, varname);
589  return;
590  }
591 
592  *value = GetXmlValue<T>(text);
593 
594  SetOk(error);
595  return;
596  } else {
597  fprintf(stderr, "unexpected node %s\n", node->name);
598  SetNullValue(error, varname);
599  return;
600  }
601  }
602 
603  void RBAI(const char* varname, int index, bool *value, MVOdbError* error)
604  {
605  RXAI(varname, index, "BOOL", "BOOL", value, error);
606  }
607 
608  void RIAI(const char* varname, int index, int *value, MVOdbError* error)
609  {
610  RXAI(varname, index, "INT", "INT32", value, error);
611  }
612 
613  void RDAI(const char* varname, int index, double *value, MVOdbError* error)
614  {
615  RXAI(varname, index, "DOUBLE", "DOUBLE", value, error);
616  }
617 
618  void RFAI(const char* varname, int index, float *value, MVOdbError* error)
619  {
620  RXAI(varname, index, "FLOAT", "FLOAT", value, error);
621  }
622 
623  void RSAI(const char* varname, int index, std::string *value, MVOdbError* error)
624  {
625  RXAI(varname, index, "STRING", "STRING", value, error);
626  }
627 
628  void RU16AI(const char* varname, int index, uint16_t *value, MVOdbError* error)
629  {
630  RXAI(varname, index, "WORD", "UINT16", value, error);
631  }
632 
633  void RU32AI(const char* varname, int index, uint32_t *value, MVOdbError* error)
634  {
635  RXAI(varname, index, "DWORD", "UINT32", value, error);
636  }
637 
638  // write functions do nothing
639 
640  void WB(const char* varname, bool v, MVOdbError* error) { SetOk(error); };
641  void WI(const char* varname, int v, MVOdbError* error) { SetOk(error); };
642  void WD(const char* varname, double v, MVOdbError* error) { SetOk(error); };
643  void WF(const char* varname, float v, MVOdbError* error) { SetOk(error); };
644  void WS(const char* varname, const char* v, int string_length, MVOdbError* error) { SetOk(error); };
645  void WU16(const char* varname, uint16_t v, MVOdbError* error) { SetOk(error); };
646  void WU32(const char* varname, uint32_t v, MVOdbError* error) { SetOk(error); };
647 
648  void WBA(const char* varname, const std::vector<bool>& v, MVOdbError* error) { SetOk(error); };
649  void WIA(const char* varname, const std::vector<int>& v, MVOdbError* error) { SetOk(error); };
650  void WDA(const char* varname, const std::vector<double>& v, MVOdbError* error) { SetOk(error); };
651  void WFA(const char* varname, const std::vector<float>& v, MVOdbError* error) { SetOk(error); };
652  void WSA(const char* varname, const std::vector<std::string>& data, int odb_string_length, MVOdbError* error) { SetOk(error); };
653  void WU16A(const char* varname, const std::vector<uint16_t>& v, MVOdbError* error) { SetOk(error); };
654  void WU32A(const char* varname, const std::vector<uint32_t>& v, MVOdbError* error) { SetOk(error); };
655 
656  void WBAI(const char* varname, int index, bool v, MVOdbError* error) { SetOk(error); };
657  void WIAI(const char* varname, int index, int v, MVOdbError* error) { SetOk(error); };
658  void WDAI(const char* varname, int index, double v, MVOdbError* error) { SetOk(error); };
659  void WFAI(const char* varname, int index, float v, MVOdbError* error) { SetOk(error); };
660  void WSAI(const char* varname, int index, const char* v, MVOdbError* error) { SetOk(error); };
661  void WU16AI(const char* varname, int index, uint16_t v, MVOdbError* error) { SetOk(error); };
662  void WU32AI(const char* varname, int index, uint32_t v, MVOdbError* error) { SetOk(error); };
663 
664  // delete function does nothing
665 
666  void Delete(const char* odbname, MVOdbError* error) { SetOk(error); };
667 };
668 
669 #if 0
670 int XmlOdb::odbReadArraySize(const char*name)
671 {
672  PMXML_NODE node = FindPath(NULL, name);
673  if (!node)
674  return 0;
675  const char* num_values = GetAttr(node, "num_values");
676  if (!num_values)
677  return 1;
678  return atoi(num_values);
679 }
680 #endif
681 
682 MVOdb* MakeXmlFileOdb(const char* filename, MVOdbError* error)
683 {
684  char err[256];
685  int err_line = 0;
686  PMXML_NODE node = mxml_parse_file(filename, err, sizeof(err), &err_line);
687  if (!node) {
688  std::string msg;
689  msg += "mxml_parse_file() error ";
690  msg += "\"";
691  msg += err;
692  msg += "\"";
693  msg += " file ";
694  msg += filename;
695  msg += " line ";
696  msg += toString(err_line);
697  SetError(error, true, filename, msg);
698  return MakeNullOdb();
699  }
700 
701  PMXML_NODE odb_node = FindNode(node, "odb");
702 
703  if (!odb_node) {
704  std::string msg;
705  msg += "invalid XML tree: no ODB tag";
706  SetError(error, true, filename, msg);
707  return MakeNullOdb();
708  }
709 
710  return new XmlOdb(node, odb_node, error);
711 }
712 
713 MVOdb* MakeXmlBufferOdb(const char* buf, int bufsize, MVOdbError* error)
714 {
715 #if 0
716  // note: this code was in the old XmlOdb.cxx file
717  // probably needed to clean up strange characters
718  // that upset the ROOT/libxml XML parser. Stefan's mxml
719  // XML parser probably does not need it, but if we see
720  // reports of XML parser failure where the old XmlOdb
721  // used to work, then we should put this code back. K.O.
722 
723  char*buf = (char*)malloc(bufLength);
724  memcpy(buf, xbuf, bufLength);
725  for (int i=0; i<bufLength; i++)
726  if (!isascii(buf[i])) {
727  buf[i] = 'X';
728  } else if (buf[i]=='\n') {
729  } else if (buf[i]=='\r') {
730  } else if (!isprint(buf[i])) {
731  buf[i] = 'X';
732  } else if (buf[i] == 0x1D) {
733  buf[i] = 'X';
734  }
735 
736  char* xend = strstr(buf,"odb>");
737  if (xend)
738  xend[4] = 0;
739 #endif
740 
741  char err[256];
742  int err_line = 0;
743  PMXML_NODE node = mxml_parse_buffer(buf, err, sizeof(err), &err_line);
744  if (!node) {
745  std::string msg;
746  msg += "mxml_parse_buffer() error ";
747  msg += "\"";
748  msg += err;
749  msg += "\"";
750  msg += " line ";
751  msg += toString(err_line);
752  SetError(error, true, "buffer", msg);
753  return MakeNullOdb();
754  }
755 
756  PMXML_NODE odb_node = FindNode(node, "odb");
757 
758  if (!odb_node) {
759  std::string msg;
760  msg += "invalid XML tree: no ODB tag";
761  SetError(error, true, "buffer", msg);
762  return MakeNullOdb();
763  }
764 
765  return new XmlOdb(node, odb_node, error);
766 }
767 
768 /* emacs
769  * Local Variables:
770  * tab-width: 8
771  * c-basic-offset: 3
772  * indent-tabs-mode: nil
773  * End:
774  */
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:652
void RU32A(const char *varname, std::vector< uint32_t > *value, bool create, int create_size, MVOdbError *error)
Definition: mxmlodb.cxx:520
void WDA(const char *varname, const std::vector< double > &v, MVOdbError *error)
Definition: mxmlodb.cxx:650
void WSAI(const char *varname, int index, const char *v, MVOdbError *error)
Definition: mxmlodb.cxx:660
void Delete(const char *odbname, MVOdbError *error)
Definition: mxmlodb.cxx:666
void WU16(const char *varname, uint16_t v, MVOdbError *error)
Definition: mxmlodb.cxx:645
void RU16(const char *varname, uint16_t *value, bool create, MVOdbError *error)
Definition: mxmlodb.cxx:390
void WI(const char *varname, int v, MVOdbError *error)
Definition: mxmlodb.cxx:641
void RXA(const char *varname, const char *type1, const char *type2, std::vector< T > *value, MVOdbError *error)
Definition: mxmlodb.cxx:428
void RU16A(const char *varname, std::vector< uint16_t > *value, bool create, int create_size, MVOdbError *error)
Definition: mxmlodb.cxx:515
void WU16A(const char *varname, const std::vector< uint16_t > &v, MVOdbError *error)
Definition: mxmlodb.cxx:653
void RU32AI(const char *varname, int index, uint32_t *value, MVOdbError *error)
Definition: mxmlodb.cxx:633
std::string fPath
Definition: mxmlodb.cxx:176
bool IsReadOnly() const
Definition: mxmlodb.cxx:242
void WB(const char *varname, bool v, MVOdbError *error)
Definition: mxmlodb.cxx:640
void RIAI(const char *varname, int index, int *value, MVOdbError *error)
Definition: mxmlodb.cxx:608
PMXML_NODE fDir
Definition: mxmlodb.cxx:175
void WF(const char *varname, float v, MVOdbError *error)
Definition: mxmlodb.cxx:643
void WBAI(const char *varname, int index, bool v, MVOdbError *error)
Definition: mxmlodb.cxx:656
void WFA(const char *varname, const std::vector< float > &v, MVOdbError *error)
Definition: mxmlodb.cxx:651
void WIAI(const char *varname, int index, int v, MVOdbError *error)
Definition: mxmlodb.cxx:657
void WIA(const char *varname, const std::vector< int > &v, MVOdbError *error)
Definition: mxmlodb.cxx:649
void RFAI(const char *varname, int index, float *value, MVOdbError *error)
Definition: mxmlodb.cxx:618
PMXML_NODE fRoot
Definition: mxmlodb.cxx:174
void WU32A(const char *varname, const std::vector< uint32_t > &v, MVOdbError *error)
Definition: mxmlodb.cxx:654
void RS(const char *varname, std::string *value, bool create, int create_string_length, MVOdbError *error)
Definition: mxmlodb.cxx:385
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:505
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:500
void WDAI(const char *varname, int index, double v, MVOdbError *error)
Definition: mxmlodb.cxx:658
void SetPrintError(bool v)
Definition: mxmlodb.cxx:203
void WU32(const char *varname, uint32_t v, MVOdbError *error)
Definition: mxmlodb.cxx:646
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:662
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:370
void RB(const char *varname, bool *value, bool create, MVOdbError *error)
Definition: mxmlodb.cxx:365
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:359
void RIA(const char *varname, std::vector< int > *value, bool create, int create_size, MVOdbError *error)
Definition: mxmlodb.cxx:495
void RXAI(const char *varname, int index, const char *type1, const char *type2, T *value, MVOdbError *error)
Definition: mxmlodb.cxx:526
void RDAI(const char *varname, int index, double *value, MVOdbError *error)
Definition: mxmlodb.cxx:613
PMXML_NODE FindXmlNode(PMXML_NODE dir, const char *varname, const char *type1, const char *type2, MVOdbError *error)
Definition: mxmlodb.cxx:400
void RU16AI(const char *varname, int index, uint16_t *value, MVOdbError *error)
Definition: mxmlodb.cxx:628
void RF(const char *varname, float *value, bool create, MVOdbError *error)
Definition: mxmlodb.cxx:380
void RBA(const char *varname, std::vector< bool > *value, bool create, int create_size, MVOdbError *error)
Definition: mxmlodb.cxx:490
void RSA(const char *varname, std::vector< std::string > *value, bool create, int create_size, int create_string_length, MVOdbError *error)
Definition: mxmlodb.cxx:510
void WBA(const char *varname, const std::vector< bool > &v, MVOdbError *error)
Definition: mxmlodb.cxx:648
void WFAI(const char *varname, int index, float v, MVOdbError *error)
Definition: mxmlodb.cxx:659
void RD(const char *varname, double *value, bool create, MVOdbError *error)
Definition: mxmlodb.cxx:375
void RBAI(const char *varname, int index, bool *value, MVOdbError *error)
Definition: mxmlodb.cxx:603
~XmlOdb()
Definition: mxmlodb.cxx:193
void RU32(const char *varname, uint32_t *value, bool create, MVOdbError *error)
Definition: mxmlodb.cxx:395
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:642
void RSAI(const char *varname, int index, std::string *value, MVOdbError *error)
Definition: mxmlodb.cxx:623
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:644
void WU16AI(const char *varname, int index, uint16_t v, MVOdbError *error)
Definition: mxmlodb.cxx:661
MVOdb * Chdir(const char *subdir, bool create, MVOdbError *error)
Definition: mxmlodb.cxx:310
MVOdb * MakeNullOdb()
Definition: nullodb.cxx:123
void SetError(MVOdbError *error, bool print, const std::string &path, const std::string &message)
Definition: mvodb.cxx:70
void SetOk(MVOdbError *error)
Definition: mvodb.cxx:31
void mxml_free_tree(PMXML_NODE tree)
Definition: mxml.cxx:2273
PMXML_NODE mxml_parse_file(const char *file_name, char *error, int error_size, int *error_line)
Definition: mxml.cxx:2073
#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:1357
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
static const char * GetAttr(PMXML_NODE node, const char *attrName)
Return the value of the named attribute.
Definition: mxmlodb.cxx:61
uint16_t GetXmlValue< uint16_t >(const char *text)
Definition: mxmlodb.cxx:152
static T GetXmlValue(const char *text)
static const char * GetAttrName(PMXML_NODE node, int i)
Return the name of the indexed attribute.
Definition: mxmlodb.cxx:45
bool GetXmlValue< bool >(const char *text)
Definition: mxmlodb.cxx:143
double GetXmlValue< double >(const char *text)
Definition: mxmlodb.cxx:131
MVOdb * MakeXmlFileOdb(const char *filename, MVOdbError *error)
Definition: mxmlodb.cxx:682
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 * GetAttrValue(PMXML_NODE node, int i)
Return the value of the indexed attribute.
Definition: mxmlodb.cxx:53
MVOdb * MakeXmlBufferOdb(const char *buf, int bufsize, MVOdbError *error)
Definition: mxmlodb.cxx:713
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