41 #ifndef __SWISSTOOLS_HPP__
42 #define __SWISSTOOLS_HPP__
52 namespace openfluid {
namespace core {
57 #define STRINGIFY(x) XSTRINGIFY(x)
58 #define XSTRINGIFY(x) #x
61 namespace openfluid {
namespace tools {
71 inline bool ConvertString(
const std::string& StrToConvert, T* Converted)
73 std::istringstream iss(StrToConvert);
75 return ((iss >> (*Converted)) && !iss.get(c));
86 inline bool ConvertValue(
const T ValueToConvert, std::string * StrConverted)
88 std::ostringstream oss;
89 bool IsOK = !(oss << ValueToConvert).fail();
91 if (IsOK) *StrConverted = oss.str();
104 std::vector<std::string>& Tokens,
105 const std::string& Delimiters);
123 return ((std::fabs(A - B)) <= (Epsilon * std::fabs(A)));
137 inline bool IsVeryClose(
double A,
double B,
double Epsilon = 0.00001)
140 return (((std::fabs(A - B)) <= (Epsilon * std::fabs(A))) && ((std::fabs(A - B)) <= (Epsilon * std::fabs(B))));
161 const std::string Ext,
162 bool WithPath =
false,
163 bool ExtIncludeDot =
false);
175 const std::string& Suffix,
176 const std::string& Ext,
177 bool WithPath =
false,
178 bool ExtIncludeDot =
false);
189 const std::string& Separators,
190 bool ReturnsEmpty =
false);
218 const std::string& ReplaceStr);
241 const std::string& IntoPath,
242 const bool DontCopyDotDirs =
false);
253 const std::string& IntoPath,
254 const bool DontCopyDotDirs =
false);
277 #endif // __SWISSTOOLS_H__
std::vector< std::string > DLLEXPORT GetFilesRecursively(const std::string &DirPath)
int DLLEXPORT CompareVersions(const std::string &VersionA, const std::string &VersionB, bool Strict=true)
void DLLEXPORT CopyDirectoryRecursively(const std::string &SourcePath, const std::string &IntoPath, const bool DontCopyDotDirs=false)
std::vector< std::string > DLLEXPORT SplitString(const std::string &StrToSplit, const std::string &Separators, bool ReturnsEmpty=false)
bool IsVeryClose(double A, double B, double Epsilon=0.00001)
Definition: SwissTools.hpp:137
void DLLEXPORT CopyDirectoryContentsRecursively(const std::string &SourcePath, const std::string &IntoPath, const bool DontCopyDotDirs=false)
void DLLEXPORT TokenizeString(const std::string &StrToTokenize, std::vector< std::string > &Tokens, const std::string &Delimiters)
std::string DLLEXPORT RemoveTrailingSlashes(std::string Str)
void DLLEXPORT printSTDOUT(std::vector< std::string > Strings, std::string Sep)
bool ConvertValue(const T ValueToConvert, std::string *StrConverted)
Definition: SwissTools.hpp:86
std::vector< std::string > DLLEXPORT GetFilesByExt(const std::string DirToExplore, const std::string Ext, bool WithPath=false, bool ExtIncludeDot=false)
std::vector< std::string > DLLEXPORT GetFilesBySuffixAndExt(const std::string &DirToExplore, const std::string &Suffix, const std::string &Ext, bool WithPath=false, bool ExtIncludeDot=false)
bool DLLEXPORT WildcardMatching(const std::string &Pattern, const std::string &Str)
std::string DLLEXPORT ReplaceEmptyString(std::string SourceStr, const std::string &ReplaceStr)
bool DLLEXPORT EmptyDirectoryRecursively(const std::string &DirPath)
bool IsCloseEnough(double A, double B, double Epsilon=0.00001)
Definition: SwissTools.hpp:120
void DLLEXPORT Sleep(const unsigned int MSec)
bool ConvertString(const std::string &StrToConvert, T *Converted)
Definition: SwissTools.hpp:71
#define DLLEXPORT
Definition: dllexport.hpp:51