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

Object to parser s-expression symbol library and schematic file formats. More...

#include <sch_io_kicad_sexpr_parser.h>

Inheritance diagram for SCH_IO_KICAD_SEXPR_PARSER:

Classes

struct  GROUP_INFO
 

Public Member Functions

 SCH_IO_KICAD_SEXPR_PARSER (LINE_READER *aLineReader=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr, unsigned aLineCount=0, SCH_SHEET *aRootSheet=nullptr, bool aIsAppending=false)
 
void ParseLib (LIB_SYMBOL_MAP &aSymbolLibMap)
 
LIB_SYMBOLParseSymbol (LIB_SYMBOL_MAP &aSymbolLibMap, int aFileVersion=SEXPR_SYMBOL_LIB_FILE_VERSION)
 Parse internal LINE_READER object into symbols and return all found.
 
SCH_ITEMParseSymbolDrawItem ()
 
void ParseSchematic (SCH_SHEET *aSheet, bool aIsCopyablyOnly=false, int aFileVersion=SEXPR_SCHEMATIC_FILE_VERSION)
 Parse the internal LINE_READER object into aSheet.
 
int GetParsedRequiredVersion () const
 

Private Member Functions

void checkpoint ()
 
KIID parseKIID ()
 
void parseHeader (TSCHEMATIC_T::T aHeaderType, int aFileVersion)
 
long parseHex ()
 
int parseInt ()
 
int parseInt (const char *aExpected)
 
int parseInternalUnits ()
 
int parseInternalUnits (const char *aExpected)
 
int parseInternalUnits (TSCHEMATIC_T::T aToken)
 
VECTOR2I parseXY (bool aInvertY=false)
 
bool parseBool ()
 
bool parseMaybeAbsentBool (bool aDefaultValue)
 Parses a boolean flag inside a list that existed before boolean normalization.
 
LIB_SYMBOLparseLibSymbol (LIB_SYMBOL_MAP &aSymbolLibMap)
 
void parseStroke (STROKE_PARAMS &aStroke)
 Parse stroke definition aStroke.
 
void parseFill (FILL_PARAMS &aFill)
 
void parseMargins (int &aLeft, int &aTop, int &aRight, int &aBottom)
 
void parseEDA_TEXT (EDA_TEXT *aText, bool aConvertOverbarSyntax, bool aEnforceMinTextSize=true)
 
void parsePinNames (std::unique_ptr< LIB_SYMBOL > &aSymbol)
 
void parsePinNumbers (std::unique_ptr< LIB_SYMBOL > &aSymbol)
 
SCH_FIELDparseProperty (std::unique_ptr< LIB_SYMBOL > &aSymbol)
 
SCH_SHAPEparseSymbolArc ()
 
SCH_SHAPEparseSymbolBezier ()
 
SCH_SHAPEparseSymbolCircle ()
 
SCH_PINparseSymbolPin ()
 
SCH_SHAPEparseSymbolPolyLine ()
 
SCH_SHAPEparseSymbolRectangle ()
 
SCH_ITEMparseSymbolText ()
 
SCH_TEXTBOXparseSymbolTextBox ()
 
void parsePAGE_INFO (PAGE_INFO &aPageInfo)
 
void parseTITLE_BLOCK (TITLE_BLOCK &aTitleBlock)
 
void parseSchSymbolInstances (SCH_SCREEN *aScreen)
 
void parseSchSheetInstances (SCH_SHEET *aRootSheet, SCH_SCREEN *aScreen)
 
void parseGroup ()
 
void parseGroupMembers (GROUP_INFO &aGroupInfo)
 
SCH_SHEET_PINparseSchSheetPin (SCH_SHEET *aSheet)
 
SCH_FIELDparseSchField (SCH_ITEM *aParent)
 
SCH_SYMBOLparseSchematicSymbol ()
 
SCH_BITMAPparseImage ()
 
SCH_SHEETparseSheet ()
 
SCH_JUNCTIONparseJunction ()
 
SCH_NO_CONNECTparseNoConnect ()
 
SCH_BUS_WIRE_ENTRYparseBusEntry ()
 
SCH_LINEparseLine ()
 
SCH_SHAPEparseSchPolyLine ()
 
SCH_SHAPEparseSchArc ()
 
SCH_SHAPEparseSchCircle ()
 
SCH_SHAPEparseSchRectangle ()
 
SCH_SHAPEparseSchBezier ()
 
SCH_RULE_AREAparseSchRuleArea ()
 
SCH_TEXTparseSchText ()
 
SCH_TEXTBOXparseSchTextBox ()
 
void parseSchTextBoxContent (SCH_TEXTBOX *aTextBox)
 
SCH_TABLECELLparseSchTableCell ()
 
SCH_TABLEparseSchTable ()
 
void parseBusAlias (SCH_SCREEN *aScreen)
 
void resolveGroups (SCH_SCREEN *aParent)
 

Private Attributes

int m_requiredVersion
 Set to the symbol library file version required.
 
wxString m_generatorVersion
 
int m_unit
 The current unit being parsed.
 
int m_bodyStyle
 The current body style being parsed.
 
wxString m_symbolName
 The current symbol name.
 
bool m_appending
 Appending load status.
 
std::set< KIIDm_uuids
 
PROGRESS_REPORTERm_progressReporter
 
const LINE_READERm_lineReader
 
unsigned m_lastProgressLine
 
unsigned m_lineCount
 
KIID m_rootUuid
 
SCH_SHEETm_rootSheet
 The rootsheet for full project loads or null for importing a schematic.
 
std::vector< GROUP_INFOm_groupInfos
 

Detailed Description

Object to parser s-expression symbol library and schematic file formats.

Definition at line 76 of file sch_io_kicad_sexpr_parser.h.

Constructor & Destructor Documentation

◆ SCH_IO_KICAD_SEXPR_PARSER()

SCH_IO_KICAD_SEXPR_PARSER::SCH_IO_KICAD_SEXPR_PARSER ( LINE_READER aLineReader = nullptr,
PROGRESS_REPORTER aProgressReporter = nullptr,
unsigned  aLineCount = 0,
SCH_SHEET aRootSheet = nullptr,
bool  aIsAppending = false 
)

Definition at line 76 of file sch_io_kicad_sexpr_parser.cpp.

Member Function Documentation

◆ checkpoint()

◆ GetParsedRequiredVersion()

int SCH_IO_KICAD_SEXPR_PARSER::GetParsedRequiredVersion ( ) const
inline

Definition at line 113 of file sch_io_kicad_sexpr_parser.h.

References m_requiredVersion.

Referenced by SCH_IO_KICAD_SEXPR_LIB_CACHE::Load().

◆ parseBool()

◆ parseBusAlias()

void SCH_IO_KICAD_SEXPR_PARSER::parseBusAlias ( SCH_SCREEN aScreen)
private

◆ parseBusEntry()

◆ parseEDA_TEXT()

◆ parseFill()

◆ parseGroup()

void SCH_IO_KICAD_SEXPR_PARSER::parseGroup ( )
private

◆ parseGroupMembers()

void SCH_IO_KICAD_SEXPR_PARSER::parseGroupMembers ( GROUP_INFO aGroupInfo)
private

◆ parseHeader()

void SCH_IO_KICAD_SEXPR_PARSER::parseHeader ( TSCHEMATIC_T::T  aHeaderType,
int  aFileVersion 
)
private

Definition at line 884 of file sch_io_kicad_sexpr_parser.cpp.

References m_requiredVersion, and parseInt().

Referenced by ParseLib(), and ParseSchematic().

◆ parseHex()

long SCH_IO_KICAD_SEXPR_PARSER::parseHex ( )
inlineprivate

Definition at line 135 of file sch_io_kicad_sexpr_parser.h.

◆ parseImage()

◆ parseInt() [1/2]

◆ parseInt() [2/2]

int SCH_IO_KICAD_SEXPR_PARSER::parseInt ( const char *  aExpected)
inlineprivate

Definition at line 146 of file sch_io_kicad_sexpr_parser.h.

References parseInt().

◆ parseInternalUnits() [1/3]

◆ parseInternalUnits() [2/3]

int SCH_IO_KICAD_SEXPR_PARSER::parseInternalUnits ( const char *  aExpected)
private

◆ parseInternalUnits() [3/3]

int SCH_IO_KICAD_SEXPR_PARSER::parseInternalUnits ( TSCHEMATIC_T::T  aToken)
inlineprivate

Definition at line 156 of file sch_io_kicad_sexpr_parser.h.

References parseInternalUnits().

◆ parseJunction()

SCH_JUNCTION * SCH_IO_KICAD_SEXPR_PARSER::parseJunction ( )
private

◆ parseKIID()

◆ ParseLib()

◆ parseLibSymbol()

◆ parseLine()

SCH_LINE * SCH_IO_KICAD_SEXPR_PARSER::parseLine ( )
private

◆ parseMargins()

void SCH_IO_KICAD_SEXPR_PARSER::parseMargins ( int &  aLeft,
int &  aTop,
int &  aRight,
int &  aBottom 
)
inlineprivate

Definition at line 197 of file sch_io_kicad_sexpr_parser.h.

References parseInternalUnits().

Referenced by parseSchTextBoxContent(), and parseSymbolTextBox().

◆ parseMaybeAbsentBool()

bool SCH_IO_KICAD_SEXPR_PARSER::parseMaybeAbsentBool ( bool  aDefaultValue)
private

Parses a boolean flag inside a list that existed before boolean normalization.

For example, this will handle both (legacy_teardrops) and (legacy_teardrops yes). Call this after parsing the T_legacy_teardrops, and aDefaultValue will be returned for the first case, or true will be returned for the second case.

Parameters
aDefaultValuewill be returned if the end of the list is encountered as the next token
Returns
the parsed boolean

Definition at line 147 of file sch_io_kicad_sexpr_parser.cpp.

References DSN_RIGHT.

Referenced by parseEDA_TEXT(), parseProperty(), parseSchematicSymbol(), parseSchField(), parseSchText(), and parseSheet().

◆ parseNoConnect()

SCH_NO_CONNECT * SCH_IO_KICAD_SEXPR_PARSER::parseNoConnect ( )
private

Definition at line 3763 of file sch_io_kicad_sexpr_parser.cpp.

References parseKIID(), and parseXY().

Referenced by ParseSchematic().

◆ parsePAGE_INFO()

◆ parsePinNames()

void SCH_IO_KICAD_SEXPR_PARSER::parsePinNames ( std::unique_ptr< LIB_SYMBOL > &  aSymbol)
private

(pin_names (offset 123) ; optional (hide yes/no) ; optional hide ; optional, pre-20241004 )

Definition at line 905 of file sch_io_kicad_sexpr_parser.cpp.

References parseBool(), and parseInternalUnits().

Referenced by parseLibSymbol().

◆ parsePinNumbers()

void SCH_IO_KICAD_SEXPR_PARSER::parsePinNumbers ( std::unique_ptr< LIB_SYMBOL > &  aSymbol)
private

(pin_numbers (hide yes/no) ; optional hide ; optional (pre-20241004) )

Definition at line 953 of file sch_io_kicad_sexpr_parser.cpp.

References parseBool().

Referenced by parseLibSymbol().

◆ parseProperty()

◆ parseSchArc()

◆ parseSchBezier()

◆ parseSchCircle()

◆ ParseSchematic()

void SCH_IO_KICAD_SEXPR_PARSER::ParseSchematic ( SCH_SHEET aSheet,
bool  aIsCopyablyOnly = false,
int  aFileVersion = SEXPR_SCHEMATIC_FILE_VERSION 
)

Parse the internal LINE_READER object into aSheet.

When aIsCopyableOnly is true, only schematic objects that are viewable on the canvas for copy and paste purposes are parsed. Other schematic content such as bus definitions or instance data will throw an IO_ERROR exception.

When aIsCopyableOnly is false, full schematic file parsing is performed.

Note
This does not load any sub-sheets or decent complex sheet hierarchies.
Parameters
aSheetThe SCH_SHEET object to store the parsed schematic file.
aIsCopyableOnlyLoad only the schematic objects that can be copied into aSheet if true. Otherwise, load the full schematic file format.
aFileVersionThe schematic file version to parser. Defaults to the schematic file being parsed when aIsCopyableOnly is false.

Definition at line 2649 of file sch_io_kicad_sexpr_parser.cpp.

References _, SCH_SCREEN::AddLibSymbol(), SCH_SCREEN::Append(), checkpoint(), SHAPE_LINE_CHAIN::CPoint(), SCH_SCREEN::FixupEmbeddedData(), Fontconfig(), SCHEMATIC::GetEmbeddedFiles(), EMBEDDED_FILES::GetFontFiles(), EDA_SHAPE::GetPointCount(), EDA_SHAPE::GetPolyShape(), SCH_SHEET::GetScreen(), SCH_SHAPE::GetStroke(), SCH_SCREEN::GetUuid(), KI_FALLTHROUGH, LAYER_NOTES, m_generatorVersion, m_requiredVersion, m_rootSheet, m_rootUuid, SCH_SCREEN::m_uuid, EDA_ITEM::m_Uuid, SHAPE_POLY_SET::Outline(), parseBool(), parseBusAlias(), parseBusEntry(), EMBEDDED_FILES_PARSER::ParseEmbedded(), parseGroup(), parseHeader(), parseImage(), parseJunction(), parseKIID(), parseLibSymbol(), parseLine(), parseNoConnect(), parsePAGE_INFO(), parseSchArc(), parseSchBezier(), parseSchCircle(), parseSchematicSymbol(), parseSchPolyLine(), parseSchRectangle(), parseSchRuleArea(), parseSchSheetInstances(), parseSchSymbolInstances(), parseSchTable(), parseSchText(), parseSchTextBox(), parseSheet(), parseTITLE_BLOCK(), Pgm(), resolveGroups(), SCH_SCREEN::Schematic(), EMBEDDED_FILES::SetAreFontsEmbedded(), SCH_LINE::SetEndPoint(), SCH_SCREEN::SetFileFormatVersionAtLoad(), SCH_SCREEN::SetLegacySymbolInstanceData(), SCH_SCREEN::SetPageSettings(), EDA_ITEM::SetParent(), SCH_LINE::SetStartPoint(), SCH_LINE::SetStroke(), SCH_SCREEN::SetTitleBlock(), SEXPR_SCHEMATIC_FILE_VERSION, THROW_PARSE_ERROR, SCH_SCREEN::UpdateLocalLibSymbolLinks(), and IO_ERROR::What().

Referenced by SCH_IO_KICAD_SEXPR::LoadContent(), SCH_IO_KICAD_SEXPR::loadFile(), and KI_TEST::LoadSheetSchematicContents().

◆ parseSchematicSymbol()

◆ parseSchField()

◆ parseSchPolyLine()

◆ parseSchRectangle()

SCH_SHAPE * SCH_IO_KICAD_SEXPR_PARSER::parseSchRectangle ( )
private

◆ parseSchRuleArea()

SCH_RULE_AREA * SCH_IO_KICAD_SEXPR_PARSER::parseSchRuleArea ( )
private

◆ parseSchSheetInstances()

◆ parseSchSheetPin()

SCH_SHEET_PIN * SCH_IO_KICAD_SEXPR_PARSER::parseSchSheetPin ( SCH_SHEET aSheet)
private

◆ parseSchSymbolInstances()

◆ parseSchTable()

SCH_TABLE * SCH_IO_KICAD_SEXPR_PARSER::parseSchTable ( )
private

◆ parseSchTableCell()

SCH_TABLECELL * SCH_IO_KICAD_SEXPR_PARSER::parseSchTableCell ( )
private

Definition at line 4480 of file sch_io_kicad_sexpr_parser.cpp.

References parseSchTextBoxContent().

Referenced by parseSchTable().

◆ parseSchText()

◆ parseSchTextBox()

SCH_TEXTBOX * SCH_IO_KICAD_SEXPR_PARSER::parseSchTextBox ( )
private

Definition at line 4467 of file sch_io_kicad_sexpr_parser.cpp.

References parseSchTextBoxContent().

Referenced by ParseSchematic().

◆ parseSchTextBoxContent()

◆ parseSheet()

◆ parseStroke()

◆ ParseSymbol()

LIB_SYMBOL * SCH_IO_KICAD_SEXPR_PARSER::ParseSymbol ( LIB_SYMBOL_MAP aSymbolLibMap,
int  aFileVersion = SEXPR_SYMBOL_LIB_FILE_VERSION 
)

◆ parseSymbolArc()

◆ parseSymbolBezier()

◆ parseSymbolCircle()

◆ ParseSymbolDrawItem()

◆ parseSymbolPin()

◆ parseSymbolPolyLine()

◆ parseSymbolRectangle()

◆ parseSymbolText()

SCH_ITEM * SCH_IO_KICAD_SEXPR_PARSER::parseSymbolText ( )
private

◆ parseSymbolTextBox()

◆ parseTITLE_BLOCK()

void SCH_IO_KICAD_SEXPR_PARSER::parseTITLE_BLOCK ( TITLE_BLOCK aTitleBlock)
private

◆ parseXY()

◆ resolveGroups()

void SCH_IO_KICAD_SEXPR_PARSER::resolveGroups ( SCH_SCREEN aParent)
private

Member Data Documentation

◆ m_appending

bool SCH_IO_KICAD_SEXPR_PARSER::m_appending
private

Appending load status.

Definition at line 259 of file sch_io_kicad_sexpr_parser.h.

Referenced by parseSchSheetInstances(), and parseSchSymbolInstances().

◆ m_bodyStyle

int SCH_IO_KICAD_SEXPR_PARSER::m_bodyStyle
private

◆ m_generatorVersion

wxString SCH_IO_KICAD_SEXPR_PARSER::m_generatorVersion
private

Definition at line 255 of file sch_io_kicad_sexpr_parser.h.

Referenced by ParseLib(), and ParseSchematic().

◆ m_groupInfos

std::vector<GROUP_INFO> SCH_IO_KICAD_SEXPR_PARSER::m_groupInfos
private

Definition at line 273 of file sch_io_kicad_sexpr_parser.h.

Referenced by parseGroup(), and resolveGroups().

◆ m_lastProgressLine

unsigned SCH_IO_KICAD_SEXPR_PARSER::m_lastProgressLine
private

Definition at line 265 of file sch_io_kicad_sexpr_parser.h.

Referenced by checkpoint().

◆ m_lineCount

unsigned SCH_IO_KICAD_SEXPR_PARSER::m_lineCount
private

Definition at line 266 of file sch_io_kicad_sexpr_parser.h.

Referenced by checkpoint().

◆ m_lineReader

const LINE_READER* SCH_IO_KICAD_SEXPR_PARSER::m_lineReader
private

Definition at line 264 of file sch_io_kicad_sexpr_parser.h.

Referenced by checkpoint().

◆ m_progressReporter

PROGRESS_REPORTER* SCH_IO_KICAD_SEXPR_PARSER::m_progressReporter
private

Definition at line 263 of file sch_io_kicad_sexpr_parser.h.

Referenced by checkpoint().

◆ m_requiredVersion

◆ m_rootSheet

SCH_SHEET* SCH_IO_KICAD_SEXPR_PARSER::m_rootSheet
private

The rootsheet for full project loads or null for importing a schematic.

Definition at line 271 of file sch_io_kicad_sexpr_parser.h.

Referenced by ParseSchematic().

◆ m_rootUuid

KIID SCH_IO_KICAD_SEXPR_PARSER::m_rootUuid
private

◆ m_symbolName

wxString SCH_IO_KICAD_SEXPR_PARSER::m_symbolName
private

The current symbol name.

Definition at line 258 of file sch_io_kicad_sexpr_parser.h.

Referenced by parseLibSymbol().

◆ m_unit

int SCH_IO_KICAD_SEXPR_PARSER::m_unit
private

◆ m_uuids

std::set<KIID> SCH_IO_KICAD_SEXPR_PARSER::m_uuids
private

Definition at line 261 of file sch_io_kicad_sexpr_parser.h.

Referenced by parseKIID().


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