-
- //@{
- /** @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;
+
+ // 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 = _T('\0'));
+ // delete the contents of the string
+ void clear() { Empty(); }
+ // returns true if the string is empty
+ bool empty() const { return IsEmpty(); }
+
+ // 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;