| 186 | 
           cycrow | 
           1 | 
           #pragma once
  | 
        
        
            | 
            | 
           2 | 
              | 
        
        
            | 
            | 
           3 | 
           #include <string>
  | 
        
        
           | 196 | 
           cycrow | 
           4 | 
           #include <vector>
  | 
        
        
           | 186 | 
           cycrow | 
           5 | 
           #include "../spkdll.h"
  | 
        
        
            | 
            | 
           6 | 
           #include "../spkdef.h"
  | 
        
        
            | 
            | 
           7 | 
              | 
        
        
           | 187 | 
           cycrow | 
           8 | 
           enum WStringCompare {
  | 
        
        
            | 
            | 
           9 | 
           	Same		= 0,
  | 
        
        
            | 
            | 
           10 | 
           	Newer		= 1,
  | 
        
        
            | 
            | 
           11 | 
           	Older		= -1,
  | 
        
        
           | 186 | 
           cycrow | 
           12 | 
           };
  | 
        
        
            | 
            | 
           13 | 
              | 
        
        
            | 
            | 
           14 | 
           #pragma warning( push )
  | 
        
        
            | 
            | 
           15 | 
           #pragma warning( disable : 4251)
  | 
        
        
            | 
            | 
           16 | 
              | 
        
        
            | 
            | 
           17 | 
           namespace Utils {
  | 
        
        
            | 
            | 
           18 | 
              | 
        
        
           | 188 | 
           cycrow | 
           19 | 
           	class SString;
  | 
        
        
           | 186 | 
           cycrow | 
           20 | 
           /**
  | 
        
        
            | 
            | 
           21 | 
            * String wrapper class
  | 
        
        
            | 
            | 
           22 | 
            */
  | 
        
        
            | 
            | 
           23 | 
           	class SPKEXPORT WString : public std::wstring
  | 
        
        
            | 
            | 
           24 | 
           {
  | 
        
        
            | 
            | 
           25 | 
           public:
  | 
        
        
            | 
            | 
           26 | 
           	static std::string ws2s(const std::wstring& wstr);
  | 
        
        
            | 
            | 
           27 | 
           	static std::wstring s2ws(const std::string& str);
  | 
        
        
            | 
            | 
           28 | 
              | 
        
        
            | 
            | 
           29 | 
           public:
  | 
        
        
            | 
            | 
           30 | 
           	// constructors
  | 
        
        
            | 
            | 
           31 | 
           	WString(void);
  | 
        
        
            | 
            | 
           32 | 
           	WString(const char* str);
  | 
        
        
            | 
            | 
           33 | 
           	WString(const wchar_t* str);
  | 
        
        
            | 
            | 
           34 | 
           	WString(const unsigned char *str);
  | 
        
        
            | 
            | 
           35 | 
           	WString(const std::string& str);
  | 
        
        
            | 
            | 
           36 | 
           	WString(const std::wstring& str);
  | 
        
        
            | 
            | 
           37 | 
           	WString(const char c);
  | 
        
        
            | 
            | 
           38 | 
           	WString(const unsigned char c);
  | 
        
        
            | 
            | 
           39 | 
           	WString(const wchar_t c);
  | 
        
        
            | 
            | 
           40 | 
           	WString(const WString &str);
  | 
        
        
            | 
            | 
           41 | 
           	WString(long l);
  | 
        
        
            | 
            | 
           42 | 
           	WString(unsigned long l);
  | 
        
        
            | 
            | 
           43 | 
           	WString(float f);
  | 
        
        
            | 
            | 
           44 | 
           	WString(double f);
  | 
        
        
            | 
            | 
           45 | 
           	WString(wchar_t* str, int len = -1)
  | 
        
        
            | 
            | 
           46 | 
           	{
  | 
        
        
            | 
            | 
           47 | 
           		if(len > 0)
  | 
        
        
            | 
            | 
           48 | 
           			this->_assign(str, len);
  | 
        
        
            | 
            | 
           49 | 
           		else
  | 
        
        
            | 
            | 
           50 | 
           			this->_assign(str);
  | 
        
        
            | 
            | 
           51 | 
           	}
  | 
        
        
            | 
            | 
           52 | 
              | 
        
        
            | 
            | 
           53 | 
           	virtual ~WString(void);
  | 
        
        
            | 
            | 
           54 | 
              | 
        
        
            | 
            | 
           55 | 
           	// conversion functions
  | 
        
        
            | 
            | 
           56 | 
           	void fromLong(long l);
  | 
        
        
            | 
            | 
           57 | 
           	const WString &fromFloat(float f, int dp = -1);
  | 
        
        
            | 
            | 
           58 | 
           	void fromDouble(double f);
  | 
        
        
            | 
            | 
           59 | 
           	const WString &fromDouble(double f, int dp);
  | 
        
        
            | 
            | 
           60 | 
           	const WString &format(const wchar_t *sFormat, ...);
  | 
        
        
            | 
            | 
           61 | 
           	const WString args(const WString *args, int max) const;
  | 
        
        
            | 
            | 
           62 | 
           	const WString &arg(const WString &s1);
  | 
        
        
            | 
            | 
           63 | 
           	const WString &arg(const WString &s1, const WString &s2);
  | 
        
        
            | 
            | 
           64 | 
           	const WString &arg(const WString &s1, const WString &s2, const WString &s3);
  | 
        
        
            | 
            | 
           65 | 
           	const WString &arg(const WString &s1, const WString &s2, const WString &s3, const WString &s4);
  | 
        
        
            | 
            | 
           66 | 
           	const WString &arg(const WString &s1, const WString &s2, const WString &s3, const WString &s4, const WString &s5);
  | 
        
        
            | 
            | 
           67 | 
              | 
        
        
            | 
            | 
           68 | 
           	static WString PadNumber(long iNum, int iAmount);
  | 
        
        
            | 
            | 
           69 | 
           	static WString Number(long l) { return WString(l); }
  | 
        
        
            | 
            | 
           70 | 
           	static WString Format(const wchar_t *sFormat, ...);
  | 
        
        
            | 
            | 
           71 | 
           	static WString Null();
  | 
        
        
            | 
            | 
           72 | 
           	static WString FromFloat(float f, int dp = -1);
  | 
        
        
            | 
            | 
           73 | 
              | 
        
        
            | 
            | 
           74 | 
           	bool toBool() const;
  | 
        
        
            | 
            | 
           75 | 
           	long toLong() const;
  | 
        
        
            | 
            | 
           76 | 
           	int toInt() const;
  | 
        
        
            | 
            | 
           77 | 
           	double toDouble() const;
  | 
        
        
            | 
            | 
           78 | 
           	float toFloat() const;
  | 
        
        
            | 
            | 
           79 | 
              | 
        
        
           | 188 | 
           cycrow | 
           80 | 
           	const SString toString() const;
  | 
        
        
           | 186 | 
           cycrow | 
           81 | 
              | 
        
        
            | 
            | 
           82 | 
           	// casting operators
  | 
        
        
            | 
            | 
           83 | 
           	inline operator const wchar_t *() const			{ return (const wchar_t *)c_str(); }
  | 
        
        
            | 
            | 
           84 | 
           	inline operator wchar_t *() const				{ return (wchar_t *)c_str(); }
  | 
        
        
            | 
            | 
           85 | 
           	inline operator const std::wstring &() const	{ return (const std::wstring &)*this; }
  | 
        
        
            | 
            | 
           86 | 
           	inline operator const int () const				{ return this->toLong(); }
  | 
        
        
            | 
            | 
           87 | 
           	inline operator const long () const				{ return this->toLong(); }
  | 
        
        
            | 
            | 
           88 | 
           	inline operator const double () const			{ return this->toDouble(); }
  | 
        
        
            | 
            | 
           89 | 
           	inline operator const float () const			{ return this->toFloat(); }
  | 
        
        
            | 
            | 
           90 | 
           	inline operator const bool () const				{ return (this->empty() ? false : ((this->toLong()) ? true : false)); }
  | 
        
        
            | 
            | 
           91 | 
              | 
        
        
            | 
            | 
           92 | 
           	// assignment operators
  | 
        
        
            | 
            | 
           93 | 
           	const WString &operator= ( const WString &str );
  | 
        
        
            | 
            | 
           94 | 
           	const WString &operator= ( const std::wstring &str );
  | 
        
        
            | 
            | 
           95 | 
           	const WString &operator= ( const wchar_t *str );
  | 
        
        
            | 
            | 
           96 | 
           	const WString &operator= ( wchar_t c );
  | 
        
        
            | 
            | 
           97 | 
           	const WString &operator= ( long l );
  | 
        
        
            | 
            | 
           98 | 
           	const WString &operator= ( unsigned long l );
  | 
        
        
            | 
            | 
           99 | 
           	const WString &operator= ( float l );
  | 
        
        
            | 
            | 
           100 | 
           	const WString &operator= ( double l );
  | 
        
        
            | 
            | 
           101 | 
              | 
        
        
            | 
            | 
           102 | 
           	// subscript operators
  | 
        
        
            | 
            | 
           103 | 
           	const wchar_t operator[] ( int num ) const;
  | 
        
        
            | 
            | 
           104 | 
           	wchar_t &operator[] ( int num );
  | 
        
        
            | 
            | 
           105 | 
              | 
        
        
            | 
            | 
           106 | 
           	// addition operators
  | 
        
        
           | 189 | 
           cycrow | 
           107 | 
           	WString operator+ (const wchar_t* str) const;
  | 
        
        
            | 
            | 
           108 | 
           	WString operator+ (const char* str) const;
  | 
        
        
           | 186 | 
           cycrow | 
           109 | 
           	WString operator+ ( const std::wstring &str ) const;
  | 
        
        
            | 
            | 
           110 | 
           	WString operator+ ( const WString &str ) const;
  | 
        
        
            | 
            | 
           111 | 
           	WString operator+ ( const wchar_t c ) const;
  | 
        
        
            | 
            | 
           112 | 
           	WString operator+ ( const long l ) const;
  | 
        
        
            | 
            | 
           113 | 
           	WString operator+ ( const unsigned long l ) const;
  | 
        
        
            | 
            | 
           114 | 
           	WString operator+ ( const float f ) const;
  | 
        
        
            | 
            | 
           115 | 
           	WString operator+ ( const double f ) const;
  | 
        
        
            | 
            | 
           116 | 
              | 
        
        
            | 
            | 
           117 | 
           	// compound operators
  | 
        
        
            | 
            | 
           118 | 
           	const WString &operator+= ( const wchar_t *str );
  | 
        
        
            | 
            | 
           119 | 
           	const WString &operator+= ( const std::wstring &str );
  | 
        
        
            | 
            | 
           120 | 
           	const WString &operator+= ( const WString &str );
  | 
        
        
            | 
            | 
           121 | 
           	const WString &operator+= ( const wchar_t c );
  | 
        
        
            | 
            | 
           122 | 
           	const WString &operator+= ( const long l );
  | 
        
        
            | 
            | 
           123 | 
           	const WString &operator+= ( const unsigned long l );
  | 
        
        
            | 
            | 
           124 | 
           	const WString &operator+= ( const float f );
  | 
        
        
            | 
            | 
           125 | 
           	const WString &operator+= ( const double f );
  | 
        
        
            | 
            | 
           126 | 
              | 
        
        
            | 
            | 
           127 | 
           	// comparison operators
  | 
        
        
            | 
            | 
           128 | 
           	bool operator== ( const wchar_t *str ) const;
  | 
        
        
            | 
            | 
           129 | 
           	bool operator== ( const std::wstring &str ) const;
  | 
        
        
            | 
            | 
           130 | 
           	bool operator== ( const WString &str ) const;
  | 
        
        
            | 
            | 
           131 | 
              | 
        
        
            | 
            | 
           132 | 
           	bool operator!= ( const wchar_t *str ) const;
  | 
        
        
            | 
            | 
           133 | 
           	bool operator!= ( const std::wstring &str ) const;
  | 
        
        
            | 
            | 
           134 | 
           	bool operator!= ( const WString &str ) const;
  | 
        
        
            | 
            | 
           135 | 
              | 
        
        
            | 
            | 
           136 | 
           	bool operator !() const;
  | 
        
        
            | 
            | 
           137 | 
              | 
        
        
            | 
            | 
           138 | 
           	bool Compare(const WString &str, bool bCaseSensative = false) const;
  | 
        
        
            | 
            | 
           139 | 
           	bool Compare(const wchar_t *str, bool bCaseSensative = false) const;
  | 
        
        
            | 
            | 
           140 | 
              | 
        
        
            | 
            | 
           141 | 
           	// file handling
  | 
        
        
            | 
            | 
           142 | 
           	wchar_t *readToEndOfLine(wchar_t *data);
  | 
        
        
            | 
            | 
           143 | 
           	const WString &readToEndOfLine(FILE *id, int *line, bool upper);
  | 
        
        
            | 
            | 
           144 | 
              | 
        
        
            | 
            | 
           145 | 
           	// tokens
  | 
        
        
            | 
            | 
           146 | 
           	int countToken(const wchar_t *token) const;
  | 
        
        
            | 
            | 
           147 | 
           	WString token(const wchar_t *token, int tok) const;
  | 
        
        
            | 
            | 
           148 | 
           	WString tokens(const wchar_t *token, int from, int to = 0) const;
  | 
        
        
            | 
            | 
           149 | 
           	WString *tokenise(const wchar_t *token, int *max) const;
  | 
        
        
           | 196 | 
           cycrow | 
           150 | 
           	size_t tokenise(const wchar_t* token, std::vector<std::wstring> &str) const;
  | 
        
        
           | 186 | 
           cycrow | 
           151 | 
           	WString replaceToken(const wchar_t *token, int from, const WString &replace) const;
  | 
        
        
            | 
            | 
           152 | 
           	WString remToken(const wchar_t* token, int from) const;
  | 
        
        
            | 
            | 
           153 | 
           	WString remTokens(const wchar_t* token, int from, int to = -1) const;
  | 
        
        
            | 
            | 
           154 | 
           	WString word(int word) const;
  | 
        
        
            | 
            | 
           155 | 
           	WString words(int from, int to = 0) const;
  | 
        
        
            | 
            | 
           156 | 
           	WString addToken(const wchar_t *token, const Utils::WString &str) const;
  | 
        
        
            | 
            | 
           157 | 
              | 
        
        
            | 
            | 
           158 | 
           	// find/replacement
  | 
        
        
            | 
            | 
           159 | 
           	int findPos(const WString &find, int iStartPos = 0) const;
  | 
        
        
            | 
            | 
           160 | 
           	WString findReplace(const WString &find, const WString &replace ) const;
  | 
        
        
            | 
            | 
           161 | 
           	WString remove(wchar_t c) const;
  | 
        
        
            | 
            | 
           162 | 
           	const WString &removeChar(wchar_t c);
  | 
        
        
            | 
            | 
           163 | 
           	const WString &removeChar(const wchar_t *cs);
  | 
        
        
            | 
            | 
           164 | 
           	WString findRemove(const WString &find) const;
  | 
        
        
            | 
            | 
           165 | 
           	WString stripHtml() const;
  | 
        
        
            | 
            | 
           166 | 
           	WString removeIf(int iChar, wchar_t c) const;
  | 
        
        
            | 
            | 
           167 | 
              | 
        
        
            | 
            | 
           168 | 
           	bool containsAny(const WString &str, bool bCaseSensative = false) const;
  | 
        
        
            | 
            | 
           169 | 
           	bool contains(const WString &str, bool bCaseSensative = false) const;
  | 
        
        
            | 
            | 
           170 | 
           	bool contains(wchar_t c, bool bCaseSensative = false) const;
  | 
        
        
            | 
            | 
           171 | 
           	bool isin(const WString &str, bool bCaseSensative = false) const;
  | 
        
        
            | 
            | 
           172 | 
           	bool isin(wchar_t c, bool bCaseSensative = false) const;
  | 
        
        
            | 
            | 
           173 | 
           	int compareVersion(const Utils::WString &v) const;
  | 
        
        
            | 
            | 
           174 | 
           	bool match(const Utils::WString &pattern) const;
  | 
        
        
            | 
            | 
           175 | 
              | 
        
        
            | 
            | 
           176 | 
           	// sub string
  | 
        
        
            | 
            | 
           177 | 
           	WString left(long num) const;
  | 
        
        
            | 
            | 
           178 | 
           	WString right(int num) const;
  | 
        
        
            | 
            | 
           179 | 
           	WString mid(int start, int end) const;
  | 
        
        
            | 
            | 
           180 | 
           	WString between(const WString &before, const WString &after) const;
  | 
        
        
            | 
            | 
           181 | 
              | 
        
        
            | 
            | 
           182 | 
           	bool isNumber(bool integer = false) const;
  | 
        
        
            | 
            | 
           183 | 
           	bool isCharNumber(int c) const;
  | 
        
        
            | 
            | 
           184 | 
           	const WString &removeFirstSpace();
  | 
        
        
            | 
            | 
           185 | 
           	const WString &removeEndSpace();
  | 
        
        
            | 
            | 
           186 | 
           	const WString &truncate(int iNum);
  | 
        
        
            | 
            | 
           187 | 
           	const WString &padNumber(int iNum);
  | 
        
        
            | 
            | 
           188 | 
           	const WString &pad(int iAmoumt, wchar_t cWith);
  | 
        
        
            | 
            | 
           189 | 
              | 
        
        
            | 
            | 
           190 | 
           	WString lower() const;
  | 
        
        
            | 
            | 
           191 | 
           	WString upper() const;
  | 
        
        
            | 
            | 
           192 | 
           	const WString &toLower();
  | 
        
        
            | 
            | 
           193 | 
           	const WString &toUpper();
  | 
        
        
            | 
            | 
           194 | 
              | 
        
        
            | 
            | 
           195 | 
           	const WString &toFilename();
  | 
        
        
            | 
            | 
           196 | 
           	WString asFilename() const;
  | 
        
        
            | 
            | 
           197 | 
              | 
        
        
            | 
            | 
           198 | 
           private:
  | 
        
        
            | 
            | 
           199 | 
           	void _assign(const wchar_t* str) { this->assign(str); }
  | 
        
        
            | 
            | 
           200 | 
           	void _assign(const wchar_t* str, size_t len) { this->assign(str, len); }
  | 
        
        
            | 
            | 
           201 | 
           	bool _isCharNumber(wchar_t c) const;
  | 
        
        
            | 
            | 
           202 | 
           	Utils::WString::size_type _token_nextPos(const wchar_t *token, Utils::WString::size_type curPos) const;
  | 
        
        
            | 
            | 
           203 | 
           };
  | 
        
        
            | 
            | 
           204 | 
              | 
        
        
            | 
            | 
           205 | 
           SPKEXPORT WString operator+(const wchar_t* str1, const WString& str2);
  | 
        
        
           | 189 | 
           cycrow | 
           206 | 
           SPKEXPORT WString operator+(const unsigned char* str1, const WString& str2);
  | 
        
        
            | 
            | 
           207 | 
           SPKEXPORT WString operator+(const char* str1, const WString& str2);
  | 
        
        
           | 186 | 
           cycrow | 
           208 | 
              | 
        
        
            | 
            | 
           209 | 
           #pragma warning( pop )
  | 
        
        
            | 
            | 
           210 | 
              | 
        
        
            | 
            | 
           211 | 
           }
  |