Loading [MathJax]/extensions/tex2jax.js
Parallel numerical verification of the σ_odd problem  October 6, 2018
All Classes Namespaces Files Functions Variables Typedefs Macros
Namespaces | Macros | Functions
helper.hpp File Reference

Some generic helper functions for programs. More...

Go to the source code of this file.

Namespaces

 helper
 Some generic helper functions for programs.
 

Macros

#define GET_OVERLOAD_(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, NAME, ...)   NAME
 From "Variadic macros tricks" https://codecraft.co/2014/11/25/variadic-macros-tricks/. More...
 
#define TSV1_(a)
 
#define TSV2_(a, b)
 
#define TSV3_(a, b, c)
 
#define TSV4_(a, b, c, d)
 
#define TSV5_(a, b, c, d, e)
 
#define TSV6_(a, b, c, d, e, f)
 
#define TSV7_(a, b, c, d, e, f, g)
 
#define TSV8_(a, b, c, d, e, f, g, h)
 
#define TSV9_(a, b, c, d, e, f, g, h, i)
 
#define TSV10_(a, b, c, d, e, f, g, h, i, j)
 
#define PRINT_LIST(l)
 Print to stdcerr the element of the list l, separated by comma. More...
 
#define STR(x)   STRINGIFY(x)
 Convert the value of the macro x to a literal string. More...
 
#define STRINGIFY(x)   #x
 Convert the name of the macro x to a literal string. More...
 
#define TSV(...)
 Print to stdout all parameters separated by tabulation. More...
 

Functions

std::string helper::concat_path (std::string path1, std::string path2)
 Return the path composed by path1/path2. More...
 
std::string helper::duration_ms_to_string (double duration_ms)
 Return a string with the duration expressed in milliseconds, seconds, minutes and hours, separated by tabulation. More...
 
std::string helper::duration_to_string (std::chrono::duration< double > duration_second)
 Return a string with the duration expressed in milliseconds, seconds, minutes and hours, separated by tabulation. More...
 
std::string helper::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. More...
 
std::string helper::get_string (int argc, const char *const argv[], unsigned int i, void(*help_and_exit_function)()=nullptr)
 Return argv[i] converted in string. More...
 
unsigned int helper::get_uint (int argc, const char *const argv[], unsigned int i, void(*help_and_exit_function)()=nullptr)
 Return argv[i] converted in integer. More...
 
unsigned long helper::get_ulong (int argc, const char *const argv[], unsigned int i, void(*help_and_exit_function)()=nullptr)
 Return argv[i] converted in integer. More...
 
bool helper::is_file_exists (std::string filename)
 Return true iff the file (or directory) exists. More...
 
void helper::print_intern_config_compiler ()
 Print to stdcout the intern configuration of the compiler. More...
 
std::string helper::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. More...
 
std::string helper::to_string (bool b)
 Return the string "true" if b, else "false". More...
 

Detailed Description

Some generic helper functions for programs.

(September 14, 2018) GPLv3 — Copyright (C) 2017, 2018 Olivier Pirson http://www.opimedia.be/

Definition in file helper.hpp.

Macro Definition Documentation

◆ GET_OVERLOAD_

#define GET_OVERLOAD_ (   _1,
  _2,
  _3,
  _4,
  _5,
  _6,
  _7,
  _8,
  _9,
  _10,
  NAME,
  ... 
)    NAME

From "Variadic macros tricks" https://codecraft.co/2014/11/25/variadic-macros-tricks/.

Definition at line 29 of file helper.hpp.

◆ PRINT_LIST

#define PRINT_LIST (   l)
Value:
{ \
std::cerr << '(' << l.size() << ')'; \
for (auto x : l) { \
std::cerr << ',' << x; \
} \
std::cerr << std::endl; \
}

Print to stdcerr the element of the list l, separated by comma.

(Useful during development phase.)

Parameters
literable

Definition at line 90 of file helper.hpp.

◆ STR

#define STR (   x)    STRINGIFY(x)

Convert the value of the macro x to a literal string.

Parameters
xmacro

Definition at line 104 of file helper.hpp.

◆ STRINGIFY

#define STRINGIFY (   x)    #x

Convert the name of the macro x to a literal string.

Parameters
xmacro

Definition at line 111 of file helper.hpp.

◆ TSV

#define TSV (   ...)
Value:
GET_OVERLOAD_(__VA_ARGS__, \
TSV4_, TSV3_, TSV2_, TSV1_)(__VA_ARGS__)
#define TSV9_(a, b, c, d, e, f, g, h, i)
Definition: helper.hpp:67
#define TSV1_(a)
Definition: helper.hpp:32
#define TSV2_(a, b)
Definition: helper.hpp:36
#define TSV3_(a, b, c)
Definition: helper.hpp:40
#define TSV7_(a, b, c, d, e, f, g)
Definition: helper.hpp:57
#define TSV8_(a, b, c, d, e, f, g, h)
Definition: helper.hpp:62
#define TSV10_(a, b, c, d, e, f, g, h, i, j)
Definition: helper.hpp:72
#define TSV4_(a, b, c, d)
Definition: helper.hpp:44
#define GET_OVERLOAD_(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, NAME,...)
From "Variadic macros tricks" https://codecraft.co/2014/11/25/variadic-macros-tricks/.
Definition: helper.hpp:29
#define TSV6_(a, b, c, d, e, f)
Definition: helper.hpp:52
#define TSV5_(a, b, c, d, e)
Definition: helper.hpp:48

Print to stdout all parameters separated by tabulation.

If a NTSV macro is defined then do nothing.

(Useful during development phase.)

Definition at line 247 of file helper.hpp.

◆ TSV10_

#define TSV10_ (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
  i,
 
)
Value:
{ \
std::cerr << a << '\t' << b << '\t' << c << '\t' << d << '\t' << e << '\t' \
<< f << '\t' << g << '\t' << h << '\t' << i << '\t' << j << std::endl; \
}

Definition at line 72 of file helper.hpp.

◆ TSV1_

#define TSV1_ (   a)
Value:
{ \
std::cerr << a << std::endl; \
}

Definition at line 32 of file helper.hpp.

◆ TSV2_

#define TSV2_ (   a,
 
)
Value:
{ \
std::cerr << a << '\t' << b << std::endl; \
}

Definition at line 36 of file helper.hpp.

◆ TSV3_

#define TSV3_ (   a,
  b,
 
)
Value:
{ \
std::cerr << a << '\t' << b << '\t' << c << std::endl; \
}

Definition at line 40 of file helper.hpp.

◆ TSV4_

#define TSV4_ (   a,
  b,
  c,
 
)
Value:
{ \
std::cerr << a << '\t' << b << '\t' << c << '\t' << d << std::endl; \
}

Definition at line 44 of file helper.hpp.

◆ TSV5_

#define TSV5_ (   a,
  b,
  c,
  d,
 
)
Value:
{ \
std::cerr << a << '\t' << b << '\t' << c << '\t' << d << '\t' << e << std::endl; \
}

Definition at line 48 of file helper.hpp.

◆ TSV6_

#define TSV6_ (   a,
  b,
  c,
  d,
  e,
 
)
Value:
{ \
std::cerr << a << '\t' << b << '\t' << c << '\t' << d << '\t' << e << '\t' \
<< f << std::endl; \
}

Definition at line 52 of file helper.hpp.

◆ TSV7_

#define TSV7_ (   a,
  b,
  c,
  d,
  e,
  f,
 
)
Value:
{ \
std::cerr << a << '\t' << b << '\t' << c << '\t' << d << '\t' << e << '\t' \
<< f << '\t' << g << std::endl; \
}

Definition at line 57 of file helper.hpp.

◆ TSV8_

#define TSV8_ (   a,
  b,
  c,
  d,
  e,
  f,
  g,
 
)
Value:
{ \
std::cerr << a << '\t' << b << '\t' << c << '\t' << d << '\t' << e << '\t' \
<< f << '\t' << g << '\t' << h << std::endl; \
}

Definition at line 62 of file helper.hpp.

◆ TSV9_

#define TSV9_ (   a,
  b,
  c,
  d,
  e,
  f,
  g,
  h,
 
)
Value:
{ \
std::cerr << a << '\t' << b << '\t' << c << '\t' << d << '\t' << e << '\t' \
<< f << '\t' << g << '\t' << h << '\t' << i << std::endl; \
}

Definition at line 67 of file helper.hpp.