Gaudi Framework, version v23r4

Home   Generated: Mon Sep 17 2012

SerializeSTL.h

Go to the documentation of this file.
00001 // $Id: SerializeSTL.h,v 1.1 2007/11/08 15:45:06 marcocle Exp $
00013 #ifndef GAUDIKERNEL_SERIALIZESTL_H_
00014 #define GAUDIKERNEL_SERIALIZESTL_H_
00015 
00016 #include <ostream>
00017 #include <vector>
00018 #include <list>
00019 #include <map>
00020 #include <utility>
00021 #include "GaudiKernel/Map.h"
00022 #include "GaudiKernel/HashMap.h"
00023 
00024 #include "GaudiKernel/SerializeSTLFwd.h"
00025 
00026 namespace GaudiUtils {
00027   //static const int NUMBERS_PER_LINE = 6;
00028 
00030   template <class T, class ALLOC>
00031   inline std::ostream& operator<< ( std::ostream& s, const std::vector<T,ALLOC>& v )
00032   {
00033     s << "[";
00034     //int cnt = 0;
00035     for(typename std::vector<T,ALLOC>::const_iterator i=v.begin(); i!=v.end(); ++i) {
00036       if ( i != v.begin()) s << ", ";
00037       s << (*i);
00038       //if ((++cnt)%NUMBERS_PER_LINE == 0) s << std::endl;
00039     }
00040     s << "]";
00041     return s;
00042   }
00043 
00045   template <class T, class ALLOC>
00046   inline std::ostream& operator<< ( std::ostream& s, const std::list<T,ALLOC>& l )
00047   {
00048     s << "[";
00049     //int cnt = 0;
00050     for(typename std::list<T,ALLOC>::const_iterator i=l.begin(); i!=l.end(); ++i) {
00051       if ( i != l.begin()) s << ", ";
00052       s << (*i);
00053       //if ((++cnt)%NUMBERS_PER_LINE == 0) s << std::endl;
00054     }
00055     s << "]";
00056     return s;
00057   }
00058 
00060   template <class T1, class T2>
00061   inline std::ostream& operator<< ( std::ostream& s, const std::pair<T1,T2>& p )
00062   {
00063     return s << "(" << p.first << ", " << p.second << ")";
00064   }
00065 
00067   template <class T1, class T2, class COMP, class ALLOC>
00068   inline std::ostream& operator << ( std::ostream& s,
00069                                      const std::map<T1,T2,COMP,ALLOC>& m )
00070   {
00071     s << "{";
00072     for ( typename std::map<T1,T2,COMP,ALLOC>::const_iterator i = m.begin();
00073     i != m.end(); ++i ) {
00074       if ( i != m.begin() ) s << ", ";
00075       s << i->first << ": " << i->second;
00076     }
00077     s << "}";
00078     return s;
00079   }
00080 
00082   template <class K, class T, class M>
00083   inline std::ostream& operator << ( std::ostream& s,
00084                                      const GaudiUtils::Map<K,T,M>& m )
00085   {
00086     // Serialize the internal map.
00087     return s << (M)m;
00088   }
00089 
00093   template <class K, class T, class H, class M>
00094   inline std::ostream& operator << ( std::ostream& s,
00095                                      const GaudiUtils::HashMap<K,T,H,M>& m )
00096   {
00097     // Copy the hash map into a map to have it ordered by key.
00098     return s << GaudiUtils::Map<K,T>(m.begin(),m.end());
00099   }
00100 
00101 } // namespace GaudiUtils
00102 
00103 #endif /*GAUDIKERNEL_SERIALIZESTL_H_*/
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Mon Sep 17 2012 13:49:32 for Gaudi Framework, version v23r4 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004