+ bool CopyBeforeWrite();
+ bool AllocBeforeWrite(size_t);
+
+ // compatibility with wxString
+ bool Alloc(size_t nLen);
+public:
+ // standard types
+ typedef wxChar value_type;
+ typedef wxChar char_type;
+ typedef size_t size_type;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type *iterator;
+ typedef const value_type *const_iterator;
+
+ // constructors and destructor
+ // ctor for an empty string
+ wxStringBase() { Init(); }
+ // copy ctor
+ wxStringBase(const wxStringBase& stringSrc)
+ {
+ wxASSERT_MSG( stringSrc.GetStringData()->IsValid(),
+ _T("did you forget to call UngetWriteBuf()?") );
+
+ if ( stringSrc.empty() ) {
+ // nothing to do for an empty string
+ Init();
+ }
+ else {
+ m_pchData = stringSrc.m_pchData; // share same data
+ GetStringData()->Lock(); // => one more copy
+ }
+ }
+ // string containing nRepeat copies of ch
+ wxStringBase(size_type nRepeat, wxChar ch);
+ // ctor takes first nLength characters from C string
+ // (default value of npos means take all the string)
+ wxStringBase(const wxChar *psz)
+ { InitWith(psz, 0, npos); }
+ wxStringBase(const wxChar *psz, size_t nLength)
+ { InitWith(psz, 0, nLength); }
+ wxStringBase(const wxChar *psz, wxMBConv& WXUNUSED(conv), size_t nLength = npos)
+ { InitWith(psz, 0, nLength); }
+ // take nLen chars starting at nPos
+ wxStringBase(const wxStringBase& str, size_t nPos, size_t nLen)
+ {
+ wxASSERT_MSG( str.GetStringData()->IsValid(),
+ _T("did you forget to call UngetWriteBuf()?") );
+ Init();
+ size_t strLen = str.length() - nPos; nLen = strLen < nLen ? strLen : nLen;
+ InitWith(str.c_str(), nPos, nLen);
+ }
+ // take all characters from pStart to pEnd
+ wxStringBase(const void *pStart, const void *pEnd);
+
+ // dtor is not virtual, this class must not be inherited from!
+ ~wxStringBase()
+ {
+#if defined(__VISUALC__) && (__VISUALC__ >= 1200)
+ //RN - according to the above VC++ does indeed inline this,
+ //even though it spits out two warnings
+ #pragma warning (disable:4714)
+#endif
+
+ GetStringData()->Unlock();
+ }
+
+#if defined(__VISUALC__) && (__VISUALC__ >= 1200)
+ //re-enable inlining warning
+ #pragma warning (default:4714)
+#endif
+ // overloaded assignment
+ // from another wxString
+ wxStringBase& operator=(const wxStringBase& stringSrc);
+ // from a character
+ wxStringBase& operator=(wxChar ch);
+ // from a C string
+ wxStringBase& operator=(const wxChar *psz);
+
+ // return the length of the string
+ size_type size() const { return GetStringData()->nDataLength; }
+ // return the length of the string
+ size_type length() const { return size(); }
+ // return the maximum size of the string
+ size_type 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() { erase(0, npos); }
+ // returns true if the string is empty
+ bool empty() const { return size() == 0; }
+ // inform string about planned change in size
+ void reserve(size_t sz) { Alloc(sz); }
+ size_type capacity() const { return GetStringData()->nAllocLength; }
+
+ // lib.string.access
+ // return the character at position n
+ value_type at(size_type n) const
+ { wxASSERT_VALID_INDEX( n ); return m_pchData[n]; }
+ // returns the writable character at position n
+ reference at(size_type n)
+ { wxASSERT_VALID_INDEX( n ); CopyBeforeWrite(); return m_pchData[n]; }
+
+ // lib.string.modifiers
+ // append elements str[pos], ..., str[pos+n]
+ wxStringBase& append(const wxStringBase& str, size_t pos, size_t n)
+ {
+ wxASSERT(pos <= str.length());
+ ConcatSelf(n, str.c_str() + pos, str.length() - pos);
+ return *this;
+ }
+ // append a string
+ wxStringBase& append(const wxStringBase& str)
+ { ConcatSelf(str.length(), str.c_str()); return *this; }
+ // append first n (or all if n == npos) characters of sz
+ wxStringBase& append(const wxChar *sz)
+ { ConcatSelf(wxStrlen(sz), sz); return *this; }
+ wxStringBase& append(const wxChar *sz, size_t n)
+ { ConcatSelf(n, sz); return *this; }
+ // append n copies of ch
+ wxStringBase& append(size_t n, wxChar ch);
+ // append from first to last
+ wxStringBase& append(const_iterator first, const_iterator last)
+ { ConcatSelf(last - first, first); return *this; }
+
+ // same as `this_string = str'
+ wxStringBase& assign(const wxStringBase& str)
+ { return *this = str; }
+ // same as ` = str[pos..pos + n]
+ wxStringBase& assign(const wxStringBase& str, size_t pos, size_t n)
+ { clear(); return append(str, pos, n); }
+ // same as `= first n (or all if n == npos) characters of sz'
+ wxStringBase& assign(const wxChar *sz)
+ { clear(); return append(sz, wxStrlen(sz)); }
+ wxStringBase& assign(const wxChar *sz, size_t n)
+ { clear(); return append(sz, n); }
+ // same as `= n copies of ch'
+ wxStringBase& assign(size_t n, wxChar ch)
+ { clear(); return append(n, ch); }
+ // assign from first to last
+ wxStringBase& assign(const_iterator first, const_iterator last)
+ { clear(); return append(first, last); }
+
+ // first valid index position
+ const_iterator begin() const { return m_pchData; }
+ // position one after the last valid one
+ const_iterator end() const { return m_pchData + length(); }
+
+ // first valid index position
+ iterator begin();
+ // position one after the last valid one
+ iterator end();
+
+ // insert another string
+ wxStringBase& insert(size_t nPos, const wxStringBase& str)
+ {
+ wxASSERT( str.GetStringData()->IsValid() );
+ return insert(nPos, str.c_str(), str.length());
+ }
+ // insert n chars of str starting at nStart (in str)
+ wxStringBase& insert(size_t nPos, const wxStringBase& str, size_t nStart, size_t n)
+ {
+ wxASSERT( str.GetStringData()->IsValid() );
+ wxASSERT( nStart < str.length() );
+ size_t strLen = str.length() - nStart;
+ n = strLen < n ? strLen : n;
+ return insert(nPos, str.c_str() + nStart, n);
+ }
+ // insert first n (or all if n == npos) characters of sz
+ wxStringBase& insert(size_t nPos, const wxChar *sz, size_t n = npos);
+ // insert n copies of ch
+ wxStringBase& insert(size_t nPos, size_t n, wxChar ch)
+ { return insert(nPos, wxStringBase(n, ch)); }
+ iterator insert(iterator it, wxChar ch)
+ { size_t idx = it - begin(); insert(idx, 1, ch); return begin() + idx; }
+ void insert(iterator it, const_iterator first, const_iterator last)
+ { insert(it - begin(), first, last - first); }
+ void insert(iterator it, size_type n, wxChar ch)
+ { insert(it - begin(), n, ch); }
+
+ // delete characters from nStart to nStart + nLen
+ wxStringBase& erase(size_type pos = 0, size_type n = npos);
+ iterator erase(iterator first, iterator last)
+ {
+ size_t idx = first - begin();
+ erase(idx, last - first);
+ return begin() + idx;
+ }
+ iterator erase(iterator first);
+
+ // explicit conversion to C string (use this with printf()!)
+ const wxChar* c_str() const { return m_pchData; }
+ const wxChar* data() const { return m_pchData; }