-#define wxUSE_STL_BASED_WXSTRING wxUSE_STL
+// we use STL-based string internally if we use std::string at all now, there
+// should be no reason to prefer our internal implement but if you really need
+// it you can predefine wxUSE_STL_BASED_WXSTRING as 0 when building the library
+#ifndef wxUSE_STL_BASED_WXSTRING
+ #define wxUSE_STL_BASED_WXSTRING wxUSE_STD_STRING
+#endif
- iterator_name& operator+=(size_t n) \
- { m_ptr += n; return *this; } \
- iterator_name& operator-=(int n) \
- { m_ptr -= n; return *this; } \
- iterator_name& operator-=(size_t n) \
+ iterator_name& operator-=(ptrdiff_t n) \
\
pointer m_ptr
// we need to declare const_iterator in wxStringImpl scope, the friend
// declaration inside iterator class itself is not enough, or at least not
// for g++ 3.4 (g++ 4 is ok)
\
pointer m_ptr
// we need to declare const_iterator in wxStringImpl scope, the friend
// declaration inside iterator class itself is not enough, or at least not
// for g++ 3.4 (g++ 4 is ok)
wxStringImpl(const wxStringImpl& stringSrc)
{
wxASSERT_MSG( stringSrc.GetStringData()->IsValid(),
wxStringImpl(const wxStringImpl& stringSrc)
{
wxASSERT_MSG( stringSrc.GetStringData()->IsValid(),
wxStringImpl(const wxStringImpl& str, size_t nPos, size_t nLen)
{
wxASSERT_MSG( str.GetStringData()->IsValid(),
wxStringImpl(const wxStringImpl& str, size_t nPos, size_t nLen)
{
wxASSERT_MSG( str.GetStringData()->IsValid(),
Init();
size_t strLen = str.length() - nPos; nLen = strLen < nLen ? strLen : nLen;
InitWith(str.c_str(), nPos, nLen);
Init();
size_t strLen = str.length() - nPos; nLen = strLen < nLen ? strLen : nLen;
InitWith(str.c_str(), nPos, nLen);
+#if defined(__VISUALC__) && (__VISUALC__ >= 1200)
+ // disable warning about Unlock() below not being inlined (first, it
+ // seems to be inlined nevertheless and second, even if it isn't, there
+ // is nothing we can do about this
+ #pragma warning(push)
+ #pragma warning (disable:4714)
+#endif
-#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
-
value_type at(size_type n) const
{ wxASSERT_VALID_INDEX( n ); return m_pchData[n]; }
// returns the writable 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
{ ConcatSelf(str.length(), str.c_str()); return *this; }
// append first n (or all if n == npos) characters of sz
wxStringImpl& append(const wxStringCharType *sz)
{ ConcatSelf(str.length(), str.c_str()); return *this; }
// append first n (or all if n == npos) characters of sz
wxStringImpl& append(const wxStringCharType *sz)
wxStringImpl& append(const wxStringCharType *sz, size_t n)
{ ConcatSelf(n, sz); return *this; }
// append n copies of ch
wxStringImpl& append(size_t n, wxStringCharType ch);
// append from first to last
wxStringImpl& append(const_iterator first, const_iterator last)
wxStringImpl& append(const wxStringCharType *sz, size_t n)
{ ConcatSelf(n, sz); return *this; }
// append n copies of ch
wxStringImpl& append(size_t n, wxStringCharType ch);
// append from first to last
wxStringImpl& append(const_iterator first, const_iterator last)
// same as `this_string = str'
wxStringImpl& assign(const wxStringImpl& str)
{ return *this = str; }
// same as ` = str[pos..pos + n]
wxStringImpl& assign(const wxStringImpl& str, size_t pos, size_t n)
// same as `this_string = str'
wxStringImpl& assign(const wxStringImpl& str)
{ return *this = str; }
// same as ` = str[pos..pos + n]
wxStringImpl& assign(const wxStringImpl& str, size_t pos, size_t n)
- { clear(); return append(str, pos, n); }
+ { return replace(0, npos, str, pos, n); }
// same as `= first n (or all if n == npos) characters of sz'
wxStringImpl& assign(const wxStringCharType *sz)
// same as `= first n (or all if n == npos) characters of sz'
wxStringImpl& assign(const wxStringCharType *sz)
// same as `= n copies of ch'
wxStringImpl& assign(size_t n, wxStringCharType ch)
// same as `= n copies of ch'
wxStringImpl& assign(size_t n, wxStringCharType ch)
// assign from first to last
wxStringImpl& assign(const_iterator first, const_iterator last)
// assign from first to last
wxStringImpl& assign(const_iterator first, const_iterator last)
iterator insert(iterator it, wxStringCharType ch)
{ size_t idx = it - begin(); insert(idx, 1, ch); return begin() + idx; }
void insert(iterator it, const_iterator first, const_iterator last)
iterator insert(iterator it, wxStringCharType ch)
{ size_t idx = it - begin(); insert(idx, 1, ch); return begin() + idx; }
void insert(iterator it, const_iterator first, const_iterator last)
void insert(iterator it, size_type n, wxStringCharType ch)
{ insert(it - begin(), n, ch); }
void insert(iterator it, size_type n, wxStringCharType ch)
{ insert(it - begin(), n, ch); }
const wxStringCharType* data() const { return m_pchData; }
// replaces the substring of length nLen starting at nStart
const wxStringCharType* data() const { return m_pchData; }
// replaces the substring of length nLen starting at nStart
- wxStringImpl& replace(size_t nStart, size_t nLen, const wxStringCharType* sz);
+ wxStringImpl& replace(size_t nStart, size_t nLen, const wxStringCharType* sz)
+ { return replace(nStart, nLen, sz, npos); }
// replaces the substring of length nLen starting at nStart
wxStringImpl& replace(size_t nStart, size_t nLen, const wxStringImpl& str)
// replaces the substring of length nLen starting at nStart
wxStringImpl& replace(size_t nStart, size_t nLen, const wxStringImpl& str)
- { return replace(nStart, nLen, str.c_str()); }
+ { return replace(nStart, nLen, str.c_str(), str.length()); }
- wxStringImpl& replace(size_t nStart, size_t nLen, size_t nCount, wxStringCharType ch);
+ wxStringImpl& replace(size_t nStart, size_t nLen,
+ size_t nCount, wxStringCharType ch)
+ { return replace(nStart, nLen, wxStringImpl(nCount, ch)); }
// replaces a substring with another substring
wxStringImpl& replace(size_t nStart, size_t nLen,
// replaces a substring with another substring
wxStringImpl& replace(size_t nStart, size_t nLen,
- const wxStringImpl& str, size_t nStart2, size_t nLen2);
+ const wxStringImpl& str, size_t nStart2, size_t nLen2)
+ { return replace(nStart, nLen, str.substr(nStart2, nLen2)); }
// replaces the substring with first nCount chars of sz
wxStringImpl& replace(size_t nStart, size_t nLen,
const wxStringCharType* sz, size_t nCount);
// replaces the substring with first nCount chars of sz
wxStringImpl& replace(size_t nStart, size_t nLen,
const wxStringCharType* sz, size_t nCount);
wxStringImpl& replace(iterator first, iterator last, const_pointer s)
{ return replace(first - begin(), last - first, s); }
wxStringImpl& replace(iterator first, iterator last, const_pointer s,
wxStringImpl& replace(iterator first, iterator last, const_pointer s)
{ return replace(first - begin(), last - first, s); }
wxStringImpl& replace(iterator first, iterator last, const_pointer s,
{ return replace(first - begin(), last - first, n, c); }
wxStringImpl& replace(iterator first, iterator last,
const_iterator first1, const_iterator last1)
{ return replace(first - begin(), last - first, n, c); }
wxStringImpl& replace(iterator first, iterator last,
const_iterator first1, const_iterator last1)
- { return replace(first - begin(), last - first, first1, last1 - first1); }
+ { return replace(first - begin(), last - first, first1.GetPtr(), last1 - first1); }
-private:
-#if wxUSE_UNICODE_UTF8
- static size_t Strsize(const wxStringCharType *s) { return strlen(s); }
-#else
- static size_t Strsize(const wxStringCharType *s) { return wxStrlen(s); }
-#endif
-
- friend class WXDLLIMPEXP_BASE wxString;
+ friend class WXDLLIMPEXP_FWD_BASE wxString;