Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
map.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2  * tlx/logger/map.hpp
3  *
4  * Part of tlx - http://panthema.net/tlx
5  *
6  * Copyright (C) 2018 Timo Bingmann <[email protected]>
7  *
8  * All rights reserved. Published under the Boost Software License, Version 1.0
9  ******************************************************************************/
10 
11 #ifndef TLX_LOGGER_MAP_HEADER
12 #define TLX_LOGGER_MAP_HEADER
13 
14 #include <tlx/logger.hpp>
15 
16 #include <map>
17 
18 namespace tlx {
19 
20 template <typename K, typename V, typename C, typename A>
21 class LoggerFormatter<std::map<K, V, C, A> >
22 {
23 public:
24  static void print(std::ostream& os, const std::map<K, V, C, A>& data) {
25  os << '{';
26  for (typename std::map<K, V, C, A>::const_iterator it = data.begin();
27  it != data.end(); ++it)
28  {
29  if (it != data.begin()) os << ',';
30  LoggerFormatter<K>::print(os, it->first);
31  os << '=';
32  LoggerFormatter<V>::print(os, it->second);
33  }
34  os << '}';
35  }
36 };
37 
38 template <typename K, typename V, typename C, typename A>
39 class LoggerFormatter<std::multimap<K, V, C, A> >
40 {
41 public:
42  static void print(std::ostream& os, const std::multimap<K, V, C, A>& data) {
43  os << '{';
44  for (typename std::multimap<K, V, C, A>::const_iterator it = data.begin();
45  it != data.end(); ++it)
46  {
47  if (it != data.begin()) os << ',';
48  LoggerFormatter<K>::print(os, it->first);
49  os << '=';
50  LoggerFormatter<V>::print(os, it->second);
51  }
52  os << '}';
53  }
54 };
55 
56 } // namespace tlx
57 
58 #endif // !TLX_LOGGER_MAP_HEADER
59 
60 /******************************************************************************/
static void print(std::ostream &os, const std::multimap< K, V, C, A > &data)
Definition: map.hpp:42
template class for formatting. contains a print() method.
Definition: logger.hpp:25
static void print(std::ostream &os, const std::map< K, V, C, A > &data)
Definition: map.hpp:24