s11n::base64::bindata_ser Struct Reference

This is a helper for serializing binary data. More...

#include <base64.hpp>

List of all members.

Public Types

typedef
std::string::value_type 
char_type

Public Member Functions

 bindata_ser (char_type const *begin, size_t n)
 Sets this object to point to begin, which is required to be at least n bytes long.
template<typename NodeT>
bool operator() (NodeT &dest) const
 Stores this->length and the base64-encoded form of this->data.

Public Attributes

char_type const * data
 The binary data we want to serialize.
size_t length
 The length of this->data.


Detailed Description

This is a helper for serializing binary data.

It is a Serializable type, but does not meet all requirements for Serializables (namely, it is not DefaultConstructable). It is to be initialized with a pointer to some binary data (which is limited to a (char const *)) and the length of that data.

The intended usage goes something like this:

       bindata_ser bin( myPtr, lengthOfMyPtr );
       serialize( anS11nNode, bin );

To deserialize it, use bindata_deser.

IMPORTANT WARNINGS:

Serializing binary data this way is not terribly efficient, due to the whole encoding/decoding process. Also most s11n data formats do some sort of entity translation when setting properties, and may peform very poorly when given huge inputs. Some formats may not like newlines in properties (simplexml_serializer comes to mind). Base64-encoded data is also larger than the original binary data. Thus the following recommendations:

Definition at line 55 of file base64.hpp.


Member Typedef Documentation

typedef std::string::value_type s11n::base64::bindata_ser::char_type

Definition at line 57 of file base64.hpp.


Constructor & Destructor Documentation

s11n::base64::bindata_ser::bindata_ser ( char_type const *  begin,
size_t  n 
) [inline]

Sets this object to point to begin, which is required to be at least n bytes long.

Definition at line 67 of file base64.hpp.


Member Function Documentation

template<typename NodeT>
bool s11n::base64::bindata_ser::operator() ( NodeT &  dest  )  const [inline]

Stores this->length and the base64-encoded form of this->data.

Definition at line 75 of file base64.hpp.

References s11n::base64::encoder::encode().


Member Data Documentation

char_type const* s11n::base64::bindata_ser::data

The binary data we want to serialize.

Definition at line 59 of file base64.hpp.

size_t s11n::base64::bindata_ser::length

The length of this->data.

Definition at line 61 of file base64.hpp.


The documentation for this struct was generated from the following file:
Generated on Wed Jun 4 21:47:18 2008 for libs11n by  doxygen 1.5.3