class
#include <src/Base/Print.hpp>
Print Pretty printer base. Contains general purpose printer functions. Using the functions defined here provides formatting, and a consistent look with simple client-side code.
Constructors, destructors, conversion operators
- Print() explicit
- Constructor.
Public functions
- void section(const std::string& t) const
-
template<typename T>void item(const std::string& name, const T& value) const
-
void item(const std::string& name,
const tk::
Timer:: Watch& watch) const -
void perfitem(const std::string& name,
tk::
real value) const -
template<class ClockFormat>void time(const std::string& t, const std::vector<std::pair<std::string, ClockFormat>>& clock) const
- void diag(const std::vector<std::string>& labels, const std::vector<std::string>& values) const
- void diagstart(const std::string& msg) const
- void diagend(const std::string& msg) const
-
template<std::size_t N>void progress(const std::array<std::string, N>& prefix, const std::array<int, N>& done, const std::array<int, N>& max, std::size_t& progress_size) const
- void version(const std::string& executable, const std::string& git_commit) const
- void mandatory(const std::string& args) const
- void usage(const std::string& example, const std::string& msg) const
-
template<typename Info>void bounds(const Info& info) const
- Print lower and upper bounds for a keyword if defined.
- void unithead(const std::string& t, const std::string& group) const
- void test(std::size_t ncomplete, std::size_t nfail, const std::vector<std::string>& status)
- void headerInciter() const
- void headerUnitTest() const
- void headerMeshConv() const
Friends
-
template<typename T>auto operator<<(const Print& os, const T& t) -> const Print&
Function documentation
void tk:: Print:: section(const std::string& t) const
Parameters | |
---|---|
t in | Section title to be printed |
Formatted print of section title
template<typename T>
void tk:: Print:: item(const std::string& name,
const T& value) const
Parameters | |
---|---|
name in | Item name to be printed |
value in | Item value to be printed |
Formatted print of item: name : value
void tk:: Print:: item(const std::string& name,
const tk:: Timer:: Watch& watch) const
Parameters | |
---|---|
name in | Item name to be printed |
watch in | Watch (in hours, minutes, seconds) to be printed as item value |
Formatted print of item: h:m:s.
template<class ClockFormat>
void tk:: Print:: time(const std::string& t,
const std::vector<std::pair<std::string, ClockFormat>>& clock) const
Parameters | |
---|---|
t in | Title of section containing a list of elapsed times |
clock in | std::vector of strings (clock names) and associated timers which could be in various formats as long as there is a corresponding item() overload that can apply operator << for outputing their value to an output stream. Examples of allowed ClockFormats are: tk:: |
Formatted print of elapsed times
void tk:: Print:: diag(const std::vector<std::string>& labels,
const std::vector<std::string>& values) const
Parameters | |
---|---|
labels in | Label parts of diagnostics message |
values in | Value parts of diagnostics message |
Echo formatted print of a diagnostics message within a progress section
void tk:: Print:: diagstart(const std::string& msg) const
Parameters | |
---|---|
msg in | First part of message to print as a diagnostics message |
Start formatted print of a diagnostics message Start formatted print of a diagnostics message
void tk:: Print:: diagend(const std::string& msg) const
Parameters | |
---|---|
msg in | Last part of message to print as a diagnostics message |
Finish formatted print of a diagnostics message
template<std::size_t N>
void tk:: Print:: progress(const std::array<std::string, N>& prefix,
const std::array<int, N>& done,
const std::array<int, N>& max,
std::size_t& progress_size) const
Parameters | |
---|---|
prefix in | Strings to output prefixing the progress report |
done in | Array of integers indicating how many have been done |
max in | Array of integers indicating how many to be done |
progress_size in | Size of previous progress report (to overwrite) |
Echo formatted print of a progress message All input arrays are the same size. The prefix strings are optional, i.e., they can be empty strings. The function generates an output to the stream configured in the following fashion: pre1[done1/max1], pre2[done2/max2], ..., e.g., r:[1/3], b[2/8]. Whenever this function is called, a number of backspaces are put into the stream so that the new progress report string overwrites the old one. In order to backtrack the correct amount, the length of the old progress report is stored (by whatever object holds us) and passed in by reference in progress_size, which is overwritten here once it has been used for backtracking. Therefore, for restarting a new series of progress reports, this variable must be zeroed. Also, it is best to not to interleave multiple tasks, because even if a different progress_size is kept for each, there is no regard as to which line we output to in the stream. In other words, multiple task outputs will be intermingled, leading to confusing output.
void tk:: Print:: test(std::size_t ncomplete,
std::size_t nfail,
const std::vector<std::string>& status)
Print one-liner info for test
Columns: [done/failed]
- done: number of tests completed so far
- failed: number of failed tests so far name of the test group name of the test result (with additional info if failed) Assumed fields for status:
- status[0]: test group name
- status[1]: test name
- status[2]: result (tut::test_result::result_type as string)
- status[3]: exception message for failed test
- status[4]: exception type id for failed test
void tk:: Print:: headerInciter() const
Print Inciter header. Text ASCII Art Generator used for executable names: http:/
void tk:: Print:: headerUnitTest() const
Print UnitTest header. Text ASCII Art Generator used for executable names: http:/
void tk:: Print:: headerMeshConv() const
Print MeshConv header. Text ASCII Art Generator used for executable names: http:/
template<typename T>
const Print& operator<<(const Print& os,
const T& t)
Parameters | |
---|---|
os in | Reference to pretty printer object |
t in | Reference to an arbitrary object of type T. T must define operator<< for std::ostream-compatible streams. |
Returns | The internal stream buffer of the stream |
Operator << for printing any type to the verbose stream.