#include <OpenGUI_XMLParser.h>
XML is processed by OpenGUI using a mixed DOM/SAX system. XML documents are fully loaded into a DOM tree comprised of XMLNode objects and is then walked in the appropriate direction for the current operation. Callbacks register to handle a particular tag signature, for a given operation (load/unload). For each XML tag processed, the registered callbacks are called in the reverse order of registration (last registered goes first). The callbacks signify their successful processing of a tag by returning true. The first callback to signal successful processing of the tag will end the callback invokes for that particular tag instance, and the next tag is read and the callback process starts over. Any tag that is processed that does not result in a success signal from a registered callback will be logged with an unprocessed tag warning, but is otherwise ignored.
During XML tree walking, the XMLParser will not automatically step deeper into the XML DOM tree. However, if a particular tag (such as the <OpenGUI> tag) is used to group together XML tags that are specific to a particular system (in this case, OpenGUI specific) then the XMLParser can be told to process the subtags of that tag by calling ProcessXML_Load() or ProcessXML_Unload() as the particular situation requires.
Public Member Functions | |
| void | LoadFromFile (const std::string &xmlFilename) |
| Reads the given XML file from the registered resource manager and parses the file according to the XML specifications. | |
| void | UnloadFromFile (const std::string &xmlFilename) |
| Reads the given XML file from the registered resource manager and parses it in reverse, performing unloads instead of loads. | |
| void | RegisterLoadHandler (const std::string &tagName, XMLNodeHandler *handler_callback) |
Registers an XML Load handler for the given tagName. | |
| void | UnregisterLoadHandler (const std::string &tagName, XMLNodeHandler *handler_callback) |
Unregisters an XML Load handler for the given tagName. | |
| void | RegisterUnloadHandler (const std::string &tagName, XMLNodeHandler *handler_callback) |
Registers an XML Unload handler for the given tagName. | |
| void | UnregisterUnloadHandler (const std::string &tagName, XMLNodeHandler *handler_callback) |
Unregisters an XML Unload handler for the given tagName. | |
| void | ProcessXML_Load (const XMLNodeContainer &container, const std::string &nodePath) |
Processes the given container with XMLLoad handlers, using the given nodePath (Calls ProcessXML_LoadNode() for all container children). | |
| void | ProcessXML_LoadNode (const XMLNode &node, const std::string &nodePath) |
Processes the given node with XMLLoad handlers, using the given nodePath. | |
| void | ProcessXML_Unload (const XMLNodeContainer &container, const std::string &nodePath) |
Processes the given container with XMLUnload handlers, using the given nodePath (Calls ProcessXML_UnloadNode() for all container children). | |
| void | ProcessXML_UnloadNode (const XMLNode &node, const std::string &nodePath) |
Processes the given node with XMLUnload handlers, using the given nodePath. | |
Static Public Member Functions | |
| static XMLParser & | getSingleton (void) |
| Retrieve the current singleton, if one exists. If none exists, this will cause an error. | |
| static XMLParser * | getSingletonPtr (void) |
| Retrieve a pointer to the current singleton, if one exists. If none exists, this will return 0. | |
| XMLParser & OpenGUI::XMLParser::getSingleton | ( | void | ) | [static] |
Retrieve the current singleton, if one exists. If none exists, this will cause an error.
| XMLParser * OpenGUI::XMLParser::getSingletonPtr | ( | void | ) | [static] |
Retrieve a pointer to the current singleton, if one exists. If none exists, this will return 0.
| void OpenGUI::XMLParser::LoadFromFile | ( | const std::string & | xmlFilename | ) |
Reads the given XML file from the registered resource manager and parses the file according to the XML specifications.
| void OpenGUI::XMLParser::ProcessXML_Load | ( | const XMLNodeContainer & | container, | |
| const std::string & | nodePath | |||
| ) |
Processes the given container with XMLLoad handlers, using the given nodePath (Calls ProcessXML_LoadNode() for all container children).
| void OpenGUI::XMLParser::ProcessXML_LoadNode | ( | const XMLNode & | node, | |
| const std::string & | nodePath | |||
| ) |
Processes the given node with XMLLoad handlers, using the given nodePath.
| void OpenGUI::XMLParser::ProcessXML_Unload | ( | const XMLNodeContainer & | container, | |
| const std::string & | nodePath | |||
| ) |
Processes the given container with XMLUnload handlers, using the given nodePath (Calls ProcessXML_UnloadNode() for all container children).
| void OpenGUI::XMLParser::ProcessXML_UnloadNode | ( | const XMLNode & | node, | |
| const std::string & | nodePath | |||
| ) |
Processes the given node with XMLUnload handlers, using the given nodePath.
| void OpenGUI::XMLParser::RegisterLoadHandler | ( | const std::string & | tagName, | |
| XMLNodeHandler * | handler_callback | |||
| ) |
Registers an XML Load handler for the given tagName.
Registering for a path that is already registered is legal, and will override the existing registration. Unregistering your override will restore the previously registered handler.
| void OpenGUI::XMLParser::RegisterUnloadHandler | ( | const std::string & | tagName, | |
| XMLNodeHandler * | handler_callback | |||
| ) |
Registers an XML Unload handler for the given tagName.
| void OpenGUI::XMLParser::UnloadFromFile | ( | const std::string & | xmlFilename | ) |
Reads the given XML file from the registered resource manager and parses it in reverse, performing unloads instead of loads.
| void OpenGUI::XMLParser::UnregisterLoadHandler | ( | const std::string & | tagName, | |
| XMLNodeHandler * | handler_callback | |||
| ) |
| void OpenGUI::XMLParser::UnregisterUnloadHandler | ( | const std::string & | tagName, | |
| XMLNodeHandler * | handler_callback | |||
| ) |
Unregisters an XML Unload handler for the given tagName.