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

The parser for reading the KiCad s-expression netlist format. More...

#include <kicad_netlist_parser.h>

Inheritance diagram for KICAD_NETLIST_PARSER:

Public Member Functions

 KICAD_NETLIST_PARSER (LINE_READER *aReader, NETLIST *aNetlist)
 
void Parse ()
 Function Parse parse the full netlist.
 
const char * getTokenName (NL_T::T aTok)
 

Private Member Functions

void skipCurrent ()
 Skip the current token level, i.e search for the RIGHT parenthesis which closes the current description.
 
void parseComponent ()
 Parse a component description: (comp (ref P1) (value DB25FEMELLE) (footprint DB25FC) (libsource (lib conn) (part DB25)) (property (name PINCOUNT) (value 25)) (sheetpath (names /) (tstamps /)) (tstamp 3256759C))
 
void parseNet ()
 Parse a net section (net (code 20) (name /PC-A0) (node (ref BUS1) (pin 62)) (node (ref U3) (pin 3)) (node (ref U9) (pin M6)))
 
void parseLibPartList ()
 Read the section "libparts" in the netlist: (libparts (libpart (lib device) (part C) (description "Condensateur non polarise") (footprints (fp SM*) (fp C?) (fp C1-1)) (fields (field (name Reference) C) (field (name Value) C)) (pins (pin (num 1) (name ~) (type passive)) (pin (num 2) (name ~) (type passive))))
 

Private Attributes

NL_T::T token
 
LINE_READERm_lineReader
 The line reader used to parse the netlist. Not owned.
 
NETLISTm_netlist
 The netlist to parse into. Not owned.
 

Detailed Description

The parser for reading the KiCad s-expression netlist format.

Definition at line 32 of file kicad_netlist_parser.h.

Constructor & Destructor Documentation

◆ KICAD_NETLIST_PARSER()

KICAD_NETLIST_PARSER::KICAD_NETLIST_PARSER ( LINE_READER aReader,
NETLIST aNetlist 
)

Definition at line 55 of file kicad_netlist_reader.cpp.

References m_lineReader, m_netlist, and token.

Member Function Documentation

◆ getTokenName()

const char * KICAD_NETLIST_PARSER::getTokenName ( NL_T::T  aTok)
inline

Definition at line 44 of file kicad_netlist_parser.h.

◆ Parse()

void KICAD_NETLIST_PARSER::Parse ( )

Function Parse parse the full netlist.

Definition at line 84 of file kicad_netlist_reader.cpp.

References parseComponent(), parseLibPartList(), parseNet(), skipCurrent(), and token.

Referenced by KICAD_NETLIST_READER::LoadNetlist().

◆ parseComponent()

void KICAD_NETLIST_PARSER::parseComponent ( )
private

Parse a component description: (comp (ref P1) (value DB25FEMELLE) (footprint DB25FC) (libsource (lib conn) (part DB25)) (property (name PINCOUNT) (value 25)) (sheetpath (names /) (tstamps /)) (tstamp 3256759C))

Definition at line 282 of file kicad_netlist_reader.cpp.

References _, NETLIST::AddComponent(), From_UTF8(), library, m_netlist, name, LIB_ID::Parse(), path, COMPONENT::SetComponentClassNames(), COMPONENT::SetFields(), COMPONENT::SetHumanReadablePath(), COMPONENT::SetLibrary(), COMPONENT::SetName(), COMPONENT::SetProperties(), skipCurrent(), THROW_IO_ERROR, and token.

Referenced by Parse().

◆ parseLibPartList()

void KICAD_NETLIST_PARSER::parseLibPartList ( )
private

Read the section "libparts" in the netlist: (libparts (libpart (lib device) (part C) (description "Condensateur non polarise") (footprints (fp SM*) (fp C?) (fp C1-1)) (fields (field (name Reference) C) (field (name Value) C)) (pins (pin (num 1) (name ~) (type passive)) (pin (num 2) (name ~) (type passive))))

And add the strings giving the footprint filter (subsection footprints) of the corresponding footprint info

This section is used by CvPcb, and is not useful in Pcbnew, therefore it it not always read

Definition at line 520 of file kicad_netlist_reader.cpp.

References From_UTF8(), NETLIST::GetComponent(), NETLIST::GetCount(), COMPONENT::IsLibSource(), m_netlist, COMPONENT::SetFootprintFilters(), COMPONENT::SetPinCount(), skipCurrent(), and token.

Referenced by Parse().

◆ parseNet()

void KICAD_NETLIST_PARSER::parseNet ( )
private

Parse a net section (net (code 20) (name /PC-A0) (node (ref BUS1) (pin 62)) (node (ref U3) (pin 3)) (node (ref U9) (pin M6)))

and set the corresponding pads netnames

Definition at line 178 of file kicad_netlist_reader.cpp.

References From_UTF8(), NETLIST::GetComponentByReference(), m_netlist, name, skipCurrent(), and token.

Referenced by Parse().

◆ skipCurrent()

void KICAD_NETLIST_PARSER::skipCurrent ( )
private

Skip the current token level, i.e search for the RIGHT parenthesis which closes the current description.

Definition at line 64 of file kicad_netlist_reader.cpp.

References token.

Referenced by Parse(), parseComponent(), parseLibPartList(), and parseNet().

Member Data Documentation

◆ m_lineReader

LINE_READER* KICAD_NETLIST_PARSER::m_lineReader
private

The line reader used to parse the netlist. Not owned.

Definition at line 100 of file kicad_netlist_parser.h.

Referenced by KICAD_NETLIST_PARSER().

◆ m_netlist

NETLIST* KICAD_NETLIST_PARSER::m_netlist
private

The netlist to parse into. Not owned.

Definition at line 101 of file kicad_netlist_parser.h.

Referenced by KICAD_NETLIST_PARSER(), parseComponent(), parseLibPartList(), and parseNet().

◆ token

NL_T::T KICAD_NETLIST_PARSER::token
private

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