]>
Commit | Line | Data |
---|---|---|
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" | |
27 | #include "wx/string.h" | |
28 | ||
29 | // ============================================================================ | |
30 | // implementation | |
31 | // ============================================================================ | |
32 | ||
33 | ||
34 | const wxStringCharType *wxArgNormalizerNative<const wxString&>::get() const | |
35 | { | |
36 | return m_value.wx_str(); | |
37 | } | |
38 | ||
39 | const wxStringCharType *wxArgNormalizerNative<const wxCStrData&>::get() const | |
40 | { | |
41 | return m_value.AsInternal(); | |
42 | } | |
43 | ||
44 | #if wxUSE_UNICODE_UTF8 | |
45 | wxArgNormalizerWchar<const wxString&>::wxArgNormalizerWchar(const wxString& s) | |
46 | : wxArgNormalizerWithBuffer<wchar_t>(s.wc_str()) | |
47 | { | |
48 | } | |
49 | ||
50 | wxArgNormalizerWchar<const wxCStrData&>::wxArgNormalizerWchar(const wxCStrData& s) | |
51 | : wxArgNormalizerWithBuffer<wchar_t>(s.AsWCharBuf()) | |
52 | { | |
53 | } | |
54 | #endif // wxUSE_UNICODE_UTF8 | |
55 | ||
56 | wxString wxArgNormalizedString::GetString() const | |
57 | { | |
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 | |
71 | } | |
72 | ||
73 | wxArgNormalizedString::operator wxString() const | |
74 | { | |
75 | return GetString(); | |
76 | } |