Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SR_binary_vector_of_fundamentals.inl
1
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; \
6 \
7 static const bool is_streamable = true; \
8 \
9 static size_t size_of(void) \
10 { return IO::UnknownSize; } \
11 \
12 static size_t size_of(const value_type& _v) \
13 { return sizeof(elem_type)*_v.size(); } \
14 \
15 static \
16 size_t store(std::ostream& _os, const value_type& _v, bool _swap=false) { \
17 size_t bytes=0; \
18 \
19 if (_swap) \
20 bytes = std::accumulate( _v.begin(), _v.end(), bytes, \
21 FunctorStore<elem_type>(_os,_swap) ); \
22 else { \
23 bytes = size_of(_v); \
24 _os.write( reinterpret_cast<const char*>(&_v[0]), bytes ); \
25 } \
26 return _os.good() ? bytes : 0; \
27 } \
28 \
29 static size_t restore(std::istream& _is, value_type& _v, bool _swap=false) { \
30 size_t bytes=0; \
31 \
32 if ( _swap) \
33 bytes = std::accumulate( _v.begin(), _v.end(), size_t(0), \
34 FunctorRestore<elem_type>(_is, _swap) ); \
35 else \
36 { \
37 bytes = size_of(_v); \
38 _is.read( reinterpret_cast<char*>(&_v[0]), bytes ); \
39 } \
40 return _is.good() ? bytes : 0; \
41 } \
42 }
43
44 BINARY_VECTOR( short );
45 BINARY_VECTOR( unsigned short );
46 BINARY_VECTOR( int );
47 BINARY_VECTOR( unsigned int );
48 BINARY_VECTOR( long );
49 BINARY_VECTOR( unsigned long );
50 BINARY_VECTOR( float );
51 BINARY_VECTOR( double );
52
53 #undef BINARY_VECTOR