|
KiCad PCB EDA Suite
|
Line-oriented parser for Protel Autotrax / Easytrax PCB files. More...
#include <autotrax_parser.h>
Public Member Functions | |
| AUTOTRAX_PARSER (REPORTER *aReporter) | |
| bool | Parse (const wxString &aContents, AUTOTRAX::BOARD_DATA &aBoard) |
Parse aContents into aBoard. | |
Static Public Member Functions | |
| static bool | Sniff (const wxString &aContents) |
| Cheap content sniff: the first non-blank, non-comment line is the magic header "PCB FILE 4" (Autotrax) or "PCB FILE 5" (Easytrax). | |
Private Member Functions | |
| bool | nextLine (wxString &aLine) |
| Return the next line trimmed of surrounding whitespace, or false at end of input. | |
| void | warn (const wxString &aMsg) const |
| bool | parseTrack (AUTOTRAX::TRACK &aOut) |
| bool | parseArc (AUTOTRAX::ARC &aOut) |
| bool | parseVia (AUTOTRAX::VIA &aOut) |
| bool | parsePad (AUTOTRAX::PAD &aOut) |
| bool | parseFill (AUTOTRAX::FILL &aOut) |
| bool | parseText (AUTOTRAX::TEXT &aOut) |
| void | parseComponent (AUTOTRAX::COMPONENT &aOut) |
| void | parseNetDef () |
Static Private Member Functions | |
| static wxArrayString | tokenize (const wxString &aLine) |
| Tokenize a whitespace-separated data line into C-locale-parseable tokens. | |
Private Attributes | |
| REPORTER * | m_reporter = nullptr |
| AUTOTRAX::BOARD_DATA * | m_board = nullptr |
| wxArrayString | m_lines |
| size_t | m_index = 0 |
| int | m_lineNo = 0 |
Line-oriented parser for Protel Autotrax / Easytrax PCB files.
The format is a flat state machine: a two-letter record keyword on its own line is followed by one or more data lines. Free primitives use F-prefixed keywords (FT/FA/FV/FF/FP/FS); the same primitives inside a COMP block use C-prefixed keywords. The parser emits an intermediate model rather than touching any KiCad object.
Parsing is tolerant. A malformed record is reported and skipped instead of aborting the import, so partially corrupt files still yield a usable board.
Definition at line 52 of file autotrax_parser.h.
|
inlineexplicit |
Definition at line 55 of file autotrax_parser.h.
References m_reporter.
|
private |
Return the next line trimmed of surrounding whitespace, or false at end of input.
Advances m_lineNo.
Definition at line 84 of file autotrax_parser.cpp.
References m_index, m_lineNo, and m_lines.
Referenced by Parse(), parseArc(), parseComponent(), parseFill(), parseNetDef(), parsePad(), parseText(), parseTrack(), and parseVia().
| bool AUTOTRAX_PARSER::Parse | ( | const wxString & | aContents, |
| AUTOTRAX::BOARD_DATA & | aBoard ) |
Parse aContents into aBoard.
Definition at line 415 of file autotrax_parser.cpp.
References AUTOTRAX::BOARD_DATA::arcs, comp, AUTOTRAX::BOARD_DATA::components, AUTOTRAX::BOARD_DATA::fills, m_board, m_index, m_lineNo, m_lines, nextLine(), AUTOTRAX::BOARD_DATA::pads, parseArc(), parseComponent(), parseFill(), parseNetDef(), parsePad(), parseText(), parseTrack(), parseVia(), AUTOTRAX::BOARD_DATA::texts, AUTOTRAX::BOARD_DATA::tracks, AUTOTRAX::BOARD_DATA::version, and AUTOTRAX::BOARD_DATA::vias.
Referenced by PCB_IO_AUTOTRAX::LoadBoard().
|
private |
Definition at line 130 of file autotrax_parser.cpp.
References _, AUTOTRAX::ARC::centerX, AUTOTRAX::ARC::centerY, AUTOTRAX::ARC::layer, nextLine(), AUTOTRAX::ARC::radius, AUTOTRAX::ARC::segments, toDouble(), toInt(), tokenize(), warn(), and AUTOTRAX::ARC::width.
Referenced by Parse(), and parseComponent().
|
private |
Definition at line 266 of file autotrax_parser.cpp.
References _, AUTOTRAX::COMPONENT::arcs, AUTOTRAX::COMPONENT::fills, AUTOTRAX::COMPONENT::name, nextLine(), AUTOTRAX::COMPONENT::pads, parseArc(), parseFill(), parsePad(), parseText(), parseTrack(), parseVia(), AUTOTRAX::COMPONENT::refdes, AUTOTRAX::COMPONENT::texts, toDouble(), tokenize(), AUTOTRAX::COMPONENT::tracks, AUTOTRAX::COMPONENT::value, AUTOTRAX::COMPONENT::vias, warn(), AUTOTRAX::COMPONENT::x, and AUTOTRAX::COMPONENT::y.
Referenced by Parse().
|
private |
Definition at line 212 of file autotrax_parser.cpp.
References _, AUTOTRAX::FILL::layer, nextLine(), toDouble(), toInt(), tokenize(), warn(), AUTOTRAX::FILL::x1, AUTOTRAX::FILL::x2, AUTOTRAX::FILL::y1, and AUTOTRAX::FILL::y2.
Referenced by Parse(), and parseComponent().
|
private |
Definition at line 353 of file autotrax_parser.cpp.
References m_board, m_index, and nextLine().
Referenced by Parse().
|
private |
Definition at line 178 of file autotrax_parser.cpp.
References _, AUTOTRAX::PAD::drill, AUTOTRAX::PAD::layer, AUTOTRAX::PAD::name, nextLine(), AUTOTRAX::PAD::planeFlags, AUTOTRAX::PAD::shape, toDouble(), toInt(), tokenize(), warn(), AUTOTRAX::PAD::x, AUTOTRAX::PAD::xSize, AUTOTRAX::PAD::y, and AUTOTRAX::PAD::ySize.
Referenced by Parse(), and parseComponent().
|
private |
Definition at line 236 of file autotrax_parser.cpp.
References _, AUTOTRAX::TEXT::direction, AUTOTRAX::TEXT::height, AUTOTRAX::TEXT::layer, nextLine(), AUTOTRAX::TEXT::text, toDouble(), toInt(), tokenize(), warn(), AUTOTRAX::TEXT::width, AUTOTRAX::TEXT::x, and AUTOTRAX::TEXT::y.
Referenced by Parse(), and parseComponent().
|
private |
Definition at line 105 of file autotrax_parser.cpp.
References _, AUTOTRAX::TRACK::layer, nextLine(), toDouble(), toInt(), tokenize(), warn(), AUTOTRAX::TRACK::width, AUTOTRAX::TRACK::x1, AUTOTRAX::TRACK::x2, AUTOTRAX::TRACK::y1, and AUTOTRAX::TRACK::y2.
Referenced by Parse(), and parseComponent().
|
private |
Definition at line 155 of file autotrax_parser.cpp.
References _, AUTOTRAX::VIA::diameter, AUTOTRAX::VIA::drill, nextLine(), toDouble(), tokenize(), warn(), AUTOTRAX::VIA::x, and AUTOTRAX::VIA::y.
Referenced by Parse(), and parseComponent().
|
static |
Cheap content sniff: the first non-blank, non-comment line is the magic header "PCB FILE 4" (Autotrax) or "PCB FILE 5" (Easytrax).
Definition at line 58 of file autotrax_parser.cpp.
Referenced by PCB_IO_AUTOTRAX::CanReadBoard().
|
staticprivate |
Tokenize a whitespace-separated data line into C-locale-parseable tokens.
Definition at line 99 of file autotrax_parser.cpp.
Referenced by parseArc(), parseComponent(), parseFill(), parsePad(), parseText(), parseTrack(), and parseVia().
|
private |
Definition at line 76 of file autotrax_parser.cpp.
References _, m_lineNo, m_reporter, and RPT_SEVERITY_WARNING.
Referenced by parseArc(), parseComponent(), parseFill(), parsePad(), parseText(), parseTrack(), and parseVia().
|
private |
Definition at line 93 of file autotrax_parser.h.
Referenced by Parse(), and parseNetDef().
|
private |
Definition at line 96 of file autotrax_parser.h.
Referenced by nextLine(), Parse(), and parseNetDef().
|
private |
Definition at line 97 of file autotrax_parser.h.
Referenced by nextLine(), Parse(), and warn().
|
private |
Definition at line 95 of file autotrax_parser.h.
Referenced by nextLine(), and Parse().
|
private |
Definition at line 92 of file autotrax_parser.h.
Referenced by AUTOTRAX_PARSER(), and warn().