Deprecate unused wxMBConv parameters in wxString functions
Some wxString functions using wide strings still took wxMBConv just for consistency with the same functions taking narrow strings in ANSI build, but this doesn't really make sense any longer because the same code can't be compiled with different values of wxChar -- it is always the same thing as wchar_t now, and so we shouldn't pass unused conversion objects to these functions any more. So give deprecation warning when these functions are used (but without formally deprecating them, as it doesn't cost much to keep them) and avoid using them in the library code.
This commit is contained in:
parent
f36e414072
commit
3bc0d1ed92
8 changed files with 23 additions and 18 deletions
|
|
@ -71,7 +71,7 @@ public:
|
|||
|
||||
// Constructs with the owned BSTR created from a wxString
|
||||
wxBasicString(const wxString& str)
|
||||
: m_bstrBuf(SysAllocString(str.wc_str(*wxConvCurrent))) {}
|
||||
: m_bstrBuf(SysAllocString(str.wc_str())) {}
|
||||
|
||||
// Constructs with the owned BSTR as a copy of the BSTR owned by bstr
|
||||
wxBasicString(const wxBasicString& bstr) : m_bstrBuf(bstr.Copy()) {}
|
||||
|
|
|
|||
|
|
@ -1171,10 +1171,15 @@ public:
|
|||
// ctors from wchar_t* strings:
|
||||
wxString(const wchar_t *pwz)
|
||||
: m_impl(ImplStr(pwz)) {}
|
||||
wxString(const wchar_t *pwz, const wxMBConv& WXUNUSED(conv))
|
||||
: m_impl(ImplStr(pwz)) {}
|
||||
wxString(const wchar_t *pwz, size_t nLength)
|
||||
{ assign(pwz, nLength); }
|
||||
|
||||
// These ctors only existed for compatibility with the ANSI build and
|
||||
// shouldn't be used any longer.
|
||||
wxDEPRECATED_MSG("remove the wxMBConv ctor argument")
|
||||
wxString(const wchar_t *pwz, const wxMBConv& WXUNUSED(conv))
|
||||
: m_impl(ImplStr(pwz)) {}
|
||||
wxDEPRECATED_MSG("remove the wxMBConv ctor argument")
|
||||
wxString(const wchar_t *pwz, const wxMBConv& WXUNUSED(conv), size_t nLength)
|
||||
{ assign(pwz, nLength); }
|
||||
|
||||
|
|
@ -1773,6 +1778,7 @@ public:
|
|||
{ return AsWCharBuf(wxMBConvStrictUTF8()); }
|
||||
#endif
|
||||
// for compatibility only
|
||||
wxDEPRECATED_MSG("remove the wxMBConv argument")
|
||||
const wxWX2WCbuf wc_str(const wxMBConv& WXUNUSED(conv)) const
|
||||
{ return wc_str(); }
|
||||
|
||||
|
|
|
|||
|
|
@ -1342,8 +1342,7 @@ int wxRegExImpl::Replace(wxString *text,
|
|||
}
|
||||
else
|
||||
{
|
||||
textNew += wxString(textstr + matchStart + start,
|
||||
wxConvUTF8, len);
|
||||
textNew += wxString(textstr + matchStart + start, len);
|
||||
|
||||
mayHaveBackrefs = true;
|
||||
}
|
||||
|
|
@ -1369,7 +1368,7 @@ int wxRegExImpl::Replace(wxString *text,
|
|||
if (result.capacity() < result.length() + start + textNew.length())
|
||||
result.reserve(2 * result.length());
|
||||
|
||||
result.append(wxString(textstr + matchStart, wxConvUTF8, start));
|
||||
result.append(wxString(textstr + matchStart, start));
|
||||
matchStart += start;
|
||||
result.append(textNew);
|
||||
|
||||
|
|
@ -1378,7 +1377,7 @@ int wxRegExImpl::Replace(wxString *text,
|
|||
matchStart += len;
|
||||
}
|
||||
|
||||
result.append(wxString(textstr + matchStart, wxConvUTF8));
|
||||
result.append(wxString(textstr + matchStart));
|
||||
*text = result;
|
||||
|
||||
return countRepl;
|
||||
|
|
|
|||
|
|
@ -837,14 +837,14 @@ wxString wxTarInputStream::GetExtendedHeader(const wxString& key) const
|
|||
if (m_HeaderRecs) {
|
||||
it = m_HeaderRecs->find(key);
|
||||
if (it != m_HeaderRecs->end())
|
||||
return wxString(it->second.wc_str(wxConvUTF8), GetConv());
|
||||
return it->second;
|
||||
}
|
||||
|
||||
// if not found, look at the global header records
|
||||
if (m_GlobalHeaderRecs) {
|
||||
it = m_GlobalHeaderRecs->find(key);
|
||||
if (it != m_GlobalHeaderRecs->end())
|
||||
return wxString(it->second.wc_str(wxConvUTF8), GetConv());
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return wxEmptyString;
|
||||
|
|
@ -966,8 +966,8 @@ bool wxTarInputStream::ReadExtendedHeader(wxTarHeaderRecords*& recs)
|
|||
// replace the '=' with a nul, to terminate the key
|
||||
*p++ = 0;
|
||||
|
||||
wxString key(wxConvUTF8.cMB2WC(pKey), GetConv());
|
||||
wxString value(wxConvUTF8.cMB2WC(p), GetConv());
|
||||
wxString key = wxString::FromUTF8(pKey);
|
||||
wxString value = wxString::FromUTF8(p);
|
||||
|
||||
// an empty value unsets a previously given value
|
||||
if (value.empty())
|
||||
|
|
|
|||
|
|
@ -585,7 +585,7 @@ wxTextOutputStream& wxTextOutputStream::PutChar(wxChar c)
|
|||
}
|
||||
}
|
||||
#else // SIZEOF_WCHAR_T == 4
|
||||
WriteString( wxString(&c, *m_conv, 1) );
|
||||
WriteString( wxString(&c, 1) );
|
||||
#endif // SIZEOF_WCHAR_T == 2 or 4
|
||||
return *this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2340,7 +2340,7 @@ void wxGDIPlusContext::DoDrawText(const wxString& str,
|
|||
|
||||
m_context->DrawString
|
||||
(
|
||||
str.wc_str(*wxConvUI), // string to draw, always Unicode
|
||||
str.wc_str(), // string to draw, always Unicode
|
||||
-1, // length: string is NUL-terminated
|
||||
fontData->GetGDIPlusFont(),
|
||||
PointF(x, y),
|
||||
|
|
@ -2354,7 +2354,7 @@ void wxGDIPlusContext::GetTextExtent( const wxString &str, wxDouble *width, wxDo
|
|||
{
|
||||
wxCHECK_RET( !m_font.IsNull(), wxT("wxGDIPlusContext::GetTextExtent - no valid font set") );
|
||||
|
||||
wxWCharBuffer s = str.wc_str( *wxConvUI );
|
||||
wxWCharBuffer s = str.wc_str();
|
||||
Font* f = ((wxGDIPlusFontData*)m_font.GetRefData())->GetGDIPlusFont();
|
||||
|
||||
// Get the font metrics if we actually need them.
|
||||
|
|
@ -2428,7 +2428,7 @@ void wxGDIPlusContext::GetPartialTextExtents(const wxString& text, wxArrayDouble
|
|||
return;
|
||||
|
||||
Font* f = ((wxGDIPlusFontData*)m_font.GetRefData())->GetGDIPlusFont();
|
||||
wxWCharBuffer ws = text.wc_str( *wxConvUI );
|
||||
wxWCharBuffer ws = text.wc_str();
|
||||
size_t len = wcslen( ws ) ;
|
||||
wxASSERT_MSG(text.length() == len , wxT("GetPartialTextExtents not yet implemented for multichar situations"));
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ WXDLLEXPORT wxString wxConvertStringFromOle(BSTR bStr)
|
|||
void wxBasicString::AssignFromString(const wxString& str)
|
||||
{
|
||||
SysFreeString(m_bstrBuf);
|
||||
m_bstrBuf = SysAllocString(str.wc_str(*wxConvCurrent));
|
||||
m_bstrBuf = SysAllocString(str.wc_str());
|
||||
}
|
||||
|
||||
BSTR wxBasicString::Detach()
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ void UnicodeTestCase::ConstructorsWithConversion()
|
|||
wxString s3(utf8, wxConvUTF8, 4);
|
||||
CPPUNIT_ASSERT_EQUAL( sub, s3 );
|
||||
|
||||
wxString s4(wchar, wxConvUTF8, 3);
|
||||
wxString s4(wchar, 3);
|
||||
CPPUNIT_ASSERT_EQUAL( sub, s4 );
|
||||
|
||||
// conversion should stop with failure at pos 35
|
||||
|
|
@ -248,7 +248,7 @@ void UnicodeTestCase::ConversionWithNULs()
|
|||
{
|
||||
static const size_t lenNulString = 10;
|
||||
|
||||
wxString szTheString(L"The\0String", wxConvLibc, lenNulString);
|
||||
wxString szTheString(L"The\0String", lenNulString);
|
||||
wxCharBuffer theBuffer = szTheString.mb_str(wxConvLibc);
|
||||
|
||||
CPPUNIT_ASSERT( memcmp(theBuffer.data(), "The\0String",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue