4 #include "boost/lexical_cast.hpp"
9 std::size_t bpos = str.find_first_of(
'(');
10 if (bpos == std::string::npos)
return str;
11 std::size_t apos = bpos;
12 bool break_cond =
false;
13 bool in_clause =
false;
14 while (!break_cond && apos > 0) {
16 if (str[apos] ==
'>') in_clause =
true;
17 if (str[apos] ==
'<') in_clause =
false;
18 if (str[apos] ==
' ' && !in_clause) {
23 std::string cpy = str.substr(apos, bpos - apos);
27 void LogLine(std::ostream& stream, std::string
const& func,
28 std::string
const& message) {
29 stream <<
"[" << func <<
"] " << message <<
"\n";
32 std::string
FnError(std::string
const& message, std::string
const& file,
33 unsigned line, std::string
const& fn) {
35 std::string banner(79,
'*');
38 res +=
"\n " + file +
":" + boost::lexical_cast<std::string>(line);
39 res +=
"\nProblem: " + message;
42 "\nPlease report issues at\n "
43 "https://github.com/cms-analysis/CombineHarvester/issues";
52 "[Timer] %-40s Calls: %-20u Total [s]: %-20.5g Per-call [s]: %-20.5g\n",
53 name_.c_str(), calls_, elapsed_, elapsed_ /
double(calls_));
61 end_ = std::chrono::system_clock::now();
62 elapsed_ += std::chrono::duration<double>(end_ - start_).count();
Determine the total amount of time spent in a function.
FnTimer(std::string name)
std::string GetQualififedName(std::string const &str)
Extracts the fully-qualified function name from a complete function signature.
void LogLine(std::ostream &stream, std::string const &func, std::string const &message)
Writes a logging message to a given ostream.
std::string FnError(std::string const &message, std::string const &file, unsigned line, std::string const &fn)
Generates an error message which includes the name of the calling function and the filename and line ...