]> git.saurik.com Git - wxWidgets.git/blame - src/common/strvararg.cpp
implement GetBestSize() (patch 1386199)
[wxWidgets.git] / src / common / strvararg.cpp
CommitLineData
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"
27#include "wx/buffer.h"
28#include "wx/strconv.h"
29#include "wx/string.h"
30
31// ============================================================================
32// implementation
33// ============================================================================
34
8f93a29f 35const wxStringCharType *wxArgNormalizer<const wxCStrData&>::get() const
c9f78968
VS
36{
37 return m_value;
38}
39
8f93a29f 40const wxStringCharType *wxArgNormalizer<const wxString&>::get() const
c9f78968 41{
8f93a29f 42 return m_value.wx_str();
c9f78968
VS
43}
44
45#if wxUSE_UNICODE_WCHAR
46
47wxArgNormalizer<const char*>::wxArgNormalizer(const char *value)
48{
49 m_value = new wxWCharBuffer(wxConvLibc.cMB2WC(value));
50}
51
52wxArgNormalizer<const char*>::~wxArgNormalizer()
53{
54 delete m_value;
55}
56
57const wchar_t *wxArgNormalizer<const char*>::get() const
58{
59 return m_value->data();
60}
61
62#elif wxUSE_WCHAR_T // !wxUSE_UNICODE_WCHAR && wxUSE_WCHAR_T
63
64wxArgNormalizer<const wchar_t*>::wxArgNormalizer(const wchar_t *value)
65{
66 m_value = new wxCharBuffer(wxConvLibc.cWC2MB(value));
67}
68
69wxArgNormalizer<const wchar_t*>::~wxArgNormalizer()
70{
71 delete m_value;
72}
73
74const char *wxArgNormalizer<const wchar_t*>::get() const
75{
76 return m_value->data();
77}
78
79#endif // wxUSE_UNICODE_WCHAR / !wxUSE_UNICODE_WCHAR && wxUSE_WCHAR_T
359bd4d1
VS
80
81// FIXME-UTF8: move this to the header once it's possible to include buffer.h
82// without including wxcrt.h
83
84wxArgNormalizer<wxCharBuffer>::wxArgNormalizer(const wxCharBuffer& buf)
85 : wxArgNormalizer<const char*>(buf.data())
86{
87}
88
89wxArgNormalizer<wxWCharBuffer>::wxArgNormalizer(const wxWCharBuffer& buf)
90 : wxArgNormalizer<const wchar_t*>(buf.data())
91{
92}