13 #include "../sigmaodd/helper.hpp" 33 else if (path2.empty()) {
37 if ((path1.back() ==
sep_) && (path2[0] == sep_)) {
38 path2 = path2.substr(1);
41 return ((path1.back() !=
sep_) && (path2[0] != sep_)
42 ? path1 + sep_ + path2
49 const double duration_second = duration_ms/1000;
50 const double duration_minute = duration_ms/(1000*60);
51 const double duration_hour = duration_ms/(1000*60*60);
62 const double duration = duration_second.count();
63 const double duration_millisecond = duration*1000;
64 const double duration_minute = duration/60;
65 const double duration_hour = duration/(60*60);
76 std::ifstream infile(filename, std::ios::in);
77 const std::string s((std::istreambuf_iterator<char>(infile)),
78 std::istreambuf_iterator<char>());
82 std::cerr <<
"! Impossible to read file \"" << filename <<
'"' << std::endl;
92 get_string(
int argc,
const char*
const argv[],
unsigned int i,
93 void (*help_and_exit_function)()) {
94 if (i < static_cast<unsigned int>(argc)) {
98 if (help_and_exit_function !=
nullptr) {
99 (*help_and_exit_function)();
108 get_uint(
int argc,
const char*
const argv[],
unsigned int i,
109 void (*help_and_exit_function)()) {
110 if (i < static_cast<unsigned int>(argc)) {
111 return static_cast<unsigned int>(std::stoul(argv[i]));
114 if (help_and_exit_function !=
nullptr) {
115 (*help_and_exit_function)();
124 get_ulong(
int argc,
const char*
const argv[],
unsigned int i,
125 void (*help_and_exit_function)()) {
126 if (i < static_cast<unsigned int>(argc)) {
127 return std::stoul(argv[i]);
130 if (help_and_exit_function !=
nullptr) {
131 (*help_and_exit_function)();
141 std::ifstream file(filename);
143 return static_cast<bool>(file);
151 "clang " STR(__clang_major__)
"." STR(__clang_minor__)
"." STR(__clang_patchlevel__)
154 "GNU C++ " STR(__GNUG__)
"." STR(__GNUC_MINOR__)
"." STR(__GNUC_PATCHLEVEL__)
170 return (!s.empty() && (s[s.size() - 1] == 0)
171 ? std::string(s.cbegin(), s.cend() - 1)
uint64_t nat_type
Type for natural number used in all code, on 64 bits.
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.
#define STR(x)
Convert the value of the macro x to a literal string.
std::string get_string(int argc, const char *const argv[], unsigned int i, void(*help_and_exit_function)())
Return argv[i] converted in string.
Some generic helper functions for programs.
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".