Web Analytics Made Easy - Statcounter
Skip to content

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.

SBCSerializerMemory::SBCSerializerMemory () 

Constructs an SBCSerializerMemory object.

Initializes the internal buffer and sets the position to zero.


function clear#

Clears the internal data buffer.

void SBCSerializerMemory::clear () 


function getData#

Retrieves a pointer to the internal serialized data buffer.

char * SBCSerializerMemory::getData () const

Returns:

Pointer to the data buffer, or null if the buffer is empty.


function getDataSize#

Retrieves the size of the internal serialized data buffer.

unsigned int SBCSerializerMemory::getDataSize () const

Returns:

Number of bytes stored in the buffer.


function readBoolElement#

Reads an element of boolean type.

virtual bool SBCSerializerMemory::readBoolElement () 

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 .

virtual char * SBCSerializerMemory::readCharArrayElement (
    unsigned int & arraySize
) 

Reads a character array element from the memory buffer.

Parameters:

  • arraySize Reference 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.

virtual char SBCSerializerMemory::readCharElement () 

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.

virtual double SBCSerializerMemory::readDoubleElement () 

Reads a double element from the memory buffer.

Returns:

The double value that was read.

Implements SBCSerializer::readDoubleElement


function readEndElement#

Reads the end element.

virtual void SBCSerializerMemory::readEndElement () 

Reads the end element marker.

Implements SBCSerializer::readEndElement


function readFloatElement#

Reads an element of float type.

virtual float SBCSerializerMemory::readFloatElement () 

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.

virtual int SBCSerializerMemory::readIntElement () 

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.

virtual long SBCSerializerMemory::readLongElement () 

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.

virtual long long SBCSerializerMemory::readLongLongElement () 

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.

virtual short SBCSerializerMemory::readShortElement () 

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.

virtual void SBCSerializerMemory::readStartElement () 

Reads the start element marker.

Implements SBCSerializer::readStartElement


function readStringElement#

Reads an element of string type.

virtual std::string SBCSerializerMemory::readStringElement () 

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)

virtual std::string SBCSerializerMemory::readStringElementFromBase64 () 

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.

virtual SBCContainerUUID SBCSerializerMemory::readUUIDElement () 

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.

virtual unsigned char SBCSerializerMemory::readUnsignedCharElement () 

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.

virtual unsigned int SBCSerializerMemory::readUnsignedIntElement () 

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.

virtual unsigned long SBCSerializerMemory::readUnsignedLongElement () 

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.

virtual unsigned long long SBCSerializerMemory::readUnsignedLongLongElement () 

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.

virtual unsigned short SBCSerializerMemory::readUnsignedShortElement () 

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.

void SBCSerializerMemory::rewind () 


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:

  • elementName The name of the element.
  • element The 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:

  • elementName The name of the element.
  • elementArray Pointer to the character array data.
  • arraySize Number 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:

  • elementName The name of the element.
  • element The 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:

  • elementName The name of the element.
  • element The double value to write.

Implements SBCSerializer::writeDoubleElement


function writeEndElement#

Writes the end element.

virtual void SBCSerializerMemory::writeEndElement () 

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:

  • elementName The name of the element.
  • element The float value to write.

Implements SBCSerializer::writeFloatElement


function writeIntElement#

Writes an element of integer type with elementName name and valueelement .

virtual void SBCSerializerMemory::writeIntElement (
    const std::string & elementName,
    int element
) 

Writes an integer element with the given name and value.

Parameters:

  • elementName The name of the element.
  • element The 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:

  • elementName The name of the element.
  • element The 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:

  • elementName The name of the element.
  • element The 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:

  • elementName The name of the element.
  • element The short integer value to write.

Implements SBCSerializer::writeShortElement


function writeStartElement#

Writes the start element with elementName name.

virtual void SBCSerializerMemory::writeStartElement (
    const std::string & elementName
) 

Writes the start element with the specified name.

Parameters:

  • elementName The 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:

  • elementName The name of the element.
  • element The 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:

  • elementName The name of the element.
  • element The 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:

  • elementName The name of the element.
  • element The 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:

  • elementName The name of the element.
  • element The 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:

  • elementName The name of the element.
  • element The 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:

  • elementName The name of the element.
  • element The 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:

  • elementName The name of the element.
  • element The 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:

  • elementName The name of the element.
  • element The unsigned short integer value to write.

Implements SBCSerializer::writeUnsignedShortElement


function ~SBCSerializerMemory#

Destructor.

virtual SBCSerializerMemory::~SBCSerializerMemory () 

Destroys the SBCSerializerMemory object and releases allocated resources.


Protected Attributes Documentation#

variable dataVector#

SBVector<char>* SBCSerializerMemory::dataVector;

variable position#

unsigned int SBCSerializerMemory::position;

Protected Functions Documentation#

function readCharArray#

Reads raw data bytes from the internal buffer.

void SBCSerializerMemory::readCharArray (
    char * charArray,
    unsigned int arraySize
) 

Parameters:

  • elementArray Pointer to a buffer that will receive the data.
  • arraySize Number of bytes to read.

function writeCharArray#

Writes raw data bytes to the internal buffer.

void SBCSerializerMemory::writeCharArray (
    const char * elementArray,
    unsigned int arraySize
) 

Parameters:

  • elementArray Pointer to the data to write.
  • arraySize Number of bytes to write.