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 
32 #include <pcb_net.h>
33 
34 namespace PCAD2KICAD {
35 
37 {
38  m_compRef = wxEmptyString;
39  m_pinRef = wxEmptyString;
40 }
41 
42 
44 {
45 }
46 
47 
48 PCB_NET::PCB_NET( int aNetCode ) : m_netCode( aNetCode )
49 {
50  m_name = wxEmptyString;
51 }
52 
53 
55 {
56  int i;
57 
58  for( i = 0; i < (int) m_netNodes.GetCount(); i++ )
59  {
60  delete m_netNodes[i];
61  }
62 }
63 
64 
65 void PCB_NET::Parse( XNODE* aNode )
66 {
67  wxString propValue, s1, s2;
68  PCB_NET_NODE* netNode;
69  XNODE* lNode;
70 
71  aNode->GetAttribute( wxT( "Name" ), &propValue );
72  propValue.Trim( false );
73  propValue.Trim( true );
74  m_name = propValue;
75 
76  lNode = FindNode( aNode, wxT( "node" ) );
77 
78  while( lNode )
79  {
80  lNode->GetAttribute( wxT( "Name" ), &s2 );
81  s2.Trim( false );
82  s1 = wxEmptyString;
83 
84  while( s2.Len() > 0 && s2[0] != wxT( ' ' ) )
85  {
86  s1 = s1 + s2[0];
87  s2 = s2.Mid( 1 );
88  }
89 
90  netNode = new PCB_NET_NODE;
91  s1.Trim( false );
92  s1.Trim( true );
93  netNode->m_compRef = s1;
94 
95  s2.Trim( false );
96  s2.Trim( true );
97  netNode->m_pinRef = s2;
98  m_netNodes.Add( netNode );
99  lNode = lNode->GetNext();
100  }
101 }
102 
103 } // 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:48
XNODE holds an XML or S-expression element.
Definition: xnode.h:43
XNODE * GetNext() const
Definition: xnode.h:68
XNODE * FindNode(XNODE *aChild, const wxString &aTag)
void Parse(XNODE *aNode)
Definition: pcb_net.cpp:65