5 #ifndef GAUDIPROPERTYPARSERS_PARSERVALUETOSTREAM_H
6 #define GAUDIPROPERTYPARSERS_PARSERVALUETOSTREAM_H 1
49 std::ostream&
toStream (
const TYPE& obj, std::ostream&
s ) ;
62 template <
class ITERATOR>
67 const std::string& open ,
68 const std::string& close ,
69 const std::string& delim ) ;
78 (
const std::string& obj , std::ostream&
s )
80 if ( std::string::npos == obj.find(
'\'') )
81 { s <<
"\'" << obj <<
"\'" ; }
83 { s <<
"\"" << obj <<
"\"" ; }
91 (
const bool obj , std::ostream& s )
92 {
return s << ( obj ?
"True" :
"False" ) ; }
98 (
const float obj , std::ostream& s ,
const int prec = 6 )
100 const int p = s.precision() ;
101 return s << std::setprecision ( prec ) << obj << std::setprecision ( p ) ;
108 (
const double obj , std::ostream& s ,
const int prec = 8 )
110 const int p = s.precision() ;
111 return s << std::setprecision ( prec ) << obj << std::setprecision ( p ) ;
118 (
const long double obj , std::ostream& s ,
const int prec = 10 )
120 const int p = s.precision() ;
121 return s << std::setprecision ( prec ) << obj << std::setprecision ( p ) ;
131 template<
class KTYPE,
class VTYPE>
133 (
const std::pair<KTYPE,VTYPE>& obj, std::ostream& s)
148 template<
class TYPE,
class ALLOCATOR>
150 (
const std::vector<TYPE,ALLOCATOR>& obj, std::ostream& s)
152 return toStream ( obj.begin() , obj.end () ,
s ,
"[ " ,
" ]" ,
" , " ) ;
161 template<
class TYPE,
class ALLOCATOR>
163 (
const std::list<TYPE,ALLOCATOR>& obj, std::ostream& s)
165 return toStream ( obj.begin() , obj.end () ,
s ,
"[ " ,
" ]" ,
" , " ) ;
174 template<
class TYPE,
class CMP,
class ALLOCATOR>
176 (
const std::set<TYPE,CMP,ALLOCATOR>& obj, std::ostream& s)
178 return toStream ( obj.begin() , obj.end () ,
s ,
"[ " ,
" ]" ,
" , " ) ;
188 template<
class KTYPE,
class VTYPE,
class CMP,
class ALLOCATOR>
190 (
const std::map<KTYPE,VTYPE,CMP,ALLOCATOR>& obj, std::ostream& s )
193 for (
typename std::map<KTYPE,VTYPE,CMP,ALLOCATOR>::const_iterator cur =
194 obj.begin() ; obj.end() != cur ; ++cur )
196 if ( obj.begin() != cur ) { s <<
" , " ; }
212 template<
class KTYPE,
class VTYPE,
class CMP,
class ALLOCATOR>
218 obj.
end() != cur ; ++cur )
220 if ( obj.
begin() != cur ) { s <<
" , " ; }
236 template<
class KTYPE,
class VTYPE,
class MAP>
242 obj.
end() != cur ; ++cur )
244 if ( obj.
begin() != cur ) { s <<
" , " ; }
260 template<
class KTYPE,
class VTYPE,
class HASH,
class MAP>
266 obj.
end() != cur ; ++cur )
268 if ( obj.
begin() != cur ) { s <<
" , " ; }
280 template <
class TYPE,
unsigned int N>
281 std::ostream&
toStream ( TYPE(&obj)[
N] , std::ostream& s )
283 return toStream ( obj , obj + N , s ,
"( " ,
" )" ,
" , " ) ;
290 template <
class TYPE,
unsigned int N>
291 std::ostream&
toStream (
const TYPE(&obj)[
N] , std::ostream& s )
293 return toStream ( obj , obj + N , s ,
"( " ,
" )" ,
" , " ) ;
300 template <
unsigned int N>
301 std::ostream&
toStream (
char (&obj)[
N] , std::ostream& s )
302 {
return toStream ( std::string ( obj , obj+N ) , s ) ; }
308 template <
unsigned int N>
309 std::ostream&
toStream (
const char (&obj)[
N] , std::ostream& s )
310 {
return toStream ( std::string ( obj , obj+N ) , s ) ; }
316 inline std::ostream&
toStream (
const char* obj , std::ostream& s )
317 {
return toStream ( std::string ( obj ) , s ) ; }
325 inline std::ostream&
toStream (
const TYPE& obj, std::ostream& s )
326 {
return s << obj ; }
339 template <
class ITERATOR>
344 const std::string& open ,
345 const std::string& close ,
346 const std::string& delim )
349 for ( ITERATOR curr = first ; curr != last ; ++curr )
351 if ( first != curr ) { s << delim ; }
366 template <
class TYPE>
369 std::ostringstream
s;
370 std::ios::fmtflags orig_flags = s.flags();
371 s.setf(std::ios::showpoint);
A bit modified version of 'Loki::AssocVector' associative vector from Loki library by Andrei Alexandr...
Extension of the STL map.
std::string toString(const TYPE &obj)
the generic implementation of the type conversion to the string
iterator end() const
"end" iterator for sequential access (const-only version!)
std::ostream & toStream(ITERATOR first, ITERATOR last, std::ostream &s, const std::string &open, const std::string &close, const std::string &delim)
the helper function to print the sequence
iterator begin() const
"begin" iterator for sequential access (const-only version!)
map_type::const_iterator const_iterator
_vector::const_iterator const_iterator
visible const_iterator (exported)
Common class providing an architecture-independent hash map.
This is a number of static methods for bootstrapping the Gaudi framework.