![]() |
KiCad PCB EDA Suite
|
Object to parser s-expression symbol library and schematic file formats. More...
#include <sch_sexpr_parser.h>
Public Member Functions | |
SCH_SEXPR_PARSER (LINE_READER *aLineReader=nullptr) | |
void | ParseLib (LIB_PART_MAP &aSymbolLibMap) |
LIB_PART * | ParseSymbol (LIB_PART_MAP &aSymbolLibMap, int aFileVersion=SEXPR_SYMBOL_LIB_FILE_VERSION) |
LIB_ITEM * | ParseDrawItem () |
void | ParseSchematic (SCH_SHEET *aSheet, bool aIsCopyablyOnly=false, int aFileVersion=SEXPR_SCHEMATIC_FILE_VERSION) |
Parse the internal LINE_READER object into aSheet. More... | |
bool | IsTooRecent () const |
Return whether a version number, if any was parsed, was too recent. More... | |
Private Member Functions | |
void | parseHeader (TSCHEMATIC_T::T aHeaderType, int aFileVersion) |
long | parseHex () |
int | parseInt () |
int | parseInt (const char *aExpected) |
double | parseDouble () |
Parse the current token as an ASCII numeric string with possible leading whitespace into a double precision floating point number. More... | |
double | parseDouble (const char *aExpected) |
double | parseDouble (TSCHEMATIC_T::T aToken) |
int | parseInternalUnits () |
int | parseInternalUnits (const char *aExpected) |
int | parseInternalUnits (TSCHEMATIC_T::T aToken) |
wxPoint | parseXY () |
bool | parseBool () |
void | parseStroke (STROKE_PARAMS &aStroke) |
Parse stroke definition aStroke. More... | |
void | parseFill (FILL_PARAMS &aFill) |
void | parseEDA_TEXT (EDA_TEXT *aText) |
void | parsePinNames (std::unique_ptr< LIB_PART > &aSymbol) |
LIB_FIELD * | parseProperty (std::unique_ptr< LIB_PART > &aSymbol) |
LIB_ARC * | parseArc () |
LIB_BEZIER * | parseBezier () |
LIB_CIRCLE * | parseCircle () |
LIB_PIN * | parsePin () |
LIB_POLYLINE * | parsePolyLine () |
LIB_RECTANGLE * | parseRectangle () |
LIB_TEXT * | parseText () |
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) |
SCH_SHEET_PIN * | parseSchSheetPin (SCH_SHEET *aSheet) |
SCH_FIELD * | parseSchField (SCH_ITEM *aParent) |
SCH_COMPONENT * | parseSchematicSymbol () |
SCH_BITMAP * | parseImage () |
SCH_SHEET * | parseSheet () |
SCH_JUNCTION * | parseJunction () |
SCH_NO_CONNECT * | parseNoConnect () |
SCH_BUS_WIRE_ENTRY * | parseBusEntry () |
SCH_LINE * | parseLine () |
SCH_TEXT * | parseSchText () |
void | parseBusAlias (SCH_SCREEN *aScreen) |
Private Attributes | |
int | m_requiredVersion |
Set to the symbol library file version required. More... | |
int | m_fieldId |
The current field ID. More... | |
int | m_unit |
The current unit being parsed. More... | |
int | m_convert |
The current body style being parsed. More... | |
wxString | m_symbolName |
The current symbol name. More... | |
Object to parser s-expression symbol library and schematic file formats.
Definition at line 79 of file sch_sexpr_parser.h.
SCH_SEXPR_PARSER::SCH_SEXPR_PARSER | ( | LINE_READER * | aLineReader = nullptr | ) |
Definition at line 60 of file sch_sexpr_parser.cpp.
bool SCH_SEXPR_PARSER::IsTooRecent | ( | ) | const |
Return whether a version number, if any was parsed, was too recent.
Definition at line 85 of file sch_sexpr_parser.cpp.
References m_requiredVersion, and SEXPR_SYMBOL_LIB_FILE_VERSION.
|
private |
Definition at line 886 of file sch_sexpr_parser.cpp.
References GetArcCenter(), KiROUND(), m_convert, FILL_PARAMS::m_FillType, m_unit, NORMALIZE_ANGLE_POS(), parseDouble(), parseFill(), parseInternalUnits(), parseXY(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by ParseDrawItem().
|
private |
Definition at line 1009 of file sch_sexpr_parser.cpp.
References m_convert, FILL_PARAMS::m_FillType, m_unit, parseFill(), parseInternalUnits(), and parseXY().
Referenced by ParseDrawItem().
|
private |
Definition at line 70 of file sch_sexpr_parser.cpp.
Referenced by parseSchematicSymbol(), and ParseSymbol().
|
private |
Definition at line 2947 of file sch_sexpr_parser.cpp.
References SCH_SCREEN::AddBusAlias().
Referenced by ParseSchematic().
|
private |
Definition at line 2709 of file sch_sexpr_parser.cpp.
References parseInternalUnits(), parseStroke(), and parseXY().
Referenced by ParseSchematic().
|
private |
Definition at line 1074 of file sch_sexpr_parser.cpp.
References m_convert, FILL_PARAMS::m_FillType, m_unit, parseFill(), parseInternalUnits(), and parseXY().
Referenced by ParseDrawItem().
|
private |
Parse the current token as an ASCII numeric string with possible leading whitespace into a double precision floating point number.
IO_ERROR | if an error occurs attempting to convert the current token. |
Definition at line 414 of file sch_sexpr_parser.cpp.
References _, NULL, and THROW_IO_ERROR.
Referenced by parseArc(), parseDouble(), parseFill(), parseImage(), parseInternalUnits(), parseJunction(), parsePAGE_INFO(), parseProperty(), parseSchematicSymbol(), parseSchField(), parseSchSheetPin(), parseSchText(), parseStroke(), and parseText().
|
inlineprivate |
Definition at line 115 of file sch_sexpr_parser.h.
References parseDouble().
|
inlineprivate |
Definition at line 121 of file sch_sexpr_parser.h.
References DSN::GetTokenText(), and parseDouble().
LIB_ITEM * SCH_SEXPR_PARSER::ParseDrawItem | ( | ) |
Definition at line 374 of file sch_sexpr_parser.cpp.
References parseArc(), parseBezier(), parseCircle(), parsePin(), parsePolyLine(), parseRectangle(), and parseText().
Referenced by ParseSymbol().
|
private |
Definition at line 574 of file sch_sexpr_parser.cpp.
References GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_TOP, parseInternalUnits(), EDA_TEXT::SetBold(), EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetItalic(), EDA_TEXT::SetMirrored(), EDA_TEXT::SetTextSize(), EDA_TEXT::SetTextThickness(), EDA_TEXT::SetVertJustify(), and EDA_TEXT::SetVisible().
Referenced by parsePin(), parseProperty(), parseSchField(), parseSchSheetPin(), parseSchText(), and parseText().
|
private |
Definition at line 519 of file sch_sexpr_parser.cpp.
References Clamp(), color, FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR, FILL_PARAMS::m_Color, FILL_PARAMS::m_FillType, NO_FILL, parseDouble(), and parseInt().
Referenced by parseArc(), parseBezier(), parseCircle(), parsePolyLine(), parseRectangle(), and parseSheet().
|
private |
Definition at line 653 of file sch_sexpr_parser.cpp.
References m_requiredVersion, and parseInt().
Referenced by ParseLib(), and ParseSchematic().
|
inlineprivate |
Definition at line 89 of file sch_sexpr_parser.h.
References NULL.
|
private |
Definition at line 2440 of file sch_sexpr_parser.cpp.
References image, parseDouble(), and parseXY().
Referenced by ParseSchematic().
|
inlineprivate |
Definition at line 95 of file sch_sexpr_parser.h.
References NULL.
Referenced by parseFill(), parseHeader(), parseInt(), parseJunction(), parsePin(), parseProperty(), parseSchematicSymbol(), parseSchField(), parseSchSymbolInstances(), parseStroke(), and parseTITLE_BLOCK().
|
inlineprivate |
|
inlineprivate |
Definition at line 126 of file sch_sexpr_parser.h.
References IU_PER_MM, KiROUND(), and parseDouble().
Referenced by parseArc(), parseBezier(), parseBusEntry(), parseCircle(), parseEDA_TEXT(), parseInternalUnits(), parseJunction(), parsePin(), parsePinNames(), parsePolyLine(), parseRectangle(), parseSheet(), parseStroke(), and parseXY().
|
inlineprivate |
Definition at line 138 of file sch_sexpr_parser.h.
References IU_PER_MM, KiROUND(), and parseDouble().
|
inlineprivate |
Definition at line 147 of file sch_sexpr_parser.h.
References DSN::GetTokenText(), and parseInternalUnits().
|
private |
Definition at line 2622 of file sch_sexpr_parser.cpp.
References Clamp(), color, parseDouble(), parseInt(), parseInternalUnits(), and parseXY().
Referenced by ParseSchematic().
void SCH_SEXPR_PARSER::ParseLib | ( | LIB_PART_MAP & | aSymbolLibMap | ) |
Definition at line 91 of file sch_sexpr_parser.cpp.
References LIB_PART::GetName(), m_convert, m_requiredVersion, m_unit, parseHeader(), ParseSymbol(), and SEXPR_SYMBOL_LIB_FILE_VERSION.
|
private |
Definition at line 2763 of file sch_sexpr_parser.cpp.
References LAYER_BUS, LAYER_NOTES, LAYER_WIRE, parseStroke(), and parseXY().
Referenced by ParseSchematic().
|
private |
Definition at line 2672 of file sch_sexpr_parser.cpp.
References parseXY().
Referenced by ParseSchematic().
|
private |
Definition at line 1526 of file sch_sexpr_parser.cpp.
References _, PAGE_INFO::Custom, m_requiredVersion, Mm2mils(), parseDouble(), PAGE_INFO::SetHeightMils(), PAGE_INFO::SetPortrait(), PAGE_INFO::SetType(), PAGE_INFO::SetWidthMils(), and THROW_PARSE_ERROR.
Referenced by ParseSchematic().
|
private |
Definition at line 1131 of file sch_sexpr_parser.cpp.
References _, CLOCK, CLOCK_LOW, FALLING_EDGE_CLOCK, INPUT_LOW, INVERTED, INVERTED_CLOCK, LINE, m_convert, LIB_PIN::ALT::m_Name, LIB_PIN::ALT::m_Shape, LIB_PIN::ALT::m_Type, m_unit, NONLOGIC, OUTPUT_LOW, parseEDA_TEXT(), parseInt(), parseInternalUnits(), parseXY(), pin, PIN_DOWN, PIN_LEFT, PIN_RIGHT, PIN_UP, PT_BIDI, PT_INPUT, PT_NC, PT_NIC, PT_OPENCOLLECTOR, PT_OPENEMITTER, PT_OUTPUT, PT_PASSIVE, PT_POWER_IN, PT_POWER_OUT, PT_TRISTATE, PT_UNSPECIFIED, text, and THROW_IO_ERROR.
Referenced by ParseDrawItem().
|
private |
Definition at line 689 of file sch_sexpr_parser.cpp.
References _, parseInternalUnits(), and THROW_IO_ERROR.
Referenced by ParseSymbol().
|
private |
Definition at line 1353 of file sch_sexpr_parser.cpp.
References m_convert, FILL_PARAMS::m_FillType, m_unit, parseFill(), parseInternalUnits(), and parseXY().
Referenced by ParseDrawItem().
Definition at line 727 of file sch_sexpr_parser.cpp.
References _, LIB_FIELD::GetCanonicalName(), MANDATORY_FIELDS, name, parseDouble(), parseEDA_TEXT(), parseInt(), parseXY(), and THROW_IO_ERROR.
Referenced by ParseSymbol().
|
private |
Definition at line 1418 of file sch_sexpr_parser.cpp.
References m_convert, FILL_PARAMS::m_FillType, m_unit, parseFill(), parseInternalUnits(), and parseXY().
Referenced by ParseDrawItem().
void SCH_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.
aSheet | The SCH_SHEET object to store the parsed schematic file. |
aIsCopyableOnly | Load only the schematic objects that can be copied into aSheet if true. Otherwise, load the full schematic file format. |
aFileVersion | The schematic file version to parser. Defaults to the schematic file being parsed when aIsCopyableOnly is false. |
Definition at line 2009 of file sch_sexpr_parser.cpp.
References SCH_SCREEN::AddLibSymbol(), SCH_SCREEN::Append(), SCH_SHEET::GetScreen(), m_requiredVersion, SCH_SCREEN::m_uuid, parseBusAlias(), parseBusEntry(), parseHeader(), parseImage(), parseJunction(), parseLine(), parseNoConnect(), parsePAGE_INFO(), parseSchematicSymbol(), parseSchSheetInstances(), parseSchSymbolInstances(), parseSchText(), parseSheet(), ParseSymbol(), parseTITLE_BLOCK(), SCH_SCREEN::SetFileFormatVersionAtLoad(), SCH_SCREEN::SetPageSettings(), EDA_ITEM::SetParent(), SCH_SCREEN::SetTitleBlock(), SEXPR_SCHEMATIC_FILE_VERSION, and SCH_SCREEN::UpdateLocalLibSymbolLinks().
Referenced by SCH_SEXPR_PLUGIN::LoadContent(), and SCH_SEXPR_PLUGIN::loadFile().
|
private |
Definition at line 2196 of file sch_sexpr_parser.cpp.
References _, CMP_MIRROR_X, CMP_MIRROR_Y, SCH_FIELD::GetId(), EDA_TEXT::GetText(), m_fieldId, m_requiredVersion, MANDATORY_FIELDS, LIB_ID::Parse(), parseBool(), parseDouble(), parseInt(), parseSchField(), parseXY(), REFERENCE_FIELD, SCH_FIELD::SetId(), and THROW_IO_ERROR.
Referenced by ParseSchematic().
Definition at line 1685 of file sch_sexpr_parser.cpp.
References _, name, parseDouble(), parseEDA_TEXT(), parseInt(), parseXY(), and THROW_IO_ERROR.
Referenced by parseSchematicSymbol(), parseSchText(), and parseSheet().
|
private |
Definition at line 1856 of file sch_sexpr_parser.cpp.
References SCH_SHEET_INSTANCE::m_PageNumber, SCH_SHEET_INSTANCE::m_Path, SCH_SCREEN::m_sheetInstances, EDA_ITEM::m_Uuid, and BASE_SCREEN::SetModify().
Referenced by ParseSchematic().
|
private |
Definition at line 1763 of file sch_sexpr_parser.cpp.
References _, PNS::angle(), name, parseDouble(), parseEDA_TEXT(), parseXY(), PS_BIDI, PS_INPUT, PS_OUTPUT, PS_TRISTATE, PS_UNSPECIFIED, SHEET_BOTTOM_SIDE, SHEET_LEFT_SIDE, SHEET_RIGHT_SIDE, SHEET_TOP_SIDE, and THROW_IO_ERROR.
Referenced by parseSheet().
|
private |
Definition at line 1935 of file sch_sexpr_parser.cpp.
References SYMBOL_INSTANCE_REFERENCE::m_Footprint, SYMBOL_INSTANCE_REFERENCE::m_Path, SYMBOL_INSTANCE_REFERENCE::m_Reference, SCH_SCREEN::m_symbolInstances, SYMBOL_INSTANCE_REFERENCE::m_Unit, SYMBOL_INSTANCE_REFERENCE::m_Value, and parseInt().
Referenced by ParseSchematic().
|
private |
Definition at line 2828 of file sch_sexpr_parser.cpp.
References LABEL_SPIN_STYLE::BOTTOM, SCH_GLOBALLABEL::GetIntersheetRefs(), LAYER_GLOBLABEL, LABEL_SPIN_STYLE::LEFT, parseDouble(), parseEDA_TEXT(), parseSchField(), parseXY(), PS_BIDI, PS_INPUT, PS_OUTPUT, PS_TRISTATE, PS_UNSPECIFIED, LABEL_SPIN_STYLE::RIGHT, SCH_GLOBAL_LABEL_T, SCH_LABEL_T, SCH_TEXT_T, SCH_GLOBALLABEL::SetIntersheetRefs(), EDA_TEXT::SetTextPos(), text, and LABEL_SPIN_STYLE::UP.
Referenced by ParseSchematic().
|
private |
Definition at line 2515 of file sch_sexpr_parser.cpp.
References STROKE_PARAMS::GetColor(), SCH_FIELD::GetId(), STROKE_PARAMS::GetWidth(), FILL_PARAMS::m_Color, m_requiredVersion, parseFill(), parseInternalUnits(), parseSchField(), parseSchSheetPin(), parseStroke(), parseXY(), SCH_FIELD::SetId(), SHEETFILENAME, and SHEETNAME.
Referenced by ParseSchematic().
|
private |
Parse stroke definition aStroke.
aStrokeDef | A reference to the STROKE_PARAMS structure to write to. |
Definition at line 453 of file sch_sexpr_parser.cpp.
References Clamp(), color, DASH, DASHDOT, DEFAULT, DEFAULT_LINE_THICKNESS, DOT, parseDouble(), parseInt(), parseInternalUnits(), STROKE_PARAMS::SetColor(), STROKE_PARAMS::SetPlotStyle(), STROKE_PARAMS::SetWidth(), and SOLID.
Referenced by parseBusEntry(), parseLine(), and parseSheet().
LIB_PART * SCH_SEXPR_PARSER::ParseSymbol | ( | LIB_PART_MAP & | aSymbolLibMap, |
int | aFileVersion = SEXPR_SYMBOL_LIB_FILE_VERSION |
||
) |
Definition at line 121 of file sch_sexpr_parser.cpp.
References _, LIB_FIELD::GetId(), m_convert, m_fieldId, m_requiredVersion, m_symbolName, m_unit, MANDATORY_FIELDS, name, parseBool(), ParseDrawItem(), parsePinNames(), parseProperty(), LIB_FIELD::SetId(), EDA_ITEM::SetParent(), and THROW_IO_ERROR.
Referenced by ParseLib(), SCH_SEXPR_PLUGIN::ParsePart(), and ParseSchematic().
|
private |
Definition at line 1475 of file sch_sexpr_parser.cpp.
References _, m_convert, m_unit, parseDouble(), parseEDA_TEXT(), parseXY(), text, and THROW_IO_ERROR.
Referenced by ParseDrawItem().
|
private |
Definition at line 1579 of file sch_sexpr_parser.cpp.
References parseInt(), TITLE_BLOCK::SetComment(), TITLE_BLOCK::SetCompany(), TITLE_BLOCK::SetDate(), TITLE_BLOCK::SetRevision(), TITLE_BLOCK::SetTitle(), and THROW_PARSE_ERROR.
Referenced by ParseSchematic().
|
inlineprivate |
Definition at line 152 of file sch_sexpr_parser.h.
References parseInternalUnits().
Referenced by parseArc(), parseBezier(), parseBusEntry(), parseCircle(), parseImage(), parseJunction(), parseLine(), parseNoConnect(), parsePin(), parsePolyLine(), parseProperty(), parseRectangle(), parseSchematicSymbol(), parseSchField(), parseSchSheetPin(), parseSchText(), parseSheet(), and parseText().
|
private |
The current body style being parsed.
Definition at line 84 of file sch_sexpr_parser.h.
Referenced by parseArc(), parseBezier(), parseCircle(), ParseLib(), parsePin(), parsePolyLine(), parseRectangle(), ParseSymbol(), and parseText().
|
private |
The current field ID.
Definition at line 82 of file sch_sexpr_parser.h.
Referenced by parseSchematicSymbol(), and ParseSymbol().
|
private |
Set to the symbol library file version required.
Definition at line 81 of file sch_sexpr_parser.h.
Referenced by IsTooRecent(), parseHeader(), ParseLib(), parsePAGE_INFO(), ParseSchematic(), parseSchematicSymbol(), parseSheet(), and ParseSymbol().
|
private |
The current symbol name.
Definition at line 85 of file sch_sexpr_parser.h.
Referenced by ParseSymbol().
|
private |
The current unit being parsed.
Definition at line 83 of file sch_sexpr_parser.h.
Referenced by parseArc(), parseBezier(), parseCircle(), ParseLib(), parsePin(), parsePolyLine(), parseRectangle(), ParseSymbol(), and parseText().