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