|
| IXmlNode (const std::string &tag_name) |
| Creates a XML tag.
|
virtual | ~IXmlNode ()=default |
| Destructor.
|
std::string | TagName () const |
| Returns the nodes tag name.
|
void | TagName (const std::string &name) |
| Sets the tag name.
|
bool | IsTagName (const std::string &tag) const |
| Returns true if the tag name match. Check if this is a specific tag name. The check ignore case and namespaces.
|
bool | IsAttribute (const std::string &key, const std::string &value) const |
| Checks if an attribute exist.
|
template<typename T> |
T | Attribute (const std::string &key, const T &def={}) const |
| Returns an attribute.
|
template<typename T> |
void | SetAttribute (const std::string &key, const T &value) |
| Sets an attribute.
|
template<typename T> |
T | Value () const |
| Returns a value.
|
template<typename T> |
void | Value (const T &value) |
| Sets a tag value.
|
template<typename T> |
T | Property (const std::string &key, const T &def={}) const |
| Returns a specific tag value.
|
template<typename T> |
void | SetProperty (const std::string &key, const T &value) |
| Sets a property.
|
virtual void | GetChildList (ChildList &child_list) const |
| Returns the child nodes.
|
virtual const IXmlNode * | GetNode (const std::string &tag) const |
| Returns a node if it exist.
|
virtual const IXmlNode * | GetNode (const std::string &tag, const std::string &key, const std::string &attr) const |
| Returns a node with a specific attribute.
|
bool | ExistProperty (const std::string &tag) const |
| Returns true if the named property exist.
|
virtual IXmlNode & | AddNode (const std::string &name) |
| Adds a new tag.
|
virtual IXmlNode & | AddUniqueNode (const std::string &name) |
| Adds a unique tag.
|
virtual IXmlNode & | AddUniqueNode (const std::string &name, const std::string &key, const std::string &attr) |
| Adds a unique tag with an attribute.
|
virtual void | AddNode (std::unique_ptr< IXmlNode > p) |
| Adds a node.
|
void | DeleteNode (const std::string &name) |
| Deletes all nodes with name.
|
void | DeleteNode (const IXmlNode *node) |
| Deletes a specific node.
|
virtual void | Write (std::ostream &dest, size_t level) |
| Write the node to the stream.
|
bool | HasChildren () const |
| Returns true if the XML node has children.
|
template<> |
void | Value (const bool &value) |
| Adds a boolean value.
|
template<> |
void | Value (const std::string &value) |
| Adds a string value.
|
template<> |
void | SetAttribute (const std::string &key, const bool &value) |
| Sets a boolean attribute.
|
]
The class is the main interface when an XML file is more than one level deep. Simple configuration files normally only have a root tag including one or more value tags (properties).
Each tag have a tag name and none or more attributes. If the tag name is unique within the file, there is no need for attributes but if many tags with the same name, it's recommended to set a unique attribute on each tag.