31#include <netlist_reader/netlist_reader.h>
37 bool is_comment =
false;
47 if( ( line = strchr( line,
'}' ) ) ==
nullptr )
58 && (strncasecmp( line,
"{ Allowed footprints", 20 ) == 0) )
64 if( ( line = strchr( line,
'}' ) ) ==
nullptr )
82 wxASSERT( component !=
nullptr );
100 wxString footprintName;
106 strncpy( line, aText,
sizeof(line)-1 );
107 line[
sizeof(line)-1] =
'\0';
114 if( (
text = strtok( line,
" ()\t\n" ) ) ==
nullptr )
116 msg =
_(
"Cannot parse time stamp in symbol section of netlist." );
124 if( (
text = strtok(
nullptr,
" ()\t\n" ) ) ==
nullptr )
126 msg =
_(
"Cannot parse footprint name in symbol section of netlist." );
134 if( footprintName == wxT(
"$noname" ) )
135 footprintName = wxEmptyString;
138 if( (
text = strtok(
nullptr,
" ()\t\n" ) ) ==
nullptr )
140 msg =
_(
"Cannot parse reference designator in symbol section of netlist." );
148 if( (
text = strtok(
nullptr,
" ()\t\n" ) ) ==
nullptr )
150 msg =
_(
"Cannot parse value in symbol section of netlist." );
159 if( (
text = strtok(
nullptr,
" ()\t\n" ) ) !=
nullptr )
161 name =
From_UTF8(
text ).AfterFirst( wxChar(
'=' ) ).BeforeLast( wxChar(
'}' ) );
166 if( !footprintName.IsEmpty() )
182 strncpy( line, aText,
sizeof( line ) );
183 line[
sizeof(line) - 1 ] =
'\0';
185 if( ( p = strtok( line,
" ()\t\n" ) ) ==
nullptr )
187 msg =
_(
"Cannot parse pin name in symbol net section of netlist." );
194 if( ( p = strtok(
nullptr,
" ()\t\n" ) ) ==
nullptr )
196 msg =
_(
"Cannot parse net name in symbol net section of netlist." );
203 if( (
char) netName[0] ==
'?' )
204 netName = wxEmptyString;
206 aComponent->
AddNet( pinName, netName, wxEmptyString, wxEmptyString );
212 wxArrayString filters;
219 if( strncasecmp( line,
"$endlist", 8 ) == 0 )
221 wxASSERT( component !=
nullptr );
228 if( strncasecmp( line,
"$endfootprintlist", 4 ) == 0 )
232 if( strncasecmp( line,
"$component", 10 ) == 0 )
236 cmpRef.Trim(
false );
238 component =
m_netlist->GetComponentByReference( cmpRef );
241 if( component ==
nullptr )
244 msg.Printf(
_(
"Cannot find symbol %s in footprint filter section of netlist." ),
Store all of the related component information found in a netlist.
void SetFootprintFilters(const wxArrayString &aFilters)
void AddNet(const wxString &aPinName, const wxString &aNetName, const wxString &aPinFunction, const wxString &aPinType)
void SetName(const wxString &aName)
COMPONENT * loadComponent(char *aText)
Read the aLine containing the description of a component from a legacy format netlist and add it to t...
void loadFootprintFilters()
Load the footprint filter section of netlist file.
void loadNet(char *aText, COMPONENT *aComponent)
Function loadNet read a component net description from aText.
virtual void LoadNetlist() override
Read the netlist file in the legacy format into aNetlist.
int SetLibItemName(const UTF8 &aLibItemName)
Override the library item name portion of the LIB_ID to aLibItemName.
bool m_loadFootprintFilters
Load the component footprint filters section if true.
CMP_READER * m_footprintReader
The reader used to load the footprint links. If NULL, footprint links are not read.
LINE_READER * m_lineReader
The line reader of the netlist.
NETLIST * m_netlist
The net list to read the file(s) into.
#define THROW_PARSE_ERROR(aProblem, aSource, aInputLine, aLineNumber, aByteIndex)
wxString From_UTF8(const char *cstring)
char * StrPurge(char *text)
Remove leading and training spaces, tabs and end of line chars in text.