Subversion Repositories spk

Rev

Rev 284 | Rev 288 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 284 Rev 285
Line 19... Line 19...
19
	class SString;
19
	class SString;
20
	class WStringList;
20
	class WStringList;
21
/**
21
/**
22
 * String wrapper class
22
 * String wrapper class
23
 */
23
 */
24
	class SPKEXPORT WString : public std::wstring
24
	class SPKEXPORT WString
25
{
25
{
26
public:
26
public:
27
	static std::string ws2s(const std::wstring& wstr);
27
	static std::string ws2s(const std::wstring& wstr);
28
	static std::wstring s2ws(const std::string& str);
28
	static std::wstring s2ws(const std::string& str);
29
	static WString ConvertTime(time_t whattime, bool shortdesc = false);
29
	static WString ConvertTime(time_t whattime, bool shortdesc = false);
-
 
30
 
-
 
31
private:
-
 
32
	std::wstring _data;
30
 
33
 
31
public:
34
public:
32
	// constructors
35
	// constructors
33
	WString(void);
36
	WString(void);
34
	WString(const char* str);
37
	WString(const char* str);
Line 82... Line 85...
82
	bool toBool() const;
85
	bool toBool() const;
83
	long toLong() const;
86
	long toLong() const;
84
	int toInt() const;
87
	int toInt() const;
85
	double toDouble() const;
88
	double toDouble() const;
86
	float toFloat() const;
89
	float toFloat() const;
-
 
90
	const wchar_t* toWChar() const;
-
 
91
	const wchar_t* c_str() const;
-
 
92
	std::string toUTF8() const;
-
 
93
	std::string toFileUTF8() const;
-
 
94
	std::wstring toStdWString() const { return _data; }
87
 
95
 
88
	const SString toString() const;
96
	const SString toString() const;
89
 
97
 
90
	// casting operators
98
	// casting operators
91
	inline operator const wchar_t *() const			{ return (const wchar_t *)c_str(); }
99
	inline operator const wchar_t *() const			{ return _data.c_str(); }
92
	inline operator wchar_t *() const				{ return (wchar_t *)c_str(); }
100
	inline operator wchar_t *() const				{ return (wchar_t *)_data.c_str(); }
93
	inline operator const std::wstring &() const	{ return (const std::wstring &)*this; }
101
	inline operator const std::wstring &() const	{ return _data; }
94
	inline operator const int () const				{ return static_cast<int>(this->toLong()); }
102
	inline operator const int () const				{ return static_cast<int>(this->toLong()); }
95
	inline operator const long () const				{ return this->toLong(); }
103
	inline operator const long () const				{ return this->toLong(); }
96
	inline operator const double () const			{ return this->toDouble(); }
104
	inline operator const double () const			{ return this->toDouble(); }
97
	inline operator const float () const			{ return this->toFloat(); }
105
	inline operator const float () const			{ return this->toFloat(); }
98
	inline operator const bool () const				{ return (this->empty() ? false : ((this->toLong()) ? true : false)); }
106
	inline operator const bool () const				{ return (this->empty() ? false : ((this->toLong()) ? true : false)); }
Line 106... Line 114...
106
	const WString &operator= ( unsigned long l );
114
	const WString &operator= ( unsigned long l );
107
	const WString &operator= ( float l );
115
	const WString &operator= ( float l );
108
	const WString &operator= ( double l );
116
	const WString &operator= ( double l );
109
 
117
 
110
	// subscript operators
118
	// subscript operators
-
 
119
#ifdef _WIN32
-
 
120
	const wchar_t operator[] (int num) const;
-
 
121
	wchar_t& operator[] (int num);
-
 
122
#else
111
	const wchar_t operator[] (size_t num) const;
123
	const wchar_t operator[] (size_t num) const;
112
	wchar_t &operator[] (size_t num);
124
	wchar_t& operator[] (size_t num);
-
 
125
#endif
-
 
126
	const wchar_t& at(size_t num) const { return _data.at(num); }
113
 
127
 
114
	// addition operators
128
	// addition operators
115
	WString operator+ (const wchar_t* str) const;
129
	WString operator+ (const wchar_t* str) const;
116
	WString operator+ (const char* str) const;
130
	WString operator+ (const char* str) const;
117
	WString operator+ ( const std::wstring &str ) const;
131
	WString operator+ ( const std::wstring &str ) const;
Line 143... Line 157...
143
 
157
 
144
	bool operator !() const;
158
	bool operator !() const;
145
 
159
 
146
	bool Compare(const WString &str, bool bCaseSensative = false) const;
160
	bool Compare(const WString &str, bool bCaseSensative = false) const;
147
	bool Compare(const wchar_t *str, bool bCaseSensative = false) const;
161
	bool Compare(const wchar_t *str, bool bCaseSensative = false) const;
-
 
162
 
-
 
163
	//std::wstring functions
-
 
164
	bool empty() const;
-
 
165
	void clear();
-
 
166
	WString &erase(size_t offset, size_t count);
-
 
167
	size_t length() const;
-
 
168
	WString substr(size_t offset, size_t count) const;
-
 
169
	WString substr(size_t offset) const;
-
 
170
	wchar_t back() const;
148
 
171
 
149
	// file handling
172
	// file handling
150
	wchar_t *readToEndOfLine(wchar_t *data);
173
	wchar_t *readToEndOfLine(wchar_t *data);
151
	const WString &readToEndOfLine(FILE *id, int *line, bool upper);
174
	const WString &readToEndOfLine(FILE *id, int *line, bool upper);
152
 
175
 
Line 179... Line 202...
179
	bool contains(wchar_t c, bool bCaseSensative = false) const;
202
	bool contains(wchar_t c, bool bCaseSensative = false) const;
180
	bool isin(const WString &str, bool bCaseSensative = false) const;
203
	bool isin(const WString &str, bool bCaseSensative = false) const;
181
	bool isin(wchar_t c, bool bCaseSensative = false) const;
204
	bool isin(wchar_t c, bool bCaseSensative = false) const;
182
	int compareVersion(const Utils::WString &v) const;
205
	int compareVersion(const Utils::WString &v) const;
183
	bool match(const Utils::WString &pattern) const;
206
	bool match(const Utils::WString &pattern) const;
-
 
207
	bool startsWith(const WString& prefix) const;
-
 
208
	bool endsWith(const WString& prefix) const;
184
 
209
 
185
	WString& prepend(const WString &str);
210
	WString& prepend(const WString &str);
186
 
211
 
187
	// sub string
212
	// sub string
188
	WString left(long num) const;
213
	WString left(long num) const;
Line 205... Line 230...
205
 
230
 
206
	const WString &toFilename();
231
	const WString &toFilename();
207
	WString asFilename() const;
232
	WString asFilename() const;
208
 
233
 
209
private:
234
private:
210
	void _assign(const wchar_t* str) { this->assign(str); }
235
	void _assign(const wchar_t* str) { _data.assign(str); }
211
	void _assign(const wchar_t* str, size_t len) { this->assign(str, len); }
236
	void _assign(const wchar_t* str, size_t len) { _data.assign(str, len); }
212
	bool _isCharNumber(wchar_t c) const;
237
	bool _isCharNumber(wchar_t c) const;
213
	Utils::WString::size_type _token_nextPos(const wchar_t *token, Utils::WString::size_type curPos) const;
238
	std::wstring::size_type _token_nextPos(const wchar_t *token, std::wstring::size_type curPos) const;
214
};
239
};
215
 
240
 
216
SPKEXPORT WString operator+(const wchar_t* str1, const WString& str2);
241
SPKEXPORT WString operator+(const wchar_t* str1, const WString& str2);
217
SPKEXPORT WString operator+(const char* str1, const WString& str2);
242
SPKEXPORT WString operator+(const char* str1, const WString& str2);
218
 
243