BmnRoot
Loading...
Searching...
No Matches
function_set.h File Reference
#include <algorithm>
#include <cstdint>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <memory>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <sys/stat.h>
#include <unistd.h>
#include <vector>
Include dependency graph for function_set.h:
This graph shows which files directly or indirectly include this file:

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)
 
vector< string > string_to_vector (string str, const string &delimiters=",;")
 
string find_first_number (const string &str, bool isOnlyPositive=true)
 
string find_first_double_number (const string &str, bool isOnlyPositive=true)
 
string find_last_number (const string &str, bool isOnlyPositive=true)
 
string find_last_double_number (const string &str, bool isOnlyPositive=true)
 
string find_first_number (const string &str, size_t &beg_pos, size_t &end_pos, bool isOnlyPositive=true)
 
string find_first_double_number (const string &str, size_t &beg_pos, size_t &end_pos, bool isOnlyPositive=true)
 
string find_last_number (const string &str, size_t &beg_pos, size_t &end_pos, bool isOnlyPositive=true)
 
string find_last_double_number (const string &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 (const string &full_str, const string &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 58 of file function_set.h.

Enumeration Type Documentation

◆ BATCH_SYSTEM_NAME

Enumerator
SGE_BATCH_SYSTEM 
TORQUE_BATCH_SYSTEM 
SLURM_BATCH_SYSTEM 

Definition at line 31 of file function_set.h.

Function Documentation

◆ absolute_path()

string absolute_path ( string  path)

Definition at line 215 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 403 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 439 of file function_set.h.

References log(), and string_format().

◆ check_directory_exist()

int check_directory_exist ( const char *  path)

Definition at line 742 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 884 of file function_set.h.

◆ convert_pchar_to_lowercase_new()

char * convert_pchar_to_lowercase_new ( char *  input_char_array)

Definition at line 630 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 876 of file function_set.h.

◆ create_directory()

int create_directory ( const char *  path)

Definition at line 755 of file function_set.h.

◆ create_directory_tree()

int create_directory_tree ( const char *  path)

Definition at line 772 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 366 of file function_set.h.

◆ endswith()

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

Definition at line 727 of file function_set.h.

◆ expand_path()

string expand_path ( string  path)

Definition at line 166 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 ( const string &  str,
bool  isOnlyPositive = true 
)

Definition at line 531 of file function_set.h.

References m.

◆ find_first_double_number() [2/2]

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

Definition at line 595 of file function_set.h.

References m.

◆ find_first_number() [1/2]

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

Definition at line 501 of file function_set.h.

References m.

◆ find_first_number() [2/2]

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

Definition at line 561 of file function_set.h.

References m.

◆ find_last_double_number() [1/2]

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

Definition at line 544 of file function_set.h.

References m.

◆ find_last_double_number() [2/2]

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

Definition at line 610 of file function_set.h.

References m.

◆ find_last_number() [1/2]

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

Definition at line 514 of file function_set.h.

References m.

◆ find_last_number() [2/2]

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

Definition at line 576 of file function_set.h.

References m.

◆ get_app_dir_linux()

string get_app_dir_linux ( )

Definition at line 322 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 307 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 239 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 860 of file function_set.h.

◆ get_directory_name()

string get_directory_name ( string  file_path)

Definition at line 840 of file function_set.h.

◆ get_directory_path()

string get_directory_path ( string  file_path)

Definition at line 829 of file function_set.h.

◆ get_file_name()

string get_file_name ( string  path)

Definition at line 802 of file function_set.h.

◆ get_file_name_with_ext()

string get_file_name_with_ext ( string  path)

Definition at line 818 of file function_set.h.

◆ get_linux_processor_count()

int get_linux_processor_count ( )

Definition at line 233 of file function_set.h.

◆ hex_string_to_int()

int hex_string_to_int ( string  hex_string)

Definition at line 392 of file function_set.h.

◆ int_to_hex_string()

string int_to_hex_string ( int  number)

Definition at line 384 of file function_set.h.

◆ int_to_string()

string int_to_string ( int  number)

Definition at line 376 of file function_set.h.

◆ is_string_number()

bool is_string_number ( const string &  s)

Definition at line 466 of file function_set.h.

◆ reduce()

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

Definition at line 706 of file function_set.h.

References trim().

◆ replace_char()

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

Definition at line 679 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 660 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 647 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 352 of file function_set.h.

Referenced by absolute_path(), and byte_size_to_human().

◆ string_to_vector()

vector< string > string_to_vector ( string  str,
const string &  delimiters = ",;" 
)

Definition at line 475 of file function_set.h.

References i.

Referenced by ParseMacroFiles().

◆ system_command_linux()

int system_command_linux ( string  aCommand,
string &  result 
)

Definition at line 144 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 693 of file function_set.h.

Referenced by reduce().