Make wxString and wxUniChar comparison operators friends too
Don't define them in the global scope to improve error messages. Also move the rest of wxString operators into the class scope.
This commit is contained in:
parent
acb24e7066
commit
09515ad4ce
4 changed files with 208 additions and 222 deletions
|
|
@ -782,19 +782,22 @@ typedef short int WXTYPE;
|
||||||
|
|
||||||
|
|
||||||
#define wxDEFINE_COMPARISON(op, T1, T2, cmp) \
|
#define wxDEFINE_COMPARISON(op, T1, T2, cmp) \
|
||||||
inline bool operator op(T1 x, T2 y) { return cmp(x, y, op); }
|
friend bool operator op(T1 x, T2 y) { return cmp(x, y, op); }
|
||||||
|
|
||||||
#define wxDEFINE_COMPARISON_REV(op, T1, T2, cmp, oprev) \
|
#define wxDEFINE_COMPARISON_REV(op, T1, T2, cmp, oprev) \
|
||||||
inline bool operator op(T2 y, T1 x) { return cmp(x, y, oprev); }
|
friend bool operator op(T2 y, T1 x) { return cmp(x, y, oprev); }
|
||||||
|
|
||||||
#define wxDEFINE_COMPARISON_BY_REV(op, T1, T2, oprev) \
|
#define wxDEFINE_COMPARISON_BY_REV(op, T1, T2, oprev) \
|
||||||
inline bool operator op(T1 x, T2 y) { return y oprev x; }
|
friend bool operator op(T1 x, T2 y) { return y oprev x; }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Define all 6 comparison operators (==, !=, <, <=, >, >=) for the given
|
Define all 6 comparison operators (==, !=, <, <=, >, >=) for the given
|
||||||
types in the specified order. The implementation is provided by the cmp
|
types in the specified order. The implementation is provided by the cmp
|
||||||
macro. Normally wxDEFINE_ALL_COMPARISONS should be used as comparison
|
macro. Normally wxDEFINE_ALL_COMPARISONS should be used as comparison
|
||||||
operators are usually symmetric.
|
operators are usually symmetric.
|
||||||
|
|
||||||
|
Note that comparison operators are defined as hidden friends and so this
|
||||||
|
macro can only be used inside the class declaration.
|
||||||
*/
|
*/
|
||||||
#define wxDEFINE_COMPARISONS(T1, T2, cmp) \
|
#define wxDEFINE_COMPARISONS(T1, T2, cmp) \
|
||||||
wxFOR_ALL_COMPARISONS_3(wxDEFINE_COMPARISON, T1, T2, cmp)
|
wxFOR_ALL_COMPARISONS_3(wxDEFINE_COMPARISON, T1, T2, cmp)
|
||||||
|
|
@ -803,6 +806,9 @@ typedef short int WXTYPE;
|
||||||
Define all 6 comparison operators (==, !=, <, <=, >, >=) for the given
|
Define all 6 comparison operators (==, !=, <, <=, >, >=) for the given
|
||||||
types in the specified order, implemented in terms of existing operators
|
types in the specified order, implemented in terms of existing operators
|
||||||
for the reverse order.
|
for the reverse order.
|
||||||
|
|
||||||
|
Note that comparison operators are defined as hidden friends and so this
|
||||||
|
macro can only be used inside the class declaration.
|
||||||
*/
|
*/
|
||||||
#define wxDEFINE_COMPARISONS_BY_REV(T1, T2) \
|
#define wxDEFINE_COMPARISONS_BY_REV(T1, T2) \
|
||||||
wxFOR_ALL_COMPARISONS_2_REV(wxDEFINE_COMPARISON_BY_REV, T1, T2)
|
wxFOR_ALL_COMPARISONS_2_REV(wxDEFINE_COMPARISON_BY_REV, T1, T2)
|
||||||
|
|
|
||||||
|
|
@ -261,6 +261,36 @@ public:
|
||||||
// "*(c_str() + 2)" work
|
// "*(c_str() + 2)" work
|
||||||
inline wxUniChar operator*() const;
|
inline wxUniChar operator*() const;
|
||||||
|
|
||||||
|
// we also need to provide the operators for comparison with wxCStrData to
|
||||||
|
// resolve ambiguity between operator(const wxChar *,const wxString &) and
|
||||||
|
// operator(const wxChar *, const wxChar *) for "p == s.c_str()"
|
||||||
|
//
|
||||||
|
// notice that these are (shallow) pointer comparisons, not (deep) string ones
|
||||||
|
#define wxCMP_CHAR_CSTRDATA(p, s, op) p op s.AsChar()
|
||||||
|
#define wxCMP_WCHAR_CSTRDATA(p, s, op) p op s.AsWChar()
|
||||||
|
|
||||||
|
wxDEFINE_ALL_COMPARISONS(const wchar_t *, const wxCStrData&, wxCMP_WCHAR_CSTRDATA)
|
||||||
|
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
|
||||||
|
wxDEFINE_ALL_COMPARISONS(const char *, const wxCStrData&, wxCMP_CHAR_CSTRDATA)
|
||||||
|
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
||||||
|
|
||||||
|
#undef wxCMP_CHAR_CSTRDATA
|
||||||
|
#undef wxCMP_WCHAR_CSTRDATA
|
||||||
|
|
||||||
|
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
|
||||||
|
// we need to define those to allow "size_t pos = p - s.c_str()" where p is
|
||||||
|
// some pointer into the string
|
||||||
|
friend size_t operator-(const char *p, const wxCStrData& cs)
|
||||||
|
{
|
||||||
|
return p - cs.AsChar();
|
||||||
|
}
|
||||||
|
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
||||||
|
|
||||||
|
friend size_t operator-(const wchar_t *p, const wxCStrData& cs)
|
||||||
|
{
|
||||||
|
return p - cs.AsWChar();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// the wxString this object was returned for
|
// the wxString this object was returned for
|
||||||
const wxString *m_str;
|
const wxString *m_str;
|
||||||
|
|
@ -2019,6 +2049,33 @@ public:
|
||||||
friend wxString WXDLLIMPEXP_BASE operator+(const wchar_t *pwz,
|
friend wxString WXDLLIMPEXP_BASE operator+(const wchar_t *pwz,
|
||||||
const wxString& string);
|
const wxString& string);
|
||||||
|
|
||||||
|
friend wxString operator+(const wxString& string, wxUniCharRef ch)
|
||||||
|
{ return string + (wxUniChar)ch; }
|
||||||
|
friend wxString operator+(const wxString& string, char ch)
|
||||||
|
{ return string + wxUniChar(ch); }
|
||||||
|
friend wxString operator+(const wxString& string, wchar_t ch)
|
||||||
|
{ return string + wxUniChar(ch); }
|
||||||
|
friend wxString operator+(wxUniCharRef ch, const wxString& string)
|
||||||
|
{ return (wxUniChar)ch + string; }
|
||||||
|
friend wxString operator+(char ch, const wxString& string)
|
||||||
|
{ return wxUniChar(ch) + string; }
|
||||||
|
friend wxString operator+(wchar_t ch, const wxString& string)
|
||||||
|
{ return wxUniChar(ch) + string; }
|
||||||
|
|
||||||
|
|
||||||
|
friend wxString operator+(const wxString& string, const wxScopedWCharBuffer& buf)
|
||||||
|
{ return string + (const wchar_t *)buf; }
|
||||||
|
friend wxString operator+(const wxScopedWCharBuffer& buf, const wxString& string)
|
||||||
|
{ return (const wchar_t *)buf + string; }
|
||||||
|
|
||||||
|
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
|
||||||
|
friend wxString operator+(const wxString& string, const wxScopedCharBuffer& buf)
|
||||||
|
{ return string + (const char *)buf; }
|
||||||
|
friend wxString operator+(const wxScopedCharBuffer& buf, const wxString& string)
|
||||||
|
{ return (const char *)buf + string; }
|
||||||
|
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
||||||
|
|
||||||
|
|
||||||
// stream-like functions
|
// stream-like functions
|
||||||
// insert an int into string
|
// insert an int into string
|
||||||
wxString& operator<<(int i)
|
wxString& operator<<(int i)
|
||||||
|
|
@ -2114,6 +2171,83 @@ public:
|
||||||
bool IsSameAs(int c, bool compareWithCase = true) const
|
bool IsSameAs(int c, bool compareWithCase = true) const
|
||||||
{ return IsSameAs(wxUniChar(c), compareWithCase); }
|
{ return IsSameAs(wxUniChar(c), compareWithCase); }
|
||||||
|
|
||||||
|
// comparison operators: these are always case sensitive
|
||||||
|
|
||||||
|
// With C strings (narrow and wide):
|
||||||
|
|
||||||
|
#define wxCMP_WXCHAR_STRING(p, s, op) 0 op s.Cmp(p)
|
||||||
|
|
||||||
|
wxDEFINE_ALL_COMPARISONS(const wchar_t *, const wxString&, wxCMP_WXCHAR_STRING)
|
||||||
|
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
|
||||||
|
wxDEFINE_ALL_COMPARISONS(const char *, const wxString&, wxCMP_WXCHAR_STRING)
|
||||||
|
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
||||||
|
|
||||||
|
#undef wxCMP_WXCHAR_STRING
|
||||||
|
|
||||||
|
// With wxString itself and related types.
|
||||||
|
friend bool operator==(const wxString& s1, const wxString& s2)
|
||||||
|
{ return s1.IsSameAs(s2); }
|
||||||
|
friend bool operator!=(const wxString& s1, const wxString& s2)
|
||||||
|
{ return !s1.IsSameAs(s2); }
|
||||||
|
friend bool operator< (const wxString& s1, const wxString& s2)
|
||||||
|
{ return s1.Cmp(s2) < 0; }
|
||||||
|
friend bool operator> (const wxString& s1, const wxString& s2)
|
||||||
|
{ return s1.Cmp(s2) > 0; }
|
||||||
|
friend bool operator<=(const wxString& s1, const wxString& s2)
|
||||||
|
{ return s1.Cmp(s2) <= 0; }
|
||||||
|
friend bool operator>=(const wxString& s1, const wxString& s2)
|
||||||
|
{ return s1.Cmp(s2) >= 0; }
|
||||||
|
|
||||||
|
friend bool operator==(const wxString& s1, const wxCStrData& s2)
|
||||||
|
{ return s1 == s2.AsString(); }
|
||||||
|
friend bool operator==(const wxCStrData& s1, const wxString& s2)
|
||||||
|
{ return s1.AsString() == s2; }
|
||||||
|
friend bool operator!=(const wxString& s1, const wxCStrData& s2)
|
||||||
|
{ return s1 != s2.AsString(); }
|
||||||
|
friend bool operator!=(const wxCStrData& s1, const wxString& s2)
|
||||||
|
{ return s1.AsString() != s2; }
|
||||||
|
|
||||||
|
friend bool operator==(const wxString& s1, const wxScopedWCharBuffer& s2)
|
||||||
|
{ return (s1.Cmp((const wchar_t *)s2) == 0); }
|
||||||
|
friend bool operator==(const wxScopedWCharBuffer& s1, const wxString& s2)
|
||||||
|
{ return (s2.Cmp((const wchar_t *)s1) == 0); }
|
||||||
|
friend bool operator!=(const wxString& s1, const wxScopedWCharBuffer& s2)
|
||||||
|
{ return (s1.Cmp((const wchar_t *)s2) != 0); }
|
||||||
|
friend bool operator!=(const wxScopedWCharBuffer& s1, const wxString& s2)
|
||||||
|
{ return (s2.Cmp((const wchar_t *)s1) != 0); }
|
||||||
|
|
||||||
|
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
|
||||||
|
friend bool operator==(const wxString& s1, const wxScopedCharBuffer& s2)
|
||||||
|
{ return (s1.Cmp((const char *)s2) == 0); }
|
||||||
|
friend bool operator==(const wxScopedCharBuffer& s1, const wxString& s2)
|
||||||
|
{ return (s2.Cmp((const char *)s1) == 0); }
|
||||||
|
friend bool operator!=(const wxString& s1, const wxScopedCharBuffer& s2)
|
||||||
|
{ return (s1.Cmp((const char *)s2) != 0); }
|
||||||
|
friend bool operator!=(const wxScopedCharBuffer& s1, const wxString& s2)
|
||||||
|
{ return (s2.Cmp((const char *)s1) != 0); }
|
||||||
|
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
||||||
|
|
||||||
|
// comparison with char
|
||||||
|
friend bool operator==(const wxUniChar& c, const wxString& s) { return s.IsSameAs(c); }
|
||||||
|
friend bool operator==(const wxUniCharRef& c, const wxString& s) { return s.IsSameAs(c); }
|
||||||
|
friend bool operator==(char c, const wxString& s) { return s.IsSameAs(c); }
|
||||||
|
friend bool operator==(wchar_t c, const wxString& s) { return s.IsSameAs(c); }
|
||||||
|
friend bool operator==(int c, const wxString& s) { return s.IsSameAs(c); }
|
||||||
|
friend bool operator==(const wxString& s, const wxUniChar& c) { return s.IsSameAs(c); }
|
||||||
|
friend bool operator==(const wxString& s, const wxUniCharRef& c) { return s.IsSameAs(c); }
|
||||||
|
friend bool operator==(const wxString& s, char c) { return s.IsSameAs(c); }
|
||||||
|
friend bool operator==(const wxString& s, wchar_t c) { return s.IsSameAs(c); }
|
||||||
|
friend bool operator!=(const wxUniChar& c, const wxString& s) { return !s.IsSameAs(c); }
|
||||||
|
friend bool operator!=(const wxUniCharRef& c, const wxString& s) { return !s.IsSameAs(c); }
|
||||||
|
friend bool operator!=(char c, const wxString& s) { return !s.IsSameAs(c); }
|
||||||
|
friend bool operator!=(wchar_t c, const wxString& s) { return !s.IsSameAs(c); }
|
||||||
|
friend bool operator!=(int c, const wxString& s) { return !s.IsSameAs(c); }
|
||||||
|
friend bool operator!=(const wxString& s, const wxUniChar& c) { return !s.IsSameAs(c); }
|
||||||
|
friend bool operator!=(const wxString& s, const wxUniCharRef& c) { return !s.IsSameAs(c); }
|
||||||
|
friend bool operator!=(const wxString& s, char c) { return !s.IsSameAs(c); }
|
||||||
|
friend bool operator!=(const wxString& s, wchar_t c) { return !s.IsSameAs(c); }
|
||||||
|
|
||||||
|
|
||||||
// simple sub-string extraction
|
// simple sub-string extraction
|
||||||
// return substring starting at nFirst of length nCount (or till the end
|
// return substring starting at nFirst of length nCount (or till the end
|
||||||
// if nCount = default value)
|
// if nCount = default value)
|
||||||
|
|
@ -3637,37 +3771,6 @@ inline wxString::reverse_iterator operator+(ptrdiff_t n, wxString::reverse_itera
|
||||||
inline wxString::const_reverse_iterator operator+(ptrdiff_t n, wxString::const_reverse_iterator i)
|
inline wxString::const_reverse_iterator operator+(ptrdiff_t n, wxString::const_reverse_iterator i)
|
||||||
{ return i + n; }
|
{ return i + n; }
|
||||||
|
|
||||||
// notice that even though for many compilers the friend declarations above are
|
|
||||||
// enough, from the point of view of C++ standard we must have the declarations
|
|
||||||
// here as friend ones are not injected in the enclosing namespace and without
|
|
||||||
// them the code fails to compile with conforming compilers such as xlC or g++4
|
|
||||||
wxString WXDLLIMPEXP_BASE operator+(const wxString& string1, const wxString& string2);
|
|
||||||
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
|
|
||||||
wxString WXDLLIMPEXP_BASE operator+(const wxString& string, const char *psz);
|
|
||||||
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
|
||||||
wxString WXDLLIMPEXP_BASE operator+(const wxString& string, const wchar_t *pwz);
|
|
||||||
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
|
|
||||||
wxString WXDLLIMPEXP_BASE operator+(const char *psz, const wxString& string);
|
|
||||||
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
|
||||||
wxString WXDLLIMPEXP_BASE operator+(const wchar_t *pwz, const wxString& string);
|
|
||||||
|
|
||||||
wxString WXDLLIMPEXP_BASE operator+(const wxString& string, wxUniChar ch);
|
|
||||||
wxString WXDLLIMPEXP_BASE operator+(wxUniChar ch, const wxString& string);
|
|
||||||
|
|
||||||
inline wxString operator+(const wxString& string, wxUniCharRef ch)
|
|
||||||
{ return string + (wxUniChar)ch; }
|
|
||||||
inline wxString operator+(const wxString& string, char ch)
|
|
||||||
{ return string + wxUniChar(ch); }
|
|
||||||
inline wxString operator+(const wxString& string, wchar_t ch)
|
|
||||||
{ return string + wxUniChar(ch); }
|
|
||||||
inline wxString operator+(wxUniCharRef ch, const wxString& string)
|
|
||||||
{ return (wxUniChar)ch + string; }
|
|
||||||
inline wxString operator+(char ch, const wxString& string)
|
|
||||||
{ return wxUniChar(ch) + string; }
|
|
||||||
inline wxString operator+(wchar_t ch, const wxString& string)
|
|
||||||
{ return wxUniChar(ch) + string; }
|
|
||||||
|
|
||||||
|
|
||||||
#define wxGetEmptyString() wxString()
|
#define wxGetEmptyString() wxString()
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
@ -4005,95 +4108,9 @@ public:
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// wxString comparison functions: operator versions are always case sensitive
|
// wxString iterators comparisons
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
// comparison with C-style narrow and wide strings.
|
|
||||||
#define wxCMP_WXCHAR_STRING(p, s, op) 0 op s.Cmp(p)
|
|
||||||
|
|
||||||
wxDEFINE_ALL_COMPARISONS(const wchar_t *, const wxString&, wxCMP_WXCHAR_STRING)
|
|
||||||
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
|
|
||||||
wxDEFINE_ALL_COMPARISONS(const char *, const wxString&, wxCMP_WXCHAR_STRING)
|
|
||||||
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
|
||||||
|
|
||||||
#undef wxCMP_WXCHAR_STRING
|
|
||||||
|
|
||||||
inline bool operator==(const wxString& s1, const wxString& s2)
|
|
||||||
{ return s1.IsSameAs(s2); }
|
|
||||||
inline bool operator!=(const wxString& s1, const wxString& s2)
|
|
||||||
{ return !s1.IsSameAs(s2); }
|
|
||||||
inline bool operator< (const wxString& s1, const wxString& s2)
|
|
||||||
{ return s1.Cmp(s2) < 0; }
|
|
||||||
inline bool operator> (const wxString& s1, const wxString& s2)
|
|
||||||
{ return s1.Cmp(s2) > 0; }
|
|
||||||
inline bool operator<=(const wxString& s1, const wxString& s2)
|
|
||||||
{ return s1.Cmp(s2) <= 0; }
|
|
||||||
inline bool operator>=(const wxString& s1, const wxString& s2)
|
|
||||||
{ return s1.Cmp(s2) >= 0; }
|
|
||||||
|
|
||||||
inline bool operator==(const wxString& s1, const wxCStrData& s2)
|
|
||||||
{ return s1 == s2.AsString(); }
|
|
||||||
inline bool operator==(const wxCStrData& s1, const wxString& s2)
|
|
||||||
{ return s1.AsString() == s2; }
|
|
||||||
inline bool operator!=(const wxString& s1, const wxCStrData& s2)
|
|
||||||
{ return s1 != s2.AsString(); }
|
|
||||||
inline bool operator!=(const wxCStrData& s1, const wxString& s2)
|
|
||||||
{ return s1.AsString() != s2; }
|
|
||||||
|
|
||||||
inline bool operator==(const wxString& s1, const wxScopedWCharBuffer& s2)
|
|
||||||
{ return (s1.Cmp((const wchar_t *)s2) == 0); }
|
|
||||||
inline bool operator==(const wxScopedWCharBuffer& s1, const wxString& s2)
|
|
||||||
{ return (s2.Cmp((const wchar_t *)s1) == 0); }
|
|
||||||
inline bool operator!=(const wxString& s1, const wxScopedWCharBuffer& s2)
|
|
||||||
{ return (s1.Cmp((const wchar_t *)s2) != 0); }
|
|
||||||
inline bool operator!=(const wxScopedWCharBuffer& s1, const wxString& s2)
|
|
||||||
{ return (s2.Cmp((const wchar_t *)s1) != 0); }
|
|
||||||
|
|
||||||
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
|
|
||||||
inline bool operator==(const wxString& s1, const wxScopedCharBuffer& s2)
|
|
||||||
{ return (s1.Cmp((const char *)s2) == 0); }
|
|
||||||
inline bool operator==(const wxScopedCharBuffer& s1, const wxString& s2)
|
|
||||||
{ return (s2.Cmp((const char *)s1) == 0); }
|
|
||||||
inline bool operator!=(const wxString& s1, const wxScopedCharBuffer& s2)
|
|
||||||
{ return (s1.Cmp((const char *)s2) != 0); }
|
|
||||||
inline bool operator!=(const wxScopedCharBuffer& s1, const wxString& s2)
|
|
||||||
{ return (s2.Cmp((const char *)s1) != 0); }
|
|
||||||
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
|
||||||
|
|
||||||
inline wxString operator+(const wxString& string, const wxScopedWCharBuffer& buf)
|
|
||||||
{ return string + (const wchar_t *)buf; }
|
|
||||||
inline wxString operator+(const wxScopedWCharBuffer& buf, const wxString& string)
|
|
||||||
{ return (const wchar_t *)buf + string; }
|
|
||||||
|
|
||||||
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
|
|
||||||
inline wxString operator+(const wxString& string, const wxScopedCharBuffer& buf)
|
|
||||||
{ return string + (const char *)buf; }
|
|
||||||
inline wxString operator+(const wxScopedCharBuffer& buf, const wxString& string)
|
|
||||||
{ return (const char *)buf + string; }
|
|
||||||
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
|
||||||
|
|
||||||
// comparison with char
|
|
||||||
inline bool operator==(const wxUniChar& c, const wxString& s) { return s.IsSameAs(c); }
|
|
||||||
inline bool operator==(const wxUniCharRef& c, const wxString& s) { return s.IsSameAs(c); }
|
|
||||||
inline bool operator==(char c, const wxString& s) { return s.IsSameAs(c); }
|
|
||||||
inline bool operator==(wchar_t c, const wxString& s) { return s.IsSameAs(c); }
|
|
||||||
inline bool operator==(int c, const wxString& s) { return s.IsSameAs(c); }
|
|
||||||
inline bool operator==(const wxString& s, const wxUniChar& c) { return s.IsSameAs(c); }
|
|
||||||
inline bool operator==(const wxString& s, const wxUniCharRef& c) { return s.IsSameAs(c); }
|
|
||||||
inline bool operator==(const wxString& s, char c) { return s.IsSameAs(c); }
|
|
||||||
inline bool operator==(const wxString& s, wchar_t c) { return s.IsSameAs(c); }
|
|
||||||
inline bool operator!=(const wxUniChar& c, const wxString& s) { return !s.IsSameAs(c); }
|
|
||||||
inline bool operator!=(const wxUniCharRef& c, const wxString& s) { return !s.IsSameAs(c); }
|
|
||||||
inline bool operator!=(char c, const wxString& s) { return !s.IsSameAs(c); }
|
|
||||||
inline bool operator!=(wchar_t c, const wxString& s) { return !s.IsSameAs(c); }
|
|
||||||
inline bool operator!=(int c, const wxString& s) { return !s.IsSameAs(c); }
|
|
||||||
inline bool operator!=(const wxString& s, const wxUniChar& c) { return !s.IsSameAs(c); }
|
|
||||||
inline bool operator!=(const wxString& s, const wxUniCharRef& c) { return !s.IsSameAs(c); }
|
|
||||||
inline bool operator!=(const wxString& s, char c) { return !s.IsSameAs(c); }
|
|
||||||
inline bool operator!=(const wxString& s, wchar_t c) { return !s.IsSameAs(c); }
|
|
||||||
|
|
||||||
|
|
||||||
// wxString iterators comparisons
|
|
||||||
inline bool wxString::const_iterator::operator==(const iterator& i) const
|
inline bool wxString::const_iterator::operator==(const iterator& i) const
|
||||||
{ return *this == const_iterator(i); }
|
{ return *this == const_iterator(i); }
|
||||||
inline bool wxString::const_iterator::operator!=(const iterator& i) const
|
inline bool wxString::const_iterator::operator!=(const iterator& i) const
|
||||||
|
|
@ -4120,22 +4137,6 @@ inline bool wxString::iterator::operator<=(const const_iterator& i) const
|
||||||
inline bool wxString::iterator::operator>=(const const_iterator& i) const
|
inline bool wxString::iterator::operator>=(const const_iterator& i) const
|
||||||
{ return i <= *this; }
|
{ return i <= *this; }
|
||||||
|
|
||||||
// we also need to provide the operators for comparison with wxCStrData to
|
|
||||||
// resolve ambiguity between operator(const wxChar *,const wxString &) and
|
|
||||||
// operator(const wxChar *, const wxChar *) for "p == s.c_str()"
|
|
||||||
//
|
|
||||||
// notice that these are (shallow) pointer comparisons, not (deep) string ones
|
|
||||||
#define wxCMP_CHAR_CSTRDATA(p, s, op) p op s.AsChar()
|
|
||||||
#define wxCMP_WCHAR_CSTRDATA(p, s, op) p op s.AsWChar()
|
|
||||||
|
|
||||||
wxDEFINE_ALL_COMPARISONS(const wchar_t *, const wxCStrData&, wxCMP_WCHAR_CSTRDATA)
|
|
||||||
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
|
|
||||||
wxDEFINE_ALL_COMPARISONS(const char *, const wxCStrData&, wxCMP_CHAR_CSTRDATA)
|
|
||||||
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
|
||||||
|
|
||||||
#undef wxCMP_CHAR_CSTRDATA
|
|
||||||
#undef wxCMP_WCHAR_CSTRDATA
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Implement hashing using C++11 std::hash<>.
|
// Implement hashing using C++11 std::hash<>.
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
@ -4264,24 +4265,6 @@ inline wxUniChar wxCStrData::operator[](size_t n) const
|
||||||
return (*m_str)[m_offset + n];
|
return (*m_str)[m_offset + n];
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// more wxCStrData operators
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING
|
|
||||||
// we need to define those to allow "size_t pos = p - s.c_str()" where p is
|
|
||||||
// some pointer into the string
|
|
||||||
inline size_t operator-(const char *p, const wxCStrData& cs)
|
|
||||||
{
|
|
||||||
return p - cs.AsChar();
|
|
||||||
}
|
|
||||||
#endif // wxNO_IMPLICIT_WXSTRING_ENCODING
|
|
||||||
|
|
||||||
inline size_t operator-(const wchar_t *p, const wxCStrData& cs)
|
|
||||||
{
|
|
||||||
return p - cs.AsWChar();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// implementation of wx[W]CharBuffer inline methods using wxCStrData
|
// implementation of wx[W]CharBuffer inline methods using wxCStrData
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -162,6 +162,9 @@ public:
|
||||||
#undef wxDEFINE_UNICHAR_OPERATOR
|
#undef wxDEFINE_UNICHAR_OPERATOR
|
||||||
#undef wxDEFINE_UNCHAR_CMP_WITH_INT
|
#undef wxDEFINE_UNCHAR_CMP_WITH_INT
|
||||||
|
|
||||||
|
wxDEFINE_COMPARISONS_BY_REV(char, const wxUniChar&)
|
||||||
|
wxDEFINE_COMPARISONS_BY_REV(wchar_t, const wxUniChar&)
|
||||||
|
|
||||||
// this is needed for expressions like 'Z'-c
|
// this is needed for expressions like 'Z'-c
|
||||||
int operator-(const wxUniChar& c) const { return m_value - c.m_value; }
|
int operator-(const wxUniChar& c) const { return m_value - c.m_value; }
|
||||||
int operator-(char c) const { return m_value - From8bit(c); }
|
int operator-(char c) const { return m_value - From8bit(c); }
|
||||||
|
|
@ -290,12 +293,23 @@ public:
|
||||||
#undef wxDEFINE_UNICHARREF_OPERATOR
|
#undef wxDEFINE_UNICHARREF_OPERATOR
|
||||||
#undef wxDEFINE_UNICHARREF_CMP_WITH_INT
|
#undef wxDEFINE_UNICHARREF_CMP_WITH_INT
|
||||||
|
|
||||||
|
// Comparison operators for the case when wxUniChar(Ref) is the second
|
||||||
|
// operand implemented in terms of member comparison functions
|
||||||
|
wxDEFINE_COMPARISONS_BY_REV(char, const wxUniCharRef&)
|
||||||
|
wxDEFINE_COMPARISONS_BY_REV(wchar_t, const wxUniCharRef&)
|
||||||
|
|
||||||
|
wxDEFINE_COMPARISONS_BY_REV(const wxUniChar&, const wxUniCharRef&)
|
||||||
|
|
||||||
// for expressions like c-'A':
|
// for expressions like c-'A':
|
||||||
int operator-(const wxUniCharRef& c) const { return UniChar() - c.UniChar(); }
|
int operator-(const wxUniCharRef& c) const { return UniChar() - c.UniChar(); }
|
||||||
int operator-(const wxUniChar& c) const { return UniChar() - c; }
|
int operator-(const wxUniChar& c) const { return UniChar() - c; }
|
||||||
int operator-(char c) const { return UniChar() - c; }
|
int operator-(char c) const { return UniChar() - c; }
|
||||||
int operator-(unsigned char c) const { return UniChar() - c; }
|
int operator-(unsigned char c) const { return UniChar() - c; }
|
||||||
int operator-(wchar_t c) const { return UniChar() - c; }
|
int operator-(wchar_t c) const { return UniChar() - c; }
|
||||||
|
friend int operator-(char c1, const wxUniCharRef& c2) { return -(c2 - c1); }
|
||||||
|
friend int operator-(const wxUniChar& c1, const wxUniCharRef& c2) { return -(c2 - c1); }
|
||||||
|
friend int operator-(wchar_t c1, const wxUniCharRef& c2) { return -(c2 - c1); }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if wxUSE_UNICODE_UTF8
|
#if wxUSE_UNICODE_UTF8
|
||||||
|
|
@ -365,21 +379,4 @@ void swap(wxUniCharRef&& lhs, wxUniCharRef&& rhs)
|
||||||
rhs = tmp;
|
rhs = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Comparison operators for the case when wxUniChar(Ref) is the second operand
|
|
||||||
// implemented in terms of member comparison functions
|
|
||||||
|
|
||||||
wxDEFINE_COMPARISONS_BY_REV(char, const wxUniChar&)
|
|
||||||
wxDEFINE_COMPARISONS_BY_REV(char, const wxUniCharRef&)
|
|
||||||
|
|
||||||
wxDEFINE_COMPARISONS_BY_REV(wchar_t, const wxUniChar&)
|
|
||||||
wxDEFINE_COMPARISONS_BY_REV(wchar_t, const wxUniCharRef&)
|
|
||||||
|
|
||||||
wxDEFINE_COMPARISONS_BY_REV(const wxUniChar&, const wxUniCharRef&)
|
|
||||||
|
|
||||||
// for expressions like c-'A':
|
|
||||||
inline int operator-(char c1, const wxUniCharRef& c2) { return -(c2 - c1); }
|
|
||||||
inline int operator-(const wxUniChar& c1, const wxUniCharRef& c2) { return -(c2 - c1); }
|
|
||||||
inline int operator-(wchar_t c1, const wxUniCharRef& c2) { return -(c2 - c1); }
|
|
||||||
|
|
||||||
#endif /* _WX_UNICHAR_H_ */
|
#endif /* _WX_UNICHAR_H_ */
|
||||||
|
|
|
||||||
|
|
@ -911,12 +911,12 @@ public:
|
||||||
/**
|
/**
|
||||||
Concatenation: returns a new string equal to the concatenation of the operands.
|
Concatenation: returns a new string equal to the concatenation of the operands.
|
||||||
*/
|
*/
|
||||||
wxString operator +(const wxString& x, const wxString& y);
|
friend wxString operator +(const wxString& x, const wxString& y);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@overload
|
@overload
|
||||||
*/
|
*/
|
||||||
wxString operator +(const wxString& x, wxUniChar y);
|
friend wxString operator +(const wxString& x, wxUniChar y);
|
||||||
|
|
||||||
wxString& operator<<(const wxString& s);
|
wxString& operator<<(const wxString& s);
|
||||||
wxString& operator<<(const char* psz);
|
wxString& operator<<(const char* psz);
|
||||||
|
|
@ -1015,6 +1015,54 @@ public:
|
||||||
*/
|
*/
|
||||||
bool IsSameAs(wxUniChar ch, bool caseSensitive = true) const;
|
bool IsSameAs(wxUniChar ch, bool caseSensitive = true) const;
|
||||||
|
|
||||||
|
///@{
|
||||||
|
/**
|
||||||
|
Comparison operator for string types.
|
||||||
|
*/
|
||||||
|
friend bool operator==(const wxString& s1, const wxString& s2);
|
||||||
|
friend bool operator!=(const wxString& s1, const wxString& s2);
|
||||||
|
friend bool operator< (const wxString& s1, const wxString& s2);
|
||||||
|
friend bool operator> (const wxString& s1, const wxString& s2);
|
||||||
|
friend bool operator<=(const wxString& s1, const wxString& s2);
|
||||||
|
friend bool operator>=(const wxString& s1, const wxString& s2);
|
||||||
|
friend bool operator==(const wxString& s1, const wxCStrData& s2);
|
||||||
|
friend bool operator==(const wxCStrData& s1, const wxString& s2);
|
||||||
|
friend bool operator!=(const wxString& s1, const wxCStrData& s2);
|
||||||
|
friend bool operator!=(const wxCStrData& s1, const wxString& s2);
|
||||||
|
friend bool operator==(const wxString& s1, const wxWCharBuffer& s2);
|
||||||
|
friend bool operator==(const wxWCharBuffer& s1, const wxString& s2);
|
||||||
|
friend bool operator!=(const wxString& s1, const wxWCharBuffer& s2);
|
||||||
|
friend bool operator!=(const wxWCharBuffer& s1, const wxString& s2);
|
||||||
|
friend bool operator==(const wxString& s1, const wxCharBuffer& s2);
|
||||||
|
friend bool operator==(const wxCharBuffer& s1, const wxString& s2);
|
||||||
|
friend bool operator!=(const wxString& s1, const wxCharBuffer& s2);
|
||||||
|
friend bool operator!=(const wxCharBuffer& s1, const wxString& s2);
|
||||||
|
///@}
|
||||||
|
|
||||||
|
///@{
|
||||||
|
/**
|
||||||
|
Comparison operators char types.
|
||||||
|
*/
|
||||||
|
friend bool operator==(const wxUniChar& c, const wxString& s);
|
||||||
|
friend bool operator==(const wxUniCharRef& c, const wxString& s);
|
||||||
|
friend bool operator==(char c, const wxString& s);
|
||||||
|
friend bool operator==(wchar_t c, const wxString& s);
|
||||||
|
friend bool operator==(int c, const wxString& s);
|
||||||
|
friend bool operator==(const wxString& s, const wxUniChar& c);
|
||||||
|
friend bool operator==(const wxString& s, const wxUniCharRef& c);
|
||||||
|
friend bool operator==(const wxString& s, char c);
|
||||||
|
friend bool operator==(const wxString& s, wchar_t c);
|
||||||
|
friend bool operator!=(const wxUniChar& c, const wxString& s);
|
||||||
|
friend bool operator!=(const wxUniCharRef& c, const wxString& s);
|
||||||
|
friend bool operator!=(char c, const wxString& s);
|
||||||
|
friend bool operator!=(wchar_t c, const wxString& s);
|
||||||
|
friend bool operator!=(int c, const wxString& s);
|
||||||
|
friend bool operator!=(const wxString& s, const wxUniChar& c);
|
||||||
|
friend bool operator!=(const wxString& s, const wxUniCharRef& c);
|
||||||
|
friend bool operator!=(const wxString& s, char c);
|
||||||
|
friend bool operator!=(const wxString& s, wchar_t c);
|
||||||
|
///@}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns @true if the string contents matches a mask containing '*' and '?'.
|
Returns @true if the string contents matches a mask containing '*' and '?'.
|
||||||
*/
|
*/
|
||||||
|
|
@ -1999,54 +2047,6 @@ public:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///@{
|
|
||||||
/**
|
|
||||||
Comparison operator for string types.
|
|
||||||
*/
|
|
||||||
inline bool operator==(const wxString& s1, const wxString& s2);
|
|
||||||
inline bool operator!=(const wxString& s1, const wxString& s2);
|
|
||||||
inline bool operator< (const wxString& s1, const wxString& s2);
|
|
||||||
inline bool operator> (const wxString& s1, const wxString& s2);
|
|
||||||
inline bool operator<=(const wxString& s1, const wxString& s2);
|
|
||||||
inline bool operator>=(const wxString& s1, const wxString& s2);
|
|
||||||
inline bool operator==(const wxString& s1, const wxCStrData& s2);
|
|
||||||
inline bool operator==(const wxCStrData& s1, const wxString& s2);
|
|
||||||
inline bool operator!=(const wxString& s1, const wxCStrData& s2);
|
|
||||||
inline bool operator!=(const wxCStrData& s1, const wxString& s2);
|
|
||||||
inline bool operator==(const wxString& s1, const wxWCharBuffer& s2);
|
|
||||||
inline bool operator==(const wxWCharBuffer& s1, const wxString& s2);
|
|
||||||
inline bool operator!=(const wxString& s1, const wxWCharBuffer& s2);
|
|
||||||
inline bool operator!=(const wxWCharBuffer& s1, const wxString& s2);
|
|
||||||
inline bool operator==(const wxString& s1, const wxCharBuffer& s2);
|
|
||||||
inline bool operator==(const wxCharBuffer& s1, const wxString& s2);
|
|
||||||
inline bool operator!=(const wxString& s1, const wxCharBuffer& s2);
|
|
||||||
inline bool operator!=(const wxCharBuffer& s1, const wxString& s2);
|
|
||||||
///@}
|
|
||||||
|
|
||||||
///@{
|
|
||||||
/**
|
|
||||||
Comparison operators char types.
|
|
||||||
*/
|
|
||||||
inline bool operator==(const wxUniChar& c, const wxString& s);
|
|
||||||
inline bool operator==(const wxUniCharRef& c, const wxString& s);
|
|
||||||
inline bool operator==(char c, const wxString& s);
|
|
||||||
inline bool operator==(wchar_t c, const wxString& s);
|
|
||||||
inline bool operator==(int c, const wxString& s);
|
|
||||||
inline bool operator==(const wxString& s, const wxUniChar& c);
|
|
||||||
inline bool operator==(const wxString& s, const wxUniCharRef& c);
|
|
||||||
inline bool operator==(const wxString& s, char c);
|
|
||||||
inline bool operator==(const wxString& s, wchar_t c);
|
|
||||||
inline bool operator!=(const wxUniChar& c, const wxString& s);
|
|
||||||
inline bool operator!=(const wxUniCharRef& c, const wxString& s);
|
|
||||||
inline bool operator!=(char c, const wxString& s);
|
|
||||||
inline bool operator!=(wchar_t c, const wxString& s);
|
|
||||||
inline bool operator!=(int c, const wxString& s);
|
|
||||||
inline bool operator!=(const wxString& s, const wxUniChar& c);
|
|
||||||
inline bool operator!=(const wxString& s, const wxUniCharRef& c);
|
|
||||||
inline bool operator!=(const wxString& s, char c);
|
|
||||||
inline bool operator!=(const wxString& s, wchar_t c);
|
|
||||||
///@}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The global wxString instance of an empty string.
|
The global wxString instance of an empty string.
|
||||||
Used extensively in the entire wxWidgets API.
|
Used extensively in the entire wxWidgets API.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue