// 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<wxFormatString*>(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)
#if wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY
public:
operator const wchar_t*() const
- { return wx_const_cast(wxFormatString*, this)->AsWChar(); }
+ { return const_cast<wxFormatString*>(this)->AsWChar(); }
private:
const wchar_t* InputAsWChar();
const wchar_t* AsWChar();
#endif // wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY
private:
-#ifdef __VISUALC__
- // "struct 'ConvertedBuffer<T>' needs to have dll-interface to be used by
- // clients of class 'wxString'" - this is private, we don't care
- #pragma warning (disable:4251)
-#endif
wxCharBuffer m_char;
wxWCharBuffer m_wchar;
-#ifdef __VISUALC__
- #pragma warning (default:4251)
-#endif
// NB: we can use a pointer here, because wxFormatString is only used
// as function argument, so it has shorter life than the string
const wxString * const m_str;
const wxCStrData * const m_cstr;
- DECLARE_NO_COPY_CLASS(wxFormatString)
+ DECLARE_NO_ASSIGN_CLASS(wxFormatString)
};
// these two helper classes are used to find wxFormatString argument among fixed
};
template<typename T>
-inline wxFormatStringArgument wxFindFormatStringArgument(T WXUNUSED(arg))
+struct wxFormatStringArgumentFinder
{
- // by default, arguments are not format strings, so return "not found"
- return wxFormatStringArgument();
-}
+ static wxFormatStringArgument find(T)
+ {
+ // by default, arguments are not format strings, so return "not found"
+ return wxFormatStringArgument();
+ }
+};
-inline wxFormatStringArgument
-wxFindFormatStringArgument(const wxFormatString& arg)
+template<>
+struct wxFormatStringArgumentFinder<const wxFormatString&>
{
- return wxFormatStringArgument(&arg);
+ static wxFormatStringArgument find(const wxFormatString& arg)
+ { return wxFormatStringArgument(&arg); }
};
+template<>
+struct wxFormatStringArgumentFinder<wxFormatString>
+ : public wxFormatStringArgumentFinder<const wxFormatString&> {};
+
+// avoid passing big objects by value to wxFormatStringArgumentFinder::find()
+// (and especially wx[W]CharBuffer with its auto_ptr<> style semantics!):
+template<>
+struct wxFormatStringArgumentFinder<wxString>
+ : public wxFormatStringArgumentFinder<const wxString&> {};
+
+template<>
+struct wxFormatStringArgumentFinder<wxCharBuffer>
+ : public wxFormatStringArgumentFinder<const wxCharBuffer&> {};
+
+template<>
+struct wxFormatStringArgumentFinder<wxWCharBuffer>
+ : public wxFormatStringArgumentFinder<const wxWCharBuffer&> {};
+
// ----------------------------------------------------------------------------
// wxArgNormalizer*<T> converters
// 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;
}
#define _WX_VARARG_FIXED_UNUSED_EXPAND_4(t1,t2,t3,t4) \
t1 WXUNUSED(f1), t2 WXUNUSED(f2), t3 WXUNUSED(f3), t4 WXUNUSED(f4)
+#define _WX_VARARG_FIXED_TYPEDEFS_1(t1) \
+ typedef t1 TF1
+#define _WX_VARARG_FIXED_TYPEDEFS_2(t1,t2) \
+ _WX_VARARG_FIXED_TYPEDEFS_1(t1); typedef t2 TF2
+#define _WX_VARARG_FIXED_TYPEDEFS_3(t1,t2,t3) \
+ _WX_VARARG_FIXED_TYPEDEFS_2(t1,t2); typedef t3 TF3
+#define _WX_VARARG_FIXED_TYPEDEFS_4(t1,t2,t3,t4) \
+ _WX_VARARG_FIXED_TYPEDEFS_3(t1,t2,t3); typedef t4 TF4
+
// This macro expands N-items tuple of fixed arguments types into part of
// function's declaration. For example,
// "_WX_VARARG_FIXED_EXPAND(3, (int, char*, int))" expands into
#define _WX_VARARG_FIXED_UNUSED_EXPAND_IMPL(N, args) \
_WX_VARARG_FIXED_UNUSED_EXPAND_##N args
+// Declarates typedefs for fixed arguments types; i-th fixed argument types
+// will have TFi typedef.
+#define _WX_VARARG_FIXED_TYPEDEFS(N, args) \
+ _WX_VARARG_FIXED_TYPEDEFS_IMPL(N, args)
+#define _WX_VARARG_FIXED_TYPEDEFS_IMPL(N, args) \
+ _WX_VARARG_FIXED_TYPEDEFS_##N args
+
+
// This macro calls another macro 'm' passed as second argument 'N' times,
// with its only argument set to 1..N, and concatenates the results using
// comma as separator.
// And the same for fixed arguments, _not_ normalizing it:
#define _WX_VARARG_PASS_FIXED(i) f##i
-#define _WX_VARARG_FIND_FMT(i) (wxFindFormatStringArgument(f##i))
+#define _WX_VARARG_FIND_FMT(i) \
+ (wxFormatStringArgumentFinder<TF##i>::find(f##i))
#define _WX_VARARG_FORMAT_STRING(numfixed, fixed) \
+ _WX_VARARG_FIXED_TYPEDEFS(numfixed, fixed); \
const wxFormatString *fmt = \
(_WX_VARARG_JOIN(numfixed, _WX_VARARG_FIND_FMT))
#define _WX_VARARG_WATCOM_UNPACK(N, convfixed) \
_WX_VARARG_WATCOM_UNPACK_##N convfixed
+#define _WX_VARARG_PASS_WATCOM(i) a##i
+
#define _WX_VARARG_WATCOM_WORKAROUND(N, rettype, name, \
convfixed, dummy, numfixed, fixed) \
template<_WX_VARARG_JOIN(N, _WX_VARARG_TEMPL)> \
_WX_VARARG_JOIN(N, _WX_VARARG_ARG)) \
{ \
return name(_WX_VARARG_WATCOM_UNPACK(numfixed, convfixed), \
- _WX_VARARG_JOIN(N, _WX_VARARG_PASS_WCHAR)); \
+ _WX_VARARG_JOIN(N, _WX_VARARG_PASS_WATCOM)); \
}
#define _WX_VARARG_WATCOM_WORKAROUND_CTOR(N, dummy1, name, \
_WX_VARARG_JOIN(N, _WX_VARARG_ARG)) \
{ \
name(_WX_VARARG_WATCOM_UNPACK(numfixed, convfixed), \
- _WX_VARARG_JOIN(N, _WX_VARARG_PASS_WCHAR)); \
+ _WX_VARARG_JOIN(N, _WX_VARARG_PASS_WATCOM)); \
}
#endif // __WATCOMC__