120 template <
typename T>
121 [[nodiscard]] T
Property(
const std::string &key,
const T &def = {})
const {
131 template <
typename T>
153 const std::string &tag)
const;
157 const std::string &input);
173 const std::string &name);
175 void WriteRoot(std::ostream &dest,
bool skip_header)
const;
188 const std::string &type =
"Expat");
std::string Encoding() const
Return the character encoding of the XML file.
Definition ixmlfile.h:59
std::unique_ptr< IXmlNode > root_node_
Pointer to the root node.
Definition ixmlfile.h:170
std::string version_
Version of the XML file.
Definition ixmlfile.h:165
IXmlFile()=default
Default constructor is hidden from external users.
const IXmlNode * GetNode(const std::string &tag) const
Returns a node with a tag name.
virtual bool ParseString(const std::string &input)
Parses a string instead of a file.
bool Standalone() const
Returns true is the XML file is stand-alone.
Definition ixmlfile.h:71
std::string encoding_
Encoding of strings in the XML file.
Definition ixmlfile.h:166
void Encoding(const std::string &encoding)
Sets the XML file encoding.
Definition ixmlfile.h:65
std::string WriteString(bool skip_header=false)
void Version(const std::string &version)
Sets the version of the XML file.
Definition ixmlfile.h:52
std::string style_sheet_
Optional style sheet.
Definition ixmlfile.h:167
virtual bool ParseFile()
Parses the XML file.
std::string StyleSheet() const
Returns the used style sheet.
Definition ixmlfile.h:101
virtual void Reset()
Reset the internals i.e. ready for a new parsing.
void FileName(const std::string &filename)
Sets the file name (full path).
virtual bool WriteFile()
Writes the XML file.
virtual ~IXmlFile()=default
Destructor.
std::string FileName() const
Return the full path file name.
Definition ixmlfile.h:35
bool standalone_
True of the file is standalone.
Definition ixmlfile.h:169
std::string FileNameWithoutPath() const
File name without path.
IXmlNode & RootName(const std::string &name)
Create the root tag in an XML file object.
void GetChildList(IXmlNode::ChildList &child_list) const
Returns a list of child tags below the root tag.
virtual std::unique_ptr< IXmlNode > CreateNode(const std::string &name)
Creates a new node.
std::string filename_
File name with full path.
Definition ixmlfile.h:164
void SetProperty(const std::string &key, const T &value)
Sets a property tag value.
Definition ixmlfile.h:132
std::string Version() const
Returns the XML file version.
Definition ixmlfile.h:45
void StyleSheet(const std::string &style_sheet)
Sets the style sheet.
Definition ixmlfile.h:108
IXmlNode * RootNode() const
Returns the root node in XML file.
Definition ixmlfile.h:94
T Property(const std::string &key, const T &def={}) const
Returns an XML tags value.
Definition ixmlfile.h:121
std::string RootName() const
Returns the name of the root tag.
Definition ixmlfile.h:77
Interface class against a XML tag (node) in a XML file.
Definition ixmlnode.h:61
std::vector< const IXmlNode * > ChildList
List of pointer to child nodes.
Definition ixmlnode.h:179
The xml namespace is used for XML related classes and functions.
Definition isuperviseapplication.h:22
std::unique_ptr< IXmlFile > CreateXmlFile(const std::string &type="Expat")
Creates an XML object that either parse or write.