Classes | Typedefs | Functions
openfluid::tools Namespace Reference

Classes

class  ChronFileInterpolator
 
class  ChronFileLinearInterpolator
 
class  ChronologicalSerie
 
class  ColumnTextParser
 
class  Console
 
class  DistributionBindings
 
class  DistributionTables
 
class  FileLogger
 
class  Filesystem
 
class  ProgressiveChronFileReader
 
class  ProgressiveColumnFileReader
 
class  ReaderNextValue
 

Typedefs

typedef std::pair< openfluid::core::DateTime, double > ChronItem_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 ConvertString (const std::string &StrToConvert, T *Converted) OPENFLUID_DEPRECATED
 
template<typename T >
bool convertValue (const T &ValueToConvert, std::string *StrConverted)
 
template<typename T >
std::string convertValue (const T &ValueToConvert)
 
template<typename T >
bool ConvertValue (const T &ValueToConvert, std::string *StrConverted) OPENFLUID_DEPRECATED
 
void OPENFLUID_API tokenizeString (const std::string &StrToTokenize, std::vector< std::string > &Tokens, const std::string &Delimiters)
 
void TokenizeString (const std::string &StrToTokenize, std::vector< std::string > &Tokens, const std::string &Delimiters) OPENFLUID_DEPRECATED
 
std::vector< std::string > OPENFLUID_API splitString (const std::string &StrToSplit, const std::string &Separators, bool ReturnsEmpty=false)
 
std::vector< std::string > SplitString (const std::string &StrToSplit, const std::string &Separators, bool ReturnsEmpty=false) OPENFLUID_DEPRECATED
 
std::vector< std::string > OPENFLUID_API findFilesByExtension (const std::string &Path, const std::string &Ext, bool WithPath=false, bool ExtIncludeDot=false)
 
std::vector< std::string > OPENFLUID_API findFilesBySuffixAndExtension (const std::string &Path, const std::string &Suffix, const std::string &Ext, bool WithPath=false, bool ExtIncludeDot=false)
 
std::vector< std::string > OPENFLUID_API findDirectories (const std::string &Path, bool WithPath=false)
 
bool OPENFLUID_API emptyDirectoryRecursively (const std::string &Path)
 
void OPENFLUID_API copyDirectoryContentsRecursively (const std::string &SrcPath, const std::string &DestPath, const bool DontCopyDotDirs=false)
 
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 isValidWareID (const openfluid::ware::WareID_t &ID)
 
bool OPENFLUID_API isValidVariableName (const openfluid::core::VariableName_t &Name)
 
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)
 
bool OPENFLUID_API matchWithWildcard (const std::string &Pattern, const std::string &Str)
 
std::string OPENFLUID_API replaceEmptyString (std::string SourceStr, const std::string &ReplaceStr)
 
std::string OPENFLUID_API removeTrailingSlashes (const std::string &Str)
 
int OPENFLUID_API compareVersions (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 generatePseudoUniqueIdentifier (const unsigned int Length)
 
void OPENFLUID_API splitDuration (long int MSecsDuration, int &Days, int &Hours, int &Minutes, int &Seconds, int &MSecs)
 
std::string OPENFLUID_API getDurationAsPrettyString (long int MSecsDuration)
 
QString OPENFLUID_API toIniCompatible (const std::string &Str)
 
std::string OPENFLUID_API fromIniCompatible (const QVariant &Var)
 
std::list< std::string > OPENFLUID_API toStdStringList (const QStringList &StrList)
 
std::vector< std::string > toStdStringVector (const QStringList &StrList)
 
QDateTime OPENFLUID_API toQDateTime (const openfluid::core::DateTime &DT)
 
QStringList OPENFLUID_API toQStringList (const std::vector< std::string > &StrVect)
 
QStringList OPENFLUID_API toQStringList (const std::set< std::string > &StrSet)
 
QStringList OPENFLUID_API toQStringList (const std::list< std::string > &StrList)
 
QStringList OPENFLUID_API toQStringList (const std::set< int > &IntSet)
 
QString OPENFLUID_API escapeXMLEntities (const QString &Str)
 
QString OPENFLUID_API decodeXMLEntities (const QString &Str)
 

Typedef Documentation

◆ ChronItem_t

Function Documentation

◆ classIDToString()

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

◆ compareVersions()

int OPENFLUID_API openfluid::tools::compareVersions ( 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

◆ convertString() [1/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

◆ convertString() [2/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

◆ ConvertString()

template<typename T >
bool openfluid::tools::ConvertString ( const std::string &  StrToConvert,
T *  Converted 
)
inline
Deprecated:
Since version 2.1.0. Use openfluid::tools::convertString instead

◆ convertValue() [1/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

◆ convertValue() [2/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

◆ ConvertValue()

template<typename T >
bool openfluid::tools::ConvertValue ( const T &  ValueToConvert,
std::string *  StrConverted 
)
inline
Deprecated:
Since version 2.1.0. Use openfluid::tools::convertValue instead

◆ copyDirectoryContentsRecursively()

void OPENFLUID_API openfluid::tools::copyDirectoryContentsRecursively ( const std::string &  SrcPath,
const std::string &  DestPath,
const bool  DontCopyDotDirs = false 
)

Copies a source directory to destination path, not including the root of the source directory. If the destination path does not exists, it is created.

Parameters
[in]SrcPaththe source directory to copy
[in]DestPaththe destination directory
[in]DontCopyDotDirsflag for copying dot ('.*') directories. Default is false.

◆ decodeXMLEntities()

QString OPENFLUID_API openfluid::tools::decodeXMLEntities ( const QString &  Str)

Decodes XML entities to characters

Parameters
[in]Strthe string to decode
Returns
The decoded string

◆ emptyDirectoryRecursively()

bool OPENFLUID_API openfluid::tools::emptyDirectoryRecursively ( const std::string &  Path)

Recursively removes all files and directories contained in the given directory. It deletes the directory and recreates it.

Parameters
[in]Paththe directory to empty
Returns
true if successful

◆ escapeXMLEntities()

QString OPENFLUID_API openfluid::tools::escapeXMLEntities ( const QString &  Str)

Escapes characters in the given string to be compatible with the XML format.

Parameters
[in]Strthe string to escape
Returns
The escaped string

◆ 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

◆ findDirectories()

std::vector<std::string> OPENFLUID_API openfluid::tools::findDirectories ( const std::string &  Path,
bool  WithPath = false 
)

Gets the list of directories found in the specified directory

Parameters
[in]Paththe directory to explore
[in]WithPathreturn full path if true, directory name only otherwise

◆ findFilesByExtension()

std::vector<std::string> OPENFLUID_API openfluid::tools::findFilesByExtension ( const std::string &  Path,
const std::string &  Ext,
bool  WithPath = false,
bool  ExtIncludeDot = false 
)

Gets the list of files with specified extension contained in the specified directory

Parameters
[in]Paththe directory to explore
[in]Extthe file extension
[in]WithPathreturn full path with file name if true, file name only otherwise
[in]ExtIncludeDotif true, the given extension through Ext parameter is suffixed by a dot

◆ findFilesBySuffixAndExtension()

std::vector<std::string> OPENFLUID_API openfluid::tools::findFilesBySuffixAndExtension ( const std::string &  Path,
const std::string &  Suffix,
const std::string &  Ext,
bool  WithPath = false,
bool  ExtIncludeDot = false 
)

Get list of files with specified extension contained in the specified dir

Parameters
[in]Paththe directory to explore
[in]Extthe file extension
[in]Suffixthe file suffix
[in]WithPathreturn full path with file name if true, file name only otherwise
[in]ExtIncludeDotif true, the given extension through Ext parameter is suffixed by a dot

◆ fromIniCompatible()

std::string OPENFLUID_API openfluid::tools::fromIniCompatible ( const QVariant &  Var)

Transforms the given variable from an INI file managed with QSettings to a string

Parameters
[in]Varthe variable to transform
Returns
The variable transformed into a 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

◆ getDurationAsPrettyString()

std::string OPENFLUID_API openfluid::tools::getDurationAsPrettyString ( long int  MSecsDuration)

returns the given duration as a pretty string representing days, hours, minutes and decimal seconds.

openfluid::tools::getDurationAsPrettyString(123456789); // returns "1d 10h 17m 36.789s"
openfluid::tools::getDurationAsPrettyString(12345678); // returns "3h 25m 45.678s"
openfluid::tools::getDurationAsPrettyString(123456); // returns "2m 3.456s"
Parameters
[in]MSecsDurationthe duration in milliseconds
Returns
the converted duration as a string

◆ 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

◆ 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

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

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
Returns
true if the ID is valid

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

◆ millisleep()

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

◆ removeTrailingSlashes()

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

Removes trailing slashes if any, useful for cleaning paths

Parameters
[in]Strthe string to process
Returns
the processed string

◆ 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

◆ splitDuration()

void OPENFLUID_API openfluid::tools::splitDuration ( long int  MSecsDuration,
int &  Days,
int &  Hours,
int &  Minutes,
int &  Seconds,
int &  MSecs 
)

splits the given duration in milliseconds into days, hours, minutes, seconds and milliseconds.

Parameters
[in]MSecsDurationthe duration in milliseconds
[out]Daysthe number of days
[out]Hoursthe number of hours
[out]Minutesthe number of minutes
[out]Secondsthe number of seconds
[out]MSecsthe number of milliseconds

◆ splitString()

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

Splits the passed 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

◆ SplitString()

std::vector< std::string > openfluid::tools::SplitString ( const std::string &  StrToSplit,
const std::string &  Separators,
bool  ReturnsEmpty = false 
)
inline
Deprecated:
Since version 2.1.0. Use openfluid::tools::splitString instead

◆ toIniCompatible()

QString OPENFLUID_API openfluid::tools::toIniCompatible ( const std::string &  Str)

Transforms the given string to a string compatible with the INI files managed with QSettings.

Parameters
[in]Strthe string to transform
Returns
The transformed 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

◆ TokenizeString()

void openfluid::tools::TokenizeString ( const std::string &  StrToTokenize,
std::vector< std::string > &  Tokens,
const std::string &  Delimiters 
)
inline
Deprecated:
Since version 2.1.0. Use openfluid::tools::tokenizeString instead

◆ toQDateTime()

QDateTime OPENFLUID_API openfluid::tools::toQDateTime ( const openfluid::core::DateTime DT)

Transforms an OpenFLUID DateTime to a QDateTime

Parameters
[in]DTThe OpenFLUID DateTime to transform
Returns
The DT transformed into QDateTime

◆ toQStringList() [1/4]

QStringList OPENFLUID_API openfluid::tools::toQStringList ( const std::vector< std::string > &  StrVect)

Transforms a std::vector of std::string into a QStringList

Parameters
[in]StrVectthe std::vector of std::string to transform
Returns
The StrVect transformed into a QStringList

◆ toQStringList() [2/4]

QStringList OPENFLUID_API openfluid::tools::toQStringList ( const std::set< std::string > &  StrSet)

Transforms a std::set of std::string into a QStringList

Parameters
[in]StrSetthe std::set of std::string to transform
Returns
The StrSet transformed into a QStringList

◆ toQStringList() [3/4]

QStringList OPENFLUID_API openfluid::tools::toQStringList ( const std::list< std::string > &  StrList)

Transforms a std::list of std::string into a QStringList

Parameters
[in]StrListthe std::list of std::string to transform
Returns
The StrList transformed into a QStringList

◆ toQStringList() [4/4]

QStringList OPENFLUID_API openfluid::tools::toQStringList ( const std::set< int > &  IntSet)

Transforms a std::set of int into a QStringList

Parameters
[in]IntSetthe std::set of int to transform
Returns
The intSet transformed into a QStringList

◆ toStdStringList()

std::list<std::string> OPENFLUID_API openfluid::tools::toStdStringList ( const QStringList &  StrList)

Transforms a QStringList into a std::list of std::string

Parameters
[in]StrListthe QStringList to transform
Returns
The QStringList transformed into a std::list of std::string

◆ toStdStringVector()

std::vector<std::string> openfluid::tools::toStdStringVector ( const QStringList &  StrList)

Transforms a QStringList into a std::vector of std::string

Parameters
[in]StrListthe QStringList to transform
Returns
The QStringList transformed into a std::vector of std::string