X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/acf0c9acfcbfb745a564e084d26e0405ce1bada7..c7554da8a9af5e23e0dae8dd2f0b8f85d556214e:/include/wx/string.h diff --git a/include/wx/string.h b/include/wx/string.h index 204e4be293..71d0b84807 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -51,7 +51,8 @@ #include #endif -#include "wx/wxchar.h" // for wxChar +#include "wx/wxchar.h" // for wxChar, wxStrlen() etc. +#include "wx/unichar.h" #include "wx/strvararg.h" #include "wx/buffer.h" // for wxCharBuffer #include "wx/strconv.h" // for wxConvertXXX() macros and wxMBConv classes @@ -98,17 +99,21 @@ extern WXDLLIMPEXP_DATA_BASE(const wxChar*) wxEmptyString; // strlen() and portable strcasecmp() //--------------------------------------------------------------------------- -// Use wxXXX() functions from wxchar.h instead! These functions are for +#if WXWIN_COMPATIBILITY_2_8 +// Use wxXXX() functions from wxcrt.h instead! These functions are for // backwards compatibility only. // checks whether the passed in pointer is NULL and if the string is empty +wxDEPRECATED( inline bool IsEmpty(const char *p) ); inline bool IsEmpty(const char *p) { return (!p || !*p); } // safe version of strlen() (returns 0 if passed NULL pointer) +wxDEPRECATED( inline size_t Strlen(const char *psz) ); inline size_t Strlen(const char *psz) { return psz ? strlen(psz) : 0; } // portable strcasecmp/_stricmp +wxDEPRECATED( inline int Stricmp(const char *psz1, const char *psz2) ); inline int Stricmp(const char *psz1, const char *psz2) { #if defined(__VISUALC__) && defined(__WXWINCE__) @@ -166,6 +171,8 @@ inline int Stricmp(const char *psz1, const char *psz2) #endif // OS/compiler } +#endif // WXWIN_COMPATIBILITY_2_8 + // ---------------------------------------------------------------------------- // deal with STL/non-STL/non-STL-but-wxUSE_STD_STRING // ---------------------------------------------------------------------------- @@ -785,6 +792,7 @@ public: // allow expressions like "c_str()[0]": wxUniChar operator[](int n) const { return operator[](size_t(n)); } wxUniChar operator[](size_t n) const; + wxUniChar operator[](long n) const { return operator[](size_t(n)); } #ifndef wxSIZE_T_IS_UINT wxUniChar operator[](unsigned int n) const { return operator[](size_t(n)); } #endif // size_t != unsigned int @@ -1046,6 +1054,8 @@ public: */ wxUniChar operator[](int n) const { return wxStringBase::at(n); } + wxUniChar operator[](long n) const + { return wxStringBase::at(n); } wxUniChar operator[](size_t n) const { return wxStringBase::at(n); } #ifndef wxSIZE_T_IS_UINT @@ -1056,6 +1066,8 @@ public: // operator versions of GetWriteableChar() wxUniCharRef operator[](int n) { return wxStringBase::at(n); } + wxUniCharRef operator[](long n) + { return wxStringBase::at(n); } wxUniCharRef operator[](size_t n) { return wxStringBase::at(n); } #ifndef wxSIZE_T_IS_UINT @@ -1139,6 +1151,7 @@ public: // from another wxString wxString& operator=(const wxStringBase& stringSrc) { return (wxString&)wxStringBase::operator=(stringSrc); } + wxString& operator=(const wxCStrData& cstr); // from a character wxString& operator=(wxUniChar ch) { return (wxString&)wxStringBase::operator=(ch); } @@ -2008,4 +2021,33 @@ inline wxUniChar wxCStrData::operator[](size_t n) const return m_str->at(m_offset + n); } +// ---------------------------------------------------------------------------- +// implementation of wxString inline methods using wxCStrData +// ---------------------------------------------------------------------------- + +inline wxString& wxString::operator=(const wxCStrData& cstr) +{ + return *this = cstr.AsString(); +} + +// ---------------------------------------------------------------------------- +// implementation of wx[W]CharBuffer inline methods using wxCStrData +// ---------------------------------------------------------------------------- + +#if wxUSE_UNICODE + +inline wxWCharBuffer::wxWCharBuffer(const wxCStrData& cstr) + : m_str(wxStrdupW(cstr)) +{ +} + +#else // !wxUSE_UNICODE + +inline wxCharBuffer::wxCharBuffer(const wxCStrData& cstr) + : m_str(wxStrdupA(cstr)) +{ +} + +#endif // wxUSE_UNICODE/!wxUSE_UNICODE + #endif // _WX_WXSTRINGH__