BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
function_set.h File Reference
#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 dependency graph for function_set.h:

Go to the source code of this file.

Macros

#define CHECK_BIT(variable, 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 )
Value:
((variable) & (1ULL << (position)))

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

References string_format(), and system_command_linux().

Here is the call graph for this function:

◆ 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().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 434 of file function_set.h.

References order, and string_format().

Referenced by printBranchSummary(), and printTreeSummary().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ check_directory_exist()

int check_directory_exist ( const char * path)

Definition at line 712 of file function_set.h.

Referenced by create_directory_tree().

Here is the caller graph for this function:

◆ convert_double_to_timespec()

struct timespec convert_double_to_timespec ( double sec)

Definition at line 854 of file function_set.h.

References convert_double_to_timespec().

Referenced by convert_double_to_timespec(), and BmnFillDstTask::Exec().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_pchar_to_lowercase_new()

char * convert_pchar_to_lowercase_new ( char * input_char_array)

Definition at line 600 of file function_set.h.

References i.

Referenced by main(), and ParseMacroFiles().

Here is the caller graph for this function:

◆ convert_string_to_datetime()

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

Definition at line 846 of file function_set.h.

◆ create_directory()

int create_directory ( const char * path)

Definition at line 725 of file function_set.h.

◆ create_directory_tree()

int create_directory_tree ( const char * path)

Definition at line 742 of file function_set.h.

References check_directory_exist(), and create_directory_tree().

Referenced by create_directory_tree().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ double_to_string()

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

Definition at line 361 of file function_set.h.

◆ endswith()

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

Definition at line 697 of file function_set.h.

◆ expand_path()

string expand_path ( string path)

Definition at line 161 of file function_set.h.

References expand_path(), and v.

Referenced by append_input_files_from_json(), expand_path(), and ParseMacroFiles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_first_double_number() [1/2]

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

Definition at line 501 of file function_set.h.

References m, and n.

◆ 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 565 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, and n.

Referenced by check_missing_files(), UniParser::ConvertElogCsv(), form_file_name(), get_batch_queue_job_count(), main(), UniParser::ParseDb2Db(), and ThreadLocalProcess().

Here is the caller graph for this function:

◆ 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 531 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 514 of file function_set.h.

References m, and n.

Referenced by UniParser::ConvertElogCsv().

Here is the caller graph for this function:

◆ 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 580 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 484 of file function_set.h.

References m, and n.

Referenced by check_event_count(), del_files_not_in_db(), and form_file_name().

Here is the caller graph for this function:

◆ 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 546 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().

Referenced by main(), and ThreadLocalProcess().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_batch_processor_count()

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

Definition at line 234 of file function_set.h.

References SGE_BATCH_SYSTEM, SLURM_BATCH_SYSTEM, and TORQUE_BATCH_SYSTEM.

Referenced by main().

Here is the caller graph for this function:

◆ get_current_date()

string get_current_date ( )

Definition at line 830 of file function_set.h.

Referenced by UniGenerateClasses::GenerateClasses().

Here is the caller graph for this function:

◆ get_directory_name()

string get_directory_name ( string file_path)

Definition at line 810 of file function_set.h.

Referenced by form_file_name().

Here is the caller graph for this function:

◆ get_directory_path()

string get_directory_path ( string file_path)

Definition at line 799 of file function_set.h.

Referenced by CopyExtraGetFiles(), main(), SubThreadProcessFile(), and ThreadLocalProcess().

Here is the caller graph for this function:

◆ get_file_name()

string get_file_name ( string path)

Definition at line 772 of file function_set.h.

Referenced by check_missing_files(), and form_file_name().

Here is the caller graph for this function:

◆ get_file_name_with_ext()

string get_file_name_with_ext ( string path)

Definition at line 788 of file function_set.h.

Referenced by CopyExtraGetFiles(), form_file_name(), main(), ParseMacroFiles(), remove_raw_files(), and ThreadLocalProcess().

Here is the caller graph for this function:

◆ get_linux_processor_count()

int get_linux_processor_count ( )

Definition at line 228 of file function_set.h.

Referenced by main().

Here is the caller graph for this function:

◆ hex_string_to_int()

int hex_string_to_int ( string hex_string)

Definition at line 387 of file function_set.h.

References x.

◆ 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.

Referenced by GenerateOutputFilePath(), main(), and write_string_to_db().

Here is the caller graph for this function:

◆ is_string_number()

bool is_string_number ( const string & s)

Definition at line 461 of file function_set.h.

Referenced by UniParser::ConvertElogCsv(), main(), ParseMacroFiles(), and UniParser::ParseTxtNoise2Db().

Here is the caller graph for this function:

◆ reduce()

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

Definition at line 676 of file function_set.h.

References trim().

Referenced by UniParser::ParseTxt2Struct(), and UniParser::ParseTxtNoise2Db().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ replace_char()

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

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

Referenced by byte_size_to_double(), UniParser::ConvertElogCsv(), form_file_name(), main(), ParseMacroFiles(), ThreadLocalProcess(), and write_string_to_db().

Here is the caller graph for this function:

◆ string_format()

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

Definition at line 347 of file function_set.h.

Referenced by absolute_path(), and byte_size_to_human().

Here is the caller graph for this function:

◆ system_command_linux()

int system_command_linux ( string aCommand,
string & result )

Definition at line 139 of file function_set.h.

References f.

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

Here is the caller graph for this function:

◆ trim()

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

Definition at line 663 of file function_set.h.

Referenced by UniParser::ConvertElogCsv(), UniGenerateClasses::GenerateClasses(), main(), UniParser::ParseCsv2Db(), ParseMacroFiles(), UniParser::ParseTxt2Db(), UniParser::ParseTxtNoise2Db(), reduce(), and write_string_to_db().

Here is the caller graph for this function: