OpenDaVINCI  4.15.3
odcore::serialization::ProtoSerializer Class Reference

#include <ProtoSerializer.h>

Inheritance diagram for odcore::serialization::ProtoSerializer:
Inheritance graph

Public Types

enum  PROTOBUF_TYPE {
  VARINT = 0, EIGHT_BYTES = 1, LENGTH_DELIMITED = 2, UNUSED_3 = 3,
  UNUSED_4 = 4, FOUR_BYTES = 5, UNUSED_6 = 6, UNUSED_7 = 7
}
 

Public Member Functions

 ProtoSerializer ()
 
 ProtoSerializer (ostream &o)
 
virtual ~ProtoSerializer ()
 
virtual void getSerializedData (ostream &o)
 
virtual uint32_t writeValue (ostream &o, const Serializable &v)
 
virtual uint32_t writeValue (ostream &o, const bool &v)
 
virtual uint32_t writeValue (ostream &o, const char &v)
 
virtual uint32_t writeValue (ostream &o, const unsigned char &v)
 
virtual uint32_t writeValue (ostream &o, const int8_t &v)
 
virtual uint32_t writeValue (ostream &o, const int16_t &v)
 
virtual uint32_t writeValue (ostream &o, const uint16_t &v)
 
virtual uint32_t writeValue (ostream &o, const int32_t &v)
 
virtual uint32_t writeValue (ostream &o, const uint32_t &v)
 
virtual uint32_t writeValue (ostream &o, const int64_t &v)
 
virtual uint32_t writeValue (ostream &o, const uint64_t &v)
 
virtual uint32_t writeValue (ostream &o, const float &v)
 
virtual uint32_t writeValue (ostream &o, const double &v)
 
virtual uint32_t writeValue (ostream &o, const string &v)
 
virtual uint32_t writeValue (ostream &o, const void *data, const uint32_t &size)
 
virtual void write (const uint32_t &id, const Serializable &s)
 
virtual void write (const uint32_t &id, const bool &b)
 
virtual void write (const uint32_t &id, const char &c)
 
virtual void write (const uint32_t &id, const unsigned char &uc)
 
virtual void write (const uint32_t &id, const int8_t &i)
 
virtual void write (const uint32_t &id, const int16_t &i)
 
virtual void write (const uint32_t &id, const uint16_t &ui)
 
virtual void write (const uint32_t &id, const int32_t &i)
 
virtual void write (const uint32_t &id, const uint32_t &ui)
 
virtual void write (const uint32_t &id, const int64_t &i)
 
virtual void write (const uint32_t &id, const uint64_t &ui)
 
virtual void write (const uint32_t &id, const float &f)
 
virtual void write (const uint32_t &id, const double &d)
 
virtual void write (const uint32_t &id, const string &s)
 
virtual void write (const uint32_t &id, const void *data, const uint32_t &size)
 
virtual void write (const uint32_t &id, const string &longName, const string &shortName, const Serializable &s)
 
virtual void write (const uint32_t &id, const string &longName, const string &shortName, const bool &b)
 
virtual void write (const uint32_t &id, const string &longName, const string &shortName, const char &c)
 
virtual void write (const uint32_t &id, const string &longName, const string &shortName, const unsigned char &uc)
 
virtual void write (const uint32_t &id, const string &longName, const string &shortName, const int8_t &i)
 
virtual void write (const uint32_t &id, const string &longName, const string &shortName, const int16_t &i)
 
virtual void write (const uint32_t &id, const string &longName, const string &shortName, const uint16_t &ui)
 
virtual void write (const uint32_t &id, const string &longName, const string &shortName, const int32_t &i)
 
virtual void write (const uint32_t &id, const string &longName, const string &shortName, const uint32_t &ui)
 
virtual void write (const uint32_t &id, const string &longName, const string &shortName, const int64_t &i)
 
virtual void write (const uint32_t &id, const string &longName, const string &shortName, const uint64_t &ui)
 
virtual void write (const uint32_t &id, const string &longName, const string &shortName, const float &f)
 
virtual void write (const uint32_t &id, const string &longName, const string &shortName, const double &d)
 
virtual void write (const uint32_t &id, const string &longName, const string &shortName, const string &s)
 
virtual void write (const uint32_t &id, const string &longName, const string &shortName, const void *data, const uint32_t &size)
 

Static Public Member Functions

static float htonf (float f)
 
static double htond (double d)
 
static uint64_t __htonll (uint64_t ui)
 
static int64_t __htonll (int64_t i)
 

Detailed Description

This class provides a serialization to encode data in Google's Protobuf format.

Member Enumeration Documentation

Enumerator
VARINT 
EIGHT_BYTES 
LENGTH_DELIMITED 
UNUSED_3 
UNUSED_4 
FOUR_BYTES 
UNUSED_6 
UNUSED_7 

Constructor & Destructor Documentation

odcore::serialization::ProtoSerializer::ProtoSerializer ( )
odcore::serialization::ProtoSerializer::ProtoSerializer ( ostream &  o)

Contructor.

Parameters
oStream to serialize data to when the destructor is called.
odcore::serialization::ProtoSerializer::~ProtoSerializer ( )
virtual

References getSerializedData().

Member Function Documentation

uint64_t odcore::serialization::Serializer::__htonll ( uint64_t  ui)
staticinherited

This method converts a uint64_t from host byte order to network byte order.

Parameters
uiuint64_t to be converted.
Returns
ui in NBO.

References odcore::wrapper::IS_BIG_ENDIAN.

Referenced by odcore::serialization::LCMSerializerVisitor::getSerializedData(), and odcore::serialization::QueryableNetstringsSerializerAACF::writeValue().

int64_t odcore::serialization::Serializer::__htonll ( int64_t  i)
staticinherited

This method converts an int64_t from host byte order to network byte order.

Parameters
iint64_t to be converted.
Returns
i in NBO.

References odcore::wrapper::IS_BIG_ENDIAN.

void odcore::serialization::ProtoSerializer::getSerializedData ( ostream &  o)
virtual

This method returns the data in serialized format.

Parameters
oostream object (for instance a stringstream) to serialize the data into.

Implements odcore::serialization::Serializer.

Referenced by ~ProtoSerializer().

double odcore::serialization::Serializer::htond ( double  d)
staticinherited

This method converts a double from host byte order to network byte order.

Parameters
ddouble to be converted.
Returns
d in NBO.

References odcore::wrapper::IS_BIG_ENDIAN.

Referenced by odcore::serialization::QueryableNetstringsSerializerAACF::writeValue(), and odcore::serialization::QueryableNetstringsSerializerABCF::writeValue().

float odcore::serialization::Serializer::htonf ( float  f)
staticinherited

This method converts a float from host byte order to network byte order.

Parameters
ffloat to be converted.
Returns
f in NBO.

References odcore::wrapper::IS_BIG_ENDIAN.

Referenced by odcore::serialization::QueryableNetstringsSerializerAACF::writeValue(), and odcore::serialization::QueryableNetstringsSerializerABCF::writeValue().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const Serializable s 
)
virtual

This method serializes a Serializable.

Parameters
idIdentifier for the s to be serialized.
sSerializable to be serialized.

Implements odcore::serialization::Serializer.

References LENGTH_DELIMITED, and writeValue().

Referenced by odcore::serialization::ProtoSerializerVisitor::visit(), and write().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const bool &  b 
)
virtual

This method serializes a bool.

Parameters
idIdentifier for the b to be serialized.
bBool to be serialized.

Implements odcore::serialization::Serializer.

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const char &  c 
)
virtual

This method serializes a char.

Parameters
idIdentifier for the c to be serialized.
cChar to be serialized.

Implements odcore::serialization::Serializer.

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const unsigned char &  uc 
)
virtual

This method serializes an unsigned char.

Parameters
idIdentifier for the uc to be serialized.
ucUnsigned char to be serialized.

Implements odcore::serialization::Serializer.

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const int8_t &  i 
)
virtual

This method serializes an int.

Parameters
idIdentifier for the i to be serialized.
iInt to be serialized.

Implements odcore::serialization::Serializer.

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const int16_t &  i 
)
virtual

This method serializes an int.

Parameters
idIdentifier for the i to be serialized.
iInt to be serialized.

Implements odcore::serialization::Serializer.

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const uint16_t &  ui 
)
virtual

This method serializes an uint32_t.

Parameters
idIdentifier for the ui to be serialized.
uiUnsigned int32_t to be serialized.

Implements odcore::serialization::Serializer.

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const int32_t &  i 
)
virtual

This method serializes an int.

Parameters
idIdentifier for the i to be serialized.
iInt to be serialized.

Implements odcore::serialization::Serializer.

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const uint32_t &  ui 
)
virtual

This method serializes an uint32_t.

Parameters
idIdentifier for the ui to be serialized.
uiUnsigned int32_t to be serialized.

Implements odcore::serialization::Serializer.

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const int64_t &  i 
)
virtual

This method serializes an int.

Parameters
idIdentifier for the i to be serialized.
iInt to be serialized.

Implements odcore::serialization::Serializer.

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const uint64_t &  ui 
)
virtual

This method serializes an uint32_t.

Parameters
idIdentifier for the ui to be serialized.
uiUnsigned int32_t to be serialized.

Implements odcore::serialization::Serializer.

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const float &  f 
)
virtual

This method serializes a float.

Parameters
idIdentifier for the f to be serialized.
fFloat to be serialized.

Implements odcore::serialization::Serializer.

References FOUR_BYTES, and writeValue().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const double &  d 
)
virtual

This method serializes a double.

Parameters
idIdentifier for the d to be serialized.
dDouble to be serialized.

Implements odcore::serialization::Serializer.

References EIGHT_BYTES, and writeValue().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const string &  s 
)
virtual

This method serializes a string.

Parameters
idIdentifier for the s to be serialized.
sString to be serialized.

Implements odcore::serialization::Serializer.

References LENGTH_DELIMITED, and writeValue().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const void *  data,
const uint32_t &  size 
)
virtual

This method serializes undefined data of length size.

Parameters
idIdentifier for the data to be serialized.
dataData to be serialized.
sizeLength of the data to be serialized.

Implements odcore::serialization::Serializer.

References LENGTH_DELIMITED, and writeValue().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
const Serializable s 
)
virtual

This method serializes a Serializable.

Parameters
idIdentifier for the value to be serialized.
longNameLong string name of the field.
shortNameShort string name of the field.
sSerializable to be serialized.

Implements odcore::serialization::Serializer.

References write().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
const bool &  b 
)
virtual

This method serializes a bool.

Parameters
idIdentifier for the value to be serialized.
longNameLong string name of the field.
shortNameShort string name of the field.
bBool to be serialized.

Implements odcore::serialization::Serializer.

References write().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
const char &  c 
)
virtual

This method serializes a char.

Parameters
idIdentifier for the value to be serialized.
longNameLong string name of the field.
shortNameShort string name of the field.
cChar to be serialized.

Implements odcore::serialization::Serializer.

References write().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
const unsigned char &  uc 
)
virtual

This method serializes an unsigned char.

Parameters
idIdentifier for the value to be serialized.
longNameLong string name of the field.
shortNameShort string name of the field.
ucUnsigned char to be serialized.

Implements odcore::serialization::Serializer.

References write().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
const int8_t &  i 
)
virtual

This method serializes an int.

Parameters
idIdentifier for the value to be serialized.
longNameLong string name of the field.
shortNameShort string name of the field.
iInt to be serialized.

Implements odcore::serialization::Serializer.

References write().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
const int16_t &  i 
)
virtual

This method serializes an int.

Parameters
idIdentifier for the value to be serialized.
longNameLong string name of the field.
shortNameShort string name of the field.
iInt to be serialized.

Implements odcore::serialization::Serializer.

References write().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
const uint16_t &  ui 
)
virtual

This method serializes an uint32_t.

Parameters
idIdentifier for the value to be serialized.
longNameLong string name of the field.
shortNameShort string name of the field.
uiUnsigned int32_t to be serialized.

Implements odcore::serialization::Serializer.

References write().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
const int32_t &  i 
)
virtual

This method serializes an int.

Parameters
idIdentifier for the value to be serialized.
longNameLong string name of the field.
shortNameShort string name of the field.
iInt to be serialized.

Implements odcore::serialization::Serializer.

References write().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
const uint32_t &  ui 
)
virtual

This method serializes an uint32_t.

Parameters
idIdentifier for the value to be serialized.
longNameLong string name of the field.
shortNameShort string name of the field.
uiUnsigned int32_t to be serialized.

Implements odcore::serialization::Serializer.

References write().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
const int64_t &  i 
)
virtual

This method serializes an int.

Parameters
idIdentifier for the value to be serialized.
longNameLong string name of the field.
shortNameShort string name of the field.
iInt to be serialized.

Implements odcore::serialization::Serializer.

References write().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
const uint64_t &  ui 
)
virtual

This method serializes an uint32_t.

Parameters
idIdentifier for the value to be serialized.
longNameLong string name of the field.
shortNameShort string name of the field.
uiUnsigned int32_t to be serialized.

Implements odcore::serialization::Serializer.

References write().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
const float &  f 
)
virtual

This method serializes a float.

Parameters
idIdentifier for the value to be serialized.
longNameLong string name of the field.
shortNameShort string name of the field.
fFloat to be serialized.

Implements odcore::serialization::Serializer.

References write().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
const double &  d 
)
virtual

This method serializes a double.

Parameters
idIdentifier for the value to be serialized.
longNameLong string name of the field.
shortNameShort string name of the field.
dDouble to be serialized.

Implements odcore::serialization::Serializer.

References write().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
const string &  s 
)
virtual

This method serializes a string.

Parameters
idIdentifier for the value to be serialized.
longNameLong string name of the field.
shortNameShort string name of the field.
sString to be serialized.

Implements odcore::serialization::Serializer.

References write().

void odcore::serialization::ProtoSerializer::write ( const uint32_t &  id,
const string &  longName,
const string &  shortName,
const void *  data,
const uint32_t &  size 
)
virtual

This method serializes undefined data of length size.

Parameters
idIdentifier for the value to be serialized.
longNameLong string name of the field.
shortNameShort string name of the field.
dataData to be serialized.
sizeLength of the data to be serialized.

Implements odcore::serialization::Serializer.

References write().

uint32_t odcore::serialization::ProtoSerializer::writeValue ( ostream &  o,
const Serializable v 
)
virtual

This method serializes the given value using raw encoding for values of this Serializer implementation.

Parameters
oStream to be used for serialization.
vValue to be serialized.
Returns
Number of bytes written for serialization.

Implements odcore::serialization::Serializer.

Referenced by write().

uint32_t odcore::serialization::ProtoSerializer::writeValue ( ostream &  o,
const bool &  v 
)
virtual

This method serializes the given value using raw encoding for values of this Serializer implementation.

Parameters
oStream to be used for serialization.
vValue to be serialized.
Returns
Number of bytes written for serialization.

Implements odcore::serialization::Serializer.

uint32_t odcore::serialization::ProtoSerializer::writeValue ( ostream &  o,
const char &  v 
)
virtual

This method serializes the given value using raw encoding for values of this Serializer implementation.

Parameters
oStream to be used for serialization.
vValue to be serialized.
Returns
Number of bytes written for serialization.

Implements odcore::serialization::Serializer.

uint32_t odcore::serialization::ProtoSerializer::writeValue ( ostream &  o,
const unsigned char &  v 
)
virtual

This method serializes the given value using raw encoding for values of this Serializer implementation.

Parameters
oStream to be used for serialization.
vValue to be serialized.
Returns
Number of bytes written for serialization.

Implements odcore::serialization::Serializer.

uint32_t odcore::serialization::ProtoSerializer::writeValue ( ostream &  o,
const int8_t &  v 
)
virtual

This method serializes the given value using raw encoding for values of this Serializer implementation.

Parameters
oStream to be used for serialization.
vValue to be serialized.
Returns
Number of bytes written for serialization.

Implements odcore::serialization::Serializer.

uint32_t odcore::serialization::ProtoSerializer::writeValue ( ostream &  o,
const int16_t &  v 
)
virtual

This method serializes the given value using raw encoding for values of this Serializer implementation.

Parameters
oStream to be used for serialization.
vValue to be serialized.
Returns
Number of bytes written for serialization.

Implements odcore::serialization::Serializer.

uint32_t odcore::serialization::ProtoSerializer::writeValue ( ostream &  o,
const uint16_t &  v 
)
virtual

This method serializes the given value using raw encoding for values of this Serializer implementation.

Parameters
oStream to be used for serialization.
vValue to be serialized.
Returns
Number of bytes written for serialization.

Implements odcore::serialization::Serializer.

uint32_t odcore::serialization::ProtoSerializer::writeValue ( ostream &  o,
const int32_t &  v 
)
virtual

This method serializes the given value using raw encoding for values of this Serializer implementation.

Parameters
oStream to be used for serialization.
vValue to be serialized.
Returns
Number of bytes written for serialization.

Implements odcore::serialization::Serializer.

uint32_t odcore::serialization::ProtoSerializer::writeValue ( ostream &  o,
const uint32_t &  v 
)
virtual

This method serializes the given value using raw encoding for values of this Serializer implementation.

Parameters
oStream to be used for serialization.
vValue to be serialized.
Returns
Number of bytes written for serialization.

Implements odcore::serialization::Serializer.

uint32_t odcore::serialization::ProtoSerializer::writeValue ( ostream &  o,
const int64_t &  v 
)
virtual

This method serializes the given value using raw encoding for values of this Serializer implementation.

Parameters
oStream to be used for serialization.
vValue to be serialized.
Returns
Number of bytes written for serialization.

Implements odcore::serialization::Serializer.

uint32_t odcore::serialization::ProtoSerializer::writeValue ( ostream &  o,
const uint64_t &  v 
)
virtual

This method serializes the given value using raw encoding for values of this Serializer implementation.

Parameters
oStream to be used for serialization.
vValue to be serialized.
Returns
Number of bytes written for serialization.

Implements odcore::serialization::Serializer.

uint32_t odcore::serialization::ProtoSerializer::writeValue ( ostream &  o,
const float &  v 
)
virtual

This method serializes the given value using raw encoding for values of this Serializer implementation.

Parameters
oStream to be used for serialization.
vValue to be serialized.
Returns
Number of bytes written for serialization.

Implements odcore::serialization::Serializer.

uint32_t odcore::serialization::ProtoSerializer::writeValue ( ostream &  o,
const double &  v 
)
virtual

This method serializes the given value using raw encoding for values of this Serializer implementation.

Parameters
oStream to be used for serialization.
vValue to be serialized.
Returns
Number of bytes written for serialization.

Implements odcore::serialization::Serializer.

uint32_t odcore::serialization::ProtoSerializer::writeValue ( ostream &  o,
const string &  v 
)
virtual

This method serializes the given value using raw encoding for values of this Serializer implementation.

Parameters
oStream to be used for serialization.
vValue to be serialized.
Returns
Number of bytes written for serialization.

Implements odcore::serialization::Serializer.

uint32_t odcore::serialization::ProtoSerializer::writeValue ( ostream &  o,
const void *  data,
const uint32_t &  size 
)
virtual

This method serializes undefined data of length size using the raw encoding for values of this Serializer implementation.

Parameters
oStream to be used for serialization.
dataData to be serialized.
sizeLength of the data to be serialized.
Returns
Number of bytes written for serialization.

Implements odcore::serialization::Serializer.