1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
6 * Created on: Mar 14, 2014
10 #ifndef CONFIG_XMLREADER_H_
11 #define CONFIG_XMLREADER_H_
13 #include <Config_def.h>
18 //>> Forward declaration of xmlNodePtr.
19 typedef struct _xmlNode xmlNode;
20 typedef xmlNode *xmlNodePtr;
24 //>> Forward declaration of xmlDocPtr.
25 typedef struct _xmlDoc xmlDoc;
26 typedef xmlDoc *xmlDocPtr;
31 * \class Config_XMLReader
33 * \brief Base class for all libxml readers. Provides high-level API
34 * for all xml operations.
36 class Config_XMLReader
39 CONFIG_EXPORT Config_XMLReader(const std::string& theXmlFile);
40 CONFIG_EXPORT virtual ~Config_XMLReader();
42 * Read all nodes in associated xml file,
43 * recursively if processChildren(xmlNode) is true for the xmlNode.
44 * For each read node the processNode will be called.
46 CONFIG_EXPORT void readAll();
48 * Returns xmlNodePtr to the root of reader's document
49 * or NULL if not found
51 CONFIG_EXPORT xmlNodePtr findRoot();
55 * \brief Allows to customize reader's behavior for a node. Virtual.
56 * The default implementation process "source", "validator" and
57 * "selection_filter" nodes.
59 virtual void processNode(xmlNodePtr aNode);
61 * \brief Defines which nodes should be processed recursively. Virtual.
62 * The default impl is to read all nodes.
64 virtual bool processChildren(xmlNodePtr aNode);
66 * Calls processNode() for each child (for some - recursively)
70 void readRecursively(xmlNodePtr theParent);
72 * \brief void* -> xmlNodePtr
74 xmlNodePtr node(void* theNode);
75 /// Gets xml node name
76 std::string getNodeName(xmlNodePtr theNode);
78 * \brief Retrieves all the necessary info from the validator node.
79 * Sends ValidatorLoaded event
81 void processValidator(xmlNodePtr theNode);
83 * \brief Retrieves all the necessary info from the SelectionFilter node.
84 * Sends SelectionFilterLoaded event
86 void processSelectionFilter(xmlNodePtr theNode);
89 std::string myCurrentFeature; ///< Name of currently processed feature
90 std::string myDocumentPath; ///< Path to the xml document
91 xmlDocPtr myXmlDoc; ///< Root of the xml document
94 #endif /* CONFIG_XMLREADER_H_ */