Web Analytics Made Easy - Statcounter
Skip to content

Class SBCSerializerBinary#

ClassList > SBCSerializerBinary

This class describes a binary serializer. More...

  • #include <SBCSerializerBinary.hpp>

Inherits the following classes: SBCSerializer

Public Functions#

Type Name
SBCSerializerBinary (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 ~SBCSerializerBinary ()
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
std::fstream * file
A pointer to the file stream.

Detailed Description#

Short name: SBSerializerBinary

Public Functions Documentation#

function SBCSerializerBinary#

Constructor.

SBCSerializerBinary::SBCSerializerBinary (
    const std::string & fileName,
    bool write
) 

Constructs a binary serializer for the specified file.

Opens the file in binary mode for reading or writing based on the write flag.

Parameters:

  • fileName The path to the file to open.
  • write True to open the file for writing; false to open for reading.

function readBoolElement#

Reads an element of boolean type.

virtual bool SBCSerializerBinary::readBoolElement () 

Reads a boolean element and returns its value.

Returns:

The boolean value read from the element.

Implements SBCSerializer::readBoolElement


function readCharArrayElement#

Reads an element of char array type of size arraySize .

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

Reads a character array element, allocating memory for the data.

Parameters:

  • arraySize Reference that receives the number of characters in the array.

Returns:

Pointer to a newly allocated character array containing the read data. The caller is responsible for deleting the array.

Implements SBCSerializer::readCharArrayElement


function readCharElement#

Reads an element of char type.

virtual char SBCSerializerBinary::readCharElement () 

Reads a character element and returns its value.

Returns:

The character value read from the element.

Implements SBCSerializer::readCharElement


function readDoubleElement#

Reads an element of double type.

virtual double SBCSerializerBinary::readDoubleElement () 

Reads a double-precision floating-point element and returns its value.

Returns:

The double value read from the element.

Implements SBCSerializer::readDoubleElement


function readEndElement#

Reads the end element.

virtual void SBCSerializerBinary::readEndElement () 

Reads the end of an element.

Implements SBCSerializer::readEndElement


function readFloatElement#

Reads an element of float type.

virtual float SBCSerializerBinary::readFloatElement () 

Reads a floating-point element and returns its value.

Returns:

The float value read from the element.

Implements SBCSerializer::readFloatElement


function readIntElement#

Reads an element of integer type.

virtual int SBCSerializerBinary::readIntElement () 

Reads an integer element and returns its value.

Returns:

The integer value read from the element.

Implements SBCSerializer::readIntElement


function readLongElement#

Reads an element of long integer type.

virtual long SBCSerializerBinary::readLongElement () 

Reads a long integer element and returns its value.

Returns:

The long integer value read from the 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.

virtual long long SBCSerializerBinary::readLongLongElement () 

Reads a long long integer element and returns its value.

Returns:

The long long integer value read from the element.

Implements SBCSerializer::readLongLongElement


function readShortElement#

Reads an element of short integer type.

virtual short SBCSerializerBinary::readShortElement () 

Reads a short integer element and returns its value.

Returns:

The short integer value read from the element.

Implements SBCSerializer::readShortElement


function readStartElement#

Reads the start element.

virtual void SBCSerializerBinary::readStartElement () 

Reads the start of an element.

Implements SBCSerializer::readStartElement


function readStringElement#

Reads an element of string type.

virtual std::string SBCSerializerBinary::readStringElement () 

Reads a string element and returns its value.

Returns:

The string value read from the element.

Implements SBCSerializer::readStringElement


function readStringElementFromBase64#

Reads an element of string type in Base64 (supports html)

virtual std::string SBCSerializerBinary::readStringElementFromBase64 () 

Reads a Base64-encoded string element, decodes it, and returns the original string.

Returns:

The decoded string value.

Implements SBCSerializer::readStringElementFromBase64


function readUUIDElement#

Reads an element of UUID type.

virtual SBCContainerUUID SBCSerializerBinary::readUUIDElement () 

Reads a UUID element and returns its value.

Returns:

The UUID value read from the element.

Implements SBCSerializer::readUUIDElement


function readUnsignedCharElement#

Reads an element of unsigned char type.

virtual unsigned char SBCSerializerBinary::readUnsignedCharElement () 

Reads an unsigned character element and returns its value.

Returns:

The unsigned character value read from the element.

Implements SBCSerializer::readUnsignedCharElement


function readUnsignedIntElement#

Reads an element of unsigned integer type.

virtual unsigned int SBCSerializerBinary::readUnsignedIntElement () 

Reads an unsigned integer element and returns its value.

Returns:

The unsigned integer value read from the element.

Implements SBCSerializer::readUnsignedIntElement


function readUnsignedLongElement#

Reads an element of unsigned long integer type.

virtual unsigned long SBCSerializerBinary::readUnsignedLongElement () 

Reads an unsigned long integer element and returns its value.

Returns:

The unsigned long integer value read from the 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.

virtual unsigned long long SBCSerializerBinary::readUnsignedLongLongElement () 

Reads an unsigned long long integer element and returns its value.

Returns:

The unsigned long long integer value read from the element.

Implements SBCSerializer::readUnsignedLongLongElement


function readUnsignedShortElement#

Reads an element of unsigned short integer type.

virtual unsigned short SBCSerializerBinary::readUnsignedShortElement () 

Reads an unsigned short integer element and returns its value.

Returns:

The unsigned short integer value read from the element.

Implements SBCSerializer::readUnsignedShortElement


function writeBoolElement#

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

virtual void SBCSerializerBinary::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 SBCSerializerBinary::writeCharArrayElement (
    const std::string & elementName,
    const char * elementArray,
    unsigned int arraySize
) 

Writes a character array element with the specified name, data pointer, and size.

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 SBCSerializerBinary::writeCharElement (
    const std::string & elementName,
    char element
) 

Writes a character element with the specified 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 SBCSerializerBinary::writeDoubleElement (
    const std::string & elementName,
    double element
) 

Writes a double-precision floating-point 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 SBCSerializerBinary::writeEndElement () 

Writes the end of the current element.

Implements SBCSerializer::writeEndElement


function writeFloatElement#

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

virtual void SBCSerializerBinary::writeFloatElement (
    const std::string & elementName,
    float element
) 

Writes a floating-point element with the specified 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 SBCSerializerBinary::writeIntElement (
    const std::string & elementName,
    int element
) 

Writes an integer element with the specified 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 SBCSerializerBinary::writeLongElement (
    const std::string & elementName,
    long element
) 

Writes a long integer element with the specified 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 SBCSerializerBinary::writeLongLongElement (
    const std::string & elementName,
    long long element
) 

Writes a long long integer element with the specified 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 SBCSerializerBinary::writeShortElement (
    const std::string & elementName,
    short element
) 

Writes a short integer element with the specified 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 SBCSerializerBinary::writeStartElement (
    const std::string & elementName
) 

Writes the start of an element with the given name.

Parameters:

  • elementName The name of the element to start.

Implements SBCSerializer::writeStartElement


function writeStringElement#

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

virtual void SBCSerializerBinary::writeStringElement (
    const std::string & elementName,
    const std::string & element
) 

Writes a string element with the specified name and value.

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 SBCSerializerBinary::writeStringElementInBase64 (
    const std::string & elementName,
    const std::string & element
) 

Writes a string element with the specified name and value, encoding the value in Base64.

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 SBCSerializerBinary::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 SBCSerializerBinary::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 SBCSerializerBinary::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 SBCSerializerBinary::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 SBCSerializerBinary::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 SBCSerializerBinary::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 ~SBCSerializerBinary#

Destructor.

virtual SBCSerializerBinary::~SBCSerializerBinary () 

Destroys the binary serializer and releases any associated resources.


Protected Attributes Documentation#

variable file#

A pointer to the file stream.

std::fstream* SBCSerializerBinary::file;