split wxCharTypeBuffer<T> into wxScopedCharTypeBuffer<T> and wxCharTypeBuffer<T> -- the former is for transient data with validity limited to parent's lifetime, the latter is for permanent storage of string data (bug #9638)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59887 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -64,35 +64,61 @@ extern WXDLLIMPEXP_DATA_BASE(UntypedBufferData * const) untypedNullDataPtr;
|
|||||||
|
|
||||||
} // namespace wxPrivate
|
} // namespace wxPrivate
|
||||||
|
|
||||||
|
|
||||||
|
// Reference-counted character buffer for storing string data. The buffer
|
||||||
|
// is only valid for as long as the "parent" object that provided the data
|
||||||
|
// is valid; see wxCharTypeBuffer<T> for persistent variant.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class wxCharTypeBuffer
|
class wxScopedCharTypeBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef T CharType;
|
typedef T CharType;
|
||||||
|
|
||||||
wxCharTypeBuffer(const CharType *str = NULL)
|
wxScopedCharTypeBuffer()
|
||||||
{
|
{
|
||||||
if ( str )
|
m_data = GetNullData();
|
||||||
m_data = new Data(wxStrdup(str));
|
|
||||||
else
|
|
||||||
m_data = GetNullData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCharTypeBuffer(size_t len)
|
// Creates "non-owned" buffer, i.e. 'str' is not owned by the buffer
|
||||||
|
// and doesn't get freed by dtor. Used e.g. to point to wxString's internal
|
||||||
|
// storage.
|
||||||
|
static const wxScopedCharTypeBuffer CreateNonOwned(const CharType *str)
|
||||||
{
|
{
|
||||||
m_data = new Data((CharType *)malloc((len + 1)*sizeof(CharType)));
|
wxScopedCharTypeBuffer buf;
|
||||||
m_data->Get()[len] = (CharType)0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const wxCharTypeBuffer CreateNonOwned(const CharType *str)
|
|
||||||
{
|
|
||||||
wxCharTypeBuffer buf;
|
|
||||||
if ( str )
|
if ( str )
|
||||||
buf.m_data = new Data(const_cast<CharType*>(str), Data::NonOwned);
|
buf.m_data = new Data(const_cast<CharType*>(str), Data::NonOwned);
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
~wxCharTypeBuffer()
|
// Creates "owned" buffer, i.e. takes over ownership of 'str' and frees it
|
||||||
|
// in dtor (if ref.count reaches 0).
|
||||||
|
static const wxScopedCharTypeBuffer CreateOwned(const CharType *str)
|
||||||
|
{
|
||||||
|
wxScopedCharTypeBuffer buf;
|
||||||
|
if ( str )
|
||||||
|
buf.m_data = new Data(wxStrdup(str));
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxScopedCharTypeBuffer(const wxScopedCharTypeBuffer& src)
|
||||||
|
{
|
||||||
|
m_data = src.m_data;
|
||||||
|
IncRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxScopedCharTypeBuffer& operator=(const wxScopedCharTypeBuffer& src)
|
||||||
|
{
|
||||||
|
if ( &src == this )
|
||||||
|
return *this;
|
||||||
|
|
||||||
|
DecRef();
|
||||||
|
m_data = src.m_data;
|
||||||
|
IncRef();
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
~wxScopedCharTypeBuffer()
|
||||||
{
|
{
|
||||||
DecRef();
|
DecRef();
|
||||||
}
|
}
|
||||||
@@ -110,7 +136,7 @@ public:
|
|||||||
|
|
||||||
CharType * const p = m_data->Get();
|
CharType * const p = m_data->Get();
|
||||||
|
|
||||||
wxCharTypeBuffer *self = const_cast<wxCharTypeBuffer*>(this);
|
wxScopedCharTypeBuffer *self = const_cast<wxScopedCharTypeBuffer*>(this);
|
||||||
self->m_data->Set(NULL);
|
self->m_data->Set(NULL);
|
||||||
self->DecRef();
|
self->DecRef();
|
||||||
|
|
||||||
@@ -122,62 +148,12 @@ public:
|
|||||||
DecRef();
|
DecRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCharTypeBuffer(const wxCharTypeBuffer& src)
|
|
||||||
{
|
|
||||||
m_data = src.m_data;
|
|
||||||
IncRef();
|
|
||||||
}
|
|
||||||
|
|
||||||
wxCharTypeBuffer& operator=(const CharType *str)
|
|
||||||
{
|
|
||||||
DecRef();
|
|
||||||
|
|
||||||
if ( str )
|
|
||||||
m_data = new Data(wxStrdup(str));
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxCharTypeBuffer& operator=(const wxCharTypeBuffer& src)
|
|
||||||
{
|
|
||||||
if ( &src == this )
|
|
||||||
return *this;
|
|
||||||
|
|
||||||
DecRef();
|
|
||||||
m_data = src.m_data;
|
|
||||||
IncRef();
|
|
||||||
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool extend(size_t len)
|
|
||||||
{
|
|
||||||
wxASSERT_MSG( m_data->m_owned, _T("cannot extend non-owned buffer") );
|
|
||||||
wxASSERT_MSG( m_data->m_ref == 1, _T("can't extend shared buffer") );
|
|
||||||
|
|
||||||
CharType *str =
|
|
||||||
(CharType *)realloc(data(), (len + 1) * sizeof(CharType));
|
|
||||||
if ( !str )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if ( m_data == GetNullData() )
|
|
||||||
{
|
|
||||||
m_data = new Data(str);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_data->Set(str);
|
|
||||||
m_data->m_owned = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
CharType *data() { return m_data->Get(); }
|
CharType *data() { return m_data->Get(); }
|
||||||
const CharType *data() const { return m_data->Get(); }
|
const CharType *data() const { return m_data->Get(); }
|
||||||
operator const CharType *() const { return data(); }
|
operator const CharType *() const { return data(); }
|
||||||
CharType operator[](size_t n) const { return data()[n]; }
|
CharType operator[](size_t n) const { return data()[n]; }
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
// reference-counted data
|
// reference-counted data
|
||||||
struct Data : public wxPrivate::UntypedBufferData
|
struct Data : public wxPrivate::UntypedBufferData
|
||||||
{
|
{
|
||||||
@@ -212,19 +188,136 @@ private:
|
|||||||
m_data = GetNullData();
|
m_data = GetNullData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
// sets this object to a be copy of 'other'; if 'src' is non-owned,
|
||||||
|
// a deep copy is made and 'this' will contain new instance of the data
|
||||||
|
void MakeOwnedCopyOf(const wxScopedCharTypeBuffer& src)
|
||||||
|
{
|
||||||
|
this->DecRef();
|
||||||
|
|
||||||
|
if ( src.m_data == this->GetNullData() )
|
||||||
|
{
|
||||||
|
this->m_data = this->GetNullData();
|
||||||
|
}
|
||||||
|
else if ( src.m_data->m_owned )
|
||||||
|
{
|
||||||
|
this->m_data = src.m_data;
|
||||||
|
this->IncRef();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// if the scoped buffer had non-owned data, we have to make
|
||||||
|
// a copy here, because src.m_data->m_str is valid only for as long
|
||||||
|
// as 'src' exists
|
||||||
|
this->m_data = new Data(wxStrdup(src.m_data->Get()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
Data *m_data;
|
Data *m_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef wxScopedCharTypeBuffer<char> wxScopedCharBuffer;
|
||||||
|
typedef wxScopedCharTypeBuffer<wchar_t> wxScopedWCharBuffer;
|
||||||
|
|
||||||
|
|
||||||
|
// this buffer class always stores data in "owned" (persistent) manner
|
||||||
|
template <typename T>
|
||||||
|
class wxCharTypeBuffer : public wxScopedCharTypeBuffer<T>
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
typedef typename wxScopedCharTypeBuffer<T>::Data Data;
|
||||||
|
|
||||||
|
public:
|
||||||
|
typedef T CharType;
|
||||||
|
|
||||||
|
wxCharTypeBuffer(const CharType *str = NULL)
|
||||||
|
{
|
||||||
|
if ( str )
|
||||||
|
this->m_data = new Data(wxStrdup(str));
|
||||||
|
else
|
||||||
|
this->m_data = this->GetNullData();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxCharTypeBuffer(size_t len)
|
||||||
|
{
|
||||||
|
this->m_data = new Data((CharType *)malloc((len + 1)*sizeof(CharType)));
|
||||||
|
this->m_data->Get()[len] = (CharType)0;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxCharTypeBuffer(const wxCharTypeBuffer& src)
|
||||||
|
{
|
||||||
|
this->m_data = src.m_data;
|
||||||
|
this->IncRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxCharTypeBuffer& operator=(const CharType *str)
|
||||||
|
{
|
||||||
|
this->DecRef();
|
||||||
|
|
||||||
|
if ( str )
|
||||||
|
this->m_data = new Data(wxStrdup(str));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxCharTypeBuffer& operator=(const wxCharTypeBuffer& src)
|
||||||
|
{
|
||||||
|
if ( &src == this )
|
||||||
|
return *this;
|
||||||
|
|
||||||
|
this->DecRef();
|
||||||
|
this->m_data = src.m_data;
|
||||||
|
this->IncRef();
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxCharTypeBuffer(const wxScopedCharTypeBuffer<T>& src)
|
||||||
|
{
|
||||||
|
MakeOwnedCopyOf(src);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxCharTypeBuffer& operator=(const wxScopedCharTypeBuffer<T>& src)
|
||||||
|
{
|
||||||
|
MakeOwnedCopyOf(src);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool extend(size_t len)
|
||||||
|
{
|
||||||
|
wxASSERT_MSG( this->m_data->m_owned, "cannot extend non-owned buffer" );
|
||||||
|
wxASSERT_MSG( this->m_data->m_ref == 1, "can't extend shared buffer" );
|
||||||
|
|
||||||
|
CharType *str =
|
||||||
|
(CharType *)realloc(this->data(), (len + 1) * sizeof(CharType));
|
||||||
|
if ( !str )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ( this->m_data == this->GetNullData() )
|
||||||
|
{
|
||||||
|
this->m_data = new Data(str);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->m_data->Set(str);
|
||||||
|
this->m_data->m_owned = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxCharTypeBuffer<char> )
|
WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxCharTypeBuffer<char> )
|
||||||
|
|
||||||
class wxCharBuffer : public wxCharTypeBuffer<char>
|
class wxCharBuffer : public wxCharTypeBuffer<char>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef wxCharTypeBuffer<char> wxCharTypeBufferBase;
|
typedef wxCharTypeBuffer<char> wxCharTypeBufferBase;
|
||||||
|
typedef wxScopedCharTypeBuffer<char> wxScopedCharTypeBufferBase;
|
||||||
|
|
||||||
wxCharBuffer(const wxCharTypeBufferBase& buf)
|
wxCharBuffer(const wxCharTypeBufferBase& buf)
|
||||||
: wxCharTypeBufferBase(buf) {}
|
: wxCharTypeBufferBase(buf) {}
|
||||||
|
wxCharBuffer(const wxScopedCharTypeBufferBase& buf)
|
||||||
|
: wxCharTypeBufferBase(buf) {}
|
||||||
|
|
||||||
wxCharBuffer(const CharType *str = NULL) : wxCharTypeBufferBase(str) {}
|
wxCharBuffer(const CharType *str = NULL) : wxCharTypeBufferBase(str) {}
|
||||||
wxCharBuffer(size_t len) : wxCharTypeBufferBase(len) {}
|
wxCharBuffer(size_t len) : wxCharTypeBufferBase(len) {}
|
||||||
@@ -239,9 +332,12 @@ class wxWCharBuffer : public wxCharTypeBuffer<wchar_t>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef wxCharTypeBuffer<wchar_t> wxCharTypeBufferBase;
|
typedef wxCharTypeBuffer<wchar_t> wxCharTypeBufferBase;
|
||||||
|
typedef wxScopedCharTypeBuffer<wchar_t> wxScopedCharTypeBufferBase;
|
||||||
|
|
||||||
wxWCharBuffer(const wxCharTypeBufferBase& buf)
|
wxWCharBuffer(const wxCharTypeBufferBase& buf)
|
||||||
: wxCharTypeBufferBase(buf) {}
|
: wxCharTypeBufferBase(buf) {}
|
||||||
|
wxWCharBuffer(const wxScopedCharTypeBufferBase& buf)
|
||||||
|
: wxCharTypeBufferBase(buf) {}
|
||||||
|
|
||||||
wxWCharBuffer(const CharType *str = NULL) : wxCharTypeBufferBase(str) {}
|
wxWCharBuffer(const CharType *str = NULL) : wxCharTypeBufferBase(str) {}
|
||||||
wxWCharBuffer(size_t len) : wxCharTypeBufferBase(len) {}
|
wxWCharBuffer(size_t len) : wxCharTypeBufferBase(len) {}
|
||||||
@@ -255,12 +351,14 @@ template <typename T>
|
|||||||
class wxWritableCharTypeBuffer : public wxCharTypeBuffer<T>
|
class wxWritableCharTypeBuffer : public wxCharTypeBuffer<T>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef typename wxCharTypeBuffer<T>::CharType CharType;
|
typedef typename wxScopedCharTypeBuffer<T>::CharType CharType;
|
||||||
|
|
||||||
wxWritableCharTypeBuffer(const wxCharTypeBuffer<T>& src)
|
wxWritableCharTypeBuffer(const wxScopedCharTypeBuffer<T>& src)
|
||||||
: wxCharTypeBuffer<T>(src) {}
|
: wxCharTypeBuffer<T>(src) {}
|
||||||
// FIXME-UTF8: this won't be needed after converting mb_str()/wc_str() to
|
// FIXME-UTF8: this won't be needed after converting mb_str()/wc_str() to
|
||||||
// always return a buffer
|
// always return a buffer
|
||||||
|
// + we should derive this class from wxScopedCharTypeBuffer
|
||||||
|
// then
|
||||||
wxWritableCharTypeBuffer(const CharType *str = NULL)
|
wxWritableCharTypeBuffer(const CharType *str = NULL)
|
||||||
: wxCharTypeBuffer<T>(str) {}
|
: wxCharTypeBuffer<T>(str) {}
|
||||||
|
|
||||||
|
@@ -143,8 +143,8 @@ public:
|
|||||||
CtorString(const wchar_t *str) : m_str(str) {}
|
CtorString(const wchar_t *str) : m_str(str) {}
|
||||||
CtorString(const wxString& str) : m_str(str) {}
|
CtorString(const wxString& str) : m_str(str) {}
|
||||||
CtorString(const wxCStrData& str) : m_str(str) {}
|
CtorString(const wxCStrData& str) : m_str(str) {}
|
||||||
CtorString(const wxCharBuffer& str) : m_str(str) {}
|
CtorString(const wxScopedCharBuffer& str) : m_str(str) {}
|
||||||
CtorString(const wxWCharBuffer& str) : m_str(str) {}
|
CtorString(const wxScopedWCharBuffer& str) : m_str(str) {}
|
||||||
|
|
||||||
operator const wxString*() const { return &m_str; }
|
operator const wxString*() const { return &m_str; }
|
||||||
|
|
||||||
|
@@ -130,7 +130,7 @@ extern XColor itemColors[5] ;
|
|||||||
|
|
||||||
wxString wxXmStringToString( const XmString& xmString );
|
wxString wxXmStringToString( const XmString& xmString );
|
||||||
XmString wxStringToXmString( const char* string );
|
XmString wxStringToXmString( const char* string );
|
||||||
inline XmString wxStringToXmString( const wxCharBuffer& string )
|
inline XmString wxStringToXmString( const wxScopedCharBuffer& string )
|
||||||
{ return wxStringToXmString(string.data()); }
|
{ return wxStringToXmString(string.data()); }
|
||||||
inline XmString wxStringToXmString( const wxString& string )
|
inline XmString wxStringToXmString( const wxString& string )
|
||||||
{ return wxStringToXmString((const char*)string.mb_str()); }
|
{ return wxStringToXmString((const char*)string.mb_str()); }
|
||||||
|
@@ -245,8 +245,9 @@ public:
|
|||||||
|
|
||||||
operator const void*() const { return AsChar(); }
|
operator const void*() const { return AsChar(); }
|
||||||
|
|
||||||
inline const wxCharBuffer AsCharBuf() const;
|
// returns buffers that are valid as long as the associated wxString exists
|
||||||
inline const wxWCharBuffer AsWCharBuf() const;
|
inline const wxScopedCharBuffer AsCharBuf() const;
|
||||||
|
inline const wxScopedWCharBuffer AsWCharBuf() const;
|
||||||
|
|
||||||
inline wxString AsString() const;
|
inline wxString AsString() const;
|
||||||
|
|
||||||
@@ -486,14 +487,14 @@ private:
|
|||||||
|
|
||||||
#if wxUSE_UNICODE_UTF8
|
#if wxUSE_UNICODE_UTF8
|
||||||
// even char* -> char* needs conversion, from locale charset to UTF-8
|
// even char* -> char* needs conversion, from locale charset to UTF-8
|
||||||
typedef SubstrBufFromType<wxCharBuffer> SubstrBufFromWC;
|
typedef SubstrBufFromType<wxScopedCharBuffer> SubstrBufFromWC;
|
||||||
typedef SubstrBufFromType<wxCharBuffer> SubstrBufFromMB;
|
typedef SubstrBufFromType<wxScopedCharBuffer> SubstrBufFromMB;
|
||||||
#elif wxUSE_UNICODE_WCHAR
|
#elif wxUSE_UNICODE_WCHAR
|
||||||
typedef SubstrBufFromType<const wchar_t*> SubstrBufFromWC;
|
typedef SubstrBufFromType<const wchar_t*> SubstrBufFromWC;
|
||||||
typedef SubstrBufFromType<wxWCharBuffer> SubstrBufFromMB;
|
typedef SubstrBufFromType<wxScopedWCharBuffer> SubstrBufFromMB;
|
||||||
#else
|
#else
|
||||||
typedef SubstrBufFromType<const char*> SubstrBufFromMB;
|
typedef SubstrBufFromType<const char*> SubstrBufFromMB;
|
||||||
typedef SubstrBufFromType<wxCharBuffer> SubstrBufFromWC;
|
typedef SubstrBufFromType<wxScopedCharBuffer> SubstrBufFromWC;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -522,8 +523,8 @@ private:
|
|||||||
{ return str ? str : wxT(""); }
|
{ return str ? str : wxT(""); }
|
||||||
static const SubstrBufFromWC ImplStr(const wchar_t* str, size_t n)
|
static const SubstrBufFromWC ImplStr(const wchar_t* str, size_t n)
|
||||||
{ return SubstrBufFromWC(str, (str && n == npos) ? wxWcslen(str) : n); }
|
{ return SubstrBufFromWC(str, (str && n == npos) ? wxWcslen(str) : n); }
|
||||||
static wxWCharBuffer ImplStr(const char* str,
|
static wxScopedWCharBuffer ImplStr(const char* str,
|
||||||
const wxMBConv& conv = wxConvLibc)
|
const wxMBConv& conv = wxConvLibc)
|
||||||
{ return ConvertStr(str, npos, conv).data; }
|
{ return ConvertStr(str, npos, conv).data; }
|
||||||
static SubstrBufFromMB ImplStr(const char* str, size_t n,
|
static SubstrBufFromMB ImplStr(const char* str, size_t n,
|
||||||
const wxMBConv& conv = wxConvLibc)
|
const wxMBConv& conv = wxConvLibc)
|
||||||
@@ -535,7 +536,7 @@ private:
|
|||||||
static const SubstrBufFromMB ImplStr(const char* str, size_t n,
|
static const SubstrBufFromMB ImplStr(const char* str, size_t n,
|
||||||
const wxMBConv& WXUNUSED(conv) = wxConvLibc)
|
const wxMBConv& WXUNUSED(conv) = wxConvLibc)
|
||||||
{ return SubstrBufFromMB(str, (str && n == npos) ? wxStrlen(str) : n); }
|
{ return SubstrBufFromMB(str, (str && n == npos) ? wxStrlen(str) : n); }
|
||||||
static wxCharBuffer ImplStr(const wchar_t* str)
|
static wxScopedCharBuffer ImplStr(const wchar_t* str)
|
||||||
{ return ConvertStr(str, npos, wxConvLibc).data; }
|
{ return ConvertStr(str, npos, wxConvLibc).data; }
|
||||||
static SubstrBufFromWC ImplStr(const wchar_t* str, size_t n)
|
static SubstrBufFromWC ImplStr(const wchar_t* str, size_t n)
|
||||||
{ return ConvertStr(str, n, wxConvLibc); }
|
{ return ConvertStr(str, n, wxConvLibc); }
|
||||||
@@ -560,14 +561,14 @@ private:
|
|||||||
|
|
||||||
#else // wxUSE_UNICODE_UTF8
|
#else // wxUSE_UNICODE_UTF8
|
||||||
|
|
||||||
static wxCharBuffer ImplStr(const char* str,
|
static wxScopedCharBuffer ImplStr(const char* str,
|
||||||
const wxMBConv& conv = wxConvLibc)
|
const wxMBConv& conv = wxConvLibc)
|
||||||
{ return ConvertStr(str, npos, conv).data; }
|
{ return ConvertStr(str, npos, conv).data; }
|
||||||
static SubstrBufFromMB ImplStr(const char* str, size_t n,
|
static SubstrBufFromMB ImplStr(const char* str, size_t n,
|
||||||
const wxMBConv& conv = wxConvLibc)
|
const wxMBConv& conv = wxConvLibc)
|
||||||
{ return ConvertStr(str, n, conv); }
|
{ return ConvertStr(str, n, conv); }
|
||||||
|
|
||||||
static wxCharBuffer ImplStr(const wchar_t* str)
|
static wxScopedCharBuffer ImplStr(const wchar_t* str)
|
||||||
{ return ConvertStr(str, npos, wxMBConvUTF8()).data; }
|
{ return ConvertStr(str, npos, wxMBConvUTF8()).data; }
|
||||||
static SubstrBufFromWC ImplStr(const wchar_t* str, size_t n)
|
static SubstrBufFromWC ImplStr(const wchar_t* str, size_t n)
|
||||||
{ return ConvertStr(str, n, wxMBConvUTF8()); }
|
{ return ConvertStr(str, n, wxMBConvUTF8()); }
|
||||||
@@ -1275,9 +1276,9 @@ public:
|
|||||||
wxString(const wchar_t *pwz, const wxMBConv& WXUNUSED(conv), size_t nLength)
|
wxString(const wchar_t *pwz, const wxMBConv& WXUNUSED(conv), size_t nLength)
|
||||||
{ assign(pwz, nLength); }
|
{ assign(pwz, nLength); }
|
||||||
|
|
||||||
wxString(const wxCharBuffer& buf)
|
wxString(const wxScopedCharBuffer& buf)
|
||||||
{ assign(buf.data()); } // FIXME-UTF8: fix for embedded NUL and buffer length
|
{ assign(buf.data()); } // FIXME-UTF8: fix for embedded NUL and buffer length
|
||||||
wxString(const wxWCharBuffer& buf)
|
wxString(const wxScopedWCharBuffer& buf)
|
||||||
{ assign(buf.data()); } // FIXME-UTF8: fix for embedded NUL and buffer length
|
{ assign(buf.data()); } // FIXME-UTF8: fix for embedded NUL and buffer length
|
||||||
|
|
||||||
// NB: this version uses m_impl.c_str() to force making a copy of the
|
// NB: this version uses m_impl.c_str() to force making a copy of the
|
||||||
@@ -1650,7 +1651,7 @@ public:
|
|||||||
static wxString FromAscii(const char *ascii, size_t len);
|
static wxString FromAscii(const char *ascii, size_t len);
|
||||||
static wxString FromAscii(const char *ascii);
|
static wxString FromAscii(const char *ascii);
|
||||||
static wxString FromAscii(char ascii);
|
static wxString FromAscii(char ascii);
|
||||||
const wxCharBuffer ToAscii() const;
|
const wxScopedCharBuffer ToAscii() const;
|
||||||
#else // ANSI
|
#else // ANSI
|
||||||
static wxString FromAscii(const char *ascii) { return wxString( ascii ); }
|
static wxString FromAscii(const char *ascii) { return wxString( ascii ); }
|
||||||
static wxString FromAscii(const char *ascii, size_t len)
|
static wxString FromAscii(const char *ascii, size_t len)
|
||||||
@@ -1721,31 +1722,37 @@ public:
|
|||||||
"string must be valid UTF-8" );
|
"string must be valid UTF-8" );
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
const wxCharBuffer utf8_str() const { return mb_str(wxMBConvUTF8()); }
|
const wxScopedCharBuffer utf8_str() const { return mb_str(wxMBConvUTF8()); }
|
||||||
const wxCharBuffer ToUTF8() const { return utf8_str(); }
|
const wxScopedCharBuffer ToUTF8() const { return utf8_str(); }
|
||||||
#else // ANSI
|
#else // ANSI
|
||||||
static wxString FromUTF8(const char *utf8)
|
static wxString FromUTF8(const char *utf8)
|
||||||
{ return wxString(wxMBConvUTF8().cMB2WC(utf8)); }
|
{ return wxString(wxMBConvUTF8().cMB2WC(utf8)); }
|
||||||
static wxString FromUTF8(const char *utf8, size_t len)
|
static wxString FromUTF8(const char *utf8, size_t len)
|
||||||
{
|
{
|
||||||
size_t wlen;
|
size_t wlen;
|
||||||
wxWCharBuffer buf(wxMBConvUTF8().cMB2WC(utf8, len == npos ? wxNO_LEN : len, &wlen));
|
wxScopedWCharBuffer buf(wxMBConvUTF8().cMB2WC(utf8, len == npos ? wxNO_LEN : len, &wlen));
|
||||||
return wxString(buf.data(), wlen);
|
return wxString(buf.data(), wlen);
|
||||||
}
|
}
|
||||||
static wxString FromUTF8Unchecked(const char *utf8, size_t len = npos)
|
static wxString FromUTF8Unchecked(const char *utf8, size_t len = npos)
|
||||||
{
|
{
|
||||||
size_t wlen;
|
size_t wlen;
|
||||||
wxWCharBuffer buf(wxMBConvUTF8().cMB2WC(utf8,
|
wxScopedWCharBuffer buf
|
||||||
len == npos ? wxNO_LEN : len,
|
(
|
||||||
&wlen));
|
wxMBConvUTF8().cMB2WC
|
||||||
|
(
|
||||||
|
utf8,
|
||||||
|
len == npos ? wxNO_LEN : len,
|
||||||
|
&wlen
|
||||||
|
)
|
||||||
|
);
|
||||||
wxASSERT_MSG( !utf8 || !*utf8 || wlen,
|
wxASSERT_MSG( !utf8 || !*utf8 || wlen,
|
||||||
"string must be valid UTF-8" );
|
"string must be valid UTF-8" );
|
||||||
|
|
||||||
return wxString(buf.data(), wlen);
|
return wxString(buf.data(), wlen);
|
||||||
}
|
}
|
||||||
const wxCharBuffer utf8_str() const
|
const wxScopedCharBuffer utf8_str() const
|
||||||
{ return wxMBConvUTF8().cWC2MB(wc_str()); }
|
{ return wxMBConvUTF8().cWC2MB(wc_str()); }
|
||||||
const wxCharBuffer ToUTF8() const { return utf8_str(); }
|
const wxScopedCharBuffer ToUTF8() const { return utf8_str(); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// functions for storing binary data in wxString:
|
// functions for storing binary data in wxString:
|
||||||
@@ -1755,7 +1762,8 @@ public:
|
|||||||
// version for NUL-terminated data:
|
// version for NUL-terminated data:
|
||||||
static wxString From8BitData(const char *data)
|
static wxString From8BitData(const char *data)
|
||||||
{ return wxString(data, wxConvISO8859_1); }
|
{ return wxString(data, wxConvISO8859_1); }
|
||||||
const wxCharBuffer To8BitData() const { return mb_str(wxConvISO8859_1); }
|
const wxScopedCharBuffer To8BitData() const
|
||||||
|
{ return mb_str(wxConvISO8859_1); }
|
||||||
#else // ANSI
|
#else // ANSI
|
||||||
static wxString From8BitData(const char *data, size_t len)
|
static wxString From8BitData(const char *data, size_t len)
|
||||||
{ return wxString(data, len); }
|
{ return wxString(data, len); }
|
||||||
@@ -1778,9 +1786,9 @@ public:
|
|||||||
|
|
||||||
#if wxUSE_UTF8_LOCALE_ONLY
|
#if wxUSE_UTF8_LOCALE_ONLY
|
||||||
const char* mb_str() const { return wx_str(); }
|
const char* mb_str() const { return wx_str(); }
|
||||||
const wxCharBuffer mb_str(const wxMBConv& conv) const;
|
const wxScopedCharBuffer mb_str(const wxMBConv& conv) const;
|
||||||
#else
|
#else
|
||||||
const wxCharBuffer mb_str(const wxMBConv& conv = wxConvLibc) const;
|
const wxScopedCharBuffer mb_str(const wxMBConv& conv = wxConvLibc) const;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const wxWX2MBbuf mbc_str() const { return mb_str(*wxConvCurrent); }
|
const wxWX2MBbuf mbc_str() const { return mb_str(*wxConvCurrent); }
|
||||||
@@ -1788,14 +1796,14 @@ public:
|
|||||||
#if wxUSE_UNICODE_WCHAR
|
#if wxUSE_UNICODE_WCHAR
|
||||||
const wchar_t* wc_str() const { return wx_str(); }
|
const wchar_t* wc_str() const { return wx_str(); }
|
||||||
#elif wxUSE_UNICODE_UTF8
|
#elif wxUSE_UNICODE_UTF8
|
||||||
const wxWCharBuffer wc_str() const;
|
const wxScopedWCharBuffer wc_str() const;
|
||||||
#endif
|
#endif
|
||||||
// for compatibility with !wxUSE_UNICODE version
|
// for compatibility with !wxUSE_UNICODE version
|
||||||
const wxWX2WCbuf wc_str(const wxMBConv& WXUNUSED(conv)) const
|
const wxWX2WCbuf wc_str(const wxMBConv& WXUNUSED(conv)) const
|
||||||
{ return wc_str(); }
|
{ return wc_str(); }
|
||||||
|
|
||||||
#if wxMBFILES
|
#if wxMBFILES
|
||||||
const wxCharBuffer fn_str() const { return mb_str(wxConvFile); }
|
const wxScopedCharBuffer fn_str() const { return mb_str(wxConvFile); }
|
||||||
#else // !wxMBFILES
|
#else // !wxMBFILES
|
||||||
const wxWX2WCbuf fn_str() const { return wc_str(); }
|
const wxWX2WCbuf fn_str() const { return wc_str(); }
|
||||||
#endif // wxMBFILES/!wxMBFILES
|
#endif // wxMBFILES/!wxMBFILES
|
||||||
@@ -1809,13 +1817,14 @@ public:
|
|||||||
const wxWX2MBbuf mbc_str() const { return mb_str(); }
|
const wxWX2MBbuf mbc_str() const { return mb_str(); }
|
||||||
|
|
||||||
#if wxUSE_WCHAR_T
|
#if wxUSE_WCHAR_T
|
||||||
const wxWCharBuffer wc_str(const wxMBConv& conv = wxConvLibc) const;
|
const wxScopedWCharBuffer wc_str(const wxMBConv& conv = wxConvLibc) const;
|
||||||
#endif // wxUSE_WCHAR_T
|
#endif // wxUSE_WCHAR_T
|
||||||
const wxCharBuffer fn_str() const { return wxConvFile.cWC2WX( wc_str( wxConvLibc ) ); }
|
const wxScopedCharBuffer fn_str() const
|
||||||
|
{ return wxConvFile.cWC2WX( wc_str( wxConvLibc ) ); }
|
||||||
#endif // Unicode/ANSI
|
#endif // Unicode/ANSI
|
||||||
|
|
||||||
#if wxUSE_UNICODE_UTF8
|
#if wxUSE_UNICODE_UTF8
|
||||||
const wxWCharBuffer t_str() const { return wc_str(); }
|
const wxScopedWCharBuffer t_str() const { return wc_str(); }
|
||||||
#elif wxUSE_UNICODE_WCHAR
|
#elif wxUSE_UNICODE_WCHAR
|
||||||
const wchar_t* t_str() const { return wx_str(); }
|
const wchar_t* t_str() const { return wx_str(); }
|
||||||
#else
|
#else
|
||||||
@@ -1910,11 +1919,11 @@ public:
|
|||||||
wxString& operator=(const unsigned char *psz)
|
wxString& operator=(const unsigned char *psz)
|
||||||
{ return operator=((const char*)psz); }
|
{ return operator=((const char*)psz); }
|
||||||
|
|
||||||
// from wxWCharBuffer
|
// from wxScopedWCharBuffer
|
||||||
wxString& operator=(const wxWCharBuffer& s)
|
wxString& operator=(const wxScopedWCharBuffer& s)
|
||||||
{ return operator=(s.data()); } // FIXME-UTF8: fix for embedded NULs
|
{ return operator=(s.data()); } // FIXME-UTF8: fix for embedded NULs
|
||||||
// from wxCharBuffer
|
// from wxScopedCharBuffer
|
||||||
wxString& operator=(const wxCharBuffer& s)
|
wxString& operator=(const wxScopedCharBuffer& s)
|
||||||
{ return operator=(s.data()); } // FIXME-UTF8: fix for embedded NULs
|
{ return operator=(s.data()); } // FIXME-UTF8: fix for embedded NULs
|
||||||
|
|
||||||
// string concatenation
|
// string concatenation
|
||||||
@@ -1950,9 +1959,9 @@ public:
|
|||||||
wxString& operator<<(wchar_t ch) { append(1, ch); return *this; }
|
wxString& operator<<(wchar_t ch) { append(1, ch); return *this; }
|
||||||
|
|
||||||
// string += buffer (i.e. from wxGetString)
|
// string += buffer (i.e. from wxGetString)
|
||||||
wxString& operator<<(const wxWCharBuffer& s)
|
wxString& operator<<(const wxScopedWCharBuffer& s)
|
||||||
{ return operator<<((const wchar_t *)s); }
|
{ return operator<<((const wchar_t *)s); }
|
||||||
wxString& operator<<(const wxCharBuffer& s)
|
wxString& operator<<(const wxScopedCharBuffer& s)
|
||||||
{ return operator<<((const char *)s); }
|
{ return operator<<((const char *)s); }
|
||||||
|
|
||||||
// string += C string
|
// string += C string
|
||||||
@@ -1971,9 +1980,9 @@ public:
|
|||||||
{ append(pwz); return *this; }
|
{ append(pwz); return *this; }
|
||||||
wxString& Append(const wxCStrData& psz)
|
wxString& Append(const wxCStrData& psz)
|
||||||
{ append(psz); return *this; }
|
{ append(psz); return *this; }
|
||||||
wxString& Append(const wxCharBuffer& psz)
|
wxString& Append(const wxScopedCharBuffer& psz)
|
||||||
{ append(psz); return *this; }
|
{ append(psz); return *this; }
|
||||||
wxString& Append(const wxWCharBuffer& psz)
|
wxString& Append(const wxScopedWCharBuffer& psz)
|
||||||
{ append(psz); return *this; }
|
{ append(psz); return *this; }
|
||||||
wxString& Append(const char* psz, size_t nLen)
|
wxString& Append(const char* psz, size_t nLen)
|
||||||
{ append(psz, nLen); return *this; }
|
{ append(psz, nLen); return *this; }
|
||||||
@@ -1981,9 +1990,9 @@ public:
|
|||||||
{ append(pwz, nLen); return *this; }
|
{ append(pwz, nLen); return *this; }
|
||||||
wxString& Append(const wxCStrData& psz, size_t nLen)
|
wxString& Append(const wxCStrData& psz, size_t nLen)
|
||||||
{ append(psz, nLen); return *this; }
|
{ append(psz, nLen); return *this; }
|
||||||
wxString& Append(const wxCharBuffer& psz, size_t nLen)
|
wxString& Append(const wxScopedCharBuffer& psz, size_t nLen)
|
||||||
{ append(psz, nLen); return *this; }
|
{ append(psz, nLen); return *this; }
|
||||||
wxString& Append(const wxWCharBuffer& psz, size_t nLen)
|
wxString& Append(const wxScopedWCharBuffer& psz, size_t nLen)
|
||||||
{ append(psz, nLen); return *this; }
|
{ append(psz, nLen); return *this; }
|
||||||
// append count copies of given character
|
// append count copies of given character
|
||||||
wxString& Append(wxUniChar ch, size_t count = 1u)
|
wxString& Append(wxUniChar ch, size_t count = 1u)
|
||||||
@@ -2064,9 +2073,9 @@ public:
|
|||||||
{ return compare(s); }
|
{ return compare(s); }
|
||||||
int Cmp(const wxCStrData& s) const
|
int Cmp(const wxCStrData& s) const
|
||||||
{ return compare(s); }
|
{ return compare(s); }
|
||||||
int Cmp(const wxCharBuffer& s) const
|
int Cmp(const wxScopedCharBuffer& s) const
|
||||||
{ return compare(s); }
|
{ return compare(s); }
|
||||||
int Cmp(const wxWCharBuffer& s) const
|
int Cmp(const wxScopedWCharBuffer& s) const
|
||||||
{ return compare(s); }
|
{ return compare(s); }
|
||||||
// same as Cmp() but not case-sensitive
|
// same as Cmp() but not case-sensitive
|
||||||
int CmpNoCase(const wxString& s) const;
|
int CmpNoCase(const wxString& s) const;
|
||||||
@@ -2089,9 +2098,9 @@ public:
|
|||||||
|
|
||||||
bool IsSameAs(const wxCStrData& str, bool compareWithCase = true) const
|
bool IsSameAs(const wxCStrData& str, bool compareWithCase = true) const
|
||||||
{ return IsSameAs(str.AsString(), compareWithCase); }
|
{ return IsSameAs(str.AsString(), compareWithCase); }
|
||||||
bool IsSameAs(const wxCharBuffer& str, bool compareWithCase = true) const
|
bool IsSameAs(const wxScopedCharBuffer& str, bool compareWithCase = true) const
|
||||||
{ return IsSameAs(str.data(), compareWithCase); }
|
{ return IsSameAs(str.data(), compareWithCase); }
|
||||||
bool IsSameAs(const wxWCharBuffer& str, bool compareWithCase = true) const
|
bool IsSameAs(const wxScopedWCharBuffer& str, bool compareWithCase = true) const
|
||||||
{ return IsSameAs(str.data(), compareWithCase); }
|
{ return IsSameAs(str.data(), compareWithCase); }
|
||||||
// comparison with a single character: returns true if equal
|
// comparison with a single character: returns true if equal
|
||||||
bool IsSameAs(wxUniChar c, bool compareWithCase = true) const;
|
bool IsSameAs(wxUniChar c, bool compareWithCase = true) const;
|
||||||
@@ -2198,9 +2207,9 @@ public:
|
|||||||
|
|
||||||
int Find(const wxCStrData& sub) const
|
int Find(const wxCStrData& sub) const
|
||||||
{ return Find(sub.AsString()); }
|
{ return Find(sub.AsString()); }
|
||||||
int Find(const wxCharBuffer& sub) const
|
int Find(const wxScopedCharBuffer& sub) const
|
||||||
{ return Find(sub.data()); }
|
{ return Find(sub.data()); }
|
||||||
int Find(const wxWCharBuffer& sub) const
|
int Find(const wxScopedWCharBuffer& sub) const
|
||||||
{ return Find(sub.data()); }
|
{ return Find(sub.data()); }
|
||||||
|
|
||||||
// replace first (or all of bReplaceAll) occurrences of substring with
|
// replace first (or all of bReplaceAll) occurrences of substring with
|
||||||
@@ -2454,15 +2463,15 @@ public:
|
|||||||
|
|
||||||
wxString& append(const wxCStrData& str)
|
wxString& append(const wxCStrData& str)
|
||||||
{ return append(str.AsString()); }
|
{ return append(str.AsString()); }
|
||||||
wxString& append(const wxCharBuffer& str)
|
wxString& append(const wxScopedCharBuffer& str)
|
||||||
{ return append(str.data()); }
|
{ return append(str.data()); }
|
||||||
wxString& append(const wxWCharBuffer& str)
|
wxString& append(const wxScopedWCharBuffer& str)
|
||||||
{ return append(str.data()); }
|
{ return append(str.data()); }
|
||||||
wxString& append(const wxCStrData& str, size_t n)
|
wxString& append(const wxCStrData& str, size_t n)
|
||||||
{ return append(str.AsString(), 0, n); }
|
{ return append(str.AsString(), 0, n); }
|
||||||
wxString& append(const wxCharBuffer& str, size_t n)
|
wxString& append(const wxScopedCharBuffer& str, size_t n)
|
||||||
{ return append(str.data(), n); }
|
{ return append(str.data(), n); }
|
||||||
wxString& append(const wxWCharBuffer& str, size_t n)
|
wxString& append(const wxScopedWCharBuffer& str, size_t n)
|
||||||
{ return append(str.data(), n); }
|
{ return append(str.data(), n); }
|
||||||
|
|
||||||
// append n copies of ch
|
// append n copies of ch
|
||||||
@@ -2586,15 +2595,15 @@ public:
|
|||||||
|
|
||||||
wxString& assign(const wxCStrData& str)
|
wxString& assign(const wxCStrData& str)
|
||||||
{ return assign(str.AsString()); }
|
{ return assign(str.AsString()); }
|
||||||
wxString& assign(const wxCharBuffer& str)
|
wxString& assign(const wxScopedCharBuffer& str)
|
||||||
{ return assign(str.data()); }
|
{ return assign(str.data()); }
|
||||||
wxString& assign(const wxWCharBuffer& str)
|
wxString& assign(const wxScopedWCharBuffer& str)
|
||||||
{ return assign(str.data()); }
|
{ return assign(str.data()); }
|
||||||
wxString& assign(const wxCStrData& str, size_t len)
|
wxString& assign(const wxCStrData& str, size_t len)
|
||||||
{ return assign(str.AsString(), len); }
|
{ return assign(str.AsString(), len); }
|
||||||
wxString& assign(const wxCharBuffer& str, size_t len)
|
wxString& assign(const wxScopedCharBuffer& str, size_t len)
|
||||||
{ return assign(str.data(), len); }
|
{ return assign(str.data(), len); }
|
||||||
wxString& assign(const wxWCharBuffer& str, size_t len)
|
wxString& assign(const wxScopedWCharBuffer& str, size_t len)
|
||||||
{ return assign(str.data(), len); }
|
{ return assign(str.data(), len); }
|
||||||
|
|
||||||
// same as `= n copies of ch'
|
// same as `= n copies of ch'
|
||||||
@@ -2645,9 +2654,9 @@ public:
|
|||||||
int compare(const wchar_t* sz) const;
|
int compare(const wchar_t* sz) const;
|
||||||
int compare(const wxCStrData& str) const
|
int compare(const wxCStrData& str) const
|
||||||
{ return compare(str.AsString()); }
|
{ return compare(str.AsString()); }
|
||||||
int compare(const wxCharBuffer& str) const
|
int compare(const wxScopedCharBuffer& str) const
|
||||||
{ return compare(str.data()); }
|
{ return compare(str.data()); }
|
||||||
int compare(const wxWCharBuffer& str) const
|
int compare(const wxScopedWCharBuffer& str) const
|
||||||
{ return compare(str.data()); }
|
{ return compare(str.data()); }
|
||||||
// comparison with a substring
|
// comparison with a substring
|
||||||
int compare(size_t nStart, size_t nLen, const wxString& str) const;
|
int compare(size_t nStart, size_t nLen, const wxString& str) const;
|
||||||
@@ -3028,9 +3037,9 @@ public:
|
|||||||
SubstrBufFromWC str(ImplStr(sz, n));
|
SubstrBufFromWC str(ImplStr(sz, n));
|
||||||
return PosFromImpl(m_impl.find(str.data, PosToImpl(nStart), str.len));
|
return PosFromImpl(m_impl.find(str.data, PosToImpl(nStart), str.len));
|
||||||
}
|
}
|
||||||
size_t find(const wxCharBuffer& s, size_t nStart = 0, size_t n = npos) const
|
size_t find(const wxScopedCharBuffer& s, size_t nStart = 0, size_t n = npos) const
|
||||||
{ return find(s.data(), nStart, n); }
|
{ return find(s.data(), nStart, n); }
|
||||||
size_t find(const wxWCharBuffer& s, size_t nStart = 0, size_t n = npos) const
|
size_t find(const wxScopedWCharBuffer& s, size_t nStart = 0, size_t n = npos) const
|
||||||
{ return find(s.data(), nStart, n); }
|
{ return find(s.data(), nStart, n); }
|
||||||
size_t find(const wxCStrData& s, size_t nStart = 0, size_t n = npos) const
|
size_t find(const wxCStrData& s, size_t nStart = 0, size_t n = npos) const
|
||||||
{ return find(s.AsWChar(), nStart, n); }
|
{ return find(s.AsWChar(), nStart, n); }
|
||||||
@@ -3074,9 +3083,9 @@ public:
|
|||||||
SubstrBufFromWC str(ImplStr(sz, n));
|
SubstrBufFromWC str(ImplStr(sz, n));
|
||||||
return PosFromImpl(m_impl.rfind(str.data, PosToImpl(nStart), str.len));
|
return PosFromImpl(m_impl.rfind(str.data, PosToImpl(nStart), str.len));
|
||||||
}
|
}
|
||||||
size_t rfind(const wxCharBuffer& s, size_t nStart = npos, size_t n = npos) const
|
size_t rfind(const wxScopedCharBuffer& s, size_t nStart = npos, size_t n = npos) const
|
||||||
{ return rfind(s.data(), nStart, n); }
|
{ return rfind(s.data(), nStart, n); }
|
||||||
size_t rfind(const wxWCharBuffer& s, size_t nStart = npos, size_t n = npos) const
|
size_t rfind(const wxScopedWCharBuffer& s, size_t nStart = npos, size_t n = npos) const
|
||||||
{ return rfind(s.data(), nStart, n); }
|
{ return rfind(s.data(), nStart, n); }
|
||||||
size_t rfind(const wxCStrData& s, size_t nStart = npos, size_t n = npos) const
|
size_t rfind(const wxCStrData& s, size_t nStart = npos, size_t n = npos) const
|
||||||
{ return rfind(s.AsWChar(), nStart, n); }
|
{ return rfind(s.AsWChar(), nStart, n); }
|
||||||
@@ -3262,54 +3271,54 @@ public:
|
|||||||
// and additional overloads for the versions taking strings:
|
// and additional overloads for the versions taking strings:
|
||||||
size_t find_first_of(const wxCStrData& sz, size_t nStart = 0) const
|
size_t find_first_of(const wxCStrData& sz, size_t nStart = 0) const
|
||||||
{ return find_first_of(sz.AsString(), nStart); }
|
{ return find_first_of(sz.AsString(), nStart); }
|
||||||
size_t find_first_of(const wxCharBuffer& sz, size_t nStart = 0) const
|
size_t find_first_of(const wxScopedCharBuffer& sz, size_t nStart = 0) const
|
||||||
{ return find_first_of(sz.data(), nStart); }
|
{ return find_first_of(sz.data(), nStart); }
|
||||||
size_t find_first_of(const wxWCharBuffer& sz, size_t nStart = 0) const
|
size_t find_first_of(const wxScopedWCharBuffer& sz, size_t nStart = 0) const
|
||||||
{ return find_first_of(sz.data(), nStart); }
|
{ return find_first_of(sz.data(), nStart); }
|
||||||
size_t find_first_of(const wxCStrData& sz, size_t nStart, size_t n) const
|
size_t find_first_of(const wxCStrData& sz, size_t nStart, size_t n) const
|
||||||
{ return find_first_of(sz.AsWChar(), nStart, n); }
|
{ return find_first_of(sz.AsWChar(), nStart, n); }
|
||||||
size_t find_first_of(const wxCharBuffer& sz, size_t nStart, size_t n) const
|
size_t find_first_of(const wxScopedCharBuffer& sz, size_t nStart, size_t n) const
|
||||||
{ return find_first_of(sz.data(), nStart, n); }
|
{ return find_first_of(sz.data(), nStart, n); }
|
||||||
size_t find_first_of(const wxWCharBuffer& sz, size_t nStart, size_t n) const
|
size_t find_first_of(const wxScopedWCharBuffer& sz, size_t nStart, size_t n) const
|
||||||
{ return find_first_of(sz.data(), nStart, n); }
|
{ return find_first_of(sz.data(), nStart, n); }
|
||||||
|
|
||||||
size_t find_last_of(const wxCStrData& sz, size_t nStart = 0) const
|
size_t find_last_of(const wxCStrData& sz, size_t nStart = 0) const
|
||||||
{ return find_last_of(sz.AsString(), nStart); }
|
{ return find_last_of(sz.AsString(), nStart); }
|
||||||
size_t find_last_of(const wxCharBuffer& sz, size_t nStart = 0) const
|
size_t find_last_of(const wxScopedCharBuffer& sz, size_t nStart = 0) const
|
||||||
{ return find_last_of(sz.data(), nStart); }
|
{ return find_last_of(sz.data(), nStart); }
|
||||||
size_t find_last_of(const wxWCharBuffer& sz, size_t nStart = 0) const
|
size_t find_last_of(const wxScopedWCharBuffer& sz, size_t nStart = 0) const
|
||||||
{ return find_last_of(sz.data(), nStart); }
|
{ return find_last_of(sz.data(), nStart); }
|
||||||
size_t find_last_of(const wxCStrData& sz, size_t nStart, size_t n) const
|
size_t find_last_of(const wxCStrData& sz, size_t nStart, size_t n) const
|
||||||
{ return find_last_of(sz.AsWChar(), nStart, n); }
|
{ return find_last_of(sz.AsWChar(), nStart, n); }
|
||||||
size_t find_last_of(const wxCharBuffer& sz, size_t nStart, size_t n) const
|
size_t find_last_of(const wxScopedCharBuffer& sz, size_t nStart, size_t n) const
|
||||||
{ return find_last_of(sz.data(), nStart, n); }
|
{ return find_last_of(sz.data(), nStart, n); }
|
||||||
size_t find_last_of(const wxWCharBuffer& sz, size_t nStart, size_t n) const
|
size_t find_last_of(const wxScopedWCharBuffer& sz, size_t nStart, size_t n) const
|
||||||
{ return find_last_of(sz.data(), nStart, n); }
|
{ return find_last_of(sz.data(), nStart, n); }
|
||||||
|
|
||||||
size_t find_first_not_of(const wxCStrData& sz, size_t nStart = 0) const
|
size_t find_first_not_of(const wxCStrData& sz, size_t nStart = 0) const
|
||||||
{ return find_first_not_of(sz.AsString(), nStart); }
|
{ return find_first_not_of(sz.AsString(), nStart); }
|
||||||
size_t find_first_not_of(const wxCharBuffer& sz, size_t nStart = 0) const
|
size_t find_first_not_of(const wxScopedCharBuffer& sz, size_t nStart = 0) const
|
||||||
{ return find_first_not_of(sz.data(), nStart); }
|
{ return find_first_not_of(sz.data(), nStart); }
|
||||||
size_t find_first_not_of(const wxWCharBuffer& sz, size_t nStart = 0) const
|
size_t find_first_not_of(const wxScopedWCharBuffer& sz, size_t nStart = 0) const
|
||||||
{ return find_first_not_of(sz.data(), nStart); }
|
{ return find_first_not_of(sz.data(), nStart); }
|
||||||
size_t find_first_not_of(const wxCStrData& sz, size_t nStart, size_t n) const
|
size_t find_first_not_of(const wxCStrData& sz, size_t nStart, size_t n) const
|
||||||
{ return find_first_not_of(sz.AsWChar(), nStart, n); }
|
{ return find_first_not_of(sz.AsWChar(), nStart, n); }
|
||||||
size_t find_first_not_of(const wxCharBuffer& sz, size_t nStart, size_t n) const
|
size_t find_first_not_of(const wxScopedCharBuffer& sz, size_t nStart, size_t n) const
|
||||||
{ return find_first_not_of(sz.data(), nStart, n); }
|
{ return find_first_not_of(sz.data(), nStart, n); }
|
||||||
size_t find_first_not_of(const wxWCharBuffer& sz, size_t nStart, size_t n) const
|
size_t find_first_not_of(const wxScopedWCharBuffer& sz, size_t nStart, size_t n) const
|
||||||
{ return find_first_not_of(sz.data(), nStart, n); }
|
{ return find_first_not_of(sz.data(), nStart, n); }
|
||||||
|
|
||||||
size_t find_last_not_of(const wxCStrData& sz, size_t nStart = 0) const
|
size_t find_last_not_of(const wxCStrData& sz, size_t nStart = 0) const
|
||||||
{ return find_last_not_of(sz.AsString(), nStart); }
|
{ return find_last_not_of(sz.AsString(), nStart); }
|
||||||
size_t find_last_not_of(const wxCharBuffer& sz, size_t nStart = 0) const
|
size_t find_last_not_of(const wxScopedCharBuffer& sz, size_t nStart = 0) const
|
||||||
{ return find_last_not_of(sz.data(), nStart); }
|
{ return find_last_not_of(sz.data(), nStart); }
|
||||||
size_t find_last_not_of(const wxWCharBuffer& sz, size_t nStart = 0) const
|
size_t find_last_not_of(const wxScopedWCharBuffer& sz, size_t nStart = 0) const
|
||||||
{ return find_last_not_of(sz.data(), nStart); }
|
{ return find_last_not_of(sz.data(), nStart); }
|
||||||
size_t find_last_not_of(const wxCStrData& sz, size_t nStart, size_t n) const
|
size_t find_last_not_of(const wxCStrData& sz, size_t nStart, size_t n) const
|
||||||
{ return find_last_not_of(sz.AsWChar(), nStart, n); }
|
{ return find_last_not_of(sz.AsWChar(), nStart, n); }
|
||||||
size_t find_last_not_of(const wxCharBuffer& sz, size_t nStart, size_t n) const
|
size_t find_last_not_of(const wxScopedCharBuffer& sz, size_t nStart, size_t n) const
|
||||||
{ return find_last_not_of(sz.data(), nStart, n); }
|
{ return find_last_not_of(sz.data(), nStart, n); }
|
||||||
size_t find_last_not_of(const wxWCharBuffer& sz, size_t nStart, size_t n) const
|
size_t find_last_not_of(const wxScopedWCharBuffer& sz, size_t nStart, size_t n) const
|
||||||
{ return find_last_not_of(sz.data(), nStart, n); }
|
{ return find_last_not_of(sz.data(), nStart, n); }
|
||||||
|
|
||||||
// string += string
|
// string += string
|
||||||
@@ -3342,9 +3351,9 @@ public:
|
|||||||
m_impl += s.AsString().m_impl;
|
m_impl += s.AsString().m_impl;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
wxString& operator+=(const wxCharBuffer& s)
|
wxString& operator+=(const wxScopedCharBuffer& s)
|
||||||
{ return operator+=(s.data()); }
|
{ return operator+=(s.data()); }
|
||||||
wxString& operator+=(const wxWCharBuffer& s)
|
wxString& operator+=(const wxScopedWCharBuffer& s)
|
||||||
{ return operator+=(s.data()); }
|
{ return operator+=(s.data()); }
|
||||||
// string += char
|
// string += char
|
||||||
wxString& operator+=(wxUniChar ch)
|
wxString& operator+=(wxUniChar ch)
|
||||||
@@ -3517,9 +3526,9 @@ namespace wxPrivate
|
|||||||
template <>
|
template <>
|
||||||
struct wxStringAsBufHelper<char>
|
struct wxStringAsBufHelper<char>
|
||||||
{
|
{
|
||||||
static wxCharBuffer Get(const wxString& s, size_t *len)
|
static wxScopedCharBuffer Get(const wxString& s, size_t *len)
|
||||||
{
|
{
|
||||||
wxCharBuffer buf(s.mb_str());
|
wxScopedCharBuffer buf(s.mb_str());
|
||||||
if ( len )
|
if ( len )
|
||||||
*len = buf ? strlen(buf) : 0;
|
*len = buf ? strlen(buf) : 0;
|
||||||
return buf;
|
return buf;
|
||||||
@@ -3529,11 +3538,11 @@ struct wxStringAsBufHelper<char>
|
|||||||
template <>
|
template <>
|
||||||
struct wxStringAsBufHelper<wchar_t>
|
struct wxStringAsBufHelper<wchar_t>
|
||||||
{
|
{
|
||||||
static wxWCharBuffer Get(const wxString& s, size_t *len)
|
static wxScopedWCharBuffer Get(const wxString& s, size_t *len)
|
||||||
{
|
{
|
||||||
if ( len )
|
if ( len )
|
||||||
*len = s.length();
|
*len = s.length();
|
||||||
return wxWCharBuffer::CreateNonOwned(s.wx_str());
|
return wxScopedWCharBuffer::CreateNonOwned(s.wx_str());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -3542,20 +3551,20 @@ struct wxStringAsBufHelper<wchar_t>
|
|||||||
template <>
|
template <>
|
||||||
struct wxStringAsBufHelper<char>
|
struct wxStringAsBufHelper<char>
|
||||||
{
|
{
|
||||||
static wxCharBuffer Get(const wxString& s, size_t *len)
|
static wxScopedCharBuffer Get(const wxString& s, size_t *len)
|
||||||
{
|
{
|
||||||
if ( len )
|
if ( len )
|
||||||
*len = s.utf8_length();
|
*len = s.utf8_length();
|
||||||
return wxCharBuffer::CreateNonOwned(s.wx_str());
|
return wxScopedCharBuffer::CreateNonOwned(s.wx_str());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct wxStringAsBufHelper<wchar_t>
|
struct wxStringAsBufHelper<wchar_t>
|
||||||
{
|
{
|
||||||
static wxWCharBuffer Get(const wxString& s, size_t *len)
|
static wxScopedWCharBuffer Get(const wxString& s, size_t *len)
|
||||||
{
|
{
|
||||||
wxWCharBuffer wbuf(s.wc_str());
|
wxScopedWCharBuffer wbuf(s.wc_str());
|
||||||
if ( len )
|
if ( len )
|
||||||
*len = wxWcslen(wbuf);
|
*len = wxWcslen(wbuf);
|
||||||
return wbuf;
|
return wbuf;
|
||||||
@@ -3859,32 +3868,32 @@ inline bool operator!=(const wxString& s1, const wxCStrData& s2)
|
|||||||
inline bool operator!=(const wxCStrData& s1, const wxString& s2)
|
inline bool operator!=(const wxCStrData& s1, const wxString& s2)
|
||||||
{ return s1.AsString() != s2; }
|
{ return s1.AsString() != s2; }
|
||||||
|
|
||||||
inline bool operator==(const wxString& s1, const wxWCharBuffer& s2)
|
inline bool operator==(const wxString& s1, const wxScopedWCharBuffer& s2)
|
||||||
{ return (s1.Cmp((const wchar_t *)s2) == 0); }
|
{ return (s1.Cmp((const wchar_t *)s2) == 0); }
|
||||||
inline bool operator==(const wxWCharBuffer& s1, const wxString& s2)
|
inline bool operator==(const wxScopedWCharBuffer& s1, const wxString& s2)
|
||||||
{ return (s2.Cmp((const wchar_t *)s1) == 0); }
|
{ return (s2.Cmp((const wchar_t *)s1) == 0); }
|
||||||
inline bool operator!=(const wxString& s1, const wxWCharBuffer& s2)
|
inline bool operator!=(const wxString& s1, const wxScopedWCharBuffer& s2)
|
||||||
{ return (s1.Cmp((const wchar_t *)s2) != 0); }
|
{ return (s1.Cmp((const wchar_t *)s2) != 0); }
|
||||||
inline bool operator!=(const wxWCharBuffer& s1, const wxString& s2)
|
inline bool operator!=(const wxScopedWCharBuffer& s1, const wxString& s2)
|
||||||
{ return (s2.Cmp((const wchar_t *)s1) != 0); }
|
{ return (s2.Cmp((const wchar_t *)s1) != 0); }
|
||||||
|
|
||||||
inline bool operator==(const wxString& s1, const wxCharBuffer& s2)
|
inline bool operator==(const wxString& s1, const wxScopedCharBuffer& s2)
|
||||||
{ return (s1.Cmp((const char *)s2) == 0); }
|
{ return (s1.Cmp((const char *)s2) == 0); }
|
||||||
inline bool operator==(const wxCharBuffer& s1, const wxString& s2)
|
inline bool operator==(const wxScopedCharBuffer& s1, const wxString& s2)
|
||||||
{ return (s2.Cmp((const char *)s1) == 0); }
|
{ return (s2.Cmp((const char *)s1) == 0); }
|
||||||
inline bool operator!=(const wxString& s1, const wxCharBuffer& s2)
|
inline bool operator!=(const wxString& s1, const wxScopedCharBuffer& s2)
|
||||||
{ return (s1.Cmp((const char *)s2) != 0); }
|
{ return (s1.Cmp((const char *)s2) != 0); }
|
||||||
inline bool operator!=(const wxCharBuffer& s1, const wxString& s2)
|
inline bool operator!=(const wxScopedCharBuffer& s1, const wxString& s2)
|
||||||
{ return (s2.Cmp((const char *)s1) != 0); }
|
{ return (s2.Cmp((const char *)s1) != 0); }
|
||||||
|
|
||||||
inline wxString operator+(const wxString& string, const wxWCharBuffer& buf)
|
inline wxString operator+(const wxString& string, const wxScopedWCharBuffer& buf)
|
||||||
{ return string + (const wchar_t *)buf; }
|
{ return string + (const wchar_t *)buf; }
|
||||||
inline wxString operator+(const wxWCharBuffer& buf, const wxString& string)
|
inline wxString operator+(const wxScopedWCharBuffer& buf, const wxString& string)
|
||||||
{ return (const wchar_t *)buf + string; }
|
{ return (const wchar_t *)buf + string; }
|
||||||
|
|
||||||
inline wxString operator+(const wxString& string, const wxCharBuffer& buf)
|
inline wxString operator+(const wxString& string, const wxScopedCharBuffer& buf)
|
||||||
{ return string + (const char *)buf; }
|
{ return string + (const char *)buf; }
|
||||||
inline wxString operator+(const wxCharBuffer& buf, const wxString& string)
|
inline wxString operator+(const wxScopedCharBuffer& buf, const wxString& string)
|
||||||
{ return (const char *)buf + string; }
|
{ return (const char *)buf + string; }
|
||||||
|
|
||||||
// comparison with char
|
// comparison with char
|
||||||
@@ -3942,16 +3951,16 @@ wxDEFINE_ALL_COMPARISONS(const char *, const wxCStrData&, wxCMP_CHAR_CSTRDATA)
|
|||||||
|
|
||||||
WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxString&);
|
WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxString&);
|
||||||
WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxCStrData&);
|
WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxCStrData&);
|
||||||
WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxCharBuffer&);
|
WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxScopedCharBuffer&);
|
||||||
#ifndef __BORLANDC__
|
#ifndef __BORLANDC__
|
||||||
WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxWCharBuffer&);
|
WXDLLIMPEXP_BASE wxSTD ostream& operator<<(wxSTD ostream&, const wxScopedWCharBuffer&);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_UNICODE && defined(HAVE_WOSTREAM)
|
#if wxUSE_UNICODE && defined(HAVE_WOSTREAM)
|
||||||
|
|
||||||
WXDLLIMPEXP_BASE wxSTD wostream& operator<<(wxSTD wostream&, const wxString&);
|
WXDLLIMPEXP_BASE wxSTD wostream& operator<<(wxSTD wostream&, const wxString&);
|
||||||
WXDLLIMPEXP_BASE wxSTD wostream& operator<<(wxSTD wostream&, const wxCStrData&);
|
WXDLLIMPEXP_BASE wxSTD wostream& operator<<(wxSTD wostream&, const wxCStrData&);
|
||||||
WXDLLIMPEXP_BASE wxSTD wostream& operator<<(wxSTD wostream&, const wxWCharBuffer&);
|
WXDLLIMPEXP_BASE wxSTD wostream& operator<<(wxSTD wostream&, const wxScopedWCharBuffer&);
|
||||||
|
|
||||||
#endif // wxUSE_UNICODE && defined(HAVE_WOSTREAM)
|
#endif // wxUSE_UNICODE && defined(HAVE_WOSTREAM)
|
||||||
|
|
||||||
@@ -4002,19 +4011,19 @@ inline const char* wxCStrData::AsChar() const
|
|||||||
}
|
}
|
||||||
#endif // wxUSE_UTF8_LOCALE_ONLY
|
#endif // wxUSE_UTF8_LOCALE_ONLY
|
||||||
|
|
||||||
inline const wxCharBuffer wxCStrData::AsCharBuf() const
|
inline const wxScopedCharBuffer wxCStrData::AsCharBuf() const
|
||||||
{
|
{
|
||||||
#if !wxUSE_UNICODE
|
#if !wxUSE_UNICODE
|
||||||
return wxCharBuffer::CreateNonOwned(AsChar());
|
return wxScopedCharBuffer::CreateNonOwned(AsChar());
|
||||||
#else
|
#else
|
||||||
return AsString().mb_str();
|
return AsString().mb_str();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const wxWCharBuffer wxCStrData::AsWCharBuf() const
|
inline const wxScopedWCharBuffer wxCStrData::AsWCharBuf() const
|
||||||
{
|
{
|
||||||
#if wxUSE_UNICODE_WCHAR
|
#if wxUSE_UNICODE_WCHAR
|
||||||
return wxWCharBuffer::CreateNonOwned(AsWChar());
|
return wxScopedWCharBuffer::CreateNonOwned(AsWChar());
|
||||||
#else
|
#else
|
||||||
return AsString().wc_str();
|
return AsString().wc_str();
|
||||||
#endif
|
#endif
|
||||||
|
@@ -128,16 +128,16 @@ class WXDLLIMPEXP_BASE wxFormatString
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxFormatString(const char *str)
|
wxFormatString(const char *str)
|
||||||
: m_char(wxCharBuffer::CreateNonOwned(str)), m_str(NULL), m_cstr(NULL) {}
|
: m_char(wxScopedCharBuffer::CreateNonOwned(str)), m_str(NULL), m_cstr(NULL) {}
|
||||||
wxFormatString(const wchar_t *str)
|
wxFormatString(const wchar_t *str)
|
||||||
: m_wchar(wxWCharBuffer::CreateNonOwned(str)), m_str(NULL), m_cstr(NULL) {}
|
: m_wchar(wxScopedWCharBuffer::CreateNonOwned(str)), m_str(NULL), m_cstr(NULL) {}
|
||||||
wxFormatString(const wxString& str)
|
wxFormatString(const wxString& str)
|
||||||
: m_str(&str), m_cstr(NULL) {}
|
: m_str(&str), m_cstr(NULL) {}
|
||||||
wxFormatString(const wxCStrData& str)
|
wxFormatString(const wxCStrData& str)
|
||||||
: m_str(NULL), m_cstr(&str) {}
|
: m_str(NULL), m_cstr(&str) {}
|
||||||
wxFormatString(const wxCharBuffer& str)
|
wxFormatString(const wxScopedCharBuffer& str)
|
||||||
: m_char(str), m_str(NULL), m_cstr(NULL) {}
|
: m_char(str), m_str(NULL), m_cstr(NULL) {}
|
||||||
wxFormatString(const wxWCharBuffer& str)
|
wxFormatString(const wxScopedWCharBuffer& str)
|
||||||
: m_wchar(str), m_str(NULL), m_cstr(NULL) {}
|
: m_wchar(str), m_str(NULL), m_cstr(NULL) {}
|
||||||
|
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ private:
|
|||||||
// ..AsWChar() below)
|
// ..AsWChar() below)
|
||||||
const char* InputAsChar();
|
const char* InputAsChar();
|
||||||
const char* AsChar();
|
const char* AsChar();
|
||||||
wxCharBuffer m_convertedChar;
|
wxScopedCharBuffer m_convertedChar;
|
||||||
#endif // !wxUSE_UNICODE_WCHAR
|
#endif // !wxUSE_UNICODE_WCHAR
|
||||||
|
|
||||||
#if wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY
|
#if wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY
|
||||||
@@ -178,12 +178,12 @@ public:
|
|||||||
private:
|
private:
|
||||||
const wchar_t* InputAsWChar();
|
const wchar_t* InputAsWChar();
|
||||||
const wchar_t* AsWChar();
|
const wchar_t* AsWChar();
|
||||||
wxWCharBuffer m_convertedWChar;
|
wxScopedWCharBuffer m_convertedWChar;
|
||||||
#endif // wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY
|
#endif // wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxCharBuffer m_char;
|
wxScopedCharBuffer m_char;
|
||||||
wxWCharBuffer m_wchar;
|
wxScopedWCharBuffer m_wchar;
|
||||||
|
|
||||||
// NB: we can use a pointer here, because wxFormatString is only used
|
// NB: we can use a pointer here, because wxFormatString is only used
|
||||||
// as function argument, so it has shorter life than the string
|
// as function argument, so it has shorter life than the string
|
||||||
@@ -240,12 +240,12 @@ struct wxFormatStringArgumentFinder<wxString>
|
|||||||
: public wxFormatStringArgumentFinder<const wxString&> {};
|
: public wxFormatStringArgumentFinder<const wxString&> {};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct wxFormatStringArgumentFinder<wxCharBuffer>
|
struct wxFormatStringArgumentFinder<wxScopedCharBuffer>
|
||||||
: public wxFormatStringArgumentFinder<const wxCharBuffer&> {};
|
: public wxFormatStringArgumentFinder<const wxScopedCharBuffer&> {};
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
struct wxFormatStringArgumentFinder<wxWCharBuffer>
|
struct wxFormatStringArgumentFinder<wxScopedWCharBuffer>
|
||||||
: public wxFormatStringArgumentFinder<const wxWCharBuffer&> {};
|
: public wxFormatStringArgumentFinder<const wxScopedWCharBuffer&> {};
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -314,7 +314,7 @@ struct wxArgNormalizerWchar : public wxArgNormalizer<T>
|
|||||||
template<typename CharType>
|
template<typename CharType>
|
||||||
struct wxArgNormalizerWithBuffer
|
struct wxArgNormalizerWithBuffer
|
||||||
{
|
{
|
||||||
typedef wxCharTypeBuffer<CharType> CharBuffer;
|
typedef wxScopedCharTypeBuffer<CharType> CharBuffer;
|
||||||
|
|
||||||
wxArgNormalizerWithBuffer() {}
|
wxArgNormalizerWithBuffer() {}
|
||||||
wxArgNormalizerWithBuffer(const CharBuffer& buf,
|
wxArgNormalizerWithBuffer(const CharBuffer& buf,
|
||||||
@@ -409,12 +409,12 @@ struct wxArgNormalizerUtf8<const char*>
|
|||||||
{
|
{
|
||||||
if ( wxLocaleIsUtf8 )
|
if ( wxLocaleIsUtf8 )
|
||||||
{
|
{
|
||||||
m_value = wxCharBuffer::CreateNonOwned(s);
|
m_value = wxScopedCharBuffer::CreateNonOwned(s);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// convert to widechar string first:
|
// convert to widechar string first:
|
||||||
wxWCharBuffer buf(wxConvLibc.cMB2WC(s));
|
wxScopedWCharBuffer buf(wxConvLibc.cMB2WC(s));
|
||||||
|
|
||||||
// then to UTF-8:
|
// then to UTF-8:
|
||||||
if ( buf )
|
if ( buf )
|
||||||
@@ -485,10 +485,10 @@ WX_ARG_NORMALIZER_FORWARD(char*, const char*);
|
|||||||
WX_ARG_NORMALIZER_FORWARD(wchar_t*, const wchar_t*);
|
WX_ARG_NORMALIZER_FORWARD(wchar_t*, const wchar_t*);
|
||||||
|
|
||||||
// versions for passing wx[W]CharBuffer:
|
// versions for passing wx[W]CharBuffer:
|
||||||
WX_ARG_NORMALIZER_FORWARD(wxCharBuffer, const char*);
|
WX_ARG_NORMALIZER_FORWARD(wxScopedCharBuffer, const char*);
|
||||||
WX_ARG_NORMALIZER_FORWARD(const wxCharBuffer&, const char*);
|
WX_ARG_NORMALIZER_FORWARD(const wxScopedCharBuffer&, const char*);
|
||||||
WX_ARG_NORMALIZER_FORWARD(wxWCharBuffer, const wchar_t*);
|
WX_ARG_NORMALIZER_FORWARD(wxScopedWCharBuffer, const wchar_t*);
|
||||||
WX_ARG_NORMALIZER_FORWARD(const wxWCharBuffer&, const wchar_t*);
|
WX_ARG_NORMALIZER_FORWARD(const wxScopedWCharBuffer&, const wchar_t*);
|
||||||
|
|
||||||
// versions for std::[w]string:
|
// versions for std::[w]string:
|
||||||
#if wxUSE_STD_STRING
|
#if wxUSE_STD_STRING
|
||||||
|
@@ -17,14 +17,18 @@
|
|||||||
|
|
||||||
#if SIZEOF_WCHAR_T == 2
|
#if SIZEOF_WCHAR_T == 2
|
||||||
typedef wxWCharBuffer wxU16CharBuffer;
|
typedef wxWCharBuffer wxU16CharBuffer;
|
||||||
|
typedef wxScopedWCharBuffer wxScopedU16CharBuffer;
|
||||||
#else
|
#else
|
||||||
typedef wxCharTypeBuffer<wxChar16> wxU16CharBuffer;
|
typedef wxCharTypeBuffer<wxChar16> wxU16CharBuffer;
|
||||||
|
typedef wxScopedCharTypeBuffer<wxChar16> wxScopedU16CharBuffer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SIZEOF_WCHAR_T == 4
|
#if SIZEOF_WCHAR_T == 4
|
||||||
typedef wxWCharBuffer wxU32CharBuffer;
|
typedef wxWCharBuffer wxU32CharBuffer;
|
||||||
|
typedef wxScopedWCharBuffer wxScopedU32CharBuffer;
|
||||||
#else
|
#else
|
||||||
typedef wxCharTypeBuffer<wxChar32> wxU32CharBuffer;
|
typedef wxCharTypeBuffer<wxChar32> wxU32CharBuffer;
|
||||||
|
typedef wxScopedCharTypeBuffer<wxChar32> wxScopedU32CharBuffer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -35,15 +39,15 @@ public:
|
|||||||
|
|
||||||
wxUString( const wxChar32 *str ) { assign(str); }
|
wxUString( const wxChar32 *str ) { assign(str); }
|
||||||
wxUString( const wxUString &str ) { assign(str); }
|
wxUString( const wxUString &str ) { assign(str); }
|
||||||
wxUString( const wxU32CharBuffer &buf ) { assign(buf); }
|
wxUString( const wxScopedU32CharBuffer &buf ) { assign(buf); }
|
||||||
|
|
||||||
wxUString( const char *str ) { assign(str); }
|
wxUString( const char *str ) { assign(str); }
|
||||||
wxUString( const wxCharBuffer &buf ) { assign(buf); }
|
wxUString( const wxScopedCharBuffer &buf ) { assign(buf); }
|
||||||
wxUString( const char *str, const wxMBConv &conv ) { assign(str,conv); }
|
wxUString( const char *str, const wxMBConv &conv ) { assign(str,conv); }
|
||||||
wxUString( const wxCharBuffer &buf, const wxMBConv &conv ) { assign(buf,conv); }
|
wxUString( const wxScopedCharBuffer &buf, const wxMBConv &conv ) { assign(buf,conv); }
|
||||||
|
|
||||||
wxUString( const wxChar16 *str ) { assign(str); }
|
wxUString( const wxChar16 *str ) { assign(str); }
|
||||||
wxUString( const wxU16CharBuffer &buf ) { assign(buf); }
|
wxUString( const wxScopedU16CharBuffer &buf ) { assign(buf); }
|
||||||
|
|
||||||
wxUString( const wxCStrData *cstr ) { assign(cstr); }
|
wxUString( const wxCStrData *cstr ) { assign(cstr); }
|
||||||
wxUString( const wxString &str ) { assign(str); }
|
wxUString( const wxString &str ) { assign(str); }
|
||||||
@@ -116,11 +120,11 @@ public:
|
|||||||
|
|
||||||
// conversions
|
// conversions
|
||||||
|
|
||||||
wxCharBuffer utf8_str() const;
|
wxScopedCharBuffer utf8_str() const;
|
||||||
wxU16CharBuffer utf16_str() const;
|
wxScopedU16CharBuffer utf16_str() const;
|
||||||
|
|
||||||
#if SIZEOF_WCHAR_T == 2
|
#if SIZEOF_WCHAR_T == 2
|
||||||
wxWCharBuffer wc_str() const
|
wxScopedWCharBuffer wc_str() const
|
||||||
{
|
{
|
||||||
return utf16_str();
|
return utf16_str();
|
||||||
}
|
}
|
||||||
@@ -145,13 +149,13 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_UNICODE_UTF8
|
#if wxUSE_UNICODE_UTF8
|
||||||
wxCharBuffer wx_str()
|
wxScopedCharBuffer wx_str()
|
||||||
{
|
{
|
||||||
return utf8_str();
|
return utf8_str();
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#if SIZEOF_WCHAR_T == 2
|
#if SIZEOF_WCHAR_T == 2
|
||||||
wxWCharBuffer wx_str()
|
wxScopedWCharBuffer wx_str()
|
||||||
{
|
{
|
||||||
return utf16_str();
|
return utf16_str();
|
||||||
}
|
}
|
||||||
@@ -201,7 +205,7 @@ public:
|
|||||||
return (wxUString &) base->assign( n, ch );
|
return (wxUString &) base->assign( n, ch );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxUString &assign( const wxU32CharBuffer &buf )
|
wxUString &assign( const wxScopedU32CharBuffer &buf )
|
||||||
{
|
{
|
||||||
return assign( buf.data() );
|
return assign( buf.data() );
|
||||||
}
|
}
|
||||||
@@ -211,7 +215,7 @@ public:
|
|||||||
return assignFromCString( str );
|
return assignFromCString( str );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxUString &assign( const wxCharBuffer &buf )
|
wxUString &assign( const wxScopedCharBuffer &buf )
|
||||||
{
|
{
|
||||||
return assignFromCString( buf.data() );
|
return assignFromCString( buf.data() );
|
||||||
}
|
}
|
||||||
@@ -221,7 +225,7 @@ public:
|
|||||||
return assignFromCString( str, conv );
|
return assignFromCString( str, conv );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxUString &assign( const wxCharBuffer &buf, const wxMBConv &conv )
|
wxUString &assign( const wxScopedCharBuffer &buf, const wxMBConv &conv )
|
||||||
{
|
{
|
||||||
return assignFromCString( buf.data(), conv );
|
return assignFromCString( buf.data(), conv );
|
||||||
}
|
}
|
||||||
@@ -231,7 +235,7 @@ public:
|
|||||||
return assignFromUTF16( str );
|
return assignFromUTF16( str );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxUString &assign( const wxU16CharBuffer &buf )
|
wxUString &assign( const wxScopedU16CharBuffer &buf )
|
||||||
{
|
{
|
||||||
return assignFromUTF16( buf.data() );
|
return assignFromUTF16( buf.data() );
|
||||||
}
|
}
|
||||||
@@ -360,12 +364,12 @@ public:
|
|||||||
|
|
||||||
// append [wx overload]
|
// append [wx overload]
|
||||||
|
|
||||||
wxUString &append( const wxU16CharBuffer &buf )
|
wxUString &append( const wxScopedU16CharBuffer &buf )
|
||||||
{
|
{
|
||||||
return append( buf.data() );
|
return append( buf.data() );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxUString &append( const wxU32CharBuffer &buf )
|
wxUString &append( const wxScopedU32CharBuffer &buf )
|
||||||
{
|
{
|
||||||
return append( buf.data() );
|
return append( buf.data() );
|
||||||
}
|
}
|
||||||
@@ -375,7 +379,7 @@ public:
|
|||||||
return append( wxUString( str ) );
|
return append( wxUString( str ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxUString &append( const wxCharBuffer &buf )
|
wxUString &append( const wxScopedCharBuffer &buf )
|
||||||
{
|
{
|
||||||
return append( wxUString( buf ) );
|
return append( wxUString( buf ) );
|
||||||
}
|
}
|
||||||
@@ -467,17 +471,17 @@ public:
|
|||||||
return insert( n, wxUString( s ) );
|
return insert( n, wxUString( s ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxUString &insert( size_type n, const wxCharBuffer &buf )
|
wxUString &insert( size_type n, const wxScopedCharBuffer &buf )
|
||||||
{
|
{
|
||||||
return insert( n, wxUString( buf ) );
|
return insert( n, wxUString( buf ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxUString &insert( size_type n, const wxU16CharBuffer &buf )
|
wxUString &insert( size_type n, const wxScopedU16CharBuffer &buf )
|
||||||
{
|
{
|
||||||
return insert( n, wxUString( buf ) );
|
return insert( n, wxUString( buf ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxUString &insert( size_type n, const wxU32CharBuffer &buf )
|
wxUString &insert( size_type n, const wxScopedU32CharBuffer &buf )
|
||||||
{
|
{
|
||||||
return insert( n, buf.data() );
|
return insert( n, buf.data() );
|
||||||
}
|
}
|
||||||
@@ -536,11 +540,11 @@ public:
|
|||||||
{ return assign( s ); }
|
{ return assign( s ); }
|
||||||
wxUString& operator=(const wxChar32 *s)
|
wxUString& operator=(const wxChar32 *s)
|
||||||
{ return assign( s ); }
|
{ return assign( s ); }
|
||||||
wxUString& operator=(const wxCharBuffer &s)
|
wxUString& operator=(const wxScopedCharBuffer &s)
|
||||||
{ return assign( s ); }
|
{ return assign( s ); }
|
||||||
wxUString& operator=(const wxU16CharBuffer &s)
|
wxUString& operator=(const wxScopedU16CharBuffer &s)
|
||||||
{ return assign( s ); }
|
{ return assign( s ); }
|
||||||
wxUString& operator=(const wxU32CharBuffer &s)
|
wxUString& operator=(const wxScopedU32CharBuffer &s)
|
||||||
{ return assign( s ); }
|
{ return assign( s ); }
|
||||||
wxUString& operator=(const char ch)
|
wxUString& operator=(const char ch)
|
||||||
{ return assign( ch ); }
|
{ return assign( ch ); }
|
||||||
@@ -566,11 +570,11 @@ public:
|
|||||||
{ return append( s ); }
|
{ return append( s ); }
|
||||||
wxUString& operator+=(const wxChar32 *s)
|
wxUString& operator+=(const wxChar32 *s)
|
||||||
{ return append( s ); }
|
{ return append( s ); }
|
||||||
wxUString& operator+=(const wxCharBuffer &s)
|
wxUString& operator+=(const wxScopedCharBuffer &s)
|
||||||
{ return append( s ); }
|
{ return append( s ); }
|
||||||
wxUString& operator+=(const wxU16CharBuffer &s)
|
wxUString& operator+=(const wxScopedU16CharBuffer &s)
|
||||||
{ return append( s ); }
|
{ return append( s ); }
|
||||||
wxUString& operator+=(const wxU32CharBuffer &s)
|
wxUString& operator+=(const wxScopedU32CharBuffer &s)
|
||||||
{ return append( s ); }
|
{ return append( s ); }
|
||||||
wxUString& operator+=(const char ch)
|
wxUString& operator+=(const char ch)
|
||||||
{ return append( ch ); }
|
{ return append( ch ); }
|
||||||
@@ -597,11 +601,11 @@ inline wxUString operator+(const wxUString &s1, const wxChar16* s2)
|
|||||||
{ return s1 + wxUString(s2); }
|
{ return s1 + wxUString(s2); }
|
||||||
inline wxUString operator+(const wxUString &s1, const wxChar32 *s2)
|
inline wxUString operator+(const wxUString &s1, const wxChar32 *s2)
|
||||||
{ return s1 + wxUString(s2); }
|
{ return s1 + wxUString(s2); }
|
||||||
inline wxUString operator+(const wxUString &s1, const wxCharBuffer &s2)
|
inline wxUString operator+(const wxUString &s1, const wxScopedCharBuffer &s2)
|
||||||
{ return s1 + wxUString(s2); }
|
{ return s1 + wxUString(s2); }
|
||||||
inline wxUString operator+(const wxUString &s1, const wxU16CharBuffer &s2)
|
inline wxUString operator+(const wxUString &s1, const wxScopedU16CharBuffer &s2)
|
||||||
{ return s1 + wxUString(s2); }
|
{ return s1 + wxUString(s2); }
|
||||||
inline wxUString operator+(const wxUString &s1, const wxU32CharBuffer &s2)
|
inline wxUString operator+(const wxUString &s1, const wxScopedU32CharBuffer &s2)
|
||||||
{ return s1 + wxUString(s2); }
|
{ return s1 + wxUString(s2); }
|
||||||
inline wxUString operator+(const wxUString &s1, char s2)
|
inline wxUString operator+(const wxUString &s1, char s2)
|
||||||
{ return s1 + wxUString(s2); }
|
{ return s1 + wxUString(s2); }
|
||||||
@@ -624,11 +628,11 @@ inline wxUString operator+(const wxChar16* s1, const wxUString &s2)
|
|||||||
{ return wxUString(s1) + s2; }
|
{ return wxUString(s1) + s2; }
|
||||||
inline wxUString operator+(const wxChar32 *s1, const wxUString &s2)
|
inline wxUString operator+(const wxChar32 *s1, const wxUString &s2)
|
||||||
{ return wxUString(s1) + s2; }
|
{ return wxUString(s1) + s2; }
|
||||||
inline wxUString operator+(const wxCharBuffer &s1, const wxUString &s2)
|
inline wxUString operator+(const wxScopedCharBuffer &s1, const wxUString &s2)
|
||||||
{ return wxUString(s1) + s2; }
|
{ return wxUString(s1) + s2; }
|
||||||
inline wxUString operator+(const wxU16CharBuffer &s1, const wxUString &s2)
|
inline wxUString operator+(const wxScopedU16CharBuffer &s1, const wxUString &s2)
|
||||||
{ return wxUString(s1) + s2; }
|
{ return wxUString(s1) + s2; }
|
||||||
inline wxUString operator+(const wxU32CharBuffer &s1, const wxUString &s2)
|
inline wxUString operator+(const wxScopedU32CharBuffer &s1, const wxUString &s2)
|
||||||
{ return wxUString(s1) + s2; }
|
{ return wxUString(s1) + s2; }
|
||||||
inline wxUString operator+(char s1, const wxUString &s2)
|
inline wxUString operator+(char s1, const wxUString &s2)
|
||||||
{ return wxUString(s1) + s2; }
|
{ return wxUString(s1) + s2; }
|
||||||
@@ -686,9 +690,9 @@ wxUSTRING_COMP_OPERATORS( const wxString & )
|
|||||||
wxUSTRING_COMP_OPERATORS( const char * )
|
wxUSTRING_COMP_OPERATORS( const char * )
|
||||||
wxUSTRING_COMP_OPERATORS( const wxChar16 * )
|
wxUSTRING_COMP_OPERATORS( const wxChar16 * )
|
||||||
wxUSTRING_COMP_OPERATORS( const wxChar32 * )
|
wxUSTRING_COMP_OPERATORS( const wxChar32 * )
|
||||||
wxUSTRING_COMP_OPERATORS( const wxCharBuffer & )
|
wxUSTRING_COMP_OPERATORS( const wxScopedCharBuffer & )
|
||||||
wxUSTRING_COMP_OPERATORS( const wxU16CharBuffer & )
|
wxUSTRING_COMP_OPERATORS( const wxScopedU16CharBuffer & )
|
||||||
wxUSTRING_COMP_OPERATORS( const wxU32CharBuffer & )
|
wxUSTRING_COMP_OPERATORS( const wxScopedU32CharBuffer & )
|
||||||
wxUSTRING_COMP_OPERATORS( const wxCStrData * )
|
wxUSTRING_COMP_OPERATORS( const wxCStrData * )
|
||||||
|
|
||||||
#endif // _WX_USTRING_H_
|
#endif // _WX_USTRING_H_
|
||||||
|
@@ -438,7 +438,7 @@ inline bool wxSetEnv(const wxString& var, const char *value)
|
|||||||
inline bool wxSetEnv(const wxString& var, const wchar_t *value)
|
inline bool wxSetEnv(const wxString& var, const wchar_t *value)
|
||||||
{ return wxSetEnv(var, wxString(value)); }
|
{ return wxSetEnv(var, wxString(value)); }
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline bool wxSetEnv(const wxString& var, const wxCharTypeBuffer<T>& value)
|
inline bool wxSetEnv(const wxString& var, const wxScopedCharTypeBuffer<T>& value)
|
||||||
{ return wxSetEnv(var, wxString(value)); }
|
{ return wxSetEnv(var, wxString(value)); }
|
||||||
inline bool wxSetEnv(const wxString& var, const wxCStrData& value)
|
inline bool wxSetEnv(const wxString& var, const wxCStrData& value)
|
||||||
{ return wxSetEnv(var, wxString(value)); }
|
{ return wxSetEnv(var, wxString(value)); }
|
||||||
|
@@ -210,8 +210,8 @@ public:
|
|||||||
wxVariant(const char* val, const wxString& name = wxEmptyString);
|
wxVariant(const char* val, const wxString& name = wxEmptyString);
|
||||||
wxVariant(const wchar_t* val, const wxString& name = wxEmptyString);
|
wxVariant(const wchar_t* val, const wxString& name = wxEmptyString);
|
||||||
wxVariant(const wxCStrData& val, const wxString& name = wxEmptyString);
|
wxVariant(const wxCStrData& val, const wxString& name = wxEmptyString);
|
||||||
wxVariant(const wxCharBuffer& val, const wxString& name = wxEmptyString);
|
wxVariant(const wxScopedCharBuffer& val, const wxString& name = wxEmptyString);
|
||||||
wxVariant(const wxWCharBuffer& val, const wxString& name = wxEmptyString);
|
wxVariant(const wxScopedWCharBuffer& val, const wxString& name = wxEmptyString);
|
||||||
|
|
||||||
bool operator== (const wxString& value) const;
|
bool operator== (const wxString& value) const;
|
||||||
bool operator!= (const wxString& value) const;
|
bool operator!= (const wxString& value) const;
|
||||||
@@ -225,7 +225,7 @@ public:
|
|||||||
wxVariant& operator=(const wxCStrData& value)
|
wxVariant& operator=(const wxCStrData& value)
|
||||||
{ return *this = value.AsString(); }
|
{ return *this = value.AsString(); }
|
||||||
template<typename T>
|
template<typename T>
|
||||||
wxVariant& operator=(const wxCharTypeBuffer<T>& value)
|
wxVariant& operator=(const wxScopedCharTypeBuffer<T>& value)
|
||||||
{ return *this = value.data(); }
|
{ return *this = value.data(); }
|
||||||
|
|
||||||
inline operator wxString () const { return MakeString(); }
|
inline operator wxString () const { return MakeString(); }
|
||||||
|
@@ -30,8 +30,8 @@
|
|||||||
/* checks whether the passed in pointer is NULL and if the string is empty */
|
/* checks whether the passed in pointer is NULL and if the string is empty */
|
||||||
inline bool wxIsEmpty(const char *s) { return !s || !*s; }
|
inline bool wxIsEmpty(const char *s) { return !s || !*s; }
|
||||||
inline bool wxIsEmpty(const wchar_t *s) { return !s || !*s; }
|
inline bool wxIsEmpty(const wchar_t *s) { return !s || !*s; }
|
||||||
inline bool wxIsEmpty(const wxCharBuffer& s) { return wxIsEmpty(s.data()); }
|
inline bool wxIsEmpty(const wxScopedCharBuffer& s) { return wxIsEmpty(s.data()); }
|
||||||
inline bool wxIsEmpty(const wxWCharBuffer& s) { return wxIsEmpty(s.data()); }
|
inline bool wxIsEmpty(const wxScopedWCharBuffer& s) { return wxIsEmpty(s.data()); }
|
||||||
inline bool wxIsEmpty(const wxString& s) { return s.empty(); }
|
inline bool wxIsEmpty(const wxString& s) { return s.empty(); }
|
||||||
inline bool wxIsEmpty(const wxCStrData& s) { return s.AsString().empty(); }
|
inline bool wxIsEmpty(const wxCStrData& s) { return s.AsString().empty(); }
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ inline char* wxTmemset(char* szOut, const char cIn, size_t len)
|
|||||||
// wxSetlocale(category, NULL) -- which is a common thing to do -- would be
|
// wxSetlocale(category, NULL) -- which is a common thing to do -- would be
|
||||||
// ambiguous
|
// ambiguous
|
||||||
WXDLLIMPEXP_BASE char* wxSetlocale(int category, const char *locale);
|
WXDLLIMPEXP_BASE char* wxSetlocale(int category, const char *locale);
|
||||||
inline char* wxSetlocale(int category, const wxCharBuffer& locale)
|
inline char* wxSetlocale(int category, const wxScopedCharBuffer& locale)
|
||||||
{ return wxSetlocale(category, locale.data()); }
|
{ return wxSetlocale(category, locale.data()); }
|
||||||
inline char* wxSetlocale(int category, const wxString& locale)
|
inline char* wxSetlocale(int category, const wxString& locale)
|
||||||
{ return wxSetlocale(category, locale.mb_str()); }
|
{ return wxSetlocale(category, locale.mb_str()); }
|
||||||
@@ -173,13 +173,13 @@ inline char* wxSetlocale(int category, const wxCStrData& locale)
|
|||||||
// NB: these are defined in wxcrtbase.h, see the comment there
|
// NB: these are defined in wxcrtbase.h, see the comment there
|
||||||
// inline size_t wxStrlen(const char *s) { return s ? strlen(s) : 0; }
|
// inline size_t wxStrlen(const char *s) { return s ? strlen(s) : 0; }
|
||||||
// inline size_t wxStrlen(const wchar_t *s) { return s ? wxCRT_Strlen_(s) : 0; }
|
// inline size_t wxStrlen(const wchar_t *s) { return s ? wxCRT_Strlen_(s) : 0; }
|
||||||
inline size_t wxStrlen(const wxCharBuffer& s) { return wxStrlen(s.data()); }
|
inline size_t wxStrlen(const wxScopedCharBuffer& s) { return wxStrlen(s.data()); }
|
||||||
inline size_t wxStrlen(const wxWCharBuffer& s) { return wxStrlen(s.data()); }
|
inline size_t wxStrlen(const wxScopedWCharBuffer& s) { return wxStrlen(s.data()); }
|
||||||
inline size_t wxStrlen(const wxString& s) { return s.length(); }
|
inline size_t wxStrlen(const wxString& s) { return s.length(); }
|
||||||
inline size_t wxStrlen(const wxCStrData& s) { return s.AsString().length(); }
|
inline size_t wxStrlen(const wxCStrData& s) { return s.AsString().length(); }
|
||||||
|
|
||||||
// this is a function new in 2.9 so we don't care about backwards compatibility and
|
// this is a function new in 2.9 so we don't care about backwards compatibility and
|
||||||
// so don't need to support wxCharBuffer/wxWCharBuffer overloads
|
// so don't need to support wxScopedCharBuffer/wxScopedWCharBuffer overloads
|
||||||
#if defined(wxCRT_StrnlenA)
|
#if defined(wxCRT_StrnlenA)
|
||||||
inline size_t wxStrnlen(const char *str, size_t maxlen) { return wxCRT_StrnlenA(str, maxlen); }
|
inline size_t wxStrnlen(const char *str, size_t maxlen) { return wxCRT_StrnlenA(str, maxlen); }
|
||||||
#else
|
#else
|
||||||
@@ -211,8 +211,8 @@ inline size_t wxStrnlen(const wchar_t *str, size_t maxlen)
|
|||||||
// NB: these are defined in wxcrtbase.h, see the comment there
|
// NB: these are defined in wxcrtbase.h, see the comment there
|
||||||
// inline char* wxStrdup(const char *s) { return wxStrdupA(s); }
|
// inline char* wxStrdup(const char *s) { return wxStrdupA(s); }
|
||||||
// inline wchar_t* wxStrdup(const wchar_t *s) { return wxStrdupW(s); }
|
// inline wchar_t* wxStrdup(const wchar_t *s) { return wxStrdupW(s); }
|
||||||
inline char* wxStrdup(const wxCharBuffer& s) { return wxStrdup(s.data()); }
|
inline char* wxStrdup(const wxScopedCharBuffer& s) { return wxStrdup(s.data()); }
|
||||||
inline wchar_t* wxStrdup(const wxWCharBuffer& s) { return wxStrdup(s.data()); }
|
inline wchar_t* wxStrdup(const wxScopedWCharBuffer& s) { return wxStrdup(s.data()); }
|
||||||
inline char* wxStrdup(const wxString& s) { return wxStrdup(s.mb_str()); }
|
inline char* wxStrdup(const wxString& s) { return wxStrdup(s.mb_str()); }
|
||||||
inline char* wxStrdup(const wxCStrData& s) { return wxStrdup(s.AsCharBuf()); }
|
inline char* wxStrdup(const wxCStrData& s) { return wxStrdup(s.AsCharBuf()); }
|
||||||
|
|
||||||
@@ -224,13 +224,13 @@ inline char *wxStrcpy(char *dest, const wxString& src)
|
|||||||
{ return wxCRT_StrcpyA(dest, src.mb_str()); }
|
{ return wxCRT_StrcpyA(dest, src.mb_str()); }
|
||||||
inline char *wxStrcpy(char *dest, const wxCStrData& src)
|
inline char *wxStrcpy(char *dest, const wxCStrData& src)
|
||||||
{ return wxCRT_StrcpyA(dest, src.AsCharBuf()); }
|
{ return wxCRT_StrcpyA(dest, src.AsCharBuf()); }
|
||||||
inline char *wxStrcpy(char *dest, const wxCharBuffer& src)
|
inline char *wxStrcpy(char *dest, const wxScopedCharBuffer& src)
|
||||||
{ return wxCRT_StrcpyA(dest, src.data()); }
|
{ return wxCRT_StrcpyA(dest, src.data()); }
|
||||||
inline wchar_t *wxStrcpy(wchar_t *dest, const wxString& src)
|
inline wchar_t *wxStrcpy(wchar_t *dest, const wxString& src)
|
||||||
{ return wxCRT_StrcpyW(dest, src.wc_str()); }
|
{ return wxCRT_StrcpyW(dest, src.wc_str()); }
|
||||||
inline wchar_t *wxStrcpy(wchar_t *dest, const wxCStrData& src)
|
inline wchar_t *wxStrcpy(wchar_t *dest, const wxCStrData& src)
|
||||||
{ return wxCRT_StrcpyW(dest, src.AsWCharBuf()); }
|
{ return wxCRT_StrcpyW(dest, src.AsWCharBuf()); }
|
||||||
inline wchar_t *wxStrcpy(wchar_t *dest, const wxWCharBuffer& src)
|
inline wchar_t *wxStrcpy(wchar_t *dest, const wxScopedWCharBuffer& src)
|
||||||
{ return wxCRT_StrcpyW(dest, src.data()); }
|
{ return wxCRT_StrcpyW(dest, src.data()); }
|
||||||
inline char *wxStrcpy(char *dest, const wchar_t *src)
|
inline char *wxStrcpy(char *dest, const wchar_t *src)
|
||||||
{ return wxCRT_StrcpyA(dest, wxConvLibc.cWC2MB(src)); }
|
{ return wxCRT_StrcpyA(dest, wxConvLibc.cWC2MB(src)); }
|
||||||
@@ -245,13 +245,13 @@ inline char *wxStrncpy(char *dest, const wxString& src, size_t n)
|
|||||||
{ return wxCRT_StrncpyA(dest, src.mb_str(), n); }
|
{ return wxCRT_StrncpyA(dest, src.mb_str(), n); }
|
||||||
inline char *wxStrncpy(char *dest, const wxCStrData& src, size_t n)
|
inline char *wxStrncpy(char *dest, const wxCStrData& src, size_t n)
|
||||||
{ return wxCRT_StrncpyA(dest, src.AsCharBuf(), n); }
|
{ return wxCRT_StrncpyA(dest, src.AsCharBuf(), n); }
|
||||||
inline char *wxStrncpy(char *dest, const wxCharBuffer& src, size_t n)
|
inline char *wxStrncpy(char *dest, const wxScopedCharBuffer& src, size_t n)
|
||||||
{ return wxCRT_StrncpyA(dest, src.data(), n); }
|
{ return wxCRT_StrncpyA(dest, src.data(), n); }
|
||||||
inline wchar_t *wxStrncpy(wchar_t *dest, const wxString& src, size_t n)
|
inline wchar_t *wxStrncpy(wchar_t *dest, const wxString& src, size_t n)
|
||||||
{ return wxCRT_StrncpyW(dest, src.wc_str(), n); }
|
{ return wxCRT_StrncpyW(dest, src.wc_str(), n); }
|
||||||
inline wchar_t *wxStrncpy(wchar_t *dest, const wxCStrData& src, size_t n)
|
inline wchar_t *wxStrncpy(wchar_t *dest, const wxCStrData& src, size_t n)
|
||||||
{ return wxCRT_StrncpyW(dest, src.AsWCharBuf(), n); }
|
{ return wxCRT_StrncpyW(dest, src.AsWCharBuf(), n); }
|
||||||
inline wchar_t *wxStrncpy(wchar_t *dest, const wxWCharBuffer& src, size_t n)
|
inline wchar_t *wxStrncpy(wchar_t *dest, const wxScopedWCharBuffer& src, size_t n)
|
||||||
{ return wxCRT_StrncpyW(dest, src.data(), n); }
|
{ return wxCRT_StrncpyW(dest, src.data(), n); }
|
||||||
inline char *wxStrncpy(char *dest, const wchar_t *src, size_t n)
|
inline char *wxStrncpy(char *dest, const wchar_t *src, size_t n)
|
||||||
{ return wxCRT_StrncpyA(dest, wxConvLibc.cWC2MB(src), n); }
|
{ return wxCRT_StrncpyA(dest, wxConvLibc.cWC2MB(src), n); }
|
||||||
@@ -296,13 +296,13 @@ inline char *wxStrcat(char *dest, const wxString& src)
|
|||||||
{ return wxCRT_StrcatA(dest, src.mb_str()); }
|
{ return wxCRT_StrcatA(dest, src.mb_str()); }
|
||||||
inline char *wxStrcat(char *dest, const wxCStrData& src)
|
inline char *wxStrcat(char *dest, const wxCStrData& src)
|
||||||
{ return wxCRT_StrcatA(dest, src.AsCharBuf()); }
|
{ return wxCRT_StrcatA(dest, src.AsCharBuf()); }
|
||||||
inline char *wxStrcat(char *dest, const wxCharBuffer& src)
|
inline char *wxStrcat(char *dest, const wxScopedCharBuffer& src)
|
||||||
{ return wxCRT_StrcatA(dest, src.data()); }
|
{ return wxCRT_StrcatA(dest, src.data()); }
|
||||||
inline wchar_t *wxStrcat(wchar_t *dest, const wxString& src)
|
inline wchar_t *wxStrcat(wchar_t *dest, const wxString& src)
|
||||||
{ return wxCRT_StrcatW(dest, src.wc_str()); }
|
{ return wxCRT_StrcatW(dest, src.wc_str()); }
|
||||||
inline wchar_t *wxStrcat(wchar_t *dest, const wxCStrData& src)
|
inline wchar_t *wxStrcat(wchar_t *dest, const wxCStrData& src)
|
||||||
{ return wxCRT_StrcatW(dest, src.AsWCharBuf()); }
|
{ return wxCRT_StrcatW(dest, src.AsWCharBuf()); }
|
||||||
inline wchar_t *wxStrcat(wchar_t *dest, const wxWCharBuffer& src)
|
inline wchar_t *wxStrcat(wchar_t *dest, const wxScopedWCharBuffer& src)
|
||||||
{ return wxCRT_StrcatW(dest, src.data()); }
|
{ return wxCRT_StrcatW(dest, src.data()); }
|
||||||
inline char *wxStrcat(char *dest, const wchar_t *src)
|
inline char *wxStrcat(char *dest, const wchar_t *src)
|
||||||
{ return wxCRT_StrcatA(dest, wxConvLibc.cWC2MB(src)); }
|
{ return wxCRT_StrcatA(dest, wxConvLibc.cWC2MB(src)); }
|
||||||
@@ -317,13 +317,13 @@ inline char *wxStrncat(char *dest, const wxString& src, size_t n)
|
|||||||
{ return wxCRT_StrncatA(dest, src.mb_str(), n); }
|
{ return wxCRT_StrncatA(dest, src.mb_str(), n); }
|
||||||
inline char *wxStrncat(char *dest, const wxCStrData& src, size_t n)
|
inline char *wxStrncat(char *dest, const wxCStrData& src, size_t n)
|
||||||
{ return wxCRT_StrncatA(dest, src.AsCharBuf(), n); }
|
{ return wxCRT_StrncatA(dest, src.AsCharBuf(), n); }
|
||||||
inline char *wxStrncat(char *dest, const wxCharBuffer& src, size_t n)
|
inline char *wxStrncat(char *dest, const wxScopedCharBuffer& src, size_t n)
|
||||||
{ return wxCRT_StrncatA(dest, src.data(), n); }
|
{ return wxCRT_StrncatA(dest, src.data(), n); }
|
||||||
inline wchar_t *wxStrncat(wchar_t *dest, const wxString& src, size_t n)
|
inline wchar_t *wxStrncat(wchar_t *dest, const wxString& src, size_t n)
|
||||||
{ return wxCRT_StrncatW(dest, src.wc_str(), n); }
|
{ return wxCRT_StrncatW(dest, src.wc_str(), n); }
|
||||||
inline wchar_t *wxStrncat(wchar_t *dest, const wxCStrData& src, size_t n)
|
inline wchar_t *wxStrncat(wchar_t *dest, const wxCStrData& src, size_t n)
|
||||||
{ return wxCRT_StrncatW(dest, src.AsWCharBuf(), n); }
|
{ return wxCRT_StrncatW(dest, src.AsWCharBuf(), n); }
|
||||||
inline wchar_t *wxStrncat(wchar_t *dest, const wxWCharBuffer& src, size_t n)
|
inline wchar_t *wxStrncat(wchar_t *dest, const wxScopedWCharBuffer& src, size_t n)
|
||||||
{ return wxCRT_StrncatW(dest, src.data(), n); }
|
{ return wxCRT_StrncatW(dest, src.data(), n); }
|
||||||
inline char *wxStrncat(char *dest, const wchar_t *src, size_t n)
|
inline char *wxStrncat(char *dest, const wchar_t *src, size_t n)
|
||||||
{ return wxCRT_StrncatA(dest, wxConvLibc.cWC2MB(src), n); }
|
{ return wxCRT_StrncatA(dest, wxConvLibc.cWC2MB(src), n); }
|
||||||
@@ -349,45 +349,45 @@ inline wchar_t *wxStrncat(wchar_t *dest, const char *src, size_t n)
|
|||||||
{ return WX_STR_CALL(crtA, s1, s2); } \
|
{ return WX_STR_CALL(crtA, s1, s2); } \
|
||||||
inline rettype WX_STR_DECL(name, const char *, const wchar_t *) \
|
inline rettype WX_STR_DECL(name, const char *, const wchar_t *) \
|
||||||
{ return WX_STR_CALL(forString, wxString(s1), wxString(s2)); } \
|
{ return WX_STR_CALL(forString, wxString(s1), wxString(s2)); } \
|
||||||
inline rettype WX_STR_DECL(name, const char *, const wxCharBuffer&) \
|
inline rettype WX_STR_DECL(name, const char *, const wxScopedCharBuffer&) \
|
||||||
{ return WX_STR_CALL(crtA, s1, s2.data()); } \
|
{ return WX_STR_CALL(crtA, s1, s2.data()); } \
|
||||||
inline rettype WX_STR_DECL(name, const char *, const wxWCharBuffer&) \
|
inline rettype WX_STR_DECL(name, const char *, const wxScopedWCharBuffer&) \
|
||||||
{ return WX_STR_CALL(forString, wxString(s1), s2.data()); } \
|
{ return WX_STR_CALL(forString, wxString(s1), s2.data()); } \
|
||||||
\
|
\
|
||||||
inline rettype WX_STR_DECL(name, const wchar_t *, const wchar_t *) \
|
inline rettype WX_STR_DECL(name, const wchar_t *, const wchar_t *) \
|
||||||
{ return WX_STR_CALL(crtW, s1, s2); } \
|
{ return WX_STR_CALL(crtW, s1, s2); } \
|
||||||
inline rettype WX_STR_DECL(name, const wchar_t *, const char *) \
|
inline rettype WX_STR_DECL(name, const wchar_t *, const char *) \
|
||||||
{ return WX_STR_CALL(forString, wxString(s1), wxString(s2)); } \
|
{ return WX_STR_CALL(forString, wxString(s1), wxString(s2)); } \
|
||||||
inline rettype WX_STR_DECL(name, const wchar_t *, const wxWCharBuffer&) \
|
inline rettype WX_STR_DECL(name, const wchar_t *, const wxScopedWCharBuffer&) \
|
||||||
{ return WX_STR_CALL(crtW, s1, s2.data()); } \
|
{ return WX_STR_CALL(crtW, s1, s2.data()); } \
|
||||||
inline rettype WX_STR_DECL(name, const wchar_t *, const wxCharBuffer&) \
|
inline rettype WX_STR_DECL(name, const wchar_t *, const wxScopedCharBuffer&) \
|
||||||
{ return WX_STR_CALL(forString, wxString(s1), s2.data()); } \
|
{ return WX_STR_CALL(forString, wxString(s1), s2.data()); } \
|
||||||
\
|
\
|
||||||
inline rettype WX_STR_DECL(name, const wxCharBuffer&, const char *) \
|
inline rettype WX_STR_DECL(name, const wxScopedCharBuffer&, const char *) \
|
||||||
{ return WX_STR_CALL(crtA, s1.data(), s2); } \
|
{ return WX_STR_CALL(crtA, s1.data(), s2); } \
|
||||||
inline rettype WX_STR_DECL(name, const wxCharBuffer&, const wchar_t *) \
|
inline rettype WX_STR_DECL(name, const wxScopedCharBuffer&, const wchar_t *) \
|
||||||
{ return WX_STR_CALL(forString, wxString(s1), wxString(s2)); } \
|
{ return WX_STR_CALL(forString, wxString(s1), wxString(s2)); } \
|
||||||
inline rettype WX_STR_DECL(name, const wxCharBuffer&, const wxCharBuffer&)\
|
inline rettype WX_STR_DECL(name, const wxScopedCharBuffer&, const wxScopedCharBuffer&)\
|
||||||
{ return WX_STR_CALL(crtA, s1.data(), s2.data()); } \
|
{ return WX_STR_CALL(crtA, s1.data(), s2.data()); } \
|
||||||
inline rettype WX_STR_DECL(name, const wxCharBuffer&, const wxWCharBuffer&) \
|
inline rettype WX_STR_DECL(name, const wxScopedCharBuffer&, const wxScopedWCharBuffer&) \
|
||||||
{ return WX_STR_CALL(forString, wxString(s1), wxString(s2)); } \
|
{ return WX_STR_CALL(forString, wxString(s1), wxString(s2)); } \
|
||||||
\
|
\
|
||||||
inline rettype WX_STR_DECL(name, const wxWCharBuffer&, const wchar_t *) \
|
inline rettype WX_STR_DECL(name, const wxScopedWCharBuffer&, const wchar_t *) \
|
||||||
{ return WX_STR_CALL(crtW, s1.data(), s2); } \
|
{ return WX_STR_CALL(crtW, s1.data(), s2); } \
|
||||||
inline rettype WX_STR_DECL(name, const wxWCharBuffer&, const char *) \
|
inline rettype WX_STR_DECL(name, const wxScopedWCharBuffer&, const char *) \
|
||||||
{ return WX_STR_CALL(forString, wxString(s1), wxString(s2)); } \
|
{ return WX_STR_CALL(forString, wxString(s1), wxString(s2)); } \
|
||||||
inline rettype WX_STR_DECL(name, const wxWCharBuffer&, const wxWCharBuffer&) \
|
inline rettype WX_STR_DECL(name, const wxScopedWCharBuffer&, const wxScopedWCharBuffer&) \
|
||||||
{ return WX_STR_CALL(crtW, s1.data(), s2.data()); } \
|
{ return WX_STR_CALL(crtW, s1.data(), s2.data()); } \
|
||||||
inline rettype WX_STR_DECL(name, const wxWCharBuffer&, const wxCharBuffer&) \
|
inline rettype WX_STR_DECL(name, const wxScopedWCharBuffer&, const wxScopedCharBuffer&) \
|
||||||
{ return WX_STR_CALL(forString, wxString(s1), wxString(s2)); } \
|
{ return WX_STR_CALL(forString, wxString(s1), wxString(s2)); } \
|
||||||
\
|
\
|
||||||
inline rettype WX_STR_DECL(name, const wxString&, const char*) \
|
inline rettype WX_STR_DECL(name, const wxString&, const char*) \
|
||||||
{ return WX_STR_CALL(forString, s1, s2); } \
|
{ return WX_STR_CALL(forString, s1, s2); } \
|
||||||
inline rettype WX_STR_DECL(name, const wxString&, const wchar_t*) \
|
inline rettype WX_STR_DECL(name, const wxString&, const wchar_t*) \
|
||||||
{ return WX_STR_CALL(forString, s1, s2); } \
|
{ return WX_STR_CALL(forString, s1, s2); } \
|
||||||
inline rettype WX_STR_DECL(name, const wxString&, const wxCharBuffer&) \
|
inline rettype WX_STR_DECL(name, const wxString&, const wxScopedCharBuffer&) \
|
||||||
{ return WX_STR_CALL(forString, s1, s2); } \
|
{ return WX_STR_CALL(forString, s1, s2); } \
|
||||||
inline rettype WX_STR_DECL(name, const wxString&, const wxWCharBuffer&) \
|
inline rettype WX_STR_DECL(name, const wxString&, const wxScopedWCharBuffer&) \
|
||||||
{ return WX_STR_CALL(forString, s1, s2); } \
|
{ return WX_STR_CALL(forString, s1, s2); } \
|
||||||
inline rettype WX_STR_DECL(name, const wxString&, const wxString&) \
|
inline rettype WX_STR_DECL(name, const wxString&, const wxString&) \
|
||||||
{ return WX_STR_CALL(forString, s1, s2); } \
|
{ return WX_STR_CALL(forString, s1, s2); } \
|
||||||
@@ -398,9 +398,9 @@ inline wchar_t *wxStrncat(wchar_t *dest, const char *src, size_t n)
|
|||||||
{ return WX_STR_CALL(forString, s1.AsString(), s2); } \
|
{ return WX_STR_CALL(forString, s1.AsString(), s2); } \
|
||||||
inline rettype WX_STR_DECL(name, const wxCStrData&, const wchar_t*) \
|
inline rettype WX_STR_DECL(name, const wxCStrData&, const wchar_t*) \
|
||||||
{ return WX_STR_CALL(forString, s1.AsString(), s2); } \
|
{ return WX_STR_CALL(forString, s1.AsString(), s2); } \
|
||||||
inline rettype WX_STR_DECL(name, const wxCStrData&, const wxCharBuffer&) \
|
inline rettype WX_STR_DECL(name, const wxCStrData&, const wxScopedCharBuffer&) \
|
||||||
{ return WX_STR_CALL(forString, s1.AsString(), s2); } \
|
{ return WX_STR_CALL(forString, s1.AsString(), s2); } \
|
||||||
inline rettype WX_STR_DECL(name, const wxCStrData&, const wxWCharBuffer&) \
|
inline rettype WX_STR_DECL(name, const wxCStrData&, const wxScopedWCharBuffer&) \
|
||||||
{ return WX_STR_CALL(forString, s1.AsString(), s2); } \
|
{ return WX_STR_CALL(forString, s1.AsString(), s2); } \
|
||||||
inline rettype WX_STR_DECL(name, const wxCStrData&, const wxString&) \
|
inline rettype WX_STR_DECL(name, const wxCStrData&, const wxString&) \
|
||||||
{ return WX_STR_CALL(forString, s1.AsString(), s2); } \
|
{ return WX_STR_CALL(forString, s1.AsString(), s2); } \
|
||||||
@@ -422,14 +422,14 @@ inline wchar_t *wxStrncat(wchar_t *dest, const char *src, size_t n)
|
|||||||
inline int WX_STR_DECL(name, const wchar_t *, const wxString&) \
|
inline int WX_STR_DECL(name, const wchar_t *, const wxString&) \
|
||||||
{ return -WX_STR_CALL(forString, s2, s1); } \
|
{ return -WX_STR_CALL(forString, s2, s1); } \
|
||||||
\
|
\
|
||||||
inline int WX_STR_DECL(name, const wxCharBuffer&, const wxCStrData&) \
|
inline int WX_STR_DECL(name, const wxScopedCharBuffer&, const wxCStrData&) \
|
||||||
{ return -WX_STR_CALL(forString, s2.AsString(), s1.data()); } \
|
{ return -WX_STR_CALL(forString, s2.AsString(), s1.data()); } \
|
||||||
inline int WX_STR_DECL(name, const wxCharBuffer&, const wxString&) \
|
inline int WX_STR_DECL(name, const wxScopedCharBuffer&, const wxString&) \
|
||||||
{ return -WX_STR_CALL(forString, s2, s1.data()); } \
|
{ return -WX_STR_CALL(forString, s2, s1.data()); } \
|
||||||
\
|
\
|
||||||
inline int WX_STR_DECL(name, const wxWCharBuffer&, const wxCStrData&) \
|
inline int WX_STR_DECL(name, const wxScopedWCharBuffer&, const wxCStrData&) \
|
||||||
{ return -WX_STR_CALL(forString, s2.AsString(), s1.data()); } \
|
{ return -WX_STR_CALL(forString, s2.AsString(), s1.data()); } \
|
||||||
inline int WX_STR_DECL(name, const wxWCharBuffer&, const wxString&) \
|
inline int WX_STR_DECL(name, const wxScopedWCharBuffer&, const wxString&) \
|
||||||
{ return -WX_STR_CALL(forString, s2, s1.data()); }
|
{ return -WX_STR_CALL(forString, s2, s1.data()); }
|
||||||
|
|
||||||
|
|
||||||
@@ -449,14 +449,14 @@ inline wchar_t *wxStrncat(wchar_t *dest, const char *src, size_t n)
|
|||||||
inline rettype WX_STR_DECL(name, const wchar_t *, const wxString&) \
|
inline rettype WX_STR_DECL(name, const wchar_t *, const wxString&) \
|
||||||
{ return WX_STR_CALL(crtW, s1, s2.wc_str()); } \
|
{ return WX_STR_CALL(crtW, s1, s2.wc_str()); } \
|
||||||
\
|
\
|
||||||
inline rettype WX_STR_DECL(name, const wxCharBuffer&, const wxCStrData&) \
|
inline rettype WX_STR_DECL(name, const wxScopedCharBuffer&, const wxCStrData&) \
|
||||||
{ return WX_STR_CALL(crtA, s1.data(), s2.AsCharBuf()); } \
|
{ return WX_STR_CALL(crtA, s1.data(), s2.AsCharBuf()); } \
|
||||||
inline rettype WX_STR_DECL(name, const wxCharBuffer&, const wxString&) \
|
inline rettype WX_STR_DECL(name, const wxScopedCharBuffer&, const wxString&) \
|
||||||
{ return WX_STR_CALL(crtA, s1.data(), s2.mb_str()); } \
|
{ return WX_STR_CALL(crtA, s1.data(), s2.mb_str()); } \
|
||||||
\
|
\
|
||||||
inline rettype WX_STR_DECL(name, const wxWCharBuffer&, const wxCStrData&) \
|
inline rettype WX_STR_DECL(name, const wxScopedWCharBuffer&, const wxCStrData&) \
|
||||||
{ return WX_STR_CALL(crtW, s1.data(), s2.AsWCharBuf()); } \
|
{ return WX_STR_CALL(crtW, s1.data(), s2.AsWCharBuf()); } \
|
||||||
inline rettype WX_STR_DECL(name, const wxWCharBuffer&, const wxString&) \
|
inline rettype WX_STR_DECL(name, const wxScopedWCharBuffer&, const wxString&) \
|
||||||
{ return WX_STR_CALL(crtW, s1.data(), s2.wc_str()); }
|
{ return WX_STR_CALL(crtW, s1.data(), s2.wc_str()); }
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@@ -490,7 +490,7 @@ inline int wxStrcoll_String(const wxString& s1, const T& s2)
|
|||||||
// NB: strcoll() doesn't work correctly on UTF-8 strings, so we have to use
|
// NB: strcoll() doesn't work correctly on UTF-8 strings, so we have to use
|
||||||
// wc_str() even if wxUSE_UNICODE_UTF8; the (const wchar_t*) cast is
|
// wc_str() even if wxUSE_UNICODE_UTF8; the (const wchar_t*) cast is
|
||||||
// there just as optimization to avoid going through
|
// there just as optimization to avoid going through
|
||||||
// wxStrcoll<wxWCharBuffer>:
|
// wxStrcoll<wxScopedWCharBuffer>:
|
||||||
return wxStrcoll((const wchar_t*)s1.wc_str(), s2);
|
return wxStrcoll((const wchar_t*)s1.wc_str(), s2);
|
||||||
#else
|
#else
|
||||||
return wxStrcoll((const char*)s1.mb_str(), s2);
|
return wxStrcoll((const char*)s1.mb_str(), s2);
|
||||||
@@ -548,7 +548,7 @@ inline size_t wxStrxfrm(char *dest, const char *src, size_t n)
|
|||||||
inline size_t wxStrxfrm(wchar_t *dest, const wchar_t *src, size_t n)
|
inline size_t wxStrxfrm(wchar_t *dest, const wchar_t *src, size_t n)
|
||||||
{ return wxCRT_StrxfrmW(dest, src, n); }
|
{ return wxCRT_StrxfrmW(dest, src, n); }
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline size_t wxStrxfrm(T *dest, const wxCharTypeBuffer<T>& src, size_t n)
|
inline size_t wxStrxfrm(T *dest, const wxScopedCharTypeBuffer<T>& src, size_t n)
|
||||||
{ return wxStrxfrm(dest, src.data(), n); }
|
{ return wxStrxfrm(dest, src.data(), n); }
|
||||||
inline size_t wxStrxfrm(char *dest, const wxString& src, size_t n)
|
inline size_t wxStrxfrm(char *dest, const wxString& src, size_t n)
|
||||||
{ return wxCRT_StrxfrmA(dest, src.mb_str(), n); }
|
{ return wxCRT_StrxfrmA(dest, src.mb_str(), n); }
|
||||||
@@ -566,7 +566,7 @@ inline char *wxStrtok(char *str, const char *delim, char **saveptr)
|
|||||||
inline wchar_t *wxStrtok(wchar_t *str, const wchar_t *delim, wchar_t **saveptr)
|
inline wchar_t *wxStrtok(wchar_t *str, const wchar_t *delim, wchar_t **saveptr)
|
||||||
{ return wxCRT_StrtokW(str, delim, saveptr); }
|
{ return wxCRT_StrtokW(str, delim, saveptr); }
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T *wxStrtok(T *str, const wxCharTypeBuffer<T>& delim, T **saveptr)
|
inline T *wxStrtok(T *str, const wxScopedCharTypeBuffer<T>& delim, T **saveptr)
|
||||||
{ return wxStrtok(str, delim.data(), saveptr); }
|
{ return wxStrtok(str, delim.data(), saveptr); }
|
||||||
inline char *wxStrtok(char *str, const wxCStrData& delim, char **saveptr)
|
inline char *wxStrtok(char *str, const wxCStrData& delim, char **saveptr)
|
||||||
{ return wxCRT_StrtokA(str, delim.AsCharBuf(), saveptr); }
|
{ return wxCRT_StrtokA(str, delim.AsCharBuf(), saveptr); }
|
||||||
@@ -628,22 +628,22 @@ inline const char *wxStrrchr(const char *s, const wxUniCharRef& c)
|
|||||||
inline const wchar_t *wxStrrchr(const wchar_t *s, const wxUniCharRef& c)
|
inline const wchar_t *wxStrrchr(const wchar_t *s, const wxUniCharRef& c)
|
||||||
{ return wxCRT_StrrchrW(s, (wchar_t)c); }
|
{ return wxCRT_StrrchrW(s, (wchar_t)c); }
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline const T* wxStrchr(const wxCharTypeBuffer<T>& s, T c)
|
inline const T* wxStrchr(const wxScopedCharTypeBuffer<T>& s, T c)
|
||||||
{ return wxStrchr(s.data(), c); }
|
{ return wxStrchr(s.data(), c); }
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline const T* wxStrrchr(const wxCharTypeBuffer<T>& s, T c)
|
inline const T* wxStrrchr(const wxScopedCharTypeBuffer<T>& s, T c)
|
||||||
{ return wxStrrchr(s.data(), c); }
|
{ return wxStrrchr(s.data(), c); }
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline const T* wxStrchr(const wxCharTypeBuffer<T>& s, const wxUniChar& c)
|
inline const T* wxStrchr(const wxScopedCharTypeBuffer<T>& s, const wxUniChar& c)
|
||||||
{ return wxStrchr(s.data(), (T)c); }
|
{ return wxStrchr(s.data(), (T)c); }
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline const T* wxStrrchr(const wxCharTypeBuffer<T>& s, const wxUniChar& c)
|
inline const T* wxStrrchr(const wxScopedCharTypeBuffer<T>& s, const wxUniChar& c)
|
||||||
{ return wxStrrchr(s.data(), (T)c); }
|
{ return wxStrrchr(s.data(), (T)c); }
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline const T* wxStrchr(const wxCharTypeBuffer<T>& s, const wxUniCharRef& c)
|
inline const T* wxStrchr(const wxScopedCharTypeBuffer<T>& s, const wxUniCharRef& c)
|
||||||
{ return wxStrchr(s.data(), (T)c); }
|
{ return wxStrchr(s.data(), (T)c); }
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline const T* wxStrrchr(const wxCharTypeBuffer<T>& s, const wxUniCharRef& c)
|
inline const T* wxStrrchr(const wxScopedCharTypeBuffer<T>& s, const wxUniCharRef& c)
|
||||||
{ return wxStrrchr(s.data(), (T)c); }
|
{ return wxStrrchr(s.data(), (T)c); }
|
||||||
// these functions return char* pointer into the non-temporary conversion buffer
|
// these functions return char* pointer into the non-temporary conversion buffer
|
||||||
// used by c_str()'s implicit conversion to char*, for ANSI build compatibility
|
// used by c_str()'s implicit conversion to char*, for ANSI build compatibility
|
||||||
@@ -717,7 +717,7 @@ inline const wchar_t *wxStrpbrk(const wxCStrData& s, const wchar_t *accept)
|
|||||||
inline const char *wxStrpbrk(const wxCStrData& s, const wxCStrData& accept)
|
inline const char *wxStrpbrk(const wxCStrData& s, const wxCStrData& accept)
|
||||||
{ return wxCRT_StrpbrkA(s.AsChar(), accept.AsCharBuf()); }
|
{ return wxCRT_StrpbrkA(s.AsChar(), accept.AsCharBuf()); }
|
||||||
template <typename S, typename T>
|
template <typename S, typename T>
|
||||||
inline const T *wxStrpbrk(const S& s, const wxCharTypeBuffer<T>& accept)
|
inline const T *wxStrpbrk(const S& s, const wxScopedCharTypeBuffer<T>& accept)
|
||||||
{ return wxStrpbrk(s, accept.data()); }
|
{ return wxStrpbrk(s, accept.data()); }
|
||||||
|
|
||||||
|
|
||||||
@@ -820,7 +820,7 @@ inline double wxStrtod(const char *nptr, char **endptr)
|
|||||||
inline double wxStrtod(const wchar_t *nptr, wchar_t **endptr)
|
inline double wxStrtod(const wchar_t *nptr, wchar_t **endptr)
|
||||||
{ return wxCRT_StrtodW(nptr, endptr); }
|
{ return wxCRT_StrtodW(nptr, endptr); }
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline double wxStrtod(const wxCharTypeBuffer<T>& nptr, T **endptr)
|
inline double wxStrtod(const wxScopedCharTypeBuffer<T>& nptr, T **endptr)
|
||||||
{ return wxStrtod(nptr.data(), endptr); }
|
{ return wxStrtod(nptr.data(), endptr); }
|
||||||
|
|
||||||
// We implement wxStrto*() like this so that the code compiles when NULL is
|
// We implement wxStrto*() like this so that the code compiles when NULL is
|
||||||
@@ -884,7 +884,7 @@ inline double wxStrtod(const wxCStrData& nptr, T endptr)
|
|||||||
inline rettype name(const wchar_t *nptr, wchar_t **endptr, int base) \
|
inline rettype name(const wchar_t *nptr, wchar_t **endptr, int base) \
|
||||||
{ return implW(nptr, endptr, base); } \
|
{ return implW(nptr, endptr, base); } \
|
||||||
template<typename T> \
|
template<typename T> \
|
||||||
inline rettype name(const wxCharTypeBuffer<T>& nptr, T **endptr, int base)\
|
inline rettype name(const wxScopedCharTypeBuffer<T>& nptr, T **endptr, int base)\
|
||||||
{ return name(nptr.data(), endptr); } \
|
{ return name(nptr.data(), endptr); } \
|
||||||
template<typename T> \
|
template<typename T> \
|
||||||
inline rettype name(const wxString& nptr, T endptr, int base) \
|
inline rettype name(const wxString& nptr, T endptr, int base) \
|
||||||
@@ -930,8 +930,8 @@ inline char* wxGetenv(const char *name) { return wxCRT_GetenvA(name); }
|
|||||||
inline wchar_t* wxGetenv(const wchar_t *name) { return wxCRT_GetenvW(name); }
|
inline wchar_t* wxGetenv(const wchar_t *name) { return wxCRT_GetenvW(name); }
|
||||||
inline char* wxGetenv(const wxString& name) { return wxCRT_GetenvA(name.mb_str()); }
|
inline char* wxGetenv(const wxString& name) { return wxCRT_GetenvA(name.mb_str()); }
|
||||||
inline char* wxGetenv(const wxCStrData& name) { return wxCRT_GetenvA(name.AsCharBuf()); }
|
inline char* wxGetenv(const wxCStrData& name) { return wxCRT_GetenvA(name.AsCharBuf()); }
|
||||||
inline char* wxGetenv(const wxCharBuffer& name) { return wxCRT_GetenvA(name.data()); }
|
inline char* wxGetenv(const wxScopedCharBuffer& name) { return wxCRT_GetenvA(name.data()); }
|
||||||
inline wchar_t* wxGetenv(const wxWCharBuffer& name) { return wxCRT_GetenvW(name.data()); }
|
inline wchar_t* wxGetenv(const wxScopedWCharBuffer& name) { return wxCRT_GetenvW(name.data()); }
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// time.h functions
|
// time.h functions
|
||||||
|
@@ -445,7 +445,7 @@ wxVsnprintf(wchar_t *str, size_t size, const wxString& format, va_list argptr);
|
|||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
#define wxScanfConvertFormatW(fmt) fmt
|
#define wxScanfConvertFormatW(fmt) fmt
|
||||||
#else
|
#else
|
||||||
const wxWCharBuffer
|
const wxScopedWCharBuffer
|
||||||
WXDLLIMPEXP_BASE wxScanfConvertFormatW(const wchar_t *format);
|
WXDLLIMPEXP_BASE wxScanfConvertFormatW(const wchar_t *format);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -463,9 +463,9 @@ WX_DEFINE_SCANFUNC(wxSscanf, 2, (const char *str, const char *format),
|
|||||||
wxCRT_SscanfA, (str, format))
|
wxCRT_SscanfA, (str, format))
|
||||||
WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wchar_t *str, const wchar_t *format),
|
WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wchar_t *str, const wchar_t *format),
|
||||||
wxCRT_SscanfW, (str, wxScanfConvertFormatW(format)))
|
wxCRT_SscanfW, (str, wxScanfConvertFormatW(format)))
|
||||||
WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wxCharBuffer& str, const char *format),
|
WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wxScopedCharBuffer& str, const char *format),
|
||||||
wxCRT_SscanfA, (str.data(), format))
|
wxCRT_SscanfA, (str.data(), format))
|
||||||
WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wxWCharBuffer& str, const wchar_t *format),
|
WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wxScopedWCharBuffer& str, const wchar_t *format),
|
||||||
wxCRT_SscanfW, (str.data(), wxScanfConvertFormatW(format)))
|
wxCRT_SscanfW, (str.data(), wxScanfConvertFormatW(format)))
|
||||||
WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wxString& str, const char *format),
|
WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wxString& str, const char *format),
|
||||||
wxCRT_SscanfA, (str.mb_str(), format))
|
wxCRT_SscanfA, (str.mb_str(), format))
|
||||||
@@ -480,8 +480,8 @@ WX_DEFINE_SCANFUNC(wxSscanf, 2, (const wxCStrData& str, const wchar_t *format),
|
|||||||
#ifndef __VISUALC___
|
#ifndef __VISUALC___
|
||||||
int WXDLLIMPEXP_BASE wxVsscanf(const char *str, const char *format, va_list ap);
|
int WXDLLIMPEXP_BASE wxVsscanf(const char *str, const char *format, va_list ap);
|
||||||
int WXDLLIMPEXP_BASE wxVsscanf(const wchar_t *str, const wchar_t *format, va_list ap);
|
int WXDLLIMPEXP_BASE wxVsscanf(const wchar_t *str, const wchar_t *format, va_list ap);
|
||||||
int WXDLLIMPEXP_BASE wxVsscanf(const wxCharBuffer& str, const char *format, va_list ap);
|
int WXDLLIMPEXP_BASE wxVsscanf(const wxScopedCharBuffer& str, const char *format, va_list ap);
|
||||||
int WXDLLIMPEXP_BASE wxVsscanf(const wxWCharBuffer& str, const wchar_t *format, va_list ap);
|
int WXDLLIMPEXP_BASE wxVsscanf(const wxScopedWCharBuffer& str, const wchar_t *format, va_list ap);
|
||||||
int WXDLLIMPEXP_BASE wxVsscanf(const wxString& str, const char *format, va_list ap);
|
int WXDLLIMPEXP_BASE wxVsscanf(const wxString& str, const char *format, va_list ap);
|
||||||
int WXDLLIMPEXP_BASE wxVsscanf(const wxString& str, const wchar_t *format, va_list ap);
|
int WXDLLIMPEXP_BASE wxVsscanf(const wxString& str, const wchar_t *format, va_list ap);
|
||||||
int WXDLLIMPEXP_BASE wxVsscanf(const wxCStrData& str, const char *format, va_list ap);
|
int WXDLLIMPEXP_BASE wxVsscanf(const wxCStrData& str, const char *format, va_list ap);
|
||||||
|
@@ -8,45 +8,190 @@
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
wxCharTypeBuffer<T> is a template class for storing characters.
|
wxScopedCharTypeBuffer<T> is a template class for storing characters.
|
||||||
|
|
||||||
@todo provide better docs for this class
|
Data are stored in reference-counted buffer. In other words, making a copy
|
||||||
|
of wxScopedCharTypeBuffer<T> will @em not make another copy of the stored
|
||||||
|
string data, it will still point to the same location in memory.
|
||||||
|
|
||||||
|
wxScopedCharTypeBuffer<T> supports two storage modes: owned and non-owned.
|
||||||
|
"Owned" data buffer (created with CreateOwned() or wxCharTypeBuffer<T>
|
||||||
|
derived class) owns the data and frees them when the last buffer pointing
|
||||||
|
to them is destroyed.
|
||||||
|
|
||||||
|
"Non-owned" buffer (created with CreateNonOwned()), on the other hand,
|
||||||
|
references data owned by somebody else -- typical use is by
|
||||||
|
wxString::mb_str() or wxString::wc_str(), which may return non-owned buffer
|
||||||
|
pointing to wxString's internal store.
|
||||||
|
|
||||||
|
Because of this, the validity of data stored in wxScopedCharTypeBuffer<T>
|
||||||
|
is limited by the lifetime of the "parent" object that created the
|
||||||
|
buffer (e.g. the wxString on which mb_str() was called).
|
||||||
|
|
||||||
|
If you need to preserve the data for longer, assign it to
|
||||||
|
wxCharTypeBuffer<T> instead of wxScopedCharTypeBuffer<T>. On the other
|
||||||
|
hand, use wxScopedCharTypeBuffer<T> if the buffer is to be destroyed before
|
||||||
|
the "parent" object -- typical use would be creating it on the stack and
|
||||||
|
destroying when it goes out of scope (hence the class' name).
|
||||||
|
|
||||||
@tparam T
|
@tparam T
|
||||||
The type of the characters stored in this class.
|
The type of the characters stored in this class.
|
||||||
|
|
||||||
|
@since 2.9.0
|
||||||
|
|
||||||
@nolibrary
|
@nolibrary
|
||||||
@category{data}
|
@category{data}
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
class wxCharTypeBuffer
|
class wxScopedCharTypeBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
/// Stored characters type.
|
||||||
typedef T CharType;
|
typedef T CharType;
|
||||||
|
|
||||||
wxCharTypeBuffer(const CharType *str = NULL);
|
/// Default constructor, creates NULL buffer.
|
||||||
wxCharTypeBuffer(size_t len);
|
wxScopedCharTypeBuffer();
|
||||||
wxCharTypeBuffer(const wxCharTypeBuffer& src);
|
|
||||||
~wxCharTypeBuffer();
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates non-owned buffer from string data @a str.
|
||||||
|
|
||||||
|
The buffer's destructor will not destroy @a str. The returned buffer's
|
||||||
|
data is valid only as long as @a str is valid.
|
||||||
|
*/
|
||||||
|
static const wxScopedCharTypeBuffer CreateNonOwned(const CharType *str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates owned buffer from @a str and takes ownership of it.
|
||||||
|
|
||||||
|
The buffer's destructor will free @a str when its reference count
|
||||||
|
reaches zero (initial count is 1).
|
||||||
|
*/
|
||||||
|
static const wxScopedCharTypeBuffer CreateOwned(const CharType *str);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Copy constructor.
|
||||||
|
|
||||||
|
Increases reference count on the data, does @em not make wxStrdup()
|
||||||
|
copy of the data.
|
||||||
|
*/
|
||||||
|
wxScopedCharTypeBuffer(const wxScopedCharTypeBuffer& src);
|
||||||
|
|
||||||
|
/// Assignment operator behaves in the same way as the copy constructor.
|
||||||
|
wxScopedCharTypeBuffer& operator=(const wxScopedCharTypeBuffer& src);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destructor. Frees stored data if it is in "owned" mode and data's
|
||||||
|
reference count reaches zero.
|
||||||
|
*/
|
||||||
|
~wxScopedCharTypeBuffer();
|
||||||
|
|
||||||
|
/// Resets the buffer to NULL, freeing the data if necessary.
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
/// Returns pointer to the stored data.
|
||||||
|
CharType *data();
|
||||||
|
|
||||||
|
/// Returns const pointer to the stored data.
|
||||||
|
const CharType *data() const;
|
||||||
|
|
||||||
|
/// Implicit conversion to C string.
|
||||||
|
operator const CharType *() const;
|
||||||
|
|
||||||
|
/// Random access to the stored C string.
|
||||||
|
CharType operator[](size_t n) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Scoped char buffer.
|
||||||
|
typedef wxScopedCharTypeBuffer<char> wxScopedCharBuffer;
|
||||||
|
|
||||||
|
/// Scoped wchar_t buffer.
|
||||||
|
typedef wxScopedCharTypeBuffer<wchar_t> wxScopedWCharBuffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
wxCharTypeBuffer<T> is a template class for storing characters.
|
||||||
|
|
||||||
|
The difference from wxScopedCharTypeBuffer<T> is that this class
|
||||||
|
doesn't have non-owned mode and the data stored in it are valid for
|
||||||
|
as long as the buffer instance exists. Other than that, this class'
|
||||||
|
behaviour is the same as wxScopedCharTypeBuffer<T>'s -- in particular,
|
||||||
|
the data are reference-counted and copying the buffer is cheap.
|
||||||
|
|
||||||
|
wxScopedCharTypeBuffer<T> buffers can be converted into wxCharTypeBuffer<T>.
|
||||||
|
|
||||||
|
@tparam T
|
||||||
|
The type of the characters stored in this class.
|
||||||
|
|
||||||
|
@since 2.9.0
|
||||||
|
|
||||||
|
@nolibrary
|
||||||
|
@category{data}
|
||||||
|
*/
|
||||||
|
template <typename T>
|
||||||
|
class wxCharTypeBuffer : public wxScopedCharTypeBuffer<T>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
Creates (owned) buffer from @a str and takes ownership of it.
|
||||||
|
|
||||||
|
@see wxScopedCharTypeBuffer<T>::CreateOwned()
|
||||||
|
*/
|
||||||
|
wxCharTypeBuffer(const CharType *str = NULL);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates (owned) buffer of size @a len.
|
||||||
|
|
||||||
|
@see wxScopedCharTypeBuffer<T>::CreateOwned()
|
||||||
|
*/
|
||||||
|
wxCharTypeBuffer(size_t len);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Copy constructor.
|
||||||
|
|
||||||
|
Increases reference count on the data, does @em not make wxStrdup()
|
||||||
|
copy of the data.
|
||||||
|
*/
|
||||||
|
wxCharTypeBuffer(const wxCharTypeBuffer& src);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Makes a copy of scoped buffer @a src.
|
||||||
|
|
||||||
|
If @a src is a non-owned buffer, a copy of its data is made using
|
||||||
|
wxStrdup(). If @a src is an owned buffer, this constructor behaves
|
||||||
|
in the usual way (reference count on buffer data is incremented).
|
||||||
|
*/
|
||||||
|
wxCharTypeBuffer(const wxScopedCharTypeBuffer<T>& src);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Assigns @a str to this buffer and takes ownership of it (i.e. the
|
||||||
|
buffer becomes "owned").
|
||||||
|
*/
|
||||||
wxCharTypeBuffer& operator=(const CharType *str);
|
wxCharTypeBuffer& operator=(const CharType *str);
|
||||||
|
|
||||||
|
/// Assignment operator behaves in the same way as the copy constructor.
|
||||||
wxCharTypeBuffer& operator=(const wxCharTypeBuffer& src);
|
wxCharTypeBuffer& operator=(const wxCharTypeBuffer& src);
|
||||||
|
|
||||||
bool extend(size_t len);
|
/**
|
||||||
|
Assigns a scoped buffer to this buffer.
|
||||||
|
|
||||||
CharType *data();
|
If @a src is a non-owned buffer, a copy of its data is made using
|
||||||
const CharType *data() const;
|
wxStrdup(). If @a src is an owned buffer, the assignment behaves
|
||||||
operator const CharType *() const;
|
in the usual way (reference count on buffer data is incremented).
|
||||||
CharType operator[](size_t n) const;
|
*/
|
||||||
|
wxCharTypeBuffer& operator=(const wxScopedCharTypeBuffer<T>& src);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Extends the buffer to have size @a len.
|
||||||
|
|
||||||
|
Can only be called on buffers that don't share data with another
|
||||||
|
buffer (i.e. reference count of the data is 1).
|
||||||
|
*/
|
||||||
|
bool extend(size_t len);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This is a specialization of wxCharTypeBuffer<T> for @c char type.
|
This is a specialization of wxCharTypeBuffer<T> for @c char type.
|
||||||
|
|
||||||
@todo provide better docs for this class
|
|
||||||
|
|
||||||
@nolibrary
|
@nolibrary
|
||||||
@category{data}
|
@category{data}
|
||||||
*/
|
*/
|
||||||
@@ -54,8 +199,10 @@ class wxCharBuffer : public wxCharTypeBuffer<char>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef wxCharTypeBuffer<char> wxCharTypeBufferBase;
|
typedef wxCharTypeBuffer<char> wxCharTypeBufferBase;
|
||||||
|
typedef wxScopedCharTypeBuffer<char> wxScopedCharTypeBufferBase;
|
||||||
|
|
||||||
wxCharBuffer(const wxCharTypeBufferBase& buf);
|
wxCharBuffer(const wxCharTypeBufferBase& buf);
|
||||||
|
wxCharBuffer(const wxScopedCharTypeBufferBase& buf);
|
||||||
wxCharBuffer(const CharType *str = NULL);
|
wxCharBuffer(const CharType *str = NULL);
|
||||||
wxCharBuffer(size_t len);
|
wxCharBuffer(size_t len);
|
||||||
wxCharBuffer(const wxCStrData& cstr);
|
wxCharBuffer(const wxCStrData& cstr);
|
||||||
@@ -63,7 +210,6 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
This is a specialization of wxCharTypeBuffer<T> for @c wchar_t type.
|
This is a specialization of wxCharTypeBuffer<T> for @c wchar_t type.
|
||||||
This class is available only when <tt>wxUSE_WCHAR_T==1</tt>
|
|
||||||
|
|
||||||
@nolibrary
|
@nolibrary
|
||||||
@category{data}
|
@category{data}
|
||||||
@@ -72,8 +218,10 @@ class wxWCharBuffer : public wxCharTypeBuffer<wchar_t>
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef wxCharTypeBuffer<wchar_t> wxCharTypeBufferBase;
|
typedef wxCharTypeBuffer<wchar_t> wxCharTypeBufferBase;
|
||||||
|
typedef wxScopedCharTypeBuffer<wchar_t> wxScopedCharTypeBufferBase;
|
||||||
|
|
||||||
wxWCharBuffer(const wxCharTypeBufferBase& buf);
|
wxWCharBuffer(const wxCharTypeBufferBase& buf);
|
||||||
|
wxWCharBuffer(const wxScopedCharTypeBufferBase& buf);
|
||||||
wxWCharBuffer(const CharType *str = NULL);
|
wxWCharBuffer(const CharType *str = NULL);
|
||||||
wxWCharBuffer(size_t len);
|
wxWCharBuffer(size_t len);
|
||||||
wxWCharBuffer(const wxCStrData& cstr);
|
wxWCharBuffer(const wxCStrData& cstr);
|
||||||
|
@@ -182,7 +182,7 @@ static wxStrCacheStatsDumper s_showCacheStats;
|
|||||||
wxSTD ostream& operator<<(wxSTD ostream& os, const wxCStrData& str)
|
wxSTD ostream& operator<<(wxSTD ostream& os, const wxCStrData& str)
|
||||||
{
|
{
|
||||||
#if wxUSE_UNICODE && !wxUSE_UNICODE_UTF8
|
#if wxUSE_UNICODE && !wxUSE_UNICODE_UTF8
|
||||||
const wxCharBuffer buf(str.AsCharBuf());
|
const wxScopedCharBuffer buf(str.AsCharBuf());
|
||||||
if ( !buf )
|
if ( !buf )
|
||||||
os.clear(wxSTD ios_base::failbit);
|
os.clear(wxSTD ios_base::failbit);
|
||||||
else
|
else
|
||||||
@@ -199,13 +199,13 @@ wxSTD ostream& operator<<(wxSTD ostream& os, const wxString& str)
|
|||||||
return os << str.c_str();
|
return os << str.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSTD ostream& operator<<(wxSTD ostream& os, const wxCharBuffer& str)
|
wxSTD ostream& operator<<(wxSTD ostream& os, const wxScopedCharBuffer& str)
|
||||||
{
|
{
|
||||||
return os << str.data();
|
return os << str.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __BORLANDC__
|
#ifndef __BORLANDC__
|
||||||
wxSTD ostream& operator<<(wxSTD ostream& os, const wxWCharBuffer& str)
|
wxSTD ostream& operator<<(wxSTD ostream& os, const wxScopedWCharBuffer& str)
|
||||||
{
|
{
|
||||||
return os << str.data();
|
return os << str.data();
|
||||||
}
|
}
|
||||||
@@ -223,7 +223,7 @@ wxSTD wostream& operator<<(wxSTD wostream& wos, const wxCStrData& str)
|
|||||||
return wos << str.AsWChar();
|
return wos << str.AsWChar();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSTD wostream& operator<<(wxSTD wostream& wos, const wxWCharBuffer& str)
|
wxSTD wostream& operator<<(wxSTD wostream& wos, const wxScopedWCharBuffer& str)
|
||||||
{
|
{
|
||||||
return wos << str.data();
|
return wos << str.data();
|
||||||
}
|
}
|
||||||
@@ -395,7 +395,7 @@ const char* wxCStrData::AsChar() const
|
|||||||
// adding more fields to wxString and require profiling results
|
// adding more fields to wxString and require profiling results
|
||||||
// to be sure that we really gain enough from them to justify
|
// to be sure that we really gain enough from them to justify
|
||||||
// doing it.
|
// doing it.
|
||||||
wxCharBuffer buf(str->mb_str());
|
wxScopedCharBuffer buf(str->mb_str());
|
||||||
|
|
||||||
// if it failed, return empty string and not NULL to avoid crashes in code
|
// if it failed, return empty string and not NULL to avoid crashes in code
|
||||||
// written with either wxWidgets 2 wxString or std::string behaviour in
|
// written with either wxWidgets 2 wxString or std::string behaviour in
|
||||||
@@ -426,7 +426,7 @@ const wchar_t* wxCStrData::AsWChar() const
|
|||||||
wxString *str = wxConstCast(m_str, wxString);
|
wxString *str = wxConstCast(m_str, wxString);
|
||||||
|
|
||||||
// convert the string:
|
// convert the string:
|
||||||
wxWCharBuffer buf(str->wc_str());
|
wxScopedWCharBuffer buf(str->wc_str());
|
||||||
|
|
||||||
// notice that here, unlike above in AsChar(), conversion can't fail as our
|
// notice that here, unlike above in AsChar(), conversion can't fail as our
|
||||||
// internal UTF-8 is always well-formed -- or the string was corrupted and
|
// internal UTF-8 is always well-formed -- or the string was corrupted and
|
||||||
@@ -465,15 +465,15 @@ wxString::SubstrBufFromMB wxString::ConvertStr(const char *psz, size_t nLength,
|
|||||||
{
|
{
|
||||||
// anything to do?
|
// anything to do?
|
||||||
if ( !psz || nLength == 0 )
|
if ( !psz || nLength == 0 )
|
||||||
return SubstrBufFromMB(L"", 0);
|
return SubstrBufFromMB(wxWCharBuffer(L""), 0);
|
||||||
|
|
||||||
if ( nLength == npos )
|
if ( nLength == npos )
|
||||||
nLength = wxNO_LEN;
|
nLength = wxNO_LEN;
|
||||||
|
|
||||||
size_t wcLen;
|
size_t wcLen;
|
||||||
wxWCharBuffer wcBuf(conv.cMB2WC(psz, nLength, &wcLen));
|
wxScopedWCharBuffer wcBuf(conv.cMB2WC(psz, nLength, &wcLen));
|
||||||
if ( !wcLen )
|
if ( !wcLen )
|
||||||
return SubstrBufFromMB(_T(""), 0);
|
return SubstrBufFromMB(wxWCharBuffer(L""), 0);
|
||||||
else
|
else
|
||||||
return SubstrBufFromMB(wcBuf, wcLen);
|
return SubstrBufFromMB(wcBuf, wcLen);
|
||||||
}
|
}
|
||||||
@@ -486,7 +486,7 @@ wxString::SubstrBufFromMB wxString::ConvertStr(const char *psz, size_t nLength,
|
|||||||
{
|
{
|
||||||
// anything to do?
|
// anything to do?
|
||||||
if ( !psz || nLength == 0 )
|
if ( !psz || nLength == 0 )
|
||||||
return SubstrBufFromMB("", 0);
|
return SubstrBufFromMB(wxCharBuffer(""), 0);
|
||||||
|
|
||||||
// if psz is already in UTF-8, we don't have to do the roundtrip to
|
// if psz is already in UTF-8, we don't have to do the roundtrip to
|
||||||
// wchar_t* and back:
|
// wchar_t* and back:
|
||||||
@@ -509,9 +509,9 @@ wxString::SubstrBufFromMB wxString::ConvertStr(const char *psz, size_t nLength,
|
|||||||
|
|
||||||
// first convert to wide string:
|
// first convert to wide string:
|
||||||
size_t wcLen;
|
size_t wcLen;
|
||||||
wxWCharBuffer wcBuf(conv.cMB2WC(psz, nLength, &wcLen));
|
wxScopedWCharBuffer wcBuf(conv.cMB2WC(psz, nLength, &wcLen));
|
||||||
if ( !wcLen )
|
if ( !wcLen )
|
||||||
return SubstrBufFromMB("", 0);
|
return SubstrBufFromMB(wxCharBuffer(""), 0);
|
||||||
|
|
||||||
// and then to UTF-8:
|
// and then to UTF-8:
|
||||||
SubstrBufFromMB buf(ConvertStr(wcBuf, wcLen, wxMBConvStrictUTF8()));
|
SubstrBufFromMB buf(ConvertStr(wcBuf, wcLen, wxMBConvStrictUTF8()));
|
||||||
@@ -529,15 +529,15 @@ wxString::SubstrBufFromWC wxString::ConvertStr(const wchar_t *pwz, size_t nLengt
|
|||||||
{
|
{
|
||||||
// anything to do?
|
// anything to do?
|
||||||
if ( !pwz || nLength == 0 )
|
if ( !pwz || nLength == 0 )
|
||||||
return SubstrBufFromWC("", 0);
|
return SubstrBufFromWC(wxCharBuffer(""), 0);
|
||||||
|
|
||||||
if ( nLength == npos )
|
if ( nLength == npos )
|
||||||
nLength = wxNO_LEN;
|
nLength = wxNO_LEN;
|
||||||
|
|
||||||
size_t mbLen;
|
size_t mbLen;
|
||||||
wxCharBuffer mbBuf(conv.cWC2MB(pwz, nLength, &mbLen));
|
wxScopedCharBuffer mbBuf(conv.cWC2MB(pwz, nLength, &mbLen));
|
||||||
if ( !mbLen )
|
if ( !mbLen )
|
||||||
return SubstrBufFromWC("", 0);
|
return SubstrBufFromWC(wxCharBuffer(""), 0);
|
||||||
else
|
else
|
||||||
return SubstrBufFromWC(mbBuf, mbLen);
|
return SubstrBufFromWC(mbBuf, mbLen);
|
||||||
}
|
}
|
||||||
@@ -547,14 +547,14 @@ wxString::SubstrBufFromWC wxString::ConvertStr(const wchar_t *pwz, size_t nLengt
|
|||||||
#if wxUSE_UNICODE_WCHAR
|
#if wxUSE_UNICODE_WCHAR
|
||||||
|
|
||||||
//Convert wxString in Unicode mode to a multi-byte string
|
//Convert wxString in Unicode mode to a multi-byte string
|
||||||
const wxCharBuffer wxString::mb_str(const wxMBConv& conv) const
|
const wxScopedCharBuffer wxString::mb_str(const wxMBConv& conv) const
|
||||||
{
|
{
|
||||||
return conv.cWC2MB(wx_str(), length() + 1 /* size, not length */, NULL);
|
return conv.cWC2MB(wx_str(), length() + 1 /* size, not length */, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif wxUSE_UNICODE_UTF8
|
#elif wxUSE_UNICODE_UTF8
|
||||||
|
|
||||||
const wxWCharBuffer wxString::wc_str() const
|
const wxScopedWCharBuffer wxString::wc_str() const
|
||||||
{
|
{
|
||||||
return wxMBConvStrictUTF8().cMB2WC
|
return wxMBConvStrictUTF8().cMB2WC
|
||||||
(
|
(
|
||||||
@@ -564,20 +564,23 @@ const wxWCharBuffer wxString::wc_str() const
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxCharBuffer wxString::mb_str(const wxMBConv& conv) const
|
const wxScopedCharBuffer wxString::mb_str(const wxMBConv& conv) const
|
||||||
{
|
{
|
||||||
if ( conv.IsUTF8() )
|
if ( conv.IsUTF8() )
|
||||||
return wxCharBuffer::CreateNonOwned(m_impl.c_str());
|
return wxScopedCharBuffer::CreateNonOwned(m_impl.c_str());
|
||||||
|
|
||||||
// FIXME-UTF8: use wc_str() here once we have buffers with length
|
// FIXME-UTF8: use wc_str() here once we have buffers with length
|
||||||
|
|
||||||
size_t wcLen;
|
size_t wcLen;
|
||||||
wxWCharBuffer wcBuf(wxMBConvStrictUTF8().cMB2WC
|
wxScopedWCharBuffer wcBuf
|
||||||
(
|
(
|
||||||
m_impl.c_str(),
|
wxMBConvStrictUTF8().cMB2WC
|
||||||
m_impl.length() + 1, // size
|
(
|
||||||
&wcLen
|
m_impl.c_str(),
|
||||||
));
|
m_impl.length() + 1, // size
|
||||||
|
&wcLen
|
||||||
|
)
|
||||||
|
);
|
||||||
if ( !wcLen )
|
if ( !wcLen )
|
||||||
return wxCharBuffer("");
|
return wxCharBuffer("");
|
||||||
|
|
||||||
@@ -588,7 +591,7 @@ const wxCharBuffer wxString::mb_str(const wxMBConv& conv) const
|
|||||||
|
|
||||||
//Converts this string to a wide character string if unicode
|
//Converts this string to a wide character string if unicode
|
||||||
//mode is not enabled and wxUSE_WCHAR_T is enabled
|
//mode is not enabled and wxUSE_WCHAR_T is enabled
|
||||||
const wxWCharBuffer wxString::wc_str(const wxMBConv& conv) const
|
const wxScopedWCharBuffer wxString::wc_str(const wxMBConv& conv) const
|
||||||
{
|
{
|
||||||
return conv.cMB2WC(wx_str(), length() + 1 /* size, not length */, NULL);
|
return conv.cMB2WC(wx_str(), length() + 1 /* size, not length */, NULL);
|
||||||
}
|
}
|
||||||
@@ -1196,7 +1199,7 @@ wxString wxString::FromAscii(char ascii)
|
|||||||
return wxString(wxUniChar((wchar_t)c));
|
return wxString(wxUniChar((wchar_t)c));
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxCharBuffer wxString::ToAscii() const
|
const wxScopedCharBuffer wxString::ToAscii() const
|
||||||
{
|
{
|
||||||
// this will allocate enough space for the terminating NUL too
|
// this will allocate enough space for the terminating NUL too
|
||||||
wxCharBuffer buffer(length());
|
wxCharBuffer buffer(length());
|
||||||
@@ -2085,8 +2088,8 @@ bool wxString::Matches(const wxString& mask) const
|
|||||||
|
|
||||||
// FIXME-UTF8: implement using iterators, remove #if
|
// FIXME-UTF8: implement using iterators, remove #if
|
||||||
#if wxUSE_UNICODE_UTF8
|
#if wxUSE_UNICODE_UTF8
|
||||||
wxWCharBuffer maskBuf = mask.wc_str();
|
const wxScopedWCharBuffer maskBuf = mask.wc_str();
|
||||||
wxWCharBuffer txtBuf = wc_str();
|
const wxScopedWCharBuffer txtBuf = wc_str();
|
||||||
const wxChar *pszMask = maskBuf.data();
|
const wxChar *pszMask = maskBuf.data();
|
||||||
const wxChar *pszTxt = txtBuf.data();
|
const wxChar *pszTxt = txtBuf.data();
|
||||||
#else
|
#else
|
||||||
|
@@ -520,7 +520,7 @@ class wxScanfFormatConverterWchar : public wxFormatConverterBase<wchar_t>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const wxWCharBuffer wxScanfConvertFormatW(const wchar_t *format)
|
const wxScopedWCharBuffer wxScanfConvertFormatW(const wchar_t *format)
|
||||||
{
|
{
|
||||||
return wxScanfFormatConverterWchar().Convert(format);
|
return wxScanfFormatConverterWchar().Convert(format);
|
||||||
}
|
}
|
||||||
|
@@ -399,7 +399,7 @@ wxUString &wxUString::assignFromCString( const char* str )
|
|||||||
if (!str)
|
if (!str)
|
||||||
return assign( wxUString() );
|
return assign( wxUString() );
|
||||||
|
|
||||||
wxWCharBuffer buffer = wxConvLibc.cMB2WC( str );
|
wxScopedWCharBuffer buffer = wxConvLibc.cMB2WC( str );
|
||||||
|
|
||||||
return assign( buffer );
|
return assign( buffer );
|
||||||
}
|
}
|
||||||
@@ -409,12 +409,12 @@ wxUString &wxUString::assignFromCString( const char* str, const wxMBConv &conv )
|
|||||||
if (!str)
|
if (!str)
|
||||||
return assign( wxUString() );
|
return assign( wxUString() );
|
||||||
|
|
||||||
wxWCharBuffer buffer = conv.cMB2WC( str );
|
wxScopedWCharBuffer buffer = conv.cMB2WC( str );
|
||||||
|
|
||||||
return assign( buffer );
|
return assign( buffer );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCharBuffer wxUString::utf8_str() const
|
wxScopedCharBuffer wxUString::utf8_str() const
|
||||||
{
|
{
|
||||||
size_type utf8_length = 0;
|
size_type utf8_length = 0;
|
||||||
const wxChar32 *ptr = data();
|
const wxChar32 *ptr = data();
|
||||||
@@ -491,7 +491,7 @@ wxCharBuffer wxUString::utf8_str() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxU16CharBuffer wxUString::utf16_str() const
|
wxScopedU16CharBuffer wxUString::utf16_str() const
|
||||||
{
|
{
|
||||||
size_type utf16_length = 0;
|
size_type utf16_length = 0;
|
||||||
const wxChar32 *ptr = data();
|
const wxChar32 *ptr = data();
|
||||||
|
@@ -908,13 +908,13 @@ wxVariant::wxVariant(const wxCStrData& val, const wxString& name)
|
|||||||
m_name = name;
|
m_name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxVariant::wxVariant(const wxCharBuffer& val, const wxString& name)
|
wxVariant::wxVariant(const wxScopedCharBuffer& val, const wxString& name)
|
||||||
{
|
{
|
||||||
m_data = new wxVariantDataString(wxString(val));
|
m_data = new wxVariantDataString(wxString(val));
|
||||||
m_name = name;
|
m_name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxVariant::wxVariant(const wxWCharBuffer& val, const wxString& name)
|
wxVariant::wxVariant(const wxScopedWCharBuffer& val, const wxString& name)
|
||||||
{
|
{
|
||||||
m_data = new wxVariantDataString(wxString(val));
|
m_data = new wxVariantDataString(wxString(val));
|
||||||
m_name = name;
|
m_name = name;
|
||||||
|
@@ -61,6 +61,7 @@ private:
|
|||||||
CPPUNIT_TEST( ExplicitConversion );
|
CPPUNIT_TEST( ExplicitConversion );
|
||||||
CPPUNIT_TEST( IndexedAccess );
|
CPPUNIT_TEST( IndexedAccess );
|
||||||
CPPUNIT_TEST( BeforeAndAfter );
|
CPPUNIT_TEST( BeforeAndAfter );
|
||||||
|
CPPUNIT_TEST( ScopedBuffers );
|
||||||
CPPUNIT_TEST_SUITE_END();
|
CPPUNIT_TEST_SUITE_END();
|
||||||
|
|
||||||
void String();
|
void String();
|
||||||
@@ -93,6 +94,7 @@ private:
|
|||||||
void ExplicitConversion();
|
void ExplicitConversion();
|
||||||
void IndexedAccess();
|
void IndexedAccess();
|
||||||
void BeforeAndAfter();
|
void BeforeAndAfter();
|
||||||
|
void ScopedBuffers();
|
||||||
|
|
||||||
DECLARE_NO_COPY_CLASS(StringTestCase)
|
DECLARE_NO_COPY_CLASS(StringTestCase)
|
||||||
};
|
};
|
||||||
@@ -924,3 +926,26 @@ void StringTestCase::BeforeAndAfter()
|
|||||||
CPPUNIT_ASSERT_EQUAL( L"\xe7a=l\xe0", s.AfterLast(';') );
|
CPPUNIT_ASSERT_EQUAL( L"\xe7a=l\xe0", s.AfterLast(';') );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void StringTestCase::ScopedBuffers()
|
||||||
|
{
|
||||||
|
// wxString relies on efficient buffers, verify they work as they should
|
||||||
|
|
||||||
|
const char *literal = "Hello World!";
|
||||||
|
|
||||||
|
// non-owned buffer points to the string passed to it
|
||||||
|
wxScopedCharBuffer sbuf = wxScopedCharBuffer::CreateNonOwned(literal);
|
||||||
|
CPPUNIT_ASSERT( sbuf.data() == literal );
|
||||||
|
|
||||||
|
// a copy of scoped non-owned buffer still points to the same string
|
||||||
|
wxScopedCharBuffer sbuf2(sbuf);
|
||||||
|
CPPUNIT_ASSERT( sbuf.data() == sbuf2.data() );
|
||||||
|
|
||||||
|
// but assigning it to wxCharBuffer makes a full copy
|
||||||
|
wxCharBuffer buf(sbuf);
|
||||||
|
CPPUNIT_ASSERT( buf.data() != literal );
|
||||||
|
CPPUNIT_ASSERT_EQUAL( literal, buf.data() );
|
||||||
|
|
||||||
|
wxCharBuffer buf2 = sbuf;
|
||||||
|
CPPUNIT_ASSERT( buf2.data() != literal );
|
||||||
|
CPPUNIT_ASSERT_EQUAL( literal, buf2.data() );
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user