00001 // Map output implementation -*- C++ -*- 00002 00003 // $Id: print_map.h 347 2008-02-06 15:20:01Z schilly $ 00004 // Copyright (C) 2001-2003 Hermann Schichl 00005 // 00006 // This file is part of the COCONUT API. This library 00007 // is free software; you can redistribute it and/or modify it under the 00008 // terms of the Library GNU General Public License as published by the 00009 // Free Software Foundation; either version 2, or (at your option) 00010 // any later version. 00011 00012 // This library is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // Library GNU General Public License for more details. 00016 00017 // As a special exception, you may use this file as part of a free software 00018 // library without restriction. Specifically, if other files instantiate 00019 // templates or use macros or inline functions from this file, or you compile 00020 // this file and link it with other files to produce an executable, this 00021 // file does not by itself cause the resulting executable to be covered by 00022 // the Library GNU General Public License. This exception does not however 00023 // invalidate any other reasons why the executable file might be covered by 00024 // the Library GNU General Public License. 00025 00028 #ifndef __PRINT_MAP_H_ 00029 #define __PRINT_MAP_H_ 00030 00031 #include <map> 00032 //#include <multimap> 00033 #include <print_tuple.h> 00034 00036 00037 namespace std { 00038 00041 template <typename _TK, typename _Ve, typename _TC, typename _TA> 00042 ostream& operator<<(ostream& o, const map<_TK,_Ve,_TC,_TA>& a) 00043 { 00044 typename map<_TK,_Ve,_TC,_TA>::const_iterator b(a.begin()), e(a.end()); 00045 o << "{"; 00046 if(!a.empty()) 00047 { 00048 o << *b; 00049 for(++b; b != e; ++b) 00050 o << "," << *b; 00051 } 00052 return o << "}"; 00053 } 00054 00057 template <typename _TK, typename _Ve, typename _TC, typename _TA> 00058 ostream& operator<<(ostream& o, const multimap<_TK,_Ve,_TC,_TA>& a) 00059 { 00060 typename multimap<_TK,_Ve,_TC,_TA>::const_iterator b(a.begin()), e(a.end()); 00061 o << "{"; 00062 if(!a.empty()) 00063 { 00064 o << *b; 00065 for(++b; b != e; ++b) 00066 o << "," << *b; 00067 } 00068 return o << "}"; 00069 } 00070 00071 } // end of namespace std 00072 00073 #endif /* __PRINT_MAP_H_ */