Class SBCSerializerXML#
This class describes an XML serializer. More...
#include <SBCSerializerXML.hpp>
Inherits the following classes: SBCSerializer
Public Functions#
| Type | Name |
|---|---|
| SBCSerializerXML (const std::string & fileName, bool write) Constructor. |
|
| virtual bool | readBoolElement () Reads an element of boolean type. |
| virtual char * | readCharArrayElement (unsigned int & arraySize) Reads an element of char array type of size arraySize . |
| virtual char | readCharElement () Reads an element of char type. |
| virtual double | readDoubleElement () Reads an element of double type. |
| virtual void | readEndElement () Reads the end element. |
| virtual float | readFloatElement () Reads an element of float type. |
| virtual int | readIntElement () Reads an element of integer type. |
| virtual long | readLongElement () Reads an element of long integer type. |
| virtual long long | readLongLongElement () Reads an element of long long integer type. |
| virtual short | readShortElement () Reads an element of short integer type. |
| virtual void | readStartElement () Reads the start element. |
| virtual std::string | readStringElement () Reads an element of string type. |
| virtual std::string | readStringElementFromBase64 () Reads an element of string type in Base64 (supports html) |
| virtual SBCContainerUUID | readUUIDElement () Reads an element of UUID type. |
| virtual unsigned char | readUnsignedCharElement () Reads an element of unsigned char type. |
| virtual unsigned int | readUnsignedIntElement () Reads an element of unsigned integer type. |
| virtual unsigned long | readUnsignedLongElement () Reads an element of unsigned long integer type. |
| virtual unsigned long long | readUnsignedLongLongElement () Reads an element of unsigned long long integer type. |
| virtual unsigned short | readUnsignedShortElement () Reads an element of unsigned short integer type. |
| virtual void | writeBoolElement (const std::string & elementName, bool element) Writes an element of boolean type with elementName name and valueelement . |
| virtual void | writeCharArrayElement (const std::string & elementName, const char * elementArray, unsigned int arraySize) Writes an element of char array type with elementName name of sizearraySize and valueselementArray . |
| virtual void | writeCharElement (const std::string & elementName, char element) Writes an element of char type with elementName name and valueelement . |
| virtual void | writeDoubleElement (const std::string & elementName, double element) Writes an element of double type with elementName name and valueelement . |
| virtual void | writeEndElement () Writes the end element. |
| virtual void | writeFloatElement (const std::string & elementName, float element) Writes an element of float type with elementName name and valueelement . |
| virtual void | writeIntElement (const std::string & elementName, int element) Writes an element of integer type with elementName name and valueelement . |
| virtual void | writeLongElement (const std::string & elementName, long element) Writes an element of long integer type with elementName name and valueelement . |
| virtual void | writeLongLongElement (const std::string & elementName, long long element) Writes an element of long long integer type with elementName name and valueelement . |
| virtual void | writeShortElement (const std::string & elementName, short element) Writes an element of short integer type with elementName name and valueelement . |
| virtual void | writeStartElement (const std::string & elementName) Writes the start element with elementName name. |
| virtual void | writeStringElement (const std::string & elementName, const std::string & element) Writes an element of string type with elementName name and valueelement . |
| virtual void | writeStringElementInBase64 (const std::string & elementName, const std::string & element) Writes an element of string type in Base64 (supports html) with elementName name and valueelement . |
| virtual void | writeUUIDElement (const std::string & elementName, const SBCContainerUUID & element) Writes an element of UUID type with elementName name and valueelement . |
| virtual void | writeUnsignedCharElement (const std::string & elementName, unsigned char element) Writes an element of unsigned char type with elementName name and valueelement . |
| virtual void | writeUnsignedIntElement (const std::string & elementName, unsigned int element) Writes an element of unsigned integer type with elementName name and valueelement . |
| virtual void | writeUnsignedLongElement (const std::string & elementName, unsigned long element) Writes an element of unsigned long integer type with elementName name and valueelement . |
| virtual void | writeUnsignedLongLongElement (const std::string & elementName, unsigned long long element) Writes an element of unsigned long long integer type with elementName name and valueelement . |
| virtual void | writeUnsignedShortElement (const std::string & elementName, unsigned short element) Writes an element of unsigned short integer type with elementName name and valueelement . |
| virtual | ~SBCSerializerXML () Destructor. |
Public Functions inherited from SBCSerializer#
See SBCSerializer
| Type | Name |
|---|---|
| SBCSerializer () Constructor. |
|
| virtual bool | readBoolElement () Reads an element of boolean type. |
| virtual char * | readCharArrayElement (unsigned int & arraySize) Reads an element of char array type of size arraySize . |
| virtual char | readCharElement () Reads an element of char type. |
| virtual double | readDoubleElement () Reads an element of double type. |
| virtual void | readEndElement () Reads the end element. |
| virtual float | readFloatElement () Reads an element of float type. |
| virtual int | readIntElement () Reads an element of integer type. |
| virtual long | readLongElement () Reads an element of long integer type. |
| virtual long long | readLongLongElement () Reads an element of long long integer type. |
| virtual short | readShortElement () Reads an element of short integer type. |
| virtual void | readStartElement () Reads the start element. |
| virtual std::string | readStringElement () Reads an element of string type. |
| virtual std::string | readStringElementFromBase64 () Reads an element of string type in Base64 (supports html) |
| virtual SBCContainerUUID | readUUIDElement () Reads an element of UUID type. |
| virtual unsigned char | readUnsignedCharElement () Reads an element of unsigned char type. |
| virtual unsigned int | readUnsignedIntElement () Reads an element of unsigned integer type. |
| virtual unsigned long | readUnsignedLongElement () Reads an element of unsigned long integer type. |
| virtual unsigned long long | readUnsignedLongLongElement () Reads an element of unsigned long long integer type. |
| virtual unsigned short | readUnsignedShortElement () Reads an element of unsigned short integer type. |
| virtual void | writeBoolElement (const std::string & elementName, bool element) Writes an element of boolean type with elementName name and valueelement . |
| virtual void | writeCharArrayElement (const std::string & elementName, const char * elementArray, unsigned int arraySize) Writes an element of char array type with elementName name of sizearraySize and valueselementArray . |
| virtual void | writeCharElement (const std::string & elementName, char element) Writes an element of char type with elementName name and valueelement . |
| virtual void | writeDoubleElement (const std::string & elementName, double element) Writes an element of double type with elementName name and valueelement . |
| virtual void | writeEndElement () Writes the end element. |
| virtual void | writeFloatElement (const std::string & elementName, float element) Writes an element of float type with elementName name and valueelement . |
| virtual void | writeIntElement (const std::string & elementName, int element) Writes an element of integer type with elementName name and valueelement . |
| virtual void | writeLongElement (const std::string & elementName, long element) Writes an element of long integer type with elementName name and valueelement . |
| virtual void | writeLongLongElement (const std::string & elementName, long long element) Writes an element of long long integer type with elementName name and valueelement . |
| virtual void | writeShortElement (const std::string & elementName, short element) Writes an element of short integer type with elementName name and valueelement . |
| virtual void | writeStartElement (const std::string & elementName) Writes the start element with elementName name. |
| virtual void | writeStringElement (const std::string & elementName, const std::string & element) Writes an element of string type with elementName name and valueelement . |
| virtual void | writeStringElementInBase64 (const std::string & elementName, const std::string & element) Writes an element of string type in Base64 (supports html) with elementName name and valueelement . |
| virtual void | writeUUIDElement (const std::string & elementName, const SBCContainerUUID & element) Writes an element of UUID type with elementName name and valueelement . |
| virtual void | writeUnsignedCharElement (const std::string & elementName, unsigned char element) Writes an element of unsigned char type with elementName name and valueelement . |
| virtual void | writeUnsignedIntElement (const std::string & elementName, unsigned int element) Writes an element of unsigned integer type with elementName name and valueelement . |
| virtual void | writeUnsignedLongElement (const std::string & elementName, unsigned long element) Writes an element of unsigned long integer type with elementName name and valueelement . |
| virtual void | writeUnsignedLongLongElement (const std::string & elementName, unsigned long long element) Writes an element of unsigned long long integer type with elementName name and valueelement . |
| virtual void | writeUnsignedShortElement (const std::string & elementName, unsigned short element) Writes an element of unsigned short integer type with elementName name and valueelement . |
| virtual | ~SBCSerializer () Destructor. |
Detailed Description#
Short name: SBSerializerXML
Public Functions Documentation#
function SBCSerializerXML#
Constructor.
Constructs an SBCSerializerXML object.
Opens the specified file for reading or writing, initializes internal data structures, and prepares the XML serializer.
Parameters:
fileNamePath to the XML file.writeIf true, opens the file for writing; otherwise opens for reading.
function readBoolElement#
Reads an element of boolean type.
Reads a boolean element from the XML file.
Returns:
The boolean value read from the element.
Implements SBCSerializer::readBoolElement
function readCharArrayElement#
Reads an element of char array type of size arraySize .
Reads a char array element from the XML file.
Parameters:
arraySizeReference to an unsigned int that will receive the size of the returned array.
Returns:
Pointer to a newly allocated char array containing the element data.
Implements SBCSerializer::readCharArrayElement
function readCharElement#
Reads an element of char type.
Reads a character element from the XML file.
Returns:
The character value read from the element.
Implements SBCSerializer::readCharElement
function readDoubleElement#
Reads an element of double type.
Reads a double element from the XML file.
Returns:
The double value extracted from the current element.
Implements SBCSerializer::readDoubleElement
function readEndElement#
Reads the end element.
Reads the end element from the XML file.
Consumes a line containing the closing tag of the current element.
Implements SBCSerializer::readEndElement
function readFloatElement#
Reads an element of float type.
Reads a float element from the XML file.
Returns:
The float value extracted from the current element.
Implements SBCSerializer::readFloatElement
function readIntElement#
Reads an element of integer type.
Reads an integer element from the XML file.
Returns:
The integer value extracted from the current element.
Implements SBCSerializer::readIntElement
function readLongElement#
Reads an element of long integer type.
Reads a long element from the XML file.
Returns:
The long value extracted from the current element. Note: because the size of longs may vary between platforms (e.g. 4 bytes on Windows and 8 bytes on OS X), it is advised not to use this function when portability is required.
Implements SBCSerializer::readLongElement
function readLongLongElement#
Reads an element of long long integer type.
Reads a long long element from the XML file.
Returns:
The long long value extracted from the current element.
Implements SBCSerializer::readLongLongElement
function readShortElement#
Reads an element of short integer type.
Reads a short integer element from the XML file.
Returns:
The short integer value read from the element.
Implements SBCSerializer::readShortElement
function readStartElement#
Reads the start element.
Reads the start element from the XML file.
Consumes a line containing the opening tag of the next element.
Implements SBCSerializer::readStartElement
function readStringElement#
Reads an element of string type.
Reads a string element from the XML file.
Extracts the text between the opening and closing tags.
Returns:
The string value read from the element.
Implements SBCSerializer::readStringElement
function readStringElementFromBase64#
Reads an element of string type in Base64 (supports html)
Reads a Base64-encoded string element and decodes it.
Returns:
The decoded string value.
Implements SBCSerializer::readStringElementFromBase64
function readUUIDElement#
Reads an element of UUID type.
Reads a UUID element from the XML file.
Returns:
The UUID value extracted from the element.
Implements SBCSerializer::readUUIDElement
function readUnsignedCharElement#
Reads an element of unsigned char type.
Reads an unsigned character element from the XML file.
Returns:
The unsigned character value read from the element.
Implements SBCSerializer::readUnsignedCharElement
function readUnsignedIntElement#
Reads an element of unsigned integer type.
Reads an unsigned integer element from the XML file.
Returns:
The unsigned integer value extracted from the current element.
Implements SBCSerializer::readUnsignedIntElement
function readUnsignedLongElement#
Reads an element of unsigned long integer type.
Reads an unsigned long element from the XML file.
Returns:
The unsigned long value extracted from the current element. Note: because the size of longs may vary between platforms (e.g. 4 bytes on Windows and 8 bytes on OS X), it is advised not to use this function when portability is required.
Implements SBCSerializer::readUnsignedLongElement
function readUnsignedLongLongElement#
Reads an element of unsigned long long integer type.
Reads an unsigned long long element from the XML file.
Returns:
The unsigned long long value extracted from the current element.
Implements SBCSerializer::readUnsignedLongLongElement
function readUnsignedShortElement#
Reads an element of unsigned short integer type.
Reads an unsigned short element from the XML file.
Returns:
The unsigned short value extracted from the current element.
Implements SBCSerializer::readUnsignedShortElement
function writeBoolElement#
Writes an element of boolean type with elementName name and valueelement .
Writes an XML element that contains a boolean value.
Parameters:
elementNameName of the XML element.elementBoolean value to write.
Implements SBCSerializer::writeBoolElement
function writeCharArrayElement#
Writes an element of char array type with elementName name of sizearraySize and valueselementArray .
virtual void SBCSerializerXML::writeCharArrayElement (
const std::string & elementName,
const char * elementArray,
unsigned int arraySize
)
Writes an XML element that contains a character array.
Parameters:
elementNameName of the XML element.elementArrayPointer to the character array to write.arraySizeNumber of characters in the array.
Implements SBCSerializer::writeCharArrayElement
function writeCharElement#
Writes an element of char type with elementName name and valueelement .
Writes an XML element that contains a character value.
Parameters:
elementNameName of the XML element.elementCharacter value to write.
Implements SBCSerializer::writeCharElement
function writeDoubleElement#
Writes an element of double type with elementName name and valueelement .
virtual void SBCSerializerXML::writeDoubleElement (
const std::string & elementName,
double element
)
Writes an XML element that contains a double value.
Parameters:
elementNameName of the XML element.elementDouble value to write.
Implements SBCSerializer::writeDoubleElement
function writeEndElement#
Writes the end element.
Writes the end tag for the most recently opened XML element.
The end tag matches the element name at the top of the internal element stack.
Implements SBCSerializer::writeEndElement
function writeFloatElement#
Writes an element of float type with elementName name and valueelement .
Writes an XML element that contains a float value.
Parameters:
elementNameName of the XML element.elementFloat value to write.
Implements SBCSerializer::writeFloatElement
function writeIntElement#
Writes an element of integer type with elementName name and valueelement .
Writes an XML element that contains an integer value.
Parameters:
elementNameName of the XML element.elementInteger value to write.
Implements SBCSerializer::writeIntElement
function writeLongElement#
Writes an element of long integer type with elementName name and valueelement .
Writes an XML element that contains a long integer value.
The size of a long may differ across platforms; consider using a fixed-size type for portable data.
Parameters:
elementNameName of the XML element.elementLong integer value to write.
Note: because the size of longs may vary between platforms (e.g. 4 bytes on Windows and 8 bytes on OS X), it is advised not to use this function when portability is required.
Implements SBCSerializer::writeLongElement
function writeLongLongElement#
Writes an element of long long integer type with elementName name and valueelement .
virtual void SBCSerializerXML::writeLongLongElement (
const std::string & elementName,
long long element
)
Writes an XML element that contains a long long integer value.
Parameters:
elementNameName of the XML element.elementLong long integer value to write.
Implements SBCSerializer::writeLongLongElement
function writeShortElement#
Writes an element of short integer type with elementName name and valueelement .
Writes an XML element that contains a short integer value.
Parameters:
elementNameName of the XML element.elementShort integer value to write.
Implements SBCSerializer::writeShortElement
function writeStartElement#
Writes the start element with elementName name.
Writes the start tag of an XML element.
The element name is written with appropriate indentation based on the current nesting level.
Parameters:
elementNameName of the XML element to start.
Implements SBCSerializer::writeStartElement
function writeStringElement#
Writes an element of string type with elementName name and valueelement .
virtual void SBCSerializerXML::writeStringElement (
const std::string & elementName,
const std::string & element
)
Writes an XML element that contains a string value.
Parameters:
elementNameName of the XML element.elementString value to write inside the element.
Implements SBCSerializer::writeStringElement
function writeStringElementInBase64#
Writes an element of string type in Base64 (supports html) with elementName name and valueelement .
virtual void SBCSerializerXML::writeStringElementInBase64 (
const std::string & elementName,
const std::string & element
)
Writes an XML element that contains a Base64-encoded string.
Parameters:
elementNameName of the XML element.elementString value to encode in Base64 and write.
Implements SBCSerializer::writeStringElementInBase64
function writeUUIDElement#
Writes an element of UUID type with elementName name and valueelement .
virtual void SBCSerializerXML::writeUUIDElement (
const std::string & elementName,
const SBCContainerUUID & element
)
Writes an XML element that contains a UUID value.
Parameters:
elementNameName of the XML element.elementUUID value to write.
Implements SBCSerializer::writeUUIDElement
function writeUnsignedCharElement#
Writes an element of unsigned char type with elementName name and valueelement .
virtual void SBCSerializerXML::writeUnsignedCharElement (
const std::string & elementName,
unsigned char element
)
Writes an XML element that contains an unsigned character value.
Parameters:
elementNameName of the XML element.elementUnsigned character value to write.
Implements SBCSerializer::writeUnsignedCharElement
function writeUnsignedIntElement#
Writes an element of unsigned integer type with elementName name and valueelement .
virtual void SBCSerializerXML::writeUnsignedIntElement (
const std::string & elementName,
unsigned int element
)
Writes an XML element that contains an unsigned integer value.
Parameters:
elementNameName of the XML element.elementUnsigned integer value to write.
Implements SBCSerializer::writeUnsignedIntElement
function writeUnsignedLongElement#
Writes an element of unsigned long integer type with elementName name and valueelement .
virtual void SBCSerializerXML::writeUnsignedLongElement (
const std::string & elementName,
unsigned long element
)
Writes an XML element that contains an unsigned long integer value.
The size of an unsigned long may differ across platforms; consider using a fixed-size type for portable data.
Parameters:
elementNameName of the XML element.elementUnsigned long integer value to write.
Note: because the size of longs may vary between platforms (e.g. 4 bytes on Windows and 8 bytes on OS X), it is advised not to use this function when portability is required.
Implements SBCSerializer::writeUnsignedLongElement
function writeUnsignedLongLongElement#
Writes an element of unsigned long long integer type with elementName name and valueelement .
virtual void SBCSerializerXML::writeUnsignedLongLongElement (
const std::string & elementName,
unsigned long long element
)
Writes an XML element that contains an unsigned long long integer value.
Parameters:
elementNameName of the XML element.elementUnsigned long long integer value to write.
Implements SBCSerializer::writeUnsignedLongLongElement
function writeUnsignedShortElement#
Writes an element of unsigned short integer type with elementName name and valueelement .
virtual void SBCSerializerXML::writeUnsignedShortElement (
const std::string & elementName,
unsigned short element
)
Writes an XML element that contains an unsigned short integer value.
Parameters:
elementNameName of the XML element.elementUnsigned short integer value to write.
Implements SBCSerializer::writeUnsignedShortElement
function ~SBCSerializerXML#
Destructor.
Destroys the SBCSerializerXML object.
Writes any pending end elements, closes the file, and releases allocated resources.