Class SBCSerializerMemory#
ClassList > SBCSerializerMemory
This class describes a serializer in memory. More...
#include <SBCSerializerMemory.hpp>
Inherits the following classes: SBCSerializer
Public Functions#
| Type | Name |
|---|---|
| SBCSerializerMemory () Constructor. |
|
| void | clear () Clears the internal data buffer. |
| char * | getData () const Retrieves a pointer to the internal serialized data buffer. |
| unsigned int | getDataSize () const Retrieves the size of the internal serialized data buffer. |
| 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. |
| void | rewind () Resets the read/write position to the beginning of the buffer. |
| 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 | ~SBCSerializerMemory () 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. |
Protected Attributes#
| Type | Name |
|---|---|
| SBVector< char > * | dataVector |
| unsigned int | position |
Protected Functions#
| Type | Name |
|---|---|
| void | readCharArray (char * charArray, unsigned int arraySize) Reads raw data bytes from the internal buffer. |
| void | writeCharArray (const char * elementArray, unsigned int arraySize) Writes raw data bytes to the internal buffer. |
Detailed Description#
Short name: SBSerializerMemory
Public Functions Documentation#
function SBCSerializerMemory#
Constructor.
Constructs an SBCSerializerMemory object.
Initializes the internal buffer and sets the position to zero.
function clear#
Clears the internal data buffer.
function getData#
Retrieves a pointer to the internal serialized data buffer.
Returns:
Pointer to the data buffer, or null if the buffer is empty.
function getDataSize#
Retrieves the size of the internal serialized data buffer.
Returns:
Number of bytes stored in the buffer.
function readBoolElement#
Reads an element of boolean type.
Reads a boolean element from the memory buffer.
Deserializes the boolean value from the memory buffer.
Returns:
The boolean value that was read.
Implements SBCSerializer::readBoolElement
function readCharArrayElement#
Reads an element of char array type of size arraySize .
Reads a character array element from the memory buffer.
Parameters:
arraySizeReference that receives the size of the array.
Returns:
Pointer to a newly allocated character array containing the data.
Implements SBCSerializer::readCharArrayElement
function readCharElement#
Reads an element of char type.
Reads a character element from the memory buffer.
Deserializes the character value from the memory buffer.
Returns:
The character value that was read.
Implements SBCSerializer::readCharElement
function readDoubleElement#
Reads an element of double type.
Reads a double element from the memory buffer.
Returns:
The double value that was read.
Implements SBCSerializer::readDoubleElement
function readEndElement#
Reads the end element.
Reads the end element marker.
Implements SBCSerializer::readEndElement
function readFloatElement#
Reads an element of float type.
Reads a float element from the memory buffer.
Returns:
The float value that was read.
Implements SBCSerializer::readFloatElement
function readIntElement#
Reads an element of integer type.
Reads an integer element from the memory buffer.
Deserializes the integer value from the memory buffer.
Returns:
The integer value that was read.
Implements SBCSerializer::readIntElement
function readLongElement#
Reads an element of long integer type.
Reads a long integer element from the memory buffer.
Returns:
The long integer value that was read. 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 integer element from the memory buffer.
Returns:
The long long integer value that was read.
Implements SBCSerializer::readLongLongElement
function readShortElement#
Reads an element of short integer type.
Reads a short integer element from the memory buffer.
Deserializes the short integer value from the memory buffer.
Returns:
The short integer value that was read.
Implements SBCSerializer::readShortElement
function readStartElement#
Reads the start element.
Reads the start element marker.
Implements SBCSerializer::readStartElement
function readStringElement#
Reads an element of string type.
Reads a string element from the memory buffer.
Deserializes the string by reading its length and characters from the memory buffer.
Returns:
The string value that was read.
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 memory buffer.
Returns:
The UUID value that was read.
Implements SBCSerializer::readUUIDElement
function readUnsignedCharElement#
Reads an element of unsigned char type.
Reads an unsigned character element from the memory buffer.
Deserializes the unsigned character value from the memory buffer.
Returns:
The unsigned character value that was read.
Implements SBCSerializer::readUnsignedCharElement
function readUnsignedIntElement#
Reads an element of unsigned integer type.
Reads an unsigned integer element from the memory buffer.
Deserializes the unsigned integer value from the memory buffer.
Returns:
The unsigned integer value that was read.
Implements SBCSerializer::readUnsignedIntElement
function readUnsignedLongElement#
Reads an element of unsigned long integer type.
Reads an unsigned long integer element from the memory buffer.
Returns:
The unsigned long integer value that was read. 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 integer element from the memory buffer.
Returns:
The unsigned long long integer value that was read.
Implements SBCSerializer::readUnsignedLongLongElement
function readUnsignedShortElement#
Reads an element of unsigned short integer type.
Reads an unsigned short integer element from the memory buffer.
Deserializes the unsigned short integer value from the memory buffer.
Returns:
The unsigned short integer value that was read.
Implements SBCSerializer::readUnsignedShortElement
function rewind#
Resets the read/write position to the beginning of the buffer.
function writeBoolElement#
Writes an element of boolean type with elementName name and valueelement .
virtual void SBCSerializerMemory::writeBoolElement (
const std::string & elementName,
bool element
)
Writes a boolean element with the given name and value.
Parameters:
elementNameThe name of the element.elementThe boolean value to write.
Implements SBCSerializer::writeBoolElement
function writeCharArrayElement#
Writes an element of char array type with elementName name of sizearraySize and valueselementArray .
virtual void SBCSerializerMemory::writeCharArrayElement (
const std::string & elementName,
const char * elementArray,
unsigned int arraySize
)
Writes a character array element with the given name and size.
Serializes the size and contents of the character array into the memory buffer.
Parameters:
elementNameThe name of the element.elementArrayPointer to the character array data.arraySizeNumber of characters in the array.
Implements SBCSerializer::writeCharArrayElement
function writeCharElement#
Writes an element of char type with elementName name and valueelement .
virtual void SBCSerializerMemory::writeCharElement (
const std::string & elementName,
char element
)
Writes a character element with the given name and value.
Parameters:
elementNameThe name of the element.elementThe character value to write.
Implements SBCSerializer::writeCharElement
function writeDoubleElement#
Writes an element of double type with elementName name and valueelement .
virtual void SBCSerializerMemory::writeDoubleElement (
const std::string & elementName,
double element
)
Writes a double element with the given name and value.
Parameters:
elementNameThe name of the element.elementThe double value to write.
Implements SBCSerializer::writeDoubleElement
function writeEndElement#
Writes the end element.
Writes the end element marker.
Implements SBCSerializer::writeEndElement
function writeFloatElement#
Writes an element of float type with elementName name and valueelement .
virtual void SBCSerializerMemory::writeFloatElement (
const std::string & elementName,
float element
)
Writes a float element with the given name and value.
Parameters:
elementNameThe name of the element.elementThe float value to write.
Implements SBCSerializer::writeFloatElement
function writeIntElement#
Writes an element of integer type with elementName name and valueelement .
Writes an integer element with the given name and value.
Parameters:
elementNameThe name of the element.elementThe integer value to write.
Implements SBCSerializer::writeIntElement
function writeLongElement#
Writes an element of long integer type with elementName name and valueelement .
virtual void SBCSerializerMemory::writeLongElement (
const std::string & elementName,
long element
)
Writes a long integer element with the given name and value.
Parameters:
elementNameThe name of the element.elementThe 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::writeLongElement
function writeLongLongElement#
Writes an element of long long integer type with elementName name and valueelement .
virtual void SBCSerializerMemory::writeLongLongElement (
const std::string & elementName,
long long element
)
Writes a long long integer element with the given name and value.
Parameters:
elementNameThe name of the element.elementThe long long integer value to write.
Implements SBCSerializer::writeLongLongElement
function writeShortElement#
Writes an element of short integer type with elementName name and valueelement .
virtual void SBCSerializerMemory::writeShortElement (
const std::string & elementName,
short element
)
Writes a short integer element with the given name and value.
Parameters:
elementNameThe name of the element.elementThe short integer value to write.
Implements SBCSerializer::writeShortElement
function writeStartElement#
Writes the start element with elementName name.
Writes the start element with the specified name.
Parameters:
elementNameThe name of the start element.
Implements SBCSerializer::writeStartElement
function writeStringElement#
Writes an element of string type with elementName name and valueelement .
virtual void SBCSerializerMemory::writeStringElement (
const std::string & elementName,
const std::string & element
)
Writes a string element with the given name and value to the memory buffer.
Serializes the string's length and contents into the internal memory buffer.
Parameters:
elementNameThe name of the element.elementThe string value to write.
Implements SBCSerializer::writeStringElement
function writeStringElementInBase64#
Writes an element of string type in Base64 (supports html) with elementName name and valueelement .
virtual void SBCSerializerMemory::writeStringElementInBase64 (
const std::string & elementName,
const std::string & element
)
Writes a string element encoded in Base64 with the given name.
Encodes the string value in Base64 and writes it as a string element.
Parameters:
elementNameThe name of the element.elementThe string value to encode and write.
Implements SBCSerializer::writeStringElementInBase64
function writeUUIDElement#
Writes an element of UUID type with elementName name and valueelement .
virtual void SBCSerializerMemory::writeUUIDElement (
const std::string & elementName,
const SBCContainerUUID & element
)
Writes a UUID element with the given name and value.
Parameters:
elementNameThe name of the element.elementThe UUID value to write.
Implements SBCSerializer::writeUUIDElement
function writeUnsignedCharElement#
Writes an element of unsigned char type with elementName name and valueelement .
virtual void SBCSerializerMemory::writeUnsignedCharElement (
const std::string & elementName,
unsigned char element
)
Writes an unsigned character element with the given name and value.
Parameters:
elementNameThe name of the element.elementThe unsigned character value to write.
Implements SBCSerializer::writeUnsignedCharElement
function writeUnsignedIntElement#
Writes an element of unsigned integer type with elementName name and valueelement .
virtual void SBCSerializerMemory::writeUnsignedIntElement (
const std::string & elementName,
unsigned int element
)
Writes an unsigned integer element with the given name and value.
Parameters:
elementNameThe name of the element.elementThe unsigned integer value to write.
Implements SBCSerializer::writeUnsignedIntElement
function writeUnsignedLongElement#
Writes an element of unsigned long integer type with elementName name and valueelement .
virtual void SBCSerializerMemory::writeUnsignedLongElement (
const std::string & elementName,
unsigned long element
)
Writes an unsigned long integer element with the given name and value.
Parameters:
elementNameThe name of the element.elementThe unsigned 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 SBCSerializerMemory::writeUnsignedLongLongElement (
const std::string & elementName,
unsigned long long element
)
Writes an unsigned long long integer element with the given name and value.
Parameters:
elementNameThe name of the element.elementThe unsigned 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 SBCSerializerMemory::writeUnsignedShortElement (
const std::string & elementName,
unsigned short element
)
Writes an unsigned short integer element with the given name and value.
Parameters:
elementNameThe name of the element.elementThe unsigned short integer value to write.
Implements SBCSerializer::writeUnsignedShortElement
function ~SBCSerializerMemory#
Destructor.
Destroys the SBCSerializerMemory object and releases allocated resources.
Protected Attributes Documentation#
variable dataVector#
variable position#
Protected Functions Documentation#
function readCharArray#
Reads raw data bytes from the internal buffer.
Parameters:
elementArrayPointer to a buffer that will receive the data.arraySizeNumber of bytes to read.
function writeCharArray#
Writes raw data bytes to the internal buffer.
Parameters:
elementArrayPointer to the data to write.arraySizeNumber of bytes to write.