public

Inheritance Graph

graph BT
	GenericAttributeSerialization
	click GenericAttributeSerialization "classUtil_1_1GenericAttributeSerialization"

Description

Serialization for GenericAttribute .

Class for serialization and unserialization of GenericAttribute objects.

Author: Benjamin Eikel

Date: 2012-03-12

Public Types

   
   
typedef std::pair< std::string, std::string > serializer_type_t
   
typedef std::pair< const GenericAttribute *, const GenericAttributeMap * > serializer_parameter_t
   
typedef GenericAttribute * unserializer_type_t
   
typedef std::pair< std::string, const GenericAttributeMap * > unserializer_parameter_t

Public Static Functions

   
   
bool init()
   
std::string serialize(const GenericAttribute * attribute)
   
std::string serialize(const GenericAttribute * attribute, const GenericAttributeMap * context)
   
GenericAttribute * unserialize(const std::string & representation)
   
GenericAttribute * unserialize(const std::string & representation, const GenericAttributeMap * context)
template< typename AttributeType >  
bool registerSerializer(const std::string & typeName, const std::function< serializer_type_t (const serializer_parameter_t &)> & serializer, const std::function< unserializer_type_t (const unserializer_parameter_t &)> & unserializer)

Documentation

typedef
Util::GenericAttributeSerialization::serializer_type_t

public
 
 
typedef std::pair< std::string, std::string > serializer_type_t

Defined in Util/GenericAttributeSerialization.h:34


typedef
Util::GenericAttributeSerialization::serializer_parameter_t

public
 
 
typedef std::pair< const GenericAttribute *, const GenericAttributeMap * > serializer_parameter_t

Defined in Util/GenericAttributeSerialization.h:36


typedef
Util::GenericAttributeSerialization::unserializer_type_t

public
 
 
typedef GenericAttribute * unserializer_type_t

Defined in Util/GenericAttributeSerialization.h:38


typedef
Util::GenericAttributeSerialization::unserializer_parameter_t

public
 
 
typedef std::pair< std::string, const GenericAttributeMap * > unserializer_parameter_t

Defined in Util/GenericAttributeSerialization.h:40


function
Util::GenericAttributeSerialization::init

public static
   
   
bool init( )

Initialize the serializers for the standard GenericAttributes. This function has to be called at least once before using the class. It is called from init.

Parameters

true
if the initialization was successful
false
if an error occurred

Defined in Util/GenericAttributeSerialization.h:62


function
Util::GenericAttributeSerialization::serialize

public static
     
     
std::string serialize( const GenericAttribute * attribute )

Convert the given generic attribute to a string. The string is a JSON representation of the generic attribute. It is constructed as follows:

{
    "type" : "[string identifying the type]",
    "value" : "[string representation of the content]"
}

Parameters

attribute
Generic attribute that is to be converted

Returns

String representation

Defined in Util/GenericAttributeSerialization.h:78


function
Util::GenericAttributeSerialization::serialize

public static
     
     
std::string serialize( const GenericAttribute * attribute,
  const GenericAttributeMap * context
)    

Convert the given generic attribute to a string. Use the given context to look up further information that is needed.

Parameters

attribute
Generic attribute that is to be converted
context
A map containing specific information that is needed during unserialization

Returns

String representation

Defined in Util/GenericAttributeSerialization.h:89


function
Util::GenericAttributeSerialization::unserialize

public static
     
     
GenericAttribute * unserialize( const std::string & representation )

Convert the given string representation to a generic attribute.

Parameters

representation
String representation that was created by serialize()

Returns

Newly constructed, generic attribute

Note: The caller has to free the memory for the generic attribute.

Defined in Util/GenericAttributeSerialization.h:100


function
Util::GenericAttributeSerialization::unserialize

public static
     
     
GenericAttribute * unserialize( const std::string & representation,
  const GenericAttributeMap * context
)    

Convert the given string representation to a generic attribute. Use the given context to look up further information that is needed.

Parameters

representation
String representation that was created by serialize()
context
A map containing specific information that is needed during unserialization

Returns

Newly constructed, generic attribute

Note: The caller has to free the memory for the generic attribute.

Defined in Util/GenericAttributeSerialization.h:113


function
Util::GenericAttributeSerialization::registerSerializer

public static inline
     
template< typename AttributeType >    
bool registerSerializer( const std::string & typeName,
  const std::function< serializer_type_t (const serializer_parameter_t &)> & serializer,
  const std::function< unserializer_type_t (const unserializer_parameter_t &)> & unserializer
)    

Register a serializer and unserializer for a generic attribute type.

Parameters

AttributeType
Type of the generic attribute to be registered

Parameters

typeName
String representation of the generic attribute type that has to be unique for generic attribute serialization
serializer
Serializer function converting a generic attribute into atypeNameand a string representation of the content
unserialize
Unserializer function reconstructing a generic attribute from a string representation

Returns

trueif both functions have been registered successfully,falseotherwise

Note: Any previous functions for the given type are unregistered

Defined in Util/GenericAttributeSerialization.h:127