1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxString and wxArrayString classes
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
13 Efficient string class [more or less] compatible with MFC CString,
14 wxWindows version 1 wxString and std::string and some handy functions
15 missing from string.h.
18 #ifndef _WX_WXSTRINGH__
19 #define _WX_WXSTRINGH__
21 #if defined(__GNUG__) && !defined(__APPLE__)
22 #pragma interface "string.h"
25 // ----------------------------------------------------------------------------
26 // conditinal compilation
27 // ----------------------------------------------------------------------------
29 // compile the std::string compatibility functions if defined
30 #define wxSTD_STRING_COMPATIBILITY
32 // ----------------------------------------------------------------------------
34 // ----------------------------------------------------------------------------
36 #include "wx/defs.h" // everybody should include this
38 #if defined(__WXMAC__) || defined(__VISAGECPP__)
46 #if defined(__VISAGECPP__) && __IBMCPP__ >= 400
47 // problem in VACPP V4 with including stdlib.h multiple times
48 // strconv includes it anyway
62 #include <strings.h> // for strcasecmp()
63 #endif // HAVE_STRINGS_H
65 #include "wx/wxchar.h" // for wxChar
66 #include "wx/buffer.h" // for wxCharBuffer
67 #include "wx/strconv.h" // for wxConvertXXX() macros and wxMBConv classes
69 // ---------------------------------------------------------------------------
71 // ---------------------------------------------------------------------------
73 // casts [unfortunately!] needed to call some broken functions which require
74 // "char *" instead of "const char *"
75 #define WXSTRINGCAST (wxChar *)(const wxChar *)
76 #define wxCSTRINGCAST (wxChar *)(const wxChar *)
77 #define wxMBSTRINGCAST (char *)(const char *)
78 #define wxWCSTRINGCAST (wchar_t *)(const wchar_t *)
80 // implementation only
81 #define wxASSERT_VALID_INDEX(i) \
82 wxASSERT_MSG( (size_t)(i) <= Len(), _T("invalid index in wxString") )
84 // ----------------------------------------------------------------------------
86 // ----------------------------------------------------------------------------
88 #if defined(__VISAGECPP__) && __IBMCPP__ >= 400
89 // must define this static for VA or else you get multiply defined symbols everywhere
90 extern const unsigned int wxSTRING_MAXLEN
;
93 // maximum possible length for a string means "take all string" everywhere
94 // (as sizeof(StringData) is unknown here, we substract 100)
95 const unsigned int wxSTRING_MAXLEN
= UINT_MAX
- 100;
99 // ----------------------------------------------------------------------------
101 // ----------------------------------------------------------------------------
103 // global pointer to empty string
104 WXDLLEXPORT_DATA(extern const wxChar
*) wxEmptyString
;
106 // ---------------------------------------------------------------------------
107 // global functions complementing standard C string library replacements for
108 // strlen() and portable strcasecmp()
109 //---------------------------------------------------------------------------
111 // Use wxXXX() functions from wxchar.h instead! These functions are for
112 // backwards compatibility only.
114 // checks whether the passed in pointer is NULL and if the string is empty
115 inline bool IsEmpty(const char *p
) { return (!p
|| !*p
); }
117 // safe version of strlen() (returns 0 if passed NULL pointer)
118 inline size_t Strlen(const char *psz
)
119 { return psz
? strlen(psz
) : 0; }
121 // portable strcasecmp/_stricmp
122 inline int Stricmp(const char *psz1
, const char *psz2
)
124 #if defined(__VISUALC__) || ( defined(__MWERKS__) && defined(__INTEL__) )
125 return _stricmp(psz1
, psz2
);
126 #elif defined(__SC__)
127 return _stricmp(psz1
, psz2
);
128 #elif defined(__SALFORDC__)
129 return stricmp(psz1
, psz2
);
130 #elif defined(__BORLANDC__)
131 return stricmp(psz1
, psz2
);
132 #elif defined(__WATCOMC__)
133 return stricmp(psz1
, psz2
);
134 #elif defined(__DJGPP__)
135 return stricmp(psz1
, psz2
);
136 #elif defined(__EMX__)
137 return stricmp(psz1
, psz2
);
138 #elif defined(__WXPM__)
139 return stricmp(psz1
, psz2
);
140 #elif defined(__UNIX__) || defined(__GNUWIN32__)
141 return strcasecmp(psz1
, psz2
);
142 #elif defined(__MWERKS__) && !defined(__INTEL__)
143 register char c1
, c2
;
145 c1
= tolower(*psz1
++);
146 c2
= tolower(*psz2
++);
147 } while ( c1
&& (c1
== c2
) );
151 // almost all compilers/libraries provide this function (unfortunately under
152 // different names), that's why we don't implement our own which will surely
153 // be more efficient than this code (uncomment to use):
155 register char c1, c2;
157 c1 = tolower(*psz1++);
158 c2 = tolower(*psz2++);
159 } while ( c1 && (c1 == c2) );
164 #error "Please define string case-insensitive compare for your OS/compiler"
165 #endif // OS/compiler
168 // return an empty wxString
169 class WXDLLEXPORT wxString
; // not yet defined
170 inline const wxString
& wxGetEmptyString() { return *(wxString
*)&wxEmptyString
; }
172 // ---------------------------------------------------------------------------
173 // string data prepended with some housekeeping info (used by wxString class),
174 // is never used directly (but had to be put here to allow inlining)
175 // ---------------------------------------------------------------------------
177 struct WXDLLEXPORT wxStringData
179 int nRefs
; // reference count
180 size_t nDataLength
, // actual string length
181 nAllocLength
; // allocated memory size
183 // mimics declaration 'wxChar data[nAllocLength]'
184 wxChar
* data() const { return (wxChar
*)(this + 1); }
186 // empty string has a special ref count so it's never deleted
187 bool IsEmpty() const { return (nRefs
== -1); }
188 bool IsShared() const { return (nRefs
> 1); }
191 void Lock() { if ( !IsEmpty() ) nRefs
++; }
193 // VC++ will refuse to inline this function but profiling shows that it
195 #if defined(__VISUALC__) && (__VISUALC__ >= 1200)
198 void Unlock() { if ( !IsEmpty() && --nRefs
== 0) free(this); }
200 // if we had taken control over string memory (GetWriteBuf), it's
201 // intentionally put in invalid state
202 void Validate(bool b
) { nRefs
= (b
? 1 : 0); }
203 bool IsValid() const { return (nRefs
!= 0); }
206 // ---------------------------------------------------------------------------
207 // This is (yet another one) String class for C++ programmers. It doesn't use
208 // any of "advanced" C++ features (i.e. templates, exceptions, namespaces...)
209 // thus you should be able to compile it with practicaly any C++ compiler.
210 // This class uses copy-on-write technique, i.e. identical strings share the
211 // same memory as long as neither of them is changed.
213 // This class aims to be as compatible as possible with the new standard
214 // std::string class, but adds some additional functions and should be at
215 // least as efficient than the standard implementation.
217 // Performance note: it's more efficient to write functions which take "const
218 // String&" arguments than "const char *" if you assign the argument to
221 // It was compiled and tested under Win32, Linux (libc 5 & 6), Solaris 5.5.
224 // - ressource support (string tables in ressources)
225 // - more wide character (UNICODE) support
226 // - regular expressions support
227 // ---------------------------------------------------------------------------
229 class WXDLLEXPORT wxString
231 friend class WXDLLEXPORT wxArrayString
;
233 // NB: special care was taken in arranging the member functions in such order
234 // that all inline functions can be effectively inlined, verify that all
235 // performace critical functions are still inlined if you change order!
237 // points to data preceded by wxStringData structure with ref count info
240 // accessor to string data
241 wxStringData
* GetStringData() const { return (wxStringData
*)m_pchData
- 1; }
243 // string (re)initialization functions
244 // initializes the string to the empty value (must be called only from
245 // ctors, use Reinit() otherwise)
246 void Init() { m_pchData
= (wxChar
*)wxEmptyString
; }
247 // initializaes the string with (a part of) C-string
248 void InitWith(const wxChar
*psz
, size_t nPos
= 0, size_t nLen
= wxSTRING_MAXLEN
);
249 // as Init, but also frees old data
250 void Reinit() { GetStringData()->Unlock(); Init(); }
253 // allocates memory for string of length nLen
254 bool AllocBuffer(size_t nLen
);
255 // copies data to another string
256 bool AllocCopy(wxString
&, int, int) const;
257 // effectively copies data to string
258 bool AssignCopy(size_t, const wxChar
*);
260 // append a (sub)string
261 bool ConcatSelf(int nLen
, const wxChar
*src
);
263 // functions called before writing to the string: they copy it if there
264 // are other references to our data (should be the only owner when writing)
265 bool CopyBeforeWrite();
266 bool AllocBeforeWrite(size_t);
268 // if we hadn't made these operators private, it would be possible to
269 // compile "wxString s; s = 17;" without any warnings as 17 is implicitly
270 // converted to char in C and we do have operator=(char)
272 // NB: we don't need other versions (short/long and unsigned) as attempt
273 // to assign another numeric type to wxString will now result in
274 // ambiguity between operator=(char) and operator=(int)
275 wxString
& operator=(int);
277 // these methods are not implemented - there is _no_ conversion from int to
278 // string, you're doing something wrong if the compiler wants to call it!
280 // try `s << i' or `s.Printf("%d", i)' instead
284 // constructors and destructor
285 // ctor for an empty string
286 wxString() : m_pchData(NULL
) { Init(); }
288 wxString(const wxString
& stringSrc
) : m_pchData(NULL
)
290 wxASSERT_MSG( stringSrc
.GetStringData()->IsValid(),
291 _T("did you forget to call UngetWriteBuf()?") );
293 if ( stringSrc
.IsEmpty() ) {
294 // nothing to do for an empty string
298 m_pchData
= stringSrc
.m_pchData
; // share same data
299 GetStringData()->Lock(); // => one more copy
302 // string containing nRepeat copies of ch
303 wxString(wxChar ch
, size_t nRepeat
= 1);
304 // ctor takes first nLength characters from C string
305 // (default value of wxSTRING_MAXLEN means take all the string)
306 wxString(const wxChar
*psz
, size_t nLength
= wxSTRING_MAXLEN
)
308 { InitWith(psz
, 0, nLength
); }
309 wxString(const wxChar
*psz
, wxMBConv
& WXUNUSED(conv
), size_t nLength
= wxSTRING_MAXLEN
)
311 { InitWith(psz
, 0, nLength
); }
314 // from multibyte string
315 // (NB: nLength is right now number of Unicode characters, not
316 // characters in psz! So try not to use it yet!)
317 wxString(const char *psz
, wxMBConv
& conv
, size_t nLength
= wxSTRING_MAXLEN
);
318 // from wxWCharBuffer (i.e. return from wxGetString)
319 wxString(const wxWCharBuffer
& psz
)
320 { InitWith(psz
, 0, wxSTRING_MAXLEN
); }
322 // from C string (for compilers using unsigned char)
323 wxString(const unsigned char* psz
, size_t nLength
= wxSTRING_MAXLEN
)
325 { InitWith((const char*)psz
, 0, nLength
); }
328 // from wide (Unicode) string
329 wxString(const wchar_t *pwz
, wxMBConv
& conv
= wxConvLibc
, size_t nLength
= wxSTRING_MAXLEN
);
330 #endif // !wxUSE_WCHAR_T
333 wxString(const wxCharBuffer
& psz
)
335 { InitWith(psz
, 0, wxSTRING_MAXLEN
); }
336 #endif // Unicode/ANSI
338 // dtor is not virtual, this class must not be inherited from!
339 ~wxString() { GetStringData()->Unlock(); }
341 // generic attributes & operations
342 // as standard strlen()
343 size_t Len() const { return GetStringData()->nDataLength
; }
344 // string contains any characters?
345 bool IsEmpty() const { return Len() == 0; }
346 // empty string is "FALSE", so !str will return TRUE
347 bool operator!() const { return IsEmpty(); }
348 // truncate the string to given length
349 wxString
& Truncate(size_t uiLen
);
350 // empty string contents
355 wxASSERT_MSG( IsEmpty(), _T("string not empty after call to Empty()?") );
357 // empty the string and free memory
360 if ( !GetStringData()->IsEmpty() )
363 wxASSERT_MSG( !GetStringData()->nDataLength
&&
364 !GetStringData()->nAllocLength
,
365 _T("string should be empty after Clear()") );
370 bool IsAscii() const;
372 bool IsNumber() const;
376 // data access (all indexes are 0 based)
378 wxChar
GetChar(size_t n
) const
379 { wxASSERT_VALID_INDEX( n
); return m_pchData
[n
]; }
381 wxChar
& GetWritableChar(size_t n
)
382 { wxASSERT_VALID_INDEX( n
); CopyBeforeWrite(); return m_pchData
[n
]; }
384 void SetChar(size_t n
, wxChar ch
)
385 { wxASSERT_VALID_INDEX( n
); CopyBeforeWrite(); m_pchData
[n
] = ch
; }
387 // get last character
390 wxASSERT_MSG( !IsEmpty(), _T("wxString: index out of bounds") );
392 return m_pchData
[Len() - 1];
395 // get writable last character
398 wxASSERT_MSG( !IsEmpty(), _T("wxString: index out of bounds") );
400 return m_pchData
[Len()-1];
404 So why do we have all these overloaded operator[]s? A bit of history:
405 initially there was only one of them, taking size_t. Then people
406 started complaining because they wanted to use ints as indices (I
407 wonder why) and compilers were giving warnings about it, so we had to
408 add the operator[](int). Then it became apparent that you couldn't
409 write str[0] any longer because there was ambiguity between two
410 overloads and so you now had to write str[0u] (or, of course, use the
411 explicit casts to either int or size_t but nobody did this).
413 Finally, someone decided to compile wxWin on an Alpha machine and got
414 a surprize: str[0u] didn't compile there because it is of type
415 unsigned int and size_t is unsigned _long_ on Alpha and so there was
416 ambiguity between converting uint to int or ulong. To fix this one we
417 now add operator[](uint) for the machines where size_t is not already
418 the same as unsigned int - hopefully this fixes the problem (for some
421 The only real fix is, of course, to remove all versions but the one
425 // operator version of GetChar
426 wxChar
operator[](size_t n
) const
427 { wxASSERT_VALID_INDEX( n
); return m_pchData
[n
]; }
429 // operator version of GetChar
430 wxChar
operator[](int n
) const
431 { wxASSERT_VALID_INDEX( n
); return m_pchData
[n
]; }
433 // operator version of GetWriteableChar
434 wxChar
& operator[](size_t n
)
435 { wxASSERT_VALID_INDEX( n
); CopyBeforeWrite(); return m_pchData
[n
]; }
437 #ifndef wxSIZE_T_IS_UINT
438 // operator version of GetChar
439 wxChar
operator[](unsigned int n
) const
440 { wxASSERT_VALID_INDEX( n
); return m_pchData
[n
]; }
442 // operator version of GetWriteableChar
443 wxChar
& operator[](unsigned int n
)
444 { wxASSERT_VALID_INDEX( n
); CopyBeforeWrite(); return m_pchData
[n
]; }
445 #endif // size_t != unsigned int
447 // implicit conversion to C string
448 operator const wxChar
*() const { return m_pchData
; }
450 // explicit conversion to C string (use this with printf()!)
451 const wxChar
* c_str() const { return m_pchData
; }
452 // identical to c_str(), for wxWin 1.6x compatibility
453 const wxChar
* wx_str() const { return m_pchData
; }
454 // identical to c_str(), for MFC compatibility
455 const wxChar
* GetData() const { return m_pchData
; }
457 // conversion to/from plain (i.e. 7 bit) ASCII: this is useful for
458 // converting numbers or strings which are certain not to contain special
459 // chars (typically system functions, X atoms, environment variables etc.)
461 // the behaviour of these functions with the strings containing anything
462 // else than 7 bit ASCII characters is undefined, use at your own risk.
464 static wxString
FromAscii(const char *ascii
); // string
465 static wxString
FromAscii(const char ascii
); // char
466 const wxCharBuffer
ToAscii() const;
468 static wxString
FromAscii(const char *ascii
) { return wxString( ascii
); }
469 static wxString
FromAscii(const char ascii
) { return wxString( ascii
); }
470 const char *ToAscii() const { return c_str(); }
471 #endif // Unicode/!Unicode
473 // conversions with (possible) format conversions: have to return a
474 // buffer with temporary data
476 // the functions defined (in either Unicode or ANSI) mode are mb_str() to
477 // return an ANSI (multibyte) string, wc_str() to return a wide string and
478 // fn_str() to return a string which should be used with the OS APIs
479 // accepting the file names. The return value is always the same, but the
480 // type differs because a function may either return pointer to the buffer
481 // directly or have to use intermediate buffer for translation.
483 const wxCharBuffer
mb_str(wxMBConv
& conv
= wxConvLibc
) const
484 { return conv
.cWC2MB(m_pchData
); }
486 const wxWX2MBbuf
mbc_str() const { return mb_str(*wxConvCurrent
); }
488 const wxChar
* wc_str() const { return m_pchData
; }
490 // for compatibility with !wxUSE_UNICODE version
491 const wxChar
* wc_str(wxMBConv
& WXUNUSED(conv
)) const { return m_pchData
; }
494 const wxCharBuffer
fn_str() const { return mb_str(wxConvFile
); }
496 const wxChar
* fn_str() const { return m_pchData
; }
497 #endif // wxMBFILES/!wxMBFILES
499 const wxChar
* mb_str() const { return m_pchData
; }
501 // for compatibility with wxUSE_UNICODE version
502 const wxChar
* mb_str(wxMBConv
& WXUNUSED(conv
)) const { return m_pchData
; }
504 const wxWX2MBbuf
mbc_str() const { return mb_str(); }
507 const wxWCharBuffer
wc_str(wxMBConv
& conv
) const
508 { return conv
.cMB2WC(m_pchData
); }
509 #endif // wxUSE_WCHAR_T
511 const wxChar
* fn_str() const { return m_pchData
; }
512 #endif // Unicode/ANSI
514 // overloaded assignment
515 // from another wxString
516 wxString
& operator=(const wxString
& stringSrc
);
518 wxString
& operator=(wxChar ch
);
520 wxString
& operator=(const wxChar
*psz
);
522 // from wxWCharBuffer
523 wxString
& operator=(const wxWCharBuffer
& psz
)
524 { (void) operator=((const wchar_t *)psz
); return *this; }
526 // from another kind of C string
527 wxString
& operator=(const unsigned char* psz
);
529 // from a wide string
530 wxString
& operator=(const wchar_t *pwz
);
533 wxString
& operator=(const wxCharBuffer
& psz
)
534 { (void) operator=((const char *)psz
); return *this; }
535 #endif // Unicode/ANSI
537 // string concatenation
538 // in place concatenation
540 Concatenate and return the result. Note that the left to right
541 associativity of << allows to write things like "str << str1 << str2
542 << ..." (unlike with +=)
545 wxString
& operator<<(const wxString
& s
)
547 wxASSERT_MSG( s
.GetStringData()->IsValid(),
548 _T("did you forget to call UngetWriteBuf()?") );
550 ConcatSelf(s
.Len(), s
);
553 // string += C string
554 wxString
& operator<<(const wxChar
*psz
)
555 { ConcatSelf(wxStrlen(psz
), psz
); return *this; }
557 wxString
& operator<<(wxChar ch
) { ConcatSelf(1, &ch
); return *this; }
560 void operator+=(const wxString
& s
) { (void)operator<<(s
); }
561 // string += C string
562 void operator+=(const wxChar
*psz
) { (void)operator<<(psz
); }
564 void operator+=(wxChar ch
) { (void)operator<<(ch
); }
566 // string += buffer (i.e. from wxGetString)
568 wxString
& operator<<(const wxWCharBuffer
& s
)
569 { (void)operator<<((const wchar_t *)s
); return *this; }
570 void operator+=(const wxWCharBuffer
& s
)
571 { (void)operator<<((const wchar_t *)s
); }
572 #else // !wxUSE_UNICODE
573 wxString
& operator<<(const wxCharBuffer
& s
)
574 { (void)operator<<((const char *)s
); return *this; }
575 void operator+=(const wxCharBuffer
& s
)
576 { (void)operator<<((const char *)s
); }
577 #endif // wxUSE_UNICODE/!wxUSE_UNICODE
579 // string += C string
580 wxString
& Append(const wxString
& s
)
582 // test for IsEmpty() to share the string if possible
586 ConcatSelf(s
.Length(), s
.c_str());
589 wxString
& Append(const wxChar
* psz
)
590 { ConcatSelf(wxStrlen(psz
), psz
); return *this; }
591 // append count copies of given character
592 wxString
& Append(wxChar ch
, size_t count
= 1u)
593 { wxString
str(ch
, count
); return *this << str
; }
594 wxString
& Append(const wxChar
* psz
, size_t nLen
)
595 { ConcatSelf(nLen
, psz
); return *this; }
597 // prepend a string, return the string itself
598 wxString
& Prepend(const wxString
& str
)
599 { *this = str
+ *this; return *this; }
601 // non-destructive concatenation
603 friend wxString WXDLLEXPORT
operator+(const wxString
& string1
, const wxString
& string2
);
605 friend wxString WXDLLEXPORT
operator+(const wxString
& string
, wxChar ch
);
607 friend wxString WXDLLEXPORT
operator+(wxChar ch
, const wxString
& string
);
609 friend wxString WXDLLEXPORT
operator+(const wxString
& string
, const wxChar
*psz
);
611 friend wxString WXDLLEXPORT
operator+(const wxChar
*psz
, const wxString
& string
);
613 // stream-like functions
614 // insert an int into string
615 wxString
& operator<<(int i
)
616 { return (*this) << Format(_T("%d"), i
); }
617 // insert an unsigned int into string
618 wxString
& operator<<(unsigned int ui
)
619 { return (*this) << Format(_T("%u"), ui
); }
620 // insert a long into string
621 wxString
& operator<<(long l
)
622 { return (*this) << Format(_T("%ld"), l
); }
623 // insert an unsigned long into string
624 wxString
& operator<<(unsigned long ul
)
625 { return (*this) << Format(_T("%lu"), ul
); }
626 // insert a float into string
627 wxString
& operator<<(float f
)
628 { return (*this) << Format(_T("%f"), f
); }
629 // insert a double into string
630 wxString
& operator<<(double d
)
631 { return (*this) << Format(_T("%g"), d
); }
634 // case-sensitive comparison (returns a value < 0, = 0 or > 0)
635 int Cmp(const wxChar
*psz
) const { return wxStrcmp(c_str(), psz
); }
636 // same as Cmp() but not case-sensitive
637 int CmpNoCase(const wxChar
*psz
) const { return wxStricmp(c_str(), psz
); }
638 // test for the string equality, either considering case or not
639 // (if compareWithCase then the case matters)
640 bool IsSameAs(const wxChar
*psz
, bool compareWithCase
= TRUE
) const
641 { return (compareWithCase
? Cmp(psz
) : CmpNoCase(psz
)) == 0; }
642 // comparison with a signle character: returns TRUE if equal
643 bool IsSameAs(wxChar c
, bool compareWithCase
= TRUE
) const
645 return (Len() == 1) && (compareWithCase
? GetChar(0u) == c
646 : wxToupper(GetChar(0u)) == wxToupper(c
));
649 // simple sub-string extraction
650 // return substring starting at nFirst of length nCount (or till the end
651 // if nCount = default value)
652 wxString
Mid(size_t nFirst
, size_t nCount
= wxSTRING_MAXLEN
) const;
654 // operator version of Mid()
655 wxString
operator()(size_t start
, size_t len
) const
656 { return Mid(start
, len
); }
658 // check that the string starts with prefix and return the rest of the
659 // string in the provided pointer if it is not NULL, otherwise return
661 bool StartsWith(const wxChar
*prefix
, wxString
*rest
= NULL
) const;
663 // get first nCount characters
664 wxString
Left(size_t nCount
) const;
665 // get last nCount characters
666 wxString
Right(size_t nCount
) const;
667 // get all characters before the first occurance of ch
668 // (returns the whole string if ch not found)
669 wxString
BeforeFirst(wxChar ch
) const;
670 // get all characters before the last occurence of ch
671 // (returns empty string if ch not found)
672 wxString
BeforeLast(wxChar ch
) const;
673 // get all characters after the first occurence of ch
674 // (returns empty string if ch not found)
675 wxString
AfterFirst(wxChar ch
) const;
676 // get all characters after the last occurence of ch
677 // (returns the whole string if ch not found)
678 wxString
AfterLast(wxChar ch
) const;
680 // for compatibility only, use more explicitly named functions above
681 wxString
Before(wxChar ch
) const { return BeforeLast(ch
); }
682 wxString
After(wxChar ch
) const { return AfterFirst(ch
); }
685 // convert to upper case in place, return the string itself
686 wxString
& MakeUpper();
687 // convert to upper case, return the copy of the string
688 // Here's something to remember: BC++ doesn't like returns in inlines.
689 wxString
Upper() const ;
690 // convert to lower case in place, return the string itself
691 wxString
& MakeLower();
692 // convert to lower case, return the copy of the string
693 wxString
Lower() const ;
695 // trimming/padding whitespace (either side) and truncating
696 // remove spaces from left or from right (default) side
697 wxString
& Trim(bool bFromRight
= TRUE
);
698 // add nCount copies chPad in the beginning or at the end (default)
699 wxString
& Pad(size_t nCount
, wxChar chPad
= wxT(' '), bool bFromRight
= TRUE
);
701 // searching and replacing
702 // searching (return starting index, or -1 if not found)
703 int Find(wxChar ch
, bool bFromEnd
= FALSE
) const; // like strchr/strrchr
704 // searching (return starting index, or -1 if not found)
705 int Find(const wxChar
*pszSub
) const; // like strstr
706 // replace first (or all of bReplaceAll) occurences of substring with
707 // another string, returns the number of replacements made
708 size_t Replace(const wxChar
*szOld
,
710 bool bReplaceAll
= TRUE
);
712 // check if the string contents matches a mask containing '*' and '?'
713 bool Matches(const wxChar
*szMask
) const;
715 // conversion to numbers: all functions return TRUE only if the whole
716 // string is a number and put the value of this number into the pointer
717 // provided, the base is the numeric base in which the conversion should be
718 // done and must be comprised between 2 and 36 or be 0 in which case the
719 // standard C rules apply (leading '0' => octal, "0x" => hex)
720 // convert to a signed integer
721 bool ToLong(long *val
, int base
= 10) const;
722 // convert to an unsigned integer
723 bool ToULong(unsigned long *val
, int base
= 10) const;
724 // convert to a double
725 bool ToDouble(double *val
) const;
727 // formated input/output
728 // as sprintf(), returns the number of characters written or < 0 on error
729 // (take 'this' into account in attribute parameter count)
730 int Printf(const wxChar
*pszFormat
, ...) ATTRIBUTE_PRINTF_2
;
731 // as vprintf(), returns the number of characters written or < 0 on error
732 int PrintfV(const wxChar
* pszFormat
, va_list argptr
);
734 // returns the string containing the result of Printf() to it
735 static wxString
Format(const wxChar
*pszFormat
, ...) ATTRIBUTE_PRINTF_1
;
736 // the same as above, but takes a va_list
737 static wxString
FormatV(const wxChar
*pszFormat
, va_list argptr
);
739 // raw access to string memory
740 // ensure that string has space for at least nLen characters
741 // only works if the data of this string is not shared
742 bool Alloc(size_t nLen
);
743 // minimize the string's memory
744 // only works if the data of this string is not shared
746 // get writable buffer of at least nLen bytes. Unget() *must* be called
747 // a.s.a.p. to put string back in a reasonable state!
748 wxChar
*GetWriteBuf(size_t nLen
);
749 // call this immediately after GetWriteBuf() has been used
750 void UngetWriteBuf();
751 void UngetWriteBuf(size_t nLen
);
753 // wxWindows version 1 compatibility functions
756 wxString
SubString(size_t from
, size_t to
) const
757 { return Mid(from
, (to
- from
+ 1)); }
758 // values for second parameter of CompareTo function
759 enum caseCompare
{exact
, ignoreCase
};
760 // values for first parameter of Strip function
761 enum stripType
{leading
= 0x1, trailing
= 0x2, both
= 0x3};
764 // (take 'this' into account in attribute parameter count)
765 int sprintf(const wxChar
*pszFormat
, ...) ATTRIBUTE_PRINTF_2
;
768 inline int CompareTo(const wxChar
* psz
, caseCompare cmp
= exact
) const
769 { return cmp
== exact
? Cmp(psz
) : CmpNoCase(psz
); }
772 size_t Length() const { return Len(); }
773 // Count the number of characters
774 int Freq(wxChar ch
) const;
776 void LowerCase() { MakeLower(); }
778 void UpperCase() { MakeUpper(); }
779 // use Trim except that it doesn't change this string
780 wxString
Strip(stripType w
= trailing
) const;
782 // use Find (more general variants not yet supported)
783 size_t Index(const wxChar
* psz
) const { return Find(psz
); }
784 size_t Index(wxChar ch
) const { return Find(ch
); }
786 wxString
& Remove(size_t pos
) { return Truncate(pos
); }
787 wxString
& RemoveLast(size_t n
= 1) { return Truncate(Len() - n
); }
789 wxString
& Remove(size_t nStart
, size_t nLen
) { return erase( nStart
, nLen
); }
792 int First( const wxChar ch
) const { return Find(ch
); }
793 int First( const wxChar
* psz
) const { return Find(psz
); }
794 int First( const wxString
&str
) const { return Find(str
); }
795 int Last( const wxChar ch
) const { return Find(ch
, TRUE
); }
796 bool Contains(const wxString
& str
) const { return Find(str
) != -1; }
799 bool IsNull() const { return IsEmpty(); }
801 #ifdef wxSTD_STRING_COMPATIBILITY
802 // std::string compatibility functions
805 typedef wxChar value_type
;
806 typedef const value_type
*const_iterator
;
808 // an 'invalid' value for string index
809 static const size_t npos
;
812 // take nLen chars starting at nPos
813 wxString(const wxString
& str
, size_t nPos
, size_t nLen
)
816 wxASSERT_MSG( str
.GetStringData()->IsValid(),
817 _T("did you forget to call UngetWriteBuf()?") );
819 InitWith(str
.c_str(), nPos
, nLen
== npos
? 0 : nLen
);
821 // take all characters from pStart to pEnd
822 wxString(const void *pStart
, const void *pEnd
);
824 // lib.string.capacity
825 // return the length of the string
826 size_t size() const { return Len(); }
827 // return the length of the string
828 size_t length() const { return Len(); }
829 // return the maximum size of the string
830 size_t max_size() const { return wxSTRING_MAXLEN
; }
831 // resize the string, filling the space with c if c != 0
832 void resize(size_t nSize
, wxChar ch
= wxT('\0'));
833 // delete the contents of the string
834 void clear() { Empty(); }
835 // returns true if the string is empty
836 bool empty() const { return IsEmpty(); }
837 // inform string about planned change in size
838 void reserve(size_t sz
) { Alloc(sz
); }
841 // return the character at position n
842 wxChar
at(size_t n
) const { return GetChar(n
); }
843 // returns the writable character at position n
844 wxChar
& at(size_t n
) { return GetWritableChar(n
); }
846 // first valid index position
847 const_iterator
begin() const { return wx_str(); }
848 // position one after the last valid one
849 const_iterator
end() const { return wx_str() + length(); }
851 // lib.string.modifiers
853 wxString
& append(const wxString
& str
)
854 { *this += str
; return *this; }
855 // append elements str[pos], ..., str[pos+n]
856 wxString
& append(const wxString
& str
, size_t pos
, size_t n
)
857 { ConcatSelf(n
, str
.c_str() + pos
); return *this; }
858 // append first n (or all if n == npos) characters of sz
859 wxString
& append(const wxChar
*sz
, size_t n
= npos
)
860 { ConcatSelf(n
== npos
? wxStrlen(sz
) : n
, sz
); return *this; }
862 // append n copies of ch
863 wxString
& append(size_t n
, wxChar ch
) { return Pad(n
, ch
); }
865 // same as `this_string = str'
866 wxString
& assign(const wxString
& str
)
867 { return *this = str
; }
868 // same as ` = str[pos..pos + n]
869 wxString
& assign(const wxString
& str
, size_t pos
, size_t n
)
870 { Empty(); return Append(str
.c_str() + pos
, n
); }
871 // same as `= first n (or all if n == npos) characters of sz'
872 wxString
& assign(const wxChar
*sz
, size_t n
= npos
)
873 { Empty(); return Append(sz
, n
== npos
? wxStrlen(sz
) : n
); }
874 // same as `= n copies of ch'
875 wxString
& assign(size_t n
, wxChar ch
)
876 { Empty(); return Append(ch
, n
); }
878 // insert another string
879 wxString
& insert(size_t nPos
, const wxString
& str
);
880 // insert n chars of str starting at nStart (in str)
881 wxString
& insert(size_t nPos
, const wxString
& str
, size_t nStart
, size_t n
)
882 { return insert(nPos
, wxString((const wxChar
*)str
+ nStart
, n
)); }
884 // insert first n (or all if n == npos) characters of sz
885 wxString
& insert(size_t nPos
, const wxChar
*sz
, size_t n
= npos
)
886 { return insert(nPos
, wxString(sz
, n
)); }
887 // insert n copies of ch
888 wxString
& insert(size_t nPos
, size_t n
, wxChar ch
)
889 { return insert(nPos
, wxString(ch
, n
)); }
891 // delete characters from nStart to nStart + nLen
892 wxString
& erase(size_t nStart
= 0, size_t nLen
= npos
);
894 // replaces the substring of length nLen starting at nStart
895 wxString
& replace(size_t nStart
, size_t nLen
, const wxChar
* sz
);
896 // replaces the substring with nCount copies of ch
897 wxString
& replace(size_t nStart
, size_t nLen
, size_t nCount
, wxChar ch
);
898 // replaces a substring with another substring
899 wxString
& replace(size_t nStart
, size_t nLen
,
900 const wxString
& str
, size_t nStart2
, size_t nLen2
);
901 // replaces the substring with first nCount chars of sz
902 wxString
& replace(size_t nStart
, size_t nLen
,
903 const wxChar
* sz
, size_t nCount
);
906 void swap(wxString
& str
);
908 // All find() functions take the nStart argument which specifies the
909 // position to start the search on, the default value is 0. All functions
910 // return npos if there were no match.
913 size_t find(const wxString
& str
, size_t nStart
= 0) const;
915 // VC++ 1.5 can't cope with this syntax.
916 #if !defined(__VISUALC__) || defined(__WIN32__)
917 // find first n characters of sz
918 size_t find(const wxChar
* sz
, size_t nStart
= 0, size_t n
= npos
) const;
921 // Gives a duplicate symbol (presumably a case-insensitivity problem)
922 #if !defined(__BORLANDC__)
923 // find the first occurence of character ch after nStart
924 size_t find(wxChar ch
, size_t nStart
= 0) const;
926 // rfind() family is exactly like find() but works right to left
928 // as find, but from the end
929 size_t rfind(const wxString
& str
, size_t nStart
= npos
) const;
931 // VC++ 1.5 can't cope with this syntax.
932 #if !defined(__VISUALC__) || defined(__WIN32__)
933 // as find, but from the end
934 size_t rfind(const wxChar
* sz
, size_t nStart
= npos
,
935 size_t n
= npos
) const;
936 // as find, but from the end
937 size_t rfind(wxChar ch
, size_t nStart
= npos
) const;
940 // find first/last occurence of any character in the set
942 // as strpbrk() but starts at nStart, returns npos if not found
943 size_t find_first_of(const wxString
& str
, size_t nStart
= 0) const
944 { return find_first_of(str
.c_str(), nStart
); }
946 size_t find_first_of(const wxChar
* sz
, size_t nStart
= 0) const;
947 // same as find(char, size_t)
948 size_t find_first_of(wxChar c
, size_t nStart
= 0) const
949 { return find(c
, nStart
); }
950 // find the last (starting from nStart) char from str in this string
951 size_t find_last_of (const wxString
& str
, size_t nStart
= npos
) const
952 { return find_last_of(str
.c_str(), nStart
); }
954 size_t find_last_of (const wxChar
* sz
, size_t nStart
= npos
) const;
956 size_t find_last_of(wxChar c
, size_t nStart
= npos
) const
957 { return rfind(c
, nStart
); }
959 // find first/last occurence of any character not in the set
961 // as strspn() (starting from nStart), returns npos on failure
962 size_t find_first_not_of(const wxString
& str
, size_t nStart
= 0) const
963 { return find_first_not_of(str
.c_str(), nStart
); }
965 size_t find_first_not_of(const wxChar
* sz
, size_t nStart
= 0) const;
967 size_t find_first_not_of(wxChar ch
, size_t nStart
= 0) const;
969 size_t find_last_not_of(const wxString
& str
, size_t nStart
= npos
) const
970 { return find_first_not_of(str
.c_str(), nStart
); }
972 size_t find_last_not_of(const wxChar
* sz
, size_t nStart
= npos
) const;
974 size_t find_last_not_of(wxChar ch
, size_t nStart
= npos
) const;
976 // All compare functions return -1, 0 or 1 if the [sub]string is less,
977 // equal or greater than the compare() argument.
979 // just like strcmp()
980 int compare(const wxString
& str
) const { return Cmp(str
); }
981 // comparison with a substring
982 int compare(size_t nStart
, size_t nLen
, const wxString
& str
) const
983 { return Mid(nStart
, nLen
).Cmp(str
); }
984 // comparison of 2 substrings
985 int compare(size_t nStart
, size_t nLen
,
986 const wxString
& str
, size_t nStart2
, size_t nLen2
) const
987 { return Mid(nStart
, nLen
).Cmp(str
.Mid(nStart2
, nLen2
)); }
988 // just like strcmp()
989 int compare(const wxChar
* sz
) const { return Cmp(sz
); }
990 // substring comparison with first nCount characters of sz
991 int compare(size_t nStart
, size_t nLen
,
992 const wxChar
* sz
, size_t nCount
= npos
) const
993 { return Mid(nStart
, nLen
).Cmp(wxString(sz
, nCount
)); }
995 // substring extraction
996 wxString
substr(size_t nStart
= 0, size_t nLen
= npos
) const
997 { return Mid(nStart
, nLen
); }
998 #endif // wxSTD_STRING_COMPATIBILITY
1001 // ----------------------------------------------------------------------------
1002 // The string array uses it's knowledge of internal structure of the wxString
1003 // class to optimize string storage. Normally, we would store pointers to
1004 // string, but as wxString is, in fact, itself a pointer (sizeof(wxString) is
1005 // sizeof(char *)) we store these pointers instead. The cast to "wxString *" is
1006 // really all we need to turn such pointer into a string!
1008 // Of course, it can be called a dirty hack, but we use twice less memory and
1009 // this approach is also more speed efficient, so it's probably worth it.
1011 // Usage notes: when a string is added/inserted, a new copy of it is created,
1012 // so the original string may be safely deleted. When a string is retrieved
1013 // from the array (operator[] or Item() method), a reference is returned.
1014 // ----------------------------------------------------------------------------
1016 class WXDLLEXPORT wxArrayString
1019 // type of function used by wxArrayString::Sort()
1020 typedef int (*CompareFunction
)(const wxString
& first
,
1021 const wxString
& second
);
1023 // constructors and destructor
1026 : m_nSize(0), m_nCount(0), m_pItems(NULL
), m_autoSort(FALSE
)
1028 // if autoSort is TRUE, the array is always sorted (in alphabetical order)
1030 // NB: the reason for using int and not bool is that like this we can avoid
1031 // using this ctor for implicit conversions from "const char *" (which
1032 // we'd like to be implicitly converted to wxString instead!)
1034 // of course, using explicit would be even better - if all compilers
1036 wxArrayString(int autoSort
)
1037 : m_nSize(0), m_nCount(0), m_pItems(NULL
), m_autoSort(FALSE
)
1038 { Init(autoSort
!= 0); }
1040 wxArrayString(const wxArrayString
& array
);
1041 // assignment operator
1042 wxArrayString
& operator=(const wxArrayString
& src
);
1043 // not virtual, this class should not be derived from
1046 // memory management
1047 // empties the list, but doesn't release memory
1049 // empties the list and releases memory
1051 // preallocates memory for given number of items
1052 void Alloc(size_t nCount
);
1053 // minimzes the memory usage (by freeing all extra memory)
1057 // number of elements in the array
1058 size_t GetCount() const { return m_nCount
; }
1060 bool IsEmpty() const { return m_nCount
== 0; }
1061 // number of elements in the array (GetCount is preferred API)
1062 size_t Count() const { return m_nCount
; }
1064 // items access (range checking is done in debug version)
1065 // get item at position uiIndex
1066 wxString
& Item(size_t nIndex
) const
1068 wxASSERT_MSG( nIndex
< m_nCount
,
1069 _T("wxArrayString: index out of bounds") );
1071 return *(wxString
*)&(m_pItems
[nIndex
]);
1075 wxString
& operator[](size_t nIndex
) const { return Item(nIndex
); }
1077 wxString
& Last() const
1079 wxASSERT_MSG( !IsEmpty(),
1080 _T("wxArrayString: index out of bounds") );
1081 return Item(Count() - 1);
1084 // return a wxString[], useful for the controls which
1085 // take one in their ctor. You must delete[] it yourself
1086 // once you are done with it. Will return NULL if the
1087 // ArrayString was empty.
1088 wxString
* GetStringArray() const;
1091 // Search the element in the array, starting from the beginning if
1092 // bFromEnd is FALSE or from end otherwise. If bCase, comparison is case
1093 // sensitive (default). Returns index of the first item matched or
1095 int Index (const wxChar
*sz
, bool bCase
= TRUE
, bool bFromEnd
= FALSE
) const;
1096 // add new element at the end (if the array is not sorted), return its
1098 size_t Add(const wxString
& str
, size_t nInsert
= 1);
1099 // add new element at given position
1100 void Insert(const wxString
& str
, size_t uiIndex
, size_t nInsert
= 1);
1101 // expand the array to have count elements
1102 void SetCount(size_t count
);
1103 // remove first item matching this value
1104 void Remove(const wxChar
*sz
);
1105 // remove item by index
1106 void Remove(size_t nIndex
, size_t nRemove
= 1);
1107 void RemoveAt(size_t nIndex
, size_t nRemove
= 1) { Remove(nIndex
, nRemove
); }
1110 // sort array elements in alphabetical order (or reversed alphabetical
1111 // order if reverseOrder parameter is TRUE)
1112 void Sort(bool reverseOrder
= FALSE
);
1113 // sort array elements using specified comparaison function
1114 void Sort(CompareFunction compareFunction
);
1117 // compare two arrays case sensitively
1118 bool operator==(const wxArrayString
& a
) const;
1119 // compare two arrays case sensitively
1120 bool operator!=(const wxArrayString
& a
) const { return !(*this == a
); }
1123 void Init(bool autoSort
); // common part of all ctors
1124 void Copy(const wxArrayString
& src
); // copies the contents of another array
1127 void Grow(size_t nIncrement
= 0); // makes array bigger if needed
1128 void Free(); // free all the strings stored
1130 void DoSort(); // common part of all Sort() variants
1132 size_t m_nSize
, // current size of the array
1133 m_nCount
; // current number of elements
1135 wxChar
**m_pItems
; // pointer to data
1137 bool m_autoSort
; // if TRUE, keep the array always sorted
1140 class WXDLLEXPORT wxSortedArrayString
: public wxArrayString
1143 wxSortedArrayString() : wxArrayString(TRUE
)
1145 wxSortedArrayString(const wxArrayString
& array
) : wxArrayString(TRUE
)
1149 // ----------------------------------------------------------------------------
1150 // wxStringBuffer: a tiny class allowing to get a writable pointer into string
1151 // ----------------------------------------------------------------------------
1153 class WXDLLEXPORT wxStringBuffer
1156 wxStringBuffer(wxString
& str
, size_t lenWanted
= 1024)
1157 : m_str(str
), m_buf(NULL
)
1158 { m_buf
= m_str
.GetWriteBuf(lenWanted
); }
1160 ~wxStringBuffer() { m_str
.UngetWriteBuf(); }
1162 operator wxChar
*() const { return m_buf
; }
1168 DECLARE_NO_COPY_CLASS(wxStringBuffer
)
1171 // ---------------------------------------------------------------------------
1172 // wxString comparison functions: operator versions are always case sensitive
1173 // ---------------------------------------------------------------------------
1175 inline bool operator==(const wxString
& s1
, const wxString
& s2
)
1176 { return (s1
.Len() == s2
.Len()) && (s1
.Cmp(s2
) == 0); }
1177 inline bool operator==(const wxString
& s1
, const wxChar
* s2
)
1178 { return s1
.Cmp(s2
) == 0; }
1179 inline bool operator==(const wxChar
* s1
, const wxString
& s2
)
1180 { return s2
.Cmp(s1
) == 0; }
1181 inline bool operator!=(const wxString
& s1
, const wxString
& s2
)
1182 { return (s1
.Len() != s2
.Len()) || (s1
.Cmp(s2
) != 0); }
1183 inline bool operator!=(const wxString
& s1
, const wxChar
* s2
)
1184 { return s1
.Cmp(s2
) != 0; }
1185 inline bool operator!=(const wxChar
* s1
, const wxString
& s2
)
1186 { return s2
.Cmp(s1
) != 0; }
1187 inline bool operator< (const wxString
& s1
, const wxString
& s2
)
1188 { return s1
.Cmp(s2
) < 0; }
1189 inline bool operator< (const wxString
& s1
, const wxChar
* s2
)
1190 { return s1
.Cmp(s2
) < 0; }
1191 inline bool operator< (const wxChar
* s1
, const wxString
& s2
)
1192 { return s2
.Cmp(s1
) > 0; }
1193 inline bool operator> (const wxString
& s1
, const wxString
& s2
)
1194 { return s1
.Cmp(s2
) > 0; }
1195 inline bool operator> (const wxString
& s1
, const wxChar
* s2
)
1196 { return s1
.Cmp(s2
) > 0; }
1197 inline bool operator> (const wxChar
* s1
, const wxString
& s2
)
1198 { return s2
.Cmp(s1
) < 0; }
1199 inline bool operator<=(const wxString
& s1
, const wxString
& s2
)
1200 { return s1
.Cmp(s2
) <= 0; }
1201 inline bool operator<=(const wxString
& s1
, const wxChar
* s2
)
1202 { return s1
.Cmp(s2
) <= 0; }
1203 inline bool operator<=(const wxChar
* s1
, const wxString
& s2
)
1204 { return s2
.Cmp(s1
) >= 0; }
1205 inline bool operator>=(const wxString
& s1
, const wxString
& s2
)
1206 { return s1
.Cmp(s2
) >= 0; }
1207 inline bool operator>=(const wxString
& s1
, const wxChar
* s2
)
1208 { return s1
.Cmp(s2
) >= 0; }
1209 inline bool operator>=(const wxChar
* s1
, const wxString
& s2
)
1210 { return s2
.Cmp(s1
) <= 0; }
1212 // comparison with char
1213 inline bool operator==(wxChar c
, const wxString
& s
) { return s
.IsSameAs(c
); }
1214 inline bool operator==(const wxString
& s
, wxChar c
) { return s
.IsSameAs(c
); }
1215 inline bool operator!=(wxChar c
, const wxString
& s
) { return !s
.IsSameAs(c
); }
1216 inline bool operator!=(const wxString
& s
, wxChar c
) { return !s
.IsSameAs(c
); }
1219 inline bool operator==(const wxString
& s1
, const wxWCharBuffer
& s2
)
1220 { return (s1
.Cmp((const wchar_t *)s2
) == 0); }
1221 inline bool operator==(const wxWCharBuffer
& s1
, const wxString
& s2
)
1222 { return (s2
.Cmp((const wchar_t *)s1
) == 0); }
1223 inline bool operator!=(const wxString
& s1
, const wxWCharBuffer
& s2
)
1224 { return (s1
.Cmp((const wchar_t *)s2
) != 0); }
1225 inline bool operator!=(const wxWCharBuffer
& s1
, const wxString
& s2
)
1226 { return (s2
.Cmp((const wchar_t *)s1
) != 0); }
1227 #else // !wxUSE_UNICODE
1228 inline bool operator==(const wxString
& s1
, const wxCharBuffer
& s2
)
1229 { return (s1
.Cmp((const char *)s2
) == 0); }
1230 inline bool operator==(const wxCharBuffer
& s1
, const wxString
& s2
)
1231 { return (s2
.Cmp((const char *)s1
) == 0); }
1232 inline bool operator!=(const wxString
& s1
, const wxCharBuffer
& s2
)
1233 { return (s1
.Cmp((const char *)s2
) != 0); }
1234 inline bool operator!=(const wxCharBuffer
& s1
, const wxString
& s2
)
1235 { return (s2
.Cmp((const char *)s1
) != 0); }
1236 #endif // wxUSE_UNICODE/!wxUSE_UNICODE
1238 wxString WXDLLEXPORT
operator+(const wxString
& string1
, const wxString
& string2
);
1239 wxString WXDLLEXPORT
operator+(const wxString
& string
, wxChar ch
);
1240 wxString WXDLLEXPORT
operator+(wxChar ch
, const wxString
& string
);
1241 wxString WXDLLEXPORT
operator+(const wxString
& string
, const wxChar
*psz
);
1242 wxString WXDLLEXPORT
operator+(const wxChar
*psz
, const wxString
& string
);
1244 inline wxString
operator+(const wxString
& string
, const wxWCharBuffer
& buf
)
1245 { return string
+ (const wchar_t *)buf
; }
1246 inline wxString
operator+(const wxWCharBuffer
& buf
, const wxString
& string
)
1247 { return (const wchar_t *)buf
+ string
; }
1248 #else // !wxUSE_UNICODE
1249 inline wxString
operator+(const wxString
& string
, const wxCharBuffer
& buf
)
1250 { return string
+ (const char *)buf
; }
1251 inline wxString
operator+(const wxCharBuffer
& buf
, const wxString
& string
)
1252 { return (const char *)buf
+ string
; }
1253 #endif // wxUSE_UNICODE/!wxUSE_UNICODE
1255 // ---------------------------------------------------------------------------
1256 // Implementation only from here until the end of file
1257 // ---------------------------------------------------------------------------
1259 // don't pollute the library user's name space
1260 #undef wxASSERT_VALID_INDEX
1262 #if defined(wxSTD_STRING_COMPATIBILITY) && wxUSE_STD_IOSTREAM
1264 #include "wx/ioswrap.h"
1266 WXDLLEXPORT wxSTD istream
& operator>>(wxSTD istream
&, wxString
&);
1267 WXDLLEXPORT wxSTD ostream
& operator<<(wxSTD ostream
&, const wxString
&);
1269 #endif // wxSTD_STRING_COMPATIBILITY
1271 #endif // _WX_WXSTRINGH__