X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/467175ab3f2177aa824ceb7b67934fd54ce4e8e0..210bb741b94a7a4a015de730017c3576afe7a8f1:/include/wx/string.h diff --git a/include/wx/string.h b/include/wx/string.h index da53909475..83ca3c62ee 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -200,8 +200,6 @@ public: const wchar_t* AsWChar() const; operator const wchar_t*() const { return AsWChar(); } - inline operator bool() const; - #if !wxUSE_UNICODE inline #endif @@ -787,7 +785,10 @@ private: static wxString FromImpl(const wxStringImpl& src) { return wxString((CtorFromStringImplTag*)NULL, src); } #else + #if !wxUSE_STL_BASED_WXSTRING wxString(const wxStringImpl& src) : m_impl(src) { } + // else: already defined as wxString(wxStdString) below + #endif static wxString FromImpl(const wxStringImpl& src) { return wxString(src); } #endif @@ -1072,6 +1073,11 @@ public: operator const char*() const { return c_str(); } operator const wchar_t*() const { return c_str(); } + // implicit conversion to untyped pointer for compatibility with previous + // wxWidgets versions: this is the same as conversion to const char * so it + // may fail! + operator const void*() const { return c_str(); } + // identical to c_str(), for MFC compatibility const wxCStrData GetData() const { return c_str(); } @@ -1504,7 +1510,7 @@ public: // // get writable buffer of at least nLen bytes. Unget() *must* be called // a.s.a.p. to put string back in a reasonable state! - wxDEPRECATED( wxChar *GetWriteBuf(size_t nLen) ); + wxDEPRECATED( wxStringCharType *GetWriteBuf(size_t nLen) ); // call this immediately after GetWriteBuf() has been used wxDEPRECATED( void UngetWriteBuf() ); wxDEPRECATED( void UngetWriteBuf(size_t nLen) ); @@ -2552,11 +2558,6 @@ inline wxCStrData::~wxCStrData() delete m_str; } -inline wxCStrData::operator bool() const -{ - return !m_str->empty(); -} - // simple cases for AsChar() and AsWChar(), the complicated ones are // in string.cpp #if wxUSE_UNICODE_WCHAR @@ -2609,7 +2610,9 @@ inline wxUniChar wxCStrData::operator*() const inline wxUniChar wxCStrData::operator[](size_t n) const { - return m_str->at(m_offset + n); + // NB: we intentionally use operator[] and not at() here because the former + // works for the terminating NUL while the latter does not + return (*m_str)[m_offset + n]; } // ----------------------------------------------------------------------------