KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcad_nets.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 The 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 "
string_utils.h
"
27
28
#include <
pcad/pcad_nets.h
>
29
30
#include <
xnode.h
>
31
32
#include <wx/string.h>
33
34
namespace
PCAD2KICAD
{
35
36
wxString
ConvertNetName
(
const
wxString& aName )
37
{
38
wxString retval;
39
bool
negate =
false
;
40
41
for
(
auto
c = aName.begin(); c < aName.end(); c++ )
42
{
43
if
( *c !=
'~'
)
44
{
45
retval += *c;
46
}
47
else
if
( !negate )
48
{
49
retval +=
'~'
;
50
retval +=
'{'
;
51
negate =
true
;
52
}
53
else
54
{
55
retval +=
'}'
;
56
negate =
false
;
57
}
58
}
59
60
retval =
EscapeString
( retval,
CTX_NETNAME
);
61
return
retval;
62
}
63
64
PCAD_NET_NODE::PCAD_NET_NODE
()
65
{
66
m_CompRef
= wxEmptyString;
67
m_PinRef
= wxEmptyString;
68
}
69
70
71
PCAD_NET_NODE::~PCAD_NET_NODE
()
72
{
73
}
74
75
76
PCAD_NET::PCAD_NET
(
int
aNetCode ) :
m_NetCode
( aNetCode )
77
{
78
m_Name
= wxEmptyString;
79
}
80
81
82
PCAD_NET::~PCAD_NET
()
83
{
84
int
i;
85
86
for
( i = 0; i < (int)
m_NetNodes
.GetCount(); i++ )
87
{
88
delete
m_NetNodes
[i];
89
}
90
}
91
92
93
void
PCAD_NET::Parse
(
XNODE
* aNode )
94
{
95
wxString propValue, s1, s2;
96
PCAD_NET_NODE
* netNode;
97
XNODE
* lNode;
98
99
aNode->GetAttribute( wxT(
"Name"
), &propValue );
100
propValue.Trim(
false
);
101
propValue.Trim(
true
);
102
m_Name
=
ConvertNetName
( propValue );
103
104
lNode =
FindNode
( aNode, wxT(
"node"
) );
105
106
while
( lNode )
107
{
108
lNode->GetAttribute( wxT(
"Name"
), &s2 );
109
s2.Trim(
false
);
110
s1 = wxEmptyString;
111
112
while
( s2.Len() > 0 && s2[0] != wxT(
' '
) )
113
{
114
s1 = s1 + s2[0];
115
s2 = s2.Mid( 1 );
116
}
117
118
netNode =
new
PCAD_NET_NODE
;
119
s1.Trim(
false
);
120
s1.Trim(
true
);
121
netNode->
m_CompRef
= s1;
122
123
s2.Trim(
false
);
124
s2.Trim(
true
);
125
netNode->
m_PinRef
= s2;
126
m_NetNodes
.Add( netNode );
127
lNode = lNode->
GetNext
();
128
}
129
}
130
131
}
// namespace PCAD2KICAD
PCAD2KICAD::PCAD_NET_NODE
Definition
pcad_nets.h:41
PCAD2KICAD::PCAD_NET_NODE::m_CompRef
wxString m_CompRef
Definition
pcad_nets.h:47
PCAD2KICAD::PCAD_NET_NODE::~PCAD_NET_NODE
~PCAD_NET_NODE()
Definition
pcad_nets.cpp:71
PCAD2KICAD::PCAD_NET_NODE::PCAD_NET_NODE
PCAD_NET_NODE()
Definition
pcad_nets.cpp:64
PCAD2KICAD::PCAD_NET_NODE::m_PinRef
wxString m_PinRef
Definition
pcad_nets.h:48
PCAD2KICAD::PCAD_NET::m_NetNodes
PCAD_NET_NODES_ARRAY m_NetNodes
Definition
pcad_nets.h:62
PCAD2KICAD::PCAD_NET::m_Name
wxString m_Name
Definition
pcad_nets.h:60
PCAD2KICAD::PCAD_NET::m_NetCode
int m_NetCode
Definition
pcad_nets.h:61
PCAD2KICAD::PCAD_NET::Parse
void Parse(XNODE *aNode)
Definition
pcad_nets.cpp:93
PCAD2KICAD::PCAD_NET::PCAD_NET
PCAD_NET(int aNetCode)
Definition
pcad_nets.cpp:76
PCAD2KICAD::PCAD_NET::~PCAD_NET
~PCAD_NET()
Definition
pcad_nets.cpp:82
XNODE
An extension of wxXmlNode that can format its contents as KiCad-style s-expressions.
Definition
xnode.h:71
XNODE::GetNext
XNODE * GetNext() const
Definition
xnode.h:106
PCAD2KICAD
Definition
pcad2kicad_common.cpp:39
PCAD2KICAD::FindNode
XNODE * FindNode(XNODE *aChild, const wxString &aTag)
Definition
pcad2kicad_common.cpp:558
PCAD2KICAD::ConvertNetName
wxString ConvertNetName(const wxString &aName)
Definition
pcad_nets.cpp:36
pcad_nets.h
EscapeString
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
Definition
string_utils.cpp:182
string_utils.h
CTX_NETNAME
@ CTX_NETNAME
Definition
string_utils.h:55
xnode.h
src
pcbnew
pcb_io
pcad
pcad_nets.cpp
Generated on Tue Nov 11 2025 00:06:20 for KiCad PCB EDA Suite by
1.13.2