KiCad PCB EDA Suite
pcb_net.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2007, 2008 Lubo Racko <developer@lura.sk>
5  * Copyright (C) 2007, 2008, 2012 Alexander Lunev <al.lunev@yahoo.com>
6  * Copyright (C) 2012 KiCad Developers, see CHANGELOG.TXT for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
30 #include <wx/wx.h>
31 #include <wx/config.h>
32 
33 #include <pcb_net.h>
34 
35 namespace PCAD2KICAD {
36 
38 {
39  m_compRef = wxEmptyString;
40  m_pinRef = wxEmptyString;
41 }
42 
43 
45 {
46 }
47 
48 
49 PCB_NET::PCB_NET( int aNetCode ) : m_netCode( aNetCode )
50 {
51  m_name = wxEmptyString;
52 }
53 
54 
56 {
57  int i;
58 
59  for( i = 0; i < (int) m_netNodes.GetCount(); i++ )
60  {
61  delete m_netNodes[i];
62  }
63 }
64 
65 
66 void PCB_NET::Parse( XNODE* aNode )
67 {
68  wxString propValue, s1, s2;
69  PCB_NET_NODE* netNode;
70  XNODE* lNode;
71 
72  aNode->GetAttribute( wxT( "Name" ), &propValue );
73  propValue.Trim( false );
74  propValue.Trim( true );
75  m_name = propValue;
76 
77  lNode = FindNode( aNode, wxT( "node" ) );
78 
79  while( lNode )
80  {
81  lNode->GetAttribute( wxT( "Name" ), &s2 );
82  s2.Trim( false );
83  s1 = wxEmptyString;
84 
85  while( s2.Len() > 0 && s2[0] != wxT( ' ' ) )
86  {
87  s1 = s1 + s2[0];
88  s2 = s2.Mid( 1 );
89  }
90 
91  netNode = new PCB_NET_NODE;
92  s1.Trim( false );
93  s1.Trim( true );
94  netNode->m_compRef = s1;
95 
96  s2.Trim( false );
97  s2.Trim( true );
98  netNode->m_pinRef = s2;
99  m_netNodes.Add( netNode );
100  lNode = lNode->GetNext();
101  }
102 }
103 
104 } // namespace PCAD2KICAD
wxString m_name
Definition: pcb_net.h:54
PCB_NET_NODES_ARRAY m_netNodes
Definition: pcb_net.h:56
PCB_NET(int aNetCode)
Definition: pcb_net.cpp:49
Class XNODE holds an XML or S-expression element.
Definition: xnode.h:43
XNODE * FindNode(XNODE *aChild, wxString aTag)
void Parse(XNODE *aNode)
Definition: pcb_net.cpp:66
XNODE * GetNext() const
Definition: xnode.h:68