19 #include "dataIStream.h"
20 #include "dataStreamArchiveException.h"
25 template<
typename T >
26 void DataIStreamArchive::load_array( boost::serialization::array< T >& a,
29 _stream >> Array< T >( a.address(), a.count( ));
32 template<
class C,
class T,
class A >
33 void DataIStreamArchive::load( std::basic_string< C, T, A >& s )
36 BOOST_STATIC_ASSERT(
sizeof(C) ==
sizeof(
char));
40 template<
typename T >
41 typename boost::enable_if< boost::is_integral<T> >::type
42 DataIStreamArchive::load( T& t )
44 #if BOOST_VERSION < 104800
45 namespace bs = boost::detail;
47 namespace bs = boost::spirit::detail;
51 if(
signed char size = _loadSignedChar( ))
54 if( size < 0 && boost::is_unsigned<T>::value )
55 throw DataStreamArchiveException();
58 else if( (
unsigned)abs(size) >
sizeof(T))
59 throw DataStreamArchiveException( size );
62 T temp = size < 0 ? -1 : 0;
63 load_binary( &temp, abs(size));
67 t = bs::load_little_endian<T, sizeof(T)>( &temp );
74 template<
typename T >
75 typename boost::enable_if<boost::is_floating_point<T> >::type
76 DataIStreamArchive::load( T& t )
78 namespace fp = boost::spirit::math;
79 typedef typename fp::detail::fp_traits<T>::type traits;
87 typename traits::bits bits;
88 BOOST_STATIC_ASSERT(
sizeof(bits) ==
sizeof(T));
89 BOOST_STATIC_ASSERT( std::numeric_limits<T>::is_iec559 );
92 traits::set_bits( t, bits );
95 if( get_flags() & serialization::no_infnan && !fp::isfinite( t ))
96 throw DataStreamArchiveException( t );
101 if( std::numeric_limits<T>::has_denorm == std::denorm_absent &&
102 fp::fpclassify(t) == (
int)FP_SUBNORMAL )
104 throw DataStreamArchiveException( t );