PLCnext API Documentation  20.6.0.30321
Public Member Functions | Static Public Member Functions | List of all members
Arp::System::Commons::Xml::XmlWriter Class Reference

Class to write an XML File More...

#include <XmlWriter.hpp>

Public Member Functions

 XmlWriter (XmlWriter &&arg)
 Move contructor. More...
 
 ~XmlWriter (void)
 Destructs this instance and frees all resources. More...
 
bool GetIndent (void) const
 Reads the indent status of this XmlWriter More...
 
const char * GetEncoding (void) const
 Gets the encoding used by this XmlWriter More...
 
void WriteStartDocument (void)
 writes the start of an xml document e.g. xml tag More...
 
void WriteEndDocument (void)
 completes the xml document, must be called after the document data was written More...
 
void WriteStartElement (const char *elementName)
 writes an start element with the given name <elementName> More...
 
void WriteEndElement (void)
 ends the currently open start element if no content was written inside this element, an empty element is written if content was written inside this element, an end element is written More...
 
void WriteElementContent (const String &value)
 writes the content inside the currently open element characters not allowed in xml are encoded More...
 
void WriteElementContentCData (const String &text)
 writes the content inside the currently open element enclosed in a CDATA section characters not allowed in xml are not encoded More...
 
template<class T >
void SetAttributeValue (const char *attributeName, const T &value)
 writes a new attribute for the currently open element characters not allowed in xml are not encoded More...
 
void SetAttributeValue (const char *attributeName, const char *value)
 
void SetAttributeValue (const char *attributeName, const String &value)
 
void SetAttributeValue (const char *attributeName, boolean value)
 

Static Public Member Functions

static XmlWriter Create (const String &filename, bool indent, const char *encoding="UTF-8")
 Creates a new Instance of the XmlWriter More...
 
static XmlWriter Create (XmlBuffer &buffer, bool indent, const char *encoding="UTF-8")
 Creates a new Instance of the XmlWriter writing to an XmlBuffer in memory More...
 

Detailed Description

Class to write an XML File

Constructor & Destructor Documentation

◆ XmlWriter()

Arp::System::Commons::Xml::XmlWriter::XmlWriter ( XmlWriter &&  arg)

Move contructor.

◆ ~XmlWriter()

Arp::System::Commons::Xml::XmlWriter::~XmlWriter ( void  )

Destructs this instance and frees all resources.

Member Function Documentation

◆ Create() [1/2]

static XmlWriter Arp::System::Commons::Xml::XmlWriter::Create ( const String filename,
bool  indent,
const char *  encoding = "UTF-8" 
)
static

Creates a new Instance of the XmlWriter

Parameters
filenameThe Filename the writer uses to write the xml data
indentif true indenting is used by the writer to format the xml so it is easier to read
encodingthe encoding to use for the xml file
Exceptions
XmlException

◆ Create() [2/2]

static XmlWriter Arp::System::Commons::Xml::XmlWriter::Create ( XmlBuffer &  buffer,
bool  indent,
const char *  encoding = "UTF-8" 
)
static

Creates a new Instance of the XmlWriter writing to an XmlBuffer in memory

Parameters
bufferThe buffer the writer uses to write the xml data
indentif true indenting is used by the writer to format the xml so it is easier to read
encodingthe encoding to use for the xml data
Exceptions
XmlException

◆ GetEncoding()

const char* Arp::System::Commons::Xml::XmlWriter::GetEncoding ( void  ) const

Gets the encoding used by this XmlWriter

Returns
the encoding name

◆ GetIndent()

bool Arp::System::Commons::Xml::XmlWriter::GetIndent ( void  ) const

Reads the indent status of this XmlWriter

Returns
true if indenting is used, false otherwise

◆ SetAttributeValue()

template<class T >
void Arp::System::Commons::Xml::XmlWriter::SetAttributeValue ( const char *  attributeName,
const T &  value 
)
inline

writes a new attribute for the currently open element characters not allowed in xml are not encoded

Parameters
attributeNamethe name of the new attribute
valuethe value of the new attribute the type of value must be const char*, Arp::String, boolean or be supported by fmt::MemoryWriter
Exceptions
XmlException

◆ WriteElementContent()

void Arp::System::Commons::Xml::XmlWriter::WriteElementContent ( const String value)

writes the content inside the currently open element characters not allowed in xml are encoded

Parameters
valuethe content as String which should be written
Exceptions
XmlException

◆ WriteElementContentCData()

void Arp::System::Commons::Xml::XmlWriter::WriteElementContentCData ( const String text)

writes the content inside the currently open element enclosed in a CDATA section characters not allowed in xml are not encoded

Parameters
textthe CDATA content as String which should be written
Exceptions
XmlException

◆ WriteEndDocument()

void Arp::System::Commons::Xml::XmlWriter::WriteEndDocument ( void  )

completes the xml document, must be called after the document data was written

Exceptions
XmlException

◆ WriteEndElement()

void Arp::System::Commons::Xml::XmlWriter::WriteEndElement ( void  )

ends the currently open start element if no content was written inside this element, an empty element is written if content was written inside this element, an end element is written

Exceptions
XmlException

◆ WriteStartDocument()

void Arp::System::Commons::Xml::XmlWriter::WriteStartDocument ( void  )

writes the start of an xml document e.g. xml tag

Exceptions
XmlException

◆ WriteStartElement()

void Arp::System::Commons::Xml::XmlWriter::WriteStartElement ( const char *  elementName)

writes an start element with the given name <elementName>

Parameters
elementNamename of the xml element
Exceptions
XmlException

The documentation for this class was generated from the following file: