| # Gaudi Framework, version v23r0 |

Home |  | Generated: Mon Jan 30 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 namespace GaudiUtils {
    00025   //static const int NUMBERS_PER_LINE = 6;
    00026
    00028   template <class T, class ALLOC>
    00029   inline std::ostream& operator<< ( std::ostream& s, const std::vector<T,ALLOC>& v )
    00030   {
    00031     s << "[";
    00032     //int cnt = 0;
    00033     for(typename std::vector<T,ALLOC>::const_iterator i=v.begin(); i!=v.end(); ++i) {
    00034       if ( i != v.begin()) s << ", ";
    00035       s << (*i);
    00036       //if ((++cnt)%NUMBERS_PER_LINE == 0) s << std::endl;
    00037     }
    00038     s << "]";
    00039     return s;
    00040   }
    00041
    00043   template <class T, class ALLOC>
    00044   inline std::ostream& operator<< ( std::ostream& s, const std::list<T,ALLOC>& l )
    00045   {
    00046     s << "[";
    00047     //int cnt = 0;
    00048     for(typename std::list<T,ALLOC>::const_iterator i=l.begin(); i!=l.end(); ++i) {
    00049       if ( i != l.begin()) s << ", ";
    00050       s << (*i);
    00051       //if ((++cnt)%NUMBERS_PER_LINE == 0) s << std::endl;
    00052     }
    00053     s << "]";
    00054     return s;
    00055   }
    00056
    00058   template <class T1, class T2>
    00059   inline std::ostream& operator<< ( std::ostream& s, const std::pair<T1,T2>& p )
    00060   {
    00061     return s << "(" << p.first << ", " << p.second << ")";
    00062   }
    00063
    00065   template <class T1, class T2, class COMP, class ALLOC>
    00066   inline std::ostream& operator << ( std::ostream& s,
    00067                                      const std::map<T1,T2,COMP,ALLOC>& m )
    00068   {
    00069     s << "{";
    00070     for ( typename std::map<T1,T2,COMP,ALLOC>::const_iterator i = m.begin();
    00071     i != m.end(); ++i ) {
    00072       if ( i != m.begin() ) s << ", ";
    00073       s << i->first << ": " << i->second;
    00074     }
    00075     s << "}";
    00076     return s;
    00077   }
    00078
    00080   template <class K, class T, class M>
    00081   inline std::ostream& operator << ( std::ostream& s,
    00082                                      const GaudiUtils::Map<K,T,M>& m )
    00083   {
    00084     // Serialize the internal map.
    00085     return s << (M)m;
    00086   }
    00087
    00091   template <class K, class T, class H, class M>
    00092   inline std::ostream& operator << ( std::ostream& s,
    00093                                      const GaudiUtils::HashMap<K,T,H,M>& m )
    00094   {
    00095     // Copy the hash map into a map to have it ordered by key.
    00096     return s << GaudiUtils::Map<K,T>(m.begin(),m.end());
    00097   }
    00098
    00099 } // namespace GaudiUtils
    00100
    00101 #endif /*GAUDIKERNEL_SERIALIZESTL_H_*/

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines