GEOS
|
#include <xmlWrapper.hpp>
Public Member Functions | |
xmlDocument () | |
Construct an empty xmlDocument that waits to load something. | |
xmlDocument (const xmlDocument &)=delete | |
non-copyable | |
xmlDocument (xmlDocument &&)=default | |
move constructor | |
xmlNode | getFirstChild () const |
xmlNode | getChild (string const &name) const |
string const & | getOriginalBuffer () const |
string const * | getOriginalBuffer (string const &filePath) const |
map< string, string > const & | getOriginalBuffers () const |
string const & | getFilePath () const |
xmlNodePos | getNodePosition (xmlWrapper::xmlNode const &node) const |
If the node file information are loaded, compute the position of a node. More... | |
xmlResult | loadString (string_view content, bool loadNodeFileInfo=false) |
Load document from zero-terminated string. No encoding conversions are applied. Free any previously loaded xml tree. Wrapper of pugi::xml_document::loadBuffer() method. More... | |
xmlResult | loadFile (string const &path, bool loadNodeFileInfo=false) |
Load document from file. Free any previously loaded xml tree. Wrapper of pugi::xml_document::loadBuffer() method. More... | |
xmlNode | appendChild (string const &name) |
Add a root element to the document. More... | |
xmlNode | appendChild (xmlNodeType type=xmlNodeType::node_element) |
Add a root element to the document. More... | |
bool | saveFile (string const &path) const |
Save the XML to a file. More... | |
void | addIncludedXML (xmlNode &targetNode, int level=0) |
Function to add xml nodes from included files. More... | |
bool | hasNodeFileInfo () const |
Static Public Attributes | |
static constexpr size_t | npos = string::npos |
Error value for when an offset / line position is undefined. | |
Wrapper class for the type of xml document. This class exists to intercept file / string loading methods, and to keep the loaded buffers, in order to retrieve the source file and line of nodes and attributes.
Definition at line 146 of file xmlWrapper.hpp.
void geos::xmlWrapper::xmlDocument::addIncludedXML | ( | xmlNode & | targetNode, |
int | level = 0 |
||
) |
Function to add xml nodes from included files.
targetNode | the node for which to look for included children specifications |
level | include tree level used to detect circular includes |
This function looks for a "Included" node under the targetNode, loops over all subnodes under the "Included" node, and then parses the file specified in those subnodes taking all the nodes in the file and adding them to the targetNode. Each found includes are added to xmlDocument::m_originalBuffers.
Add a root element to the document.
name | the tag name of the node to add |
xmlNode geos::xmlWrapper::xmlDocument::appendChild | ( | xmlNodeType | type = xmlNodeType::node_element | ) |
Add a root element to the document.
type | the type of the node to add to the root of the document. As an exemple, node_declaration is useful to add the "<?xml ?>" node. |
name | the tag name of the node to find |
string const& geos::xmlWrapper::xmlDocument::getFilePath | ( | ) | const |
xmlNode geos::xmlWrapper::xmlDocument::getFirstChild | ( | ) | const |
xmlNodePos geos::xmlWrapper::xmlDocument::getNodePosition | ( | xmlWrapper::xmlNode const & | node | ) | const |
If the node file information are loaded, compute the position of a node.
node | the node to locate |
an | InputError if the node position is not found and source file is loaded. |
string const& geos::xmlWrapper::xmlDocument::getOriginalBuffer | ( | ) | const |
filePath | the path of the file which buffer must be returned. |
bool geos::xmlWrapper::xmlDocument::hasNodeFileInfo | ( | ) | const |
xmlResult geos::xmlWrapper::xmlDocument::loadFile | ( | string const & | path, |
bool | loadNodeFileInfo = false |
||
) |
Load document from file. Free any previously loaded xml tree. Wrapper of pugi::xml_document::loadBuffer() method.
path | the path of an xml file to load. |
loadNodeFileInfo | Load the node source file info, allowing getNodePosition() to work. |
xmlResult geos::xmlWrapper::xmlDocument::loadString | ( | string_view | content, |
bool | loadNodeFileInfo = false |
||
) |
Load document from zero-terminated string. No encoding conversions are applied. Free any previously loaded xml tree. Wrapper of pugi::xml_document::loadBuffer() method.
content | the string containing the document content |
loadNodeFileInfo | Load the node source file info, allowing getNodePosition() to work. |
bool geos::xmlWrapper::xmlDocument::saveFile | ( | string const & | path | ) | const |
Save the XML to a file.
path | the file path |