6 #ifndef LOFAR_COMMON_STREAMUTILX_H
7 #define LOFAR_COMMON_STREAMUTILX_H
34 static unsigned int level() {
return lvl; }
36 static const std::string&
token() {
return tok; }
40 static unsigned int lvl;
42 static const std::string tok;
47 inline std::ostream&
indent(std::ostream& os) {
56 template <
typename T,
typename U>
57 std::ostream&
operator<<(std::ostream& os,
const std::pair<T, U>& p);
60 template <
typename ITER>
61 void print(std::ostream& os, ITER begin, ITER end,
const char* separator =
",",
62 const char* prefix =
"[",
const char* postfix =
"]");
68 std::ostream&
operator<<(std::ostream& os,
const std::vector<T>& v);
74 std::ostream&
operator<<(std::ostream& os,
const std::set<T>& v);
79 template <
typename T,
typename U>
80 std::ostream&
operator<<(std::ostream& os,
const std::map<T, U>& m);
83 template <
typename T,
typename U>
84 inline std::ostream&
operator<<(std::ostream& os,
const std::pair<T, U>& p) {
85 os <<
'<' << p.first <<
',' << p.second <<
'>';
90 template <
typename ITER>
91 inline void print(std::ostream& os, ITER begin, ITER end,
const char* separator,
92 const char* prefix,
const char* postfix) {
98 for (; begin != end; ++begin) {
99 os << separator << *begin;
107 template <
typename T>
108 inline std::ostream&
operator<<(std::ostream& os,
const std::vector<T>& v) {
109 print(os, v.begin(), v.end(),
",",
"[",
"]");
116 template <
typename T>
117 inline std::ostream&
operator<<(std::ostream& os,
const std::set<T>& s) {
118 print(os, s.begin(), s.end(),
",",
"[",
"]");
125 template <
typename T,
typename U>
126 inline std::ostream&
operator<<(std::ostream& os,
const std::map<T, U>& m) {
127 print(os, m.begin(), m.end(),
", ",
"{",
"}");
Useful stream manipulation methods.
Definition: StreamUtil.h:27
static unsigned int level()
Return the amount of indentation.
Definition: StreamUtil.h:34
Indent()
Constructor. Increments indentation level.
Definition: StreamUtil.h:30
~Indent()
Destructor. Decrements indentation level.
Definition: StreamUtil.h:32
static const std::string & token()
Return the token to be printed per indentation level.
Definition: StreamUtil.h:36
std::ostream & indent(std::ostream &os)
Definition: StreamUtil.h:47
std::ostream & operator<<(std::ostream &os, const KVpair &kv)
void print(std::ostream &os, ITER begin, ITER end, const char *separator=",", const char *prefix="[", const char *postfix="]")
Write any container to the given std::ostream.
Definition: StreamUtil.h:91
This file has generic helper routines for testing steps.
Definition: AntennaConfig.h:53