Welcome to mirror list, hosted at ThFree Co, Russian Federation.

message.hpp « internal « base - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a378fdce1188fc70a5bd21db653866424dbf711f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#pragma once
#include "std/array.hpp"
#include "std/functional.hpp"
#include "std/initializer_list.hpp"
#include "std/iterator.hpp"
#include "std/list.hpp"
#include "std/map.hpp"
#include "std/set.hpp"
#include "std/sstream.hpp"
#include "std/string.hpp"
#include "std/unique_ptr.hpp"
#include "std/unordered_map.hpp"
#include "std/unordered_set.hpp"
#include "std/utility.hpp"
#include "std/vector.hpp"


/// @name Declarations.
//@{
template <typename T> inline string DebugPrint(T const & t);

string DebugPrint(string const & t);
inline string DebugPrint(char const * t);
inline string DebugPrint(char t);

template <typename U, typename V> inline string DebugPrint(pair<U, V> const & p);
template <typename T> inline string DebugPrint(list<T> const & v);
template <typename T> inline string DebugPrint(vector<T> const & v);
template <typename T, typename C = less<T>> inline string DebugPrint(set<T, C> const & v);
template <typename U, typename V, typename C = less<U>> inline string DebugPrint(map<U, V, C> const & v);
template <typename T> inline string DebugPrint(initializer_list<T> const & v);
template <typename T> inline string DebugPrint(unique_ptr<T> const & v);

template <class Key, class Hash = hash<Key>, class Pred = equal_to<Key>>
inline string DebugPrint(unordered_set<Key, Hash, Pred> const & v);
template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>>
inline string DebugPrint(unordered_map<Key, T, Hash, Pred> const & v);
//@}


inline string DebugPrint(char const * t)
{
  if (t)
    return DebugPrint(string(t));
  else
    return string("NULL string pointer");
}

inline string DebugPrint(char t)
{
  return DebugPrint(string(1, t));
}

inline string DebugPrint(signed char t)
{
  return DebugPrint(static_cast<int>(t));
}

inline string DebugPrint(unsigned char t)
{
  return DebugPrint(static_cast<unsigned int>(t));
}

template <typename U, typename V> inline string DebugPrint(pair<U,V> const & p)
{
  ostringstream out;
  out << "(" << DebugPrint(p.first) << ", " << DebugPrint(p.second) << ")";
  return out.str();
}

namespace my
{
  namespace impl
  {
    template <typename IterT> inline string DebugPrintSequence(IterT beg, IterT end)
    {
      ostringstream out;
      out << "[" << distance(beg, end) << ":";
      for (;  beg != end; ++beg)
        out << " " << DebugPrint(*beg);
      out << " ]";
      return out.str();
    }
  }
}

template <typename T, size_t N> inline string DebugPrint(T (&arr) [N])
{
  return ::my::impl::DebugPrintSequence(arr, arr + N);
}

template <typename T, size_t N> inline string DebugPrint(array<T, N> const & v)
{
  return ::my::impl::DebugPrintSequence(v.begin(), v.end());
}

template <typename T> inline string DebugPrint(vector<T> const & v)
{
  return ::my::impl::DebugPrintSequence(v.begin(), v.end());
}

template <typename T> inline string DebugPrint(list<T> const & v)
{
  return ::my::impl::DebugPrintSequence(v.begin(), v.end());
}

template <typename T, typename C> inline string DebugPrint(set<T, C> const & v)
{
  return ::my::impl::DebugPrintSequence(v.begin(), v.end());
}

template <typename U, typename V, typename C> inline string DebugPrint(map<U, V, C> const & v)
{
  return ::my::impl::DebugPrintSequence(v.begin(), v.end());
}

template <typename T> inline string DebugPrint(initializer_list<T> const & v)
{
  return ::my::impl::DebugPrintSequence(v.begin(), v.end());
}

template <class Key, class Hash, class Pred>
inline string DebugPrint(unordered_set<Key, Hash, Pred> const & v)
{
  return ::my::impl::DebugPrintSequence(v.begin(), v.end());
}

template <class Key, class T, class Hash, class Pred>
inline string DebugPrint(unordered_map<Key, T, Hash, Pred> const & v)
{
  return ::my::impl::DebugPrintSequence(v.begin(), v.end());
}

template <typename T> inline string DebugPrint(T const & t)
{
  ostringstream out;
  out << t;
  return out.str();
}

template <typename T> inline string DebugPrint(unique_ptr<T> const & v)
{
  ostringstream out;
  if (v.get() != nullptr)
    out << DebugPrint(*v);
  else
    out << DebugPrint("null");
  return out.str();
}

namespace my
{
  namespace impl
  {
    inline string Message()
    {
      return string();
    }
    template <typename T> string Message(T const & t)
    {
      return DebugPrint(t);
    }
    template <typename T, typename... ARGS> string Message(T const & t, ARGS const & ... others)
    {
      return DebugPrint(t) + " " + Message(others...);
    }
  }
}