]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/string.h | |
3 | // Purpose: wxString and wxArrayString classes | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 29/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | /* | |
13 | Efficient string class [more or less] compatible with MFC CString, | |
14 | wxWidgets version 1 wxString and std::string and some handy functions | |
15 | missing from string.h. | |
16 | */ | |
17 | ||
18 | #ifndef _WX_WXSTRINGH__ | |
19 | #define _WX_WXSTRINGH__ | |
20 | ||
21 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) | |
22 | #pragma interface "string.h" | |
23 | #endif | |
24 | ||
25 | // ---------------------------------------------------------------------------- | |
26 | // headers | |
27 | // ---------------------------------------------------------------------------- | |
28 | ||
29 | #include "wx/defs.h" // everybody should include this | |
30 | ||
31 | #if defined(__WXMAC__) || defined(__VISAGECPP__) | |
32 | #include <ctype.h> | |
33 | #endif | |
34 | ||
35 | #if defined(__VISAGECPP__) && __IBMCPP__ >= 400 | |
36 | // problem in VACPP V4 with including stdlib.h multiple times | |
37 | // strconv includes it anyway | |
38 | # include <stdio.h> | |
39 | # include <string.h> | |
40 | # include <stdarg.h> | |
41 | # include <limits.h> | |
42 | #else | |
43 | # include <string.h> | |
44 | # include <stdio.h> | |
45 | # include <stdarg.h> | |
46 | # include <limits.h> | |
47 | # include <stdlib.h> | |
48 | #endif | |
49 | ||
50 | #ifdef HAVE_STRCASECMP_IN_STRINGS_H | |
51 | #include <strings.h> // for strcasecmp() | |
52 | #endif // HAVE_STRCASECMP_IN_STRINGS_H | |
53 | ||
54 | #ifdef __WXPALMOS__ | |
55 | #include <StringMgr.h> | |
56 | #endif | |
57 | ||
58 | #include "wx/wxchar.h" // for wxChar | |
59 | #include "wx/buffer.h" // for wxCharBuffer | |
60 | #include "wx/strconv.h" // for wxConvertXXX() macros and wxMBConv classes | |
61 | ||
62 | class WXDLLIMPEXP_BASE wxString; | |
63 | ||
64 | // --------------------------------------------------------------------------- | |
65 | // macros | |
66 | // --------------------------------------------------------------------------- | |
67 | ||
68 | // casts [unfortunately!] needed to call some broken functions which require | |
69 | // "char *" instead of "const char *" | |
70 | #define WXSTRINGCAST (wxChar *)(const wxChar *) | |
71 | #define wxCSTRINGCAST (wxChar *)(const wxChar *) | |
72 | #define wxMBSTRINGCAST (char *)(const char *) | |
73 | #define wxWCSTRINGCAST (wchar_t *)(const wchar_t *) | |
74 | ||
75 | // implementation only | |
76 | #define wxASSERT_VALID_INDEX(i) \ | |
77 | wxASSERT_MSG( (size_t)(i) <= length(), _T("invalid index in wxString") ) | |
78 | ||
79 | // ---------------------------------------------------------------------------- | |
80 | // constants | |
81 | // ---------------------------------------------------------------------------- | |
82 | ||
83 | // maximum possible length for a string means "take all string" everywhere | |
84 | #define wxSTRING_MAXLEN wxStringBase::npos | |
85 | ||
86 | // ---------------------------------------------------------------------------- | |
87 | // global data | |
88 | // ---------------------------------------------------------------------------- | |
89 | ||
90 | // global pointer to empty string | |
91 | extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxEmptyString; | |
92 | ||
93 | // --------------------------------------------------------------------------- | |
94 | // global functions complementing standard C string library replacements for | |
95 | // strlen() and portable strcasecmp() | |
96 | //--------------------------------------------------------------------------- | |
97 | ||
98 | // Use wxXXX() functions from wxchar.h instead! These functions are for | |
99 | // backwards compatibility only. | |
100 | ||
101 | // checks whether the passed in pointer is NULL and if the string is empty | |
102 | inline bool IsEmpty(const char *p) { return (!p || !*p); } | |
103 | ||
104 | // safe version of strlen() (returns 0 if passed NULL pointer) | |
105 | inline size_t Strlen(const char *psz) | |
106 | { return psz ? strlen(psz) : 0; } | |
107 | ||
108 | // portable strcasecmp/_stricmp | |
109 | inline int Stricmp(const char *psz1, const char *psz2) | |
110 | { | |
111 | #if defined(__VISUALC__) && defined(__WXWINCE__) | |
112 | register char c1, c2; | |
113 | do { | |
114 | c1 = tolower(*psz1++); | |
115 | c2 = tolower(*psz2++); | |
116 | } while ( c1 && (c1 == c2) ); | |
117 | ||
118 | return c1 - c2; | |
119 | #elif defined(__VISUALC__) || ( defined(__MWERKS__) && defined(__INTEL__) ) | |
120 | return _stricmp(psz1, psz2); | |
121 | #elif defined(__SC__) | |
122 | return _stricmp(psz1, psz2); | |
123 | #elif defined(__SALFORDC__) | |
124 | return stricmp(psz1, psz2); | |
125 | #elif defined(__BORLANDC__) | |
126 | return stricmp(psz1, psz2); | |
127 | #elif defined(__WATCOMC__) | |
128 | return stricmp(psz1, psz2); | |
129 | #elif defined(__DJGPP__) | |
130 | return stricmp(psz1, psz2); | |
131 | #elif defined(__EMX__) | |
132 | return stricmp(psz1, psz2); | |
133 | #elif defined(__WXPM__) | |
134 | return stricmp(psz1, psz2); | |
135 | #elif defined(__WXPALMOS__) || \ | |
136 | defined(HAVE_STRCASECMP_IN_STRING_H) || \ | |
137 | defined(HAVE_STRCASECMP_IN_STRINGS_H) || \ | |
138 | defined(__GNUWIN32__) | |
139 | return strcasecmp(psz1, psz2); | |
140 | #elif defined(__MWERKS__) && !defined(__INTEL__) | |
141 | register char c1, c2; | |
142 | do { | |
143 | c1 = tolower(*psz1++); | |
144 | c2 = tolower(*psz2++); | |
145 | } while ( c1 && (c1 == c2) ); | |
146 | ||
147 | return c1 - c2; | |
148 | #else | |
149 | // almost all compilers/libraries provide this function (unfortunately under | |
150 | // different names), that's why we don't implement our own which will surely | |
151 | // be more efficient than this code (uncomment to use): | |
152 | /* | |
153 | register char c1, c2; | |
154 | do { | |
155 | c1 = tolower(*psz1++); | |
156 | c2 = tolower(*psz2++); | |
157 | } while ( c1 && (c1 == c2) ); | |
158 | ||
159 | return c1 - c2; | |
160 | */ | |
161 | ||
162 | #error "Please define string case-insensitive compare for your OS/compiler" | |
163 | #endif // OS/compiler | |
164 | } | |
165 | ||
166 | #if wxUSE_STL | |
167 | ||
168 | #include "wx/beforestd.h" | |
169 | #include <string> | |
170 | #include "wx/afterstd.h" | |
171 | ||
172 | #if wxUSE_UNICODE | |
173 | #ifdef HAVE_STD_WSTRING | |
174 | typedef std::wstring wxStringBase; | |
175 | #else | |
176 | typedef std::basic_string<wxChar> wxStringBase; | |
177 | #endif | |
178 | #else | |
179 | typedef std::string wxStringBase; | |
180 | #endif | |
181 | ||
182 | #if (defined(__GNUG__) && (__GNUG__ < 3)) || \ | |
183 | (defined(_MSC_VER) && (_MSC_VER <= 1200)) | |
184 | #define wxSTRING_BASE_HASNT_CLEAR | |
185 | #endif | |
186 | ||
187 | #else // if !wxUSE_STL | |
188 | ||
189 | #ifndef HAVE_STD_STRING_COMPARE | |
190 | #define HAVE_STD_STRING_COMPARE | |
191 | #endif | |
192 | ||
193 | // --------------------------------------------------------------------------- | |
194 | // string data prepended with some housekeeping info (used by wxString class), | |
195 | // is never used directly (but had to be put here to allow inlining) | |
196 | // --------------------------------------------------------------------------- | |
197 | ||
198 | struct WXDLLIMPEXP_BASE wxStringData | |
199 | { | |
200 | int nRefs; // reference count | |
201 | size_t nDataLength, // actual string length | |
202 | nAllocLength; // allocated memory size | |
203 | ||
204 | // mimics declaration 'wxChar data[nAllocLength]' | |
205 | wxChar* data() const { return (wxChar*)(this + 1); } | |
206 | ||
207 | // empty string has a special ref count so it's never deleted | |
208 | bool IsEmpty() const { return (nRefs == -1); } | |
209 | bool IsShared() const { return (nRefs > 1); } | |
210 | ||
211 | // lock/unlock | |
212 | void Lock() { if ( !IsEmpty() ) nRefs++; } | |
213 | ||
214 | // VC++ will refuse to inline Unlock but profiling shows that it is wrong | |
215 | #if defined(__VISUALC__) && (__VISUALC__ >= 1200) | |
216 | __forceinline | |
217 | #endif | |
218 | // VC++ free must take place in same DLL as allocation when using non dll | |
219 | // run-time library (e.g. Multithreaded instead of Multithreaded DLL) | |
220 | #if defined(__VISUALC__) && defined(_MT) && !defined(_DLL) | |
221 | void Unlock() { if ( !IsEmpty() && --nRefs == 0) Free(); } | |
222 | // we must not inline deallocation since allocation is not inlined | |
223 | void Free(); | |
224 | #else | |
225 | void Unlock() { if ( !IsEmpty() && --nRefs == 0) free(this); } | |
226 | #endif | |
227 | ||
228 | // if we had taken control over string memory (GetWriteBuf), it's | |
229 | // intentionally put in invalid state | |
230 | void Validate(bool b) { nRefs = (b ? 1 : 0); } | |
231 | bool IsValid() const { return (nRefs != 0); } | |
232 | }; | |
233 | ||
234 | class WXDLLIMPEXP_BASE wxStringBase | |
235 | { | |
236 | #if !wxUSE_STL | |
237 | friend class WXDLLIMPEXP_BASE wxArrayString; | |
238 | #endif | |
239 | public : | |
240 | // an 'invalid' value for string index, moved to this place due to a CW bug | |
241 | static const size_t npos; | |
242 | protected: | |
243 | // points to data preceded by wxStringData structure with ref count info | |
244 | wxChar *m_pchData; | |
245 | ||
246 | // accessor to string data | |
247 | wxStringData* GetStringData() const { return (wxStringData*)m_pchData - 1; } | |
248 | ||
249 | // string (re)initialization functions | |
250 | // initializes the string to the empty value (must be called only from | |
251 | // ctors, use Reinit() otherwise) | |
252 | void Init() { m_pchData = (wxChar *)wxEmptyString; } | |
253 | // initializaes the string with (a part of) C-string | |
254 | void InitWith(const wxChar *psz, size_t nPos = 0, size_t nLen = npos); | |
255 | // as Init, but also frees old data | |
256 | void Reinit() { GetStringData()->Unlock(); Init(); } | |
257 | ||
258 | // memory allocation | |
259 | // allocates memory for string of length nLen | |
260 | bool AllocBuffer(size_t nLen); | |
261 | // copies data to another string | |
262 | bool AllocCopy(wxString&, int, int) const; | |
263 | // effectively copies data to string | |
264 | bool AssignCopy(size_t, const wxChar *); | |
265 | ||
266 | // append a (sub)string | |
267 | bool ConcatSelf(size_t nLen, const wxChar *src, size_t nMaxLen); | |
268 | bool ConcatSelf(size_t nLen, const wxChar *src) | |
269 | { return ConcatSelf(nLen, src, nLen); } | |
270 | ||
271 | // functions called before writing to the string: they copy it if there | |
272 | // are other references to our data (should be the only owner when writing) | |
273 | bool CopyBeforeWrite(); | |
274 | bool AllocBeforeWrite(size_t); | |
275 | ||
276 | // compatibility with wxString | |
277 | bool Alloc(size_t nLen); | |
278 | public: | |
279 | // standard types | |
280 | typedef wxChar value_type; | |
281 | typedef wxChar char_type; | |
282 | typedef size_t size_type; | |
283 | typedef value_type& reference; | |
284 | typedef const value_type& const_reference; | |
285 | typedef value_type* pointer; | |
286 | typedef const value_type* const_pointer; | |
287 | typedef value_type *iterator; | |
288 | typedef const value_type *const_iterator; | |
289 | ||
290 | // constructors and destructor | |
291 | // ctor for an empty string | |
292 | wxStringBase() { Init(); } | |
293 | // copy ctor | |
294 | wxStringBase(const wxStringBase& stringSrc) | |
295 | { | |
296 | wxASSERT_MSG( stringSrc.GetStringData()->IsValid(), | |
297 | _T("did you forget to call UngetWriteBuf()?") ); | |
298 | ||
299 | if ( stringSrc.empty() ) { | |
300 | // nothing to do for an empty string | |
301 | Init(); | |
302 | } | |
303 | else { | |
304 | m_pchData = stringSrc.m_pchData; // share same data | |
305 | GetStringData()->Lock(); // => one more copy | |
306 | } | |
307 | } | |
308 | // string containing nRepeat copies of ch | |
309 | wxStringBase(size_type nRepeat, wxChar ch); | |
310 | // ctor takes first nLength characters from C string | |
311 | // (default value of npos means take all the string) | |
312 | wxStringBase(const wxChar *psz) | |
313 | { InitWith(psz, 0, npos); } | |
314 | wxStringBase(const wxChar *psz, size_t nLength) | |
315 | { InitWith(psz, 0, nLength); } | |
316 | wxStringBase(const wxChar *psz, wxMBConv& WXUNUSED(conv), size_t nLength = npos) | |
317 | { InitWith(psz, 0, nLength); } | |
318 | // take nLen chars starting at nPos | |
319 | wxStringBase(const wxStringBase& str, size_t nPos, size_t nLen) | |
320 | { | |
321 | wxASSERT_MSG( str.GetStringData()->IsValid(), | |
322 | _T("did you forget to call UngetWriteBuf()?") ); | |
323 | Init(); | |
324 | size_t strLen = str.length() - nPos; nLen = strLen < nLen ? strLen : nLen; | |
325 | InitWith(str.c_str(), nPos, nLen); | |
326 | } | |
327 | // take all characters from pStart to pEnd | |
328 | wxStringBase(const void *pStart, const void *pEnd); | |
329 | ||
330 | // dtor is not virtual, this class must not be inherited from! | |
331 | ~wxStringBase() | |
332 | { | |
333 | #if defined(__VISUALC__) && (__VISUALC__ >= 1200) | |
334 | //RN - according to the above VC++ does indeed inline this, | |
335 | //even though it spits out two warnings | |
336 | #pragma warning (disable:4714) | |
337 | #endif | |
338 | ||
339 | GetStringData()->Unlock(); | |
340 | } | |
341 | ||
342 | #if defined(__VISUALC__) && (__VISUALC__ >= 1200) | |
343 | //re-enable inlining warning | |
344 | #pragma warning (default:4714) | |
345 | #endif | |
346 | // overloaded assignment | |
347 | // from another wxString | |
348 | wxStringBase& operator=(const wxStringBase& stringSrc); | |
349 | // from a character | |
350 | wxStringBase& operator=(wxChar ch); | |
351 | // from a C string | |
352 | wxStringBase& operator=(const wxChar *psz); | |
353 | ||
354 | // return the length of the string | |
355 | size_type size() const { return GetStringData()->nDataLength; } | |
356 | // return the length of the string | |
357 | size_type length() const { return size(); } | |
358 | // return the maximum size of the string | |
359 | size_type max_size() const { return wxSTRING_MAXLEN; } | |
360 | // resize the string, filling the space with c if c != 0 | |
361 | void resize(size_t nSize, wxChar ch = wxT('\0')); | |
362 | // delete the contents of the string | |
363 | void clear() { erase(0, npos); } | |
364 | // returns true if the string is empty | |
365 | bool empty() const { return size() == 0; } | |
366 | // inform string about planned change in size | |
367 | void reserve(size_t sz) { Alloc(sz); } | |
368 | size_type capacity() const { return GetStringData()->nAllocLength; } | |
369 | ||
370 | // lib.string.access | |
371 | // return the character at position n | |
372 | value_type at(size_type n) const | |
373 | { wxASSERT_VALID_INDEX( n ); return m_pchData[n]; } | |
374 | // returns the writable character at position n | |
375 | reference at(size_type n) | |
376 | { wxASSERT_VALID_INDEX( n ); CopyBeforeWrite(); return m_pchData[n]; } | |
377 | ||
378 | // lib.string.modifiers | |
379 | // append elements str[pos], ..., str[pos+n] | |
380 | wxStringBase& append(const wxStringBase& str, size_t pos, size_t n) | |
381 | { | |
382 | wxASSERT(pos <= str.length()); | |
383 | ConcatSelf(n, str.c_str() + pos, str.length() - pos); | |
384 | return *this; | |
385 | } | |
386 | // append a string | |
387 | wxStringBase& append(const wxStringBase& str) | |
388 | { ConcatSelf(str.length(), str.c_str()); return *this; } | |
389 | // append first n (or all if n == npos) characters of sz | |
390 | wxStringBase& append(const wxChar *sz) | |
391 | { ConcatSelf(wxStrlen(sz), sz); return *this; } | |
392 | wxStringBase& append(const wxChar *sz, size_t n) | |
393 | { ConcatSelf(n, sz); return *this; } | |
394 | // append n copies of ch | |
395 | wxStringBase& append(size_t n, wxChar ch); | |
396 | // append from first to last | |
397 | wxStringBase& append(const_iterator first, const_iterator last) | |
398 | { ConcatSelf(last - first, first); return *this; } | |
399 | ||
400 | // same as `this_string = str' | |
401 | wxStringBase& assign(const wxStringBase& str) | |
402 | { return *this = str; } | |
403 | // same as ` = str[pos..pos + n] | |
404 | wxStringBase& assign(const wxStringBase& str, size_t pos, size_t n) | |
405 | { clear(); return append(str, pos, n); } | |
406 | // same as `= first n (or all if n == npos) characters of sz' | |
407 | wxStringBase& assign(const wxChar *sz) | |
408 | { clear(); return append(sz, wxStrlen(sz)); } | |
409 | wxStringBase& assign(const wxChar *sz, size_t n) | |
410 | { clear(); return append(sz, n); } | |
411 | // same as `= n copies of ch' | |
412 | wxStringBase& assign(size_t n, wxChar ch) | |
413 | { clear(); return append(n, ch); } | |
414 | // assign from first to last | |
415 | wxStringBase& assign(const_iterator first, const_iterator last) | |
416 | { clear(); return append(first, last); } | |
417 | ||
418 | // first valid index position | |
419 | const_iterator begin() const { return m_pchData; } | |
420 | // position one after the last valid one | |
421 | const_iterator end() const { return m_pchData + length(); } | |
422 | ||
423 | // first valid index position | |
424 | iterator begin(); | |
425 | // position one after the last valid one | |
426 | iterator end(); | |
427 | ||
428 | // insert another string | |
429 | wxStringBase& insert(size_t nPos, const wxStringBase& str) | |
430 | { | |
431 | wxASSERT( str.GetStringData()->IsValid() ); | |
432 | return insert(nPos, str.c_str(), str.length()); | |
433 | } | |
434 | // insert n chars of str starting at nStart (in str) | |
435 | wxStringBase& insert(size_t nPos, const wxStringBase& str, size_t nStart, size_t n) | |
436 | { | |
437 | wxASSERT( str.GetStringData()->IsValid() ); | |
438 | wxASSERT( nStart < str.length() ); | |
439 | size_t strLen = str.length() - nStart; | |
440 | n = strLen < n ? strLen : n; | |
441 | return insert(nPos, str.c_str() + nStart, n); | |
442 | } | |
443 | // insert first n (or all if n == npos) characters of sz | |
444 | wxStringBase& insert(size_t nPos, const wxChar *sz, size_t n = npos); | |
445 | // insert n copies of ch | |
446 | wxStringBase& insert(size_t nPos, size_t n, wxChar ch) | |
447 | { return insert(nPos, wxStringBase(n, ch)); } | |
448 | iterator insert(iterator it, wxChar ch) | |
449 | { size_t idx = it - begin(); insert(idx, 1, ch); return begin() + idx; } | |
450 | void insert(iterator it, const_iterator first, const_iterator last) | |
451 | { insert(it - begin(), first, last - first); } | |
452 | void insert(iterator it, size_type n, wxChar ch) | |
453 | { insert(it - begin(), n, ch); } | |
454 | ||
455 | // delete characters from nStart to nStart + nLen | |
456 | wxStringBase& erase(size_type pos = 0, size_type n = npos); | |
457 | iterator erase(iterator first, iterator last) | |
458 | { | |
459 | size_t idx = first - begin(); | |
460 | erase(idx, last - first); | |
461 | return begin() + idx; | |
462 | } | |
463 | iterator erase(iterator first); | |
464 | ||
465 | // explicit conversion to C string (use this with printf()!) | |
466 | const wxChar* c_str() const { return m_pchData; } | |
467 | const wxChar* data() const { return m_pchData; } | |
468 | ||
469 | // replaces the substring of length nLen starting at nStart | |
470 | wxStringBase& replace(size_t nStart, size_t nLen, const wxChar* sz); | |
471 | // replaces the substring of length nLen starting at nStart | |
472 | wxStringBase& replace(size_t nStart, size_t nLen, const wxStringBase& str) | |
473 | { return replace(nStart, nLen, str.c_str()); } | |
474 | // replaces the substring with nCount copies of ch | |
475 | wxStringBase& replace(size_t nStart, size_t nLen, size_t nCount, wxChar ch); | |
476 | // replaces a substring with another substring | |
477 | wxStringBase& replace(size_t nStart, size_t nLen, | |
478 | const wxStringBase& str, size_t nStart2, size_t nLen2); | |
479 | // replaces the substring with first nCount chars of sz | |
480 | wxStringBase& replace(size_t nStart, size_t nLen, | |
481 | const wxChar* sz, size_t nCount); | |
482 | wxStringBase& replace(iterator first, iterator last, const_pointer s) | |
483 | { return replace(first - begin(), last - first, s); } | |
484 | wxStringBase& replace(iterator first, iterator last, const_pointer s, | |
485 | size_type n) | |
486 | { return replace(first - begin(), last - first, s, n); } | |
487 | wxStringBase& replace(iterator first, iterator last, const wxStringBase& s) | |
488 | { return replace(first - begin(), last - first, s); } | |
489 | wxStringBase& replace(iterator first, iterator last, size_type n, wxChar c) | |
490 | { return replace(first - begin(), last - first, n, c); } | |
491 | wxStringBase& replace(iterator first, iterator last, | |
492 | const_iterator first1, const_iterator last1) | |
493 | { return replace(first - begin(), last - first, first1, last1 - first1); } | |
494 | ||
495 | // swap two strings | |
496 | void swap(wxStringBase& str); | |
497 | ||
498 | // All find() functions take the nStart argument which specifies the | |
499 | // position to start the search on, the default value is 0. All functions | |
500 | // return npos if there were no match. | |
501 | ||
502 | // find a substring | |
503 | size_t find(const wxStringBase& str, size_t nStart = 0) const; | |
504 | ||
505 | // VC++ 1.5 can't cope with this syntax. | |
506 | #if !defined(__VISUALC__) || defined(__WIN32__) | |
507 | // find first n characters of sz | |
508 | size_t find(const wxChar* sz, size_t nStart = 0, size_t n = npos) const; | |
509 | #endif // VC++ 1.5 | |
510 | ||
511 | // find the first occurence of character ch after nStart | |
512 | size_t find(wxChar ch, size_t nStart = 0) const; | |
513 | ||
514 | // rfind() family is exactly like find() but works right to left | |
515 | ||
516 | // as find, but from the end | |
517 | size_t rfind(const wxStringBase& str, size_t nStart = npos) const; | |
518 | ||
519 | // VC++ 1.5 can't cope with this syntax. | |
520 | // as find, but from the end | |
521 | size_t rfind(const wxChar* sz, size_t nStart = npos, | |
522 | size_t n = npos) const; | |
523 | // as find, but from the end | |
524 | size_t rfind(wxChar ch, size_t nStart = npos) const; | |
525 | ||
526 | // find first/last occurence of any character in the set | |
527 | ||
528 | // as strpbrk() but starts at nStart, returns npos if not found | |
529 | size_t find_first_of(const wxStringBase& str, size_t nStart = 0) const | |
530 | { return find_first_of(str.c_str(), nStart); } | |
531 | // same as above | |
532 | size_t find_first_of(const wxChar* sz, size_t nStart = 0) const; | |
533 | size_t find_first_of(const wxChar* sz, size_t nStart, size_t n) const; | |
534 | // same as find(char, size_t) | |
535 | size_t find_first_of(wxChar c, size_t nStart = 0) const | |
536 | { return find(c, nStart); } | |
537 | // find the last (starting from nStart) char from str in this string | |
538 | size_t find_last_of (const wxStringBase& str, size_t nStart = npos) const | |
539 | { return find_last_of(str.c_str(), nStart); } | |
540 | // same as above | |
541 | size_t find_last_of (const wxChar* sz, size_t nStart = npos) const; | |
542 | size_t find_last_of(const wxChar* sz, size_t nStart, size_t n) const; | |
543 | // same as above | |
544 | size_t find_last_of(wxChar c, size_t nStart = npos) const | |
545 | { return rfind(c, nStart); } | |
546 | ||
547 | // find first/last occurence of any character not in the set | |
548 | ||
549 | // as strspn() (starting from nStart), returns npos on failure | |
550 | size_t find_first_not_of(const wxStringBase& str, size_t nStart = 0) const | |
551 | { return find_first_not_of(str.c_str(), nStart); } | |
552 | // same as above | |
553 | size_t find_first_not_of(const wxChar* sz, size_t nStart = 0) const; | |
554 | size_t find_first_not_of(const wxChar* sz, size_t nStart, size_t n) const; | |
555 | // same as above | |
556 | size_t find_first_not_of(wxChar ch, size_t nStart = 0) const; | |
557 | // as strcspn() | |
558 | size_t find_last_not_of(const wxStringBase& str, size_t nStart = npos) const | |
559 | { return find_last_not_of(str.c_str(), nStart); } | |
560 | // same as above | |
561 | size_t find_last_not_of(const wxChar* sz, size_t nStart = npos) const; | |
562 | size_t find_last_not_of(const wxChar* sz, size_t nStart, size_t n) const; | |
563 | // same as above | |
564 | size_t find_last_not_of(wxChar ch, size_t nStart = npos) const; | |
565 | ||
566 | // All compare functions return -1, 0 or 1 if the [sub]string is less, | |
567 | // equal or greater than the compare() argument. | |
568 | ||
569 | // comparison with another string | |
570 | int compare(const wxStringBase& str) const; | |
571 | // comparison with a substring | |
572 | int compare(size_t nStart, size_t nLen, const wxStringBase& str) const; | |
573 | // comparison of 2 substrings | |
574 | int compare(size_t nStart, size_t nLen, | |
575 | const wxStringBase& str, size_t nStart2, size_t nLen2) const; | |
576 | // comparison with a c string | |
577 | int compare(const wxChar* sz) const; | |
578 | // substring comparison with first nCount characters of sz | |
579 | int compare(size_t nStart, size_t nLen, | |
580 | const wxChar* sz, size_t nCount = npos) const; | |
581 | ||
582 | size_type copy(wxChar* s, size_type n, size_type pos = 0); | |
583 | ||
584 | // substring extraction | |
585 | wxStringBase substr(size_t nStart = 0, size_t nLen = npos) const; | |
586 | ||
587 | // string += string | |
588 | wxStringBase& operator+=(const wxStringBase& s) { return append(s); } | |
589 | // string += C string | |
590 | wxStringBase& operator+=(const wxChar *psz) { return append(psz); } | |
591 | // string += char | |
592 | wxStringBase& operator+=(wxChar ch) { return append(1, ch); } | |
593 | }; | |
594 | ||
595 | #endif // !wxUSE_STL | |
596 | ||
597 | // ---------------------------------------------------------------------------- | |
598 | // wxString: string class trying to be compatible with std::string, MFC | |
599 | // CString and wxWindows 1.x wxString all at once | |
600 | // --------------------------------------------------------------------------- | |
601 | ||
602 | class WXDLLIMPEXP_BASE wxString : public wxStringBase | |
603 | { | |
604 | #if !wxUSE_STL | |
605 | friend class WXDLLIMPEXP_BASE wxArrayString; | |
606 | #endif | |
607 | ||
608 | // NB: special care was taken in arranging the member functions in such order | |
609 | // that all inline functions can be effectively inlined, verify that all | |
610 | // performace critical functions are still inlined if you change order! | |
611 | private: | |
612 | // if we hadn't made these operators private, it would be possible to | |
613 | // compile "wxString s; s = 17;" without any warnings as 17 is implicitly | |
614 | // converted to char in C and we do have operator=(char) | |
615 | // | |
616 | // NB: we don't need other versions (short/long and unsigned) as attempt | |
617 | // to assign another numeric type to wxString will now result in | |
618 | // ambiguity between operator=(char) and operator=(int) | |
619 | wxString& operator=(int); | |
620 | ||
621 | // these methods are not implemented - there is _no_ conversion from int to | |
622 | // string, you're doing something wrong if the compiler wants to call it! | |
623 | // | |
624 | // try `s << i' or `s.Printf("%d", i)' instead | |
625 | wxString(int); | |
626 | ||
627 | public: | |
628 | // constructors and destructor | |
629 | // ctor for an empty string | |
630 | wxString() : wxStringBase() { } | |
631 | // copy ctor | |
632 | wxString(const wxStringBase& stringSrc) : wxStringBase(stringSrc) { } | |
633 | wxString(const wxString& stringSrc) : wxStringBase(stringSrc) { } | |
634 | // string containing nRepeat copies of ch | |
635 | wxString(wxChar ch, size_t nRepeat = 1) | |
636 | : wxStringBase(nRepeat, ch) { } | |
637 | wxString(size_t nRepeat, wxChar ch) | |
638 | : wxStringBase(nRepeat, ch) { } | |
639 | // ctor takes first nLength characters from C string | |
640 | // (default value of npos means take all the string) | |
641 | wxString(const wxChar *psz) | |
642 | : wxStringBase(psz ? psz : wxT("")) { } | |
643 | wxString(const wxChar *psz, size_t nLength) | |
644 | : wxStringBase(psz, nLength) { } | |
645 | wxString(const wxChar *psz, wxMBConv& WXUNUSED(conv), size_t nLength = npos) | |
646 | : wxStringBase(psz, nLength == npos ? wxStrlen(psz) : nLength) { } | |
647 | ||
648 | #if wxUSE_UNICODE | |
649 | // from multibyte string | |
650 | wxString(const char *psz, wxMBConv& conv, size_t nLength = npos); | |
651 | // from wxWCharBuffer (i.e. return from wxGetString) | |
652 | wxString(const wxWCharBuffer& psz) : wxStringBase(psz.data()) { } | |
653 | #else // ANSI | |
654 | // from C string (for compilers using unsigned char) | |
655 | wxString(const unsigned char* psz, size_t nLength = npos) | |
656 | : wxStringBase((const char*)psz, nLength) { } | |
657 | ||
658 | #if wxUSE_WCHAR_T | |
659 | // from wide (Unicode) string | |
660 | wxString(const wchar_t *pwz, wxMBConv& conv = wxConvLibc, size_t nLength = npos); | |
661 | #endif // !wxUSE_WCHAR_T | |
662 | ||
663 | // from wxCharBuffer | |
664 | wxString(const wxCharBuffer& psz) | |
665 | : wxStringBase(psz) { } | |
666 | #endif // Unicode/ANSI | |
667 | ||
668 | // generic attributes & operations | |
669 | // as standard strlen() | |
670 | size_t Len() const { return length(); } | |
671 | // string contains any characters? | |
672 | bool IsEmpty() const { return empty(); } | |
673 | // empty string is "false", so !str will return true | |
674 | bool operator!() const { return IsEmpty(); } | |
675 | // truncate the string to given length | |
676 | wxString& Truncate(size_t uiLen); | |
677 | // empty string contents | |
678 | void Empty() | |
679 | { | |
680 | Truncate(0); | |
681 | ||
682 | wxASSERT_MSG( IsEmpty(), _T("string not empty after call to Empty()?") ); | |
683 | } | |
684 | // empty the string and free memory | |
685 | void Clear() | |
686 | { | |
687 | wxString tmp(wxEmptyString); | |
688 | swap(tmp); | |
689 | } | |
690 | ||
691 | // contents test | |
692 | // Is an ascii value | |
693 | bool IsAscii() const; | |
694 | // Is a number | |
695 | bool IsNumber() const; | |
696 | // Is a word | |
697 | bool IsWord() const; | |
698 | ||
699 | // data access (all indexes are 0 based) | |
700 | // read access | |
701 | wxChar GetChar(size_t n) const | |
702 | { return at(n); } | |
703 | // read/write access | |
704 | wxChar& GetWritableChar(size_t n) | |
705 | { return at(n); } | |
706 | // write access | |
707 | void SetChar(size_t n, wxChar ch) | |
708 | { at(n) = ch; } | |
709 | ||
710 | // get last character | |
711 | wxChar Last() const | |
712 | { | |
713 | wxASSERT_MSG( !IsEmpty(), _T("wxString: index out of bounds") ); | |
714 | ||
715 | return at(length() - 1); | |
716 | } | |
717 | ||
718 | // get writable last character | |
719 | wxChar& Last() | |
720 | { | |
721 | wxASSERT_MSG( !IsEmpty(), _T("wxString: index out of bounds") ); | |
722 | return at(length() - 1); | |
723 | } | |
724 | ||
725 | /* | |
726 | Note that we we must define all of the overloads below to avoid | |
727 | ambiguity when using str[0]. Also note that for a conforming compiler we | |
728 | don't need const version of operatorp[] at all as indexed access to | |
729 | const string is provided by implicit conversion to "const wxChar *" | |
730 | below and defining them would only result in ambiguities, but some other | |
731 | compilers refuse to compile "str[0]" without them. | |
732 | */ | |
733 | ||
734 | #if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__MWERKS__) | |
735 | wxChar operator[](int n) const | |
736 | { return wxStringBase::at(n); } | |
737 | wxChar operator[](size_type n) const | |
738 | { return wxStringBase::at(n); } | |
739 | #ifndef wxSIZE_T_IS_UINT | |
740 | wxChar operator[](unsigned int n) const | |
741 | { return wxStringBase::at(n); } | |
742 | #endif // size_t != unsigned int | |
743 | #endif // broken compiler | |
744 | ||
745 | ||
746 | // operator versions of GetWriteableChar() | |
747 | wxChar& operator[](int n) | |
748 | { return wxStringBase::at(n); } | |
749 | wxChar& operator[](size_type n) | |
750 | { return wxStringBase::at(n); } | |
751 | #ifndef wxSIZE_T_IS_UINT | |
752 | wxChar& operator[](unsigned int n) | |
753 | { return wxStringBase::at(n); } | |
754 | #endif // size_t != unsigned int | |
755 | ||
756 | // implicit conversion to C string | |
757 | operator const wxChar*() const { return c_str(); } | |
758 | ||
759 | // identical to c_str(), for wxWin 1.6x compatibility | |
760 | const wxChar* wx_str() const { return c_str(); } | |
761 | // identical to c_str(), for MFC compatibility | |
762 | const wxChar* GetData() const { return c_str(); } | |
763 | ||
764 | // conversion to/from plain (i.e. 7 bit) ASCII: this is useful for | |
765 | // converting numbers or strings which are certain not to contain special | |
766 | // chars (typically system functions, X atoms, environment variables etc.) | |
767 | // | |
768 | // the behaviour of these functions with the strings containing anything | |
769 | // else than 7 bit ASCII characters is undefined, use at your own risk. | |
770 | #if wxUSE_UNICODE | |
771 | static wxString FromAscii(const char *ascii); // string | |
772 | static wxString FromAscii(const char ascii); // char | |
773 | const wxCharBuffer ToAscii() const; | |
774 | #else // ANSI | |
775 | static wxString FromAscii(const char *ascii) { return wxString( ascii ); } | |
776 | static wxString FromAscii(const char ascii) { return wxString( ascii ); } | |
777 | const char *ToAscii() const { return c_str(); } | |
778 | #endif // Unicode/!Unicode | |
779 | ||
780 | // conversions with (possible) format conversions: have to return a | |
781 | // buffer with temporary data | |
782 | // | |
783 | // the functions defined (in either Unicode or ANSI) mode are mb_str() to | |
784 | // return an ANSI (multibyte) string, wc_str() to return a wide string and | |
785 | // fn_str() to return a string which should be used with the OS APIs | |
786 | // accepting the file names. The return value is always the same, but the | |
787 | // type differs because a function may either return pointer to the buffer | |
788 | // directly or have to use intermediate buffer for translation. | |
789 | #if wxUSE_UNICODE | |
790 | const wxCharBuffer mb_str(wxMBConv& conv = wxConvLibc) const; | |
791 | ||
792 | const wxWX2MBbuf mbc_str() const { return mb_str(*wxConvCurrent); } | |
793 | ||
794 | const wxChar* wc_str() const { return c_str(); } | |
795 | ||
796 | // for compatibility with !wxUSE_UNICODE version | |
797 | const wxChar* wc_str(wxMBConv& WXUNUSED(conv)) const { return c_str(); } | |
798 | ||
799 | #if wxMBFILES | |
800 | const wxCharBuffer fn_str() const { return mb_str(wxConvFile); } | |
801 | #else // !wxMBFILES | |
802 | const wxChar* fn_str() const { return c_str(); } | |
803 | #endif // wxMBFILES/!wxMBFILES | |
804 | #else // ANSI | |
805 | const wxChar* mb_str() const { return c_str(); } | |
806 | ||
807 | // for compatibility with wxUSE_UNICODE version | |
808 | const wxChar* mb_str(wxMBConv& WXUNUSED(conv)) const { return c_str(); } | |
809 | ||
810 | const wxWX2MBbuf mbc_str() const { return mb_str(); } | |
811 | ||
812 | #if wxUSE_WCHAR_T | |
813 | const wxWCharBuffer wc_str(wxMBConv& conv) const; | |
814 | #endif // wxUSE_WCHAR_T | |
815 | #ifdef __WXOSX__ | |
816 | const wxCharBuffer fn_str() const { return wxConvFile.cWC2WX( wc_str( wxConvLocal ) ); } | |
817 | #else | |
818 | const wxChar* fn_str() const { return c_str(); } | |
819 | #endif | |
820 | #endif // Unicode/ANSI | |
821 | ||
822 | // overloaded assignment | |
823 | // from another wxString | |
824 | wxString& operator=(const wxStringBase& stringSrc) | |
825 | { return (wxString&)wxStringBase::operator=(stringSrc); } | |
826 | // from a character | |
827 | wxString& operator=(wxChar ch) | |
828 | { return (wxString&)wxStringBase::operator=(ch); } | |
829 | // from a C string | |
830 | wxString& operator=(const wxChar *psz) | |
831 | { return (wxString&)wxStringBase::operator=(psz); } | |
832 | #if wxUSE_UNICODE | |
833 | // from wxWCharBuffer | |
834 | wxString& operator=(const wxWCharBuffer& psz) | |
835 | { (void) operator=((const wchar_t *)psz); return *this; } | |
836 | #else // ANSI | |
837 | // from another kind of C string | |
838 | wxString& operator=(const unsigned char* psz); | |
839 | #if wxUSE_WCHAR_T | |
840 | // from a wide string | |
841 | wxString& operator=(const wchar_t *pwz); | |
842 | #endif | |
843 | // from wxCharBuffer | |
844 | wxString& operator=(const wxCharBuffer& psz) | |
845 | { (void) operator=((const char *)psz); return *this; } | |
846 | #endif // Unicode/ANSI | |
847 | ||
848 | // string concatenation | |
849 | // in place concatenation | |
850 | /* | |
851 | Concatenate and return the result. Note that the left to right | |
852 | associativity of << allows to write things like "str << str1 << str2 | |
853 | << ..." (unlike with +=) | |
854 | */ | |
855 | // string += string | |
856 | wxString& operator<<(const wxString& s) | |
857 | { | |
858 | #if !wxUSE_STL | |
859 | wxASSERT_MSG( s.GetStringData()->IsValid(), | |
860 | _T("did you forget to call UngetWriteBuf()?") ); | |
861 | #endif | |
862 | ||
863 | append(s); | |
864 | return *this; | |
865 | } | |
866 | // string += C string | |
867 | wxString& operator<<(const wxChar *psz) | |
868 | { append(psz); return *this; } | |
869 | // string += char | |
870 | wxString& operator<<(wxChar ch) { append(1, ch); return *this; } | |
871 | ||
872 | // string += buffer (i.e. from wxGetString) | |
873 | #if wxUSE_UNICODE | |
874 | wxString& operator<<(const wxWCharBuffer& s) | |
875 | { (void)operator<<((const wchar_t *)s); return *this; } | |
876 | void operator+=(const wxWCharBuffer& s) | |
877 | { (void)operator<<((const wchar_t *)s); } | |
878 | #else // !wxUSE_UNICODE | |
879 | wxString& operator<<(const wxCharBuffer& s) | |
880 | { (void)operator<<((const char *)s); return *this; } | |
881 | void operator+=(const wxCharBuffer& s) | |
882 | { (void)operator<<((const char *)s); } | |
883 | #endif // wxUSE_UNICODE/!wxUSE_UNICODE | |
884 | ||
885 | // string += C string | |
886 | wxString& Append(const wxString& s) | |
887 | { | |
888 | // test for IsEmpty() to share the string if possible | |
889 | if ( IsEmpty() ) | |
890 | *this = s; | |
891 | else | |
892 | append(s); | |
893 | return *this; | |
894 | } | |
895 | wxString& Append(const wxChar* psz) | |
896 | { append(psz); return *this; } | |
897 | // append count copies of given character | |
898 | wxString& Append(wxChar ch, size_t count = 1u) | |
899 | { append(count, ch); return *this; } | |
900 | wxString& Append(const wxChar* psz, size_t nLen) | |
901 | { append(psz, nLen); return *this; } | |
902 | ||
903 | // prepend a string, return the string itself | |
904 | wxString& Prepend(const wxString& str) | |
905 | { *this = str + *this; return *this; } | |
906 | ||
907 | // non-destructive concatenation | |
908 | // | |
909 | friend wxString WXDLLIMPEXP_BASE operator+(const wxString& string1, const wxString& string2); | |
910 | // | |
911 | friend wxString WXDLLIMPEXP_BASE operator+(const wxString& string, wxChar ch); | |
912 | // | |
913 | friend wxString WXDLLIMPEXP_BASE operator+(wxChar ch, const wxString& string); | |
914 | // | |
915 | friend wxString WXDLLIMPEXP_BASE operator+(const wxString& string, const wxChar *psz); | |
916 | // | |
917 | friend wxString WXDLLIMPEXP_BASE operator+(const wxChar *psz, const wxString& string); | |
918 | ||
919 | // stream-like functions | |
920 | // insert an int into string | |
921 | wxString& operator<<(int i) | |
922 | { return (*this) << Format(_T("%d"), i); } | |
923 | // insert an unsigned int into string | |
924 | wxString& operator<<(unsigned int ui) | |
925 | { return (*this) << Format(_T("%u"), ui); } | |
926 | // insert a long into string | |
927 | wxString& operator<<(long l) | |
928 | { return (*this) << Format(_T("%ld"), l); } | |
929 | // insert an unsigned long into string | |
930 | wxString& operator<<(unsigned long ul) | |
931 | { return (*this) << Format(_T("%lu"), ul); } | |
932 | // insert a float into string | |
933 | wxString& operator<<(float f) | |
934 | { return (*this) << Format(_T("%f"), f); } | |
935 | // insert a double into string | |
936 | wxString& operator<<(double d) | |
937 | { return (*this) << Format(_T("%g"), d); } | |
938 | ||
939 | // string comparison | |
940 | // case-sensitive comparison (returns a value < 0, = 0 or > 0) | |
941 | int Cmp(const wxChar *psz) const; | |
942 | int Cmp(const wxString& s) const; | |
943 | // same as Cmp() but not case-sensitive | |
944 | int CmpNoCase(const wxChar *psz) const; | |
945 | int CmpNoCase(const wxString& s) const; | |
946 | // test for the string equality, either considering case or not | |
947 | // (if compareWithCase then the case matters) | |
948 | bool IsSameAs(const wxChar *psz, bool compareWithCase = true) const | |
949 | { return (compareWithCase ? Cmp(psz) : CmpNoCase(psz)) == 0; } | |
950 | // comparison with a signle character: returns true if equal | |
951 | bool IsSameAs(wxChar c, bool compareWithCase = true) const | |
952 | { | |
953 | return (length() == 1) && (compareWithCase ? GetChar(0u) == c | |
954 | : wxToupper(GetChar(0u)) == wxToupper(c)); | |
955 | } | |
956 | ||
957 | // simple sub-string extraction | |
958 | // return substring starting at nFirst of length nCount (or till the end | |
959 | // if nCount = default value) | |
960 | wxString Mid(size_t nFirst, size_t nCount = npos) const; | |
961 | ||
962 | // operator version of Mid() | |
963 | wxString operator()(size_t start, size_t len) const | |
964 | { return Mid(start, len); } | |
965 | ||
966 | // check that the string starts with prefix and return the rest of the | |
967 | // string in the provided pointer if it is not NULL, otherwise return | |
968 | // false | |
969 | bool StartsWith(const wxChar *prefix, wxString *rest = NULL) const; | |
970 | ||
971 | // get first nCount characters | |
972 | wxString Left(size_t nCount) const; | |
973 | // get last nCount characters | |
974 | wxString Right(size_t nCount) const; | |
975 | // get all characters before the first occurance of ch | |
976 | // (returns the whole string if ch not found) | |
977 | wxString BeforeFirst(wxChar ch) const; | |
978 | // get all characters before the last occurence of ch | |
979 | // (returns empty string if ch not found) | |
980 | wxString BeforeLast(wxChar ch) const; | |
981 | // get all characters after the first occurence of ch | |
982 | // (returns empty string if ch not found) | |
983 | wxString AfterFirst(wxChar ch) const; | |
984 | // get all characters after the last occurence of ch | |
985 | // (returns the whole string if ch not found) | |
986 | wxString AfterLast(wxChar ch) const; | |
987 | ||
988 | // for compatibility only, use more explicitly named functions above | |
989 | wxString Before(wxChar ch) const { return BeforeLast(ch); } | |
990 | wxString After(wxChar ch) const { return AfterFirst(ch); } | |
991 | ||
992 | // case conversion | |
993 | // convert to upper case in place, return the string itself | |
994 | wxString& MakeUpper(); | |
995 | // convert to upper case, return the copy of the string | |
996 | // Here's something to remember: BC++ doesn't like returns in inlines. | |
997 | wxString Upper() const ; | |
998 | // convert to lower case in place, return the string itself | |
999 | wxString& MakeLower(); | |
1000 | // convert to lower case, return the copy of the string | |
1001 | wxString Lower() const ; | |
1002 | ||
1003 | // trimming/padding whitespace (either side) and truncating | |
1004 | // remove spaces from left or from right (default) side | |
1005 | wxString& Trim(bool bFromRight = true); | |
1006 | // add nCount copies chPad in the beginning or at the end (default) | |
1007 | wxString& Pad(size_t nCount, wxChar chPad = wxT(' '), bool bFromRight = true); | |
1008 | ||
1009 | // searching and replacing | |
1010 | // searching (return starting index, or -1 if not found) | |
1011 | int Find(wxChar ch, bool bFromEnd = false) const; // like strchr/strrchr | |
1012 | // searching (return starting index, or -1 if not found) | |
1013 | int Find(const wxChar *pszSub) const; // like strstr | |
1014 | // replace first (or all of bReplaceAll) occurences of substring with | |
1015 | // another string, returns the number of replacements made | |
1016 | size_t Replace(const wxChar *szOld, | |
1017 | const wxChar *szNew, | |
1018 | bool bReplaceAll = true); | |
1019 | ||
1020 | // check if the string contents matches a mask containing '*' and '?' | |
1021 | bool Matches(const wxChar *szMask) const; | |
1022 | ||
1023 | // conversion to numbers: all functions return true only if the whole | |
1024 | // string is a number and put the value of this number into the pointer | |
1025 | // provided, the base is the numeric base in which the conversion should be | |
1026 | // done and must be comprised between 2 and 36 or be 0 in which case the | |
1027 | // standard C rules apply (leading '0' => octal, "0x" => hex) | |
1028 | // convert to a signed integer | |
1029 | bool ToLong(long *val, int base = 10) const; | |
1030 | // convert to an unsigned integer | |
1031 | bool ToULong(unsigned long *val, int base = 10) const; | |
1032 | // convert to a double | |
1033 | bool ToDouble(double *val) const; | |
1034 | ||
1035 | // formated input/output | |
1036 | // as sprintf(), returns the number of characters written or < 0 on error | |
1037 | // (take 'this' into account in attribute parameter count) | |
1038 | int Printf(const wxChar *pszFormat, ...) ATTRIBUTE_PRINTF_2; | |
1039 | // as vprintf(), returns the number of characters written or < 0 on error | |
1040 | int PrintfV(const wxChar* pszFormat, va_list argptr); | |
1041 | ||
1042 | // returns the string containing the result of Printf() to it | |
1043 | static wxString Format(const wxChar *pszFormat, ...) ATTRIBUTE_PRINTF_1; | |
1044 | // the same as above, but takes a va_list | |
1045 | static wxString FormatV(const wxChar *pszFormat, va_list argptr); | |
1046 | ||
1047 | // raw access to string memory | |
1048 | // ensure that string has space for at least nLen characters | |
1049 | // only works if the data of this string is not shared | |
1050 | bool Alloc(size_t nLen) { reserve(nLen); /*return capacity() >= nLen;*/ return true; } | |
1051 | // minimize the string's memory | |
1052 | // only works if the data of this string is not shared | |
1053 | bool Shrink(); | |
1054 | #if !wxUSE_STL | |
1055 | // get writable buffer of at least nLen bytes. Unget() *must* be called | |
1056 | // a.s.a.p. to put string back in a reasonable state! | |
1057 | wxChar *GetWriteBuf(size_t nLen); | |
1058 | // call this immediately after GetWriteBuf() has been used | |
1059 | void UngetWriteBuf(); | |
1060 | void UngetWriteBuf(size_t nLen); | |
1061 | #endif | |
1062 | ||
1063 | // wxWidgets version 1 compatibility functions | |
1064 | ||
1065 | // use Mid() | |
1066 | wxString SubString(size_t from, size_t to) const | |
1067 | { return Mid(from, (to - from + 1)); } | |
1068 | // values for second parameter of CompareTo function | |
1069 | enum caseCompare {exact, ignoreCase}; | |
1070 | // values for first parameter of Strip function | |
1071 | enum stripType {leading = 0x1, trailing = 0x2, both = 0x3}; | |
1072 | ||
1073 | // use Printf() | |
1074 | // (take 'this' into account in attribute parameter count) | |
1075 | int sprintf(const wxChar *pszFormat, ...) ATTRIBUTE_PRINTF_2; | |
1076 | ||
1077 | // use Cmp() | |
1078 | inline int CompareTo(const wxChar* psz, caseCompare cmp = exact) const | |
1079 | { return cmp == exact ? Cmp(psz) : CmpNoCase(psz); } | |
1080 | ||
1081 | // use Len | |
1082 | size_t Length() const { return length(); } | |
1083 | // Count the number of characters | |
1084 | int Freq(wxChar ch) const; | |
1085 | // use MakeLower | |
1086 | void LowerCase() { MakeLower(); } | |
1087 | // use MakeUpper | |
1088 | void UpperCase() { MakeUpper(); } | |
1089 | // use Trim except that it doesn't change this string | |
1090 | wxString Strip(stripType w = trailing) const; | |
1091 | ||
1092 | // use Find (more general variants not yet supported) | |
1093 | size_t Index(const wxChar* psz) const { return Find(psz); } | |
1094 | size_t Index(wxChar ch) const { return Find(ch); } | |
1095 | // use Truncate | |
1096 | wxString& Remove(size_t pos) { return Truncate(pos); } | |
1097 | wxString& RemoveLast(size_t n = 1) { return Truncate(length() - n); } | |
1098 | ||
1099 | wxString& Remove(size_t nStart, size_t nLen) | |
1100 | { return (wxString&)erase( nStart, nLen ); } | |
1101 | ||
1102 | // use Find() | |
1103 | int First( const wxChar ch ) const { return Find(ch); } | |
1104 | int First( const wxChar* psz ) const { return Find(psz); } | |
1105 | int First( const wxString &str ) const { return Find(str); } | |
1106 | int Last( const wxChar ch ) const { return Find(ch, true); } | |
1107 | bool Contains(const wxString& str) const { return Find(str) != wxNOT_FOUND; } | |
1108 | ||
1109 | // use IsEmpty() | |
1110 | bool IsNull() const { return IsEmpty(); } | |
1111 | ||
1112 | // std::string compatibility functions | |
1113 | ||
1114 | // take nLen chars starting at nPos | |
1115 | wxString(const wxString& str, size_t nPos, size_t nLen) | |
1116 | : wxStringBase(str, nPos, nLen) { } | |
1117 | // take all characters from pStart to pEnd | |
1118 | wxString(const void *pStart, const void *pEnd) | |
1119 | : wxStringBase((const wxChar*)pStart, (const wxChar*)pEnd) { } | |
1120 | #if wxUSE_STL | |
1121 | wxString(const_iterator first, const_iterator last) | |
1122 | : wxStringBase(first, last) { } | |
1123 | #endif | |
1124 | ||
1125 | // lib.string.modifiers | |
1126 | // append elements str[pos], ..., str[pos+n] | |
1127 | wxString& append(const wxString& str, size_t pos, size_t n) | |
1128 | { return (wxString&)wxStringBase::append(str, pos, n); } | |
1129 | // append a string | |
1130 | wxString& append(const wxString& str) | |
1131 | { return (wxString&)wxStringBase::append(str); } | |
1132 | // append first n (or all if n == npos) characters of sz | |
1133 | wxString& append(const wxChar *sz) | |
1134 | { return (wxString&)wxStringBase::append(sz); } | |
1135 | wxString& append(const wxChar *sz, size_t n) | |
1136 | { return (wxString&)wxStringBase::append(sz, n); } | |
1137 | // append n copies of ch | |
1138 | wxString& append(size_t n, wxChar ch) | |
1139 | { return (wxString&)wxStringBase::append(n, ch); } | |
1140 | // append from first to last | |
1141 | wxString& append(const_iterator first, const_iterator last) | |
1142 | { return (wxString&)wxStringBase::append(first, last); } | |
1143 | ||
1144 | // same as `this_string = str' | |
1145 | wxString& assign(const wxString& str) | |
1146 | { return (wxString&)wxStringBase::assign(str); } | |
1147 | // same as ` = str[pos..pos + n] | |
1148 | wxString& assign(const wxString& str, size_t pos, size_t n) | |
1149 | { return (wxString&)wxStringBase::assign(str, pos, n); } | |
1150 | // same as `= first n (or all if n == npos) characters of sz' | |
1151 | wxString& assign(const wxChar *sz) | |
1152 | { return (wxString&)wxStringBase::assign(sz); } | |
1153 | wxString& assign(const wxChar *sz, size_t n) | |
1154 | { return (wxString&)wxStringBase::assign(sz, n); } | |
1155 | // same as `= n copies of ch' | |
1156 | wxString& assign(size_t n, wxChar ch) | |
1157 | { return (wxString&)wxStringBase::assign(n, ch); } | |
1158 | // assign from first to last | |
1159 | wxString& assign(const_iterator first, const_iterator last) | |
1160 | { return (wxString&)wxStringBase::assign(first, last); } | |
1161 | ||
1162 | // string comparison | |
1163 | #ifndef HAVE_STD_STRING_COMPARE | |
1164 | int compare(const wxStringBase& str) const; | |
1165 | // comparison with a substring | |
1166 | int compare(size_t nStart, size_t nLen, const wxStringBase& str) const; | |
1167 | // comparison of 2 substrings | |
1168 | int compare(size_t nStart, size_t nLen, | |
1169 | const wxStringBase& str, size_t nStart2, size_t nLen2) const; | |
1170 | // just like strcmp() | |
1171 | int compare(const wxChar* sz) const; | |
1172 | // substring comparison with first nCount characters of sz | |
1173 | int compare(size_t nStart, size_t nLen, | |
1174 | const wxChar* sz, size_t nCount = npos) const; | |
1175 | #endif // !defined HAVE_STD_STRING_COMPARE | |
1176 | ||
1177 | // insert another string | |
1178 | wxString& insert(size_t nPos, const wxString& str) | |
1179 | { return (wxString&)wxStringBase::insert(nPos, str); } | |
1180 | // insert n chars of str starting at nStart (in str) | |
1181 | wxString& insert(size_t nPos, const wxString& str, size_t nStart, size_t n) | |
1182 | { return (wxString&)wxStringBase::insert(nPos, str, nStart, n); } | |
1183 | // insert first n (or all if n == npos) characters of sz | |
1184 | wxString& insert(size_t nPos, const wxChar *sz) | |
1185 | { return (wxString&)wxStringBase::insert(nPos, sz); } | |
1186 | wxString& insert(size_t nPos, const wxChar *sz, size_t n) | |
1187 | { return (wxString&)wxStringBase::insert(nPos, sz, n); } | |
1188 | // insert n copies of ch | |
1189 | wxString& insert(size_t nPos, size_t n, wxChar ch) | |
1190 | { return (wxString&)wxStringBase::insert(nPos, n, ch); } | |
1191 | iterator insert(iterator it, wxChar ch) | |
1192 | { return wxStringBase::insert(it, ch); } | |
1193 | void insert(iterator it, const_iterator first, const_iterator last) | |
1194 | { wxStringBase::insert(it, first, last); } | |
1195 | void insert(iterator it, size_type n, wxChar ch) | |
1196 | { wxStringBase::insert(it, n, ch); } | |
1197 | ||
1198 | // delete characters from nStart to nStart + nLen | |
1199 | wxString& erase(size_type pos = 0, size_type n = npos) | |
1200 | { return (wxString&)wxStringBase::erase(pos, n); } | |
1201 | iterator erase(iterator first, iterator last) | |
1202 | { return wxStringBase::erase(first, last); } | |
1203 | iterator erase(iterator first) | |
1204 | { return wxStringBase::erase(first); } | |
1205 | ||
1206 | #ifdef wxSTRING_BASE_HASNT_CLEAR | |
1207 | void clear() { erase(); } | |
1208 | #endif | |
1209 | ||
1210 | // replaces the substring of length nLen starting at nStart | |
1211 | wxString& replace(size_t nStart, size_t nLen, const wxChar* sz) | |
1212 | { return (wxString&)wxStringBase::replace(nStart, nLen, sz); } | |
1213 | // replaces the substring of length nLen starting at nStart | |
1214 | wxString& replace(size_t nStart, size_t nLen, const wxString& str) | |
1215 | { return (wxString&)wxStringBase::replace(nStart, nLen, str); } | |
1216 | // replaces the substring with nCount copies of ch | |
1217 | wxString& replace(size_t nStart, size_t nLen, size_t nCount, wxChar ch) | |
1218 | { return (wxString&)wxStringBase::replace(nStart, nLen, nCount, ch); } | |
1219 | // replaces a substring with another substring | |
1220 | wxString& replace(size_t nStart, size_t nLen, | |
1221 | const wxString& str, size_t nStart2, size_t nLen2) | |
1222 | { return (wxString&)wxStringBase::replace(nStart, nLen, str, | |
1223 | nStart2, nLen2); } | |
1224 | // replaces the substring with first nCount chars of sz | |
1225 | wxString& replace(size_t nStart, size_t nLen, | |
1226 | const wxChar* sz, size_t nCount) | |
1227 | { return (wxString&)wxStringBase::replace(nStart, nLen, sz, nCount); } | |
1228 | wxString& replace(iterator first, iterator last, const_pointer s) | |
1229 | { return (wxString&)wxStringBase::replace(first, last, s); } | |
1230 | wxString& replace(iterator first, iterator last, const_pointer s, | |
1231 | size_type n) | |
1232 | { return (wxString&)wxStringBase::replace(first, last, s, n); } | |
1233 | wxString& replace(iterator first, iterator last, const wxString& s) | |
1234 | { return (wxString&)wxStringBase::replace(first, last, s); } | |
1235 | wxString& replace(iterator first, iterator last, size_type n, wxChar c) | |
1236 | { return (wxString&)wxStringBase::replace(first, last, n, c); } | |
1237 | wxString& replace(iterator first, iterator last, | |
1238 | const_iterator first1, const_iterator last1) | |
1239 | { return (wxString&)wxStringBase::replace(first, last, first1, last1); } | |
1240 | ||
1241 | // string += string | |
1242 | wxString& operator+=(const wxString& s) | |
1243 | { return (wxString&)wxStringBase::operator+=(s); } | |
1244 | // string += C string | |
1245 | wxString& operator+=(const wxChar *psz) | |
1246 | { return (wxString&)wxStringBase::operator+=(psz); } | |
1247 | // string += char | |
1248 | wxString& operator+=(wxChar ch) | |
1249 | { return (wxString&)wxStringBase::operator+=(ch); } | |
1250 | }; | |
1251 | ||
1252 | // define wxArrayString, for compatibility | |
1253 | #if WXWIN_COMPATIBILITY_2_4 && !wxUSE_STL | |
1254 | #include "wx/arrstr.h" | |
1255 | #endif | |
1256 | ||
1257 | #if wxUSE_STL | |
1258 | // return an empty wxString (not very useful with wxUSE_STL == 1) | |
1259 | inline const wxString wxGetEmptyString() { return wxString(); } | |
1260 | #else // !wxUSE_STL | |
1261 | // return an empty wxString (more efficient than wxString() here) | |
1262 | inline const wxString& wxGetEmptyString() | |
1263 | { | |
1264 | return *(wxString *)&wxEmptyString; | |
1265 | } | |
1266 | #endif // wxUSE_STL/!wxUSE_STL | |
1267 | ||
1268 | // ---------------------------------------------------------------------------- | |
1269 | // wxStringBuffer: a tiny class allowing to get a writable pointer into string | |
1270 | // ---------------------------------------------------------------------------- | |
1271 | ||
1272 | #if wxUSE_STL | |
1273 | ||
1274 | class WXDLLIMPEXP_BASE wxStringBuffer | |
1275 | { | |
1276 | public: | |
1277 | wxStringBuffer(wxString& str, size_t lenWanted = 1024) | |
1278 | : m_str(str), m_buf(lenWanted) | |
1279 | { } | |
1280 | ||
1281 | ~wxStringBuffer() { m_str.assign(m_buf.data(), wxStrlen(m_buf.data())); } | |
1282 | ||
1283 | operator wxChar*() { return m_buf.data(); } | |
1284 | ||
1285 | private: | |
1286 | wxString& m_str; | |
1287 | #if wxUSE_UNICODE | |
1288 | wxWCharBuffer m_buf; | |
1289 | #else | |
1290 | wxCharBuffer m_buf; | |
1291 | #endif | |
1292 | ||
1293 | DECLARE_NO_COPY_CLASS(wxStringBuffer) | |
1294 | }; | |
1295 | ||
1296 | class WXDLLIMPEXP_BASE wxStringBufferLength | |
1297 | { | |
1298 | public: | |
1299 | wxStringBufferLength(wxString& str, size_t lenWanted = 1024) | |
1300 | : m_str(str), m_buf(lenWanted), m_len(0), m_lenSet(false) | |
1301 | { } | |
1302 | ||
1303 | ~wxStringBufferLength() | |
1304 | { | |
1305 | wxASSERT(m_lenSet); | |
1306 | m_str.assign(m_buf.data(), m_len); | |
1307 | } | |
1308 | ||
1309 | operator wxChar*() { return m_buf.data(); } | |
1310 | void SetLength(size_t length) { m_len = length; m_lenSet = true; } | |
1311 | ||
1312 | private: | |
1313 | wxString& m_str; | |
1314 | #if wxUSE_UNICODE | |
1315 | wxWCharBuffer m_buf; | |
1316 | #else | |
1317 | wxCharBuffer m_buf; | |
1318 | #endif | |
1319 | size_t m_len; | |
1320 | bool m_lenSet; | |
1321 | ||
1322 | DECLARE_NO_COPY_CLASS(wxStringBufferLength) | |
1323 | }; | |
1324 | ||
1325 | #else // if !wxUSE_STL | |
1326 | ||
1327 | class WXDLLIMPEXP_BASE wxStringBuffer | |
1328 | { | |
1329 | public: | |
1330 | wxStringBuffer(wxString& str, size_t lenWanted = 1024) | |
1331 | : m_str(str), m_buf(NULL) | |
1332 | { m_buf = m_str.GetWriteBuf(lenWanted); } | |
1333 | ||
1334 | ~wxStringBuffer() { m_str.UngetWriteBuf(); } | |
1335 | ||
1336 | operator wxChar*() const { return m_buf; } | |
1337 | ||
1338 | private: | |
1339 | wxString& m_str; | |
1340 | wxChar *m_buf; | |
1341 | ||
1342 | DECLARE_NO_COPY_CLASS(wxStringBuffer) | |
1343 | }; | |
1344 | ||
1345 | class WXDLLIMPEXP_BASE wxStringBufferLength | |
1346 | { | |
1347 | public: | |
1348 | wxStringBufferLength(wxString& str, size_t lenWanted = 1024) | |
1349 | : m_str(str), m_buf(NULL), m_len(0), m_lenSet(false) | |
1350 | { | |
1351 | m_buf = m_str.GetWriteBuf(lenWanted); | |
1352 | wxASSERT(m_buf != NULL); | |
1353 | } | |
1354 | ||
1355 | ~wxStringBufferLength() | |
1356 | { | |
1357 | wxASSERT(m_lenSet); | |
1358 | m_str.UngetWriteBuf(m_len); | |
1359 | } | |
1360 | ||
1361 | operator wxChar*() const { return m_buf; } | |
1362 | void SetLength(size_t length) { m_len = length; m_lenSet = true; } | |
1363 | ||
1364 | private: | |
1365 | wxString& m_str; | |
1366 | wxChar *m_buf; | |
1367 | size_t m_len; | |
1368 | bool m_lenSet; | |
1369 | ||
1370 | DECLARE_NO_COPY_CLASS(wxStringBufferLength) | |
1371 | }; | |
1372 | ||
1373 | #endif // !wxUSE_STL | |
1374 | ||
1375 | // --------------------------------------------------------------------------- | |
1376 | // wxString comparison functions: operator versions are always case sensitive | |
1377 | // --------------------------------------------------------------------------- | |
1378 | ||
1379 | // note that when wxUSE_STL == 1 the comparison operators taking std::string | |
1380 | // are used and defining them also for wxString would only result in | |
1381 | // compilation ambiguities when comparing std::string and wxString | |
1382 | #if !wxUSE_STL | |
1383 | ||
1384 | inline bool operator==(const wxString& s1, const wxString& s2) | |
1385 | { return (s1.Len() == s2.Len()) && (s1.Cmp(s2) == 0); } | |
1386 | inline bool operator==(const wxString& s1, const wxChar * s2) | |
1387 | { return s1.Cmp(s2) == 0; } | |
1388 | inline bool operator==(const wxChar * s1, const wxString& s2) | |
1389 | { return s2.Cmp(s1) == 0; } | |
1390 | inline bool operator!=(const wxString& s1, const wxString& s2) | |
1391 | { return (s1.Len() != s2.Len()) || (s1.Cmp(s2) != 0); } | |
1392 | inline bool operator!=(const wxString& s1, const wxChar * s2) | |
1393 | { return s1.Cmp(s2) != 0; } | |
1394 | inline bool operator!=(const wxChar * s1, const wxString& s2) | |
1395 | { return s2.Cmp(s1) != 0; } | |
1396 | inline bool operator< (const wxString& s1, const wxString& s2) | |
1397 | { return s1.Cmp(s2) < 0; } | |
1398 | inline bool operator< (const wxString& s1, const wxChar * s2) | |
1399 | { return s1.Cmp(s2) < 0; } | |
1400 | inline bool operator< (const wxChar * s1, const wxString& s2) | |
1401 | { return s2.Cmp(s1) > 0; } | |
1402 | inline bool operator> (const wxString& s1, const wxString& s2) | |
1403 | { return s1.Cmp(s2) > 0; } | |
1404 | inline bool operator> (const wxString& s1, const wxChar * s2) | |
1405 | { return s1.Cmp(s2) > 0; } | |
1406 | inline bool operator> (const wxChar * s1, const wxString& s2) | |
1407 | { return s2.Cmp(s1) < 0; } | |
1408 | inline bool operator<=(const wxString& s1, const wxString& s2) | |
1409 | { return s1.Cmp(s2) <= 0; } | |
1410 | inline bool operator<=(const wxString& s1, const wxChar * s2) | |
1411 | { return s1.Cmp(s2) <= 0; } | |
1412 | inline bool operator<=(const wxChar * s1, const wxString& s2) | |
1413 | { return s2.Cmp(s1) >= 0; } | |
1414 | inline bool operator>=(const wxString& s1, const wxString& s2) | |
1415 | { return s1.Cmp(s2) >= 0; } | |
1416 | inline bool operator>=(const wxString& s1, const wxChar * s2) | |
1417 | { return s1.Cmp(s2) >= 0; } | |
1418 | inline bool operator>=(const wxChar * s1, const wxString& s2) | |
1419 | { return s2.Cmp(s1) <= 0; } | |
1420 | ||
1421 | #if wxUSE_UNICODE | |
1422 | inline bool operator==(const wxString& s1, const wxWCharBuffer& s2) | |
1423 | { return (s1.Cmp((const wchar_t *)s2) == 0); } | |
1424 | inline bool operator==(const wxWCharBuffer& s1, const wxString& s2) | |
1425 | { return (s2.Cmp((const wchar_t *)s1) == 0); } | |
1426 | inline bool operator!=(const wxString& s1, const wxWCharBuffer& s2) | |
1427 | { return (s1.Cmp((const wchar_t *)s2) != 0); } | |
1428 | inline bool operator!=(const wxWCharBuffer& s1, const wxString& s2) | |
1429 | { return (s2.Cmp((const wchar_t *)s1) != 0); } | |
1430 | #else // !wxUSE_UNICODE | |
1431 | inline bool operator==(const wxString& s1, const wxCharBuffer& s2) | |
1432 | { return (s1.Cmp((const char *)s2) == 0); } | |
1433 | inline bool operator==(const wxCharBuffer& s1, const wxString& s2) | |
1434 | { return (s2.Cmp((const char *)s1) == 0); } | |
1435 | inline bool operator!=(const wxString& s1, const wxCharBuffer& s2) | |
1436 | { return (s1.Cmp((const char *)s2) != 0); } | |
1437 | inline bool operator!=(const wxCharBuffer& s1, const wxString& s2) | |
1438 | { return (s2.Cmp((const char *)s1) != 0); } | |
1439 | #endif // wxUSE_UNICODE/!wxUSE_UNICODE | |
1440 | ||
1441 | wxString WXDLLIMPEXP_BASE operator+(const wxString& string1, const wxString& string2); | |
1442 | wxString WXDLLIMPEXP_BASE operator+(const wxString& string, wxChar ch); | |
1443 | wxString WXDLLIMPEXP_BASE operator+(wxChar ch, const wxString& string); | |
1444 | wxString WXDLLIMPEXP_BASE operator+(const wxString& string, const wxChar *psz); | |
1445 | wxString WXDLLIMPEXP_BASE operator+(const wxChar *psz, const wxString& string); | |
1446 | ||
1447 | #if wxUSE_UNICODE | |
1448 | inline wxString operator+(const wxString& string, const wxWCharBuffer& buf) | |
1449 | { return string + (const wchar_t *)buf; } | |
1450 | inline wxString operator+(const wxWCharBuffer& buf, const wxString& string) | |
1451 | { return (const wchar_t *)buf + string; } | |
1452 | #else // !wxUSE_UNICODE | |
1453 | inline wxString operator+(const wxString& string, const wxCharBuffer& buf) | |
1454 | { return string + (const char *)buf; } | |
1455 | inline wxString operator+(const wxCharBuffer& buf, const wxString& string) | |
1456 | { return (const char *)buf + string; } | |
1457 | #endif // wxUSE_UNICODE/!wxUSE_UNICODE | |
1458 | ||
1459 | #endif // !wxUSE_STL | |
1460 | ||
1461 | // comparison with char (those are not defined by std::[w]string and so should | |
1462 | // be always available) | |
1463 | inline bool operator==(wxChar c, const wxString& s) { return s.IsSameAs(c); } | |
1464 | inline bool operator==(const wxString& s, wxChar c) { return s.IsSameAs(c); } | |
1465 | inline bool operator!=(wxChar c, const wxString& s) { return !s.IsSameAs(c); } | |
1466 | inline bool operator!=(const wxString& s, wxChar c) { return !s.IsSameAs(c); } | |
1467 | ||
1468 | // --------------------------------------------------------------------------- | |
1469 | // Implementation only from here until the end of file | |
1470 | // --------------------------------------------------------------------------- | |
1471 | ||
1472 | // don't pollute the library user's name space | |
1473 | #undef wxASSERT_VALID_INDEX | |
1474 | ||
1475 | #if wxUSE_STD_IOSTREAM | |
1476 | ||
1477 | #include "wx/iosfwrap.h" | |
1478 | ||
1479 | WXDLLIMPEXP_BASE wxSTD istream& operator>>(wxSTD istream&, wxString&); | |
1480 | WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxString&); | |
1481 | ||
1482 | #endif // wxSTD_STRING_COMPATIBILITY | |
1483 | ||
1484 | #endif // _WX_WXSTRINGH__ |