]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/strvararg.cpp
fix compilation in ANSI STL build
[wxWidgets.git] / src / common / strvararg.cpp
index dc59f135560423f2fe38936f0e21eaa093ce90d2..36b6af060b3fe9fe380d4a820727d5f3e3ffa14a 100644 (file)
@@ -30,6 +30,9 @@
 // implementation
 // ============================================================================
 
+// ----------------------------------------------------------------------------
+// wxArgNormalizer<>
+// ----------------------------------------------------------------------------
 
 const wxStringCharType *wxArgNormalizerNative<const wxString&>::get() const
 {
@@ -53,6 +56,10 @@ wxArgNormalizerWchar<const wxCStrData&>::wxArgNormalizerWchar(const wxCStrData&
 }
 #endif // wxUSE_UNICODE_UTF8 && !wxUSE_UTF8_LOCALE_ONLY
 
+// ----------------------------------------------------------------------------
+// wxArgNormalizedString
+// ----------------------------------------------------------------------------
+
 wxString wxArgNormalizedString::GetString() const
 {
     if ( !IsValid() )
@@ -66,7 +73,7 @@ wxString wxArgNormalizedString::GetString() const
             return wxString(wx_reinterpret_cast(const char*, m_ptr));
         else
     #endif
-        return wxString(wx_reinterpret_cast(const wchar_t*, m_ptr));
+        return wxString(wx_reinterpret_cast(const wxChar*, m_ptr));
 #endif // !wxUSE_UTF8_LOCALE_ONLY
 }
 
@@ -74,3 +81,67 @@ wxArgNormalizedString::operator wxString() const
 {
     return GetString();
 }
+
+// ----------------------------------------------------------------------------
+// wxFormatString
+// ----------------------------------------------------------------------------
+
+#if !wxUSE_UNICODE_WCHAR
+const char* wxFormatString::AsChar()
+{
+    if ( m_char )
+        return m_char.data();
+
+    // in ANSI build, wx_str() returns char*, in UTF-8 build, this function
+    // is only called under UTF-8 locales, so we should return UTF-8 string,
+    // which is, again, what wx_str() returns:
+    if ( m_str )
+        return m_str->wx_str();
+
+    // ditto wxCStrData:
+    if ( m_cstr )
+        return m_cstr->AsInternal();
+
+    // the last case is that wide string was passed in: in that case, we need
+    // to convert it:
+    wxASSERT( m_wchar );
+
+    m_char = wxConvLibc.cWC2MB(m_wchar.data());
+
+    return m_char.data();
+}
+#endif // !wxUSE_UNICODE_WCHAR
+
+#if wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY
+const wchar_t* wxFormatString::AsWChar()
+{
+    if ( m_wchar )
+        return m_wchar.data();
+
+#if wxUSE_UNICODE_WCHAR
+    if ( m_str )
+        return m_str->wc_str();
+    if ( m_cstr )
+        return m_cstr->AsInternal();
+#else // wxUSE_UNICODE_UTF8
+    if ( m_str )
+    {
+        m_wchar = m_str->wc_str();
+        return m_wchar.data();
+    }
+    if ( m_cstr )
+    {
+        m_wchar = m_cstr->AsWCharBuf();
+        return m_wchar.data();
+    }
+#endif // wxUSE_UNICODE_WCHAR/UTF8
+
+    // the last case is that narrow string was passed in: in that case, we need
+    // to convert it:
+    wxASSERT( m_char );
+
+    m_wchar = wxConvLibc.cMB2WC(m_char.data());
+
+    return m_wchar.data();
+}
+#endif // wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY