Use wxString's empty() when checking if the string is (non-)empty throughout wx.

Instead of constructs such as if "( s.length() )" and "if (s.length() > 0)" use "if ( !s.empty() )" instead. Similarly for "if (s.length() == 0)" or "if ( s.IsNull() )", use "if ( s.empty() )".
No code changes intended except for a few instances where a construct like "if ( s.length() && wxFileExists(s) )" was changed to not check the length of the string and let wxFileExists handle such cases.



git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66728 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Dimitri Schoolwerth
2011-01-22 14:38:36 +00:00
parent c9ed413ab4
commit 6636ef8ddf
47 changed files with 122 additions and 122 deletions

View File

@@ -53,7 +53,7 @@ FortyCanvas::FortyCanvas(wxWindow* parent, const wxPoint& pos, const wxSize& siz
m_arrowCursor = new wxCursor(wxCURSOR_ARROW); m_arrowCursor = new wxCursor(wxCURSOR_ARROW);
wxString name = wxTheApp->GetAppName(); wxString name = wxTheApp->GetAppName();
if (name.Length() <= 0) name = wxT("forty"); if ( name.empty() ) name = wxT("forty");
m_scoreFile = new ScoreFile(name); m_scoreFile = new ScoreFile(name);
m_game = new Game(0, 0, 0); m_game = new Game(0, 0, 0);
m_game->Deal(); m_game->Deal();
@@ -75,7 +75,7 @@ Write the current player's score back to the score file
*/ */
void FortyCanvas::UpdateScores() void FortyCanvas::UpdateScores()
{ {
if (m_player.Length() > 0 && m_scoreFile && m_game) if (!m_player.empty() && m_scoreFile && m_game)
{ {
m_scoreFile->WritePlayersScore( m_scoreFile->WritePlayersScore(
m_player, m_player,
@@ -94,12 +94,12 @@ void FortyCanvas::OnDraw(wxDC& dc)
#if 0 #if 0
// if player name not set (and selection dialog is not displayed) // if player name not set (and selection dialog is not displayed)
// then ask the player for their name // then ask the player for their name
if (m_player.Length() == 0 && !m_playerDialog) if (m_player.empty() && !m_playerDialog)
{ {
m_playerDialog = new PlayerSelectionDialog(this, m_scoreFile); m_playerDialog = new PlayerSelectionDialog(this, m_scoreFile);
m_playerDialog->ShowModal(); m_playerDialog->ShowModal();
m_player = m_playerDialog->GetPlayersName(); m_player = m_playerDialog->GetPlayersName();
if (m_player.Length() > 0) if ( !m_player.empty() )
{ {
// user entered a name - lookup their score // user entered a name - lookup their score
int wins, games, score; int wins, games, score;
@@ -123,12 +123,12 @@ void FortyCanvas::ShowPlayerDialog()
{ {
// if player name not set (and selection dialog is not displayed) // if player name not set (and selection dialog is not displayed)
// then ask the player for their name // then ask the player for their name
if (m_player.Length() == 0 && !m_playerDialog) if (m_player.empty() && !m_playerDialog)
{ {
m_playerDialog = new PlayerSelectionDialog(this, m_scoreFile); m_playerDialog = new PlayerSelectionDialog(this, m_scoreFile);
m_playerDialog->ShowModal(); m_playerDialog->ShowModal();
m_player = m_playerDialog->GetPlayersName(); m_player = m_playerDialog->GetPlayersName();
if (m_player.Length() > 0) if ( !m_player.empty() )
{ {
// user entered a name - lookup their score // user entered a name - lookup their score
int wins, games, score; int wins, games, score;

View File

@@ -114,7 +114,7 @@ void PlayerSelectionDialog::ButtonCallback(wxCommandEvent& event)
if (event.GetId() == wxID_OK) if (event.GetId() == wxID_OK)
{ {
wxString name = m_textField->GetValue(); wxString name = m_textField->GetValue();
if (!name.IsNull() && name.Length() > 0) if ( !name.empty() )
{ {
if (name.Contains(wxT('@'))) if (name.Contains(wxT('@')))
{ {

View File

@@ -997,7 +997,7 @@ public:
void SetCustomButton( const wxString& custBtText, void SetCustomButton( const wxString& custBtText,
wxArrayStringProperty* pcc ) wxArrayStringProperty* pcc )
{ {
if ( custBtText.length() ) if ( !custBtText.empty() )
{ {
EnableCustomNewAction(); EnableCustomNewAction();
m_pCallingClass = pcc; m_pCallingClass = pcc;

View File

@@ -1548,7 +1548,7 @@ wxTextCtrl* MyFrame::CreateTextCtrl(const wxString& ctrl_text)
static int n = 0; static int n = 0;
wxString text; wxString text;
if (ctrl_text.Length() > 0) if ( !ctrl_text.empty() )
text = ctrl_text; text = ctrl_text;
else else
text.Printf(wxT("This is text box %d"), ++n); text.Printf(wxT("This is text box %d"), ++n);

View File

@@ -322,7 +322,7 @@ public:
wxString s = ::wxGetSingleChoice(wxT("Message"), wxString s = ::wxGetSingleChoice(wxT("Message"),
wxT("Caption"), wxT("Caption"),
m_choices.GetLabels()); m_choices.GetLabels());
if ( s.length() ) if ( !s.empty() )
{ {
SetValue(s); SetValue(s);
return true; return true;

View File

@@ -618,7 +618,7 @@ bool wxArrayDoubleProperty::StringToValue( wxVariant& variant, const wxString& t
WX_PG_TOKENIZER1_BEGIN(text,delimiter) WX_PG_TOKENIZER1_BEGIN(text,delimiter)
if ( token.length() ) if ( !token.empty() )
{ {
// If token was invalid, exit the loop now // If token was invalid, exit the loop now

View File

@@ -884,7 +884,7 @@ wxBitmap BitmapComboBoxWidgetsPage::QueryBitmap(wxString* pStr)
::wxSetCursor( *wxHOURGLASS_CURSOR ); ::wxSetCursor( *wxHOURGLASS_CURSOR );
if ( filepath.length() ) if ( !filepath.empty() )
{ {
if ( pStr ) if ( pStr )
{ {

View File

@@ -222,7 +222,7 @@ void wxBitmapComboBoxBase::DrawItem(wxDC& dc,
true); true);
} }
if ( text.length() ) if ( !text.empty() )
dc.DrawText(text, dc.DrawText(text,
rect.x + m_imgAreaWidth + 1, rect.x + m_imgAreaWidth + 1,
rect.y + (rect.height-dc.GetCharHeight())/2); rect.y + (rect.height-dc.GetCharHeight())/2);

View File

@@ -2130,7 +2130,7 @@ void wxComboCtrlBase::DoSetPopupControl(wxComboPopup* iface)
} }
// This must be done after creation // This must be done after creation
if ( m_valueString.length() ) if ( !m_valueString.empty() )
{ {
iface->SetStringValue(m_valueString); iface->SetStringValue(m_valueString);
//Refresh(); //Refresh();

View File

@@ -945,7 +945,7 @@ void wxGCDCImpl::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y,
{ {
wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") ); wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawRotatedText - invalid DC") );
if ( str.length() == 0 ) if ( str.empty() )
return; return;
if ( !m_logicalFunctionSupported ) if ( !m_logicalFunctionSupported )
return; return;
@@ -960,7 +960,7 @@ void wxGCDCImpl::DoDrawText(const wxString& str, wxCoord x, wxCoord y)
{ {
wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawText - invalid DC") ); wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoDrawText - invalid DC") );
if ( str.length() == 0 ) if ( str.empty() )
return; return;
if ( !m_logicalFunctionSupported ) if ( !m_logicalFunctionSupported )

View File

@@ -355,7 +355,7 @@ void wxFileSystem::ChangePathTo(const wxString& location, bool is_dir)
if (is_dir) if (is_dir)
{ {
if (m_Path.length() > 0 && m_Path.Last() != wxT('/') && m_Path.Last() != wxT(':')) if (!m_Path.empty() && m_Path.Last() != wxT('/') && m_Path.Last() != wxT(':'))
m_Path << wxT('/'); m_Path << wxT('/');
} }

View File

@@ -358,7 +358,7 @@ wxFSFile* wxArchiveFSHandler::OpenFile(
right = rightPart.GetFullPath(wxPATH_UNIX); right = rightPart.GetFullPath(wxPATH_UNIX);
} }
if (right.Length() && right.GetChar(0) == wxT('/')) right = right.Mid(1); if (!right.empty() && right.GetChar(0) == wxT('/')) right = right.Mid(1);
if (!m_cache) if (!m_cache)
m_cache = new wxArchiveFSCache; m_cache = new wxArchiveFSCache;

View File

@@ -225,7 +225,7 @@ bool wxHTTP::ParseHeaders()
if (m_lastError != wxPROTO_NOERR) if (m_lastError != wxPROTO_NOERR)
return false; return false;
if (line.length() == 0) if ( line.empty() )
break; break;
wxString left_str = line.BeforeFirst(':'); wxString left_str = line.BeforeFirst(':');
@@ -312,7 +312,7 @@ bool wxHTTP::BuildRequest(const wxString& path, wxHTTP_Req req)
case wxHTTP_POST: case wxHTTP_POST:
request = wxT("POST"); request = wxT("POST");
if ( GetHeader( wxT("Content-Length") ).IsNull() ) if ( GetHeader( wxT("Content-Length") ).empty() )
SetHeader( wxT("Content-Length"), wxString::Format( wxT("%lu"), (unsigned long)m_post_buf.Len() ) ); SetHeader( wxT("Content-Length"), wxString::Format( wxT("%lu"), (unsigned long)m_post_buf.Len() ) );
break; break;
@@ -323,7 +323,7 @@ bool wxHTTP::BuildRequest(const wxString& path, wxHTTP_Req req)
m_http_response = 0; m_http_response = 0;
// If there is no User-Agent defined, define it. // If there is no User-Agent defined, define it.
if (GetHeader(wxT("User-Agent")).IsNull()) if ( GetHeader(wxT("User-Agent")).empty() )
SetHeader(wxT("User-Agent"), wxT("wxWidgets 2.x")); SetHeader(wxT("User-Agent"), wxT("wxWidgets 2.x"));
// Send authentication information // Send authentication information

View File

@@ -672,7 +672,7 @@ bool wxGIFHandler_WriteHeader(wxOutputStream *stream, int width, int height,
ok = ok && wxGIFHandler_WriteLoop(stream); ok = ok && wxGIFHandler_WriteLoop(stream);
} }
if (comment.length()) if ( !comment.empty() )
{ {
ok = ok && wxGIFHandler_WriteComment(stream, comment); ok = ok && wxGIFHandler_WriteComment(stream, comment);
} }

View File

@@ -395,14 +395,14 @@ bool wxStringImpl::Alloc(size_t nLen)
wxStringImpl::iterator wxStringImpl::begin() wxStringImpl::iterator wxStringImpl::begin()
{ {
if (length() > 0) if ( !empty() )
CopyBeforeWrite(); CopyBeforeWrite();
return m_pchData; return m_pchData;
} }
wxStringImpl::iterator wxStringImpl::end() wxStringImpl::iterator wxStringImpl::end()
{ {
if (length() > 0) if ( !empty() )
CopyBeforeWrite(); CopyBeforeWrite();
return m_pchData + length(); return m_pchData + length();
} }
@@ -528,7 +528,7 @@ size_t wxStringImpl::rfind(const wxStringImpl& str, size_t nStart) const
if ( length() >= str.length() ) if ( length() >= str.length() )
{ {
// avoids a corner case later // avoids a corner case later
if ( length() == 0 && str.length() == 0 ) if ( empty() && str.empty() )
return 0; return 0;
// "top" is the point where search starts from // "top" is the point where search starts from

View File

@@ -1741,7 +1741,7 @@ wxArrayString wxFileTranslationsLoader::GetAvailableTranslations(const wxString&
i != prefixes.end(); i != prefixes.end();
++i ) ++i )
{ {
if (i->length() == 0) if ( i->empty() )
continue; continue;
wxDir dir; wxDir dir;
if ( !dir.Open(*i) ) if ( !dir.Open(*i) )

View File

@@ -251,7 +251,7 @@ bool wxURL::FetchProtocol()
{ {
if (m_scheme == info->m_protoname) if (m_scheme == info->m_protoname)
{ {
if (m_port.IsNull()) if ( m_port.empty() )
m_port = info->m_servname; m_port = info->m_servname;
m_protoinfo = info; m_protoinfo = info;
m_protocol = (wxProtocol *)m_protoinfo->m_cinfo->CreateObject(); m_protocol = (wxProtocol *)m_protoinfo->m_cinfo->CreateObject();

View File

@@ -399,7 +399,7 @@ int wxObjectXmlReader::ReadComponent(wxXmlNode *node, wxObjectReaderCallback *ca
// properties were written in the xml // properties were written in the xml
for ( size_t j = 0; j < propertyNames.size(); ++j ) for ( size_t j = 0; j < propertyNames.size(); ++j )
{ {
if ( propertyNames[j].length() ) if ( !propertyNames[j].empty() )
{ {
PropertyNodes::iterator propiter = propertyNodes.find( propertyNames[j] ); PropertyNodes::iterator propiter = propertyNodes.find( propertyNames[j] );
if ( propiter != propertyNodes.end() ) if ( propiter != propertyNodes.end() )

View File

@@ -506,10 +506,10 @@ void wxGenericFontDialog::CreateWidgets()
if (m_colourChoice) if (m_colourChoice)
{ {
wxString name(wxTheColourDatabase->FindName(m_fontData.GetColour())); wxString name(wxTheColourDatabase->FindName(m_fontData.GetColour()));
if (name.length()) if ( name.empty() )
m_colourChoice->SetStringSelection(name);
else
m_colourChoice->SetStringSelection(wxT("BLACK")); m_colourChoice->SetStringSelection(wxT("BLACK"));
else
m_colourChoice->SetStringSelection(name);
} }
if (m_underLineCheckBox) if (m_underLineCheckBox)

View File

@@ -339,7 +339,7 @@ bool wxExtHelpController::DisplayContents()
file << m_helpDir << wxFILE_SEP_PATH << contents; file << m_helpDir << wxFILE_SEP_PATH << contents;
if (file.Contains(wxT('#'))) if (file.Contains(wxT('#')))
file = file.BeforeLast(wxT('#')); file = file.BeforeLast(wxT('#'));
if (contents.length() && wxFileExists(file)) if ( wxFileExists(file) )
rc = DisplaySection(WXEXTHELP_CONTENTS_ID); rc = DisplaySection(WXEXTHELP_CONTENTS_ID);
// if not found, open homemade toc: // if not found, open homemade toc:

View File

@@ -865,7 +865,7 @@ void wxVListBoxComboPopup::Populate( const wxArrayString& choices )
// Find initial selection // Find initial selection
wxString strValue = m_combo->GetValue(); wxString strValue = m_combo->GetValue();
if ( strValue.length() ) if ( !strValue.empty() )
m_value = m_strings.Index(strValue); m_value = m_strings.Index(strValue);
} }

View File

@@ -744,7 +744,7 @@ void wxComboBox::Replace( long from, long to, const wxString& value )
GtkWidget *entry = GTK_COMBO(m_widget)->entry; GtkWidget *entry = GTK_COMBO(m_widget)->entry;
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to ); gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
if (value.IsNull()) return; if ( value.empty() ) return;
gint pos = (gint)to; gint pos = (gint)to;
#if wxUSE_UNICODE #if wxUSE_UNICODE

View File

@@ -429,7 +429,7 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
static void wxInsertChildInMDI( wxMDIClientWindow* parent, wxMDIChildFrame* child ) static void wxInsertChildInMDI( wxMDIClientWindow* parent, wxMDIChildFrame* child )
{ {
wxString s = child->GetTitle(); wxString s = child->GetTitle();
if (s.IsNull()) s = _("MDI child"); if ( s.empty() ) s = _("MDI child");
GtkWidget *label_widget = gtk_label_new( s.mbc_str() ); GtkWidget *label_widget = gtk_label_new( s.mbc_str() );
gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 ); gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 );

View File

@@ -228,7 +228,7 @@ int wxFileDialog::ShowModal()
Widget shell = XtParent(fileSel); Widget shell = XtParent(fileSel);
if (!m_message.IsNull()) if ( !m_message.empty() )
XtVaSetValues(shell, XtVaSetValues(shell,
XmNtitle, (const char*)m_message.mb_str(), XmNtitle, (const char*)m_message.mb_str(),
NULL); NULL);

View File

@@ -161,7 +161,7 @@ bool wxTextCtrl::Create(wxWindow *parent,
#if 0 #if 0
// TODO: Is this relevant? What does it do? // TODO: Is this relevant? What does it do?
int noCols = 2; int noCols = 2;
if (!value.IsNull() && (value.length() > (unsigned int) noCols)) if (!value.empty() && (value.length() > (unsigned int) noCols))
noCols = value.length(); noCols = value.length();
XtVaSetValues((Widget) m_mainWidget, XtVaSetValues((Widget) m_mainWidget,
XmNcolumns, noCols, XmNcolumns, noCols,

View File

@@ -177,13 +177,13 @@ wxMetafileDCImpl::wxMetafileDCImpl(wxDC *owner, const wxString& file)
m_maxY = -10000; m_maxY = -10000;
// m_title = NULL; // m_title = NULL;
if (!file.IsNull() && wxFileExists(file)) if ( wxFileExists(file) )
wxRemoveFile(file); wxRemoveFile(file);
if (!file.IsNull() && (file != wxEmptyString)) if ( file.empty() )
m_hDC = (WXHDC) CreateMetaFile(file);
else
m_hDC = (WXHDC) CreateMetaFile(NULL); m_hDC = (WXHDC) CreateMetaFile(NULL);
else
m_hDC = (WXHDC) CreateMetaFile(file);
m_ok = (m_hDC != (WXHDC) 0) ; m_ok = (m_hDC != (WXHDC) 0) ;

View File

@@ -109,7 +109,7 @@ bool wxAutomationObject::Invoke(const wxString& member, int action,
int namedArgCount = 0; int namedArgCount = 0;
int i; int i;
for (i = 0; i < noArgs; i++) for (i = 0; i < noArgs; i++)
if (!INVOKEARG(i).GetName().IsNull()) if ( !INVOKEARG(i).GetName().empty() )
{ {
namedArgCount ++; namedArgCount ++;
} }
@@ -124,7 +124,7 @@ bool wxAutomationObject::Invoke(const wxString& member, int action,
int j = 0; int j = 0;
for (i = 0; i < namedArgCount; i++) for (i = 0; i < namedArgCount; i++)
{ {
if (!INVOKEARG(i).GetName().IsNull()) if ( !INVOKEARG(i).GetName().empty() )
{ {
argNames[(namedArgCount-j)] = wxConvertStringToOle(INVOKEARG(i).GetName()); argNames[(namedArgCount-j)] = wxConvertStringToOle(INVOKEARG(i).GetName());
j ++; j ++;

View File

@@ -114,7 +114,7 @@ bool wxDialog::Create( wxWindow* pParent,
// //
// Must defer setting the title until after dialog is created and sized // Must defer setting the title until after dialog is created and sized
// //
if (!rsTitle.IsNull()) if ( !rsTitle.empty() )
SetTitle(rsTitle); SetTitle(rsTitle);
return true; return true;
} // end of wxDialog::Create } // end of wxDialog::Create

View File

@@ -142,7 +142,7 @@ wxMetafileDCImpl::wxMetafileDCImpl(wxDC *owner, const wxString& file)
m_maxY = -10000; m_maxY = -10000;
// m_title = NULL; // m_title = NULL;
if (!file.IsNull() && wxFileExists(file)) if ( wxFileExists(file) )
wxRemoveFile(file); wxRemoveFile(file);
// TODO // TODO

View File

@@ -545,7 +545,7 @@ bool wxToolBar::Realize()
m_vLastY = m_yMargin; m_vLastY = m_yMargin;
} }
pTool->m_vX = m_vLastX + pTool->GetWidth(); pTool->m_vX = m_vLastX + pTool->GetWidth();
if (HasFlag(wxTB_TEXT) && !pTool->GetLabel().IsNull()) if ( HasFlag(wxTB_TEXT) && !pTool->GetLabel().empty() )
pTool->m_vY = m_vLastY + (nMaxToolHeight - m_vTextY) + m_toolPacking; pTool->m_vY = m_vLastY + (nMaxToolHeight - m_vTextY) + m_toolPacking;
else else
pTool->m_vY = m_vLastY + (nMaxToolHeight - (int)(pTool->GetHeight()/2)); pTool->m_vY = m_vLastY + (nMaxToolHeight - (int)(pTool->GetHeight()/2));
@@ -858,7 +858,7 @@ void wxToolBar::DrawTool( wxDC& rDc, wxToolBarToolBase* pToolBase )
{ {
RaiseTool(pTool); RaiseTool(pTool);
} }
if (HasFlag(wxTB_TEXT) && !pTool->GetLabel().IsNull()) if ( HasFlag(wxTB_TEXT) && !pTool->GetLabel().empty() )
{ {
wxCoord vX; wxCoord vX;
wxCoord vY; wxCoord vY;
@@ -903,7 +903,7 @@ void wxToolBar::DrawTool( wxDC& rDc, wxToolBarToolBase* pToolBase )
,pTool->m_vY ,pTool->m_vY
,bUseMask ,bUseMask
); );
if (HasFlag(wxTB_TEXT) && !pTool->GetLabel().IsNull()) if ( HasFlag(wxTB_TEXT) && !pTool->GetLabel().empty() )
{ {
wxCoord vX; wxCoord vX;
wxCoord vY; wxCoord vY;
@@ -953,7 +953,7 @@ wxToolBarToolBase* wxToolBar::FindToolForPosition(
{ {
wxToolBarTool* pTool = (wxToolBarTool *)node->GetData(); wxToolBarTool* pTool = (wxToolBarTool *)node->GetData();
if (HasFlag(wxTB_TEXT) && !pTool->GetLabel().IsNull()) if ( HasFlag(wxTB_TEXT) && !pTool->GetLabel().empty() )
{ {
if ((vX >= (pTool->m_vX - ((wxCoord)(pTool->GetWidth()/2) - 2))) && if ((vX >= (pTool->m_vX - ((wxCoord)(pTool->GetWidth()/2) - 2))) &&
(vY >= (pTool->m_vY - 2)) && (vY >= (pTool->m_vY - 2)) &&

View File

@@ -472,7 +472,7 @@ bool wxDataObject::GetFromPasteboard( void * pb )
} }
CFRelease( flavorTypeArray ); CFRelease( flavorTypeArray );
} }
if (filenamesPassed.length() > 0) if ( !filenamesPassed.empty() )
{ {
wxCharBuffer buf = filenamesPassed.fn_str(); wxCharBuffer buf = filenamesPassed.fn_str();
SetData( wxDF_FILENAME, strlen( buf ), (const char*)buf ); SetData( wxDF_FILENAME, strlen( buf ), (const char*)buf );

View File

@@ -324,11 +324,11 @@ void OpenUserDataRec::MakeUserDataRec( const wxString& filter )
wxString extension = m_extensions[i]; wxString extension = m_extensions[i];
// Remove leading '*' // Remove leading '*'
if (extension.length() && (extension.GetChar(0) == '*')) if ( !extension.empty() && (extension.GetChar(0) == '*') )
extension = extension.Mid( 1 ); extension = extension.Mid( 1 );
// Remove leading '.' // Remove leading '.'
if (extension.length() && (extension.GetChar(0) == '.')) if ( !extension.empty() && (extension.GetChar(0) == '.') )
extension = extension.Mid( 1 ); extension = extension.Mid( 1 );
if (wxFileName::MacFindDefaultTypeAndCreator( extension, &fileType, &creator )) if (wxFileName::MacFindDefaultTypeAndCreator( extension, &fileType, &creator ))

View File

@@ -577,7 +577,7 @@ bool wxMimeTypesManagerImpl::GetDescription(const wxString& uti, wxString *desc)
{ {
const UtiMap::const_iterator itr = m_utiMap.find( uti ); const UtiMap::const_iterator itr = m_utiMap.find( uti );
if( itr == m_utiMap.end() || itr->second.description.IsNull() ) if( itr == m_utiMap.end() || itr->second.description.empty() )
{ {
*desc = wxEmptyString; *desc = wxEmptyString;
return false; return false;

View File

@@ -634,7 +634,7 @@ wxFontProperty::wxFontProperty( const wxString& label, const wxString& name,
wxString faceName = font.GetFaceName(); wxString faceName = font.GetFaceName();
// If font was not in there, add it now // If font was not in there, add it now
if ( faceName.length() && if ( !faceName.empty() &&
wxPGGlobalVars->m_fontFamilyChoices->Index(faceName) == wxNOT_FOUND ) wxPGGlobalVars->m_fontFamilyChoices->Index(faceName) == wxNOT_FOUND )
wxPGGlobalVars->m_fontFamilyChoices->AddAsSorted(faceName); wxPGGlobalVars->m_fontFamilyChoices->AddAsSorted(faceName);
@@ -797,7 +797,7 @@ void wxFontProperty::OnCustomPaint(wxDC& dc,
else else
drawFace = m_value_wxFont.GetFaceName(); drawFace = m_value_wxFont.GetFaceName();
if ( drawFace.length() ) if ( !drawFace.empty() )
{ {
// Draw the background // Draw the background
dc.SetBrush( wxColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)) ); dc.SetBrush( wxColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)) );
@@ -1782,7 +1782,7 @@ void wxCursorProperty::OnCustomPaint( wxDC&, const wxRect&, wxPGPaintData& ) { }
const wxString& wxPGGetDefaultImageWildcard() const wxString& wxPGGetDefaultImageWildcard()
{ {
// Form the wildcard, if not done yet // Form the wildcard, if not done yet
if ( !wxPGGlobalVars->m_pDefaultImageWildcard.length() ) if ( wxPGGlobalVars->m_pDefaultImageWildcard.empty() )
{ {
wxString str; wxString str;
@@ -2179,7 +2179,7 @@ wxString wxDateProperty::ValueToString( wxVariant& value,
if ( !dateTime.IsValid() ) if ( !dateTime.IsValid() )
return wxT("Invalid"); return wxT("Invalid");
if ( !ms_defaultDateFormat.length() ) if ( ms_defaultDateFormat.empty() )
{ {
#if wxUSE_DATEPICKCTRL #if wxUSE_DATEPICKCTRL
bool showCentury = m_dpStyle & wxDP_SHOWCENTURY ? true : false; bool showCentury = m_dpStyle & wxDP_SHOWCENTURY ? true : false;
@@ -2189,7 +2189,7 @@ wxString wxDateProperty::ValueToString( wxVariant& value,
ms_defaultDateFormat = DetermineDefaultDateFormat( showCentury ); ms_defaultDateFormat = DetermineDefaultDateFormat( showCentury );
} }
if ( m_format.length() && if ( !m_format.empty() &&
!(argFlags & wxPG_FULL_VALUE) ) !(argFlags & wxPG_FULL_VALUE) )
format = m_format.c_str(); format = m_format.c_str();

View File

@@ -444,7 +444,7 @@ bool wxPGTextCtrlEditor::GetTextCtrlValueFromControl( wxVariant& variant, wxPGPr
wxTextCtrl* tc = wxStaticCast(ctrl, wxTextCtrl); wxTextCtrl* tc = wxStaticCast(ctrl, wxTextCtrl);
wxString textVal = tc->GetValue(); wxString textVal = tc->GetValue();
if ( property->UsesAutoUnspecified() && !textVal.length() ) if ( property->UsesAutoUnspecified() && textVal.empty() )
{ {
variant.MakeNull(); variant.MakeNull();
return true; return true;
@@ -1070,10 +1070,10 @@ wxWindow* wxPGChoiceEditor::CreateControlsBase( wxPropertyGrid* propGrid,
if ( index >= 0 && index < (int)cb->GetCount() ) if ( index >= 0 && index < (int)cb->GetCount() )
{ {
cb->SetSelection( index ); cb->SetSelection( index );
if ( defString.length() ) if ( !defString.empty() )
cb->SetText( defString ); cb->SetText( defString );
} }
else if ( !(extraStyle & wxCB_READONLY) && defString.length() ) else if ( !(extraStyle & wxCB_READONLY) && !defString.empty() )
{ {
propGrid->SetupTextCtrlValue(defString); propGrid->SetupTextCtrlValue(defString);
cb->SetValue( defString ); cb->SetValue( defString );
@@ -1283,7 +1283,7 @@ bool wxPGComboBoxEditor::GetValueFromControl( wxVariant& variant, wxPGProperty*
wxOwnerDrawnComboBox* cb = (wxOwnerDrawnComboBox*)ctrl; wxOwnerDrawnComboBox* cb = (wxOwnerDrawnComboBox*)ctrl;
wxString textVal = cb->GetValue(); wxString textVal = cb->GetValue();
if ( property->UsesAutoUnspecified() && !textVal.length() ) if ( property->UsesAutoUnspecified() && textVal.empty() )
{ {
variant.MakeNull(); variant.MakeNull();
return true; return true;

View File

@@ -986,7 +986,7 @@ wxPropertyGridPage* wxPropertyGridManager::InsertPage( int index,
state->InitNonCatMode(); state->InitNonCatMode();
} }
if ( label.length() ) if ( !label.empty() )
{ {
wxASSERT_MSG( !pageObj->m_label.length(), wxASSERT_MSG( !pageObj->m_label.length(),
wxT("If page label is given in constructor, empty label must be given in AddPage")); wxT("If page label is given in constructor, empty label must be given in AddPage"));

View File

@@ -206,7 +206,7 @@ bool wxPGDefaultRenderer::Render( wxDC& dc, const wxRect& rect,
{ {
text = propertyGrid->GetCommonValueLabel(cmnVal); text = propertyGrid->GetCommonValueLabel(cmnVal);
DrawText( dc, rect, 0, text ); DrawText( dc, rect, 0, text );
if ( text.length() ) if ( !text.empty() )
return true; return true;
} }
return false; return false;
@@ -258,15 +258,15 @@ bool wxPGDefaultRenderer::Render( wxDC& dc, const wxRect& rect,
if ( propertyGrid->GetColumnCount() <= 2 ) if ( propertyGrid->GetColumnCount() <= 2 )
{ {
wxString unitsString = property->GetAttribute(wxPGGlobalVars->m_strUnits, wxEmptyString); wxString unitsString = property->GetAttribute(wxPGGlobalVars->m_strUnits, wxEmptyString);
if ( unitsString.length() ) if ( !unitsString.empty() )
text = wxString::Format(wxS("%s %s"), text.c_str(), unitsString.c_str() ); text = wxString::Format(wxS("%s %s"), text.c_str(), unitsString.c_str() );
} }
} }
if ( text.length() == 0 ) if ( text.empty() )
{ {
text = property->GetHintText(); text = property->GetHintText();
if ( text.length() > 0 ) if ( !text.empty() )
{ {
res = true; res = true;
@@ -715,7 +715,7 @@ wxString wxPGProperty::GetName() const
{ {
wxPGProperty* parent = GetParent(); wxPGProperty* parent = GetParent();
if ( !m_name.length() || !parent || parent->IsCategory() || parent->IsRoot() ) if ( m_name.empty() || !parent || parent->IsCategory() || parent->IsRoot() )
return m_name; return m_name;
return m_parent->GetName() + wxS(".") + m_name; return m_parent->GetName() + wxS(".") + m_name;
@@ -924,7 +924,7 @@ void wxPGProperty::DoGenerateComposedValue( wxString& text,
(*childResults)[curChild->GetName()] = s; (*childResults)[curChild->GetName()] = s;
bool skip = false; bool skip = false;
if ( (argFlags & wxPG_UNEDITABLE_COMPOSITE_FRAGMENT) && !s.length() ) if ( (argFlags & wxPG_UNEDITABLE_COMPOSITE_FRAGMENT) && s.empty() )
skip = true; skip = true;
if ( !curChild->GetChildCount() || skip ) if ( !curChild->GetChildCount() || skip )
@@ -1172,7 +1172,7 @@ bool wxPGProperty::StringToValue( wxVariant& variant, const wxString& text, int
token = text.substr(startPos,pos-startPos-1); token = text.substr(startPos,pos-startPos-1);
if ( !token.length() ) if ( token.empty() )
break; break;
const wxPGProperty* child = Item(curChild); const wxPGProperty* child = Item(curChild);
@@ -1848,7 +1848,7 @@ wxString wxPGProperty::GetFlagsAsString( FlagType flagsMask ) const
{ {
const wxChar* fs = gs_propFlagToString[i]; const wxChar* fs = gs_propFlagToString[i];
wxASSERT(fs); wxASSERT(fs);
if ( s.length() ) if ( !s.empty() )
s << wxS("|"); s << wxS("|");
s << fs; s << fs;
} }

View File

@@ -1688,7 +1688,7 @@ wxPoint wxPropertyGrid::GetGoodEditorDialogPosition( wxPGProperty* p,
wxString& wxPropertyGrid::ExpandEscapeSequences( wxString& dst_str, wxString& src_str ) wxString& wxPropertyGrid::ExpandEscapeSequences( wxString& dst_str, wxString& src_str )
{ {
if ( src_str.length() == 0 ) if ( src_str.empty() )
{ {
dst_str = src_str; dst_str = src_str;
return src_str; return src_str;
@@ -1747,7 +1747,7 @@ wxString& wxPropertyGrid::ExpandEscapeSequences( wxString& dst_str, wxString& sr
wxString& wxPropertyGrid::CreateEscapeSequences( wxString& dst_str, wxString& src_str ) wxString& wxPropertyGrid::CreateEscapeSequences( wxString& dst_str, wxString& src_str )
{ {
if ( src_str.length() == 0 ) if ( src_str.empty() )
{ {
dst_str = src_str; dst_str = src_str;
return src_str; return src_str;
@@ -3162,7 +3162,7 @@ wxStatusBar* wxPropertyGrid::GetStatusBar()
void wxPropertyGrid::DoShowPropertyError( wxPGProperty* WXUNUSED(property), const wxString& msg ) void wxPropertyGrid::DoShowPropertyError( wxPGProperty* WXUNUSED(property), const wxString& msg )
{ {
if ( !msg.length() ) if ( msg.empty() )
return; return;
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
@@ -3290,7 +3290,7 @@ bool wxPropertyGrid::DoOnValidationFailure( wxPGProperty* property, wxVariant& W
{ {
wxString msg = m_validationInfo.m_failureMessage; wxString msg = m_validationInfo.m_failureMessage;
if ( !msg.length() ) if ( msg.empty() )
msg = _("You have entered invalid value. Press ESC to cancel editing."); msg = _("You have entered invalid value. Press ESC to cancel editing.");
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
@@ -4339,7 +4339,7 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags )
wxStatusBar* statusbar = GetStatusBar(); wxStatusBar* statusbar = GetStatusBar();
if ( statusbar ) if ( statusbar )
{ {
if ( pHelpString && pHelpString->length() ) if ( pHelpString && !pHelpString->empty() )
{ {
// Set help box text. // Set help box text.
statusbar->SetStatusText( *pHelpString ); statusbar->SetStatusText( *pHelpString );
@@ -4361,7 +4361,7 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags )
// //
// Show help as a tool tip on the editor control. // Show help as a tool tip on the editor control.
// //
if ( pHelpString && pHelpString->length() && if ( pHelpString && !pHelpString->empty() &&
primaryCtrl ) primaryCtrl )
{ {
primaryCtrl->SetToolTip(*pHelpString); primaryCtrl->SetToolTip(*pHelpString);
@@ -6020,7 +6020,7 @@ wxPGEditor* wxPropertyGrid::DoRegisterEditorClass( wxPGEditor* editorClass,
RegisterDefaultEditors(); RegisterDefaultEditors();
wxString name = editorName; wxString name = editorName;
if ( name.length() == 0 ) if ( name.empty() )
name = editorClass->GetName(); name = editorClass->GetName();
// Existing editor under this name? // Existing editor under this name?
@@ -6421,7 +6421,7 @@ wxPGChoices wxPropertyGridPopulator::ParseChoices( const wxString& choicesString
else else
{ {
bool found = false; bool found = false;
if ( idString.length() ) if ( !idString.empty() )
{ {
wxPGHashMapS2P::iterator it = m_dictIdChoices.find(idString); wxPGHashMapS2P::iterator it = m_dictIdChoices.find(idString);
if ( it != m_dictIdChoices.end() ) if ( it != m_dictIdChoices.end() )
@@ -6497,7 +6497,7 @@ wxPGChoices wxPropertyGridPopulator::ParseChoices( const wxString& choicesString
} }
// Assign to id // Assign to id
if ( idString.length() ) if ( !idString.empty() )
m_dictIdChoices[idString] = choices.GetData(); m_dictIdChoices[idString] = choices.GetData();
} }
} }
@@ -6538,7 +6538,7 @@ bool wxPropertyGridPopulator::AddAttribute( const wxString& name,
wxString valuel = value.Lower(); wxString valuel = value.Lower();
wxVariant variant; wxVariant variant;
if ( type.length() == 0 ) if ( type.empty() )
{ {
long v; long v;

View File

@@ -699,7 +699,7 @@ void wxPropertyGridInterface::SetPropertyCell( wxPGPropArg id,
wxPG_PROP_ARG_CALL_PROLOG() wxPG_PROP_ARG_CALL_PROLOG()
wxPGCell& cell = p->GetCell(column); wxPGCell& cell = p->GetCell(column);
if ( text.length() && text != wxPG_LABEL ) if ( !text.empty() && text != wxPG_LABEL )
cell.SetText(text); cell.SetText(text);
if ( bitmap.IsOk() ) if ( bitmap.IsOk() )
cell.SetBitmap(bitmap); cell.SetBitmap(bitmap);
@@ -932,7 +932,7 @@ wxString wxPropertyGridInterface::SaveEditableState( int includedStates ) const
} }
// Remove last '|' // Remove last '|'
if ( result.length() ) if ( !result.empty() )
result.RemoveLast(); result.RemoveLast();
return result; return result;
@@ -1034,13 +1034,13 @@ bool wxPropertyGridInterface::RestoreEditableState( const wxString& src, int res
{ {
if ( pageState->IsDisplayed() ) if ( pageState->IsDisplayed() )
{ {
if ( values[0].length() ) if ( !values[0].empty() )
newSelection = GetPropertyByName(value); newSelection = GetPropertyByName(value);
pgSelectionSet = true; pgSelectionSet = true;
} }
else else
{ {
if ( values[0].length() ) if ( !values[0].empty() )
pageState->DoSetSelection(GetPropertyByName(value)); pageState->DoSetSelection(GetPropertyByName(value));
else else
pageState->DoClearSelection(); pageState->DoClearSelection();

View File

@@ -477,9 +477,9 @@ void wxPropertyGridPageState::DoSetPropertyName( wxPGProperty* p,
if ( parent->IsCategory() || parent->IsRoot() ) if ( parent->IsCategory() || parent->IsRoot() )
{ {
if ( p->GetBaseName().length() ) if ( !p->GetBaseName().empty() )
m_dictName.erase( p->GetBaseName() ); m_dictName.erase( p->GetBaseName() );
if ( newName.length() ) if ( !newName.empty() )
m_dictName[newName] = (void*) p; m_dictName[newName] = (void*) p;
} }
@@ -1498,7 +1498,7 @@ void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList& list, wx
wxASSERT( wxStrcmp(current->GetClassInfo()->GetClassName(),wxT("wxVariant")) == 0 ); wxASSERT( wxStrcmp(current->GetClassInfo()->GetClassName(),wxT("wxVariant")) == 0 );
const wxString& name = current->GetName(); const wxString& name = current->GetName();
if ( name.length() > 0 ) if ( !name.empty() )
{ {
// //
// '@' signified a special entry // '@' signified a special entry
@@ -1557,7 +1557,7 @@ void wxPropertyGridPageState::DoSetPropertyValues( const wxVariantList& list, wx
wxVariant *current = (wxVariant*)*node; wxVariant *current = (wxVariant*)*node;
const wxString& name = current->GetName(); const wxString& name = current->GetName();
if ( name.length() > 0 ) if ( !name.empty() )
{ {
// //
// '@' signified a special entry // '@' signified a special entry
@@ -1782,7 +1782,7 @@ wxPGProperty* wxPropertyGridPageState::DoInsert( wxPGProperty* parent, int index
} }
// Only add name to hashmap if parent is root or category // Only add name to hashmap if parent is root or category
if ( property->m_name.length() && if ( !property->m_name.empty() &&
(parentIsCategory || parentIsRoot) ) (parentIsCategory || parentIsRoot) )
m_dictName[property->m_name] = (void*) property; m_dictName[property->m_name] = (void*) property;
@@ -1919,7 +1919,7 @@ void wxPropertyGridPageState::DoDelete( wxPGProperty* item, bool doDelete )
} }
} }
if ( item->GetBaseName().length() && if ( !item->GetBaseName().empty() &&
(parent->IsCategory() || parent->IsRoot()) ) (parent->IsCategory() || parent->IsRoot()) )
m_dictName.erase(item->GetBaseName()); m_dictName.erase(item->GetBaseName());

View File

@@ -210,7 +210,7 @@ bool wxNumericPropertyValidator::Validate(wxWindow* parent)
wxTextCtrl* tc = static_cast<wxTextCtrl*>(wnd); wxTextCtrl* tc = static_cast<wxTextCtrl*>(wnd);
wxString text = tc->GetValue(); wxString text = tc->GetValue();
if ( !text.length() ) if ( text.empty() )
return false; return false;
return true; return true;
@@ -260,7 +260,7 @@ bool wxIntProperty::StringToValue( wxVariant& variant, const wxString& text, int
wxString s; wxString s;
long value32; long value32;
if ( text.length() == 0 ) if ( text.empty() )
{ {
variant.MakeNull(); variant.MakeNull();
return true; return true;
@@ -539,7 +539,7 @@ bool wxUIntProperty::StringToValue( wxVariant& variant, const wxString& text, in
wxString variantType = variant.GetType(); wxString variantType = variant.GetType();
bool isPrevLong = variantType == wxPG_VARIANT_TYPE_LONG; bool isPrevLong = variantType == wxPG_VARIANT_TYPE_LONG;
if ( text.length() == 0 ) if ( text.empty() )
{ {
variant.MakeNull(); variant.MakeNull();
return true; return true;
@@ -682,7 +682,7 @@ const wxString& wxPropertyGrid::DoubleToString(wxString& target,
if (!precTemplate) if (!precTemplate)
precTemplate = &text1; precTemplate = &text1;
if ( !precTemplate->length() ) if ( precTemplate->empty() )
{ {
*precTemplate = wxS("%."); *precTemplate = wxS("%.");
*precTemplate << wxString::Format( wxS("%i"), precision ); *precTemplate << wxString::Format( wxS("%i"), precision );
@@ -696,7 +696,7 @@ const wxString& wxPropertyGrid::DoubleToString(wxString& target,
target.Printf( wxS("%f"), value ); target.Printf( wxS("%f"), value );
} }
if ( removeZeroes && precision != 0 && target.length() ) if ( removeZeroes && precision != 0 && !target.empty() )
{ {
// Remove excess zeroes (do not remove this code just yet, // Remove excess zeroes (do not remove this code just yet,
// since sprintf can't do the same consistently across platforms). // since sprintf can't do the same consistently across platforms).
@@ -760,7 +760,7 @@ bool wxFloatProperty::StringToValue( wxVariant& variant, const wxString& text, i
wxString s; wxString s;
double value; double value;
if ( text.length() == 0 ) if ( text.empty() )
{ {
variant.MakeNull(); variant.MakeNull();
return true; return true;
@@ -914,7 +914,7 @@ bool wxBoolProperty::StringToValue( wxVariant& variant, const wxString& text, in
text.CmpNoCase(m_label) == 0 ) text.CmpNoCase(m_label) == 0 )
boolValue = true; boolValue = true;
if ( text.length() == 0 ) if ( text.empty() )
{ {
variant.MakeNull(); variant.MakeNull();
return true; return true;
@@ -1518,7 +1518,7 @@ bool wxFlagsProperty::StringToValue( wxVariant& variant, const wxString& text, i
// semicolons are no longer valid delimeters // semicolons are no longer valid delimeters
WX_PG_TOKENIZER1_BEGIN(text,wxS(',')) WX_PG_TOKENIZER1_BEGIN(text,wxS(','))
if ( token.length() ) if ( !token.empty() )
{ {
// Determine which one it is // Determine which one it is
long bit = IdToBit( token ); long bit = IdToBit( token );
@@ -1690,7 +1690,7 @@ bool wxPGFileDialogAdapter::DoShowDialog( wxPropertyGrid* propGrid, wxPGProperty
path = filename.GetPath(); path = filename.GetPath();
indFilter = fileProp->m_indFilter; indFilter = fileProp->m_indFilter;
if ( !path.length() && fileProp->m_basePath.length() ) if ( path.empty() && !fileProp->m_basePath.empty() )
path = fileProp->m_basePath; path = fileProp->m_basePath;
} }
else else
@@ -1781,7 +1781,7 @@ void wxFileProperty::OnSetValue()
} }
// Find index for extension. // Find index for extension.
if ( m_indFilter < 0 && fnstr.length() ) if ( m_indFilter < 0 && !fnstr.empty() )
{ {
wxString ext = filename.GetExt(); wxString ext = filename.GetExt();
int curind = 0; int curind = 0;
@@ -1798,7 +1798,7 @@ void wxFileProperty::OnSetValue()
pos = len; pos = len;
wxString found_ext = m_wildcard.substr(ext_begin, pos-ext_begin); wxString found_ext = m_wildcard.substr(ext_begin, pos-ext_begin);
if ( found_ext.length() > 0 ) if ( !found_ext.empty() )
{ {
if ( found_ext[0] == wxS('*') ) if ( found_ext[0] == wxS('*') )
{ {
@@ -1839,7 +1839,7 @@ wxString wxFileProperty::ValueToString( wxVariant& value,
return wxEmptyString; return wxEmptyString;
wxString fullName = filename.GetFullName(); wxString fullName = filename.GetFullName();
if ( !fullName.length() ) if ( fullName.empty() )
return wxEmptyString; return wxEmptyString;
if ( argFlags & wxPG_FULL_VALUE ) if ( argFlags & wxPG_FULL_VALUE )
@@ -1848,7 +1848,7 @@ wxString wxFileProperty::ValueToString( wxVariant& value,
} }
else if ( m_flags & wxPG_PROP_SHOW_FULL_FILENAME ) else if ( m_flags & wxPG_PROP_SHOW_FULL_FILENAME )
{ {
if ( m_basePath.Length() ) if ( !m_basePath.empty() )
{ {
wxFileName fn2(filename); wxFileName fn2(filename);
fn2.MakeRelativeTo(m_basePath); fn2.MakeRelativeTo(m_basePath);
@@ -2186,7 +2186,7 @@ bool wxPGArrayEditorDialog::Create( wxWindow *parent,
wxBoxSizer* topsizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* topsizer = new wxBoxSizer( wxVERTICAL );
// Message // Message
if ( message.length() ) if ( !message.empty() )
topsizer->Add( new wxStaticText(this,-1,message), topsizer->Add( new wxStaticText(this,-1,message),
0, wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL|wxALL, spacing ); 0, wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL|wxALL, spacing );
@@ -2555,7 +2555,7 @@ wxArrayStringProperty::ArrayStringToString( wxString& dst,
if ( flags & Escape ) if ( flags & Escape )
{ {
str.Replace( wxS("\\"), wxS("\\\\"), true ); str.Replace( wxS("\\"), wxS("\\\\"), true );
if ( pdr.length() ) if ( !pdr.empty() )
str.Replace( preas, pdr, true ); str.Replace( preas, pdr, true );
} }

View File

@@ -6668,13 +6668,13 @@ bool wxRichTextParagraphLayoutBox::InsertTextWithUndo(long pos, const wxString&
int length = action->GetNewParagraphs().GetOwnRange().GetLength(); int length = action->GetNewParagraphs().GetOwnRange().GetLength();
if (text.length() > 0 && text.Last() != wxT('\n')) if (!text.empty() && text.Last() != wxT('\n'))
{ {
// Don't count the newline when undoing // Don't count the newline when undoing
length --; length --;
action->GetNewParagraphs().SetPartialParagraph(true); action->GetNewParagraphs().SetPartialParagraph(true);
} }
else if (text.length() > 0 && text.Last() == wxT('\n')) else if (!text.empty() && text.Last() == wxT('\n'))
length --; length --;
action->SetPosition(pos); action->SetPosition(pos);

View File

@@ -289,7 +289,7 @@ void ScintillaWX::StartDrag() {
stc->GetEventHandler()->ProcessEvent(evt); stc->GetEventHandler()->ProcessEvent(evt);
dragText = evt.GetDragText(); dragText = evt.GetDragText();
if (dragText.length()) { if ( !dragText.empty() ) {
wxDropSource source(stc); wxDropSource source(stc);
wxTextDataObject data(dragText); wxTextDataObject data(dragText);
wxDragResult result; wxDragResult result;

View File

@@ -395,7 +395,7 @@ void wxDialUpManagerImpl::DisableAutoCheckOnlineStatus()
void wxDialUpManagerImpl::SetWellKnownHost(const wxString& hostname, int portno) void wxDialUpManagerImpl::SetWellKnownHost(const wxString& hostname, int portno)
{ {
if(hostname.length() == 0) if( hostname.empty() )
{ {
m_BeaconHost = WXDIALUP_MANAGER_DEFAULT_BEACONHOST; m_BeaconHost = WXDIALUP_MANAGER_DEFAULT_BEACONHOST;
m_BeaconPort = 80; m_BeaconPort = 80;
@@ -404,7 +404,7 @@ void wxDialUpManagerImpl::SetWellKnownHost(const wxString& hostname, int portno)
// does hostname contain a port number? // does hostname contain a port number?
wxString port = hostname.After(wxT(':')); wxString port = hostname.After(wxT(':'));
if(port.length()) if( !port.empty() )
{ {
m_BeaconHost = hostname.Before(wxT(':')); m_BeaconHost = hostname.Before(wxT(':'));
m_BeaconPort = wxAtoi(port); m_BeaconPort = wxAtoi(port);
@@ -667,7 +667,7 @@ wxDialUpManagerImpl::CheckIfconfig()
{ {
wxLogNull ln; // suppress all error messages wxLogNull ln; // suppress all error messages
wxASSERT_MSG( m_IfconfigPath.length(), wxASSERT_MSG( !m_IfconfigPath.empty(),
wxT("can't use ifconfig if it wasn't found") ); wxT("can't use ifconfig if it wasn't found") );
wxString tmpfile = wxFileName::CreateTempFileName( wxT("_wxdialuptest") ); wxString tmpfile = wxFileName::CreateTempFileName( wxT("_wxdialuptest") );

View File

@@ -255,16 +255,16 @@ wxDialUpManagerImpl::SetWellKnownHost(const wxString& hostname, int portno)
{ {
/// does hostname contain a port number? /// does hostname contain a port number?
wxString port = hostname.After(':'); wxString port = hostname.After(':');
if(port.Length()) if(port.empty())
{
m_BeaconHost = hostname.Before(':');
m_BeaconPort = atoi(port);
}
else
{ {
m_BeaconHost = hostname; m_BeaconHost = hostname;
m_BeaconPort = portno; m_BeaconPort = portno;
} }
else
{
m_BeaconHost = hostname.Before(':');
m_BeaconPort = atoi(port);
}
} }
@@ -319,7 +319,7 @@ wxDialUpManagerImpl::CheckStatusInternal(void)
// Let's try the ifconfig method first, should be fastest: // Let's try the ifconfig method first, should be fastest:
if(m_CanUseIfconfig != 0) // unknown or yes if(m_CanUseIfconfig != 0) // unknown or yes
{ {
wxASSERT(m_IfconfigPath.length()); wxASSERT( !m_IfconfigPath.empty() );
wxString tmpfile = wxFileName::CreateTempFileName("_wxdialuptest"); wxString tmpfile = wxFileName::CreateTempFileName("_wxdialuptest");
wxString cmd = "/bin/sh -c \'"; wxString cmd = "/bin/sh -c \'";

View File

@@ -1556,7 +1556,7 @@ void wxTextCtrl::DrawLine( wxDC &dc, int x, int y, const wxString &line2, int li
size_t pos = 0; size_t pos = 0;
wxString token( GetNextToken( line, pos ) ); wxString token( GetNextToken( line, pos ) );
while (!token.IsNull()) while ( !token.empty() )
{ {
if (m_keywords.Index( token ) != wxNOT_FOUND) if (m_keywords.Index( token ) != wxNOT_FOUND)
{ {

View File

@@ -140,7 +140,7 @@ public:
{ {
const XRCWidgetData& w = m_wdata.Item(i); const XRCWidgetData& w = m_wdata.Item(i);
if( !CanBeUsedWithXRCCTRL(w.GetClass()) ) continue; if( !CanBeUsedWithXRCCTRL(w.GetClass()) ) continue;
if( w.GetName().Length() == 0 ) continue; if( w.GetName().empty() ) continue;
file.Write( file.Write(
wxT(" ") + w.GetClass() + wxT("* ") + w.GetName() wxT(" ") + w.GetClass() + wxT("* ") + w.GetName()
+ wxT(";\n")); + wxT(";\n"));
@@ -155,7 +155,7 @@ public:
{ {
const XRCWidgetData& w = m_wdata.Item(i); const XRCWidgetData& w = m_wdata.Item(i);
if( !CanBeUsedWithXRCCTRL(w.GetClass()) ) continue; if( !CanBeUsedWithXRCCTRL(w.GetClass()) ) continue;
if( w.GetName().Length() == 0 ) continue; if( w.GetName().empty() ) continue;
file.Write( wxT(" ") file.Write( wxT(" ")
+ w.GetName() + w.GetName()
+ wxT(" = XRCCTRL(*this,\"") + wxT(" = XRCCTRL(*this,\"")