BmnRoot
Loading...
Searching...
No Matches
function_set.h File Reference
#include <unistd.h>
#include <iomanip>
#include <iostream>
#include <cstring>
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <sstream>
#include <ctime>
#include <math.h>
#include <memory>
#include <limits.h>
#include <sys/stat.h>
Include dependency graph for function_set.h:

Go to the source code of this file.

Macros

#define CHECK_BIT(variable, position)   ((variable) & (1ULL<<(position)))
 

Enumerations

enum  BATCH_SYSTEM_NAME { SGE_BATCH_SYSTEM , TORQUE_BATCH_SYSTEM , SLURM_BATCH_SYSTEM }
 

Functions

int system_command_linux (string aCommand, string &result)
 
string expand_path (string path)
 
string absolute_path (string path)
 
int get_linux_processor_count ()
 
int get_batch_processor_count (BATCH_SYSTEM_NAME batch_system, string queue_name="")
 
string get_app_name_linux ()
 
string get_app_dir_linux ()
 
template<typename ... Args>
string string_format (const string &format, Args ... args)
 
string double_to_string (double number, int precision, bool is_fixed_point=true)
 
string int_to_string (int number)
 
string int_to_hex_string (int number)
 
int hex_string_to_int (string hex_string)
 
double byte_size_to_double (string byte_size_in_string, char convert_to='B')
 
string byte_size_to_human (uint64_t byte_size, unsigned precision=2)
 
bool is_string_number (const string &s)
 
string find_first_number (string const &str, bool isOnlyPositive=true)
 
string find_first_double_number (string const &str, bool isOnlyPositive=true)
 
string find_last_number (string const &str, bool isOnlyPositive=true)
 
string find_last_double_number (string const &str, bool isOnlyPositive=true)
 
string find_first_number (string const &str, size_t &beg_pos, size_t &end_pos, bool isOnlyPositive=true)
 
string find_first_double_number (string const &str, size_t &beg_pos, size_t &end_pos, bool isOnlyPositive=true)
 
string find_last_number (string const &str, size_t &beg_pos, size_t &end_pos, bool isOnlyPositive=true)
 
string find_last_double_number (string const &str, size_t &beg_pos, size_t &end_pos, bool isOnlyPositive=true)
 
char * convert_pchar_to_lowercase_new (char *input_char_array)
 
void replace_string_in_text (string &text, string old_substring, string new_substring)
 
void replace_string_in_text (string &text, string old_substring, int new_subinteger)
 
int replace_char (char *&str, char find, char replace)
 
string trim (const string &str, const string &whitespace=" \t\r")
 
string reduce (const string &str, const string &fill=" ", const string &whitespace=" \t\r")
 
bool endswith (string const &full_str, string const &ending)
 
int check_directory_exist (const char *path)
 
int create_directory (const char *path)
 
int create_directory_tree (const char *path)
 
string get_file_name (string path)
 
string get_file_name_with_ext (string path)
 
string get_directory_path (string file_path)
 
string get_directory_name (string file_path)
 
string get_current_date ()
 
tm convert_string_to_datetime (string str_datetime, const char *format="%d.%m.%Y %H:%M:%S")
 
struct timespec convert_double_to_timespec (double sec)
 

Macro Definition Documentation

◆ CHECK_BIT

#define CHECK_BIT (   variable,
  position 
)    ((variable) & (1ULL<<(position)))

Definition at line 50 of file function_set.h.

Enumeration Type Documentation

◆ BATCH_SYSTEM_NAME

Enumerator
SGE_BATCH_SYSTEM 
TORQUE_BATCH_SYSTEM 
SLURM_BATCH_SYSTEM 

Definition at line 28 of file function_set.h.

Function Documentation

◆ absolute_path()

string absolute_path ( string  path)

Definition at line 202 of file function_set.h.

References string_format(), and system_command_linux().

◆ byte_size_to_double()

double byte_size_to_double ( string  byte_size_in_string,
char  convert_to = 'B' 
)

Definition at line 398 of file function_set.h.

References replace_string_in_text().

◆ byte_size_to_human()

string byte_size_to_human ( uint64_t  byte_size,
unsigned  precision = 2 
)

// SIMPLE METHOD (cycle) int order = 0; while (byte_size >= 1024 && order < FILE_SIZE_UNITS.Length - 1) { order++; byte_size = byte_size/1024; }

Adjust the format string to your preferences. For example "{0:0.#}{1}" would show a single decimal place, and no space. return string_format("%.3f %s", byte_size, FILE_SIZE_UNITS[order]);

Definition at line 433 of file function_set.h.

References log(), and string_format().

◆ check_directory_exist()

int check_directory_exist ( const char *  path)

Definition at line 735 of file function_set.h.

Referenced by create_directory_tree().

◆ convert_double_to_timespec()

struct timespec convert_double_to_timespec ( double  sec)

Definition at line 883 of file function_set.h.

◆ convert_pchar_to_lowercase_new()

char * convert_pchar_to_lowercase_new ( char *  input_char_array)

Definition at line 612 of file function_set.h.

References i.

◆ convert_string_to_datetime()

tm convert_string_to_datetime ( string  str_datetime,
const char *  format = "%d.%m.%Y %H:%M:%S" 
)

Definition at line 875 of file function_set.h.

◆ create_directory()

int create_directory ( const char *  path)

Definition at line 748 of file function_set.h.

◆ create_directory_tree()

int create_directory_tree ( const char *  path)

Definition at line 768 of file function_set.h.

References check_directory_exist(), and create_directory_tree().

Referenced by create_directory_tree().

◆ double_to_string()

string double_to_string ( double  number,
int  precision,
bool  is_fixed_point = true 
)

Definition at line 362 of file function_set.h.

◆ endswith()

bool endswith ( string const &  full_str,
string const &  ending 
)

Definition at line 719 of file function_set.h.

◆ expand_path()

string expand_path ( string  path)

Definition at line 153 of file function_set.h.

References expand_path(), and v.

Referenced by expand_path().

◆ find_first_double_number() [1/2]

string find_first_double_number ( string const &  str,
bool  isOnlyPositive = true 
)

Definition at line 504 of file function_set.h.

References m.

◆ find_first_double_number() [2/2]

string find_first_double_number ( string const &  str,
size_t &  beg_pos,
size_t &  end_pos,
bool  isOnlyPositive = true 
)

Definition at line 574 of file function_set.h.

References m.

◆ find_first_number() [1/2]

string find_first_number ( string const &  str,
bool  isOnlyPositive = true 
)

Definition at line 471 of file function_set.h.

References m.

◆ find_first_number() [2/2]

string find_first_number ( string const &  str,
size_t &  beg_pos,
size_t &  end_pos,
bool  isOnlyPositive = true 
)

Definition at line 537 of file function_set.h.

References m.

◆ find_last_double_number() [1/2]

string find_last_double_number ( string const &  str,
bool  isOnlyPositive = true 
)

Definition at line 518 of file function_set.h.

References m.

◆ find_last_double_number() [2/2]

string find_last_double_number ( string const &  str,
size_t &  beg_pos,
size_t &  end_pos,
bool  isOnlyPositive = true 
)

Definition at line 590 of file function_set.h.

References m.

◆ find_last_number() [1/2]

string find_last_number ( string const &  str,
bool  isOnlyPositive = true 
)

Definition at line 485 of file function_set.h.

References m.

◆ find_last_number() [2/2]

string find_last_number ( string const &  str,
size_t &  beg_pos,
size_t &  end_pos,
bool  isOnlyPositive = true 
)

Definition at line 553 of file function_set.h.

References m.

◆ get_app_dir_linux()

string get_app_dir_linux ( )

Definition at line 317 of file function_set.h.

References get_app_name_linux(), and system_command_linux().

◆ get_app_name_linux()

string get_app_name_linux ( )

Definition at line 302 of file function_set.h.

References system_command_linux().

Referenced by get_app_dir_linux().

◆ get_batch_processor_count()

int get_batch_processor_count ( BATCH_SYSTEM_NAME  batch_system,
string  queue_name = "" 
)

Definition at line 224 of file function_set.h.

References SGE_BATCH_SYSTEM, SLURM_BATCH_SYSTEM, and TORQUE_BATCH_SYSTEM.

◆ get_current_date()

string get_current_date ( )

Definition at line 859 of file function_set.h.

◆ get_directory_name()

string get_directory_name ( string  file_path)

Definition at line 837 of file function_set.h.

◆ get_directory_path()

string get_directory_path ( string  file_path)

Definition at line 826 of file function_set.h.

◆ get_file_name()

string get_file_name ( string  path)

Definition at line 799 of file function_set.h.

◆ get_file_name_with_ext()

string get_file_name_with_ext ( string  path)

Definition at line 815 of file function_set.h.

◆ get_linux_processor_count()

int get_linux_processor_count ( )

Definition at line 218 of file function_set.h.

◆ hex_string_to_int()

int hex_string_to_int ( string  hex_string)

Definition at line 387 of file function_set.h.

◆ int_to_hex_string()

string int_to_hex_string ( int  number)

Definition at line 379 of file function_set.h.

◆ int_to_string()

string int_to_string ( int  number)

Definition at line 371 of file function_set.h.

◆ is_string_number()

bool is_string_number ( const string &  s)

Definition at line 463 of file function_set.h.

◆ reduce()

string reduce ( const string &  str,
const string &  fill = " ",
const string &  whitespace = " \t\r" 
)

Definition at line 697 of file function_set.h.

References trim().

◆ replace_char()

int replace_char ( char *&  str,
char  find,
char  replace 
)

Definition at line 669 of file function_set.h.

◆ replace_string_in_text() [1/2]

void replace_string_in_text ( string &  text,
string  old_substring,
int  new_subinteger 
)

Definition at line 646 of file function_set.h.

◆ replace_string_in_text() [2/2]

void replace_string_in_text ( string &  text,
string  old_substring,
string  new_substring 
)

Definition at line 630 of file function_set.h.

Referenced by byte_size_to_double().

◆ string_format()

template<typename ... Args>
string string_format ( const string &  format,
Args ...  args 
)

Definition at line 350 of file function_set.h.

Referenced by absolute_path(), and byte_size_to_human().

◆ system_command_linux()

int system_command_linux ( string  aCommand,
string &  result 
)

Definition at line 129 of file function_set.h.

References f.

Referenced by absolute_path(), get_app_dir_linux(), and get_app_name_linux().

◆ trim()

string trim ( const string &  str,
const string &  whitespace = " \t\r" 
)

Definition at line 684 of file function_set.h.

Referenced by reduce().