]>
Commit | Line | Data |
---|---|---|
c9f78968 VS |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: src/common/strvararg.cpp | |
3 | // Purpose: macros for implementing type-safe vararg passing of strings | |
4 | // Author: Vaclav Slavik | |
5 | // Created: 2007-02-19 | |
6 | // RCS-ID: $Id$ | |
7 | // Copyright: (c) 2007 REA Elektronik GmbH | |
8 | // Licence: wxWindows licence | |
9 | /////////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | // ============================================================================ | |
12 | // declarations | |
13 | // ============================================================================ | |
14 | ||
15 | // ---------------------------------------------------------------------------- | |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
19 | // for compilers that support precompilation, includes "wx.h". | |
20 | #include "wx/wxprec.h" | |
21 | ||
22 | #ifdef __BORLANDC__ | |
23 | #pragma hdrstop | |
24 | #endif | |
25 | ||
26 | #include "wx/strvararg.h" | |
c9f78968 VS |
27 | #include "wx/string.h" |
28 | ||
29 | // ============================================================================ | |
30 | // implementation | |
31 | // ============================================================================ | |
32 | ||
c9f78968 | 33 | |
2523e9b7 | 34 | const wxStringCharType *wxArgNormalizerNative<const wxString&>::get() const |
c9f78968 | 35 | { |
8f93a29f | 36 | return m_value.wx_str(); |
c9f78968 | 37 | } |
c9f78968 | 38 | |
2523e9b7 | 39 | const wxStringCharType *wxArgNormalizerNative<const wxCStrData&>::get() const |
c9f78968 | 40 | { |
2523e9b7 | 41 | return m_value.AsInternal(); |
c9f78968 VS |
42 | } |
43 | ||
2523e9b7 VS |
44 | #if wxUSE_UNICODE_UTF8 |
45 | wxArgNormalizerWchar<const wxString&>::wxArgNormalizerWchar(const wxString& s) | |
46 | : wxArgNormalizerWithBuffer<wchar_t>(s.wc_str()) | |
c9f78968 | 47 | { |
c9f78968 VS |
48 | } |
49 | ||
2523e9b7 VS |
50 | wxArgNormalizerWchar<const wxCStrData&>::wxArgNormalizerWchar(const wxCStrData& s) |
51 | : wxArgNormalizerWithBuffer<wchar_t>(s.AsWCharBuf()) | |
c9f78968 | 52 | { |
81727065 VS |
53 | } |
54 | #endif // wxUSE_UNICODE_UTF8 | |
55 | ||
2523e9b7 | 56 | wxString wxArgNormalizedString::GetString() const |
359bd4d1 | 57 | { |
2523e9b7 VS |
58 | if ( !IsValid() ) |
59 | return wxEmptyString; | |
60 | ||
61 | #if wxUSE_UTF8_LOCALE_ONLY | |
62 | return wxString(wx_reinterpret_cast(const char*, m_ptr)); | |
63 | #else | |
64 | #if wxUSE_UNICODE_UTF8 | |
65 | if ( wxLocaleIsUtf8 ) | |
66 | return wxString(wx_reinterpret_cast(const char*, m_ptr)); | |
67 | else | |
68 | #endif | |
69 | return wxString(wx_reinterpret_cast(const wchar_t*, m_ptr)); | |
70 | #endif // !wxUSE_UTF8_LOCALE_ONLY | |
359bd4d1 VS |
71 | } |
72 | ||
2523e9b7 | 73 | wxArgNormalizedString::operator wxString() const |
359bd4d1 | 74 | { |
2523e9b7 | 75 | return GetString(); |
359bd4d1 | 76 | } |