2 #define BINARY_VECTOR( T ) \ 3 template <> struct binary< std::vector< T > > { \ 4 typedef std::vector< T > value_type; \ 5 typedef value_type::value_type elem_type; \ 7 static const bool is_streamable = true; \ 9 static size_t size_of(void) \ 10 { return IO::UnknownSize; } \ 12 static size_t size_of(const value_type& _v) \ 13 { return sizeof(elem_type)*_v.size(); } \ 16 size_t store(std::ostream& _os, const value_type& _v, bool _swap=false) { \ 20 bytes = std::accumulate( _v.begin(), _v.end(), bytes, \ 21 FunctorStore<elem_type>(_os,_swap) ); \ 23 bytes = size_of(_v); \ 24 _os.write( reinterpret_cast<const char*>(&_v[0]), bytes ); \ 26 return _os.good() ? bytes : 0; \ 29 static size_t restore(std::istream& _is, value_type& _v, bool _swap=false) { \ 33 bytes = std::accumulate( _v.begin(), _v.end(), size_t(0), \ 34 FunctorRestore<elem_type>(_is, _swap) ); \ 37 bytes = size_of(_v); \ 38 _is.read( reinterpret_cast<char*>(&_v[0]), bytes ); \ 40 return _is.good() ? bytes : 0; \ 44 BINARY_VECTOR(
short );
45 BINARY_VECTOR(
unsigned short );
47 BINARY_VECTOR(
unsigned int );
48 BINARY_VECTOR(
long );
49 BINARY_VECTOR(
unsigned long );
50 BINARY_VECTOR(
float );
51 BINARY_VECTOR(
double );