X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9183da066e07f3e9105bf4cec9e3e8c1ddb04b72..80255b7eaf9427daf6fa21a3f27e4475dcc54cf8:/include/wx/strvararg.h?ds=sidebyside diff --git a/include/wx/strvararg.h b/include/wx/strvararg.h index 4cbe39b3aa..e81a083a61 100644 --- a/include/wx/strvararg.h +++ b/include/wx/strvararg.h @@ -154,11 +154,15 @@ public: // n-th variadic argument desired representation ArgumentType GetArgumentType(unsigned n) const; + // returns the value passed to ctor, only converted to wxString, similarly + // to other InputAsXXX() methods + wxString InputAsString() const; + #if !wxUSE_UNICODE_WCHAR operator const char*() const - { return wx_const_cast(wxFormatString*, this)->AsChar(); } + { return const_cast(this)->AsChar(); } private: - // InputAsChar() returns the value converted passed to ctor, only converted + // InputAsChar() returns the value passed to ctor, only converted // to char, while AsChar() takes the the string returned by InputAsChar() // and does format string conversion on it as well (and similarly for // ..AsWChar() below) @@ -170,7 +174,7 @@ private: #if wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY public: operator const wchar_t*() const - { return wx_const_cast(wxFormatString*, this)->AsWChar(); } + { return const_cast(this)->AsWChar(); } private: const wchar_t* InputAsWChar(); const wchar_t* AsWChar(); @@ -187,7 +191,7 @@ private: const wxString * const m_str; const wxCStrData * const m_cstr; - DECLARE_NO_ASSIGN_CLASS(wxFormatString) + wxDECLARE_NO_ASSIGN_CLASS(wxFormatString); }; // these two helper classes are used to find wxFormatString argument among fixed @@ -227,10 +231,21 @@ struct wxFormatStringArgumentFinder template<> struct wxFormatStringArgumentFinder -{ - static wxFormatStringArgument find(const wxFormatString& arg) - { return wxFormatStringArgument(&arg); } -}; + : public wxFormatStringArgumentFinder {}; + +// avoid passing big objects by value to wxFormatStringArgumentFinder::find() +// (and especially wx[W]CharBuffer with its auto_ptr<> style semantics!): +template<> +struct wxFormatStringArgumentFinder + : public wxFormatStringArgumentFinder {}; + +template<> +struct wxFormatStringArgumentFinder + : public wxFormatStringArgumentFinder {}; + +template<> +struct wxFormatStringArgumentFinder + : public wxFormatStringArgumentFinder {}; // ---------------------------------------------------------------------------- @@ -553,7 +568,7 @@ struct wxArgNormalizerNarrowChar // FIXME-UTF8: which one is better default in absence of fmt string // (i.e. when used like e.g. Foo("foo", "bar", 'c', NULL)? if ( !fmt || fmt->GetArgumentType(index) == wxFormatString::Arg_Char ) - m_value = wxUniChar(value).GetValue(); + m_value = wx_truncate_cast(T, wxUniChar(value).GetValue()); else m_value = value; }