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

Function Documentation

std::string OPENFLUID_API openfluid::tools::classIDToString ( const openfluid::core::UnitsClass_t Class,
openfluid::core::UnitID_t  ID 
)
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
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
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
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
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
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
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
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.
QString OPENFLUID_API openfluid::tools::decodeXMLEntities ( const QString &  Str)

Decodes XML entities to characters

Parameters
[in]Strthe string to decode
Returns
The decoded string
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
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
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
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
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
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
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
std::string OPENFLUID_API openfluid::tools::generatePseudoUniqueIdentifier ( const unsigned int  Length)
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
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
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
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
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
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
void OPENFLUID_API openfluid::tools::microsleep ( const unsigned long  USec)
void OPENFLUID_API openfluid::tools::millisleep ( const unsigned long  MSec)
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
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
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
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
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
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
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
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
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
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
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
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
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
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