fixed compilation if wxUSE_STL=1
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44959 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -177,8 +177,18 @@ inline int Stricmp(const char *psz1, const char *psz2)
|
|||||||
// deal with STL/non-STL/non-STL-but-wxUSE_STD_STRING
|
// deal with STL/non-STL/non-STL-but-wxUSE_STD_STRING
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// FIXME-UTF8: using std::string as wxString base class is currently broken,
|
||||||
|
// so we use the standard wxString with std::string conversion
|
||||||
|
// enabled, this is API-compatible.
|
||||||
|
#define wxUSE_STL_BASED_WXSTRING 0
|
||||||
|
#if wxUSE_STL
|
||||||
|
#undef wxUSE_STD_STRING
|
||||||
|
#define wxUSE_STD_STRING 1
|
||||||
|
#endif
|
||||||
|
//#define wxUSE_STL_BASED_WXSTRING wxUSE_STL
|
||||||
|
|
||||||
// in both cases we need to define wxStdString
|
// in both cases we need to define wxStdString
|
||||||
#if wxUSE_STL || wxUSE_STD_STRING
|
#if wxUSE_STL_BASED_WXSTRING || wxUSE_STD_STRING
|
||||||
|
|
||||||
#include "wx/beforestd.h"
|
#include "wx/beforestd.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -196,7 +206,7 @@ inline int Stricmp(const char *psz1, const char *psz2)
|
|||||||
|
|
||||||
#endif // need <string>
|
#endif // need <string>
|
||||||
|
|
||||||
#if wxUSE_STL
|
#if wxUSE_STL_BASED_WXSTRING
|
||||||
|
|
||||||
// we don't need an extra ctor from std::string when copy ctor already does
|
// we don't need an extra ctor from std::string when copy ctor already does
|
||||||
// the work
|
// the work
|
||||||
@@ -209,10 +219,10 @@ inline int Stricmp(const char *psz1, const char *psz2)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef wxStdString wxStringBase;
|
typedef wxStdString wxStringBase;
|
||||||
#else // if !wxUSE_STL
|
#else // if !wxUSE_STL_BASED_WXSTRING
|
||||||
|
|
||||||
#if !defined(HAVE_STD_STRING_COMPARE) && \
|
#if !defined(HAVE_STD_STRING_COMPARE) && \
|
||||||
(!defined(__WX_SETUP_H__) || wxUSE_STL == 0)
|
(!defined(__WX_SETUP_H__) || wxUSE_STL_BASED_WXSTRING == 0)
|
||||||
#define HAVE_STD_STRING_COMPARE
|
#define HAVE_STD_STRING_COMPARE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -751,7 +761,7 @@ public:
|
|||||||
wxStringBase& operator+=(wchar_t ch) { return append(1, ch); }
|
wxStringBase& operator+=(wchar_t ch) { return append(1, ch); }
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !wxUSE_STL
|
#endif // !wxUSE_STL_BASED_WXSTRING
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxCStrData
|
// wxCStrData
|
||||||
@@ -1163,7 +1173,7 @@ public:
|
|||||||
{ return (wxString&)wxStringBase::operator=(wxUniChar(ch)); }
|
{ return (wxString&)wxStringBase::operator=(wxUniChar(ch)); }
|
||||||
// from a C string - STL probably will crash on NULL,
|
// from a C string - STL probably will crash on NULL,
|
||||||
// so we need to compensate in that case
|
// so we need to compensate in that case
|
||||||
#if wxUSE_STL
|
#if wxUSE_STL_BASED_WXSTRING
|
||||||
wxString& operator=(const wxChar *psz)
|
wxString& operator=(const wxChar *psz)
|
||||||
{ if(psz) wxStringBase::operator=(psz); else Clear(); return *this; }
|
{ if(psz) wxStringBase::operator=(psz); else Clear(); return *this; }
|
||||||
#else
|
#else
|
||||||
@@ -1663,7 +1673,7 @@ public:
|
|||||||
wxString& operator+=(wchar_t ch) { return *this += wxUniChar(ch); }
|
wxString& operator+=(wchar_t ch) { return *this += wxUniChar(ch); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if !wxUSE_STL
|
#if !wxUSE_STL_BASED_WXSTRING
|
||||||
// helpers for wxStringBuffer and wxStringBufferLength
|
// helpers for wxStringBuffer and wxStringBufferLength
|
||||||
wxChar *DoGetWriteBuf(size_t nLen);
|
wxChar *DoGetWriteBuf(size_t nLen);
|
||||||
void DoUngetWriteBuf();
|
void DoUngetWriteBuf();
|
||||||
@@ -1708,22 +1718,22 @@ inline wxString operator+(wchar_t ch, const wxString& string)
|
|||||||
{ return wxUniChar(ch) + string; }
|
{ return wxUniChar(ch) + string; }
|
||||||
|
|
||||||
|
|
||||||
#if wxUSE_STL
|
#if wxUSE_STL_BASED_WXSTRING
|
||||||
// return an empty wxString (not very useful with wxUSE_STL == 1)
|
// return an empty wxString (not very useful with wxUSE_STL == 1)
|
||||||
inline const wxString wxGetEmptyString() { return wxString(); }
|
inline const wxString wxGetEmptyString() { return wxString(); }
|
||||||
#else // !wxUSE_STL
|
#else // !wxUSE_STL_BASED_WXSTRING
|
||||||
// return an empty wxString (more efficient than wxString() here)
|
// return an empty wxString (more efficient than wxString() here)
|
||||||
inline const wxString& wxGetEmptyString()
|
inline const wxString& wxGetEmptyString()
|
||||||
{
|
{
|
||||||
return *(wxString *)&wxEmptyString;
|
return *(wxString *)&wxEmptyString;
|
||||||
}
|
}
|
||||||
#endif // wxUSE_STL/!wxUSE_STL
|
#endif // wxUSE_STL_BASED_WXSTRING/!wxUSE_STL_BASED_WXSTRING
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxStringBuffer: a tiny class allowing to get a writable pointer into string
|
// wxStringBuffer: a tiny class allowing to get a writable pointer into string
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if wxUSE_STL
|
#if wxUSE_STL_BASED_WXSTRING
|
||||||
|
|
||||||
class WXDLLIMPEXP_BASE wxStringBuffer
|
class WXDLLIMPEXP_BASE wxStringBuffer
|
||||||
{
|
{
|
||||||
@@ -1776,7 +1786,7 @@ private:
|
|||||||
DECLARE_NO_COPY_CLASS(wxStringBufferLength)
|
DECLARE_NO_COPY_CLASS(wxStringBufferLength)
|
||||||
};
|
};
|
||||||
|
|
||||||
#else // if !wxUSE_STL
|
#else // if !wxUSE_STL_BASED_WXSTRING
|
||||||
|
|
||||||
class WXDLLIMPEXP_BASE wxStringBuffer
|
class WXDLLIMPEXP_BASE wxStringBuffer
|
||||||
{
|
{
|
||||||
@@ -1824,16 +1834,16 @@ private:
|
|||||||
DECLARE_NO_COPY_CLASS(wxStringBufferLength)
|
DECLARE_NO_COPY_CLASS(wxStringBufferLength)
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // !wxUSE_STL
|
#endif // !wxUSE_STL_BASED_WXSTRING
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// wxString comparison functions: operator versions are always case sensitive
|
// wxString comparison functions: operator versions are always case sensitive
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
// note that when wxUSE_STL == 1 the comparison operators taking std::string
|
// note that when wxUSE_STL_BASED_WXSTRING == 1 the comparison operators taking
|
||||||
// are used and defining them also for wxString would only result in
|
// std::string are used and defining them also for wxString would only result
|
||||||
// compilation ambiguities when comparing std::string and wxString
|
// in compilation ambiguities when comparing std::string and wxString
|
||||||
#if !wxUSE_STL
|
#if !wxUSE_STL_BASED_WXSTRING
|
||||||
|
|
||||||
inline bool operator==(const wxString& s1, const wxString& s2)
|
inline bool operator==(const wxString& s1, const wxString& s2)
|
||||||
{ return (s1.Len() == s2.Len()) && (s1.Cmp(s2) == 0); }
|
{ return (s1.Len() == s2.Len()) && (s1.Cmp(s2) == 0); }
|
||||||
@@ -1904,7 +1914,7 @@ inline wxString operator+(const wxCharBuffer& buf, const wxString& string)
|
|||||||
{ return (const char *)buf + string; }
|
{ return (const char *)buf + string; }
|
||||||
#endif // wxUSE_UNICODE/!wxUSE_UNICODE
|
#endif // wxUSE_UNICODE/!wxUSE_UNICODE
|
||||||
|
|
||||||
#endif // !wxUSE_STL
|
#endif // !wxUSE_STL_BASED_WXSTRING
|
||||||
|
|
||||||
// comparison with char (those are not defined by std::[w]string and so should
|
// comparison with char (those are not defined by std::[w]string and so should
|
||||||
// be always available)
|
// be always available)
|
||||||
|
@@ -56,7 +56,7 @@
|
|||||||
// static class variables definition
|
// static class variables definition
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
#if !wxUSE_STL
|
#if !wxUSE_STL_BASED_WXSTRING
|
||||||
//According to STL _must_ be a -1 size_t
|
//According to STL _must_ be a -1 size_t
|
||||||
const size_t wxStringBase::npos = (size_t) -1;
|
const size_t wxStringBase::npos = (size_t) -1;
|
||||||
#endif
|
#endif
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
// static data
|
// static data
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if wxUSE_STL
|
#if wxUSE_STL_BASED_WXSTRING
|
||||||
|
|
||||||
extern const wxChar WXDLLIMPEXP_BASE *wxEmptyString = _T("");
|
extern const wxChar WXDLLIMPEXP_BASE *wxEmptyString = _T("");
|
||||||
|
|
||||||
@@ -138,7 +138,7 @@ wxSTD ostream& operator<<(wxSTD ostream& os, const wxCStrData& str)
|
|||||||
#define STATISTICS_ADD(av, val)
|
#define STATISTICS_ADD(av, val)
|
||||||
#endif // WXSTRING_STATISTICS
|
#endif // WXSTRING_STATISTICS
|
||||||
|
|
||||||
#if !wxUSE_STL
|
#if !wxUSE_STL_BASED_WXSTRING
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// wxStringData class deallocation
|
// wxStringData class deallocation
|
||||||
@@ -911,11 +911,11 @@ bool wxStringBase::AllocCopy(wxString& dest, int nCopyLen, int nCopyIndex) const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !wxUSE_STL
|
#endif // !wxUSE_STL_BASED_WXSTRING
|
||||||
|
|
||||||
#if !wxUSE_STL || !defined(HAVE_STD_STRING_COMPARE)
|
#if !wxUSE_STL_BASED_WXSTRING || !defined(HAVE_STD_STRING_COMPARE)
|
||||||
|
|
||||||
#if !wxUSE_STL
|
#if !wxUSE_STL_BASED_WXSTRING
|
||||||
#define STRINGCLASS wxStringBase
|
#define STRINGCLASS wxStringBase
|
||||||
#else
|
#else
|
||||||
#define STRINGCLASS wxString
|
#define STRINGCLASS wxString
|
||||||
@@ -985,7 +985,7 @@ int STRINGCLASS::compare(size_t nStart, size_t nLen,
|
|||||||
|
|
||||||
#undef STRINGCLASS
|
#undef STRINGCLASS
|
||||||
|
|
||||||
#endif // !wxUSE_STL || !defined(HAVE_STD_STRING_COMPARE)
|
#endif // !wxUSE_STL_BASED_WXSTRING || !defined(HAVE_STD_STRING_COMPARE)
|
||||||
|
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
// wxString class core
|
// wxString class core
|
||||||
@@ -1064,7 +1064,7 @@ bool wxString::Shrink()
|
|||||||
return tmp.length() == length();
|
return tmp.length() == length();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !wxUSE_STL
|
#if !wxUSE_STL_BASED_WXSTRING
|
||||||
// get the pointer to writable buffer of (at least) nLen bytes
|
// get the pointer to writable buffer of (at least) nLen bytes
|
||||||
wxChar *wxString::DoGetWriteBuf(size_t nLen)
|
wxChar *wxString::DoGetWriteBuf(size_t nLen)
|
||||||
{
|
{
|
||||||
@@ -1157,7 +1157,7 @@ wxString& wxString::operator=(const wchar_t *pwz)
|
|||||||
|
|
||||||
wxString operator+(const wxString& str1, const wxString& str2)
|
wxString operator+(const wxString& str1, const wxString& str2)
|
||||||
{
|
{
|
||||||
#if !wxUSE_STL
|
#if !wxUSE_STL_BASED_WXSTRING
|
||||||
wxASSERT( str1.GetStringData()->IsValid() );
|
wxASSERT( str1.GetStringData()->IsValid() );
|
||||||
wxASSERT( str2.GetStringData()->IsValid() );
|
wxASSERT( str2.GetStringData()->IsValid() );
|
||||||
#endif
|
#endif
|
||||||
@@ -1170,7 +1170,7 @@ wxString operator+(const wxString& str1, const wxString& str2)
|
|||||||
|
|
||||||
wxString operator+(const wxString& str, wxUniChar ch)
|
wxString operator+(const wxString& str, wxUniChar ch)
|
||||||
{
|
{
|
||||||
#if !wxUSE_STL
|
#if !wxUSE_STL_BASED_WXSTRING
|
||||||
wxASSERT( str.GetStringData()->IsValid() );
|
wxASSERT( str.GetStringData()->IsValid() );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1182,7 +1182,7 @@ wxString operator+(const wxString& str, wxUniChar ch)
|
|||||||
|
|
||||||
wxString operator+(wxUniChar ch, const wxString& str)
|
wxString operator+(wxUniChar ch, const wxString& str)
|
||||||
{
|
{
|
||||||
#if !wxUSE_STL
|
#if !wxUSE_STL_BASED_WXSTRING
|
||||||
wxASSERT( str.GetStringData()->IsValid() );
|
wxASSERT( str.GetStringData()->IsValid() );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1194,7 +1194,7 @@ wxString operator+(wxUniChar ch, const wxString& str)
|
|||||||
|
|
||||||
wxString operator+(const wxString& str, const wxChar *psz)
|
wxString operator+(const wxString& str, const wxChar *psz)
|
||||||
{
|
{
|
||||||
#if !wxUSE_STL
|
#if !wxUSE_STL_BASED_WXSTRING
|
||||||
wxASSERT( str.GetStringData()->IsValid() );
|
wxASSERT( str.GetStringData()->IsValid() );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1210,7 +1210,7 @@ wxString operator+(const wxString& str, const wxChar *psz)
|
|||||||
|
|
||||||
wxString operator+(const wxChar *psz, const wxString& str)
|
wxString operator+(const wxChar *psz, const wxString& str)
|
||||||
{
|
{
|
||||||
#if !wxUSE_STL
|
#if !wxUSE_STL_BASED_WXSTRING
|
||||||
wxASSERT( str.GetStringData()->IsValid() );
|
wxASSERT( str.GetStringData()->IsValid() );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user