guts
|
Enumerations | |
enum | randomModel { uniform , gaussian , cosine , sphere } |
Enumeration of random models. More... | |
Functions | |
string | removeLeadingAndTrailingSpacesFromString (const std::string &input) |
Removes leading and trailing spaces and tabs from a string. More... | |
string | removeAllSpacesFromString (const std::string &str) |
Removes all spaces from a string. More... | |
string | getFileFromPath (const std::string &path) |
Extracts the filename from a given file path. More... | |
string | getDirFromPath (const std::string &path) |
Extracts the directory path from a given file path. More... | |
vector< std::string > | getStringVectorFromString (const std::string &input) |
Splits a string into a vector of strings using spaces as delimiters. More... | |
string | replaceCharInStringWithChars (const std::string &input, const std::string &toReplace, const std::string &replacement) |
Replaces all occurrences of specified characters in a string with another string. More... | |
string | replaceAllStringsWithString (const string &source, const string &from, const string &to) |
Replaces all occurrences of a substring with another string. More... | |
string | fillDigits (const string &word, const string &c, int ndigits) |
Pads a string with a specified character until it reaches a desired length. More... | |
double | getG4Number (const string &v, bool warnIfNotUnit=false) |
Converts a string representation of a number with optional units to a double. More... | |
double | getG4Number (double input, const string &unit) |
Converts a numeric value with a unit into a G4 number format and returns the converted value. More... | |
vector< double > | getG4NumbersFromStringVector (const vector< string > &vstring, bool warnIfNotUnit=false) |
Converts a vector of strings representing numbers with units to a vector of doubles. More... | |
vector< double > | getG4NumbersFromString (const string &vstring, bool warnIfNotUnit=false) |
Converts a comma-separated string of numbers with units to a vector of doubles. More... | |
string | parseFileAndRemoveComments (const string &filename, const string &commentChars="#", int verbosity=0) |
Parses a file and removes all lines containing specified comment characters. More... | |
string | retrieveStringBetweenChars (const string &input, const string &firstDelimiter, const string &secondDelimiter) |
Retrieves a substring between two specified delimiters in a string. More... | |
vector< string > | getStringVectorFromStringWithDelimiter (const string &input, const string &x) |
Splits a string into a vector of substrings using a specified delimiter. More... | |
bool | directoryExists (const std::string &path) |
Checks if a directory exists at the given path. More... | |
string | searchForDirInLocations (const string &dirName, const vector< string > &possibleLocations) |
Searches for a directory within a list of possible locations. More... | |
bool | hasExtension (const string &filename, const vector< string > &extensions) |
Checks if a filename has one of the specified extensions. More... | |
vector< string > | getListOfFilesInDirectory (const string &dirName, const vector< string > &extensions) |
Retrieves a list of files with specific extensions from a directory. More... | |
string | convertToLowercase (const string &str) |
Converts a string to lowercase. More... | |
template<class KEY , class VALUE > | |
vector< KEY > | getKeys (const map< KEY, VALUE > &map) |
Retrieves all keys from a map. More... | |
randomModel | stringToRandomModel (const std::string &str) |
Converts a string to a corresponding randomModel enum value. More... | |
Enumerator | |
---|---|
uniform | Uniform distribution. |
gaussian | Gaussian distribution. |
cosine | Cosine distribution. |
sphere | Sphere distribution. |
Definition at line 275 of file gutilities.h.
string gutilities::convertToLowercase | ( | const string & | str | ) |
This function transforms all characters in the input string to lowercase.
str | The string to convert. |
Definition at line 360 of file gutilities.cc.
bool gutilities::directoryExists | ( | const std::string & | path | ) |
This function checks the file system to determine whether a directory exists at the specified path.
path | The path to check for a directory. |
true
if the directory exists, false
otherwise. Definition at line 309 of file gutilities.cc.
string gutilities::fillDigits | ( | const string & | word, |
const string & | c, | ||
int | ndigits | ||
) |
This function prepends the specified character to the given word until its length is equal to the specified number of digits.
word | The original string to be padded. |
c | The character to use for padding. |
ndigits | The target length of the padded string. |
Definition at line 102 of file gutilities.cc.
std::string gutilities::getDirFromPath | ( | const std::string & | path | ) |
This function extracts and returns the directory path from a given POSIX file path.
path | The input file path. |
Definition at line 48 of file gutilities.cc.
std::string gutilities::getFileFromPath | ( | const std::string & | path | ) |
This function extracts and returns the filename from a given POSIX file path.
path | The input file path. |
Definition at line 39 of file gutilities.cc.
double gutilities::getG4Number | ( | const string & | v, |
bool | warnIfNotUnit = false |
||
) |
This function extracts the numeric value from the input string and multiplies it by the appropriate unit conversion factor. If no units are specified, it issues a warning if warnIfNotUnit
is true and the value is non-zero.
v | The input string containing the number and optional units, formatted as "number*unit". |
warnIfNotUnit | Flag indicating whether to issue a warning if the units are not present. |
Definition at line 117 of file gutilities.cc.
double gutilities::getG4Number | ( | double | input, |
const string & | unit | ||
) |
This function concatenates a numeric value and a unit into a G4 number format and then converts it to the appropriate unit.
input | The numeric value to convert. |
unit | The unit associated with the numeric value. |
Definition at line 191 of file gutilities.cc.
vector< double > gutilities::getG4NumbersFromString | ( | const string & | vstring, |
bool | warnIfNotUnit = false |
||
) |
This function splits the input string by commas and converts each segment to a double, taking into account the specified units.
vstring | A comma-separated string of numbers with optional units. |
warnIfNotUnit | Flag indicating whether to issue a warning if the units are not present. |
Definition at line 207 of file gutilities.cc.
vector< double > gutilities::getG4NumbersFromStringVector | ( | const vector< string > & | vstring, |
bool | warnIfNotUnit = false |
||
) |
This function parses each string in the input vector and converts it into a double, taking into account the specified units.
vstring | A vector of strings, each containing a number with optional units. |
warnIfNotUnit | Flag indicating whether to issue a warning if the units are not present. |
Definition at line 196 of file gutilities.cc.
vector< KEY > gutilities::getKeys | ( | const map< KEY, VALUE > & | map | ) |
This function extracts and returns all the keys from the given map.
KEY | The type of keys in the map. |
VALUE | The type of values in the map. |
map | The map from which to extract keys. |
Definition at line 368 of file gutilities.cc.
vector< string > gutilities::getListOfFilesInDirectory | ( | const string & | dirName, |
const vector< string > & | extensions | ||
) |
This function opens the specified directory and retrieves a list of files that match the given extensions.
dirName | The name of the directory to search in. |
extensions | A vector of file extensions to filter the files. |
Definition at line 338 of file gutilities.cc.
std::vector< std::string > gutilities::getStringVectorFromString | ( | const std::string & | input | ) |
This function splits the input string into a vector of strings, using spaces as the delimiter, and removes leading and trailing spaces from each substring.
input | The input string to split. |
Definition at line 54 of file gutilities.cc.
vector< string > gutilities::getStringVectorFromStringWithDelimiter | ( | const string & | input, |
const string & | x | ||
) |
This function splits the input string by the given single-character delimiter and returns the substrings as a vector.
input | The input string to split. |
x | The delimiter character used to split the string. |
Definition at line 250 of file gutilities.cc.
bool gutilities::hasExtension | ( | const string & | filename, |
const vector< string > & | extensions | ||
) |
This function checks whether a given filename ends with any of the extensions specified in a list.
filename | The name of the file to check. |
extensions | A vector of extensions to check against. |
true
if the filename has one of the specified extensions, false
otherwise. Definition at line 328 of file gutilities.cc.
string gutilities::parseFileAndRemoveComments | ( | const string & | filename, |
const string & | commentChars = "#" , |
||
int | verbosity = 0 |
||
) |
This function reads the content of a file, removes lines containing the specified comment characters, and returns the processed string.
filename | The name of the file to parse. |
commentChars | The characters indicating the start of a comment in the file. |
verbosity | The verbosity level for logging information. |
Definition at line 212 of file gutilities.cc.
std::string gutilities::removeAllSpacesFromString | ( | const std::string & | str | ) |
This function removes all spaces from the input string and returns the modified string.
str | The input string from which spaces will be removed. |
Definition at line 33 of file gutilities.cc.
std::string gutilities::removeLeadingAndTrailingSpacesFromString | ( | const std::string & | input | ) |
This function trims any whitespace, including spaces and tabs, from both the beginning and the end of the input string.
input | The string to be trimmed. |
Definition at line 20 of file gutilities.cc.
string gutilities::replaceAllStringsWithString | ( | const string & | source, |
const string & | from, | ||
const string & | to | ||
) |
This function searches for all occurrences of the specified substring in the source string and replaces them with the provided replacement string.
source | The original string where replacements will occur. |
from | The substring to be replaced. |
to | The string to replace each occurrence of the substring. |
Definition at line 80 of file gutilities.cc.
std::string gutilities::replaceCharInStringWithChars | ( | const std::string & | input, |
const std::string & | toReplace, | ||
const std::string & | replacement | ||
) |
This function replaces every occurrence of any character from the 'toReplace' string in the input string with the specified replacement string.
input | The input string in which characters are to be replaced. |
toReplace | A string containing characters to be replaced. |
replacement | The string to replace each occurrence of characters in 'toReplace'. |
Definition at line 68 of file gutilities.cc.
string gutilities::retrieveStringBetweenChars | ( | const string & | input, |
const string & | firstDelimiter, | ||
const string & | secondDelimiter | ||
) |
This function extracts and returns the substring found between the first and second delimiters within the input string.
input | The input string containing the delimiters. |
firstDelimiter | The delimiter marking the start of the substring. |
secondDelimiter | The delimiter marking the end of the substring. |
Definition at line 240 of file gutilities.cc.
string gutilities::searchForDirInLocations | ( | const string & | dirName, |
const vector< string > & | possibleLocations | ||
) |
This function iterates over a list of possible locations to find the first directory that matches the specified name.
dirName | The name of the directory to search for. |
possibleLocations | A vector of paths where the directory might be located. |
Definition at line 317 of file gutilities.cc.
randomModel gutilities::stringToRandomModel | ( | const std::string & | str | ) |
This function maps a given string to its corresponding randomModel
enum value. If the string does not match any known model, an exception is thrown.
str | The string representation of the random model. |
randomModel
enum value. std::invalid_argument | if the string does not match any valid model. |
Definition at line 379 of file gutilities.cc.