Uses wxUSE_WCHAR_T for compilers that don't support wchar_t.
Added wx_str() and WXCSTRINGCAST, which should be explicitly defined to work on wxChar (doesn't look like people want c_str() to be unconditionally defined as wxChar). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2279 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -66,6 +66,7 @@ const unsigned int wxSTRING_MAXLEN = UINT_MAX - 100;
|
|||||||
|
|
||||||
// 'naughty' cast
|
// 'naughty' cast
|
||||||
#define WXSTRINGCAST (wxChar *)(const wxChar *)
|
#define WXSTRINGCAST (wxChar *)(const wxChar *)
|
||||||
|
#define WXCSTRINGCAST (wxChar *)(const wxChar *)
|
||||||
#define MBSTRINGCAST (char *)(const char *)
|
#define MBSTRINGCAST (char *)(const char *)
|
||||||
#define WCSTRINGCAST (wchar_t *)(const wchar_t *)
|
#define WCSTRINGCAST (wchar_t *)(const wchar_t *)
|
||||||
|
|
||||||
@@ -169,6 +170,7 @@ struct WXDLLEXPORT wxStringData
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// types of multibyte<->Unicode conversions
|
// types of multibyte<->Unicode conversions
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
#if wxUSE_WCHAR_T
|
||||||
class WXDLLEXPORT wxMBConv
|
class WXDLLEXPORT wxMBConv
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -254,6 +256,10 @@ WXDLLEXPORT_DATA(extern wxMBConv *) wxConv_current;
|
|||||||
#define wxFNCONV(name) name
|
#define wxFNCONV(name) name
|
||||||
#define FNSTRINGCAST WXSTRINGCAST
|
#define FNSTRINGCAST WXSTRINGCAST
|
||||||
#endif
|
#endif
|
||||||
|
#else//!wxUSE_WCHAR_T
|
||||||
|
class WXDLLEXPORT wxMBConv {};
|
||||||
|
WXDLLEXPORT_DATA(extern wxMBConv) wxConv_libc;
|
||||||
|
#endif//wxUSE_WCHAR_T
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// This is (yet another one) String class for C++ programmers. It doesn't use
|
// This is (yet another one) String class for C++ programmers. It doesn't use
|
||||||
@@ -370,8 +376,10 @@ public:
|
|||||||
// from multibyte string
|
// from multibyte string
|
||||||
wxString(const char *psz, wxMBConv& WXUNUSED(conv), size_t nLength = wxSTRING_MAXLEN)
|
wxString(const char *psz, wxMBConv& WXUNUSED(conv), size_t nLength = wxSTRING_MAXLEN)
|
||||||
{ InitWith(psz, 0, nLength); }
|
{ InitWith(psz, 0, nLength); }
|
||||||
|
#if wxUSE_WCHAR_T
|
||||||
// from wide (Unicode) string
|
// from wide (Unicode) string
|
||||||
wxString(const wchar_t *pwz);
|
wxString(const wchar_t *pwz);
|
||||||
|
#endif
|
||||||
// from wxCharBuffer
|
// from wxCharBuffer
|
||||||
wxString(const wxCharBuffer& psz)
|
wxString(const wxCharBuffer& psz)
|
||||||
{ InitWith(psz, 0, wxSTRING_MAXLEN); }
|
{ InitWith(psz, 0, wxSTRING_MAXLEN); }
|
||||||
@@ -451,6 +459,8 @@ public:
|
|||||||
operator const wxChar*() const { return m_pchData; }
|
operator const wxChar*() const { return m_pchData; }
|
||||||
// explicit conversion to C string (use this with printf()!)
|
// explicit conversion to C string (use this with printf()!)
|
||||||
const wxChar* c_str() const { return m_pchData; }
|
const wxChar* c_str() const { return m_pchData; }
|
||||||
|
// (and this with [wx]Printf()!)
|
||||||
|
const wxChar* wx_str() const { return m_pchData; }
|
||||||
//
|
//
|
||||||
const wxChar* GetData() const { return m_pchData; }
|
const wxChar* GetData() const { return m_pchData; }
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
@@ -463,7 +473,9 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
const wxChar* mb_str(wxMBConv& WXUNUSED(conv) = wxConv_libc ) const { return m_pchData; }
|
const wxChar* mb_str(wxMBConv& WXUNUSED(conv) = wxConv_libc ) const { return m_pchData; }
|
||||||
|
#if wxUSE_WCHAR_T
|
||||||
const wxWCharBuffer wc_str(wxMBConv& conv) const { return conv.cMB2WC(m_pchData); }
|
const wxWCharBuffer wc_str(wxMBConv& conv) const { return conv.cMB2WC(m_pchData); }
|
||||||
|
#endif
|
||||||
const wxChar* fn_str() const { return m_pchData; }
|
const wxChar* fn_str() const { return m_pchData; }
|
||||||
#endif
|
#endif
|
||||||
// for convenience
|
// for convenience
|
||||||
@@ -482,8 +494,10 @@ public:
|
|||||||
#else
|
#else
|
||||||
// from another kind of C string
|
// from another kind of C string
|
||||||
wxString& operator=(const unsigned char* psz);
|
wxString& operator=(const unsigned char* psz);
|
||||||
|
#if wxUSE_WCHAR_T
|
||||||
// from a wide string
|
// from a wide string
|
||||||
wxString& operator=(const wchar_t *pwz);
|
wxString& operator=(const wchar_t *pwz);
|
||||||
|
#endif
|
||||||
// from wxCharBuffer
|
// from wxCharBuffer
|
||||||
wxString& operator=(const wxCharBuffer& psz) { return operator=((const char *)psz); }
|
wxString& operator=(const wxCharBuffer& psz) { return operator=((const char *)psz); }
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user