Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / Config / Config_XMLReader.h
1 /*
2  * Config_XMLReader.h
3  *
4  *  Created on: Mar 14, 2014
5  *      Author: sbh
6  */
7
8 #ifndef CONFIG_XMLREADER_H_
9 #define CONFIG_XMLREADER_H_
10
11 #include <Config.h>
12
13 #include <cstdarg>
14 #include <string>
15
16 //>> Forward declaration of xmlNodePtr.
17 typedef struct _xmlNode xmlNode;
18 typedef xmlNode *xmlNodePtr;
19 struct _xmlNode;
20 //<<
21
22 //>> Forward declaration of xmlDocPtr.
23 typedef struct _xmlDoc xmlDoc;
24 typedef xmlDoc *xmlDocPtr;
25 struct _xmlDoc;
26 //<<
27
28 /*
29  * Base class for all libxml readers. Provides high-level API
30  * for all xml operations.
31  *
32  */
33 class CONFIG_EXPORT Config_XMLReader
34 {
35 public:
36   Config_XMLReader(const std::string& theXmlFile);
37   virtual ~Config_XMLReader();
38
39   void readAll();
40
41 protected:
42   virtual void processNode(xmlNodePtr aNode);
43   virtual bool processChildren(xmlNodePtr aNode);
44
45   xmlNodePtr findRoot();
46   void readRecursively(xmlNodePtr theParent);
47
48   xmlNodePtr node(void* theNode);
49   std::string getProperty(xmlNodePtr theNode, const char* property);
50   /*
51    * Please note that this function should be called with NULL last argument. 
52    * In example: isNode(aNode, "type1", ["type2", ...], NULL);
53    * ", NULL" is required to use unlimited number of arguments.
54    * TODO(sbh): find a way to simplify calling this method.
55    */
56   bool isNode(xmlNodePtr theNode, const char* name, ...);
57
58 protected:
59   std::string myDocumentPath;
60   xmlDocPtr   myXmlDoc;
61 };
62
63 #endif /* CONFIG_XMLREADER_H_ */