35 #ifndef REPORTINGUTILS_H
36 #define REPORTINGUTILS_H
51 getClassMethod__(std::string prettyFunction)
53 size_t pos = prettyFunction.find(
"(");
54 if (pos == std::string::npos)
55 return prettyFunction;
56 prettyFunction.erase(pos);
57 pos = prettyFunction.rfind(
" ");
58 if (pos == std::string::npos)
59 return prettyFunction;
60 prettyFunction.erase(0, pos + 1);
61 return prettyFunction;
64 #define printErr std::cerr << "!!! " << __PRETTY_FUNCTION__ << " [" << __FILE__ << ":" << __LINE__ << "]: error: "
65 #define printWarn std::cerr << "??? " << __PRETTY_FUNCTION__ << " [" << __FILE__ << ":" << __LINE__ << "]: warning: "
66 #define printInfo std::cout << ">>> " << getClassMethod__(__PRETTY_FUNCTION__) << "(): info: "
72 #ifndef SVN_VERSION // SVN_VERSION set by Makefile
73 #define SVN_VERSION "undefined"
75 inline std::string svnVersion() {
return SVN_VERSION; }
81 const std::string ver = svnVersion();
83 printInfo <<
"subversion repository revision is unknown." << std::endl;
85 printInfo <<
"subversion repository revision is '" << ver <<
"'" << std::endl;
89 #ifndef CMAKE_SOURCE_DIR // CMAKE_SOURCE_DIR set by Makefile
90 #define CMAKE_SOURCE_DIR "undefined"
92 inline std::string compileDir() {
return CMAKE_SOURCE_DIR; }
98 const std::string date = __DATE__;
99 const std::string time = __TIME__;
100 const std::string ver = __VERSION__;
101 const std::string dir = compileDir();
102 printInfo <<
"this executable was compiled in ";
104 std::cout <<
"'" << dir <<
"'";
106 std::cout <<
"unknown directory";
107 std::cout <<
" on " << date <<
" " << time <<
" by compiler " << ver << std::endl;
114 template<
typename T1,
typename T2>
117 operator << (std::ostream& out,
118 const std::pair<T1, T2>& pair)
120 return out <<
"(" << pair.first <<
", " << pair.second <<
")";
127 operator << (std::ostream& out,
128 const std::vector<T>& vec)
131 for (
unsigned int i = 0; i < (vec.size() - 1); ++i)
132 out <<
"[" << i <<
"] = " << vec[i] <<
", ";
133 return out <<
"[" << vec.size() - 1 <<
"] = " << vec[vec.size() - 1] <<
"}";
143 progressIndicator(
const unsigned int currentPos,
144 const unsigned int nmbTotal,
145 const bool absolute =
false,
146 const unsigned int fieldWidth = 3,
147 const unsigned int nmbSteps = 10,
148 std::ostream& out = std::cout)
150 const double step = nmbTotal / (double)nmbSteps;
151 if ((
int)(currentPos / step) - (
int)((currentPos - 1) / step) != 0) {
153 out <<
" " << std::setw(fieldWidth) << currentPos <<
" of " << nmbTotal << std::endl;
155 out <<
" " << std::setw(fieldWidth) << (int)(currentPos / step) * nmbSteps <<
" %" << std::endl;
163 std::string trueFalse(
const bool val)
173 std::string yesNo(
const bool val)
183 std::string onOff(
const bool val)
193 std::string enDisabled(
const bool val)
202 #endif // REPORTINGUTILS_H