Remove returns of wxEmptyString

This commit is contained in:
Paul Cornett
2017-02-18 11:26:40 -08:00
parent 32535f5bf6
commit 6169ced23f
8 changed files with 47 additions and 37 deletions

View File

@@ -490,11 +490,11 @@ bool wxArrayString::operator==(const wxArrayString& a) const
wxString wxJoin(const wxArrayString& arr, const wxChar sep, const wxChar escape)
{
wxString str;
size_t count = arr.size();
if ( count == 0 )
return wxEmptyString;
wxString str;
return str;
// pre-allocate memory using the estimation of the average length of the
// strings in the given array: this is very imprecise, of course, but

View File

@@ -2247,18 +2247,20 @@ enum TimeSpanPart
// %l milliseconds (000 - 999)
wxString wxTimeSpan::Format(const wxString& format) const
{
wxString str;
// we deal with only positive time spans here and just add the sign in
// front for the negative ones
if ( IsNegative() )
{
wxString str(Negate().Format(format));
return "-" + str;
str = "-";
str << Negate().Format(format);
return str;
}
wxCHECK_MSG( !format.empty(), wxEmptyString,
wxCHECK_MSG( !format.empty(), str,
wxT("NULL format in wxTimeSpan::Format") );
wxString str;
str.Alloc(format.length());
// Suppose we have wxTimeSpan ts(1 /* hour */, 2 /* min */, 3 /* sec */)

View File

@@ -318,9 +318,10 @@ void wxFontBase::DoSetNativeFontInfo(const wxNativeFontInfo& info)
wxString wxFontBase::GetNativeFontInfoDesc() const
{
wxCHECK_MSG( IsOk(), wxEmptyString, wxT("invalid font") );
wxString fontDesc;
wxCHECK_MSG(IsOk(), fontDesc, "invalid font");
const wxNativeFontInfo *fontInfo = GetNativeFontInfo();
if ( fontInfo )
{
@@ -337,9 +338,10 @@ wxString wxFontBase::GetNativeFontInfoDesc() const
wxString wxFontBase::GetNativeFontInfoUserDesc() const
{
wxCHECK_MSG( IsOk(), wxEmptyString, wxT("invalid font") );
wxString fontDesc;
wxCHECK_MSG(IsOk(), fontDesc, "invalid font");
const wxNativeFontInfo *fontInfo = GetNativeFontInfo();
if ( fontInfo )
{

View File

@@ -976,27 +976,31 @@ const wxLanguageInfo *wxLocale::GetLanguageInfo(int lang)
/* static */
wxString wxLocale::GetLanguageName(int lang)
{
wxString string;
if ( lang == wxLANGUAGE_DEFAULT || lang == wxLANGUAGE_UNKNOWN )
return wxEmptyString;
return string;
const wxLanguageInfo *info = GetLanguageInfo(lang);
if ( !info )
return wxEmptyString;
else
return info->Description;
if (info)
string = info->Description;
return string;
}
/* static */
wxString wxLocale::GetLanguageCanonicalName(int lang)
{
wxString string;
if ( lang == wxLANGUAGE_DEFAULT || lang == wxLANGUAGE_UNKNOWN )
return wxEmptyString;
return string;
const wxLanguageInfo *info = GetLanguageInfo(lang);
if ( !info )
return wxEmptyString;
else
return info->CanonicalName;
if (info)
string = info->CanonicalName;
return string;
}
/* static */

View File

@@ -259,12 +259,14 @@ wxString wxPlatformInfo::GetOperatingSystemIdName(wxOperatingSystemId os)
wxString wxPlatformInfo::GetPortIdName(wxPortId port, bool usingUniversal)
{
wxString ret;
const unsigned idx = wxGetIndexFromEnumValue(port);
wxCHECK_MSG( idx < WXSIZEOF(wxPortIdNames), wxEmptyString,
wxCHECK_MSG( idx < WXSIZEOF(wxPortIdNames), ret,
wxT("invalid port id") );
wxString ret = wxPortIdNames[idx];
ret = wxPortIdNames[idx];
if ( usingUniversal )
ret += wxT("/wxUniversal");
@@ -274,12 +276,14 @@ wxString wxPlatformInfo::GetPortIdName(wxPortId port, bool usingUniversal)
wxString wxPlatformInfo::GetPortIdShortName(wxPortId port, bool usingUniversal)
{
wxString ret;
const unsigned idx = wxGetIndexFromEnumValue(port);
wxCHECK_MSG( idx < WXSIZEOF(wxPortIdNames), wxEmptyString,
wxCHECK_MSG( idx < WXSIZEOF(wxPortIdNames), ret,
wxT("invalid port id") );
wxString ret = wxPortIdNames[idx];
ret = wxPortIdNames[idx];
ret = ret.Mid(2).Lower(); // remove 'wx' prefix
if ( usingUniversal )

View File

@@ -1160,11 +1160,11 @@ int wxString::CmpNoCase(const wxString& s) const
wxString wxString::FromAscii(const char *ascii, size_t len)
{
if (!ascii || len == 0)
return wxEmptyString;
wxString res;
if (!ascii || len == 0)
return res;
{
wxStringInternalBuffer buf(res, len);
wxStringCharType *dest = buf;

View File

@@ -139,13 +139,10 @@ bool wxVariant::operator!= (const wxVariant& variant) const
wxString wxVariant::MakeString() const
{
if (!IsNull())
{
wxString str;
if (GetData()->Write(str))
if (!IsNull())
GetData()->Write(str);
return str;
}
return wxEmptyString;
}
void wxVariant::SetData(wxVariantData* data)

View File

@@ -946,10 +946,11 @@ void wxGenericPropertyAccessor::GetProperty(const wxObject *object, wxAny& value
wxString wxAnyGetAsString( const wxAny& data)
{
if ( data.IsNull() || data.GetTypeInfo()==NULL )
return wxEmptyString;
wxString s;
if ( data.IsNull() || data.GetTypeInfo()==NULL )
return s;
data.GetTypeInfo()->ConvertToString(data,s);
return s;
}