]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/unichar.h
PCH-less compilation fix
[wxWidgets.git] / include / wx / unichar.h
index 3abf1807cd5b88a915bb08c4e11f7d1944a001f3..e9645cfcabfe43d2552f2186ddb8beeac8e51f08 100644 (file)
@@ -13,6 +13,7 @@
 
 #include "wx/defs.h"
 #include "wx/chartype.h"
+#include "wx/stringimpl.h"
 
 class WXDLLIMPEXP_BASE wxUniCharRef;
 
@@ -43,12 +44,22 @@ public:
     // Returns Unicode code point value of the character
     value_type GetValue() const { return m_value; }
 
-    // Casts to char and wchar_t types:
+    // Conversions to char and wchar_t types: all of those are needed to be
+    // able to pass wxUniChars to verious standard narrow and wide character
+    // functions
     operator char() const { return To8bit(m_value); }
-    operator unsigned char() const { return (unsigned char)To8bit(m_value); }
     operator wchar_t() const { return m_value; }
     operator int() const { return m_value; }
-    operator unsigned int() const { return m_value; }
+
+    // More conversions needed for other standard functions: uchar is for VC++
+    // _mbxxx() ones (to which toxxx/isxxx() are mapped when _MBCS is defined)
+    // and some wide character functions take wint_t which happens to be the
+    // same as wchar_t for Windows compilers but not for g++ (except for the
+    // special Apple version)
+    operator unsigned char() const { return (unsigned char)To8bit(m_value); }
+#if defined(__GNUC__) && !defined(__DARWIN__)
+    operator wint_t() const { return m_value; }
+#endif
 
     // We need this operator for the "*p" part of expressions like "for (
     // const_iterator p = begin() + nStart; *p; ++p )". In this case,
@@ -102,9 +113,10 @@ private:
 class WXDLLIMPEXP_BASE wxUniCharRef
 {
 private:
+    typedef wxStringImpl::iterator iterator;
+
     // create the reference
-    // FIXME-UTF8: the interface will need changes for UTF-8 build
-    wxUniCharRef(wxChar *pos) : m_pos(pos) {}
+    wxUniCharRef(iterator pos) : m_pos(pos) {}
 
 public:
     // NB: we have to make this public, because we don't have wxString
@@ -112,9 +124,7 @@ public:
     //     as friend; so at least don't use a ctor but a static function
     //     that must be used explicitly (this is more than using 'explicit'
     //     keyword on ctor!):
-    //
-    // FIXME-UTF8: the interface will need changes for UTF-8 build
-    static wxUniCharRef CreateForString(wxChar *pos)
+    static wxUniCharRef CreateForString(iterator pos)
         { return wxUniCharRef(pos); }
 
     wxUniChar::value_type GetValue() const { return UniChar().GetValue(); }
@@ -135,12 +145,14 @@ public:
     wxUniCharRef& operator=(char c) { return *this = wxUniChar(c); }
     wxUniCharRef& operator=(wchar_t c) { return *this = wxUniChar(c); }
 
-    // Casts to wxUniChar type:
+    // Conversions to the same types as wxUniChar is convertible too:
     operator char() const { return UniChar(); }
-    operator unsigned char() const { return UniChar(); }
     operator wchar_t() const { return UniChar(); }
     operator int() const { return UniChar(); }
-    operator unsigned int() const { return UniChar(); }
+    operator unsigned char() const { return UniChar(); }
+#if defined(__GNUC__) && !defined(__DARWIN__)
+    operator wint_t() const { return UniChar(); }
+#endif
 
     // see wxUniChar::operator bool etc. for explanation
     operator bool() const { return (bool)UniChar(); }
@@ -173,7 +185,7 @@ private:
 
 private:
     // pointer to the character in string
-    wxChar *m_pos;
+    iterator m_pos;
 };
 
 inline wxUniChar::wxUniChar(const wxUniCharRef& c)