const wchar_t* AsWChar() const;
operator const wchar_t*() const { return AsWChar(); }
- inline operator bool() const;
-
#if !wxUSE_UNICODE
inline
#endif
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
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(); }
//
// 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) );
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
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];
}
// ----------------------------------------------------------------------------