m_str[len] = (CharType)0;
}
- static wxCharTypeBuffer CreateNonOwned(const CharType *str)
+ static const wxCharTypeBuffer CreateNonOwned(const CharType *str)
{
wxCharTypeBuffer buf;
- buf.m_str = str;
+ buf.m_str = wx_const_cast(CharType*, str);
buf.m_owned = false;
return buf;
}
public:
typedef wxCharTypeBuffer<char> wxCharTypeBufferBase;
+ wxCharBuffer(const wxCharTypeBufferBase& buf)
+ : wxCharTypeBufferBase(buf) {}
+
wxCharBuffer(const CharType *str = NULL) : wxCharTypeBufferBase(str) {}
wxCharBuffer(size_t len) : wxCharTypeBufferBase(len) {}
public:
typedef wxCharTypeBuffer<wchar_t> wxCharTypeBufferBase;
+ wxWCharBuffer(const wxCharTypeBufferBase& buf)
+ : wxCharTypeBufferBase(buf) {}
+
wxWCharBuffer(const CharType *str = NULL) : wxCharTypeBufferBase(str) {}
wxWCharBuffer(size_t len) : wxCharTypeBufferBase(len) {}
operator const void*() const { return AsChar(); }
+ inline const wxCharBuffer AsCharBuf() const;
+ inline const wxWCharBuffer AsWCharBuf() const;
+
inline wxString AsString() const;
// allow expressions like "c_str()[0]":
}
#endif // !wxUSE_UNICODE
+inline const wxCharBuffer wxCStrData::AsCharBuf() const
+{
+#if !wxUSE_UNICODE
+ return wxCharBuffer::CreateNonOwned(AsChar());
+#else
+ return AsString().mb_str();
+#endif
+}
+
+inline const wxWCharBuffer wxCStrData::AsWCharBuf() const
+{
+#if wxUSE_UNICODE_WCHAR
+ return wxWCharBuffer::CreateNonOwned(AsWChar());
+#else
+ return AsString().wc_str();
+#endif
+}
+
inline wxString wxCStrData::AsString() const
{
if ( m_offset == 0 )
// FIXME-UTF8: move this to buffer.h
inline wxCharBuffer::wxCharBuffer(const wxCStrData& cstr)
- : wxCharTypeBufferBase(cstr.AsChar())
+ : wxCharTypeBufferBase(cstr.AsCharBuf())
{
}
inline wxWCharBuffer::wxWCharBuffer(const wxCStrData& cstr)
- : wxCharTypeBufferBase(cstr.AsWChar())
+ : wxCharTypeBufferBase(cstr.AsWCharBuf())
{
}
{
// FIXME-UTF8: always, not only if wxUSE_UNICODE
#if wxUSE_UNICODE && !defined(__BORLANDC__)
- return os << str.AsWChar();
+ return os << (const wchar_t*)str.AsWCharBuf();
#else
- return os << str.AsChar();
+ return os << (const char*)str.AsCharBuf();
#endif
}