Safir SDK Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Safir::Dob::Typesystem::Serialization Class Reference

Functions for serializing objects to binary and XML forms. More...

#include <Serialization.h>

Static Public Member Functions

static const std::wstring ToXml (const Dob::Typesystem::ObjectPtr object)
 Serialize an object to XML. More...
 
static Dob::Typesystem::ObjectPtr ToObject (const std::wstring &xml)
 Deserialize an XML serialization. More...
 
static const std::wstring ToXml (const BinarySerialization &bin)
 Convert a binary serialization to XML. More...
 
static const std::wstring ToXml (const char *const blob)
 Convert a blob to XML. More...
 
static void ToBinary (const Dob::Typesystem::ObjectPtr object, Dob::Typesystem::BinarySerialization &binary)
 Serialize an object to binary form. More...
 
static Dob::Typesystem::ObjectPtr ToObject (const Dob::Typesystem::BinarySerialization &binary)
 Deserialize a binary serialization and create an object. More...
 

Detailed Description

Functions for serializing objects to binary and XML forms.

Member Function Documentation

static void Safir::Dob::Typesystem::Serialization::ToBinary ( const Dob::Typesystem::ObjectPtr  object,
Dob::Typesystem::BinarySerialization binary 
)
static

Serialize an object to binary form.

The serialization is put into a variable of type BinarySerialization, which is of type std::vector<char>. If you need to get hold of a "raw" C-pointer to the data use &binary[0]. See Effective STL Item 16 for more info.

Parameters
[in]object- The object to serialize
[out]binary- The destination of the serialization
Exceptions
IllegalValueException- There is something wrong with the object.
static Dob::Typesystem::ObjectPtr Safir::Dob::Typesystem::Serialization::ToObject ( const std::wstring &  xml)
static

Deserialize an XML serialization.

This method creates a new object from a given xml serialization. It uses the ObjectFactory to accomplish this.

Parameters
[in]xml- The xml to convert.
Returns
A boost::shared_ptr to the new object
Exceptions
IllegalValueExceptionIf there is something wrong with the XML or if the type represented by the serialization isn't found in the ObjectFactory.
static Dob::Typesystem::ObjectPtr Safir::Dob::Typesystem::Serialization::ToObject ( const Dob::Typesystem::BinarySerialization binary)
static

Deserialize a binary serialization and create an object.

It uses the ObjectFactory to accomplish this. If you have a char * that you want to deserialize the easiest way is to pass it to the ObjectFactory instead.

Parameters
[in]binary- The binary serialization to deserialize.
Returns
A boost::shared_ptr to the new object
Exceptions
IllegalValueExceptionIf the type represented by the serialization isn't found in the ObjectFactory.
static const std::wstring Safir::Dob::Typesystem::Serialization::ToXml ( const Dob::Typesystem::ObjectPtr  object)
static

Serialize an object to XML.

Parameters
[in]object- The object to serialize
Returns
The xml serialization
Exceptions
IllegalValueException- There is something wrong with the object.
static const std::wstring Safir::Dob::Typesystem::Serialization::ToXml ( const BinarySerialization bin)
static

Convert a binary serialization to XML.

Parameters
[in]bin- the binary serialization to convert to xml.
Returns
The xml of the binary serialization.
static const std::wstring Safir::Dob::Typesystem::Serialization::ToXml ( const char *const  blob)
static

Convert a blob to XML.

Parameters
[in]blob- the blob to convert to xml.
Returns
The xml of the blob.

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