QxOrm
1.4.1
C++ Object Relational Mapping library

Portable binary input archive using little endian format. More...
#include <portable_iarchive.hpp>
Classes  
struct  dummy 
Public Member Functions  
template<class T >  
boost::disable_if < boost::is_arithmetic< T > >::type  load (T &t, dummy< 1 >=0) 
Default fall through for nonarithmetic types (ie. strings)  
void  load (bool &b) 
template<typename T >  
boost::enable_if < boost::is_integral< T > >::type  load (T &t, dummy< 2 >=0) 
Load integer types.  
template<typename T >  
boost::enable_if < boost::is_floating_point< T > >::type  load (T &t, dummy< 3 >=0) 
Load floating point types.  
portable_iarchive (std::istream &is, unsigned flags=0)  
always construct on a stream using ios::binary mode!  
Private Member Functions  
signed char  load_signed_char () 
Portable binary input archive using little endian format.
This archive addresses integer size, endianness and floating point types so that data can be transferred across different systems. There may still be constraints as to what systems are compatible and the user will have to take care that e.g. a very large int being saved on a 64 bit machine will result in a portable_archive_exception if loaded into an int on a 32 bit system. A possible workaround to this would be to use fixed types like boost::uint64_t in your serialization structures.
Definition at line 153 of file portable_iarchive.hpp.
eos::portable_iarchive::portable_iarchive  (  std::istream &  is, 
unsigned  flags = 0 

)  [inline] 
always construct on a stream using ios::binary mode!
Definition at line 279 of file portable_iarchive.hpp.
boost::disable_if<boost::is_arithmetic<T> >::type eos::portable_iarchive::load  (  T &  t, 
dummy< 1 >  = 0 

)  [inline] 
Default fall through for nonarithmetic types (ie. strings)
Definition at line 176 of file portable_iarchive.hpp.
void eos::portable_iarchive::load  (  bool &  b  )  [inline] 
Special case loading bool type, preserving compatibility to integer types  this is somewhat redundant but simply treating bool as integer type generates lots of warnings
Definition at line 184 of file portable_iarchive.hpp.
boost::enable_if<boost::is_integral<T> >::type eos::portable_iarchive::load  (  T &  t, 
dummy< 2 >  = 0 

)  [inline] 
Load integer types.
First we load the size information ie. the number of bytes that hold the actual data. Then we retrieve the data and transform it to the original value by using load_little_endian.
Definition at line 203 of file portable_iarchive.hpp.
boost::enable_if<boost::is_floating_point<T> >::type eos::portable_iarchive::load  (  T &  t, 
dummy< 3 >  = 0 

)  [inline] 
Load floating point types.
We simply rely on fp_traits to set the bit pattern from the (unsigned) integral type that was stored in 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 254 of file portable_iarchive.hpp.
signed char eos::portable_iarchive::load_signed_char  (  )  [inline, private] 
Definition at line 164 of file portable_iarchive.hpp.