git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45099
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
#endif // wxUSE_UNICODE_WCHAR / !wxUSE_UNICODE_WCHAR && wxUSE_WCHAR_T
#endif // wxUSE_UNICODE_WCHAR / !wxUSE_UNICODE_WCHAR && wxUSE_WCHAR_T
+// versions for passing wx[W]CharBuffer:
+template<>
+struct WXDLLIMPEXP_BASE wxArgNormalizer<wxCharBuffer>
+ : public wxArgNormalizer<const char*>
+{
+ wxArgNormalizer(const wxCharBuffer& buf);
+};
+
+template<>
+struct WXDLLIMPEXP_BASE wxArgNormalizer<wxWCharBuffer>
+ : public wxArgNormalizer<const wchar_t*>
+{
+ wxArgNormalizer(const wxWCharBuffer& buf);
+};
+
+
+
// NB: The vararg emulation code is limited to 30 arguments at the moment.
// If you need more, you need to
// 1) increase the value of _WX_VARARG_MAX_ARGS
// NB: The vararg emulation code is limited to 30 arguments at the moment.
// If you need more, you need to
// 1) increase the value of _WX_VARARG_MAX_ARGS
}
#endif // wxUSE_UNICODE_WCHAR / !wxUSE_UNICODE_WCHAR && wxUSE_WCHAR_T
}
#endif // wxUSE_UNICODE_WCHAR / !wxUSE_UNICODE_WCHAR && wxUSE_WCHAR_T
+
+// FIXME-UTF8: move this to the header once it's possible to include buffer.h
+// without including wxcrt.h
+
+wxArgNormalizer<wxCharBuffer>::wxArgNormalizer(const wxCharBuffer& buf)
+ : wxArgNormalizer<const char*>(buf.data())
+{
+}
+
+wxArgNormalizer<wxWCharBuffer>::wxArgNormalizer(const wxWCharBuffer& buf)
+ : wxArgNormalizer<const wchar_t*>(buf.data())
+{
+}
+ // test passing literals:
s.Printf("%s %i", "foo", 42);
CPPUNIT_ASSERT( s == "foo 42" );
s.Printf("%s %s %i", _T("bar"), "=", 11);
s.Printf("%s %i", "foo", 42);
CPPUNIT_ASSERT( s == "foo 42" );
s.Printf("%s %s %i", _T("bar"), "=", 11);
+
+ // test passing c_str():
CPPUNIT_ASSERT( s == "bar = 11" );
s2.Printf("(%s)", s.c_str());
CPPUNIT_ASSERT( s2 == "(bar = 11)" );
s2.Printf(_T("[%s](%s)"), s.c_str(), "str");
CPPUNIT_ASSERT( s2 == "[bar = 11](str)" );
CPPUNIT_ASSERT( s == "bar = 11" );
s2.Printf("(%s)", s.c_str());
CPPUNIT_ASSERT( s2 == "(bar = 11)" );
s2.Printf(_T("[%s](%s)"), s.c_str(), "str");
CPPUNIT_ASSERT( s2 == "[bar = 11](str)" );
+ // test passing wxString directly:
s2.Printf(_T("[%s](%s)"), s, "str");
CPPUNIT_ASSERT( s2 == "[bar = 11](str)" );
s2.Printf(_T("[%s](%s)"), s, "str");
CPPUNIT_ASSERT( s2 == "[bar = 11](str)" );
+
+ // test passing wxCharBufferType<T>:
+ s = "FooBar";
+ s2.Printf(_T("(%s)"), s.mb_str());
+ CPPUNIT_ASSERT( s2 == "(FooBar)" );
+ s2.Printf(_T("value=%s;"), s.wc_str());
+ CPPUNIT_ASSERT( s2 == "value=FooBar;" );