| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SerializeSTL.h
Go to the documentation of this file.
1 // $Id: SerializeSTL.h,v 1.1 2007/11/08 15:45:06 marcocle Exp $
13 #ifndef GAUDIKERNEL_SERIALIZESTL_H_
14 #define GAUDIKERNEL_SERIALIZESTL_H_
15
16 #include <ostream>
17 #include <vector>
18 #include <list>
19 #include <map>
20 #include <utility>
21 #include "GaudiKernel/Map.h"
22 #include "GaudiKernel/HashMap.h"
23
24 #include "GaudiKernel/SerializeSTLFwd.h"
25
26 namespace GaudiUtils {
27 //static const int NUMBERS_PER_LINE = 6;
28
30 template <class T, class ALLOC>
31 inline std::ostream& operator<< ( std::ostream& s, const std::vector<T,ALLOC>& v )
32 {
33 s << "[";
34 //int cnt = 0;
35 for(typename std::vector<T,ALLOC>::const_iterator i=v.begin(); i!=v.end(); ++i) {
36 if ( i != v.begin()) s << ", ";
37 s << (*i);
38 //if ((++cnt)%NUMBERS_PER_LINE == 0) s << std::endl;
39 }
40 s << "]";
41 return s;
42 }
43
45 template <class T, class ALLOC>
46 inline std::ostream& operator<< ( std::ostream& s, const std::list<T,ALLOC>& l )
47 {
48 s << "[";
49 //int cnt = 0;
50 for(typename std::list<T,ALLOC>::const_iterator i=l.begin(); i!=l.end(); ++i) {
51 if ( i != l.begin()) s << ", ";
52 s << (*i);
53 //if ((++cnt)%NUMBERS_PER_LINE == 0) s << std::endl;
54 }
55 s << "]";
56 return s;
57 }
58
60 template <class T1, class T2>
61 inline std::ostream& operator<< ( std::ostream& s, const std::pair<T1,T2>& p )
62 {
63 return s << "(" << p.first << ", " << p.second << ")";
64 }
65
67 template <class T1, class T2, class COMP, class ALLOC>
68 inline std::ostream& operator << ( std::ostream& s,
69 const std::map<T1,T2,COMP,ALLOC>& m )
70 {
71 s << "{";
72 for ( typename std::map<T1,T2,COMP,ALLOC>::const_iterator i = m.begin();
73 i != m.end(); ++i ) {
74 if ( i != m.begin() ) s << ", ";
75 s << i->first << ": " << i->second;
76 }
77 s << "}";
78 return s;
79 }
80
82 template <class K, class T, class M>
83 inline std::ostream& operator << ( std::ostream& s,
84 const GaudiUtils::Map<K,T,M>& m )
85 {
86 // Serialize the internal map.
87 return s << (M)m;
88 }
89
93 template <class K, class T, class H, class M>
94 inline std::ostream& operator << ( std::ostream& s,
95 const GaudiUtils::HashMap<K,T,H,M>& m )
96 {
97 // Copy the hash map into a map to have it ordered by key.
98 return s << GaudiUtils::Map<K,T>(m.begin(),m.end());
99 }
100
101 } // namespace GaudiUtils
102
103 #endif /*GAUDIKERNEL_SERIALIZESTL_H_*/