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