Hyperiso 1.0.3
Modular flavour-physics calculations, Wilson coefficients and statistical inference
Loading...
Searching...
No Matches
Utils.cpp File Reference
#include "Utils.h"
Include dependency graph for Utils.cpp:

Go to the source code of this file.

Functions

bool ends_with (const std::string &str, const std::string &suffix)
 Tests whether a string ends with a given suffix.
 
std::vector< std::string > split (const std::string &s, char delimiter)
 Splits a string into parts using a single-character delimiter.
 
std::string doubleToString (double value, int precision)
 Converts a double to a fixed-format string with a given precision.
 
std::string to_lowercase (const std::string &str)
 Returns a lowercase copy of the input string.
 

Function Documentation

◆ doubleToString()

std::string doubleToString ( double  value,
int  precision 
)

Converts a double to a fixed-format string with a given precision.

The output uses std::fixed formatting and precision digits after the decimal point.

Parameters
valueFloating-point value to convert.
precisionNumber of digits after the decimal point.
Returns
Formatted string representation of value.

Definition at line 25 of file Utils.cpp.

◆ ends_with()

bool ends_with ( const std::string &  str,
const std::string &  suffix 
)

Tests whether a string ends with a given suffix.

The comparison is case-sensitive and operates on the raw bytes of the strings.

Parameters
strString to test.
suffixSuffix to look for.
Returns
true if str ends with suffix, false otherwise.

Definition at line 3 of file Utils.cpp.

◆ split()

std::vector< std::string > split ( const std::string &  s,
char  delimiter 
)

Splits a string into parts using a single-character delimiter.

Consecutive delimiters yield empty tokens. The delimiter itself is not included in the resulting strings.

Example:

  • split("a,b,c", ',') → {"a","b","c"}
  • split("a,,c", ',') → {"a","","c"}
Parameters
sInput string to split.
delimiterCharacter used as separator.
Returns
Vector of substrings.

Definition at line 8 of file Utils.cpp.

◆ to_lowercase()

std::string to_lowercase ( const std::string &  str)

Returns a lowercase copy of the input string.

All characters are converted using std::tolower with unsigned char promotion to avoid undefined behavior.

Parameters
strInput string.
Returns
Lowercased copy of str.

Definition at line 31 of file Utils.cpp.