#include "wx/stringops.h"
#include "wx/unichar.h"
-class WXDLLIMPEXP_BASE wxString;
+class WXDLLIMPEXP_FWD_BASE wxString;
// unless this symbol is predefined to disable the compatibility functions, do
// use them
size_t m_offset;
bool m_owned;
- friend class WXDLLIMPEXP_BASE wxString;
+ friend class WXDLLIMPEXP_FWD_BASE wxString;
};
// ----------------------------------------------------------------------------
/* for internal wxString use only: */ \
underlying_iterator impl() const { return m_cur; } \
\
- friend class WXDLLIMPEXP_BASE wxString; \
- friend class WXDLLIMPEXP_BASE wxCStrData; \
+ friend class wxString; \
+ friend class wxCStrData; \
\
private: \
underlying_iterator m_cur
- class WXDLLIMPEXP_BASE const_iterator;
+ class WXDLLIMPEXP_FWD_BASE const_iterator;
#if wxUSE_UNICODE_UTF8
// NB: In UTF-8 build, (non-const) iterator needs to keep reference
// implicit conversion to C string
operator wxCStrData() const { return c_str(); }
- // these operators conflict with operators for conversion to std::string,
- // so they must be disabled in STL build:
+ // the first two operators conflict with operators for conversion to
+ // std::string and they must be disabled in STL build; the next one only
+ // makes sense if conversions to char* are also defined and not defining it
+ // in STL build also helps us to get more clear error messages for the code
+ // which relies on implicit conversion to char* in STL build
#if !wxUSE_STL
operator const char*() const { return c_str(); }
operator const wchar_t*() const { return c_str(); }
-#endif
// 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(); }
+#endif // wxUSE_STL
// identical to c_str(), for MFC compatibility
const wxCStrData GetData() const { return c_str(); }
// the behaviour of these functions with the strings containing anything
// else than 7 bit ASCII characters is undefined, use at your own risk.
#if wxUSE_UNICODE
- static wxString FromAscii(const char *ascii, size_t len); // string
- static wxString FromAscii(const char *ascii); // string
- static wxString FromAscii(const char ascii); // char
+ static wxString FromAscii(const char *ascii, size_t len);
+ static wxString FromAscii(const char *ascii);
+ static wxString FromAscii(char ascii);
const wxCharBuffer ToAscii() const;
#else // ANSI
static wxString FromAscii(const char *ascii) { return wxString( ascii ); }
static wxString FromAscii(const char *ascii, size_t len)
{ return wxString( ascii, len ); }
- static wxString FromAscii(const char ascii) { return wxString( ascii ); }
+ static wxString FromAscii(char ascii) { return wxString( ascii ); }
const char *ToAscii() const { return c_str(); }
#endif // Unicode/!Unicode
+ // also provide unsigned char overloads as signed/unsigned doesn't matter
+ // for 7 bit ASCII characters
+ static wxString FromAscii(const unsigned char *ascii)
+ { return FromAscii((const char *)ascii); }
+ static wxString FromAscii(const unsigned char *ascii, size_t len)
+ { return FromAscii((const char *)ascii, len); }
+
// conversion to/from UTF-8:
#if wxUSE_UNICODE_UTF8
static wxString FromUTF8(const char *utf8)
wxStringIteratorNodeHead m_iterators;
- friend class WXDLLIMPEXP_BASE wxStringIteratorNode;
- friend class WXDLLIMPEXP_BASE wxUniCharRef;
+ friend class WXDLLIMPEXP_FWD_BASE wxStringIteratorNode;
+ friend class WXDLLIMPEXP_FWD_BASE wxUniCharRef;
#endif // wxUSE_UNICODE_UTF8
- friend class WXDLLIMPEXP_BASE wxCStrData;
+ friend class WXDLLIMPEXP_FWD_BASE wxCStrData;
friend class wxImplStringBuffer;
friend class wxImplStringBufferLength;
};
{ return wxUniChar(ch) + string; }
-#if wxUSE_STL_BASED_WXSTRING
- // return an empty wxString (not very useful with wxUSE_STL == 1)
- inline const wxString wxGetEmptyString() { return wxString(); }
-#else // !wxUSE_STL_BASED_WXSTRING
- // return an empty wxString (more efficient than wxString() here)
- inline const wxString& wxGetEmptyString()
- {
- return *(wxString *)&wxEmptyString;
- }
-#endif // wxUSE_STL_BASED_WXSTRING/!wxUSE_STL_BASED_WXSTRING
+#define wxGetEmptyString() wxString()
// ----------------------------------------------------------------------------
// wxStringBuffer: a tiny class allowing to get a writable pointer into string
inline wxCStrData::~wxCStrData()
{
if ( m_owned )
- delete m_str;
+ delete wx_const_cast(wxString*, m_str); // cast to silence warnings
}
// simple cases for AsChar() and AsWChar(), the complicated ones are