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