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.
|
Block * | get_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 Serializer * | unserialize (const std::string &value) |
| Creates a serializer from a string representation.
|
Protected Attributes |
std::map< std::string, Block > | blocks |
| 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_name | Name of the type for the serializer |
crp::Serializer::~Serializer |
( |
| ) |
|
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:
-
name | Name of the block |
buffer | Address of the node |
size | Size of the node |
void crp::Serializer::add_int |
( |
const std::string & |
name, |
|
|
int |
value |
|
) |
| |
Adds an integer value to the serializer.
- Parameters:
-
name | Name of the block |
value | Integer 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:
-
- Returns:
- Data block
int crp::Serializer::get_int |
( |
const std::string & |
name | ) |
const |
Returns an integer value.
- Parameters:
-
- 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:
-
- Returns:
- New serializer object
Field Documentation
List of serializer blocks.
Type name of the serialized object.
The documentation for this class was generated from the following file: