Interface class that defines an XML parser.
More...
#include "util/ixmlfile.h"
|
|
virtual | ~IXmlFile ()=default |
| | Destructor.
|
| void | FileName (const std::string &filename) |
| | Sets the file name (full path).
|
| std::string | FileName () const |
| | Return the full path file name.
|
|
std::string | FileNameWithoutPath () const |
| | File name without path.
|
| std::string | Version () const |
| | Returns the XML file version.
|
| void | Version (const std::string &version) |
| | Sets the version of the XML file.
|
| std::string | Encoding () const |
| | Return the character encoding of the XML file.
|
| void | Encoding (const std::string &encoding) |
| | Sets the XML file encoding.
|
| bool | Standalone () const |
| | Returns true is the XML file is stand-alone.
|
| std::string | RootName () const |
| | Returns the name of the root tag.
|
| IXmlNode & | RootName (const std::string &name) |
| | Create the root tag in an XML file object.
|
| IXmlNode * | RootNode () const |
| | Returns the root node in XML file.
|
| std::string | StyleSheet () const |
| | Returns the used style sheet.
|
| void | StyleSheet (const std::string &style_sheet) |
| | Sets the style sheet.
|
| template<typename T> |
| T | Property (const std::string &key, const T &def={}) const |
| | Returns an XML tags value.
|
| template<typename T> |
| void | SetProperty (const std::string &key, const T &value) |
| | Sets a property tag value.
|
| void | GetChildList (IXmlNode::ChildList &child_list) const |
| | Returns a list of child tags below the root tag.
|
| const IXmlNode * | GetNode (const std::string &tag) const |
| | Returns a node with a tag name.
|
|
virtual bool | ParseFile () |
| | Parses the XML file.
|
|
virtual bool | ParseString (const std::string &input) |
| | Parses a string instead of a file.
|
|
virtual void | Reset () |
| | Reset the internals i.e. ready for a new parsing.
|
|
virtual bool | WriteFile () |
| | Writes the XML file.
|
| std::string | WriteString (bool skip_header=false) |
|
|
| IXmlFile ()=default |
| | Default constructor is hidden from external users.
|
|
virtual std::unique_ptr< IXmlNode > | CreateNode (const std::string &name) |
| | Creates a new node.
|
|
|
std::string | filename_ |
| | File name with full path.
|
|
std::string | version_ = "1.0" |
| | Version of the XML file.
|
|
std::string | encoding_ = "UTF-8" |
| | Encoding of strings in the XML file.
|
|
std::string | style_sheet_ |
| | Optional style sheet.
|
|
bool | standalone_ = true |
| | True of the file is standalone.
|
|
std::unique_ptr< IXmlNode > | root_node_ |
| | Pointer to the root node.
|
The interface shall hide the implementation code of an XML parser.
◆ Encoding() [1/2]
| std::string util::xml::IXmlFile::Encoding |
( |
| ) |
const |
|
inlinenodiscard |
Returns the character encoding of the XML file. Standard encoding is UTF-8.
- Returns
- XML encoding.
◆ Encoding() [2/2]
| void util::xml::IXmlFile::Encoding |
( |
const std::string & | encoding | ) |
|
|
inline |
Sets the XML file encoding. By default the UTF-8 encoding is used.
- Parameters
-
| encoding | XML file encoding |
◆ FileName() [1/2]
| std::string util::xml::IXmlFile::FileName |
( |
| ) |
const |
|
inlinenodiscard |
- Returns
- Full path to the file name
◆ FileName() [2/2]
| void util::xml::IXmlFile::FileName |
( |
const std::string & | filename | ) |
|
- Parameters
-
| filename | File name with full path |
◆ GetChildList()
Returns a list of tags below the root tag.
- Parameters
-
| child_list | List of main tags in the file, Returns a list of XML tags (nodes). |
◆ GetNode()
| const IXmlNode * util::xml::IXmlFile::GetNode |
( |
const std::string & | tag | ) |
const |
|
nodiscard |
Returns a (unique) node with a specific tag name
- Parameters
-
- Returns
- Pointer ti the node. Returns a tag node.
◆ Property()
template<typename T>
| T util::xml::IXmlFile::Property |
( |
const std::string & | key, |
|
|
const T & | def = {} ) const |
|
inlinenodiscard |
Returns a value of an XML tag excluding the root tag.
- Template Parameters
-
| T | Type can be string, numbers and boolean. |
- Parameters
-
| [in] | key | Tag name with the value. |
| [in] | def | Default value if not found. |
- Returns
- Returns the tag value or default value.
◆ RootName() [1/2]
| std::string util::xml::IXmlFile::RootName |
( |
| ) |
const |
|
inlinenodiscard |
- Returns
- Name of the root tag
< Return the name of the root tag.
◆ RootName() [2/2]
| IXmlNode & util::xml::IXmlFile::RootName |
( |
const std::string & | name | ) |
|
Creates the root tag and sets its tag name.
- Parameters
-
◆ RootNode()
| IXmlNode * util::xml::IXmlFile::RootNode |
( |
| ) |
const |
|
inlinenodiscard |
Returns the root node in the XML file. Note that this function may return null if no root node exist,
- Returns
- The root node object if it exists, otherwise null.
◆ SetProperty()
template<typename T>
| void util::xml::IXmlFile::SetProperty |
( |
const std::string & | key, |
|
|
const T & | value ) |
|
inline |
Sets a property tag value
- Template Parameters
-
- Parameters
-
| key | Tag name |
| value | Tag value |
◆ Standalone()
| bool util::xml::IXmlFile::Standalone |
( |
| ) |
const |
|
inlinenodiscard |
- Returns
- True if the XML file is stand-alone.
◆ StyleSheet() [1/2]
| std::string util::xml::IXmlFile::StyleSheet |
( |
| ) |
const |
|
inlinenodiscard |
Returns the used style sheet.
- Returns
- The style sheet
◆ StyleSheet() [2/2]
| void util::xml::IXmlFile::StyleSheet |
( |
const std::string & | style_sheet | ) |
|
|
inline |
Sets the style sheet. Include full url path.
- Parameters
-
| style_sheet | URL to style sheet. |
◆ Version() [1/2]
| std::string util::xml::IXmlFile::Version |
( |
| ) |
const |
|
inlinenodiscard |
Returns the XML file version. Typical 1.0 or 1.1.
- Returns
- XML version.
◆ Version() [2/2]
| void util::xml::IXmlFile::Version |
( |
const std::string & | version | ) |
|
|
inline |
Sets the XML file version. Set default to 1.0.
- Parameters
-
◆ WriteString()
| std::string util::xml::IXmlFile::WriteString |
( |
bool | skip_header = false | ) |
|
Creates a string that is a whole XML file.
The documentation for this class was generated from the following file: