fixed vararg functions with format argument to not use wxString or reference argument (the latter is invalid C++, the former doesn't work with Watcom and produces at least warnings with GCC 3.3)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45781 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2007-05-03 10:50:25 +00:00
parent 30957174e5
commit d1f6e2cfe2
14 changed files with 543 additions and 143 deletions

View File

@@ -95,17 +95,26 @@ public:
static void SetResolution(int ppi); static void SetResolution(int ppi);
static int GetResolution(); static int GetResolution();
WX_DEFINE_VARARG_FUNC_VOID(PsPrintf, 1, (const wxString&), DoPsPrintfFormat) WX_DEFINE_VARARG_FUNC_VOID(PsPrintf, 1, (const wxString&),
DoPsPrintfFormatWchar, DoPsPrintfFormatUtf8)
#ifdef __WATCOMC__ #ifdef __WATCOMC__
// workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
WX_DEFINE_VARARG_FUNC_VOID(PsPrintf, 1, (const char*), DoPsPrintfFormat) WX_DEFINE_VARARG_FUNC_VOID(PsPrintf, 1, (const char*),
WX_DEFINE_VARARG_FUNC_VOID(PsPrintf, 1, (const wchar_t*), DoPsPrintfFormat) DoPsPrintfFormatWchar, DoPsPrintfFormatUtf8)
WX_DEFINE_VARARG_FUNC_VOID(PsPrintf, 1, (const wchar_t*),
DoPsPrintfFormatWchar, DoPsPrintfFormatUtf8)
#endif #endif
void PsPrint( const wxString& psdata ); void PsPrint( const wxString& psdata );
void PsPrint( int ch ); void PsPrint( int ch );
private: private:
void DoPsPrintfFormat(const wxString& fmt, ... ); #if !wxUSE_UTF8_LOCALE_ONLY
void DoPsPrintfFormatWchar(const wxChar *fmt, ... );
#endif
#if wxUSE_UNICODE_UTF8
void DoPsPrintfFormatUtf8(const char *fmt, ... );
#endif
static float ms_PSScaleFactor; static float ms_PSScaleFactor;

View File

@@ -473,9 +473,12 @@ WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
#define DECLARE_LOG_FUNCTION(level) \ #define DECLARE_LOG_FUNCTION(level) \
extern void WXDLLIMPEXP_BASE \ extern void WXDLLIMPEXP_BASE \
wxDoLog##level(const wxString& format, ...); \ wxDoLog##level##Wchar(const wxChar *format, ...); \
extern void WXDLLIMPEXP_BASE \
wxDoLog##level##Utf8(const char *format, ...); \
WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \ WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \
1, (const wxString&), wxDoLog##level) \ 1, (const wxString&), \
wxDoLog##level##Wchar, wxDoLog##level##Utf8) \
DECLARE_LOG_FUNCTION_WATCOM(level) \ DECLARE_LOG_FUNCTION_WATCOM(level) \
extern void WXDLLIMPEXP_BASE wxVLog##level(const wxString& format, \ extern void WXDLLIMPEXP_BASE wxVLog##level(const wxString& format, \
va_list argptr) va_list argptr)
@@ -486,22 +489,30 @@ WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
// something too big for Borland C++ to handle // something too big for Borland C++ to handle
#define DECLARE_LOG_FUNCTION_WATCOM(level) \ #define DECLARE_LOG_FUNCTION_WATCOM(level) \
WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \ WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \
1, (const char*), wxDoLog##level) \ 1, (const char*), \
wxDoLog##level##Wchar, \
wxDoLog##level##Utf8) \
WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \ WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \
1, (const wchar_t*), wxDoLog##level) \ 1, (const wchar_t*), \
wxDoLog##level##Wchar, \
wxDoLog##level##Utf8) \
WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \ WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \
1, (const wxCStrData&), wxDoLog##level) 1, (const wxCStrData&), \
wxDoLog##level##Wchar, \
wxDoLog##level##Utf8)
#else #else
#define DECLARE_LOG_FUNCTION_WATCOM(level) #define DECLARE_LOG_FUNCTION_WATCOM(level)
#endif #endif
#define DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, expdecl) \ #define DECLARE_LOG_FUNCTION2_EXP(level, argclass, arg, expdecl) \
extern void expdecl wxDoLog##level(argclass arg, \ extern void expdecl wxDoLog##level##Wchar(argclass arg, \
const wxString& format, ...); \ const wxChar *format, ...); \
extern void expdecl wxDoLog##level##Utf8(argclass arg, \
const char *format, ...); \
WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \ WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \
2, (argclass, const wxString&), \ 2, (argclass, const wxString&), \
wxDoLog##level) \ wxDoLog##level##Wchar, wxDoLog##level##Utf8) \
DECLARE_LOG_FUNCTION2_EXP_WATCOM(level, argclass, arg, expdecl) \ DECLARE_LOG_FUNCTION2_EXP_WATCOM(level, argclass, arg, expdecl) \
extern void expdecl wxVLog##level(argclass arg, \ extern void expdecl wxVLog##level(argclass arg, \
const wxString& format, \ const wxString& format, \
@@ -514,13 +525,16 @@ WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
#define DECLARE_LOG_FUNCTION2_EXP_WATCOM(level, argclass, arg, expdecl) \ #define DECLARE_LOG_FUNCTION2_EXP_WATCOM(level, argclass, arg, expdecl) \
WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \ WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \
2, (argclass, const char*), \ 2, (argclass, const char*), \
wxDoLog##level) \ wxDoLog##level##Wchar, \
wxDoLog##level##Utf8) \
WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \ WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \
2, (argclass, const wchar_t*), \ 2, (argclass, const wchar_t*), \
wxDoLog##level) \ wxDoLog##level##Wchar, \
wxDoLog##level##Utf8) \
WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \ WX_DEFINE_VARARG_FUNC_VOID(wxLog##level, \
2, (argclass, const wxCStrData&), \ 2, (argclass, const wxCStrData&), \
wxDoLog##level) wxDoLog##level##Wchar, \
wxDoLog##level##Utf8)
#else #else
#define DECLARE_LOG_FUNCTION2_EXP_WATCOM(level, argclass, arg, expdecl) #define DECLARE_LOG_FUNCTION2_EXP_WATCOM(level, argclass, arg, expdecl)
#endif #endif

View File

@@ -26,6 +26,8 @@
#include "wx/dynarray.h" #include "wx/dynarray.h"
#include "wx/arrstr.h" #include "wx/arrstr.h"
#include <stdarg.h>
// fwd decls // fwd decls
class WXDLLIMPEXP_BASE wxIconLocation; class WXDLLIMPEXP_BASE wxIconLocation;
class WXDLLIMPEXP_BASE wxFileTypeImpl; class WXDLLIMPEXP_BASE wxFileTypeImpl;
@@ -117,13 +119,30 @@ private:
class WXDLLIMPEXP_BASE wxFileTypeInfo class WXDLLIMPEXP_BASE wxFileTypeInfo
{ {
private: private:
void VarArgInit(const wxString& mimeType, void DoVarArgInit(const wxString& mimeType,
const wxString& openCmd, const wxString& openCmd,
const wxString& printCmd, const wxString& printCmd,
const wxString& desc, const wxString& desc,
// the other parameters form a NULL terminated list of va_list argptr);
// extensions
...); #if !wxUSE_UTF8_LOCALE_ONLY
void VarArgInitWchar(const wxChar *mimeType,
const wxChar *openCmd,
const wxChar *printCmd,
const wxChar *desc,
// the other parameters form a NULL terminated list of
// extensions
...);
#endif
#if wxUSE_UNICODE_UTF8
void VarArgInitUtf8(const char *mimeType,
const char *openCmd,
const char *printCmd,
const char *desc,
// the other parameters form a NULL terminated list of
// extensions
...);
#endif
public: public:
// ctors // ctors
// a normal item // a normal item
@@ -138,21 +157,21 @@ public:
WX_DEFINE_VARARG_FUNC_CTOR(wxFileTypeInfo, WX_DEFINE_VARARG_FUNC_CTOR(wxFileTypeInfo,
4, (const wxString&, const wxString&, 4, (const wxString&, const wxString&,
const wxString&, const wxString&), const wxString&, const wxString&),
VarArgInit) VarArgInitWchar, VarArgInitUtf8)
#ifdef __WATCOMC__ #ifdef __WATCOMC__
// workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
WX_DEFINE_VARARG_FUNC_CTOR(wxFileTypeInfo, WX_DEFINE_VARARG_FUNC_CTOR(wxFileTypeInfo,
4, (const char*, const char*, 4, (const char*, const char*,
const char*, const char*), const char*, const char*),
VarArgInit) VarArgInitWchar, VarArgInitUtf8)
WX_DEFINE_VARARG_FUNC_CTOR(wxFileTypeInfo, WX_DEFINE_VARARG_FUNC_CTOR(wxFileTypeInfo,
4, (const wchar_t*, const wchar_t*, 4, (const wchar_t*, const wchar_t*,
const wchar_t*, const wchar_t*), const wchar_t*, const wchar_t*),
VarArgInit) VarArgInitWchar, VarArgInitUtf8)
WX_DEFINE_VARARG_FUNC_CTOR(wxFileTypeInfo, WX_DEFINE_VARARG_FUNC_CTOR(wxFileTypeInfo,
4, (const wxCStrData&, const wxCStrData&, 4, (const wxCStrData&, const wxCStrData&,
const wxCStrData&, const wxCStrData&), const wxCStrData&, const wxCStrData&),
VarArgInit) VarArgInitWchar, VarArgInitUtf8)
#endif #endif
// the array elements correspond to the parameters of the ctor above in // the array elements correspond to the parameters of the ctor above in

View File

@@ -37,18 +37,27 @@ public:
// show a message to the user // show a message to the user
// void Printf(const wxString& format, ...) = 0; // void Printf(const wxString& format, ...) = 0;
WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wxString&), DoPrintf) WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wxString&),
DoPrintfWchar, DoPrintfUtf8)
#ifdef __WATCOMC__ #ifdef __WATCOMC__
// workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const char*), DoPrintf) WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const char*),
WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wchar_t*), DoPrintf) DoPrintfWchar, DoPrintfUtf8)
WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wxCStrData&), DoPrintf) WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wchar_t*),
DoPrintfWchar, DoPrintfUtf8)
WX_DEFINE_VARARG_FUNC_VOID(Printf, 1, (const wxCStrData&),
DoPrintfWchar, DoPrintfUtf8)
#endif #endif
protected: protected:
// NB: this is pure virtual so that it can be implemented in dllexported // NB: this is pure virtual so that it can be implemented in dllexported
// wxMessagOutput class // wxMessagOutput class
virtual void DoPrintf(const wxString& format, ...) = 0; #if !wxUSE_UTF8_LOCALE_ONLY
virtual void DoPrintfWchar(const wxChar *format, ...) = 0;
#endif
#if wxUSE_UNICODE_UTF8
virtual void DoPrintfUtf8(const char *format, ...) = 0;
#endif
// called by DoPrintf() to output formatted string // called by DoPrintf() to output formatted string
virtual void Output(const wxString& str) = 0; virtual void Output(const wxString& str) = 0;
@@ -73,7 +82,12 @@ public:
static wxMessageOutput* Set(wxMessageOutput* msgout); static wxMessageOutput* Set(wxMessageOutput* msgout);
protected: protected:
virtual void DoPrintf(const wxString& format, ...); #if !wxUSE_UTF8_LOCALE_ONLY
virtual void DoPrintfWchar(const wxChar *format, ...);
#endif
#if wxUSE_UNICODE_UTF8
virtual void DoPrintfUtf8(const char *format, ...);
#endif
virtual void Output(const wxString& str) = 0; virtual void Output(const wxString& str) = 0;
private: private:

View File

@@ -297,8 +297,14 @@ class WXDLLIMPEXP_BASE wxStringPrintfMixinBase
protected: protected:
wxStringPrintfMixinBase() {} wxStringPrintfMixinBase() {}
int DoPrintf(const wxString& format, ...); #if !wxUSE_UTF8_LOCALE_ONLY
static wxString DoFormat(const wxString& format, ...); int DoPrintfWchar(const wxChar *format, ...);
static wxString DoFormatWchar(const wxChar *format, ...);
#endif
#if wxUSE_UNICODE_UTF8
int DoPrintfUtf8(const char *format, ...);
static wxString DoFormatUtf8(const char *format, ...);
#endif
}; };
// this class contains template wrappers for wxString's vararg methods, it's // this class contains template wrappers for wxString's vararg methods, it's
@@ -322,9 +328,9 @@ public:
// if !wxNEEDS_WXSTRING_PRINTF_MIXIN: // if !wxNEEDS_WXSTRING_PRINTF_MIXIN:
// static wxString Format(const wString& format, ...) ATTRIBUTE_PRINTF_1; // static wxString Format(const wString& format, ...) ATTRIBUTE_PRINTF_1;
WX_DEFINE_VARARG_FUNC2_SANS_N0(static typename StringReturnType<T1>::type, WX_DEFINE_VARARG_FUNC_SANS_N0(static typename StringReturnType<T1>::type,
Format, 1, (const wxString&), Format, 1, (const wxString&),
DoFormat, DoFormat) DoFormatWchar, DoFormatUtf8)
// We have to implement the version without template arguments manually // We have to implement the version without template arguments manually
// because of the StringReturnType<> hack, although WX_DEFINE_VARARG_FUNC // because of the StringReturnType<> hack, although WX_DEFINE_VARARG_FUNC
// normally does it itself. It has to be a template so that we can use // normally does it itself. It has to be a template so that we can use
@@ -339,9 +345,11 @@ public:
} }
// int Printf(const wxString& format, ...); // int Printf(const wxString& format, ...);
WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxString&), DoPrintf) WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxString&),
DoPrintfWchar, DoPrintfUtf8)
// int sprintf(const wxString& format, ...) ATTRIBUTE_PRINTF_2; // int sprintf(const wxString& format, ...) ATTRIBUTE_PRINTF_2;
WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wxString&), DoPrintf) WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wxString&),
DoPrintfWchar, DoPrintfUtf8)
protected: protected:
wxStringPrintfMixin() : wxStringPrintfMixinBase() {} wxStringPrintfMixin() : wxStringPrintfMixinBase() {}
@@ -1533,11 +1541,15 @@ public:
// as sprintf(), returns the number of characters written or < 0 on error // as sprintf(), returns the number of characters written or < 0 on error
// (take 'this' into account in attribute parameter count) // (take 'this' into account in attribute parameter count)
// int Printf(const wxString& format, ...); // int Printf(const wxString& format, ...);
WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxString&), DoPrintf) WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxString&),
DoPrintfWchar, DoPrintfUtf8)
#ifdef __WATCOMC__ #ifdef __WATCOMC__
WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const char*), DoPrintf) WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const char*)
WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wchar_t*), DoPrintf) DoPrintfWchar, DoPrintfUtf8)
WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxCStrData&), DoPrintf) WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wchar_t*)
DoPrintfWchar, DoPrintfUtf8)
WX_DEFINE_VARARG_FUNC(int, Printf, 1, (const wxCStrData&)
DoPrintfWchar, DoPrintfUtf8)
#endif #endif
#endif // !wxNEEDS_WXSTRING_PRINTF_MIXIN #endif // !wxNEEDS_WXSTRING_PRINTF_MIXIN
// as vprintf(), returns the number of characters written or < 0 on error // as vprintf(), returns the number of characters written or < 0 on error
@@ -1546,12 +1558,16 @@ public:
#ifndef wxNEEDS_WXSTRING_PRINTF_MIXIN #ifndef wxNEEDS_WXSTRING_PRINTF_MIXIN
// returns the string containing the result of Printf() to it // returns the string containing the result of Printf() to it
// static wxString Format(const wxString& format, ...) ATTRIBUTE_PRINTF_1; // static wxString Format(const wxString& format, ...) ATTRIBUTE_PRINTF_1;
WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const wxString&), DoFormat) WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const wxString&),
DoFormatWchar, DoFormatUtf8)
#ifdef __WATCOMC__ #ifdef __WATCOMC__
// workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const char*), DoFormat) WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const char*),
WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const wchar_t*), DoFormat) DoFormatWchar, DoFormatUtf8)
WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const wxCStrData&), DoFormat) WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const wchar_t*),
DoFormatWchar, DoFormatUtf8)
WX_DEFINE_VARARG_FUNC(static wxString, Format, 1, (const wxCStrData&),
DoFormatWchar, DoFormatUtf8)
#endif #endif
#endif #endif
// the same as above, but takes a va_list // the same as above, but takes a va_list
@@ -1589,12 +1605,16 @@ public:
// use Printf() // use Printf()
// (take 'this' into account in attribute parameter count) // (take 'this' into account in attribute parameter count)
// int sprintf(const wxString& format, ...) ATTRIBUTE_PRINTF_2; // int sprintf(const wxString& format, ...) ATTRIBUTE_PRINTF_2;
WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wxString&), DoPrintf) WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wxString&),
DoPrintfWchar, DoPrintfUtf8)
#ifdef __WATCOMC__ #ifdef __WATCOMC__
// workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const char*), DoPrintf) WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const char*),
WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wchar_t*), DoPrintf) DoPrintfWchar, DoPrintfUtf8)
WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wxCStrData&), DoPrintf) WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wchar_t*),
DoPrintfWchar, DoPrintfUtf8)
WX_DEFINE_VARARG_FUNC(int, sprintf, 1, (const wxCStrData&),
DoPrintfWchar, DoPrintfUtf8)
#endif #endif
#endif // wxNEEDS_WXSTRING_PRINTF_MIXIN #endif // wxNEEDS_WXSTRING_PRINTF_MIXIN
@@ -2369,8 +2389,14 @@ private:
#endif // !wxUSE_STL_BASED_WXSTRING #endif // !wxUSE_STL_BASED_WXSTRING
#ifndef wxNEEDS_WXSTRING_PRINTF_MIXIN #ifndef wxNEEDS_WXSTRING_PRINTF_MIXIN
int DoPrintf(const wxString& format, ...); #if !wxUSE_UTF8_LOCALE_ONLY
static wxString DoFormat(const wxString& format, ...); int DoPrintfWchar(const wxChar *format, ...);
static wxString DoFormatWchar(const wxChar *format, ...);
#endif
#if wxUSE_UNICODE_UTF8
int DoPrintfUtf8(const char *format, ...);
static wxString DoFormatUtf8(const char *format, ...);
#endif
#endif #endif
#if !wxUSE_STL_BASED_WXSTRING #if !wxUSE_STL_BASED_WXSTRING

View File

@@ -70,33 +70,25 @@ class WXDLLIMPEXP_BASE wxString;
// if wxUSE_UNICODE_UTF8 and running under UTF-8 locale // if wxUSE_UNICODE_UTF8 and running under UTF-8 locale
// (ignored otherwise) [fprintf] // (ignored otherwise) [fprintf]
// //
#define WX_DEFINE_VARARG_FUNC2(rettype, name, numfixed, fixed, impl, implUtf8)\ #define WX_DEFINE_VARARG_FUNC(rettype, name, numfixed, fixed, impl, implUtf8) \
_WX_VARARG_DEFINE_FUNC_N0(rettype, name, impl, implUtf8, numfixed, fixed) \ _WX_VARARG_DEFINE_FUNC_N0(rettype, name, impl, implUtf8, numfixed, fixed) \
WX_DEFINE_VARARG_FUNC2_SANS_N0(rettype, name, numfixed, fixed, impl, implUtf8) WX_DEFINE_VARARG_FUNC_SANS_N0(rettype, name, numfixed, fixed, impl, implUtf8)
// ditto, but without the version with 0 template/vararg arguments // ditto, but without the version with 0 template/vararg arguments
#define WX_DEFINE_VARARG_FUNC2_SANS_N0(rettype, name, \ #define WX_DEFINE_VARARG_FUNC_SANS_N0(rettype, name, \
numfixed, fixed, impl, implUtf8) \ numfixed, fixed, impl, implUtf8) \
_WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \ _WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \
_WX_VARARG_DEFINE_FUNC, \ _WX_VARARG_DEFINE_FUNC, \
rettype, name, impl, implUtf8, numfixed, fixed) rettype, name, impl, implUtf8, numfixed, fixed)
// like WX_DEFINE_VARARG_FUNC2, but for impl=implUtf8: // Like WX_DEFINE_VARARG_FUNC, but for variadic functions that don't return
#define WX_DEFINE_VARARG_FUNC(rettype, name, numfixed, fixed, impl) \
WX_DEFINE_VARARG_FUNC2(rettype, name, numfixed, fixed, impl, impl)
// Like WX_DEFINE_VARARG_FUNC2, but for variadic functions that don't return
// a value. // a value.
#define WX_DEFINE_VARARG_FUNC_VOID2(name, numfixed, fixed, impl, implUtf8) \ #define WX_DEFINE_VARARG_FUNC_VOID(name, numfixed, fixed, impl, implUtf8) \
_WX_VARARG_DEFINE_FUNC_VOID_N0(name, impl, implUtf8, numfixed, fixed) \ _WX_VARARG_DEFINE_FUNC_VOID_N0(name, impl, implUtf8, numfixed, fixed) \
_WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \ _WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \
_WX_VARARG_DEFINE_FUNC_VOID, \ _WX_VARARG_DEFINE_FUNC_VOID, \
void, name, impl, implUtf8, numfixed, fixed) void, name, impl, implUtf8, numfixed, fixed)
// like WX_DEFINE_VARARG_FUNC_VOID2, but for impl=implUtf8:
#define WX_DEFINE_VARARG_FUNC_VOID(name, numfixed, fixed, impl) \
WX_DEFINE_VARARG_FUNC_VOID2(name, numfixed, fixed, impl, impl)
// Like WX_DEFINE_VARARG_FUNC_VOID, but instead of wrapping an implementation // Like WX_DEFINE_VARARG_FUNC_VOID, but instead of wrapping an implementation
// function, does nothing in defined functions' bodies. // function, does nothing in defined functions' bodies.
// //
@@ -108,11 +100,11 @@ class WXDLLIMPEXP_BASE wxString;
void, name, dummy, dummy, numfixed, fixed) void, name, dummy, dummy, numfixed, fixed)
// Like WX_DEFINE_VARARG_FUNC_CTOR, but for defining template constructors // Like WX_DEFINE_VARARG_FUNC_CTOR, but for defining template constructors
#define WX_DEFINE_VARARG_FUNC_CTOR(name, numfixed, fixed, impl) \ #define WX_DEFINE_VARARG_FUNC_CTOR(name, numfixed, fixed, impl, implUtf8) \
_WX_VARARG_DEFINE_FUNC_CTOR_N0(name, impl, impl, numfixed, fixed) \ _WX_VARARG_DEFINE_FUNC_CTOR_N0(name, impl, implUtf8, numfixed, fixed) \
_WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \ _WX_VARARG_ITER(_WX_VARARG_MAX_ARGS, \
_WX_VARARG_DEFINE_FUNC_CTOR, \ _WX_VARARG_DEFINE_FUNC_CTOR, \
void, name, impl, impl, numfixed, fixed) void, name, impl, implUtf8, numfixed, fixed)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxArgNormalizer*<T> converters // wxArgNormalizer*<T> converters
@@ -548,7 +540,7 @@ private:
#define _WX_VARARG_ARG(i) T##i a##i #define _WX_VARARG_ARG(i) T##i a##i
// Like _WX_VARARG_ARG_UNUSED, but outputs argument's type with WXUNUSED: // Like _WX_VARARG_ARG_UNUSED, but outputs argument's type with WXUNUSED:
#define _WX_VARARG_ARG_UNUSED(i) T##i WXUNUSED(a##i) #define _WX_VARARG_ARG_UNUSED(i) T##i WXUNUSED(a##i)
// Generates code snippet for i-th type in vararg function's template<...>: // Generates code snippet for i-th type in vararg function's template<...>:
#define _WX_VARARG_TEMPL(i) typename T##i #define _WX_VARARG_TEMPL(i) typename T##i

View File

@@ -259,10 +259,10 @@
// we'll also need wxArgNormalizer<T> specializations for char, // we'll also need wxArgNormalizer<T> specializations for char,
// wchar_t, wxUniChar and wxUniCharRef to handle this correctly // wchar_t, wxUniChar and wxUniCharRef to handle this correctly
WX_DEFINE_VARARG_FUNC2(int, wxPrintf, 1, (const wxString&), WX_DEFINE_VARARG_FUNC(int, wxPrintf, 1, (const wxString&),
wxCRT_Printf, printf) wxCRT_Printf, printf)
WX_DEFINE_VARARG_FUNC2(int, wxFprintf, 2, (FILE*, const wxString&), WX_DEFINE_VARARG_FUNC(int, wxFprintf, 2, (FILE*, const wxString&),
wxCRT_Fprintf, fprintf) wxCRT_Fprintf, fprintf)
// va_list versions of printf functions simply forward to the respective // va_list versions of printf functions simply forward to the respective
// CRT function; note that they assume that va_list was created using // CRT function; note that they assume that va_list was created using
@@ -299,34 +299,56 @@ wxVfprintf(FILE *f, const wxString& format, va_list ap)
// wxSprintf() and friends have to be implemented in two forms, one for // wxSprintf() and friends have to be implemented in two forms, one for
// writing to char* buffer and one for writing to wchar_t*: // writing to char* buffer and one for writing to wchar_t*:
int WXDLLIMPEXP_BASE wxDoSprintf(char *str, const wxString& format, ...); #if !wxUSE_UTF8_LOCALE_ONLY
int WXDLLIMPEXP_BASE wxDoSprintfWchar(char *str, const wxChar *format, ...);
#endif
#if wxUSE_UNICODE_UTF8
int WXDLLIMPEXP_BASE wxDoSprintfUtf8(char *str, const char *format, ...);
#endif
WX_DEFINE_VARARG_FUNC(int, wxSprintf, 2, (char*, const wxString&), WX_DEFINE_VARARG_FUNC(int, wxSprintf, 2, (char*, const wxString&),
wxDoSprintf) wxDoSprintfWchar, wxDoSprintfUtf8)
int WXDLLIMPEXP_BASE int WXDLLIMPEXP_BASE
wxVsprintf(char *str, const wxString& format, va_list argptr); wxVsprintf(char *str, const wxString& format, va_list argptr);
int WXDLLIMPEXP_BASE wxDoSnprintf(char *str, size_t size, const wxString& format, ...); #if !wxUSE_UTF8_LOCALE_ONLY
int WXDLLIMPEXP_BASE wxDoSnprintfWchar(char *str, size_t size, const wxChar *format, ...);
#endif
#if wxUSE_UNICODE_UTF8
int WXDLLIMPEXP_BASE wxDoSnprintfUtf8(char *str, size_t size, const char *format, ...);
#endif
WX_DEFINE_VARARG_FUNC(int, wxSnprintf, 3, (char*, size_t, const wxString&), WX_DEFINE_VARARG_FUNC(int, wxSnprintf, 3, (char*, size_t, const wxString&),
wxDoSnprintf) wxDoSnprintfWchar, wxDoSnprintfUtf8)
int WXDLLIMPEXP_BASE int WXDLLIMPEXP_BASE
wxVsnprintf(char *str, size_t size, const wxString& format, va_list argptr); wxVsnprintf(char *str, size_t size, const wxString& format, va_list argptr);
#if wxUSE_UNICODE #if wxUSE_UNICODE
int WXDLLIMPEXP_BASE wxDoSprintf(wchar_t *str, const wxString& format, ...);
#if !wxUSE_UTF8_LOCALE_ONLY
int WXDLLIMPEXP_BASE wxDoSprintfWchar(wchar_t *str, const wxChar *format, ...);
#endif
#if wxUSE_UNICODE_UTF8
int WXDLLIMPEXP_BASE wxDoSprintfUtf8(wchar_t *str, const char *format, ...);
#endif
WX_DEFINE_VARARG_FUNC(int, wxSprintf, 2, (wchar_t*, const wxString&), WX_DEFINE_VARARG_FUNC(int, wxSprintf, 2, (wchar_t*, const wxString&),
wxDoSprintf) wxDoSprintfWchar, wxDoSprintfUtf8)
int WXDLLIMPEXP_BASE int WXDLLIMPEXP_BASE
wxVsprintf(wchar_t *str, const wxString& format, va_list argptr); wxVsprintf(wchar_t *str, const wxString& format, va_list argptr);
int WXDLLIMPEXP_BASE wxDoSnprintf(wchar_t *str, size_t size, const wxString& format, ...); #if !wxUSE_UTF8_LOCALE_ONLY
int WXDLLIMPEXP_BASE wxDoSnprintfWchar(wchar_t *str, size_t size, const wxChar *format, ...);
#endif
#if wxUSE_UNICODE_UTF8
int WXDLLIMPEXP_BASE wxDoSnprintfUtf8(wchar_t *str, size_t size, const char *format, ...);
#endif
WX_DEFINE_VARARG_FUNC(int, wxSnprintf, 3, (wchar_t*, size_t, const wxString&), WX_DEFINE_VARARG_FUNC(int, wxSnprintf, 3, (wchar_t*, size_t, const wxString&),
wxDoSnprintf) wxDoSnprintfWchar, wxDoSnprintfUtf8)
int WXDLLIMPEXP_BASE int WXDLLIMPEXP_BASE
wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argptr); wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argptr);
#endif // wxUSE_UNICODE #endif // wxUSE_UNICODE
#ifdef __WATCOMC__ #ifdef __WATCOMC__

View File

@@ -91,13 +91,51 @@ void wxVLogGeneric(wxLogLevel level, const wxString& format, va_list argptr)
} }
} }
void wxDoLogGeneric(wxLogLevel level, const wxString& format, ...) #if !wxUSE_UTF8_LOCALE_ONLY
void wxDoLogGenericWchar(wxLogLevel level, const wxChar *format, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, format); va_start(argptr, format);
wxVLogGeneric(level, format, argptr); wxVLogGeneric(level, format, argptr);
va_end(argptr); va_end(argptr);
} }
#endif // wxUSE_UTF8_LOCALE_ONLY
#if wxUSE_UNICODE_UTF8
void wxDoLogGenericUtf8(wxLogLevel level, const char *format, ...)
{
va_list argptr;
va_start(argptr, format);
wxVLogGeneric(level, format, argptr);
va_end(argptr);
}
#endif // wxUSE_UNICODE_UTF8
#if !wxUSE_UTF8_LOCALE_ONLY
#define IMPLEMENT_LOG_FUNCTION_WCHAR(level) \
void wxDoLog##level##Wchar(const wxChar *format, ...) \
{ \
va_list argptr; \
va_start(argptr, format); \
wxVLog##level(format, argptr); \
va_end(argptr); \
}
#else
#define IMPLEMENT_LOG_FUNCTION_WCHAR(level)
#endif
#if wxUSE_UNICODE_UTF8
#define IMPLEMENT_LOG_FUNCTION_UTF8(level) \
void wxDoLog##level##Utf8(const char *format, ...) \
{ \
va_list argptr; \
va_start(argptr, format); \
wxVLog##level(format, argptr); \
va_end(argptr); \
}
#else
#define IMPLEMENT_LOG_FUNCTION_UTF8(level)
#endif
#define IMPLEMENT_LOG_FUNCTION(level) \ #define IMPLEMENT_LOG_FUNCTION(level) \
void wxVLog##level(const wxString& format, va_list argptr) \ void wxVLog##level(const wxString& format, va_list argptr) \
@@ -107,14 +145,8 @@ void wxDoLogGeneric(wxLogLevel level, const wxString& format, ...)
wxString::FormatV(format, argptr), time(NULL)); \ wxString::FormatV(format, argptr), time(NULL)); \
} \ } \
} \ } \
\ IMPLEMENT_LOG_FUNCTION_WCHAR(level) \
void wxDoLog##level(const wxString& format, ...) \ IMPLEMENT_LOG_FUNCTION_UTF8(level)
{ \
va_list argptr; \
va_start(argptr, format); \
wxVLog##level(format, argptr); \
va_end(argptr); \
}
IMPLEMENT_LOG_FUNCTION(Error) IMPLEMENT_LOG_FUNCTION(Error)
IMPLEMENT_LOG_FUNCTION(Warning) IMPLEMENT_LOG_FUNCTION(Warning)
@@ -145,7 +177,8 @@ void wxVLogFatalError(const wxString& format, va_list argptr)
#endif #endif
} }
void wxDoLogFatalError(const wxString& format, ...) #if !wxUSE_UTF8_LOCALE_ONLY
void wxDoLogFatalErrorWchar(const wxChar *format, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, format); va_start(argptr, format);
@@ -155,6 +188,20 @@ void wxDoLogFatalError(const wxString& format, ...)
// for the others anyhow... // for the others anyhow...
//va_end(argptr); //va_end(argptr);
} }
#endif // wxUSE_UTF8_LOCALE_ONLY
#if wxUSE_UNICODE_UTF8
void wxDoLogFatalErrorUtf8(const char *format, ...)
{
va_list argptr;
va_start(argptr, format);
wxVLogFatalError(format, argptr);
// some compilers warn about unreachable code and it shouldn't matter
// for the others anyhow...
//va_end(argptr);
}
#endif // wxUSE_UNICODE_UTF8
// same as info, but only if 'verbose' mode is on // same as info, but only if 'verbose' mode is on
void wxVLogVerbose(const wxString& format, va_list argptr) void wxVLogVerbose(const wxString& format, va_list argptr)
@@ -167,16 +214,55 @@ void wxVLogVerbose(const wxString& format, va_list argptr)
} }
} }
void wxDoLogVerbose(const wxString& format, ...) #if !wxUSE_UTF8_LOCALE_ONLY
void wxDoLogVerboseWchar(const wxChar *format, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, format); va_start(argptr, format);
wxVLogVerbose(format, argptr); wxVLogVerbose(format, argptr);
va_end(argptr); va_end(argptr);
} }
#endif // !wxUSE_UTF8_LOCALE_ONLY
#if wxUSE_UNICODE_UTF8
void wxDoLogVerboseUtf8(const char *format, ...)
{
va_list argptr;
va_start(argptr, format);
wxVLogVerbose(format, argptr);
va_end(argptr);
}
#endif // wxUSE_UNICODE_UTF8
// debug functions // debug functions
#ifdef __WXDEBUG__ #ifdef __WXDEBUG__
#if !wxUSE_UTF8_LOCALE_ONLY
#define IMPLEMENT_LOG_DEBUG_FUNCTION_WCHAR(level) \
void wxDoLog##level##Wchar(const wxChar *format, ...) \
{ \
va_list argptr; \
va_start(argptr, format); \
wxVLog##level(format, argptr); \
va_end(argptr); \
}
#else
#define IMPLEMENT_LOG_DEBUG_FUNCTION_WCHAR(level)
#endif
#if wxUSE_UNICODE_UTF8
#define IMPLEMENT_LOG_DEBUG_FUNCTION_UTF8(level) \
void wxDoLog##level##Utf8(const char *format, ...) \
{ \
va_list argptr; \
va_start(argptr, format); \
wxVLog##level(format, argptr); \
va_end(argptr); \
}
#else
#define IMPLEMENT_LOG_DEBUG_FUNCTION_UTF8(level)
#endif
#define IMPLEMENT_LOG_DEBUG_FUNCTION(level) \ #define IMPLEMENT_LOG_DEBUG_FUNCTION(level) \
void wxVLog##level(const wxString& format, va_list argptr) \ void wxVLog##level(const wxString& format, va_list argptr) \
{ \ { \
@@ -185,14 +271,9 @@ void wxDoLogVerbose(const wxString& format, ...)
wxString::FormatV(format, argptr), time(NULL)); \ wxString::FormatV(format, argptr), time(NULL)); \
} \ } \
} \ } \
\ IMPLEMENT_LOG_DEBUG_FUNCTION_WCHAR(level) \
void wxDoLog##level(const wxString& format, ...) \ IMPLEMENT_LOG_DEBUG_FUNCTION_UTF8(level)
{ \
va_list argptr; \
va_start(argptr, format); \
wxVLog##level(format, argptr); \
va_end(argptr); \
}
void wxVLogTrace(const wxString& mask, const wxString& format, va_list argptr) void wxVLogTrace(const wxString& mask, const wxString& format, va_list argptr)
{ {
@@ -204,13 +285,25 @@ void wxDoLogVerbose(const wxString& format, ...)
} }
} }
void wxDoLogTrace(const wxString& mask, const wxString& format, ...) #if !wxUSE_UTF8_LOCALE_ONLY
void wxDoLogTraceWchar(const wxString& mask, const wxChar *format, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, format); va_start(argptr, format);
wxVLogTrace(mask, format, argptr); wxVLogTrace(mask, format, argptr);
va_end(argptr); va_end(argptr);
} }
#endif // !wxUSE_UTF8_LOCALE_ONLY
#if wxUSE_UNICODE_UTF8
void wxDoLogTraceUtf8(const wxString& mask, const char *format, ...)
{
va_list argptr;
va_start(argptr, format);
wxVLogTrace(mask, format, argptr);
va_end(argptr);
}
#endif // wxUSE_UNICODE_UTF8
void wxVLogTrace(wxTraceMask mask, const wxString& format, va_list argptr) void wxVLogTrace(wxTraceMask mask, const wxString& format, va_list argptr)
{ {
@@ -222,17 +315,29 @@ void wxDoLogVerbose(const wxString& format, ...)
} }
} }
void wxDoLogTrace(wxTraceMask mask, const wxString& format, ...) #if wxUSE_UTF8_LOCALE_ONLY
void wxDoLogTraceWchar(wxTraceMask mask, const wxChar *format, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, format); va_start(argptr, format);
wxVLogTrace(mask, format, argptr); wxVLogTrace(mask, format, argptr);
va_end(argptr); va_end(argptr);
} }
#endif // wxUSE_UTF8_LOCALE_ONLY
#if wxUSE_UNICODE_UTF8
void wxDoLogTraceUtf8(wxTraceMask mask, const char *format, ...)
{
va_list argptr;
va_start(argptr, format);
wxVLogTrace(mask, format, argptr);
va_end(argptr);
}
#endif // wxUSE_UNICODE_UTF8
#ifdef __WATCOMC__ #ifdef __WATCOMC__
// workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
void wxDoLogTrace(int mask, const wxString& format, ...) void wxDoLogTrace(int mask, const wxChar *format, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, format); va_start(argptr, format);
@@ -240,7 +345,7 @@ void wxDoLogVerbose(const wxString& format, ...)
va_end(argptr); va_end(argptr);
} }
void wxDoLogTrace(const char *mask, const wxString& format, ...) void wxDoLogTrace(const char *mask, const wxChar *format, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, format); va_start(argptr, format);
@@ -248,7 +353,7 @@ void wxDoLogVerbose(const wxString& format, ...)
va_end(argptr); va_end(argptr);
} }
void wxDoLogTrace(const wchar_t *mask, const wxString& format, ...) void wxDoLogTrace(const wchar_t *mask, const wxChar *format, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, format); va_start(argptr, format);
@@ -285,13 +390,25 @@ void WXDLLEXPORT wxVLogSysError(const wxString& format, va_list argptr)
wxVLogSysError(wxSysErrorCode(), format, argptr); wxVLogSysError(wxSysErrorCode(), format, argptr);
} }
void WXDLLEXPORT wxDoLogSysError(const wxString& format, ...) #if !wxUSE_UTF8_LOCALE_ONLY
void WXDLLEXPORT wxDoLogSysErrorWchar(const wxChar *format, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, format); va_start(argptr, format);
wxVLogSysError(format, argptr); wxVLogSysError(format, argptr);
va_end(argptr); va_end(argptr);
} }
#endif // !wxUSE_UTF8_LOCALE_ONLY
#if wxUSE_UNICODE_UTF8
void WXDLLEXPORT wxDoLogSysErrorUtf8(const char *format, ...)
{
va_list argptr;
va_start(argptr, format);
wxVLogSysError(format, argptr);
va_end(argptr);
}
#endif // wxUSE_UNICODE_UTF8
void WXDLLEXPORT wxVLogSysError(long err, const wxString& format, va_list argptr) void WXDLLEXPORT wxVLogSysError(long err, const wxString& format, va_list argptr)
{ {
@@ -302,17 +419,29 @@ void WXDLLEXPORT wxVLogSysError(long err, const wxString& format, va_list argptr
} }
} }
void WXDLLEXPORT wxDoLogSysError(long lErrCode, const wxString& format, ...) #if !wxUSE_UTF8_LOCALE_ONLY
void WXDLLEXPORT wxDoLogSysErrorWchar(long lErrCode, const wxChar *format, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, format); va_start(argptr, format);
wxVLogSysError(lErrCode, format, argptr); wxVLogSysError(lErrCode, format, argptr);
va_end(argptr); va_end(argptr);
} }
#endif // !wxUSE_UTF8_LOCALE_ONLY
#if wxUSE_UNICODE_UTF8
void WXDLLEXPORT wxDoLogSysErrorUtf8(long lErrCode, const char *format, ...)
{
va_list argptr;
va_start(argptr, format);
wxVLogSysError(lErrCode, format, argptr);
va_end(argptr);
}
#endif // wxUSE_UNICODE_UTF8
#ifdef __WATCOMC__ #ifdef __WATCOMC__
// workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351 // workaround for http://bugzilla.openwatcom.org/show_bug.cgi?id=351
void WXDLLEXPORT wxDoLogSysError(unsigned long lErrCode, const wxString& format, ...) void WXDLLEXPORT wxDoLogSysError(unsigned long lErrCode, const wxChar *format, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, format); va_start(argptr, format);
@@ -320,7 +449,7 @@ void WXDLLEXPORT wxDoLogSysError(unsigned long lErrCode, const wxString& format,
va_end(argptr); va_end(argptr);
} }
void WXDLLEXPORT wxVLogSysError(unsigned long err, const wxString& format, va_list argptr) void WXDLLEXPORT wxVLogSysError(unsigned long err, const wxChar *format, va_list argptr)
{ wxVLogSysError((long)err, format, argptr); } { wxVLogSysError((long)err, format, argptr); }
#endif // __WATCOMC__ #endif // __WATCOMC__

View File

@@ -111,15 +111,12 @@ wxString wxMimeTypeCommands::GetVerbCmd(size_t n) const
// wxFileTypeInfo // wxFileTypeInfo
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxFileTypeInfo::VarArgInit(const wxString& mimeType, void wxFileTypeInfo::DoVarArgInit(const wxString& mimeType,
const wxString& openCmd, const wxString& openCmd,
const wxString& printCmd, const wxString& printCmd,
const wxString& desc, const wxString& desc,
...) va_list argptr)
{ {
va_list argptr;
va_start(argptr, desc);
m_mimeType = mimeType; m_mimeType = mimeType;
m_openCmd = openCmd; m_openCmd = openCmd;
m_printCmd = printCmd; m_printCmd = printCmd;
@@ -146,9 +143,46 @@ void wxFileTypeInfo::VarArgInit(const wxString& mimeType,
m_exts.Add(ext.GetString()); m_exts.Add(ext.GetString());
} }
}
// NB: DoVarArgInit uses WX_VA_ARG_STRING macro to extract the string and this
// macro interprets the argument as char* or wchar_t* depending on build
// (and in UTF8 build, on the current locale). Because only one of the
// vararg forms below is called and the decision about which one gets
// called depends on the same conditions WX_VA_ARG_STRING uses, we can
// implement both of them in the exact same way:
#if !wxUSE_UTF8_LOCALE_ONLY
void wxFileTypeInfo::VarArgInitWchar(const wxChar *mimeType,
const wxChar *openCmd,
const wxChar *printCmd,
const wxChar *desc,
...)
{
va_list argptr;
va_start(argptr, desc);
DoVarArgInit(mimeType, openCmd, printCmd, desc, argptr);
va_end(argptr); va_end(argptr);
} }
#endif // !wxUSE_UTF8_LOCALE_ONLY
#if wxUSE_UNICODE_UTF8
void wxFileTypeInfo::VarArgInitUtf8(const char *mimeType,
const char *openCmd,
const char *printCmd,
const char *desc,
...)
{
va_list argptr;
va_start(argptr, desc);
DoVarArgInit(mimeType, openCmd, printCmd, desc, argptr);
va_end(argptr);
}
#endif // wxUSE_UNICODE_UTF8
wxFileTypeInfo::wxFileTypeInfo(const wxArrayString& sArray) wxFileTypeInfo::wxFileTypeInfo(const wxArrayString& sArray)

View File

@@ -76,7 +76,8 @@ wxMessageOutput* wxMessageOutput::Set(wxMessageOutput* msgout)
return old; return old;
} }
void wxMessageOutput::DoPrintf(const wxString& format, ...) #if !wxUSE_UTF8_LOCALE_ONLY
void wxMessageOutput::DoPrintfWchar(const wxChar *format, ...)
{ {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
@@ -87,6 +88,21 @@ void wxMessageOutput::DoPrintf(const wxString& format, ...)
Output(out); Output(out);
} }
#endif // !wxUSE_UTF8_LOCALE_ONLY
#if wxUSE_UNICODE_UTF8
void wxMessageOutput::DoPrintfUtf8(const char *format, ...)
{
va_list args;
va_start(args, format);
wxString out;
out.PrintfV(format, args);
va_end(args);
Output(out);
}
#endif // wxUSE_UNICODE_UTF8
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxMessageOutputBest // wxMessageOutputBest

View File

@@ -1447,11 +1447,12 @@ bool wxString::ToDouble(double *val) const
// formatted output // formatted output
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
#if !wxUSE_UTF8_LOCALE_ONLY
/* static */ /* static */
#ifdef wxNEEDS_WXSTRING_PRINTF_MIXIN #ifdef wxNEEDS_WXSTRING_PRINTF_MIXIN
wxString wxStringPrintfMixinBase::DoFormat(const wxString& format, ...) wxString wxStringPrintfMixinBase::DoFormat(const wxChar *format, ...)
#else #else
wxString wxString::DoFormat(const wxString& format, ...) wxString wxString::DoFormatWchar(const wxChar *format, ...)
#endif #endif
{ {
va_list argptr; va_list argptr;
@@ -1464,6 +1465,23 @@ wxString wxString::DoFormat(const wxString& format, ...)
return s; return s;
} }
#endif // !wxUSE_UTF8_LOCALE_ONLY
#if wxUSE_UNICODE_UTF8
/* static */
wxString wxString::DoFormatUtf8(const char *format, ...)
{
va_list argptr;
va_start(argptr, format);
wxString s;
s.PrintfV(format, argptr);
va_end(argptr);
return s;
}
#endif // wxUSE_UNICODE_UTF8
/* static */ /* static */
wxString wxString::FormatV(const wxString& format, va_list argptr) wxString wxString::FormatV(const wxString& format, va_list argptr)
@@ -1473,10 +1491,11 @@ wxString wxString::FormatV(const wxString& format, va_list argptr)
return s; return s;
} }
#if !wxUSE_UTF8_LOCALE_ONLY
#ifdef wxNEEDS_WXSTRING_PRINTF_MIXIN #ifdef wxNEEDS_WXSTRING_PRINTF_MIXIN
int wxStringPrintfMixinBase::DoPrintf(const wxString& format, ...) int wxStringPrintfMixinBase::DoPrintfWchar(const wxChar *format, ...)
#else #else
int wxString::DoPrintf(const wxString& format, ...) int wxString::DoPrintfWchar(const wxChar *format, ...)
#endif #endif
{ {
va_list argptr; va_list argptr;
@@ -1497,6 +1516,21 @@ int wxString::DoPrintf(const wxString& format, ...)
return iLen; return iLen;
} }
#endif // !wxUSE_UTF8_LOCALE_ONLY
#if wxUSE_UNICODE_UTF8
int wxString::DoPrintfUtf8(const char *format, ...)
{
va_list argptr;
va_start(argptr, format);
int iLen = PrintfV(format, argptr);
va_end(argptr);
return iLen;
}
#endif // wxUSE_UNICODE_UTF8
#if wxUSE_UNICODE_UTF8 #if wxUSE_UNICODE_UTF8
template<typename BufferType> template<typename BufferType>

View File

@@ -606,7 +606,8 @@ int wxCRT_Vsprintf( wxChar *str, const wxChar *format, va_list argptr )
// wrappers to printf and scanf function families // wrappers to printf and scanf function families
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
int wxDoSprintf(char *str, const wxString& format, ...) #if !wxUSE_UTF8_LOCALE_ONLY
int wxDoSprintfWchar(char *str, const wxChar *format, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, format); va_start(argptr, format);
@@ -616,9 +617,10 @@ int wxDoSprintf(char *str, const wxString& format, ...)
va_end(argptr); va_end(argptr);
return rv; return rv;
} }
#endif // !wxUSE_UTF8_LOCALE_ONLY
#if wxUSE_UNICODE #if wxUSE_UNICODE_UTF8
int wxDoSprintf(wchar_t *str, const wxString& format, ...) int wxDoSprintfUtf8(char *str, const char *format, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, format); va_start(argptr, format);
@@ -628,21 +630,40 @@ int wxDoSprintf(wchar_t *str, const wxString& format, ...)
va_end(argptr); va_end(argptr);
return rv; return rv;
} }
#endif #endif // wxUSE_UNICODE_UTF8
int wxDoSnprintf(char *str, size_t size, const wxString& format, ...)
{
va_list argptr;
va_start(argptr, format);
int rv = wxVsnprintf(str, size, format, argptr);
va_end(argptr);
return rv;
}
#if wxUSE_UNICODE #if wxUSE_UNICODE
int wxDoSnprintf(wchar_t *str, size_t size, const wxString& format, ...)
#if !wxUSE_UTF8_LOCALE_ONLY
int wxDoSprintfWchar(wchar_t *str, const wxChar *format, ...)
{
va_list argptr;
va_start(argptr, format);
int rv = wxVsprintf(str, format, argptr);
va_end(argptr);
return rv;
}
#endif // !wxUSE_UTF8_LOCALE_ONLY
#if wxUSE_UNICODE_UTF8
int wxDoSprintfUtf8(wchar_t *str, const char *format, ...)
{
va_list argptr;
va_start(argptr, format);
int rv = wxVsprintf(str, format, argptr);
va_end(argptr);
return rv;
}
#endif // wxUSE_UNICODE_UTF8
#endif // wxUSE_UNICODE
#if !wxUSE_UTF8_LOCALE_ONLY
int wxDoSnprintfWchar(char *str, size_t size, const wxChar *format, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, format); va_start(argptr, format);
@@ -652,7 +673,50 @@ int wxDoSnprintf(wchar_t *str, size_t size, const wxString& format, ...)
va_end(argptr); va_end(argptr);
return rv; return rv;
} }
#endif #endif // !wxUSE_UTF8_LOCALE_ONLY
#if wxUSE_UNICODE_UTF8
int wxDoSnprintfUtf8(char *str, size_t size, const char *format, ...)
{
va_list argptr;
va_start(argptr, format);
int rv = wxVsnprintf(str, size, format, argptr);
va_end(argptr);
return rv;
}
#endif // wxUSE_UNICODE_UTF8
#if wxUSE_UNICODE
#if !wxUSE_UTF8_LOCALE_ONLY
int wxDoSnprintfWchar(wchar_t *str, size_t size, const wxChar *format, ...)
{
va_list argptr;
va_start(argptr, format);
int rv = wxVsnprintf(str, size, format, argptr);
va_end(argptr);
return rv;
}
#endif // !wxUSE_UTF8_LOCALE_ONLY
#if wxUSE_UNICODE_UTF8
int wxDoSnprintfUtf8(wchar_t *str, size_t size, const char *format, ...)
{
va_list argptr;
va_start(argptr, format);
int rv = wxVsnprintf(str, size, format, argptr);
va_end(argptr);
return rv;
}
#endif // wxUSE_UNICODE_UTF8
#endif // wxUSE_UNICODE
#ifdef HAVE_BROKEN_VSNPRINTF_DECL #ifdef HAVE_BROKEN_VSNPRINTF_DECL
@@ -660,6 +724,8 @@ int wxDoSnprintf(wchar_t *str, size_t size, const wxString& format, ...)
#endif #endif
#if wxUSE_UNICODE #if wxUSE_UNICODE
#if !wxUSE_UTF8_LOCALE_ONLY
static int ConvertStringToBuf(const wxString& s, char *out, size_t outsize) static int ConvertStringToBuf(const wxString& s, char *out, size_t outsize)
{ {
const wxWX2WCbuf buf = s.wc_str(); const wxWX2WCbuf buf = s.wc_str();
@@ -670,6 +736,7 @@ static int ConvertStringToBuf(const wxString& s, char *out, size_t outsize)
else else
return wxConvLibc.FromWChar(NULL, 0, buf); return wxConvLibc.FromWChar(NULL, 0, buf);
} }
#endif // !wxUSE_UTF8_LOCALE_ONLY
#if wxUSE_UNICODE_UTF8 #if wxUSE_UNICODE_UTF8
static int ConvertStringToBuf(const wxString& s, wchar_t *out, size_t outsize) static int ConvertStringToBuf(const wxString& s, wchar_t *out, size_t outsize)
@@ -681,7 +748,7 @@ static int ConvertStringToBuf(const wxString& s, wchar_t *out, size_t outsize)
// else: not enough space // else: not enough space
return len; return len;
} }
#endif #endif // wxUSE_UNICODE_UTF8
template<typename T> template<typename T>
static size_t PrintfViaString(T *out, size_t outsize, static size_t PrintfViaString(T *out, size_t outsize,

View File

@@ -2228,13 +2228,25 @@ void wxPostScriptDC::DoGetTextExtent(const wxString& string,
} }
// print postscript datas via required method (file, stream) // print postscript datas via required method (file, stream)
void wxPostScriptDC::DoPsPrintfFormat(const wxString& fmt, ...) #if !wxUSE_UTF8_LOCALE_ONLY
void wxPostScriptDC::DoPsPrintfFormatWchar(const wxChar *fmt, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, fmt); va_start(argptr, fmt);
PsPrint( wxString::FormatV( fmt, argptr ) ); PsPrint( wxString::FormatV( fmt, argptr ) );
} }
#endif // !wxUSE_UTF8_LOCALE_ONLY
#if wxUSE_UNICODE_UTF8
void wxPostScriptDC::DoPsPrintfFormatUtf8(const char *fmt, ...)
{
va_list argptr;
va_start(argptr, fmt);
PsPrint( wxString::FormatV( fmt, argptr ) );
}
#endif // wxUSE_UNICODE_UTF8
void wxPostScriptDC::PsPrint( const wxString& str ) void wxPostScriptDC::PsPrint( const wxString& str )
{ {

View File

@@ -225,13 +225,25 @@ void wxVLogStatus(wxFrame *pFrame, const wxString& format, va_list argptr)
} }
} }
void wxDoLogStatus(wxFrame *pFrame, const wxString& format, ...) #if !wxUSE_UTF8_LOCALE_ONLY
void wxDoLogStatusWchar(wxFrame *pFrame, const wxChar *format, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, format); va_start(argptr, format);
wxVLogStatus(pFrame, format, argptr); wxVLogStatus(pFrame, format, argptr);
va_end(argptr); va_end(argptr);
} }
#endif // !wxUSE_UTF8_LOCALE_ONLY
#if wxUSE_UNICODE_UTF8
void wxDoLogStatusUtf8(wxFrame *pFrame, const char *format, ...)
{
va_list argptr;
va_start(argptr, format);
wxVLogStatus(pFrame, format, argptr);
va_end(argptr);
}
#endif // wxUSE_UNICODE_UTF8
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxLogGui implementation (FIXME MT-unsafe) // wxLogGui implementation (FIXME MT-unsafe)