]>
git.saurik.com Git - wxWidgets.git/blob - src/common/strvararg.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/strvararg.cpp
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 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
26 #include "wx/strvararg.h"
27 #include "wx/buffer.h"
28 #include "wx/strconv.h"
29 #include "wx/string.h"
31 // ============================================================================
33 // ============================================================================
35 const wxStringCharType
*wxArgNormalizer
<const wxCStrData
&>::get() const
40 const wxStringCharType
*wxArgNormalizer
<const wxString
&>::get() const
42 return m_value
.wx_str();
45 #if wxUSE_UNICODE_WCHAR
47 wxArgNormalizer
<const char*>::wxArgNormalizer(const char *value
)
49 m_value
= new wxWCharBuffer(wxConvLibc
.cMB2WC(value
));
52 wxArgNormalizer
<const char*>::~wxArgNormalizer()
57 const wchar_t *wxArgNormalizer
<const char*>::get() const
59 return m_value
->data();
62 #elif wxUSE_WCHAR_T // !wxUSE_UNICODE_WCHAR && wxUSE_WCHAR_T
64 wxArgNormalizer
<const wchar_t*>::wxArgNormalizer(const wchar_t *value
)
66 m_value
= new wxCharBuffer(wxConvLibc
.cWC2MB(value
));
69 wxArgNormalizer
<const wchar_t*>::~wxArgNormalizer()
74 const char *wxArgNormalizer
<const wchar_t*>::get() const
76 return m_value
->data();
79 #endif // wxUSE_UNICODE_WCHAR / !wxUSE_UNICODE_WCHAR && wxUSE_WCHAR_T
81 // FIXME-UTF8: move this to the header once it's possible to include buffer.h
82 // without including wxcrt.h
84 wxArgNormalizer
<wxCharBuffer
>::wxArgNormalizer(const wxCharBuffer
& buf
)
85 : wxArgNormalizer
<const char*>(buf
.data())
89 wxArgNormalizer
<wxWCharBuffer
>::wxArgNormalizer(const wxWCharBuffer
& buf
)
90 : wxArgNormalizer
<const wchar_t*>(buf
.data())