10 #ifndef PROGS_SRC_COMMON_HELPER_HELPER_HPP_ 11 #define PROGS_SRC_COMMON_HELPER_HELPER_HPP_ 29 #define GET_OVERLOAD_(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, NAME, ...) NAME 33 std::cerr << a << std::endl; \ 36 #define TSV2_(a, b) { \ 37 std::cerr << a << '\t' << b << std::endl; \ 40 #define TSV3_(a, b, c) { \ 41 std::cerr << a << '\t' << b << '\t' << c << std::endl; \ 44 #define TSV4_(a, b, c, d) { \ 45 std::cerr << a << '\t' << b << '\t' << c << '\t' << d << std::endl; \ 48 #define TSV5_(a, b, c, d, e) { \ 49 std::cerr << a << '\t' << b << '\t' << c << '\t' << d << '\t' << e << std::endl; \ 52 #define TSV6_(a, b, c, d, e, f) { \ 53 std::cerr << a << '\t' << b << '\t' << c << '\t' << d << '\t' << e << '\t' \ 57 #define TSV7_(a, b, c, d, e, f, g) { \ 58 std::cerr << a << '\t' << b << '\t' << c << '\t' << d << '\t' << e << '\t' \ 59 << f << '\t' << g << std::endl; \ 62 #define TSV8_(a, b, c, d, e, f, g, h) { \ 63 std::cerr << a << '\t' << b << '\t' << c << '\t' << d << '\t' << e << '\t' \ 64 << f << '\t' << g << '\t' << h << std::endl; \ 67 #define TSV9_(a, b, c, d, e, f, g, h, i) { \ 68 std::cerr << a << '\t' << b << '\t' << c << '\t' << d << '\t' << e << '\t' \ 69 << f << '\t' << g << '\t' << h << '\t' << i << std::endl; \ 72 #define TSV10_(a, b, c, d, e, f, g, h, i, j) { \ 73 std::cerr << a << '\t' << b << '\t' << c << '\t' << d << '\t' << e << '\t' \ 74 << f << '\t' << g << '\t' << h << '\t' << i << '\t' << j << std::endl; \ 90 #define PRINT_LIST(l) { \ 91 std::cerr << '(' << l.size() << ')'; \ 93 std::cerr << ',' << x; \ 95 std::cerr << std::endl; \ 104 #define STR(x) STRINGIFY(x) 111 #define STRINGIFY(x) #x 169 get_string(
int argc,
const char*
const argv[],
unsigned int i,
170 void (*help_and_exit_function)() =
nullptr);
180 get_uint(
int argc,
const char*
const argv[],
unsigned int i,
181 void (*help_and_exit_function)() =
nullptr);
191 get_ulong(
int argc,
const char*
const argv[],
unsigned int i,
192 void (*help_and_exit_function)() =
nullptr);
226 #endif // PROGS_SRC_COMMON_HELPER_HELPER_HPP_ 247 #define TSV(...) GET_OVERLOAD_(__VA_ARGS__, \ 248 TSV10_, TSV9_, TSV8_, TSV7_, TSV6_, TSV5_, \ 249 TSV4_, TSV3_, TSV2_, TSV1_)(__VA_ARGS__) 255 #ifndef PROGS_SRC_COMMON_HELPER_HELPER_HPP_ 256 #endif // PROGS_SRC_COMMON_HELPER_HELPER_HPP_ Some generic helper functions for programs.
std::string remove_last_if_null(const std::string &s)
If s terminates by a null character then return a copy of s without this last character, else return s.
std::string duration_ms_to_string(double duration_ms)
Return a string with the duration expressed in milliseconds, seconds, minutes and hours...
unsigned int get_uint(int argc, const char *const argv[], unsigned int i, void(*help_and_exit_function)())
Return argv[i] converted in integer.
std::string duration_to_string(std::chrono::duration< double > duration_second)
Return a string with the duration expressed in milliseconds, seconds, minutes and hours...
bool is_file_exists(std::string filename)
Return true iff the file (or directory) exists.
std::string get_string(int argc, const char *const argv[], unsigned int i, void(*help_and_exit_function)())
Return argv[i] converted in string.
std::string concat_path(std::string path1, std::string path2)
Return the path composed by path1/path2.
std::string file_to_string(std::string filename)
Read the file and return its content to a string. If failed then print a error message and exit...
void print_intern_config_compiler()
Print to stdcout the intern configuration of the compiler.
unsigned long get_ulong(int argc, const char *const argv[], unsigned int i, void(*help_and_exit_function)())
Return argv[i] converted in integer.
std::string to_string(bool b)
Return the string "true" if b, else "false".