Documentation for OpenFLUID 2.2.0
openfluid::tools Namespace Reference

Classes

class  ChronFileInterpolator
 
class  ChronFileLinearInterpolator
 
class  ChronologicalSerie
 
class  ColumnTextParser
 
class  Console
 
class  ReaderNextValue
 
class  GenericDistributionBindings
 
class  DistributionBindings
 
class  MulticolDistributionBindings
 
class  DistributionTables
 
class  FileLogger
 
class  Filesystem
 
class  FilesystemPath
 
class  ProgressiveChronFileReader
 
class  ProgressiveColumnFileReader
 
class  RandomNumberGenerator
 Class for management of random. It includes distribution utility functions. More...
 
class  SettingValue
 
class  SettingsBackend
 
class  TemplateProcessor
 
class  Timer
 
struct  UnitVarPair
 
struct  ClassIDVar
 
struct  ClassIDVarPrecision
 

Typedefs

template<typename DataType = double>
using ChronItem_t = std::pair< openfluid::core::DateTime, DataType >
 
using Path = FilesystemPath
 
typedef std::vector< UnitVarPairUnitVarPairs_t
 
typedef std::vector< ClassIDVarUnitVarTriplets_t
 

Functions

template<typename T >
bool convertString (const std::string &StrToConvert, T *Converted)
 
template<typename T >
convertString (const std::string &StrToConvert)
 
template<typename T >
bool convertValue (const T &ValueToConvert, std::string *StrConverted)
 
template<typename T >
std::string convertValue (const T &ValueToConvert)
 
void OPENFLUID_API tokenizeString (const std::string &StrToTokenize, std::vector< std::string > &Tokens, const std::string &Delimiters)
 
std::vector< std::string > OPENFLUID_API splitString (const std::string &StrToSplit, const std::string &Separators, bool ReturnsEmpty=false)
 
std::vector< std::string > OPENFLUID_API splitString (const std::string &StrToSplit, char Separator, bool ReturnsEmpty=false)
 
void OPENFLUID_API stringReplace (std::string &Data, const std::string &ToSearch, const std::string &ReplaceStr)
 
std::vector< openfluid::tools::ClassIDVarstringArrayToClassIDVarList (const std::vector< std::string > &StringArray, bool RemoveFirst=false)
 
std::vector< openfluid::tools::ClassIDVarstringSelectionToClassIDVarList (const std::string &SelectionStr, bool RemoveFirst=false)
 
constexpr auto DatasetNameRuleString ("[A-Za-z0-9]+([A-Za-z0-9_\\.\\-]*)")
 
constexpr auto WareIDRuleString ("[A-Za-z0-9]+([A-Za-z0-9_\\.\\-]*)")
 
constexpr auto WareIDRuleStringAndTpl ("[A-Za-z0-9]+([A-Za-z0-9_@\\.\\-]*)")
 
constexpr auto FragmentNameRuleString ("[A-Za-z]+([A-Za-z0-9_\\.\\-]*)")
 
constexpr auto VariableNameRuleString ("[A-Za-z]+([A-Za-z0-9_\\.\\-]*)")
 
constexpr auto UnitsClassNameRuleString ("^[^;:#]+$")
 
std::string OPENFLUID_API classIDToString (const openfluid::core::UnitsClass_t &Class, openfluid::core::UnitID_t ID)
 
bool OPENFLUID_API isValidAlphaNumName (const std::string &Name)
 
bool OPENFLUID_API isValidDatasetName (const std::string &Name)
 
bool OPENFLUID_API isValidWareID (const openfluid::ware::WareID_t &ID, bool Template=false)
 
bool OPENFLUID_API isValidUnitsClassName (const openfluid::core::UnitsClass_t &Name)
 
bool OPENFLUID_API isValidVariableName (const openfluid::core::VariableName_t &Name)
 
std::string OPENFLUID_API getVariableSelectionRegExp ()
 
bool OPENFLUID_API isValidTypedVariableName (const openfluid::core::VariableName_t &Name)
 
bool OPENFLUID_API isValidAttributeName (const openfluid::core::AttributeName_t &Name)
 
bool OPENFLUID_API extractVariableNameAndType (const openfluid::core::VariableName_t &Name, openfluid::core::VariableName_t &VarName, openfluid::core::Value::Type &VarType)
 
std::string OPENFLUID_API buildGeneratorID (const openfluid::tools::UnitVarPairs_t &VarPairs, const std::string &StrDimType)
 
bool OPENFLUID_API matchWithWildcard (const std::string &Pattern, const std::string &Str)
 
std::string OPENFLUID_API replaceEmptyString (std::string SourceStr, const std::string &ReplaceStr)
 
int OPENFLUID_API compareVersions (const std::string &VersionA, const std::string &VersionB)
 
int OPENFLUID_API compareOpenFLUIDVersions (const std::string &VersionA, const std::string &VersionB, bool Strict=true)
 
void OPENFLUID_API millisleep (const unsigned long MSec)
 
void OPENFLUID_API microsleep (const unsigned long USec)
 
std::string OPENFLUID_API getNowAsString (const std::string &Format)
 
std::string OPENFLUID_API generatePseudoUniqueIdentifier (const unsigned int Length)
 
std::string OPENFLUID_API escapePattern (const std::string &Str)
 
std::string OPENFLUID_API escapeString (const std::string &Str)
 
std::pair< int, int > OPENFLUID_API fromGeometryString (const std::string &Str, const std::string &GeomInfo)
 
std::string OPENFLUID_API toGeometryString (const std::string &GeomInfo, int Value1, int Value2)
 
std::string OPENFLUID_API toLowerCase (const std::string &Str)
 
std::string OPENFLUID_API toUpperCase (const std::string &Str)
 
std::string OPENFLUID_API trimLeft (const std::string &Str)
 
std::string OPENFLUID_API trimRight (const std::string &Str)
 
std::string OPENFLUID_API trim (const std::string &Str)
 
template<typename T >
bool toNumeric (const std::string &Str, T &Num)
 
template<typename T >
toNumeric (const std::string &Str)
 
bool OPENFLUID_API toBoolean (const std::string &Str)
 
bool OPENFLUID_API startsWith (const std::string &Str, const std::string &SubStr)
 
bool OPENFLUID_API endsWith (const std::string &Str, const std::string &SubStr)
 
bool OPENFLUID_API contains (const std::string &Str, const std::string &SubStr, bool CaseSensitive=true)
 
std::string OPENFLUID_API replace (const std::string &Str, const std::string &SearchStr, const std::string &ReplaceStr)
 
template<class... A>
std::string format (const std::string &Fmt, A &&...Args)
 
std::vector< std::string > OPENFLUID_API split (const std::string &Str, const char Sep, bool KeepEmpty=false)
 
std::vector< std::string > OPENFLUID_API split (const std::string &Str, const std::string &SepChars, bool KeepEmpty=false)
 
std::string OPENFLUID_API join (const std::vector< std::string > &Vect, const std::string &Sep)
 
UnitVarTriplets_t OPENFLUID_API deserializeVarTriplets (const std::string &Selection)
 
UnitVarPairs_t OPENFLUID_API deduceVarPairs (const UnitVarTriplets_t &Triplets)
 
std::string OPENFLUID_API serializeVarTriplets (const UnitVarTriplets_t &Triplets)
 

Variables

static std::error_code DefaultErrorCode
 

Typedef Documentation

◆ ChronItem_t

template<typename DataType = double>
using openfluid::tools::ChronItem_t = typedef std::pair<openfluid::core::DateTime,DataType>

◆ Path

◆ UnitVarPairs_t

◆ UnitVarTriplets_t

Function Documentation

◆ buildGeneratorID()

std::string OPENFLUID_API openfluid::tools::buildGeneratorID ( const openfluid::tools::UnitVarPairs_t VarPairs,
const std::string &  StrDimType 
)

Builds a generator ID

Parameters
[in]VarPairsPair of unit classes/variables to create the generator ID
[in]StrDimTypeDimension type of generator

◆ classIDToString()

std::string OPENFLUID_API openfluid::tools::classIDToString ( const openfluid::core::UnitsClass_t Class,
openfluid::core::UnitID_t  ID 
)

Generates string from class and ID of a spatial unit using the "Class#ID" pattern.

Parameters
[in]ClassThe units class
[in]IDThe unit ID
Returns
the generated string

◆ compareOpenFLUIDVersions()

int OPENFLUID_API openfluid::tools::compareOpenFLUIDVersions ( const std::string &  VersionA,
const std::string &  VersionB,
bool  Strict = true 
)

Compares two OpenFLUID software versions. Version number must be formed as major.minor.patch[~status]

Parameters
[in]VersionAthe first version number
[in]VersionBthe second version number
[in]StrictIf true, the comparison include the status part of the version (it ignores it otherwise)
Returns
1 if VersionA is greater than VersionB, -1 if VersionB is greater than VersionA, 0 if versions are equals, -2 if a version format is not well-formed

◆ compareVersions()

int OPENFLUID_API openfluid::tools::compareVersions ( const std::string &  VersionA,
const std::string &  VersionB 
)

Compares two OpenFLUID software versions. Only numeric numbers are accepted (no alphabetic character)

Parameters
[in]VersionAthe first version number
[in]VersionBthe second version number
Returns
1 if VersionA is greater than VersionB, -1 if VersionB is greater than VersionA, 0 if versions are equals, -2 if a version format is not well-formed

◆ contains()

bool OPENFLUID_API openfluid::tools::contains ( const std::string &  Str,
const std::string &  SubStr,
bool  CaseSensitive = true 
)

Checks if a string contains a given substring

openfluid::tools::contains("Some words in a string","Some"); // true
bool OPENFLUID_API contains(const std::string &Str, const std::string &SubStr, bool CaseSensitive=true)
Parameters
[in]Strthe string to check
[in]SubStrthe substring
[in]CaseSensitivetrue for case sensitive
Returns
true if the string contains the substring, false otherwise

◆ convertString() [1/2]

template<typename T >
T openfluid::tools::convertString ( const std::string &  StrToConvert)
inline

Converts a string to another type

Parameters
[in]StrToConvertthe string to convert
Returns
true the string converted
Exceptions
openfluid::base::FrameworkExceptionError in string conversion
Deprecated:
Since version 2.2.0. Use openfluid::tools::toNumeric() instead

◆ convertString() [2/2]

template<typename T >
bool openfluid::tools::convertString ( const std::string &  StrToConvert,
T *  Converted 
)
inline

Converts a string to another type

Parameters
[in]StrToConvertthe string to convert
[out]Convertedthe result of the conversion
Returns
true if the conversion is correct
Deprecated:
Since version 2.2.0. Use openfluid::tools::toNumeric() instead

◆ convertValue() [1/2]

template<typename T >
std::string openfluid::tools::convertValue ( const T &  ValueToConvert)
inline

Converts a value to a string

Parameters
[in]ValueToConvertthe value to convert
Returns
the converted value
Exceptions
openfluid::base::FrameworkExceptionError in value conversion
Deprecated:
Since version 2.2.0. Use std::to_string() instead

◆ convertValue() [2/2]

template<typename T >
bool openfluid::tools::convertValue ( const T &  ValueToConvert,
std::string *  StrConverted 
)
inline

Converts a value to a string

Parameters
[in]ValueToConvertthe value to convert
[out]StrConvertedthe result of the conversion
Returns
true if the conversion is correct
Deprecated:
Since version 2.2.0. Use std::to_string() instead

◆ DatasetNameRuleString()

constexpr auto openfluid::tools::DatasetNameRuleString ( "+([A-Za-z0-9_\\.\\-]*)"  [A-Za-z0-9])
constexpr

◆ deduceVarPairs()

UnitVarPairs_t OPENFLUID_API openfluid::tools::deduceVarPairs ( const UnitVarTriplets_t Triplets)

◆ deserializeVarTriplets()

UnitVarTriplets_t OPENFLUID_API openfluid::tools::deserializeVarTriplets ( const std::string &  Selection)

◆ endsWith()

bool OPENFLUID_API openfluid::tools::endsWith ( const std::string &  Str,
const std::string &  SubStr 
)

Checks if a string ends with a given substring

openfluid::tools::endsWith("Some words in a string","Some"); // false
bool OPENFLUID_API endsWith(const std::string &Str, const std::string &SubStr)
Parameters
[in]Strthe string to check
[in]SubStrthe substring
Returns
true if the string ends with the substring, false otherwise

◆ escapePattern()

std::string OPENFLUID_API openfluid::tools::escapePattern ( const std::string &  Str)

Returns the given regex pattern string with special chars that are escaped

Parameters
[in]Strthe regex pattern
Returns
the regex pattern with special chars that are escaped

◆ escapeString()

std::string OPENFLUID_API openfluid::tools::escapeString ( const std::string &  Str)

Returns the given string with special chars that are escaped

Parameters
[in]Strthe string
Returns
the string with special chars that are escaped

◆ extractVariableNameAndType()

bool OPENFLUID_API openfluid::tools::extractVariableNameAndType ( const openfluid::core::VariableName_t Name,
openfluid::core::VariableName_t VarName,
openfluid::core::Value::Type VarType 
)

Checks and extracts variable name and type from a full variable name (with or without type).
To be valid, a variable name must only contain alphanumeric, '_', '-' or '.' characters, must begin by an alphanumeric character, and can be suffixed by a valid type into square brackets.

Parameters
[in]Namethe variable name to process
[out]VarNamethe extracted variable name
[out]VarTypethe extracted variable type
Returns
true if the check and extraction are OK

◆ format()

template<class... A>
std::string openfluid::tools::format ( const std::string &  Fmt,
A &&...  Args 
)
inline

Formats a string using a format and a variable number of arguments.
As it is based on the C snprintf functions, it uses the same format specification, and has the same limitations in usable types, performance and error handling

const double Pi = 3.1415926;
std::string TwoPiStr = openfluid::tools::format("%dxPi equals %.5f",2,2*Pi);
const std::string Name = "Marty";
const unsigned int Year = 1955;
std::string BTTFStr = openfluid::tools::format("%s went back to %d!",Name.c_str(),Year);
// BTTFStr = "Marty went back to 1955!"
std::string format(const std::string &Fmt, A &&...Args)
Definition: StringHelpers.hpp:205
Parameters
[in]FmtThe format string using POSIX format style
[in]ArgsThe variadic list of arguments to format
See also
snprintf function specification: https://en.cppreference.com/w/cpp/io/c/fprintf

◆ FragmentNameRuleString()

constexpr auto openfluid::tools::FragmentNameRuleString ( "+([A-Za-z0-9_\\.\\-]*)"  [A-Za-z])
constexpr

◆ fromGeometryString()

std::pair<int,int> OPENFLUID_API openfluid::tools::fromGeometryString ( const std::string &  Str,
const std::string &  GeomInfo 
)

Returns a pair of integer values extracted from a geometry string

Parameters
[in]Strthe geometry string (e.g. "@Point(127 82)", "@Size(1024 768)")
[in]GeomInfothe expected geometry information type (e.g. "Point", "Size")
Returns
the pair of values extracted from the geometry string

◆ generatePseudoUniqueIdentifier()

std::string OPENFLUID_API openfluid::tools::generatePseudoUniqueIdentifier ( const unsigned int  Length)

Generates a pseudo-unique identifier using alphanumeric characters and Mersenne Twister random engine.

Parameters
[in]Lengththe length of the identifier to generate
Returns
the generated identifier

◆ getNowAsString()

std::string OPENFLUID_API openfluid::tools::getNowAsString ( const std::string &  Format)

Returns the current date and time as a formatted string

Parameters
[in]Formatan strftime()-like format string
Returns
the formatted date-time

◆ getVariableSelectionRegExp()

std::string OPENFLUID_API openfluid::tools::getVariableSelectionRegExp ( )

Checks whether a variable sequence (without type) is valid or not.
To be valid, a sequence must contain triplets of variable separated by ';'

Returns
the regex as string (for compatibility reasons)

◆ isValidAlphaNumName()

bool OPENFLUID_API openfluid::tools::isValidAlphaNumName ( const std::string &  Name)

Checks whether an alphanumeric name is valid or not.
To be valid, a name must only contain alphanumeric characters.

Parameters
[in]Namethe name to check
Returns
true if the name is valid

◆ isValidAttributeName()

bool OPENFLUID_API openfluid::tools::isValidAttributeName ( const openfluid::core::AttributeName_t Name)

Checks whether an attribute name is valid or not.
To be valid, an attribute name must only contain alphanumeric, '_', '-' or '.' characters, and must begin by an alphanumeric character.

Parameters
[in]Namethe attribute name to check
Returns
true if the name is valid

◆ isValidDatasetName()

bool OPENFLUID_API openfluid::tools::isValidDatasetName ( const std::string &  Name)

Checks whether a dataset or project name is valid or not.
To be valid, a name must only contain alphanumeric, '_', '-', '.' characters, and must begin by an alphanumeric character.

Parameters
[in]Namethe name to check
Returns
true if the name is valid

◆ isValidTypedVariableName()

bool OPENFLUID_API openfluid::tools::isValidTypedVariableName ( const openfluid::core::VariableName_t Name)

Checks whether a variable name (with or without type) is valid or not.
To be valid, a variable name must only contain alphanumeric, '_', '-' or '.' characters, must begin by an alphanumeric character, and can be suffixed by a valid type into square brackets.

Parameters
[in]Namethe variable name to check
Returns
true if the name is valid

◆ isValidUnitsClassName()

bool OPENFLUID_API openfluid::tools::isValidUnitsClassName ( const openfluid::core::UnitsClass_t Name)

Checks whether a units classe name is valid or not.
To be valid, a units class name must not contain any of ';', ':' and '#' characters,

Parameters
[in]Namethe units class name to check
Returns
true if the name is valid

◆ isValidVariableName()

bool OPENFLUID_API openfluid::tools::isValidVariableName ( const openfluid::core::VariableName_t Name)

Checks whether a variable name (without type) is valid or not.
To be valid, a variable name must only contain alphanumeric, '_', '-' or '.' characters, and must begin by an alphanumeric character.

Parameters
[in]Namethe variable name to check
Returns
true if the name is valid

◆ isValidWareID()

bool OPENFLUID_API openfluid::tools::isValidWareID ( const openfluid::ware::WareID_t ID,
bool  Template = false 
)

Checks whether a ware ID is valid or not.
To be valid, a ware ID must only contain alphanumeric, '_', '-', '.' characters, and must begin by an alphanumeric character.

Parameters
[in]IDthe ware ID to check
[in]TemplateTrue to enable a template on the ware ID
Returns
true if the ID is valid

◆ join()

std::string OPENFLUID_API openfluid::tools::join ( const std::vector< std::string > &  Vect,
const std::string &  Sep 
)

Joins a vector of strings into a string using a separator

std::string Str = openfluid::tools::join({"Apples","Oranges","Strawberries"},", ");
// Str = "Apples, Oranges, Strawberries"
std::string OPENFLUID_API join(const std::vector< std::string > &Vect, const std::string &Sep)
Parameters
[in]Vectthe vector of strings to join
[in]Septhe string used as separator
Returns
the joined string

◆ matchWithWildcard()

bool OPENFLUID_API openfluid::tools::matchWithWildcard ( const std::string &  Pattern,
const std::string &  Str 
)

Checks if the given string matches the given pattern, including * and ? wildcards

Parameters
[in]PatternThe pattern to match
[in]StrThe string to test
Returns
true if the given string matches the given pattern

◆ microsleep()

void OPENFLUID_API openfluid::tools::microsleep ( const unsigned long  USec)

Suspend execution of current thread for microseconds

Parameters
[in]USecthe microseconds interval

◆ millisleep()

void OPENFLUID_API openfluid::tools::millisleep ( const unsigned long  MSec)

Suspends execution of current thread for milliseconds

Parameters
[in]MSecthe milliseconds interval

◆ replace()

std::string OPENFLUID_API openfluid::tools::replace ( const std::string &  Str,
const std::string &  SearchStr,
const std::string &  ReplaceStr 
)

Replaces every occurrence in a string of a searched substring by a replacement substring

std::string Str = openfluid::tools::replace("Oranges are orange","orange","blue");
// Str = "Oranges are blue"
std::string OPENFLUID_API replace(const std::string &Str, const std::string &SearchStr, const std::string &ReplaceStr)
Parameters
[in]Strthe original string
[in]SearchStrthe searched substring
[in]ReplaceStrthe replacement substring
Returns
a string with replaced parts

◆ replaceEmptyString()

std::string OPENFLUID_API openfluid::tools::replaceEmptyString ( std::string  SourceStr,
const std::string &  ReplaceStr 
)

Replaces a string by another string if it is empty

Parameters
[in]SourceStrthe source string to process
[in]ReplaceStrthe replacement string to use
Returns
the processed string

◆ serializeVarTriplets()

std::string OPENFLUID_API openfluid::tools::serializeVarTriplets ( const UnitVarTriplets_t Triplets)

◆ split() [1/2]

std::vector<std::string> OPENFLUID_API openfluid::tools::split ( const std::string &  Str,
const char  Sep,
bool  KeepEmpty = false 
)

Splits a string into a vector of strings using a separator character

std::vector<std::string> VectStr = openfluid::tools::split("Hello World!"," ");
// VectStr = ["Hello","World!"]
std::vector< std::string > OPENFLUID_API split(const std::string &Str, const char Sep, bool KeepEmpty=false)
Parameters
[in]Strthe string to split
[in]Septhe separator character used to split the string
[in]KeepEmptyif true, empty strings are returned (disabled by default)
Returns
a vector of strings

◆ split() [2/2]

std::vector<std::string> OPENFLUID_API openfluid::tools::split ( const std::string &  Str,
const std::string &  SepChars,
bool  KeepEmpty = false 
)

Splits a string into a vector of strings using any character of the the string of separators

std::vector<std::string> VectStr = openfluid::tools::split("Hello World!"," ");
// VectStr = ["Hello","World!"]
Parameters
[in]Strthe string to split
[in]SepCharsthe string of separators used to split the string
[in]KeepEmptyif true, empty strings are returned (disabled by default)
Returns
a vector of strings

◆ splitString() [1/2]

std::vector<std::string> OPENFLUID_API openfluid::tools::splitString ( const std::string &  StrToSplit,
char  Separator,
bool  ReturnsEmpty = false 
)

Splits the given string into a std::string array, split using the given SepString

Parameters
[in]StrToSplitthe string to split
[in]Separatorthe separator character used to split the string
[in]ReturnsEmptyif true, the empty strings are returned
Returns
a vector of strings
Deprecated:
Since version 2.2.0. Use openfluid::tools::split() instead

◆ splitString() [2/2]

std::vector<std::string> OPENFLUID_API openfluid::tools::splitString ( const std::string &  StrToSplit,
const std::string &  Separators,
bool  ReturnsEmpty = false 
)

Splits the given string into a std::string array, split using the given SepString

Parameters
[in]StrToSplitthe string to split
[in]Separatorsthe string of separators used to split the string
[in]ReturnsEmptyif true, the empty strings are returned
Returns
a vector of strings
Deprecated:
Since version 2.2.0. Use openfluid::tools::split() instead

◆ startsWith()

bool OPENFLUID_API openfluid::tools::startsWith ( const std::string &  Str,
const std::string &  SubStr 
)

Checks if a string starts with a given substring

openfluid::tools::startsWith("Some words in a string","Some"); // true
bool OPENFLUID_API startsWith(const std::string &Str, const std::string &SubStr)
Parameters
[in]Strthe string to check
[in]SubStrthe substring
Returns
true if the string starts with the substring, false otherwise

◆ stringArrayToClassIDVarList()

std::vector<openfluid::tools::ClassIDVar> openfluid::tools::stringArrayToClassIDVarList ( const std::vector< std::string > &  StringArray,
bool  RemoveFirst = false 
)
inline

◆ stringReplace()

void OPENFLUID_API openfluid::tools::stringReplace ( std::string &  Data,
const std::string &  ToSearch,
const std::string &  ReplaceStr 
)

Replace every occurrence of a given substring (target) in a string by wanted replacement substring

Parameters
[in]Datathe string to work on
[in]ToSearchthe target substring
[in]ReplaceStrthe replacement substring
Deprecated:
Since version 2.2.0. Use openfluid::tools::replace() instead

◆ stringSelectionToClassIDVarList()

std::vector<openfluid::tools::ClassIDVar> openfluid::tools::stringSelectionToClassIDVarList ( const std::string &  SelectionStr,
bool  RemoveFirst = false 
)
inline

◆ toBoolean()

bool OPENFLUID_API openfluid::tools::toBoolean ( const std::string &  Str)

Converts a string into a boolean.

Parameters
[in]Strthe string to convert
Returns
the converted boolean value
Exceptions
openfluid::base::FrameworkExceptionError during conversion

◆ toGeometryString()

std::string OPENFLUID_API openfluid::tools::toGeometryString ( const std::string &  GeomInfo,
int  Value1,
int  Value2 
)

Returns a geometry string from a geometry info type and a pair of integer values

Parameters
[in]GeomInfothe geometry information type (e.g. "Point", "Size")
[in]Value1the first value
[in]Value2the second value
Returns
the geometry string

◆ tokenizeString()

void OPENFLUID_API openfluid::tools::tokenizeString ( const std::string &  StrToTokenize,
std::vector< std::string > &  Tokens,
const std::string &  Delimiters 
)

Function for tokenizing string into a vector of tokens

Parameters
[in]StrToTokenizethe string to tokenize
[out]Tokensthe resulting tokens
[in]Delimitersthe string delimiter
Deprecated:
Since version 2.2.0. Use openfluid::tools::split() instead

◆ toLowerCase()

std::string OPENFLUID_API openfluid::tools::toLowerCase ( const std::string &  Str)

Converts a string to lower case

std::string Str = openfluid::tools::toLowerCase("UpPeRaNdLoWeR");
// Str = "upperandlower"
std::string OPENFLUID_API toLowerCase(const std::string &Str)
Parameters
[in]Strthe string to convert
Returns
the string converted to lower case

◆ toNumeric() [1/2]

template<typename T >
T openfluid::tools::toNumeric ( const std::string &  Str)
inline

Converts a string into a numeric value.
Due to the poor performance of this generic method, it is preferable to use standard C++ typed methods such as std::stoi, std:stod and others to convert a string into numerical values

double Val = openfluid::tools::toNumeric<double>("42.01");
// Val = 42.01
Parameters
[in]Strthe string to convert
Returns
the converted numerical value
Exceptions
openfluid::base::FrameworkExceptionError during conversion
See also
std::stoi() to convert integer values : https://en.cppreference.com/w/cpp/string/basic_string/stol
std::stof() to convert floating point values : https://en.cppreference.com/w/cpp/string/basic_string/stof

◆ toNumeric() [2/2]

template<typename T >
bool openfluid::tools::toNumeric ( const std::string &  Str,
T &  Num 
)
inline

Converts a string into a numeric value.
Due to the poor performance of this generic method, it is preferable to use standard C++ typed methods such as std::stoi, std:stod and others to convert a string into numerical values

double Val;
if (openfluid::tools::toNumeric("42.01",Val))
{
// conversion succeeded
}
else
{
// conversion failed
}
bool toNumeric(const std::string &Str, T &Num)
Definition: StringHelpers.hpp:113
Parameters
[in]Strthe string to convert
[out]Numthe converted numerical value
Returns
true if conversion is successful, false otherwise
See also
std::stoi() to convert integer values : https://en.cppreference.com/w/cpp/string/basic_string/stol
std::stof() to convert floating point values : https://en.cppreference.com/w/cpp/string/basic_string/stof

◆ toUpperCase()

std::string OPENFLUID_API openfluid::tools::toUpperCase ( const std::string &  Str)

Converts a string to upper case

std::string Str = openfluid::tools::toUpperCase("UpPeRaNdLoWeR");
// Str = "UPPERANDLOWER"
std::string OPENFLUID_API toUpperCase(const std::string &Str)
Parameters
[in]Strthe string to convert
Returns
the string converted to upper case

◆ trim()

std::string OPENFLUID_API openfluid::tools::trim ( const std::string &  Str)

Trims all the whitespaces character located on both right and left sides of the string

std::string Str = openfluid::tools::trim(" The string to trim \n ");
// Str = "The string to trim"
std::string OPENFLUID_API trim(const std::string &Str)
Parameters
[in]Strthe string to trim
Returns
the trimmed string

◆ trimLeft()

std::string OPENFLUID_API openfluid::tools::trimLeft ( const std::string &  Str)

Trims all the whitespaces character located on the left side of the string

std::string Str = openfluid::tools::trimLeft(" The string to trim \n ");
// Str = "The string to trim \n "
std::string OPENFLUID_API trimLeft(const std::string &Str)
Parameters
[in]Strthe string to trim
Returns
the trimmed string

◆ trimRight()

std::string OPENFLUID_API openfluid::tools::trimRight ( const std::string &  Str)

Trims all the whitespaces character located on the right side of the string

std::string Str = openfluid::tools::trimRight(" The string to trim \n ");
// Str = " The string to trim"
std::string OPENFLUID_API trimRight(const std::string &Str)
Parameters
[in]Strthe string to trim
Returns
the trimmed string

◆ UnitsClassNameRuleString()

constexpr auto openfluid::tools::UnitsClassNameRuleString ( "^+$"  [^;:#])
constexpr

◆ VariableNameRuleString()

constexpr auto openfluid::tools::VariableNameRuleString ( "+([A-Za-z0-9_\\.\\-]*)"  [A-Za-z])
constexpr

◆ WareIDRuleString()

constexpr auto openfluid::tools::WareIDRuleString ( "+([A-Za-z0-9_\\.\\-]*)"  [A-Za-z0-9])
constexpr

◆ WareIDRuleStringAndTpl()

constexpr auto openfluid::tools::WareIDRuleStringAndTpl ( "+([A-Za-z0-9_@\\.\\-]*)"  [A-Za-z0-9])
constexpr

Variable Documentation

◆ DefaultErrorCode

std::error_code openfluid::tools::DefaultErrorCode
static