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

Some generic helper functions for programs. More...

Functions

std::string concat_path (std::string path1, std::string path2)
 Return the path composed by path1/path2. More...
 
std::string 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 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 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 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 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 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 is_file_exists (std::string filename)
 Return true iff the file (or directory) exists. More...
 
void print_intern_config_compiler ()
 Print to stdcout the intern configuration of the compiler. More...
 
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. More...
 
std::string to_string (bool b)
 Return the string "true" if b, else "false". More...
 

Variables

const char sep_ = '/'
 

Detailed Description

Some generic helper functions for programs.

Function Documentation

◆ concat_path()

std::string helper::concat_path ( std::string  path1,
std::string  path2 
)

Return the path composed by path1/path2.

Parameters
path1a valid path
path2a valid relative path

Definition at line 29 of file helper.cpp.

◆ duration_ms_to_string()

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.

Returns
"_ms\t= _s\t= _m\t= _h"

Definition at line 48 of file helper.cpp.

◆ duration_to_string()

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.

Returns
"_ms\t= _s\t= _m\t= _h"

Definition at line 61 of file helper.cpp.

◆ file_to_string()

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.

Definition at line 75 of file helper.cpp.

◆ get_string()

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.

If (help_and_exit_function != nullptr) and (i is not a valid index) then call help_and_exit_function().

Definition at line 92 of file helper.cpp.

◆ get_uint()

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.

If (help_and_exit_function != nullptr) and (i is not a valid index) then call help_and_exit_function().

Definition at line 108 of file helper.cpp.

◆ get_ulong()

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.

If (help_and_exit_function != nullptr) and (i is not a valid index) then call help_and_exit_function().

Definition at line 124 of file helper.cpp.

◆ is_file_exists()

bool helper::is_file_exists ( std::string  filename)

Return true iff the file (or directory) exists.

Definition at line 140 of file helper.cpp.

◆ print_intern_config_compiler()

void helper::print_intern_config_compiler ( )

Print to stdcout the intern configuration of the compiler.

Definition at line 148 of file helper.cpp.

◆ remove_last_if_null()

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.

Definition at line 169 of file helper.cpp.

◆ to_string()

std::string helper::to_string ( bool  b)

Return the string "true" if b, else "false".

Definition at line 177 of file helper.cpp.

Variable Documentation

◆ sep_

const char helper::sep_ = '/'

Definition at line 21 of file helper.cpp.