Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / Config / Config_XMLReader.h
index 25637fd496e9bad70cb16c8f36fd36fa963074ff..331de4b6b4383406639f112b18237a1796a04ccb 100644 (file)
@@ -8,34 +8,57 @@
 #ifndef CONFIG_XMLREADER_H_
 #define CONFIG_XMLREADER_H_
 
-#include "Config.h"
-#include "Config_Message.h"
+#include <Config.h>
 
+#include <cstdarg>
 #include <string>
-#include <map>
 
-class CONFIG_EXPORT Config_XMLReader {
+//>> Forward declaration of xmlNodePtr.
+typedef struct _xmlNode xmlNode;
+typedef xmlNode *xmlNodePtr;
+struct _xmlNode;
+//<<
+
+//>> Forward declaration of xmlDocPtr.
+typedef struct _xmlDoc xmlDoc;
+typedef xmlDoc *xmlDocPtr;
+struct _xmlDoc;
+//<<
+
+/*
+ * Base class for all libxml readers. Provides high-level API
+ * for all xml operations.
+ *
+ */
+class CONFIG_EXPORT Config_XMLReader
+{
 public:
   Config_XMLReader(const std::string& theXmlFile);
   virtual ~Config_XMLReader();
 
-  std::string documentPath() const;
-  void setDocumentPath(std::string documentName);
-
   void readAll();
 
 protected:
-  //! Performs the real import of the given xml file, return false if file is not found
-  //! or generates an algo error if file content is bad
-  //! \param theFile name of the imported XML file
-  //! \returns true if file exists and not corrupted
-  bool import();
-  bool importWorkbench(void*);
-  void fillFeature(void *theRoot, Config_FeatureMessage& outFeatureMessage);
-  std::string getProperty(void *theRoot, const char* name);
-
-private:
-  std::string m_DocumentPath;
+  virtual void processNode(xmlNodePtr aNode);
+  virtual bool processChildren(xmlNodePtr aNode);
+
+  xmlNodePtr findRoot();
+  void readRecursively(xmlNodePtr theParent);
+
+  xmlNodePtr node(void* theNode);
+  std::string getProperty(xmlNodePtr theNode, const char* property);
+  /*
+   * Please note that this function should be called with NULL last argument. 
+   * In example: isNode(aNode, "type1", ["type2", ...], NULL);
+   * ", NULL" is required to use unlimited number of arguments.
+   * TODO(sbh): find a way to simplify calling this method.
+   */
+  bool isNode(xmlNodePtr theNode, const char* name, ...);
+  bool hasChild(xmlNodePtr theNode);
+
+protected:
+  std::string myDocumentPath;
+  xmlDocPtr   myXmlDoc;
 };
 
 #endif /* CONFIG_XMLREADER_H_ */