Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v38r0 (2143aa4c)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
SerializeSTL.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
22 #ifndef GAUDIKERNEL_SERIALIZESTL_H_
23 #define GAUDIKERNEL_SERIALIZESTL_H_
24 
25 #include "GaudiKernel/HashMap.h"
26 #include "GaudiKernel/Map.h"
27 #include <array>
28 #include <list>
29 #include <map>
30 #include <ostream>
31 #include <utility>
32 #include <vector>
33 
34 namespace GaudiUtils {
36  template <class T1, class T2>
38 
40  template <class T, class ALLOC>
42 
44  template <class T, std::size_t N>
46 
48  template <class T, class ALLOC>
50 
52  template <class T1, class T2, class COMP, class ALLOC>
54 
56  template <class K, class T, class M>
58 
60  template <class K, class T, class H, class M>
62 
63  namespace details {
64 
66  template <typename T>
67  std::ostream& operator()( std::ostream& os, T&& t ) const {
68  return os << std::forward<T>( t );
69  }
70  };
71 
72  template <typename Stream, typename Iterator, typename Separator, typename OutputElement = IdentityOutputter>
73  Stream& ostream_joiner( Stream& os, Iterator first, Iterator last, Separator sep,
74  OutputElement output = OutputElement{} ) {
75  if ( first != last ) output( os, *first++ );
76  while ( first != last ) output( os << sep, *first++ );
77  return os;
78  }
79 
80  template <typename Stream, typename Container, typename Separator, typename OutputElement = IdentityOutputter>
81  Stream& ostream_joiner( Stream& os, const Container& c, Separator sep, OutputElement output = OutputElement{} ) {
82  using std::begin, std::end;
83  return ostream_joiner( os, begin( c ), end( c ), sep, output );
84  }
85  } // namespace details
86 
87  template <class T1, class T2>
89  return s << '(' << p.first << ", " << p.second << ')';
90  }
91 
92  template <class T, class ALLOC>
94  return details::ostream_joiner( s << '[', v, ", " ) << ']';
95  }
96 
97  template <class T, std::size_t N>
99  return details::ostream_joiner( s << '[', v, ", " ) << ']';
100  }
101 
102  template <class T, class ALLOC>
104  return details::ostream_joiner( s << '[', l, ", " ) << ']';
105  }
106 
107  template <class T1, class T2, class COMP, class ALLOC>
109  return details::ostream_joiner( s << "{", m, ", ",
110  []( std::ostream& os, const std::pair<const T1, T2>& p ) -> std::ostream& {
111  return os << p.first << ": " << p.second;
112  } )
113  << "}";
114  }
115 
116  template <class K, class T, class M>
118  // Serialize the internal map.
119  return s << static_cast<const M&>( m );
120  }
121 
124  template <class K, class T, class H, class M>
126  // Copy the hash map into a map to have it ordered by key.
127  return s << GaudiUtils::Map<K, T>( m.begin(), m.end() );
128  }
129 
130 } // namespace GaudiUtils
131 
132 #endif /*GAUDIKERNEL_SERIALIZESTL_H_*/
std::list
STL class.
std::pair
gaudirun.s
string s
Definition: gaudirun.py:346
std::vector
STL class.
gaudirun.c
c
Definition: gaudirun.py:525
gaudirun.output
output
Definition: gaudirun.py:521
HashMap.h
bug_34121.t
t
Definition: bug_34121.py:30
GaudiUtils::details::IdentityOutputter::operator()
std::ostream & operator()(std::ostream &os, T &&t) const
Definition: SerializeSTL.h:67
GaudiUtils::operator<<
std::ostream & operator<<(std::ostream &s, const std::pair< T1, T2 > &p)
Serialize an std::pair in a python like format. E.g. "(1, 2)".
Definition: SerializeSTL.h:88
details
Definition: AnyDataWrapper.h:18
Gaudi::Units::m
constexpr double m
Definition: SystemOfUnits.h:108
std::ostream
STL class.
CLHEP::begin
double * begin(CLHEP::HepVector &v)
Definition: TupleAlg.cpp:45
GaudiUtils::details::IdentityOutputter
Definition: SerializeSTL.h:65
std::array
STL class.
GaudiUtils::Map
Definition: Map.h:91
std::map
STL class.
gaudirun.l
dictionary l
Definition: gaudirun.py:580
std::begin
T begin(T... args)
Properties.v
v
Definition: Properties.py:122
std::end
T end(T... args)
Map.h
GaudiUtils::HashMap
Definition: HashMap.h:83
IOTest.end
end
Definition: IOTest.py:123
GaudiUtils
Definition: GaudiHistoID.h:145
GaudiUtils::details::ostream_joiner
Stream & ostream_joiner(Stream &os, Iterator first, Iterator last, Separator sep, OutputElement output=OutputElement{})
Definition: SerializeSTL.h:73
Iterator
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:28