#include <base64.hpp>
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. |
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.
typedef std::string::value_type s11n::base64::bindata_ser::char_type |
Definition at line 57 of file base64.hpp.
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.
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().