diff --git a/common/eagle_parser.cpp b/common/eagle_parser.cpp index e63b30bea2..2d5be8b8e8 100644 --- a/common/eagle_parser.cpp +++ b/common/eagle_parser.cpp @@ -43,14 +43,14 @@ using std::string; template<> -string Convert( const wxString& aValue ) +string Convert( wxString aValue ) { return aValue.ToStdString(); } template <> -double Convert( const wxString& aValue ) +double Convert( wxString aValue ) { double value; @@ -63,7 +63,7 @@ double Convert( const wxString& aValue ) template <> -int Convert( const wxString& aValue ) +int Convert( wxString aValue ) { if( aValue.IsEmpty() ) throw XML_PARSER_ERROR( "Conversion to int failed. Original value is empty." ); @@ -73,7 +73,7 @@ int Convert( const wxString& aValue ) template <> -bool Convert( const wxString& aValue ) +bool Convert( wxString aValue ) { if( aValue != "yes" && aValue != "no" ) throw XML_PARSER_ERROR( "Conversion to bool failed. Original value, '" + @@ -87,7 +87,7 @@ bool Convert( const wxString& aValue ) /// parse an Eagle XML "rot" field. Unfortunately the DTD seems not to explain /// this format very well. [S][M]R. Examples: "R90", "MR180", "SR180" template<> -EROT Convert( const wxString& aRot ) +EROT Convert( wxString aRot ) { EROT value; @@ -638,7 +638,7 @@ wxPoint kicad_arc_center( const wxPoint& aStart, const wxPoint& aEnd, double aAn double dx = aEnd.x - aStart.x, dy = aEnd.y - aStart.y; wxPoint mid = ( aStart + aEnd ) / 2; - double dlen = sqrt( dx * dx + dy * dy ); + double dlen = sqrt( dx*dx + dy*dy ); double dist = dlen / ( 2 * tan( DEG2RAD( aAngle ) / 2 ) ); wxPoint center( diff --git a/eeschema/sch_eagle_plugin.cpp b/eeschema/sch_eagle_plugin.cpp index 2ef5d5a810..e95af738e4 100644 --- a/eeschema/sch_eagle_plugin.cpp +++ b/eeschema/sch_eagle_plugin.cpp @@ -2,7 +2,6 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 CERN -* * @author Alejandro García Montoro * * This program is free software; you can redistribute it and/or @@ -33,24 +32,22 @@ using namespace std; -typedef unordered_map< string, wxXmlNode* > NodeMap; - -NodeMap mapChildren( wxXmlNode* currentNode ) +NODE_MAP mapChildren( wxXmlNode* aCurrentNode ) { // Map node_name -> node_pointer - NodeMap nodesMap; + NODE_MAP nodesMap; // Loop through all children mapping them in nodesMap - currentNode = currentNode->GetChildren(); - while( currentNode ) + aCurrentNode = aCurrentNode->GetChildren(); + while( aCurrentNode ) { // Create a new pair in the map // key: current node name // value: current node pointer - nodesMap[currentNode->GetName().ToStdString()] = currentNode; + nodesMap[aCurrentNode->GetName().ToStdString()] = aCurrentNode; // Get next child - currentNode = currentNode->GetNext(); + aCurrentNode = aCurrentNode->GetNext(); } return nodesMap; @@ -74,8 +71,6 @@ void kicadLayer( int aEagleLayer ) * * * - * - * */ switch( aEagleLayer ) @@ -116,7 +111,6 @@ const wxString SCH_EAGLE_PLUGIN::GetFileExtension() const } - int SCH_EAGLE_PLUGIN::GetModifyHash() const { return 0; @@ -125,7 +119,6 @@ int SCH_EAGLE_PLUGIN::GetModifyHash() const void SCH_EAGLE_PLUGIN::SaveLibrary( const wxString& aFileName, const PROPERTIES* aProperties ) { - } @@ -163,7 +156,7 @@ SCH_SHEET* SCH_EAGLE_PLUGIN::Load( const wxString& aFileName, KIWAY* aKiway, m_version = currentNode->GetAttribute( "version", "0.0" ); // Map all children into a readable dictionary - NodeMap children = mapChildren( currentNode ); + NODE_MAP children = mapChildren( currentNode ); // TODO: handle compatibility nodes // wxXmlNode* compatibility = children["compatibility"]; @@ -179,7 +172,7 @@ SCH_SHEET* SCH_EAGLE_PLUGIN::Load( const wxString& aFileName, KIWAY* aKiway, void SCH_EAGLE_PLUGIN::loadDrawing( wxXmlNode* aDrawingNode ) { // Map all children into a readable dictionary - NodeMap drawingChildren = mapChildren( aDrawingNode ); + NODE_MAP drawingChildren = mapChildren( aDrawingNode ); // Board nodes should not appear in .sch files // wxXmlNode* board = drawingChildren["board"] @@ -204,10 +197,10 @@ void SCH_EAGLE_PLUGIN::loadDrawing( wxXmlNode* aDrawingNode ) void SCH_EAGLE_PLUGIN::loadSchematic( wxXmlNode* aSchematicNode ) { // Map all children into a readable dictionary - NodeMap schematicChildren = mapChildren( aSchematicNode ); + NODE_MAP schematicChildren = mapChildren( aSchematicNode ); // TODO : handle classes nodes - // wxXmlNode* classes = schematicChildren["classes"]; + //wxXmlNode* classes = schematicChildren["classes"]; // TODO : handle description nodes // wxXmlNode* description = schematicChildren["description"]; @@ -230,6 +223,7 @@ void SCH_EAGLE_PLUGIN::loadSchematic( wxXmlNode* aSchematicNode ) // Loop through all the libraries wxXmlNode* libraryNode = schematicChildren["libraries"]->GetChildren(); + while( libraryNode ) { loadLibrary( libraryNode ); @@ -238,6 +232,7 @@ void SCH_EAGLE_PLUGIN::loadSchematic( wxXmlNode* aSchematicNode ) // Loop through all the sheets wxXmlNode* sheetNode = schematicChildren["sheets"]->GetChildren(); + while( sheetNode ) { loadSheet( sheetNode ); @@ -249,13 +244,14 @@ void SCH_EAGLE_PLUGIN::loadSchematic( wxXmlNode* aSchematicNode ) void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode ) { // Map all children into a readable dictionary - NodeMap sheetChildren = mapChildren( aSheetNode ); + NODE_MAP sheetChildren = mapChildren( aSheetNode ); // Loop through all busses // From the DTD: "Buses receive names which determine which signals they include. // A bus is a drawing object. It does not create any electrical connections. // These are always created by means of the nets and their names." wxXmlNode* busNode = sheetChildren["busses"]->GetChildren(); + while( busNode ) { // Get the bus name @@ -271,6 +267,7 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode ) // Loop through all nets // From the DTD: "Net is an electrical connection in a schematic." wxXmlNode* netNode = sheetChildren["nets"]->GetChildren(); + while( netNode ) { // Get the net name and class @@ -286,6 +283,7 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode ) // Loop through all instances wxXmlNode* instanceNode = sheetChildren["instances"]->GetChildren(); + while( instanceNode ) { loadInstance( instanceNode ); @@ -294,6 +292,7 @@ void SCH_EAGLE_PLUGIN::loadSheet( wxXmlNode* aSheetNode ) // Loop through all moduleinsts wxXmlNode* moduleinstNode = sheetChildren["moduleinsts"]->GetChildren(); + while( moduleinstNode ) { loadModuleinst( moduleinstNode ); @@ -431,13 +430,13 @@ void SCH_EAGLE_PLUGIN::loadLibrary( wxXmlNode* aLibraryNode ) wxString libName = aLibraryNode->GetAttribute( "name" ); // Query all children and map them into a readable dictionary - NodeMap libraryChildren = mapChildren( aLibraryNode ); + NODE_MAP libraryChildren = mapChildren( aLibraryNode ); // TODO: Do something with the description // wxXmlNode* libraryChildren["description"]; // Loop through the devicesets and load each of them - // wxXmlNode* devicesetNode = libraryChildren["devicesets"].GetChildren(); + // wxXmlNode* devicesetNode = libraryChildren["devicesets"]->GetChildren(); // while( devicesetNode ) // { // loadDeviceset( devicesetNode ); @@ -445,7 +444,7 @@ void SCH_EAGLE_PLUGIN::loadLibrary( wxXmlNode* aLibraryNode ) // } // Loop through the packages and load each of them - // wxXmlNode* packageNode = libraryChildren["packages"].GetChildren(); + // wxXmlNode* packageNode = libraryChildren["packages"]->GetChildren(); // while( packageNode ) // { // loadPackage( packageNode ); @@ -454,6 +453,7 @@ void SCH_EAGLE_PLUGIN::loadLibrary( wxXmlNode* aLibraryNode ) // Loop through the symbols and load each of them wxXmlNode* symbolNode = libraryChildren["symbols"]->GetChildren(); + while( symbolNode ) { loadSymbol( symbolNode ); @@ -466,7 +466,7 @@ LIB_PART* SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode ) { // Create a new part with the symbol name wxString symbolName = aSymbolNode->GetAttribute( "name" ); - std::unique_ptr< LIB_PART > part( new LIB_PART( symbolName ) ); + std::unique_ptr part( new LIB_PART( symbolName ) ); wxXmlNode* currentNode = aSymbolNode->GetChildren(); @@ -476,11 +476,13 @@ LIB_PART* SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode ) if( nodeName == "description" ) { - // TODO: Do something with the description + // TODO + wxASSERT_MSG( false, "'description' nodes are not implemented yet" ); } else if( nodeName == "dimension" ) { - // TODO: Handle dimension + // TODO + wxASSERT_MSG( false, "'description' nodes are not implemented yet" ); } else if( nodeName == "frame" ) { @@ -516,6 +518,7 @@ LIB_PART* SCH_EAGLE_PLUGIN::loadSymbol( wxXmlNode* aSymbolNode ) return part.release(); } + LIB_CIRCLE* SCH_EAGLE_PLUGIN::loadCircle( LIB_PART* aPart, wxXmlNode* aCircleNode ) { unique_ptr< LIB_CIRCLE > circle( new LIB_CIRCLE( aPart.get() ) ); diff --git a/eeschema/sch_eagle_plugin.h b/eeschema/sch_eagle_plugin.h index d76247fc78..8e46761337 100644 --- a/eeschema/sch_eagle_plugin.h +++ b/eeschema/sch_eagle_plugin.h @@ -2,7 +2,6 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 CERN -* * @author Alejandro García Montoro * * This program is free software; you can redistribute it and/or diff --git a/include/eagle_parser.h b/include/eagle_parser.h index fbbab2ec3e..2d8a883e04 100644 --- a/include/eagle_parser.h +++ b/include/eagle_parser.h @@ -3,7 +3,7 @@ * * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck * Copyright (C) 2012-2016 KiCad Developers, see AUTHORS.txt for contributors. - * Copyright (C) 2017 CERN. + * Copyright (C) 2017 CERN * @author Alejandro García Montoro * * This program is free software; you can redistribute it and/or @@ -45,8 +45,8 @@ using std::string; class MODULE; -typedef std::unordered_map< string, wxXmlNode* > NODE_MAP; -typedef std::map< string, MODULE* > MODULE_MAP; +typedef std::unordered_map NODE_MAP; +typedef std::map MODULE_MAP; /** @@ -98,7 +98,7 @@ struct TRIPLET */ class XPATH { - std::vector p; + std::vector p; public: void push( const char* aPathSegment, const char* aAttribute="" ) @@ -159,7 +159,7 @@ public: * type T is unknown. */ template -T Convert( const wxString& aValue ) +T Convert( wxString aValue ) { throw XML_PARSER_ERROR( "Conversion failed. Unknown type." ); } @@ -196,7 +196,7 @@ public: * aData is empty, the attribute is understood as unavailable; otherwise, the * conversion to T is tried. */ - OPTIONAL_XML_ATTRIBUTE( const wxString& aData ) + OPTIONAL_XML_ATTRIBUTE( wxString aData ) { m_isAvailable = !aData.IsEmpty(); @@ -229,7 +229,7 @@ public: * @param aData is a wxString that should be converted to T. If the string is empty, the * attribute is set to unavailable. */ - OPTIONAL_XML_ATTRIBUTE& operator =( const wxString& aData ) + OPTIONAL_XML_ATTRIBUTE& operator =( wxString aData ) { m_isAvailable = !aData.IsEmpty(); @@ -268,7 +268,7 @@ public: * tries to convert a string to the base type. * @param aString is the string that will be converted to the base type. */ - void Set( const wxString& aString ) + void Set( wxString aString ) { m_data = Convert( aString ); }