diff --git a/qa/tools/pns/pns_log_file.cpp b/qa/tools/pns/pns_log_file.cpp index 155ac67d03..9e2f3564b4 100644 --- a/qa/tools/pns/pns_log_file.cpp +++ b/qa/tools/pns/pns_log_file.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2020-2022 KiCad Developers. + * Copyright (C) 2020-2023 KiCad Developers. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -43,7 +43,7 @@ BOARD_CONNECTED_ITEM* PNS_LOG_FILE::ItemById( const PNS::LOGGER::EVENT_ENTRY& ev { BOARD_CONNECTED_ITEM* parent = nullptr; - for( auto item : m_board->AllConnectedItems() ) + for( BOARD_CONNECTED_ITEM* item : m_board->AllConnectedItems() ) { if( item->m_Uuid == evt.uuid ) { @@ -75,8 +75,8 @@ std::shared_ptr parseShape( SHAPE_TYPE expectedType, wxStringTokenizer& a if( type == SHAPE_TYPE::SH_SEGMENT ) { - std::shared_ptr sh( new SHAPE_SEGMENT ); - VECTOR2I a,b; + std::shared_ptr sh( new SHAPE_SEGMENT ); + VECTOR2I a, b; a.x = wxAtoi( aTokens.GetNextToken() ); a.y = wxAtoi( aTokens.GetNextToken() ); b.x = wxAtoi( aTokens.GetNextToken() ); @@ -86,10 +86,9 @@ std::shared_ptr parseShape( SHAPE_TYPE expectedType, wxStringTokenizer& a sh->SetWidth( width ); return sh; } - else if ( type == SHAPE_TYPE::SH_CIRCLE ) + else if( type == SHAPE_TYPE::SH_CIRCLE ) { - - std::shared_ptr sh( new SHAPE_CIRCLE ); + std::shared_ptr sh( new SHAPE_CIRCLE ); VECTOR2I a; a.x = wxAtoi( aTokens.GetNextToken() ); a.y = wxAtoi( aTokens.GetNextToken() ); @@ -105,7 +104,7 @@ std::shared_ptr parseShape( SHAPE_TYPE expectedType, wxStringTokenizer& a bool PNS_LOG_FILE::parseCommonPnsProps( PNS::ITEM* aItem, const wxString& cmd, wxStringTokenizer& aTokens ) { - if( cmd == "net" ) + if( cmd == wxS( "net" ) ) { if( aItem->Parent() && aItem->Parent()->GetBoard() ) { @@ -115,7 +114,7 @@ bool PNS_LOG_FILE::parseCommonPnsProps( PNS::ITEM* aItem, const wxString& cmd, return false; } - else if( cmd == "layers" ) + else if( cmd == wxS( "layers" ) ) { int start = wxAtoi( aTokens.GetNextToken() ); int end = wxAtoi( aTokens.GetNextToken() ); @@ -128,24 +127,25 @@ bool PNS_LOG_FILE::parseCommonPnsProps( PNS::ITEM* aItem, const wxString& cmd, PNS::SEGMENT* PNS_LOG_FILE::parsePnsSegmentFromString( PNS::SEGMENT* aSeg, wxStringTokenizer& aTokens ) { - PNS::SEGMENT* seg = new ( PNS::SEGMENT ); + PNS::SEGMENT* seg = new PNS::SEGMENT(); while( aTokens.CountTokens() ) { - wxString cmd = aTokens.GetNextToken(); - if( !parseCommonPnsProps( seg, cmd, aTokens ) ) + wxString cmd = aTokens.GetNextToken(); + + if( !parseCommonPnsProps( seg, cmd, aTokens ) ) + { + if( cmd == wxS( "shape" ) ) { - if ( cmd == "shape" ) - { - auto sh = parseShape( SH_SEGMENT, aTokens ); + std::shared_ptr sh = parseShape( SH_SEGMENT, aTokens ); - if(!sh) - return nullptr; + if( !sh ) + return nullptr; - seg->SetShape( *static_cast(sh.get()) ); + seg->SetShape( *static_cast(sh.get()) ); - } } + } } return seg; @@ -153,30 +153,31 @@ PNS::SEGMENT* PNS_LOG_FILE::parsePnsSegmentFromString( PNS::SEGMENT* aSeg, PNS::VIA* PNS_LOG_FILE::parsePnsViaFromString( PNS::VIA* aSeg, wxStringTokenizer& aTokens ) { - PNS::VIA* via = new ( PNS::VIA ); + PNS::VIA* via = new PNS::VIA(); while( aTokens.CountTokens() ) { - wxString cmd = aTokens.GetNextToken(); - if( !parseCommonPnsProps( via, cmd, aTokens ) ) + wxString cmd = aTokens.GetNextToken(); + + if( !parseCommonPnsProps( via, cmd, aTokens ) ) + { + if( cmd == wxS( "shape" ) ) { - if ( cmd == "shape" ) - { - auto sh = parseShape( SH_CIRCLE, aTokens ); - - if(!sh) - return nullptr; - - auto *sc = static_cast( sh.get() ); - - via->SetPos( sc->GetCenter() ); - via->SetDiameter( 2 * sc->GetRadius() ); - } - else if ( cmd == "drill" ) - { - via->SetDrill( wxAtoi( aTokens.GetNextToken() ) ); - } + std::shared_ptr sh = parseShape( SH_CIRCLE, aTokens ); + + if( !sh ) + return nullptr; + + SHAPE_CIRCLE* sc = static_cast( sh.get() ); + + via->SetPos( sc->GetCenter() ); + via->SetDiameter( 2 * sc->GetRadius() ); } + else if( cmd == wxS( "drill" ) ) + { + via->SetDrill( wxAtoi( aTokens.GetNextToken() ) ); + } + } } return via; @@ -187,21 +188,21 @@ PNS::ITEM* PNS_LOG_FILE::parseItemFromString( wxStringTokenizer& aTokens ) { wxString type = aTokens.GetNextToken(); - if( type == "segment" ) + if( type == wxS( "segment" ) ) { - auto seg = new PNS::SEGMENT(); + PNS::SEGMENT* seg = new PNS::SEGMENT(); return parsePnsSegmentFromString( seg, aTokens ); } - else if( type == "via" ) + else if( type == wxS( "via" ) ) { - auto seg = new PNS::VIA(); + PNS::VIA* seg = new PNS::VIA(); return parsePnsViaFromString( seg, aTokens ); } return nullptr; } -bool comparePnsItems( const PNS::ITEM*a , const PNS::ITEM* b ) +bool comparePnsItems( const PNS::ITEM* a , const PNS::ITEM* b ) { if( a->Kind() != b->Kind() ) return false; @@ -214,8 +215,8 @@ bool comparePnsItems( const PNS::ITEM*a , const PNS::ITEM* b ) if( a->Kind() == PNS::ITEM::VIA_T ) { - auto va = static_cast(a); - auto vb = static_cast(b); + const PNS::VIA* va = static_cast(a); + const PNS::VIA* vb = static_cast(b); if( va->Diameter() != vb->Diameter() ) return false; @@ -229,8 +230,8 @@ bool comparePnsItems( const PNS::ITEM*a , const PNS::ITEM* b ) } else if ( a->Kind() == PNS::ITEM::SEGMENT_T ) { - auto sa = static_cast(a); - auto sb = static_cast(b); + const PNS::SEGMENT* sa = static_cast(a); + const PNS::SEGMENT* sb = static_cast(b); if( sa->Seg() != sb->Seg() ) return false; @@ -247,10 +248,11 @@ const std::set deduplicate( const std::vector& items ) { std::set rv; - for( auto item : items ) + for( PNS::ITEM* item : items ) { bool isDuplicate = false; - for (auto ritem : rv ) + + for( PNS::ITEM* ritem : rv ) { if( comparePnsItems( ritem, item) ) { @@ -277,21 +279,17 @@ bool PNS_LOG_FILE::COMMIT_STATE::Compare( const PNS_LOG_FILE::COMMIT_STATE& aOth for( const KIID& uuid : m_removedIds ) { if( check.m_removedIds.find( uuid ) != check.m_removedIds.end() ) - { check.m_removedIds.erase( uuid ); - } else - { return false; // removed twice? wtf - } } - auto addedItems = deduplicate( m_addedItems ); - auto chkAddedItems = deduplicate( check.m_addedItems ); + std::set addedItems = deduplicate( m_addedItems ); + std::set chkAddedItems = deduplicate( check.m_addedItems ); - for( auto item : addedItems ) + for( PNS::ITEM* item : addedItems ) { - for( auto chk : chkAddedItems ) + for( PNS::ITEM* chk : chkAddedItems ) { if( comparePnsItems( item, chk ) ) { @@ -337,16 +335,19 @@ bool PNS_LOG_FILE::Load( const wxFileName& logFileName, REPORTER* aRpt ) wxFileName fname_settings( logFileName ); fname_settings.SetExt( wxT( "settings" ) ); - aRpt->Report( wxString::Format( wxT("Loading router settings from '%s'"), fname_settings.GetFullPath() ) ); + aRpt->Report( wxString::Format( wxT( "Loading router settings from '%s'" ), + fname_settings.GetFullPath() ) ); bool ok = m_routerSettings->LoadFromRawFile( fname_settings.GetFullPath() ); if( !ok ) { - aRpt->Report( wxString::Format( wxT("Failed to load routing settings. Usign defaults.")) , RPT_SEVERITY_WARNING ); + aRpt->Report( wxString::Format( wxT( "Failed to load routing settings. Usign defaults." ) ) , + RPT_SEVERITY_WARNING ); } - aRpt->Report( wxString::Format( wxT("Loading project settings from '%s'"), fname_settings.GetFullPath() ) ); + aRpt->Report( wxString::Format( wxT( "Loading project settings from '%s'" ), + fname_settings.GetFullPath() ) ); m_settingsMgr.reset( new SETTINGS_MANAGER ( true ) ); m_settingsMgr->LoadProject( fname_project.GetFullPath() ); @@ -379,7 +380,7 @@ bool PNS_LOG_FILE::Load( const wxFileName& logFileName, REPORTER* aRpt ) catch( const PARSE_ERROR& parse_error ) { aRpt->Report( wxString::Format( "parse error : %s (%s)\n", parse_error.Problem(), - parse_error.What() ), RPT_SEVERITY_ERROR ); + parse_error.What() ), RPT_SEVERITY_ERROR ); return false; } @@ -404,20 +405,20 @@ bool PNS_LOG_FILE::Load( const wxFileName& logFileName, REPORTER* aRpt ) wxString cmd = tokens.GetNextToken(); - if( cmd == wxT("mode") ) + if( cmd == wxT( "mode" ) ) { m_mode = static_cast( wxAtoi( tokens.GetNextToken() ) ); } - else if( cmd == wxT("event") ) + else if( cmd == wxT( "event" ) ) { m_events.push_back( PNS::LOGGER::ParseEvent( line ) ); } - else if ( cmd == wxT("added") ) + else if ( cmd == wxT( "added" ) ) { - auto item = parseItemFromString( tokens ); + PNS::ITEM* item = parseItemFromString( tokens ); m_commitState.m_addedItems.push_back( item ); } - else if ( cmd == wxT("removed") ) + else if ( cmd == wxT( "removed" ) ) { m_commitState.m_removedIds.insert( KIID( tokens.GetNextToken() ) ); }