#include <base64.hpp>
Public Types | |
typedef std::string::value_type | char_type |
Public Member Functions | |
bindata_deser () | |
template<typename NodeT> | |
bool | operator() (NodeT const &src) |
Decodes base64-encoded data from src and sets this->data to that data, and this->length to the length of that data. | |
Static Public Member Functions | |
static char * | allocate (size_t count) |
Uses malloc() to allocate count bytes. | |
static void | deallocate (bindata_deser &tgt) |
Deallocates tgt.data using free() and sets tgt's values to 0. | |
Public Attributes | |
char_type * | data |
The raw binary data. | |
size_t | length |
The length of the raw binary data. |
It is intended to be used in conjunction with bindata_ser.
The intended usage goes something like this:
bindata_deser bin; deserialize( anS11nNode, bin ); // ... either take over bin.data or deallocate it ...
Definition at line 107 of file base64.hpp.
typedef std::string::value_type s11n::base64::bindata_deser::char_type |
Definition at line 109 of file base64.hpp.
s11n::base64::bindata_deser::bindata_deser | ( | ) | [inline] |
Definition at line 120 of file base64.hpp.
static char* s11n::base64::bindata_deser::allocate | ( | size_t | count | ) | [inline, static] |
Uses malloc() to allocate count bytes.
Returns 0 on error, at least theoretically (depends on the OS's allocator - some always return non-0 with the assumption that memory will become free at some point).
Definition at line 130 of file base64.hpp.
Referenced by operator()().
static void s11n::base64::bindata_deser::deallocate | ( | bindata_deser & | tgt | ) | [inline, static] |
Deallocates tgt.data using free() and sets tgt's values to 0.
Definition at line 139 of file base64.hpp.
bool s11n::base64::bindata_deser::operator() | ( | NodeT const & | src | ) | [inline] |
Decodes base64-encoded data from src and sets this->data to that data, and this->length to the length of that data.
It allocates the memory using malloc(). The caller owns the deserialized data and must deallocate it at some point using free() or deallocate(thisObject).
If src does not appear to contain any data, false is returned. If it contains data but does not appear to be consistent (e.g. decoded data length does not match recorded length) or we cannot allocate enough memory to deserialize then an s11n_exception is thrown.
This is not a terribly efficient routine, requiring several copies of the binary data. Thus it should not be used with very large data sets.
Definition at line 164 of file base64.hpp.
References allocate(), data, s11n::base64::decoder::decode(), length, and S11N_SOURCEINFO.
The raw binary data.
It is set by the deserialize operator.
Definition at line 114 of file base64.hpp.
Referenced by deallocate(), and operator()().
The length of the raw binary data.
It is set by the deserialize operator.
Definition at line 119 of file base64.hpp.
Referenced by deallocate(), and operator()().