00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef VRS_STRINGUTILS_H
00019 #define VRS_STRINGUTILS_H
00020
00021 #include <vrs/config.h>
00022 #include <vrs/color.h>
00023 #include <vrs/matrix.h>
00024 #include <vrs/io/dataresource.h>
00025 #include <string>
00026 #include <vector>
00027
00028 namespace VRS {
00029
00030 class VRS_CORE_API StringUtils {
00031 public:
00032
00033
00034 #ifdef VRS_HAS_WSTRING
00036 static std::string WString2String(const std::wstring& str);
00038 static std::wstring String2WString(const std::string& str);
00039 #endif // VRS_HAS_WSTRING
00040
00045 static std::string Int2String(INT64 value, unsigned int width = 0, char fillChar = ' ');
00046
00048 static INT64 String2Int(const std::string& value, INT64 defaultValue = 0);
00049
00055 static std::string Double2String(double value, int decimals = -1);
00057 static double String2Double(const std::string& value, double defaultValue = 0.0);
00059 static bool String2DoubleC(const std::string& value, double& result);
00060
00061
00065 static std::string Bool2String(bool value, bool use0and1);
00071 static bool String2Bool(const std::string& value, bool defaultValue = false);
00072
00075 static std::string Color2String(const Color& color, char prefix = '#');
00081 static Color String2Color(const std::string& color, const Color& defaultColor = Color::black, char prefix = '#');
00082
00084 static std::string Vector2String(const Vector& vec);
00087 static Vector String2Vector(const std::string& vec, const Vector& defaultVector = Vector::origin);
00088
00090 static std::string Matrix2String(const Matrix& mat);
00092 static Matrix String2Matrix(const std::string& s, const Matrix& defaultValue = Matrix::identity);
00093
00095 static std::string Binary2Hex(SO<DataResource> binary);
00097 static SO<DataResource> Hex2Binary(const std::string& hex);
00098
00099
00100
00101
00103 static std::string TrimLeft(const std::string& str);
00105 static std::string TrimRight(const std::string& str);
00107 static std::string Trim(const std::string& str);
00108
00110 static std::string ToLowerCase(const std::string& str);
00112 static std::string ToUpperCase(const std::string& str);
00113
00115 static bool Split(const std::string& strToSplit, const std::string& separator, std::vector<std::string>& outParts);
00116
00119 static std::string Replace(const std::string& str, const std::string& toReplace, const std::string& replaceWith);
00120
00121
00122
00126 static std::string Encrypt(const std::string& stringToEncrypt);
00127
00132 static bool Decrypt(const std::string& stringToDecrypt, std::string& result);
00133
00134 private:
00135 StringUtils();
00136 };
00137
00138 }
00139
00140 #endif // VRS_STRINGUTILS_H