]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/string.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxString class
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "string.h"
19 /* Dependencies (should be included before this header):
31 #include "wx/defs.h" // Robert Roebling
32 #include "wx/object.h"
37 /** @name wxString library
38 @memo Efficient wxString class [more or less] compatible with MFC CString,
39 wxWindows wxString and std::string and some handy functions
40 missing from string.h.
44 // ---------------------------------------------------------------------------
46 // ---------------------------------------------------------------------------
49 @memo You can switch off wxString/std::string compatibility if desired
51 /// compile the std::string compatibility functions
52 #define STD_STRING_COMPATIBILITY
54 /// define to derive wxString from wxObject
55 #undef WXSTRING_IS_WXOBJECT
57 /// maximum possible length for a string means "take all string" everywhere
58 // (as sizeof(StringData) is unknown here we substract 100)
59 #define STRING_MAXLEN (UINT_MAX - 100)
62 #define WXSTRINGCAST (char *)(const char *)
64 // NB: works only inside wxString class
65 #define ASSERT_VALID_INDEX(i) wxASSERT( (unsigned)(i) < Len() )
67 // ---------------------------------------------------------------------------
68 /** @name Global functions complementing standard C string library
69 @memo replacements for strlen() and portable strcasecmp()
71 // ---------------------------------------------------------------------------
73 /// checks whether the passed in pointer is NULL and if the string is empty
74 inline bool WXDLLEXPORT
IsEmpty(const char *p
) { return !p
|| !*p
; }
76 /// safe version of strlen() (returns 0 if passed NULL pointer)
77 inline size_t WXDLLEXPORT
Strlen(const char *psz
)
78 { return psz
? strlen(psz
) : 0; }
80 /// portable strcasecmp/_stricmp
81 int WXDLLEXPORT
Stricmp(const char *, const char *);
83 // ---------------------------------------------------------------------------
84 // string data prepended with some housekeeping info (used by String class),
85 // is never used directly (but had to be put here to allow inlining)
86 // ---------------------------------------------------------------------------
87 struct WXDLLEXPORT wxStringData
89 int nRefs
; // reference count
90 uint nDataLength
, // actual string length
91 nAllocLength
; // allocated memory size
93 // mimics declaration 'char data[nAllocLength]'
94 char* data() const { return (char*)(this + 1); }
96 // empty string has a special ref count so it's never deleted
97 bool IsEmpty() const { return nRefs
== -1; }
98 bool IsShared() const { return nRefs
> 1; }
101 void Lock() { if ( !IsEmpty() ) nRefs
++; }
102 void Unlock() { if ( !IsEmpty() && --nRefs
== 0) delete (char *)this; }
104 // if we had taken control over string memory (GetWriteBuf), it's
105 // intentionally put in invalid state
106 void Validate(bool b
) { nRefs
= b
? 1 : 0; }
107 bool IsValid() const { return nRefs
!= 0; }
110 extern const char *g_szNul
; // global pointer to empty string
112 // ---------------------------------------------------------------------------
114 This is (yet another one) String class for C++ programmers. It doesn't use
115 any of "advanced" C++ features (i.e. templates, exceptions, namespaces...)
116 thus you should be able to compile it with practicaly any C++ compiler.
117 This class uses copy-on-write technique, i.e. identical strings share the
118 same memory as long as neither of them is changed.
120 This class aims to be as compatible as possible with the new standard
121 std::string class, but adds some additional functions and should be
122 at least as efficient than the standard implementation.
124 Performance note: it's more efficient to write functions which take
125 "const String&" arguments than "const char *" if you assign the argument
128 It was compiled and tested under Win32, Linux (libc 5 & 6), Solaris 5.5.
131 - ressource support (string tables in ressources)
132 - more wide character (UNICODE) support
133 - regular expressions support
135 @memo A non-template portable wxString class implementing copy-on-write.
139 // ---------------------------------------------------------------------------
140 #ifdef WXSTRING_IS_WXOBJECT
141 class WXDLLEXPORT wxString
: public wxObject
143 DECLARE_DYNAMIC_CLASS(wxString
)
144 #else //WXSTRING_IS_WXOBJECT
145 class WXDLLEXPORT wxString
147 #endif //WXSTRING_IS_WXOBJECT
149 friend class wxArrayString
;
152 /** @name constructors & dtor */
154 /// ctor for an empty string
157 wxString(const wxString
& stringSrc
);
158 /// string containing nRepeat copies of ch
159 wxString(char ch
, size_t nRepeat
= 1);
160 /// ctor takes first nLength characters from C string
161 wxString(const char *psz
, size_t nLength
= STRING_MAXLEN
);
162 /// from C string (for compilers using unsigned char)
163 wxString(const unsigned char* psz
, size_t nLength
= STRING_MAXLEN
);
164 /// from wide (UNICODE) string
165 wxString(const wchar_t *pwz
);
166 /// dtor is not virtual, this class must not be inherited from!
170 /** @name generic attributes & operations */
172 /// as standard strlen()
173 size_t Len() const { return GetStringData()->nDataLength
; }
174 /// string contains any characters?
175 bool IsEmpty() const;
176 /// reinitialize string (and free data!)
178 /// Is an ascii value
179 bool IsAscii() const;
181 bool IsNumber() const;
186 /** @name data access (all indexes are 0 based) */
189 char GetChar(size_t n
) const
190 { ASSERT_VALID_INDEX( n
); return m_pchData
[n
]; }
191 /// read/write access
192 char& GetWritableChar(size_t n
)
193 { ASSERT_VALID_INDEX( n
); CopyBeforeWrite(); return m_pchData
[n
]; }
195 void SetChar(size_t n
, char ch
)
196 { ASSERT_VALID_INDEX( n
); CopyBeforeWrite(); m_pchData
[n
] = ch
; }
198 /// get last character
200 { wxASSERT( !IsEmpty() ); return m_pchData
[Len() - 1]; }
201 /// get writable last character
203 { wxASSERT( !IsEmpty() ); CopyBeforeWrite(); return m_pchData
[Len()-1]; }
205 /// operator version of GetChar
206 char operator[](size_t n
) const
207 { ASSERT_VALID_INDEX( n
); return m_pchData
[n
]; }
208 /// operator version of GetChar
209 char operator[](int n
) const
210 { ASSERT_VALID_INDEX( n
); return m_pchData
[n
]; }
211 /// operator version of GetWritableChar
212 char& operator[](size_t n
)
213 { ASSERT_VALID_INDEX( n
); CopyBeforeWrite(); return m_pchData
[n
]; }
215 /// implicit conversion to C string
216 operator const char*() const { return m_pchData
; }
217 /// explicit conversion to C string (use this with printf()!)
218 const char* c_str() const { return m_pchData
; }
220 const char* GetData() const { return m_pchData
; }
223 /** @name overloaded assignment */
226 wxString
& operator=(const wxString
& stringSrc
);
228 wxString
& operator=(char ch
);
230 wxString
& operator=(const char *psz
);
232 wxString
& operator=(const unsigned char* psz
);
234 wxString
& operator=(const wchar_t *pwz
);
237 /** @name string concatenation */
239 /** @name in place concatenation */
242 void operator+=(const wxString
& string
);
243 /// string += C string
244 void operator+=(const char *psz
);
246 void operator+=(char ch
);
248 /** @name concatenate and return the result
249 left to right associativity of << allows to write
250 things like "str << str1 << str2 << ..." */
253 wxString
& operator<<(const wxString
& string
);
255 wxString
& operator<<(char ch
);
257 wxString
& operator<<(const char *psz
);
260 /** @name return resulting string */
263 friend wxString
operator+(const wxString
& string1
, const wxString
& string2
);
265 friend wxString
operator+(const wxString
& string
, char ch
);
267 friend wxString
operator+(char ch
, const wxString
& string
);
269 friend wxString
operator+(const wxString
& string
, const char *psz
);
271 friend wxString
operator+(const char *psz
, const wxString
& string
);
275 /** @name string comparison */
278 case-sensitive comparaison
279 @return 0 if equal, +1 if greater or -1 if less
280 @see CmpNoCase, IsSameAs
282 int Cmp(const char *psz
) const { return strcmp(c_str(), psz
); }
284 case-insensitive comparaison, return code as for wxString::Cmp()
287 int CmpNoCase(const char *psz
) const { return Stricmp(c_str(), psz
); }
289 test for string equality, case-sensitive (default) or not
290 @param bCase is TRUE by default (case matters)
291 @return TRUE if strings are equal, FALSE otherwise
294 bool IsSameAs(const char *psz
, bool bCase
= TRUE
) const
295 { return !(bCase
? Cmp(psz
) : CmpNoCase(psz
)); }
298 /** @name other standard string operations */
300 /** @name simple sub-string extraction
304 return substring starting at nFirst of length
305 nCount (or till the end if nCount = default value)
307 wxString
Mid(size_t nFirst
, size_t nCount
= STRING_MAXLEN
) const;
308 /// get first nCount characters
309 wxString
Left(size_t nCount
) const;
310 /// get all characters before the first occurence of ch
311 /// (returns the whole string if ch not found)
312 wxString
Left(char ch
) const;
313 /// get all characters before the last occurence of ch
314 /// (returns empty string if ch not found)
315 wxString
Before(char ch
) const;
316 /// get all characters after the first occurence of ch
317 /// (returns empty string if ch not found)
318 wxString
After(char ch
) const;
319 /// get last nCount characters
320 wxString
Right(size_t nCount
) const;
321 /// get all characters after the last occurence of ch
322 /// (returns the whole string if ch not found)
323 wxString
Right(char ch
) const;
326 /** @name case conversion */
329 wxString
& MakeUpper();
331 wxString
& MakeLower();
334 /** @name trimming/padding whitespace (either side) and truncating */
336 /// remove spaces from left or from right (default) side
337 wxString
& Trim(bool bFromRight
= TRUE
);
338 /// add nCount copies chPad in the beginning or at the end (default)
339 wxString
& Pad(size_t nCount
, char chPad
= ' ', bool bFromRight
= TRUE
);
340 /// truncate string to given length
341 wxString
& Truncate(size_t uiLen
);
344 /** @name searching and replacing */
346 /// searching (return starting index, or -1 if not found)
347 int Find(char ch
, bool bFromEnd
= FALSE
) const; // like strchr/strrchr
348 /// searching (return starting index, or -1 if not found)
349 int Find(const char *pszSub
) const; // like strstr
351 replace first (or all) occurences of substring with another one
352 @param bReplaceAll: global replace (default) or only the first occurence
353 @return the number of replacements made
355 uint
Replace(const char *szOld
, const char *szNew
, bool bReplaceAll
= TRUE
);
358 /// check if the string contents matches a mask containing '*' and '?'
359 bool Matches(const char *szMask
) const;
362 /** @name formated input/output */
364 /// as sprintf(), returns the number of characters written or < 0 on error
365 int Printf(const char *pszFormat
, ...);
366 /// as vprintf(), returns the number of characters written or < 0 on error
367 int PrintfV(const char* pszFormat
, va_list argptr
);
370 /** @name raw access to string memory */
373 get writable buffer of at least nLen bytes.
374 Unget() *must* be called a.s.a.p. to put string back in a reasonable
377 char *GetWriteBuf(int nLen
);
378 /// call this immediately after GetWriteBuf() has been used
379 void UngetWriteBuf();
382 /** @name wxWindows compatibility functions */
384 /// values for second parameter of CompareTo function
385 enum caseCompare
{exact
, ignoreCase
};
386 /// values for first parameter of Strip function
387 enum stripType
{leading
= 0x1, trailing
= 0x2, both
= 0x3};
389 inline int sprintf(const char *pszFormat
, ...)
392 va_start(argptr
, pszFormat
);
393 int iLen
= PrintfV(pszFormat
, argptr
);
399 inline int CompareTo(const char* psz
, caseCompare cmp
= exact
) const
400 { return cmp
== exact
? Cmp(psz
) : CmpNoCase(psz
); }
402 /// same as Mid (substring extraction)
403 inline wxString
operator()(size_t start
, size_t len
) const { return Mid(start
, len
); }
406 inline wxString
& Append(const char* psz
) { return *this << psz
; }
407 inline wxString
& Append(char ch
, int count
= 1) { wxString
str(ch
, count
); (*this) += str
; return *this; }
410 wxString
& Prepend(const wxString
& str
) { *this = str
+ *this; return *this; }
412 size_t Length() const { return Len(); }
413 /// same as MakeLower
414 void LowerCase() { MakeLower(); }
415 /// same as MakeUpper
416 void UpperCase() { MakeUpper(); }
417 /// same as Trim except that it doesn't change this string
418 wxString
Strip(stripType w
= trailing
) const;
420 /// same as Find (more general variants not yet supported)
421 size_t Index(const char* psz
) const { return Find(psz
); }
422 size_t Index(char ch
) const { return Find(ch
); }
424 wxString
& Remove(size_t pos
) { return Truncate(pos
); }
425 wxString
& RemoveLast() { return Truncate(Len() - 1); }
429 wxString
& Remove(size_t nStart
, size_t nLen
) { return erase( nStart
, nLen
); }
431 size_t First( const char ch
) const { return find(ch
); }
432 size_t First( const char* psz
) const { return find(psz
); }
433 size_t First( const wxString
&str
) const { return find(str
); }
435 size_t Last( const char ch
) const { return rfind(ch
,0); }
436 size_t Last( const char* psz
) const { return rfind(psz
,0); }
437 size_t Last( const wxString
&str
) const { return rfind(str
,0); }
440 bool IsNull() const { return IsEmpty(); }
443 #ifdef STD_STRING_COMPATIBILITY
444 /** @name std::string compatibility functions */
446 /// an 'invalid' value for string index
447 static const size_t npos
;
450 /** @name constructors */
452 /// take nLen chars starting at nPos
453 wxString(const wxString
& s
, size_t nPos
, size_t nLen
= npos
);
454 /// take all characters from pStart to pEnd
455 wxString(const void *pStart
, const void *pEnd
);
457 /** @name lib.string.capacity */
459 /// return the length of the string
460 size_t size() const { return Len(); }
461 /// return the length of the string
462 size_t length() const { return Len(); }
463 /// return the maximum size of the string
464 size_t max_size() const { return STRING_MAXLEN
; }
465 /// resize the string, filling the space with c if c != 0
466 void resize(size_t nSize
, char ch
= '\0');
467 /// delete the contents of the string
468 void clear() { Empty(); }
469 /// returns true if the string is empty
470 bool empty() const { return IsEmpty(); }
472 /** @name lib.string.access */
474 /// return the character at position n
475 char at(size_t n
) const { return GetChar(n
); }
476 /// returns the writable character at position n
477 char& at(size_t n
) { return GetWritableChar(n
); }
479 /** @name lib.string.modifiers */
481 /** @name append something to the end of this one */
484 wxString
& append(const wxString
& str
)
485 { *this += str
; return *this; }
486 /// append elements str[pos], ..., str[pos+n]
487 wxString
& append(const wxString
& str
, size_t pos
, size_t n
)
488 { ConcatSelf(n
, str
.c_str() + pos
); return *this; }
489 /// append first n (or all if n == npos) characters of sz
490 wxString
& append(const char *sz
, size_t n
= npos
)
491 { ConcatSelf(n
== npos
? Strlen(sz
) : n
, sz
); return *this; }
493 /// append n copies of ch
494 wxString
& append(size_t n
, char ch
) { return Pad(n
, ch
); }
497 /** @name replaces the contents of this string with another one */
499 /// same as `this_string = str'
500 wxString
& assign(const wxString
& str
) { return (*this) = str
; }
501 /// same as ` = str[pos..pos + n]
502 wxString
& assign(const wxString
& str
, size_t pos
, size_t n
)
503 { return *this = wxString((const char *)str
+ pos
, n
); }
504 /// same as `= first n (or all if n == npos) characters of sz'
505 wxString
& assign(const char *sz
, size_t n
= npos
)
506 { return *this = wxString(sz
, n
); }
507 /// same as `= n copies of ch'
508 wxString
& assign(size_t n
, char ch
)
509 { return *this = wxString(ch
, n
); }
513 /** @name inserts something at position nPos into this one */
515 /// insert another string
516 wxString
& insert(size_t nPos
, const wxString
& str
);
517 /// insert n chars of str starting at nStart (in str)
518 wxString
& insert(size_t nPos
, const wxString
& str
, size_t nStart
, size_t n
)
519 { return insert(nPos
, wxString((const char *)str
+ nStart
, n
)); }
521 /// insert first n (or all if n == npos) characters of sz
522 wxString
& insert(size_t nPos
, const char *sz
, size_t n
= npos
)
523 { return insert(nPos
, wxString(sz
, n
)); }
524 /// insert n copies of ch
525 wxString
& insert(size_t nPos
, size_t n
, char ch
)
526 { return insert(nPos
, wxString(ch
, n
)); }
530 /** @name deletes a part of the string */
532 /// delete characters from nStart to nStart + nLen
533 wxString
& erase(size_t nStart
= 0, size_t nLen
= npos
);
536 /** @name replaces a substring of this string with another one */
538 /// replaces the substring of length nLen starting at nStart
539 wxString
& replace(size_t nStart
, size_t nLen
, const char* sz
);
540 /// replaces the substring with nCount copies of ch
541 wxString
& replace(size_t nStart
, size_t nLen
, size_t nCount
, char ch
);
542 /// replaces a substring with another substring
543 wxString
& replace(size_t nStart
, size_t nLen
,
544 const wxString
& str
, size_t nStart2
, size_t nLen2
);
545 /// replaces the substring with first nCount chars of sz
546 wxString
& replace(size_t nStart
, size_t nLen
,
547 const char* sz
, size_t nCount
);
552 void swap(wxString
& str
);
554 /** @name string operations */
556 /** All find() functions take the nStart argument which specifies
557 the position to start the search on, the default value is 0.
559 All functions return npos if there were no match.
565 @name find a match for the string/character in this string
569 size_t find(const wxString
& str
, size_t nStart
= 0) const;
571 // VC++ 1.5 can't cope with this syntax.
572 #if ! (defined(_MSC_VER) && !defined(__WIN32__))
573 /// find first n characters of sz
574 size_t find(const char* sz
, size_t nStart
= 0, size_t n
= npos
) const;
576 /// find the first occurence of character ch after nStart
577 size_t find(char ch
, size_t nStart
= 0) const;
579 // wxWin compatibility
580 inline bool Contains(const wxString
& str
) { return (Find(str
) != -1); }
585 @name rfind() family is exactly like find() but works right to left
588 /// as find, but from the end
589 size_t rfind(const wxString
& str
, size_t nStart
= npos
) const;
590 /// as find, but from the end
591 // VC++ 1.5 can't cope with this syntax.
592 #if ! (defined(_MSC_VER) && !defined(__WIN32__))
593 size_t rfind(const char* sz
, size_t nStart
= npos
,
594 size_t n
= npos
) const;
595 /// as find, but from the end
596 size_t rfind(char ch
, size_t nStart
= npos
) const;
601 @name find first/last occurence of any character in the set
605 size_t find_first_of(const wxString
& str
, size_t nStart
= 0) const;
607 size_t find_first_of(const char* sz
, size_t nStart
= 0) const;
608 /// same as find(char, size_t)
609 size_t find_first_of(char c
, size_t nStart
= 0) const;
612 size_t find_last_of (const wxString
& str
, size_t nStart
= npos
) const;
614 size_t find_last_of (const char* s
, size_t nStart
= npos
) const;
615 /// same as rfind(char, size_t)
616 size_t find_last_of (char c
, size_t nStart
= npos
) const;
620 @name find first/last occurence of any character not in the set
624 size_t find_first_not_of(const wxString
& str
, size_t nStart
= 0) const;
626 size_t find_first_not_of(const char* s
, size_t nStart
= 0) const;
628 size_t find_first_not_of(char ch
, size_t nStart
= 0) const;
631 size_t find_last_not_of(const wxString
& str
, size_t nStart
=npos
) const;
633 size_t find_last_not_of(const char* s
, size_t nStart
= npos
) const;
635 size_t find_last_not_of(char ch
, size_t nStart
= npos
) const;
640 All compare functions return -1, 0 or 1 if the [sub]string
641 is less, equal or greater than the compare() argument.
646 /// just like strcmp()
647 int compare(const wxString
& str
) const { return Cmp(str
); }
648 /// comparaison with a substring
649 int compare(size_t nStart
, size_t nLen
, const wxString
& str
) const;
650 /// comparaison of 2 substrings
651 int compare(size_t nStart
, size_t nLen
,
652 const wxString
& str
, size_t nStart2
, size_t nLen2
) const;
653 /// just like strcmp()
654 int compare(const char* sz
) const { return Cmp(sz
); }
655 /// substring comparaison with first nCount characters of sz
656 int compare(size_t nStart
, size_t nLen
,
657 const char* sz
, size_t nCount
= npos
) const;
659 wxString
substr(size_t nStart
= 0, size_t nLen
= npos
) const;
664 // points to data preceded by wxStringData structure with ref count info
667 // accessor to string data
668 wxStringData
* GetStringData() const { return (wxStringData
*)m_pchData
- 1; }
670 // string (re)initialization functions
671 // initializes the string to the empty value (must be called only from
672 // ctors, use Reinit() otherwise)
673 void Init() { m_pchData
= (char *)g_szNul
; }
674 // initializaes the string with (a part of) C-string
675 void InitWith(const char *psz
, size_t nPos
= 0, size_t nLen
= STRING_MAXLEN
);
676 // as Init, but also frees old data
677 inline void Reinit();
680 // allocates memory for string of lenght nLen
681 void AllocBuffer(size_t nLen
);
682 // copies data to another string
683 void AllocCopy(wxString
&, int, int) const;
684 // effectively copies data to string
685 void AssignCopy(size_t, const char *);
687 // append a (sub)string
688 void ConcatCopy(int nLen1
, const char *src1
, int nLen2
, const char *src2
);
689 void ConcatSelf(int nLen
, const char *src
);
691 // functions called before writing to the string: they copy it if there
692 // other references (should be the only owner when writing)
693 void CopyBeforeWrite();
694 void AllocBeforeWrite(size_t);
697 // ----------------------------------------------------------------------------
698 /** The string array uses it's knowledge of internal structure of the String
699 class to optimize string storage. Normally, we would store pointers to
700 string, but as String is, in fact, itself a pointer (sizeof(String) is
701 sizeof(char *)) we store these pointers instead. The cast to "String *"
702 is really all we need to turn such pointer into a string!
704 Of course, it can be called a dirty hack, but we use twice less memory
705 and this approach is also more speed efficient, so it's probably worth it.
707 Usage notes: when a string is added/inserted, a new copy of it is created,
708 so the original string may be safely deleted. When a string is retrieved
709 from the array (operator[] or Item() method), a reference is returned.
712 @memo probably the most commonly used array type - array of strings
714 // ----------------------------------------------------------------------------
718 /** @name ctors and dtor */
723 wxArrayString(const wxArrayString
& array
);
724 /// assignment operator
725 wxArrayString
& operator=(const wxArrayString
& src
);
726 /// not virtual, this class can't be derived from
730 /** @name memory management */
732 /// empties the list, but doesn't release memory
734 /// empties the list and releases memory
736 /// preallocates memory for given number of items
737 void Alloc(size_t nCount
);
740 /** @name simple accessors */
742 /// number of elements in the array
743 uint
Count() const { return m_nCount
; }
745 bool IsEmpty() const { return m_nCount
== 0; }
748 /** @name items access (range checking is done in debug version) */
750 /// get item at position uiIndex
751 wxString
& Item(size_t nIndex
) const
752 { wxASSERT( nIndex
< m_nCount
); return *(wxString
*)&(m_pItems
[nIndex
]); }
754 wxString
& operator[](size_t nIndex
) const { return Item(nIndex
); }
756 wxString
& Last() const { wxASSERT( !IsEmpty() ); return Item(Count() - 1); }
759 /** @name item management */
762 Search the element in the array, starting from the either side
763 @param if bFromEnd reverse search direction
764 @param if bCase, comparaison is case sensitive (default)
765 @return index of the first item matched or NOT_FOUND
768 int Index (const char *sz
, bool bCase
= TRUE
, bool bFromEnd
= FALSE
) const;
769 /// add new element at the end
770 void Add (const wxString
& str
);
771 /// add new element at given position
772 void Insert(const wxString
& str
, uint uiIndex
);
773 /// remove first item matching this value
774 void Remove(const char *sz
);
775 /// remove item by index
776 void Remove(size_t nIndex
);
779 /// sort array elements
780 void Sort(bool bCase
= TRUE
, bool bReverse
= FALSE
);
783 void Grow(); // makes array bigger if needed
784 void Free(); // free the string stored
786 size_t m_nSize
, // current size of the array
787 m_nCount
; // current number of elements
789 char **m_pItems
; // pointer to data
792 // ---------------------------------------------------------------------------
793 // implementation of inline functions
794 // ---------------------------------------------------------------------------
796 // Put back into class, since BC++ can't create precompiled header otherwise
798 // ---------------------------------------------------------------------------
799 /** @name wxString comparaison functions
800 @memo Comparaisons are case sensitive
802 // ---------------------------------------------------------------------------
804 inline bool operator==(const wxString
& s1
, const wxString
& s2
) { return s1
.Cmp(s2
) == 0; }
806 inline bool operator==(const wxString
& s1
, const char * s2
) { return s1
.Cmp(s2
) == 0; }
808 inline bool operator==(const char * s1
, const wxString
& s2
) { return s2
.Cmp(s1
) == 0; }
810 inline bool operator!=(const wxString
& s1
, const wxString
& s2
) { return s1
.Cmp(s2
) != 0; }
812 inline bool operator!=(const wxString
& s1
, const char * s2
) { return s1
.Cmp(s2
) != 0; }
814 inline bool operator!=(const char * s1
, const wxString
& s2
) { return s2
.Cmp(s1
) != 0; }
816 inline bool operator< (const wxString
& s1
, const wxString
& s2
) { return s1
.Cmp(s2
) < 0; }
818 inline bool operator< (const wxString
& s1
, const char * s2
) { return s1
.Cmp(s2
) < 0; }
820 inline bool operator< (const char * s1
, const wxString
& s2
) { return s2
.Cmp(s1
) > 0; }
822 inline bool operator> (const wxString
& s1
, const wxString
& s2
) { return s1
.Cmp(s2
) > 0; }
824 inline bool operator> (const wxString
& s1
, const char * s2
) { return s1
.Cmp(s2
) > 0; }
826 inline bool operator> (const char * s1
, const wxString
& s2
) { return s2
.Cmp(s1
) < 0; }
828 inline bool operator<=(const wxString
& s1
, const wxString
& s2
) { return s1
.Cmp(s2
) <= 0; }
830 inline bool operator<=(const wxString
& s1
, const char * s2
) { return s1
.Cmp(s2
) <= 0; }
832 inline bool operator<=(const char * s1
, const wxString
& s2
) { return s2
.Cmp(s1
) >= 0; }
834 inline bool operator>=(const wxString
& s1
, const wxString
& s2
) { return s1
.Cmp(s2
) >= 0; }
836 inline bool operator>=(const wxString
& s1
, const char * s2
) { return s1
.Cmp(s2
) >= 0; }
838 inline bool operator>=(const char * s1
, const wxString
& s2
) { return s2
.Cmp(s1
) <= 0; }
841 // ---------------------------------------------------------------------------
842 /** @name Global functions complementing standard C string library
843 @memo replacements for strlen() and portable strcasecmp()
845 // ---------------------------------------------------------------------------
847 #ifdef STD_STRING_COMPATIBILITY
850 class WXDLLEXPORT istream
;
852 istream
& WXDLLEXPORT
operator>>(istream
& is
, wxString
& str
);
854 #endif //std::string compatibility
856 #endif // __WXSTRINGH__