fix DLL build with MSVC: it wasn't happy that some functions of a template class were not implemented, so get rid of FromCStrData() and implement its logic in one of the 2 derived classes ctors instead

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45026 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2007-03-23 00:04:15 +00:00
parent d18c8d3d94
commit ccd4deab6b
2 changed files with 21 additions and 20 deletions

View File

@ -27,7 +27,7 @@ inline char *wxStrDup(const char *s) { return wxStrdupA(s); }
// ----------------------------------------------------------------------------
template <typename T>
class WXDLLIMPEXP_BASE wxCharTypeBuffer
class wxCharTypeBuffer
{
public:
typedef T CharType;
@ -37,11 +37,6 @@ public:
{
}
wxCharTypeBuffer(const wxCStrData& cstr)
{
FromCStrData(cstr);
}
wxCharTypeBuffer(size_t len)
: m_str((CharType *)malloc((len + 1)*sizeof(CharType)))
{
@ -119,9 +114,6 @@ public:
operator const CharType *() const { return m_str; }
CharType operator[](size_t n) const { return m_str[n]; }
private:
void FromCStrData(const wxCStrData& cstr);
private:
CharType *m_str;
};
@ -129,30 +121,40 @@ private:
class WXDLLIMPEXP_BASE wxCharBuffer : public wxCharTypeBuffer<char>
{
public:
wxCharBuffer(const CharType *str = NULL) : wxCharTypeBuffer<char>(str) {}
wxCharBuffer(const wxCStrData& cstr) : wxCharTypeBuffer<char>(cstr) {}
wxCharBuffer(size_t len) : wxCharTypeBuffer<char>(len) {}
typedef wxCharTypeBuffer<char> wxCharTypeBufferBase;
wxCharBuffer(const CharType *str = NULL) : wxCharTypeBufferBase(str) {}
wxCharBuffer(size_t len) : wxCharTypeBufferBase(len) {}
#if !wxUSE_UNICODE
wxCharBuffer(const wxCStrData& cstr);
#endif
};
#if wxUSE_WCHAR_T
class WXDLLIMPEXP_BASE wxWCharBuffer : public wxCharTypeBuffer<wchar_t>
{
public:
wxWCharBuffer(const CharType *str = NULL) : wxCharTypeBuffer<wchar_t>(str) {}
wxWCharBuffer(const wxCStrData& cstr) : wxCharTypeBuffer<wchar_t>(cstr) {}
wxWCharBuffer(size_t len) : wxCharTypeBuffer<wchar_t>(len) {}
typedef wxCharTypeBuffer<wchar_t> wxCharTypeBufferBase;
wxWCharBuffer(const CharType *str = NULL) : wxCharTypeBufferBase(str) {}
wxWCharBuffer(size_t len) : wxCharTypeBufferBase(len) {}
#if wxUSE_UNICODE
wxWCharBuffer(const wxCStrData& cstr);
#endif
};
#endif // wxUSE_WCHAR_T
#if wxUSE_UNICODE
typedef wxWCharBuffer wxWxCharBuffer;
#define wxWxCharBuffer wxWCharBuffer
#define wxMB2WXbuf wxWCharBuffer
#define wxWX2MBbuf wxCharBuffer
#define wxWC2WXbuf wxChar*
#define wxWX2WCbuf wxChar*
#else // ANSI
typedef wxCharBuffer wxWxCharBuffer;
#define wxWxCharBuffer wxCharBuffer
#define wxMB2WXbuf wxChar*
#define wxWX2MBbuf wxChar*

View File

@ -2045,10 +2045,9 @@ inline wxString& wxString::operator=(const wxCStrData& cstr)
// ----------------------------------------------------------------------------
// FIXME-UTF8: move this to buffer.h; provide versions for both variants
template<>
inline void wxCharTypeBuffer<wxChar>::FromCStrData(const wxCStrData& cstr)
inline wxWxCharBuffer::wxWxCharBuffer(const wxCStrData& cstr)
: wxCharTypeBufferBase((const wxChar *)cstr)
{
m_str = wxStrDup(cstr.AsString());
}
#endif // _WX_WXSTRINGH__