1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/strvararg.h
3 // Purpose: macros for implementing type-safe vararg passing of strings
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2007 REA Elektronik GmbH
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_STRVARARG_H_
12 #define _WX_STRVARARG_H_
14 #include "wx/platform.h"
15 #if wxONLY_WATCOM_EARLIER_THAN(1,4)
16 #error "OpenWatcom version >= 1.4 is required to compile this code"
20 #include "wx/chartype.h"
21 #include "wx/strconv.h"
22 #include "wx/buffer.h"
23 #include "wx/unichar.h"
25 class WXDLLIMPEXP_FWD_BASE wxCStrData
;
26 class WXDLLIMPEXP_FWD_BASE wxString
;
28 // ----------------------------------------------------------------------------
29 // WX_DEFINE_VARARG_FUNC* macros
30 // ----------------------------------------------------------------------------
32 // This macro is used to implement type-safe wrappers for variadic functions
33 // that accept strings as arguments. This makes it possible to pass char*,
34 // wchar_t* or even wxString (as opposed to having to use wxString::c_str())
35 // to e.g. wxPrintf().
37 // This is done by defining a set of N template function taking 1..N arguments
38 // (currently, N is set to 30 in this header). These functions are just thin
39 // wrappers around another variadic function ('impl' or 'implUtf8' arguments,
40 // see below) and the only thing the wrapper does is that it normalizes the
41 // arguments passed in so that they are of the type expected by variadic
42 // functions taking string arguments, i.e., char* or wchar_t*, depending on the
44 // * char* in the current locale's charset in ANSI build
45 // * char* with UTF-8 encoding if wxUSE_UNICODE_UTF8 and the app is running
46 // under an UTF-8 locale
47 // * wchar_t* if wxUSE_UNICODE_WCHAR or if wxUSE_UNICODE_UTF8 and the current
48 // locale is not UTF-8
50 // Note that wxFormatString *must* be used for the format parameter of these
51 // functions, otherwise the implementation won't work correctly. Furthermore,
52 // it must be passed by value, not reference, because it's modified by the
53 // vararg templates internally.
56 // [ there are examples in square brackets showing values of the parameters
57 // for the wxFprintf() wrapper for fprintf() function with the following
59 // int wxFprintf(FILE *stream, const wxString& format, ...); ]
61 // rettype Functions' return type [int]
62 // name Name of the function [fprintf]
63 // numfixed The number of leading "fixed" (i.e., not variadic)
64 // arguments of the function (e.g. "stream" and "format"
65 // arguments of fprintf()); their type is _not_ converted
66 // using wxArgNormalizer<T>, unlike the rest of
67 // the function's arguments [2]
68 // fixed List of types of the leading "fixed" arguments, in
69 // parenthesis [(FILE*,const wxString&)]
70 // impl Name of the variadic function that implements 'name' for
71 // the native strings representation (wchar_t* if
72 // wxUSE_UNICODE_WCHAR or wxUSE_UNICODE_UTF8 when running under
73 // non-UTF8 locale, char* in ANSI build) [wxCrt_Fprintf]
74 // implUtf8 Like 'impl', but for the UTF-8 char* version to be used
75 // if wxUSE_UNICODE_UTF8 and running under UTF-8 locale
76 // (ignored otherwise) [fprintf]
78 #define WX_DEFINE_VARARG_FUNC(rettype, name, numfixed, fixed, impl, implUtf8) \
79 _WX_VARARG_DEFINE_FUNC_N0(rettype, name, impl, implUtf8, numfixed, fixed) \
80 WX_DEFINE_VARARG_FUNC_SANS_N0(rettype, name, numfixed, fixed, impl, implUtf8)
82 // ditto, but without the version with 0 template/vararg arguments
83 #define WX_DEFINE_VARARG_FUNC_SANS_N0(rettype, name, \
84 numfixed, fixed, impl, implUtf8) \
85 _WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \
86 _WX_VARARG_DEFINE_FUNC, \
87 rettype, name, impl, implUtf8, numfixed, fixed)
89 // Like WX_DEFINE_VARARG_FUNC, but for variadic functions that don't return
91 #define WX_DEFINE_VARARG_FUNC_VOID(name, numfixed, fixed, impl, implUtf8) \
92 _WX_VARARG_DEFINE_FUNC_VOID_N0(name, impl, implUtf8, numfixed, fixed) \
93 _WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \
94 _WX_VARARG_DEFINE_FUNC_VOID, \
95 void, name, impl, implUtf8, numfixed, fixed)
97 // Like WX_DEFINE_VARARG_FUNC_VOID, but instead of wrapping an implementation
98 // function, does nothing in defined functions' bodies.
100 // Used to implement wxLogXXX functions if wxUSE_LOG=0.
101 #define WX_DEFINE_VARARG_FUNC_NOP(name, numfixed, fixed) \
102 _WX_VARARG_DEFINE_FUNC_NOP_N0(name, numfixed, fixed) \
103 _WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \
104 _WX_VARARG_DEFINE_FUNC_NOP, \
105 void, name, dummy, dummy, numfixed, fixed)
107 // Like WX_DEFINE_VARARG_FUNC_CTOR, but for defining template constructors
108 #define WX_DEFINE_VARARG_FUNC_CTOR(name, numfixed, fixed, impl, implUtf8) \
109 _WX_VARARG_DEFINE_FUNC_CTOR_N0(name, impl, implUtf8, numfixed, fixed) \
110 _WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \
111 _WX_VARARG_DEFINE_FUNC_CTOR, \
112 void, name, impl, implUtf8, numfixed, fixed)
115 // ----------------------------------------------------------------------------
117 // ----------------------------------------------------------------------------
119 // This class must be used for format string argument of the functions
120 // defined using WX_DEFINE_VARARG_FUNC_* macros. It converts the string to
121 // char* or wchar_t* for passing to implementation function efficiently (i.e.
122 // without keeping the converted string in memory for longer than necessary,
123 // like c_str()). It also converts format string to the correct form that
124 // accounts for string changes done by wxArgNormalizer<>
126 // Note that this class can _only_ be used for function arguments!
127 class WXDLLIMPEXP_BASE wxFormatString
130 wxFormatString(const char *str
)
131 : m_char(wxCharBuffer::CreateNonOwned(str
)), m_str(NULL
), m_cstr(NULL
) {}
132 wxFormatString(const wchar_t *str
)
133 : m_wchar(wxWCharBuffer::CreateNonOwned(str
)), m_str(NULL
), m_cstr(NULL
) {}
134 wxFormatString(const wxString
& str
)
135 : m_str(&str
), m_cstr(NULL
) {}
136 wxFormatString(const wxCStrData
& str
)
137 : m_str(NULL
), m_cstr(&str
) {}
138 wxFormatString(const wxCharBuffer
& str
)
139 : m_char(str
), m_str(NULL
), m_cstr(NULL
) {}
140 wxFormatString(const wxWCharBuffer
& str
)
141 : m_wchar(str
), m_str(NULL
), m_cstr(NULL
) {}
146 Arg_Char
, // character as char
148 Arg_Other
// something else, for example int for %d
151 // returns the type of format specifier for n-th variadic argument (this is
152 // not necessarily n-th format specifier if positional specifiers are used);
153 // called by wxArgNormalizer<> specializations to get information about
154 // n-th variadic argument desired representation
155 ArgumentType
GetArgumentType(unsigned n
) const;
157 #if !wxUSE_UNICODE_WCHAR
158 operator const char*() const
159 { return wx_const_cast(wxFormatString
*, this)->AsChar(); }
161 // InputAsChar() returns the value converted passed to ctor, only converted
162 // to char, while AsChar() takes the the string returned by InputAsChar()
163 // and does format string conversion on it as well (and similarly for
164 // ..AsWChar() below)
165 const char* InputAsChar();
166 const char* AsChar();
167 wxCharBuffer m_convertedChar
;
168 #endif // !wxUSE_UNICODE_WCHAR
170 #if wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY
172 operator const wchar_t*() const
173 { return wx_const_cast(wxFormatString
*, this)->AsWChar(); }
175 const wchar_t* InputAsWChar();
176 const wchar_t* AsWChar();
177 wxWCharBuffer m_convertedWChar
;
178 #endif // wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY
182 // "struct 'ConvertedBuffer<T>' needs to have dll-interface to be used by
183 // clients of class 'wxString'" - this is private, we don't care
184 #pragma warning (disable:4251)
187 wxWCharBuffer m_wchar
;
189 #pragma warning (default:4251)
192 // NB: we can use a pointer here, because wxFormatString is only used
193 // as function argument, so it has shorter life than the string
194 // passed to the ctor
195 const wxString
* const m_str
;
196 const wxCStrData
* const m_cstr
;
198 DECLARE_NO_COPY_CLASS(wxFormatString
)
201 // these two helper classes are used to find wxFormatString argument among fixed
202 // arguments passed to a vararg template
203 struct wxFormatStringArgument
205 wxFormatStringArgument(const wxFormatString
*s
= NULL
) : m_str(s
) {}
206 const wxFormatString
*m_str
;
208 // overriding this operator allows us to reuse _WX_VARARG_JOIN macro
209 wxFormatStringArgument
operator,(const wxFormatStringArgument
& a
) const
211 wxASSERT_MSG( m_str
== NULL
|| a
.m_str
== NULL
,
212 "can't have two format strings in vararg function" );
213 return wxFormatStringArgument(m_str
? m_str
: a
.m_str
);
216 operator const wxFormatString
*() const { return m_str
; }
220 inline wxFormatStringArgument
wxFindFormatStringArgument(T
WXUNUSED(arg
))
222 // by default, arguments are not format strings, so return "not found"
223 return wxFormatStringArgument();
226 inline wxFormatStringArgument
227 wxFindFormatStringArgument(const wxFormatString
& arg
)
229 return wxFormatStringArgument(&arg
);
233 // ----------------------------------------------------------------------------
234 // wxArgNormalizer*<T> converters
235 // ----------------------------------------------------------------------------
237 // Converts an argument passed to wxPrint etc. into standard form expected,
238 // by wxXXX functions, e.g. all strings (wxString, char*, wchar_t*) are
239 // converted into wchar_t* or char* depending on the build.
241 struct wxArgNormalizer
243 // Ctor. 'value' is the value passed as variadic argument, 'fmt' is pointer
244 // to printf-like format string or NULL if the variadic function doesn't
245 // use format string and 'index' is index of 'value' in variadic arguments
246 // list (starting at 1)
247 wxArgNormalizer(T value
,
248 const wxFormatString
*WXUNUSED(fmt
), unsigned WXUNUSED(index
))
251 // Returns the value in a form that can be safely passed to real vararg
252 // functions. In case of strings, this is char* in ANSI build and wchar_t*
254 T
get() const { return m_value
; }
259 // normalizer for passing arguments to functions working with wchar_t* (and
260 // until ANSI build is removed, char* in ANSI build as well - FIXME-UTF8)
261 // string representation
262 #if !wxUSE_UTF8_LOCALE_ONLY
264 struct wxArgNormalizerWchar
: public wxArgNormalizer
<T
>
266 wxArgNormalizerWchar(T value
,
267 const wxFormatString
*fmt
, unsigned index
)
268 : wxArgNormalizer
<T
>(value
, fmt
, index
) {}
270 #endif // !wxUSE_UTF8_LOCALE_ONLY
272 // normalizer for passing arguments to functions working with UTF-8 encoded
274 #if wxUSE_UNICODE_UTF8
276 struct wxArgNormalizerUtf8
: public wxArgNormalizer
<T
>
278 wxArgNormalizerUtf8(T value
,
279 const wxFormatString
*fmt
, unsigned index
)
280 : wxArgNormalizer
<T
>(value
, fmt
, index
) {}
283 #define wxArgNormalizerNative wxArgNormalizerUtf8
284 #else // wxUSE_UNICODE_WCHAR
285 #define wxArgNormalizerNative wxArgNormalizerWchar
286 #endif // wxUSE_UNICODE_UTF8 // wxUSE_UNICODE_UTF8
290 // special cases for converting strings:
293 // base class for wxArgNormalizer<T> specializations that need to do conversion;
294 // CharType is either wxStringCharType or wchar_t in UTF-8 build when wrapping
295 // widechar CRT function
296 template<typename CharType
>
297 struct wxArgNormalizerWithBuffer
299 typedef wxCharTypeBuffer
<CharType
> CharBuffer
;
301 wxArgNormalizerWithBuffer() {}
302 wxArgNormalizerWithBuffer(const CharBuffer
& buf
,
303 const wxFormatString
*WXUNUSED(fmt
),
304 unsigned WXUNUSED(index
))
307 const CharType
*get() const { return m_value
; }
314 struct WXDLLIMPEXP_BASE wxArgNormalizerNative
<const wxString
&>
316 wxArgNormalizerNative(const wxString
& s
,
317 const wxFormatString
*WXUNUSED(fmt
),
318 unsigned WXUNUSED(index
))
321 const wxStringCharType
*get() const;
323 const wxString
& m_value
;
328 struct WXDLLIMPEXP_BASE wxArgNormalizerNative
<const wxCStrData
&>
330 wxArgNormalizerNative(const wxCStrData
& value
,
331 const wxFormatString
*WXUNUSED(fmt
),
332 unsigned WXUNUSED(index
))
335 const wxStringCharType
*get() const;
337 const wxCStrData
& m_value
;
340 // wxString/wxCStrData conversion to wchar_t* value
341 #if wxUSE_UNICODE_UTF8 && !wxUSE_UTF8_LOCALE_ONLY
343 struct WXDLLIMPEXP_BASE wxArgNormalizerWchar
<const wxString
&>
344 : public wxArgNormalizerWithBuffer
<wchar_t>
346 wxArgNormalizerWchar(const wxString
& s
,
347 const wxFormatString
*fmt
, unsigned index
);
351 struct WXDLLIMPEXP_BASE wxArgNormalizerWchar
<const wxCStrData
&>
352 : public wxArgNormalizerWithBuffer
<wchar_t>
354 wxArgNormalizerWchar(const wxCStrData
& s
,
355 const wxFormatString
*fmt
, unsigned index
);
357 #endif // wxUSE_UNICODE_UTF8 && !wxUSE_UTF8_LOCALE_ONLY
360 // C string pointers of the wrong type (wchar_t* for ANSI or UTF8 build,
361 // char* for wchar_t Unicode build or UTF8):
362 #if wxUSE_UNICODE_WCHAR
365 struct wxArgNormalizerWchar
<const char*>
366 : public wxArgNormalizerWithBuffer
<wchar_t>
368 wxArgNormalizerWchar(const char* s
,
369 const wxFormatString
*fmt
, unsigned index
)
370 : wxArgNormalizerWithBuffer
<wchar_t>(wxConvLibc
.cMB2WC(s
), fmt
, index
) {}
373 #elif wxUSE_UNICODE_UTF8
376 struct wxArgNormalizerUtf8
<const wchar_t*>
377 : public wxArgNormalizerWithBuffer
<char>
379 wxArgNormalizerUtf8(const wchar_t* s
,
380 const wxFormatString
*fmt
, unsigned index
)
381 : wxArgNormalizerWithBuffer
<char>(wxConvUTF8
.cWC2MB(s
), fmt
, index
) {}
385 struct wxArgNormalizerUtf8
<const char*>
386 : public wxArgNormalizerWithBuffer
<char>
388 wxArgNormalizerUtf8(const char* s
,
389 const wxFormatString
*WXUNUSED(fmt
),
390 unsigned WXUNUSED(index
))
392 if ( wxLocaleIsUtf8
)
394 m_value
= wxCharBuffer::CreateNonOwned(s
);
398 // convert to widechar string first:
399 wxWCharBuffer
buf(wxConvLibc
.cMB2WC(s
));
403 m_value
= wxConvUTF8
.cWC2MB(buf
);
408 // UTF-8 build needs conversion to wchar_t* too:
409 #if !wxUSE_UTF8_LOCALE_ONLY
411 struct wxArgNormalizerWchar
<const char*>
412 : public wxArgNormalizerWithBuffer
<wchar_t>
414 wxArgNormalizerWchar(const char* s
,
415 const wxFormatString
*fmt
, unsigned index
)
416 : wxArgNormalizerWithBuffer
<wchar_t>(wxConvLibc
.cMB2WC(s
), fmt
, index
) {}
418 #endif // !wxUSE_UTF8_LOCALE_ONLY
420 #else // ANSI - FIXME-UTF8
423 struct wxArgNormalizerWchar
<const wchar_t*>
424 : public wxArgNormalizerWithBuffer
<char>
426 wxArgNormalizerWchar(const wchar_t* s
,
427 const wxFormatString
*fmt
, unsigned index
)
428 : wxArgNormalizerWithBuffer
<char>(wxConvLibc
.cWC2MB(s
), fmt
, index
) {}
431 #endif // wxUSE_UNICODE_WCHAR/wxUSE_UNICODE_UTF8/ANSI
434 // this macro is used to implement specialization that are exactly same as
435 // some other specialization, i.e. to "forward" the implementation (e.g. for
436 // T=wxString and T=const wxString&). Note that the ctor takes BaseT argument,
438 #if wxUSE_UNICODE_UTF8
439 #if wxUSE_UTF8_LOCALE_ONLY
440 #define WX_ARG_NORMALIZER_FORWARD(T, BaseT) \
441 _WX_ARG_NORMALIZER_FORWARD_IMPL(wxArgNormalizerUtf8, T, BaseT)
442 #else // possibly non-UTF8 locales
443 #define WX_ARG_NORMALIZER_FORWARD(T, BaseT) \
444 _WX_ARG_NORMALIZER_FORWARD_IMPL(wxArgNormalizerWchar, T, BaseT); \
445 _WX_ARG_NORMALIZER_FORWARD_IMPL(wxArgNormalizerUtf8, T, BaseT)
447 #else // wxUSE_UNICODE_WCHAR
448 #define WX_ARG_NORMALIZER_FORWARD(T, BaseT) \
449 _WX_ARG_NORMALIZER_FORWARD_IMPL(wxArgNormalizerWchar, T, BaseT)
450 #endif // wxUSE_UNICODE_UTF8/wxUSE_UNICODE_WCHAR
452 #define _WX_ARG_NORMALIZER_FORWARD_IMPL(Normalizer, T, BaseT) \
454 struct Normalizer<T> : public Normalizer<BaseT> \
456 Normalizer(BaseT value, \
457 const wxFormatString *fmt, unsigned index) \
458 : Normalizer<BaseT>(value, fmt, index) {} \
461 // non-reference versions of specializations for string objects
462 WX_ARG_NORMALIZER_FORWARD(wxString
, const wxString
&);
463 WX_ARG_NORMALIZER_FORWARD(wxCStrData
, const wxCStrData
&);
465 // versions for passing non-const pointers:
466 WX_ARG_NORMALIZER_FORWARD(char*, const char*);
467 WX_ARG_NORMALIZER_FORWARD(wchar_t*, const wchar_t*);
469 // versions for passing wx[W]CharBuffer:
470 WX_ARG_NORMALIZER_FORWARD(wxCharBuffer
, const char*);
471 WX_ARG_NORMALIZER_FORWARD(const wxCharBuffer
&, const char*);
472 WX_ARG_NORMALIZER_FORWARD(wxWCharBuffer
, const wchar_t*);
473 WX_ARG_NORMALIZER_FORWARD(const wxWCharBuffer
&, const wchar_t*);
475 // versions for std::[w]string:
478 #include "wx/stringimpl.h"
480 #if !wxUSE_UTF8_LOCALE_ONLY
482 struct wxArgNormalizerWchar
<const std::string
&>
483 : public wxArgNormalizerWchar
<const char*>
485 wxArgNormalizerWchar(const std::string
& s
,
486 const wxFormatString
*fmt
, unsigned index
)
487 : wxArgNormalizerWchar
<const char*>(s
.c_str(), fmt
, index
) {}
491 struct wxArgNormalizerWchar
<const wxStdWideString
&>
492 : public wxArgNormalizerWchar
<const wchar_t*>
494 wxArgNormalizerWchar(const wxStdWideString
& s
,
495 const wxFormatString
*fmt
, unsigned index
)
496 : wxArgNormalizerWchar
<const wchar_t*>(s
.c_str(), fmt
, index
) {}
498 #endif // !wxUSE_UTF8_LOCALE_ONLY
500 #if wxUSE_UNICODE_UTF8
502 struct wxArgNormalizerUtf8
<const std::string
&>
503 : public wxArgNormalizerUtf8
<const char*>
505 wxArgNormalizerUtf8(const std::string
& s
,
506 const wxFormatString
*fmt
, unsigned index
)
507 : wxArgNormalizerUtf8
<const char*>(s
.c_str(), fmt
, index
) {}
511 struct wxArgNormalizerUtf8
<const wxStdWideString
&>
512 : public wxArgNormalizerUtf8
<const wchar_t*>
514 wxArgNormalizerUtf8(const wxStdWideString
& s
,
515 const wxFormatString
*fmt
, unsigned index
)
516 : wxArgNormalizerUtf8
<const wchar_t*>(s
.c_str(), fmt
, index
) {}
518 #endif // wxUSE_UNICODE_UTF8
520 WX_ARG_NORMALIZER_FORWARD(std::string
, const std::string
&);
521 WX_ARG_NORMALIZER_FORWARD(wxStdWideString
, const wxStdWideString
&);
523 #endif // wxUSE_STD_STRING
526 // versions for wxUniChar, wxUniCharRef:
527 // (this is same for UTF-8 and Wchar builds, we just convert to wchar_t)
529 struct wxArgNormalizer
<const wxUniChar
&> : public wxArgNormalizer
<wchar_t>
531 wxArgNormalizer(const wxUniChar
& s
,
532 const wxFormatString
*fmt
, unsigned index
)
533 : wxArgNormalizer
<wchar_t>(s
.GetValue(), fmt
, index
) {}
536 // for wchar_t, default handler does the right thing
538 // char has to be treated differently in Unicode builds: a char argument may
539 // be used either for a character value (which should be converted into
540 // wxUniChar) or as an integer value (which should be left as-is). We take
541 // advantage of the fact that both char and wchar_t are converted into int
542 // in variadic arguments here.
545 struct wxArgNormalizerNarrowChar
547 wxArgNormalizerNarrowChar(T value
,
548 const wxFormatString
*fmt
, unsigned index
)
550 // FIXME-UTF8: which one is better default in absence of fmt string
551 // (i.e. when used like e.g. Foo("foo", "bar", 'c', NULL)?
552 if ( !fmt
|| fmt
->GetArgumentType(index
) == wxFormatString::Arg_Char
)
553 m_value
= wxUniChar(value
).GetValue();
558 int get() const { return m_value
; }
564 struct wxArgNormalizer
<char> : public wxArgNormalizerNarrowChar
<char>
566 wxArgNormalizer(char value
,
567 const wxFormatString
*fmt
, unsigned index
)
568 : wxArgNormalizerNarrowChar
<char>(value
, fmt
, index
) {}
572 struct wxArgNormalizer
<unsigned char>
573 : public wxArgNormalizerNarrowChar
<unsigned char>
575 wxArgNormalizer(unsigned char value
,
576 const wxFormatString
*fmt
, unsigned index
)
577 : wxArgNormalizerNarrowChar
<unsigned char>(value
, fmt
, index
) {}
580 #endif // wxUSE_UNICODE
582 // convert references:
583 WX_ARG_NORMALIZER_FORWARD(wxUniChar
, const wxUniChar
&);
584 WX_ARG_NORMALIZER_FORWARD(const wxUniCharRef
&, const wxUniChar
&);
585 WX_ARG_NORMALIZER_FORWARD(wxUniCharRef
, const wxUniChar
&);
586 WX_ARG_NORMALIZER_FORWARD(const wchar_t&, wchar_t);
588 WX_ARG_NORMALIZER_FORWARD(const char&, char);
589 WX_ARG_NORMALIZER_FORWARD(const unsigned char&, unsigned char);
592 #undef WX_ARG_NORMALIZER_FORWARD
593 #undef _WX_ARG_NORMALIZER_FORWARD_IMPL
595 // ----------------------------------------------------------------------------
597 // ----------------------------------------------------------------------------
599 // Replacement for va_arg() for use with strings in functions that accept
600 // strings normalized by wxArgNormalizer<T>:
602 struct WXDLLIMPEXP_BASE wxArgNormalizedString
604 wxArgNormalizedString(const void* ptr
) : m_ptr(ptr
) {}
606 // returns true if non-NULL string was passed in
607 bool IsValid() const { return m_ptr
!= NULL
; }
608 operator bool() const { return IsValid(); }
610 // extracts the string, returns empty string if NULL was passed in
611 wxString
GetString() const;
612 operator wxString() const;
618 #define WX_VA_ARG_STRING(ap) wxArgNormalizedString(va_arg(ap, const void*))
620 // ----------------------------------------------------------------------------
621 // implementation of the WX_DEFINE_VARARG_* macros
622 // ----------------------------------------------------------------------------
624 // NB: The vararg emulation code is limited to 30 variadic and 4 fixed
625 // arguments at the moment.
626 // If you need more variadic arguments, you need to
627 // 1) increase the value of _WX_VARARG_MAX_ARGS
628 // 2) add _WX_VARARG_JOIN_* and _WX_VARARG_ITER_* up to the new
629 // _WX_VARARG_MAX_ARGS value to the lists below
630 // If you need more fixed arguments, you need to
631 // 1) increase the value of _WX_VARARG_MAX_FIXED_ARGS
632 // 2) add _WX_VARARG_FIXED_EXPAND_* and _WX_VARARG_FIXED_UNUSED_EXPAND_*
634 #define _WX_VARARG_MAX_ARGS 30
635 #define _WX_VARARG_MAX_FIXED_ARGS 4
637 #define _WX_VARARG_JOIN_1(m) m(1)
638 #define _WX_VARARG_JOIN_2(m) _WX_VARARG_JOIN_1(m), m(2)
639 #define _WX_VARARG_JOIN_3(m) _WX_VARARG_JOIN_2(m), m(3)
640 #define _WX_VARARG_JOIN_4(m) _WX_VARARG_JOIN_3(m), m(4)
641 #define _WX_VARARG_JOIN_5(m) _WX_VARARG_JOIN_4(m), m(5)
642 #define _WX_VARARG_JOIN_6(m) _WX_VARARG_JOIN_5(m), m(6)
643 #define _WX_VARARG_JOIN_7(m) _WX_VARARG_JOIN_6(m), m(7)
644 #define _WX_VARARG_JOIN_8(m) _WX_VARARG_JOIN_7(m), m(8)
645 #define _WX_VARARG_JOIN_9(m) _WX_VARARG_JOIN_8(m), m(9)
646 #define _WX_VARARG_JOIN_10(m) _WX_VARARG_JOIN_9(m), m(10)
647 #define _WX_VARARG_JOIN_11(m) _WX_VARARG_JOIN_10(m), m(11)
648 #define _WX_VARARG_JOIN_12(m) _WX_VARARG_JOIN_11(m), m(12)
649 #define _WX_VARARG_JOIN_13(m) _WX_VARARG_JOIN_12(m), m(13)
650 #define _WX_VARARG_JOIN_14(m) _WX_VARARG_JOIN_13(m), m(14)
651 #define _WX_VARARG_JOIN_15(m) _WX_VARARG_JOIN_14(m), m(15)
652 #define _WX_VARARG_JOIN_16(m) _WX_VARARG_JOIN_15(m), m(16)
653 #define _WX_VARARG_JOIN_17(m) _WX_VARARG_JOIN_16(m), m(17)
654 #define _WX_VARARG_JOIN_18(m) _WX_VARARG_JOIN_17(m), m(18)
655 #define _WX_VARARG_JOIN_19(m) _WX_VARARG_JOIN_18(m), m(19)
656 #define _WX_VARARG_JOIN_20(m) _WX_VARARG_JOIN_19(m), m(20)
657 #define _WX_VARARG_JOIN_21(m) _WX_VARARG_JOIN_20(m), m(21)
658 #define _WX_VARARG_JOIN_22(m) _WX_VARARG_JOIN_21(m), m(22)
659 #define _WX_VARARG_JOIN_23(m) _WX_VARARG_JOIN_22(m), m(23)
660 #define _WX_VARARG_JOIN_24(m) _WX_VARARG_JOIN_23(m), m(24)
661 #define _WX_VARARG_JOIN_25(m) _WX_VARARG_JOIN_24(m), m(25)
662 #define _WX_VARARG_JOIN_26(m) _WX_VARARG_JOIN_25(m), m(26)
663 #define _WX_VARARG_JOIN_27(m) _WX_VARARG_JOIN_26(m), m(27)
664 #define _WX_VARARG_JOIN_28(m) _WX_VARARG_JOIN_27(m), m(28)
665 #define _WX_VARARG_JOIN_29(m) _WX_VARARG_JOIN_28(m), m(29)
666 #define _WX_VARARG_JOIN_30(m) _WX_VARARG_JOIN_29(m), m(30)
668 #define _WX_VARARG_ITER_1(m,a,b,c,d,e,f) m(1,a,b,c,d,e,f)
669 #define _WX_VARARG_ITER_2(m,a,b,c,d,e,f) _WX_VARARG_ITER_1(m,a,b,c,d,e,f) m(2,a,b,c,d,e,f)
670 #define _WX_VARARG_ITER_3(m,a,b,c,d,e,f) _WX_VARARG_ITER_2(m,a,b,c,d,e,f) m(3,a,b,c,d,e,f)
671 #define _WX_VARARG_ITER_4(m,a,b,c,d,e,f) _WX_VARARG_ITER_3(m,a,b,c,d,e,f) m(4,a,b,c,d,e,f)
672 #define _WX_VARARG_ITER_5(m,a,b,c,d,e,f) _WX_VARARG_ITER_4(m,a,b,c,d,e,f) m(5,a,b,c,d,e,f)
673 #define _WX_VARARG_ITER_6(m,a,b,c,d,e,f) _WX_VARARG_ITER_5(m,a,b,c,d,e,f) m(6,a,b,c,d,e,f)
674 #define _WX_VARARG_ITER_7(m,a,b,c,d,e,f) _WX_VARARG_ITER_6(m,a,b,c,d,e,f) m(7,a,b,c,d,e,f)
675 #define _WX_VARARG_ITER_8(m,a,b,c,d,e,f) _WX_VARARG_ITER_7(m,a,b,c,d,e,f) m(8,a,b,c,d,e,f)
676 #define _WX_VARARG_ITER_9(m,a,b,c,d,e,f) _WX_VARARG_ITER_8(m,a,b,c,d,e,f) m(9,a,b,c,d,e,f)
677 #define _WX_VARARG_ITER_10(m,a,b,c,d,e,f) _WX_VARARG_ITER_9(m,a,b,c,d,e,f) m(10,a,b,c,d,e,f)
678 #define _WX_VARARG_ITER_11(m,a,b,c,d,e,f) _WX_VARARG_ITER_10(m,a,b,c,d,e,f) m(11,a,b,c,d,e,f)
679 #define _WX_VARARG_ITER_12(m,a,b,c,d,e,f) _WX_VARARG_ITER_11(m,a,b,c,d,e,f) m(12,a,b,c,d,e,f)
680 #define _WX_VARARG_ITER_13(m,a,b,c,d,e,f) _WX_VARARG_ITER_12(m,a,b,c,d,e,f) m(13,a,b,c,d,e,f)
681 #define _WX_VARARG_ITER_14(m,a,b,c,d,e,f) _WX_VARARG_ITER_13(m,a,b,c,d,e,f) m(14,a,b,c,d,e,f)
682 #define _WX_VARARG_ITER_15(m,a,b,c,d,e,f) _WX_VARARG_ITER_14(m,a,b,c,d,e,f) m(15,a,b,c,d,e,f)
683 #define _WX_VARARG_ITER_16(m,a,b,c,d,e,f) _WX_VARARG_ITER_15(m,a,b,c,d,e,f) m(16,a,b,c,d,e,f)
684 #define _WX_VARARG_ITER_17(m,a,b,c,d,e,f) _WX_VARARG_ITER_16(m,a,b,c,d,e,f) m(17,a,b,c,d,e,f)
685 #define _WX_VARARG_ITER_18(m,a,b,c,d,e,f) _WX_VARARG_ITER_17(m,a,b,c,d,e,f) m(18,a,b,c,d,e,f)
686 #define _WX_VARARG_ITER_19(m,a,b,c,d,e,f) _WX_VARARG_ITER_18(m,a,b,c,d,e,f) m(19,a,b,c,d,e,f)
687 #define _WX_VARARG_ITER_20(m,a,b,c,d,e,f) _WX_VARARG_ITER_19(m,a,b,c,d,e,f) m(20,a,b,c,d,e,f)
688 #define _WX_VARARG_ITER_21(m,a,b,c,d,e,f) _WX_VARARG_ITER_20(m,a,b,c,d,e,f) m(21,a,b,c,d,e,f)
689 #define _WX_VARARG_ITER_22(m,a,b,c,d,e,f) _WX_VARARG_ITER_21(m,a,b,c,d,e,f) m(22,a,b,c,d,e,f)
690 #define _WX_VARARG_ITER_23(m,a,b,c,d,e,f) _WX_VARARG_ITER_22(m,a,b,c,d,e,f) m(23,a,b,c,d,e,f)
691 #define _WX_VARARG_ITER_24(m,a,b,c,d,e,f) _WX_VARARG_ITER_23(m,a,b,c,d,e,f) m(24,a,b,c,d,e,f)
692 #define _WX_VARARG_ITER_25(m,a,b,c,d,e,f) _WX_VARARG_ITER_24(m,a,b,c,d,e,f) m(25,a,b,c,d,e,f)
693 #define _WX_VARARG_ITER_26(m,a,b,c,d,e,f) _WX_VARARG_ITER_25(m,a,b,c,d,e,f) m(26,a,b,c,d,e,f)
694 #define _WX_VARARG_ITER_27(m,a,b,c,d,e,f) _WX_VARARG_ITER_26(m,a,b,c,d,e,f) m(27,a,b,c,d,e,f)
695 #define _WX_VARARG_ITER_28(m,a,b,c,d,e,f) _WX_VARARG_ITER_27(m,a,b,c,d,e,f) m(28,a,b,c,d,e,f)
696 #define _WX_VARARG_ITER_29(m,a,b,c,d,e,f) _WX_VARARG_ITER_28(m,a,b,c,d,e,f) m(29,a,b,c,d,e,f)
697 #define _WX_VARARG_ITER_30(m,a,b,c,d,e,f) _WX_VARARG_ITER_29(m,a,b,c,d,e,f) m(30,a,b,c,d,e,f)
700 #define _WX_VARARG_FIXED_EXPAND_1(t1) \
702 #define _WX_VARARG_FIXED_EXPAND_2(t1,t2) \
704 #define _WX_VARARG_FIXED_EXPAND_3(t1,t2,t3) \
706 #define _WX_VARARG_FIXED_EXPAND_4(t1,t2,t3,t4) \
707 t1 f1, t2 f2, t3 f3, t4 f4
709 #define _WX_VARARG_FIXED_UNUSED_EXPAND_1(t1) \
711 #define _WX_VARARG_FIXED_UNUSED_EXPAND_2(t1,t2) \
712 t1 WXUNUSED(f1), t2 WXUNUSED(f2)
713 #define _WX_VARARG_FIXED_UNUSED_EXPAND_3(t1,t2,t3) \
714 t1 WXUNUSED(f1), t2 WXUNUSED(f2), t3 WXUNUSED(f3)
715 #define _WX_VARARG_FIXED_UNUSED_EXPAND_4(t1,t2,t3,t4) \
716 t1 WXUNUSED(f1), t2 WXUNUSED(f2), t3 WXUNUSED(f3), t4 WXUNUSED(f4)
718 // This macro expands N-items tuple of fixed arguments types into part of
719 // function's declaration. For example,
720 // "_WX_VARARG_FIXED_EXPAND(3, (int, char*, int))" expands into
721 // "int f1, char* f2, int f3".
722 #define _WX_VARARG_FIXED_EXPAND(N, args) \
723 _WX_VARARG_FIXED_EXPAND_IMPL(N, args)
724 #define _WX_VARARG_FIXED_EXPAND_IMPL(N, args) \
725 _WX_VARARG_FIXED_EXPAND_##N args
727 // Ditto for unused arguments
728 #define _WX_VARARG_FIXED_UNUSED_EXPAND(N, args) \
729 _WX_VARARG_FIXED_UNUSED_EXPAND_IMPL(N, args)
730 #define _WX_VARARG_FIXED_UNUSED_EXPAND_IMPL(N, args) \
731 _WX_VARARG_FIXED_UNUSED_EXPAND_##N args
733 // This macro calls another macro 'm' passed as second argument 'N' times,
734 // with its only argument set to 1..N, and concatenates the results using
735 // comma as separator.
738 // #define foo(i) x##i
739 // // this expands to "x1,x2,x3,x4"
740 // _WX_VARARG_JOIN(4, foo)
743 // N must not be greater than _WX_VARARG_MAX_ARGS (=30).
744 #define _WX_VARARG_JOIN(N, m) _WX_VARARG_JOIN_IMPL(N, m)
745 #define _WX_VARARG_JOIN_IMPL(N, m) _WX_VARARG_JOIN_##N(m)
748 // This macro calls another macro 'm' passed as second argument 'N' times, with
749 // its first argument set to 1..N and the remaining arguments set to 'a', 'b',
750 // 'c', 'd', 'e' and 'f'. The results are separated with whitespace in the
754 // // this macro expands to:
755 // // foo(1,a,b,c,d,e,f)
756 // // foo(2,a,b,c,d,e,f)
757 // // foo(3,a,b,c,d,e,f)
758 // _WX_VARARG_ITER(3, foo, a, b, c, d, e, f)
760 // N must not be greater than _WX_VARARG_MAX_ARGS (=30).
761 #define _WX_VARARG_ITER(N,m,a,b,c,d,e,f) \
762 _WX_VARARG_ITER_IMPL(N,m,a,b,c,d,e,f)
763 #define _WX_VARARG_ITER_IMPL(N,m,a,b,c,d,e,f) \
764 _WX_VARARG_ITER_##N(m,a,b,c,d,e,f)
766 // Generates code snippet for i-th "variadic" argument in vararg function's
768 #define _WX_VARARG_ARG(i) T##i a##i
770 // Like _WX_VARARG_ARG_UNUSED, but outputs argument's type with WXUNUSED:
771 #define _WX_VARARG_ARG_UNUSED(i) T##i WXUNUSED(a##i)
773 // Generates code snippet for i-th type in vararg function's template<...>:
774 #define _WX_VARARG_TEMPL(i) typename T##i
776 // Generates code snippet for passing i-th argument of vararg function
777 // wrapper to its implementation, normalizing it in the process:
778 #define _WX_VARARG_PASS_WCHAR(i) \
779 wxArgNormalizerWchar<T##i>(a##i, fmt, i).get()
780 #define _WX_VARARG_PASS_UTF8(i) \
781 wxArgNormalizerUtf8<T##i>(a##i, fmt, i).get()
784 // And the same for fixed arguments, _not_ normalizing it:
785 #define _WX_VARARG_PASS_FIXED(i) f##i
787 #define _WX_VARARG_FIND_FMT(i) (wxFindFormatStringArgument(f##i))
789 #define _WX_VARARG_FORMAT_STRING(numfixed, fixed) \
790 const wxFormatString *fmt = \
791 (_WX_VARARG_JOIN(numfixed, _WX_VARARG_FIND_FMT))
793 #if wxUSE_UNICODE_UTF8
794 #define _WX_VARARG_DO_CALL_UTF8(return_kw, impl, implUtf8, N, numfixed) \
795 return_kw implUtf8(_WX_VARARG_JOIN(numfixed, _WX_VARARG_PASS_FIXED), \
796 _WX_VARARG_JOIN(N, _WX_VARARG_PASS_UTF8))
797 #define _WX_VARARG_DO_CALL0_UTF8(return_kw, impl, implUtf8, numfixed) \
798 return_kw implUtf8(_WX_VARARG_JOIN(numfixed, _WX_VARARG_PASS_FIXED))
799 #endif // wxUSE_UNICODE_UTF8
801 #define _WX_VARARG_DO_CALL_WCHAR(return_kw, impl, implUtf8, N, numfixed) \
802 return_kw impl(_WX_VARARG_JOIN(numfixed, _WX_VARARG_PASS_FIXED), \
803 _WX_VARARG_JOIN(N, _WX_VARARG_PASS_WCHAR))
804 #define _WX_VARARG_DO_CALL0_WCHAR(return_kw, impl, implUtf8, numfixed) \
805 return_kw impl(_WX_VARARG_JOIN(numfixed, _WX_VARARG_PASS_FIXED))
807 #if wxUSE_UNICODE_UTF8
808 #if wxUSE_UTF8_LOCALE_ONLY
809 #define _WX_VARARG_DO_CALL _WX_VARARG_DO_CALL_UTF8
810 #define _WX_VARARG_DO_CALL0 _WX_VARARG_DO_CALL0_UTF8
811 #else // possibly non-UTF8 locales
812 #define _WX_VARARG_DO_CALL(return_kw, impl, implUtf8, N, numfixed) \
813 if ( wxLocaleIsUtf8 ) \
814 _WX_VARARG_DO_CALL_UTF8(return_kw, impl, implUtf8, N, numfixed);\
816 _WX_VARARG_DO_CALL_WCHAR(return_kw, impl, implUtf8, N, numfixed)
818 #define _WX_VARARG_DO_CALL0(return_kw, impl, implUtf8, numfixed) \
819 if ( wxLocaleIsUtf8 ) \
820 _WX_VARARG_DO_CALL0_UTF8(return_kw, impl, implUtf8, numfixed); \
822 _WX_VARARG_DO_CALL0_WCHAR(return_kw, impl, implUtf8, numfixed)
823 #endif // wxUSE_UTF8_LOCALE_ONLY or not
824 #else // wxUSE_UNICODE_WCHAR or ANSI
825 #define _WX_VARARG_DO_CALL _WX_VARARG_DO_CALL_WCHAR
826 #define _WX_VARARG_DO_CALL0 _WX_VARARG_DO_CALL0_WCHAR
827 #endif // wxUSE_UNICODE_UTF8 / wxUSE_UNICODE_WCHAR
830 // Macro to be used with _WX_VARARG_ITER in the implementation of
831 // WX_DEFINE_VARARG_FUNC (see its documentation for the meaning of arguments)
832 #define _WX_VARARG_DEFINE_FUNC(N, rettype, name, \
833 impl, implUtf8, numfixed, fixed) \
834 template<_WX_VARARG_JOIN(N, _WX_VARARG_TEMPL)> \
835 rettype name(_WX_VARARG_FIXED_EXPAND(numfixed, fixed), \
836 _WX_VARARG_JOIN(N, _WX_VARARG_ARG)) \
838 _WX_VARARG_FORMAT_STRING(numfixed, fixed); \
839 _WX_VARARG_DO_CALL(return, impl, implUtf8, N, numfixed); \
842 #define _WX_VARARG_DEFINE_FUNC_N0(rettype, name, \
843 impl, implUtf8, numfixed, fixed) \
844 inline rettype name(_WX_VARARG_FIXED_EXPAND(numfixed, fixed)) \
846 _WX_VARARG_DO_CALL0(return, impl, implUtf8, numfixed); \
849 // Macro to be used with _WX_VARARG_ITER in the implementation of
850 // WX_DEFINE_VARARG_FUNC_VOID (see its documentation for the meaning of
851 // arguments; rettype is ignored and is used only to satisfy _WX_VARARG_ITER's
853 #define _WX_VARARG_DEFINE_FUNC_VOID(N, rettype, name, \
854 impl, implUtf8, numfixed, fixed) \
855 template<_WX_VARARG_JOIN(N, _WX_VARARG_TEMPL)> \
856 void name(_WX_VARARG_FIXED_EXPAND(numfixed, fixed), \
857 _WX_VARARG_JOIN(N, _WX_VARARG_ARG)) \
859 _WX_VARARG_FORMAT_STRING(numfixed, fixed); \
860 _WX_VARARG_DO_CALL(wxEMPTY_PARAMETER_VALUE, \
861 impl, implUtf8, N, numfixed); \
864 #define _WX_VARARG_DEFINE_FUNC_VOID_N0(name, impl, implUtf8, numfixed, fixed) \
865 inline void name(_WX_VARARG_FIXED_EXPAND(numfixed, fixed)) \
867 _WX_VARARG_DO_CALL0(wxEMPTY_PARAMETER_VALUE, \
868 impl, implUtf8, numfixed); \
871 // Macro to be used with _WX_VARARG_ITER in the implementation of
872 // WX_DEFINE_VARARG_FUNC_CTOR (see its documentation for the meaning of
873 // arguments; rettype is ignored and is used only to satisfy _WX_VARARG_ITER's
875 #define _WX_VARARG_DEFINE_FUNC_CTOR(N, rettype, name, \
876 impl, implUtf8, numfixed, fixed) \
877 template<_WX_VARARG_JOIN(N, _WX_VARARG_TEMPL)> \
878 name(_WX_VARARG_FIXED_EXPAND(numfixed, fixed), \
879 _WX_VARARG_JOIN(N, _WX_VARARG_ARG)) \
881 _WX_VARARG_FORMAT_STRING(numfixed, fixed); \
882 _WX_VARARG_DO_CALL(wxEMPTY_PARAMETER_VALUE, \
883 impl, implUtf8, N, numfixed); \
886 #define _WX_VARARG_DEFINE_FUNC_CTOR_N0(name, impl, implUtf8, numfixed, fixed) \
887 inline name(_WX_VARARG_FIXED_EXPAND(numfixed, fixed)) \
889 _WX_VARARG_DO_CALL0(wxEMPTY_PARAMETER_VALUE, \
890 impl, implUtf8, numfixed); \
893 // Macro to be used with _WX_VARARG_ITER in the implementation of
894 // WX_DEFINE_VARARG_FUNC_NOP, i.e. empty stub for a disabled vararg function.
895 // The rettype and impl arguments are ignored.
896 #define _WX_VARARG_DEFINE_FUNC_NOP(N, rettype, name, \
897 impl, implUtf8, numfixed, fixed) \
898 template<_WX_VARARG_JOIN(N, _WX_VARARG_TEMPL)> \
899 void name(_WX_VARARG_FIXED_UNUSED_EXPAND(numfixed, fixed), \
900 _WX_VARARG_JOIN(N, _WX_VARARG_ARG_UNUSED)) \
903 #define _WX_VARARG_DEFINE_FUNC_NOP_N0(name, numfixed, fixed) \
904 inline void name(_WX_VARARG_FIXED_UNUSED_EXPAND(numfixed, fixed)) \
908 // ----------------------------------------------------------------------------
909 // workaround for OpenWatcom bug #351
910 // ----------------------------------------------------------------------------
913 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
915 // This macro can be used to forward a 'vararg' template to another one with
916 // different fixed arguments types. Parameters are same as for
917 // WX_DEFINE_VARARG_FUNC (rettype=void can be used here), 'convfixed' is how
918 // to convert fixed arguments. For example, this is typical code for dealing
919 // with different forms of format string:
921 // WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wxFormatString&),
922 // DoPrintfWchar, DoPrintfUtf8)
923 // #ifdef __WATCOMC__
924 // WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const wxString&),
925 // (wxFormatString(f1)))
926 // WX_VARARG_WATCOM_WORKAROUND(void, Printf, 1, (const char*),
927 // (wxFormatString(f1)))
929 #define WX_VARARG_WATCOM_WORKAROUND(rettype, name, numfixed, fixed, convfixed)\
930 _WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \
931 _WX_VARARG_WATCOM_WORKAROUND, \
932 rettype, name, convfixed, dummy, numfixed, fixed)
934 #define WX_VARARG_WATCOM_WORKAROUND_CTOR(name, numfixed, fixed, convfixed) \
935 _WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \
936 _WX_VARARG_WATCOM_WORKAROUND_CTOR, \
937 dummy, name, convfixed, dummy, numfixed, fixed)
939 #define _WX_VARARG_WATCOM_UNPACK_1(a1) a1
940 #define _WX_VARARG_WATCOM_UNPACK_2(a1, a2) a1, a2
941 #define _WX_VARARG_WATCOM_UNPACK_3(a1, a2, a3) a1, a2, a3
942 #define _WX_VARARG_WATCOM_UNPACK_4(a1, a2, a3, a4) a1, a2, a3, a4
943 #define _WX_VARARG_WATCOM_UNPACK(N, convfixed) \
944 _WX_VARARG_WATCOM_UNPACK_##N convfixed
946 #define _WX_VARARG_WATCOM_WORKAROUND(N, rettype, name, \
947 convfixed, dummy, numfixed, fixed) \
948 template<_WX_VARARG_JOIN(N, _WX_VARARG_TEMPL)> \
949 rettype name(_WX_VARARG_FIXED_EXPAND(numfixed, fixed), \
950 _WX_VARARG_JOIN(N, _WX_VARARG_ARG)) \
952 return name(_WX_VARARG_WATCOM_UNPACK(numfixed, convfixed), \
953 _WX_VARARG_JOIN(N, _WX_VARARG_PASS_WCHAR)); \
956 #define _WX_VARARG_WATCOM_WORKAROUND_CTOR(N, dummy1, name, \
957 convfixed, dummy2, numfixed, fixed) \
958 template<_WX_VARARG_JOIN(N, _WX_VARARG_TEMPL)> \
959 name(_WX_VARARG_FIXED_EXPAND(numfixed, fixed), \
960 _WX_VARARG_JOIN(N, _WX_VARARG_ARG)) \
962 name(_WX_VARARG_WATCOM_UNPACK(numfixed, convfixed), \
963 _WX_VARARG_JOIN(N, _WX_VARARG_PASS_WCHAR)); \
966 #endif // __WATCOMC__
968 #endif // _WX_STRVARARG_H_