KiCad PCB EDA Suite
Loading...
Searching...
No Matches
LEGACY_NETLIST_READER Class Reference

Read the KiCad legacy and the old Orcad netlist formats. More...

#include <netlist_reader.h>

Inheritance diagram for LEGACY_NETLIST_READER:
NETLIST_READER

Public Types

enum  NETLIST_FILE_T { UNKNOWN = -1 , ORCAD , LEGACY , KICAD }
 

Public Member Functions

 LEGACY_NETLIST_READER (LINE_READER *aLineReader, NETLIST *aNetlist, CMP_READER *aFootprintLinkReader=nullptr)
 
virtual void LoadNetlist () override
 Read the netlist file in the legacy format into aNetlist.
 

Static Public Member Functions

static NETLIST_FILE_T GuessNetlistFileType (LINE_READER *aLineReader)
 Look at aFileHeaderLine to see if it matches any of the netlist file types it knows about.
 
static NETLIST_READERGetNetlistReader (NETLIST *aNetlist, const wxString &aNetlistFileName, const wxString &aCompFootprintFileName=wxEmptyString)
 Attempt to determine the net list file type of aNetlistFileName and return the appropriate NETLIST_READER type.
 

Protected Attributes

NETLISTm_netlist
 The net list to read the file(s) into.
 
bool m_loadFootprintFilters
 Load the component footprint filters section if true.
 
bool m_loadNets
 Load the nets section of the netlist file if true.
 
LINE_READERm_lineReader
 The line reader of the netlist.
 
CMP_READERm_footprintReader
 The reader used to load the footprint links. If NULL, footprint links are not read.
 

Private Member Functions

COMPONENTloadComponent (char *aText)
 Read the aLine containing the description of a component from a legacy format netlist and add it to the netlist.
 
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.
 

Detailed Description

Read the KiCad legacy and the old Orcad netlist formats.

The KiCad legacy netlist format was derived directly from an old Orcad netlist format. The primary difference is the header was changed so this reader can read both formats.

Definition at line 179 of file netlist_reader.h.

Member Enumeration Documentation

◆ NETLIST_FILE_T

Enumerator
UNKNOWN 
ORCAD 
LEGACY 
KICAD 

Definition at line 97 of file netlist_reader.h.

Constructor & Destructor Documentation

◆ LEGACY_NETLIST_READER()

LEGACY_NETLIST_READER::LEGACY_NETLIST_READER ( LINE_READER aLineReader,
NETLIST aNetlist,
CMP_READER aFootprintLinkReader = nullptr 
)
inline

Definition at line 226 of file netlist_reader.h.

Member Function Documentation

◆ GetNetlistReader()

NETLIST_READER * NETLIST_READER::GetNetlistReader ( NETLIST aNetlist,
const wxString &  aNetlistFileName,
const wxString &  aCompFootprintFileName = wxEmptyString 
)
staticinherited

Attempt to determine the net list file type of aNetlistFileName and return the appropriate NETLIST_READER type.

Parameters
aNetlistis the netlist to load aNetlistFileName into.
aNetlistFileNameis the full path and file name of the net list to read.
aCompFootprintFileNameis the full path and file name of the component footprint associations to read. Set to wxEmptyString if loading the footprint association file is not required.
Returns
the appropriate NETLIST_READER if aNetlistFileName is a valid netlist or NULL if aNetlistFileName is not a valid netlist files.

Definition at line 82 of file netlist_reader.cpp.

References NETLIST_READER::GuessNetlistFileType(), NETLIST_READER::KICAD, NETLIST_READER::LEGACY, and NETLIST_READER::ORCAD.

Referenced by TEST_NETLIST_EXPORTER_KICAD_FIXTURE::CompareNetlists(), and PCB_EDIT_FRAME::ReadNetlistFromFile().

◆ GuessNetlistFileType()

NETLIST_READER::NETLIST_FILE_T NETLIST_READER::GuessNetlistFileType ( LINE_READER aLineReader)
staticinherited

Look at aFileHeaderLine to see if it matches any of the netlist file types it knows about.

Parameters
aLineReaderis the LINE_READER object containing lines from the netlist to test.
Returns
the NETLIST_FILE_T of aLineReader.

Definition at line 49 of file netlist_reader.cpp.

References From_UTF8(), NETLIST_READER::KICAD, NETLIST_READER::LEGACY, LINE_READER::Line(), NETLIST_READER::ORCAD, LINE_READER::ReadLine(), and NETLIST_READER::UNKNOWN.

Referenced by NETLIST_READER::GetNetlistReader().

◆ loadComponent()

COMPONENT * LEGACY_NETLIST_READER::loadComponent ( char *  aText)
private

Read the aLine containing the description of a component from a legacy format netlist and add it to the netlist.

Analyze the first line of a component description in netlist: ( /40C08647 $noname R20 4.7K {Lib=R}

Parameters
aTextcontains the first line of description.
Returns
the new component created by parsing aLine.
Exceptions
PARSE_ERRORwhen aLine is not a valid component description.

Definition at line 94 of file legacy_netlist_reader.cpp.

References _, NETLIST::AddComponent(), From_UTF8(), LINE_READER::GetSource(), LINE_READER::Length(), LINE_READER::LineNumber(), NETLIST_READER::m_lineReader, NETLIST_READER::m_netlist, name, path, LIB_ID::SetLibItemName(), COMPONENT::SetName(), text, and THROW_PARSE_ERROR.

Referenced by LoadNetlist().

◆ loadFootprintFilters()

void LEGACY_NETLIST_READER::loadFootprintFilters ( )
private

Load the footprint filter section of netlist file.

Sample legacy footprint filter section: { Allowed footprints by component: $component R11 R? SM0603 SM0805 R?-* SM1206 $endlist $endfootprintlist }

Exceptions
IO_ERRORif a file IO error occurs.
PARSE_ERRORif an error occurs while parsing the file.

Definition at line 208 of file legacy_netlist_reader.cpp.

References _, From_UTF8(), NETLIST::GetComponentByReference(), LINE_READER::GetSource(), LINE_READER::Length(), LINE_READER::LineNumber(), NETLIST_READER::m_lineReader, NETLIST_READER::m_netlist, LINE_READER::ReadLine(), COMPONENT::SetFootprintFilters(), and THROW_PARSE_ERROR.

Referenced by LoadNetlist().

◆ loadNet()

void LEGACY_NETLIST_READER::loadNet ( char *  aText,
COMPONENT aComponent 
)
private

Function loadNet read a component net description from aText.

Parameters
aTextis current line read from the netlist.
aComponentis the component to add the net to.
Exceptions
PARSE_ERRORif a error occurs reading aText.

Definition at line 174 of file legacy_netlist_reader.cpp.

References _, COMPONENT::AddNet(), From_UTF8(), LINE_READER::GetSource(), LINE_READER::Length(), LINE_READER::LineNumber(), NETLIST_READER::m_lineReader, and THROW_PARSE_ERROR.

Referenced by LoadNetlist().

◆ LoadNetlist()

void LEGACY_NETLIST_READER::LoadNetlist ( )
overridevirtual

Read the netlist file in the legacy format into aNetlist.

The legacy netlist format is: # EESchema Netlist Version 1.0 generee le 18/5/2005-12:30:22 ( ( 40C08647 $noname R20 4,7K {Lib=R} ( 1 VCC ) ( 2 MODB_1 ) ) ( 40C0863F $noname R18 4,7_k {Lib=R} ( 1 VCC ) ( 2 MODA_1 ) ) } #End

Exceptions
IO_ERRORif a file IO error occurs.
PARSE_ERRORif an error occurs while parsing the file.

Implements NETLIST_READER.

Definition at line 32 of file legacy_netlist_reader.cpp.

References LINE_READER::Line(), CMP_READER::Load(), loadComponent(), loadFootprintFilters(), loadNet(), NETLIST_READER::m_footprintReader, NETLIST_READER::m_lineReader, NETLIST_READER::m_loadFootprintFilters, NETLIST_READER::m_netlist, LINE_READER::ReadLine(), and StrPurge().

Member Data Documentation

◆ m_footprintReader

CMP_READER* NETLIST_READER::m_footprintReader
protectedinherited

The reader used to load the footprint links. If NULL, footprint links are not read.

Definition at line 169 of file netlist_reader.h.

Referenced by LoadNetlist(), KICAD_NETLIST_READER::LoadNetlist(), NETLIST_READER::NETLIST_READER(), and NETLIST_READER::~NETLIST_READER().

◆ m_lineReader

LINE_READER* NETLIST_READER::m_lineReader
protectedinherited

◆ m_loadFootprintFilters

bool NETLIST_READER::m_loadFootprintFilters
protectedinherited

Load the component footprint filters section if true.

Definition at line 164 of file netlist_reader.h.

Referenced by LoadNetlist(), and NETLIST_READER::NETLIST_READER().

◆ m_loadNets

bool NETLIST_READER::m_loadNets
protectedinherited

Load the nets section of the netlist file if true.

Definition at line 165 of file netlist_reader.h.

Referenced by NETLIST_READER::NETLIST_READER().

◆ m_netlist

NETLIST* NETLIST_READER::m_netlist
protectedinherited

The net list to read the file(s) into.

Definition at line 163 of file netlist_reader.h.

Referenced by loadComponent(), loadFootprintFilters(), LoadNetlist(), KICAD_NETLIST_READER::LoadNetlist(), and NETLIST_READER::NETLIST_READER().


The documentation for this class was generated from the following files: