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
41 * \param theXmlFile - full path to the xml file which will be processed by the reader
43 CONFIG_EXPORT Config_XMLReader(const std::string& theXmlFile);
44 CONFIG_EXPORT virtual ~Config_XMLReader();
46 * Read all nodes in associated xml file,
47 * recursively if processChildren(xmlNode) is true for the xmlNode.
48 * For each read node the processNode will be called.
50 CONFIG_EXPORT void readAll();
52 * Returns xmlNodePtr to the root of reader's document
53 * or NULL if not found
55 CONFIG_EXPORT xmlNodePtr findRoot();
59 * \brief Allows to customize reader's behavior for a node. Virtual.
60 * The default implementation process "source", "validator" and
61 * "selection_filter" nodes.
63 virtual void processNode(xmlNodePtr aNode);
66 * This method gives an ability to finalize processing of a node,
67 * when reader is about to leave the node (node and all it's children are processed)
69 virtual void cleanup(xmlNodePtr aNode);
71 * \brief Defines which nodes should be processed recursively. Virtual.
72 * The default impl is to read all nodes.
74 virtual bool processChildren(xmlNodePtr aNode);
76 * Calls processNode() for each child (for some - recursively)
80 void readRecursively(xmlNodePtr theParent);
82 * \brief void* -> xmlNodePtr
84 xmlNodePtr node(void* theNode);
85 /// Gets xml node name
86 std::string getNodeName(xmlNodePtr theNode);
88 * \brief Retrieves all the necessary info from the validator node.
89 * Sends ValidatorLoaded event
91 void processValidator(xmlNodePtr theNode);
93 * \brief Retrieves all the necessary info from the SelectionFilter node.
94 * Sends SelectionFilterLoaded event
96 void processSelectionFilter(xmlNodePtr theNode);
99 std::string myCurrentFeature; ///< Name of currently processed feature
100 std::string myDocumentPath; ///< Path to the xml document
101 xmlDocPtr myXmlDoc; ///< Root of the xml document
104 #endif /* CONFIG_XMLREADER_H_ */