- //@{
- /** @name constructors */
- //@{
- /// take nLen chars starting at nPos
- wxString(const wxString& s, size_t nPos, size_t nLen = npos);
- /// take all characters from pStart to pEnd
- wxString(const void *pStart, const void *pEnd);
- //@}
- /** @name lib.string.capacity */
- //@{
- /// return the length of the string
- size_t size() const { return Len(); }
- /// return the length of the string
- size_t length() const { return Len(); }
- /// return the maximum size of the string
- size_t max_size() const { return STRING_MAXLEN; }
- /// resize the string, filling the space with c if c != 0
- void resize(size_t nSize, char ch = '\0');
- /// delete the contents of the string
- void clear() { Empty(); }
- /// returns true if the string is empty
- bool empty() const { return IsEmpty(); }
- //@}
- /** @name lib.string.access */
- //@{
- /// return the character at position n
- char at(size_t n) const { return GetChar(n); }
- /// returns the writable character at position n
- char& at(size_t n) { return GetWritableChar(n); }
- //@}
- /** @name lib.string.modifiers */
- //@{
- /** @name append something to the end of this one */
- //@{
- /// append a string
- wxString& append(const wxString& str)
- { *this += str; return *this; }
- /// append elements str[pos], ..., str[pos+n]
- wxString& append(const wxString& str, size_t pos, size_t n)
- { ConcatSelf(n, str.c_str() + pos); return *this; }
- /// append first n (or all if n == npos) characters of sz
- wxString& append(const char *sz, size_t n = npos)
- { ConcatSelf(n == npos ? Strlen(sz) : n, sz); return *this; }
-
- /// append n copies of ch
- wxString& append(size_t n, char ch) { return Pad(n, ch); }
- //@}
-
- /** @name replaces the contents of this string with another one */
- //@{
- /// same as `this_string = str'
- wxString& assign(const wxString& str) { return (*this) = str; }
- /// same as ` = str[pos..pos + n]
- wxString& assign(const wxString& str, size_t pos, size_t n)
- { return *this = wxString((const char *)str + pos, n); }
- /// same as `= first n (or all if n == npos) characters of sz'
- wxString& assign(const char *sz, size_t n = npos)
- { return *this = wxString(sz, n); }
- /// same as `= n copies of ch'
- wxString& assign(size_t n, char ch)
- { return *this = wxString(ch, n); }
-
- //@}
-
- /** @name inserts something at position nPos into this one */
- //@{
- /// insert another string
- wxString& insert(size_t nPos, const wxString& str);
- /// insert n chars of str starting at nStart (in str)
- wxString& insert(size_t nPos, const wxString& str, size_t nStart, size_t n)
- { return insert(nPos, wxString((const char *)str + nStart, n)); }
-
- /// insert first n (or all if n == npos) characters of sz
- wxString& insert(size_t nPos, const char *sz, size_t n = npos)
- { return insert(nPos, wxString(sz, n)); }
- /// insert n copies of ch
- wxString& insert(size_t nPos, size_t n, char ch)
- { return insert(nPos, wxString(ch, n)); }
-
- //@}
-
- /** @name deletes a part of the string */
- //@{
- /// delete characters from nStart to nStart + nLen
- wxString& erase(size_t nStart = 0, size_t nLen = npos);
- //@}
-
- /** @name replaces a substring of this string with another one */
- //@{
- /// replaces the substring of length nLen starting at nStart
- wxString& replace(size_t nStart, size_t nLen, const char* sz);
- /// replaces the substring with nCount copies of ch
- wxString& replace(size_t nStart, size_t nLen, size_t nCount, char ch);
- /// replaces a substring with another substring
- wxString& replace(size_t nStart, size_t nLen,
- const wxString& str, size_t nStart2, size_t nLen2);
- /// replaces the substring with first nCount chars of sz
- wxString& replace(size_t nStart, size_t nLen,
- const char* sz, size_t nCount);
- //@}
- //@}
-
- /// swap two strings
- void swap(wxString& str);
-
- /** @name string operations */
- //@{
- /** All find() functions take the nStart argument which specifies
- the position to start the search on, the default value is 0.
-
- All functions return npos if there were no match.
-
- @name string search
- */
- //@{
- /**
- @name find a match for the string/character in this string
- */
- //@{
- /// find a substring
- size_t find(const wxString& str, size_t nStart = 0) const;
-
- // VC++ 1.5 can't cope with this syntax.
-#if ! (defined(_MSC_VER) && !defined(__WIN32__))
- /// find first n characters of sz
- size_t find(const char* sz, size_t nStart = 0, size_t n = npos) const;
-#endif
- /// find the first occurence of character ch after nStart
- size_t find(char ch, size_t nStart = 0) const;
-
- // wxWin compatibility
- inline bool Contains(const wxString& str) { return Find(str) != -1; }
-
- //@}
-
- /**
- @name rfind() family is exactly like find() but works right to left
- */
- //@{
- /// as find, but from the end
- size_t rfind(const wxString& str, size_t nStart = npos) const;
- /// as find, but from the end
- // VC++ 1.5 can't cope with this syntax.
-#if ! (defined(_MSC_VER) && !defined(__WIN32__))
- size_t rfind(const char* sz, size_t nStart = npos,
- size_t n = npos) const;
- /// as find, but from the end
- size_t rfind(char ch, size_t nStart = npos) const;
-#endif
- //@}
-
- /**
- @name find first/last occurence of any character in the set
- */
- //@{
- ///
- size_t find_first_of(const wxString& str, size_t nStart = 0) const;
- ///
- size_t find_first_of(const char* sz, size_t nStart = 0) const;
- /// same as find(char, size_t)
- size_t find_first_of(char c, size_t nStart = 0) const;
-
- ///
- size_t find_last_of (const wxString& str, size_t nStart = npos) const;
- ///
- size_t find_last_of (const char* s, size_t nStart = npos) const;
- /// same as rfind(char, size_t)
- size_t find_last_of (char c, size_t nStart = npos) const;
- //@}
-
- /**
- @name find first/last occurence of any character not in the set
- */
- //@{
- ///
- size_t find_first_not_of(const wxString& str, size_t nStart = 0) const;
- ///
- size_t find_first_not_of(const char* s, size_t nStart = 0) const;
- ///
- size_t find_first_not_of(char ch, size_t nStart = 0) const;
-
- ///
- size_t find_last_not_of(const wxString& str, size_t nStart=npos) const;
- ///
- size_t find_last_not_of(const char* s, size_t nStart = npos) const;
- ///
- size_t find_last_not_of(char ch, size_t nStart = npos) const;
- //@}
- //@}
-
- /**
- All compare functions return -1, 0 or 1 if the [sub]string
- is less, equal or greater than the compare() argument.
-
- @name comparison
- */
- //@{
- /// just like strcmp()
- int compare(const wxString& str) const { return Cmp(str); }
- /// comparaison with a substring
- int compare(size_t nStart, size_t nLen, const wxString& str) const;
- /// comparaison of 2 substrings
- int compare(size_t nStart, size_t nLen,
- const wxString& str, size_t nStart2, size_t nLen2) const;
- /// just like strcmp()
- int compare(const char* sz) const { return Cmp(sz); }
- /// substring comparaison with first nCount characters of sz
- int compare(size_t nStart, size_t nLen,
- const char* sz, size_t nCount = npos) const;
- //@}
- wxString substr(size_t nStart = 0, size_t nLen = npos) const;
- //@}
+ // constructors
+ // take nLen chars starting at nPos
+ wxString(const wxString& str, size_t nPos, size_t nLen)
+ {
+ wxASSERT( str.GetStringData()->IsValid() );
+ InitWith(str.c_str(), nPos, nLen == npos ? 0 : nLen);
+ }
+ // take all characters from pStart to pEnd
+ wxString(const void *pStart, const void *pEnd);
+
+ // lib.string.capacity
+ // return the length of the string
+ size_t size() const { return Len(); }
+ // return the length of the string
+ size_t length() const { return Len(); }
+ // return the maximum size of the string
+ size_t max_size() const { return wxSTRING_MAXLEN; }
+ // resize the string, filling the space with c if c != 0
+ void resize(size_t nSize, wxChar ch = wxT('\0'));
+ // delete the contents of the string
+ void clear() { Empty(); }
+ // returns true if the string is empty
+ bool empty() const { return IsEmpty(); }
+ // inform string about planned change in size
+ void reserve(size_t size) { Alloc(size); }
+
+ // lib.string.access
+ // return the character at position n
+ wxChar at(size_t n) const { return GetChar(n); }
+ // returns the writable character at position n
+ wxChar& at(size_t n) { return GetWritableChar(n); }
+
+ // first valid index position
+ const_iterator begin() const { return wx_str(); }
+ // position one after the last valid one
+ const_iterator end() const { return wx_str() + length(); }
+
+ // lib.string.modifiers
+ // append a string
+ wxString& append(const wxString& str)
+ { *this += str; return *this; }
+ // append elements str[pos], ..., str[pos+n]
+ wxString& append(const wxString& str, size_t pos, size_t n)
+ { ConcatSelf(n, str.c_str() + pos); return *this; }
+ // append first n (or all if n == npos) characters of sz
+ wxString& append(const wxChar *sz, size_t n = npos)
+ { ConcatSelf(n == npos ? wxStrlen(sz) : n, sz); return *this; }
+
+ // append n copies of ch
+ wxString& append(size_t n, wxChar ch) { return Pad(n, ch); }
+
+ // same as `this_string = str'
+ wxString& assign(const wxString& str) { return (*this) = str; }
+ // same as ` = str[pos..pos + n]
+ wxString& assign(const wxString& str, size_t pos, size_t n)
+ { return *this = wxString((const wxChar *)str + pos, n); }
+ // same as `= first n (or all if n == npos) characters of sz'
+ wxString& assign(const wxChar *sz, size_t n = npos)
+ { return *this = wxString(sz, n); }
+ // same as `= n copies of ch'
+ wxString& assign(size_t n, wxChar ch)
+ { return *this = wxString(ch, n); }
+
+ // insert another string
+ wxString& insert(size_t nPos, const wxString& str);
+ // insert n chars of str starting at nStart (in str)
+ wxString& insert(size_t nPos, const wxString& str, size_t nStart, size_t n)
+ { return insert(nPos, wxString((const wxChar *)str + nStart, n)); }
+
+ // insert first n (or all if n == npos) characters of sz
+ wxString& insert(size_t nPos, const wxChar *sz, size_t n = npos)
+ { return insert(nPos, wxString(sz, n)); }
+ // insert n copies of ch
+ wxString& insert(size_t nPos, size_t n, wxChar ch)
+ { return insert(nPos, wxString(ch, n)); }
+
+ // delete characters from nStart to nStart + nLen
+ wxString& erase(size_t nStart = 0, size_t nLen = npos);
+
+ // replaces the substring of length nLen starting at nStart
+ wxString& replace(size_t nStart, size_t nLen, const wxChar* sz);
+ // replaces the substring with nCount copies of ch
+ wxString& replace(size_t nStart, size_t nLen, size_t nCount, wxChar ch);
+ // replaces a substring with another substring
+ wxString& replace(size_t nStart, size_t nLen,
+ const wxString& str, size_t nStart2, size_t nLen2);
+ // replaces the substring with first nCount chars of sz
+ wxString& replace(size_t nStart, size_t nLen,
+ const wxChar* sz, size_t nCount);
+
+ // swap two strings
+ void swap(wxString& str);
+
+ // All find() functions take the nStart argument which specifies the
+ // position to start the search on, the default value is 0. All functions
+ // return npos if there were no match.
+
+ // find a substring
+ size_t find(const wxString& str, size_t nStart = 0) const;
+
+ // VC++ 1.5 can't cope with this syntax.
+#if !defined(__VISUALC__) || defined(__WIN32__)
+ // find first n characters of sz
+ size_t find(const wxChar* sz, size_t nStart = 0, size_t n = npos) const;
+#endif // VC++ 1.5
+
+ // Gives a duplicate symbol (presumably a case-insensitivity problem)
+#if !defined(__BORLANDC__)
+ // find the first occurence of character ch after nStart
+ size_t find(wxChar ch, size_t nStart = 0) const;