guts
|
The gutilities library provides a suite of basic utilities encapsulated within a dedicated namespace, offering a range of functionality for string manipulation, file path operations, and unit conversions.
The gutilities
namespace includes essential utility functions such as:
std::string removeLeadingAndTrailingSpacesFromString(const std::string &input)
std::vector<std::string> getStringVectorFromString(const std::string &input)
std::string getFileFromPath(const std::string &path)
std::string getDirFromPath(const std::string &path)
double getG4Number(const std::string &v, bool warnIfNotUnit = false)
The gutilities library adheres to several conventions for consistent output formatting and verbosity:
FRED("my sentence")
to print in red.FATALERRORL
, GWARNING
, POINTITEM
, CIRCLEITEM
, and SQUAREITEM
to standardize message outputs and highlight key information.The following example demonstrates how to use getStringVectorFromString
to split a string into individual words:
Usage:
Run the above code with a string input to see each word printed on a new line:
The library provides additional utility functions, such as:
std::string replaceCharInStringWithChars(const std::string &input, const std::string &toReplace, const std::string &replacement)
bool directoryExists(const std::string &path)
std::vector<std::string> getListOfFilesInDirectory(const std::string &dirName, const std::vector<std::string> &extensions)
These utilities are designed to streamline common tasks in software development by providing efficient and easy-to-use functions for string manipulation and file system operations.
The GOptions framework is continuously integrated and tested to ensure stability and reliability across updates.