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 <[email protected]>
5 * Copyright (C) 2007, 2008, 2012 Alexander Lunev <[email protected]>
6 * Copyright (C) 2012-2020 KiCad Developers, see AUTHORS.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
26#include <pcad/pcb_net.h>
27
28#include <xnode.h>
29
30#include <wx/string.h>
31
32namespace PCAD2KICAD {
33
35{
36 m_CompRef = wxEmptyString;
37 m_PinRef = wxEmptyString;
38}
39
40
42{
43}
44
45
46PCB_NET::PCB_NET( int aNetCode ) : m_NetCode( aNetCode )
47{
48 m_Name = wxEmptyString;
49}
50
51
53{
54 int i;
55
56 for( i = 0; i < (int) m_NetNodes.GetCount(); i++ )
57 {
58 delete m_NetNodes[i];
59 }
60}
61
62
63void PCB_NET::Parse( XNODE* aNode )
64{
65 wxString propValue, s1, s2;
66 PCB_NET_NODE* netNode;
67 XNODE* lNode;
68
69 aNode->GetAttribute( wxT( "Name" ), &propValue );
70 propValue.Trim( false );
71 propValue.Trim( true );
72 m_Name = propValue;
73
74 lNode = FindNode( aNode, wxT( "node" ) );
75
76 while( lNode )
77 {
78 lNode->GetAttribute( wxT( "Name" ), &s2 );
79 s2.Trim( false );
80 s1 = wxEmptyString;
81
82 while( s2.Len() > 0 && s2[0] != wxT( ' ' ) )
83 {
84 s1 = s1 + s2[0];
85 s2 = s2.Mid( 1 );
86 }
87
88 netNode = new PCB_NET_NODE;
89 s1.Trim( false );
90 s1.Trim( true );
91 netNode->m_CompRef = s1;
92
93 s2.Trim( false );
94 s2.Trim( true );
95 netNode->m_PinRef = s2;
96 m_NetNodes.Add( netNode );
97 lNode = lNode->GetNext();
98 }
99}
100
101} // namespace PCAD2KICAD
PCB_NET(int aNetCode)
Definition: pcb_net.cpp:46
wxString m_Name
Definition: pcb_net.h:56
void Parse(XNODE *aNode)
Definition: pcb_net.cpp:63
PCB_NET_NODES_ARRAY m_NetNodes
Definition: pcb_net.h:58
Hold an XML or S-expression element.
Definition: xnode.h:44
XNODE * GetNext() const
Definition: xnode.h:67
XNODE * FindNode(XNODE *aChild, const wxString &aTag)