otsdaq  v1_01_02
 All Classes Namespaces Functions
XmlDocument.h
1 #ifndef ots_XmlDocument_h
2 #define ots_XmlDocument_h
3 
4 #include <xercesc/parsers/XercesDOMParser.hpp>
5 #include <xercesc/dom/DOMElement.hpp>
6 #include <vector>
7 #include <string>
8 
9 namespace ots
10 {
11 
13 {
14 public:
15 
16  XmlDocument(std::string rootName="ROOT");
17  XmlDocument(const XmlDocument& doc);
18  XmlDocument& operator=(const XmlDocument& doc);
19  ~XmlDocument(void);
20 
21  xercesc::DOMElement* addTextElementToParent (std::string childName, std::string childText, xercesc::DOMElement* parent);
22  xercesc::DOMElement* addTextElementToParent (std::string childName, std::string childText, std::string parentName, unsigned int parentIndex=0);
23 
24  void saveXmlDocument (std::string filePath);
25  void recursiveRemoveChild (xercesc::DOMElement *childEl,xercesc::DOMElement *parentEl); //remove entire element and sub tree, recursively
26 
27 
28  bool loadXmlDocument (std::string filePath);
29 
30  void outputXmlDocument (std::ostringstream *out, bool dispStdOut=false);
31 
32 protected:
33  void copyDocument (const xercesc::DOMDocument* toCopy, xercesc::DOMDocument* copy);
34  void recursiveElementCopy (const xercesc::DOMElement* toCopy, xercesc::DOMElement* copy);
35  void initDocument (void);
36  void initPlatform (void);
37  void terminatePlatform (void);
38  void recursiveOutputXmlDocument (xercesc::DOMElement *currEl, std::ostringstream *out, bool dispStdOut=false, std::string tabStr="");
39 
40 // unsigned int addElementToParent (std::string field, std::string value, xercesc::DOMElement *parentEl, bool verbose=false);
41 // void recursiveAddElementToParent (xercesc::DOMElement *currEl, xercesc::DOMElement *parentEl);
42 // std::string recursiveFindElement (xercesc::DOMElement *currEl, const std::string field, const unsigned int occurance, unsigned int &count);
43 // void recursiveFindAllElements (xercesc::DOMElement *currEl, const std::string field,std::vector<std::string> *retVec);
44  std::string escapeString (std::string inString, bool allowWhiteSpace=false);
45 
46  xercesc::DOMImplementation* theImplementation_;
47  xercesc::DOMDocument* theDocument_;
48  xercesc::DOMElement* rootElement_;
49 
50  const std::string rootTagName_;
51 };
52 
53 }
54 
55 #endif //ots_XmlDocument_h