]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/string.h
Fix up NSSlider code to not use class posing and instantiate the proper type (now...
[wxWidgets.git] / include / wx / string.h
index 83d702c5bc82b54f66986ba654ebf179c7688d6f..7345c36d17daf2103951111fc402c17ee7ccb547 100644 (file)
@@ -1202,17 +1202,20 @@ public:
     // implicit conversion to C string
     operator wxCStrData() const { return c_str(); }
 
-    // these operators conflict with operators for conversion to std::string,
-    // so they must be disabled in STL build:
+    // the first two operators conflict with operators for conversion to
+    // std::string and they must be disabled in STL build; the next one only
+    // makes sense if conversions to char* are also defined and not defining it
+    // in STL build also helps us to get more clear error messages for the code
+    // which relies on implicit conversion to char* in STL build
 #if !wxUSE_STL
     operator const char*() const { return c_str(); }
     operator const wchar_t*() const { return c_str(); }
-#endif
 
     // implicit conversion to untyped pointer for compatibility with previous
     // wxWidgets versions: this is the same as conversion to const char * so it
     // may fail!
     operator const void*() const { return c_str(); }
+#endif // wxUSE_STL
 
     // identical to c_str(), for MFC compatibility
     const wxCStrData GetData() const { return c_str(); }
@@ -1235,18 +1238,25 @@ public:
     // the behaviour of these functions with the strings containing anything
     // else than 7 bit ASCII characters is undefined, use at your own risk.
 #if wxUSE_UNICODE
-    static wxString FromAscii(const char *ascii, size_t len);  // string
-    static wxString FromAscii(const char *ascii);  // string
-    static wxString FromAscii(const char ascii);   // char
+    static wxString FromAscii(const char *ascii, size_t len);
+    static wxString FromAscii(const char *ascii);
+    static wxString FromAscii(char ascii);
     const wxCharBuffer ToAscii() const;
 #else // ANSI
     static wxString FromAscii(const char *ascii) { return wxString( ascii ); }
     static wxString FromAscii(const char *ascii, size_t len)
         { return wxString( ascii, len ); }
-    static wxString FromAscii(const char ascii) { return wxString( ascii ); }
+    static wxString FromAscii(char ascii) { return wxString( ascii ); }
     const char *ToAscii() const { return c_str(); }
 #endif // Unicode/!Unicode
 
+    // also provide unsigned char overloads as signed/unsigned doesn't matter
+    // for 7 bit ASCII characters
+    static wxString FromAscii(const unsigned char *ascii)
+        { return FromAscii((const char *)ascii); }
+    static wxString FromAscii(const unsigned char *ascii, size_t len)
+        { return FromAscii((const char *)ascii, len); }
+
     // conversion to/from UTF-8:
 #if wxUSE_UNICODE_UTF8
     static wxString FromUTF8(const char *utf8)
@@ -2686,16 +2696,7 @@ inline wxString operator+(wchar_t ch, const wxString& string)
     { return wxUniChar(ch) + string; }
 
 
-#if wxUSE_STL_BASED_WXSTRING
-    // return an empty wxString (not very useful with wxUSE_STL == 1)
-    inline const wxString wxGetEmptyString() { return wxString(); }
-#else // !wxUSE_STL_BASED_WXSTRING
-    // return an empty wxString (more efficient than wxString() here)
-    inline const wxString& wxGetEmptyString()
-    {
-        return *(wxString *)&wxEmptyString;
-    }
-#endif // wxUSE_STL_BASED_WXSTRING/!wxUSE_STL_BASED_WXSTRING
+#define wxGetEmptyString() wxString()
 
 // ----------------------------------------------------------------------------
 // wxStringBuffer: a tiny class allowing to get a writable pointer into string