vsl_pair_io.hxx
Go to the documentation of this file.
1 // This is core/vsl/vsl_pair_io.hxx
2 #ifndef vsl_pair_io_hxx_
3 #define vsl_pair_io_hxx_
4 //:
5 // \file
6 // \brief binary IO functions for std::pair<T>
7 // \author Ian Scott
8 //
9 // Implementation
10 
11 #include "vsl_pair_io.h"
12 #include <vsl/vsl_binary_io.h>
13 
14 //====================================================================================
15 //: Write pair to binary stream
16 template <class S, class T>
17 void vsl_b_write(vsl_b_ostream& s, const std::pair<S, T>& v)
18 {
19  // Do not write a version number here for space efficiency reasons.
20  // There is no reason to expect the format to change
21  vsl_b_write(s,v.first);
22  vsl_b_write(s,v.second);
23 }
24 
25 //====================================================================================
26 //: Read pair from binary stream
27 template <class S, class T>
28 void vsl_b_read(vsl_b_istream& s, std::pair<S, T>& v)
29 {
30  vsl_b_read(s,v.first);
31  vsl_b_read(s,v.second);
32 }
33 
34 
35 //====================================================================================
36 //: Output a human readable summary to the stream
37 template <class S, class T>
38 void vsl_print_summary(std::ostream& os, const std::pair<S, T> &v)
39 {
40  os << "(";
41  vsl_print_summary(os, v.first);
42  os << ", ";
43  vsl_print_summary(os, v.second);
44  os << ")";
45 }
46 
47 
48 #undef VSL_PAIR_IO_INSTANTIATE
49 #define VSL_PAIR_IO_INSTANTIATE(S, T ) \
50 template void vsl_print_summary(std::ostream& s, const std::pair<S, T >& v); \
51 template void vsl_b_write(vsl_b_ostream& s, const std::pair<S, T > & v); \
52 template void vsl_b_read(vsl_b_istream& s, std::pair<S, T > & v)
53 
54 #endif // vsl_pair_io_hxx_
A binary output adaptor for any std::ostream.
Definition: vsl_binary_io.h:37
void vsl_print_summary(std::ostream &os, const std::pair< S, T > &v)
Output a human readable summary to the stream.
Definition: vsl_pair_io.hxx:38
void vsl_b_read(vsl_b_istream &s, std::pair< S, T > &v)
Read pair from binary stream.
Definition: vsl_pair_io.hxx:28
An adaptor for any std::istream to make it suitable for binary input.
Set of functions, and objects to perform binary IO.
void vsl_b_write(vsl_b_ostream &s, const std::pair< S, T > &v)
Write pair to binary stream.
Definition: vsl_pair_io.hxx:17
binary IO functions for std::pair<S, T>