![]() |
QxOrm
1.4.4
C++ Object Relational Mapping library
|
Portable binary output archive using little endian format. More...
#include <portable_oarchive.hpp>
Classes | |
struct | dummy |
Public Member Functions | |
template<class T > | |
boost::disable_if < boost::is_arithmetic< T > >::type | save (const T &t, dummy< 1 >=0) |
Default fall through for non-arithmetic types (ie. strings) | |
void | save (const bool &b) |
Saving bool directly. | |
template<typename T > | |
boost::enable_if < std::is_integral< T > >::type | save (const T &t, dummy< 2 >=0) |
Save integer types. | |
template<typename T > | |
boost::enable_if < boost::is_floating_point< T > >::type | save (const T &t, dummy< 3 >=0) |
Save floating point types. | |
portable_oarchive (std::ostream &os, unsigned flags=0) | |
always construct on a stream using ios::binary mode! | |
Private Member Functions | |
void | save_signed_char (const signed char &c) |
Portable binary output archive using little endian format.
This archive addresses integer size, endianness and floating point types so that data can be transferred across different systems. The archive consists primarily of three different save implementations for integral types, floating point types and string types. Those functions are templates and use enable_if to be correctly selected for overloading.
Definition at line 142 of file portable_oarchive.hpp.
eos::portable_oarchive::portable_oarchive | ( | std::ostream & | os, |
unsigned | flags = 0 |
||
) | [inline] |
always construct on a stream using ios::binary mode!
Definition at line 258 of file portable_oarchive.hpp.
boost::disable_if<boost::is_arithmetic<T> >::type eos::portable_oarchive::save | ( | const T & | t, |
dummy< 1 > | = 0 |
||
) | [inline] |
Default fall through for non-arithmetic types (ie. strings)
Definition at line 163 of file portable_oarchive.hpp.
void eos::portable_oarchive::save | ( | const bool & | b | ) | [inline] |
Saving bool directly.
Definition at line 169 of file portable_oarchive.hpp.
boost::enable_if<std::is_integral<T> >::type eos::portable_oarchive::save | ( | const T & | t, |
dummy< 2 > | = 0 |
||
) | [inline] |
Save integer types.
First we save the size information ie. the number of bytes that hold the actual data. We subsequently transform the data using store_little_endian and store non-zero bytes to the stream.
Definition at line 184 of file portable_oarchive.hpp.
boost::enable_if<boost::is_floating_point<T> >::type eos::portable_oarchive::save | ( | const T & | t, |
dummy< 3 > | = 0 |
||
) | [inline] |
Save floating point types.
We simply rely on fp_traits to extract the bit pattern into an (unsigned) integral type and store that into the stream.
The member fp_traits<T>::type::coverage will tell you whether all bits are copied. This is a typedef for either math::detail::all_bits or math::detail::not_all_bits.
If the function does not copy all bits, then it will copy the most significant bits. So if you serialize and deserialize the way you describe, and fp_traits<T>::type::coverage is math::detail::not_all_bits, then your floating point numbers will be truncated. This will introduce small rounding off errors.
Definition at line 236 of file portable_oarchive.hpp.
void eos::portable_oarchive::save_signed_char | ( | const signed char & | c | ) | [inline, private] |
Definition at line 153 of file portable_oarchive.hpp.