ContRap-Core
Data Structures | Public Member Functions | Static Public Member Functions | Protected Attributes

crp::Serializer Class Reference

Class Serializer is a weak typed representation of objects for sending them through a serial stream. More...

#include <serializer.h>

Data Structures

class  Block
 Serializer block. More...

Public Member Functions

 Serializer (const std::string &type_name)
 Creates an empty serializer.
 ~Serializer ()
 Releases the memory.
void add_int (const std::string &name, int value)
 Adds an integer value to the serializer.
void add_block (const std::string &name, char *buffer, size_t size)
 Adds a data block to the serialized data.
int get_int (const std::string &name) const
 Returns an integer value.
Blockget_block (const std::string &name)
 Returns the block of serialized data or a zero pointer if no such block exists.
std::string serialize () const
 Returns the serialized representation of the object.
const std::string & get_type_name () const
 Returns the type name of the serialized object.

Static Public Member Functions

static Serializerunserialize (const std::string &value)
 Creates a serializer from a string representation.

Protected Attributes

std::map< std::string, Blockblocks
 List of serializer blocks.
std::string type_name
 Type name of the serialized object.

Detailed Description

Class Serializer is a weak typed representation of objects for sending them through a serial stream.


Constructor & Destructor Documentation

crp::Serializer::Serializer ( const std::string &  type_name)

Creates an empty serializer.

Parameters:
type_nameName of the type for the serializer
crp::Serializer::~Serializer ( )

Releases the memory.


Member Function Documentation

void crp::Serializer::add_block ( const std::string &  name,
char *  buffer,
size_t  size 
)

Adds a data block to the serialized data.

Parameters:
nameName of the block
bufferAddress of the node
sizeSize of the node
void crp::Serializer::add_int ( const std::string &  name,
int  value 
)

Adds an integer value to the serializer.

Parameters:
nameName of the block
valueInteger value
Block* crp::Serializer::get_block ( const std::string &  name)

Returns the block of serialized data or a zero pointer if no such block exists.

Parameters:
nameName of the block
Returns:
Data block
int crp::Serializer::get_int ( const std::string &  name) const

Returns an integer value.

Parameters:
nameName of the block
Returns:
Corresponding integer value
const std::string& crp::Serializer::get_type_name ( ) const [inline]

Returns the type name of the serialized object.

Returns:
Type name
std::string crp::Serializer::serialize ( ) const

Returns the serialized representation of the object.

Returns:
String with the serialized representation of the object
static Serializer* crp::Serializer::unserialize ( const std::string &  value) [static]

Creates a serializer from a string representation.

Parameters:
valueSerialized object
Returns:
New serializer object

Field Documentation

std::map<std::string, Block> crp::Serializer::blocks [protected]

List of serializer blocks.

std::string crp::Serializer::type_name [protected]

Type name of the serialized object.


The documentation for this class was generated from the following file: