Developer Documentation

SR_binary_vector_of_string.inl
1
2 template <> struct binary< std::vector< std::string > >
3 {
4 // struct binary interface
5
6 typedef std::vector< std::string > value_type;
7 typedef value_type::value_type elem_type;
8
9 static const bool is_streamable = true;
10
11 // Helper
12
13 struct Sum
14 {
15 size_t operator() ( size_t _v1, const elem_type& _s2 )
16 { return _v1 + binary<elem_type>::size_of(_s2); }
17 };
18
19 // struct binary interface
20
21 static size_t size_of(void) { return UnknownSize; }
22
23 static size_t size_of(const value_type& _v)
24 { return std::accumulate( _v.begin(), _v.end(), size_t(0), Sum() ); }
25
26 static
27 size_t store(std::ostream& _os, const value_type& _v, bool _swap=false)
28 {
29 return std::accumulate( _v.begin(), _v.end(), size_t(0),
30 FunctorStore<elem_type>(_os, _swap) );
31 }
32
33 static
34 size_t restore(std::istream& _is, value_type& _v, bool _swap=false)
35 {
36 return std::accumulate( _v.begin(), _v.end(), size_t(0),
37 FunctorRestore<elem_type>(_is, _swap) );
38 }
39 };
std
STL namespace.