added wxString::Clone() and made wxString(wxCStrData) ctor make deep copy too
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53327 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -953,8 +953,11 @@ public:
|
|||||||
wxString(const wxWCharBuffer& buf)
|
wxString(const wxWCharBuffer& 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
|
||||||
|
// string, so that "wxString(str.c_str())" idiom for passing strings
|
||||||
|
// between threads works
|
||||||
wxString(const wxCStrData& cstr)
|
wxString(const wxCStrData& cstr)
|
||||||
: m_impl(cstr.AsString().m_impl) { }
|
: m_impl(cstr.AsString().m_impl.c_str()) { }
|
||||||
|
|
||||||
// as we provide both ctors with this signature for both char and unsigned
|
// as we provide both ctors with this signature for both char and unsigned
|
||||||
// char string, we need to provide one for wxCStrData to resolve ambiguity
|
// char string, we need to provide one for wxCStrData to resolve ambiguity
|
||||||
@@ -1014,6 +1017,13 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
#endif // wxUSE_STL
|
#endif // wxUSE_STL
|
||||||
|
|
||||||
|
wxString Clone() const
|
||||||
|
{
|
||||||
|
// make a deep copy of the string, i.e. the returned string will have
|
||||||
|
// ref count = 1 with refcounted implementation
|
||||||
|
return wxString::FromImpl(wxStringImpl(m_impl.c_str(), m_impl.length()));
|
||||||
|
}
|
||||||
|
|
||||||
// first valid index position
|
// first valid index position
|
||||||
const_iterator begin() const { return const_iterator(this, m_impl.begin()); }
|
const_iterator begin() const { return const_iterator(this, m_impl.begin()); }
|
||||||
iterator begin() { return iterator(this, m_impl.begin()); }
|
iterator begin() { return iterator(this, m_impl.begin()); }
|
||||||
|
@@ -261,6 +261,20 @@ public:
|
|||||||
*/
|
*/
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns a deep copy of the string.
|
||||||
|
|
||||||
|
That is, the returned string is guaranteed to not share data with this
|
||||||
|
string when using reference-counted wxString implementation.
|
||||||
|
|
||||||
|
This method is primarily useful for passing strings between threads
|
||||||
|
(because wxString is not thread-safe). Unlike creating a copy using
|
||||||
|
@c wxString(c_str()), Clone() handles embedded NULs correctly.
|
||||||
|
|
||||||
|
@since 2.9.0
|
||||||
|
*/
|
||||||
|
wxString Clone() const;
|
||||||
|
|
||||||
//@{
|
//@{
|
||||||
/**
|
/**
|
||||||
Case-sensitive comparison.
|
Case-sensitive comparison.
|
||||||
|
Reference in New Issue
Block a user