|
KiCad PCB EDA Suite
|
Read-only parser for the pre-v6 binary Eagle .brd format. More...
#include <eagle_bin_parser.h>
Classes | |
| struct | DRC_CTX |
| DRC values pulled from the trailing 244-byte block (or sane defaults). More... | |
| struct | EGB_NODE |
| Lightweight mutable tree node for the intermediate Eagle binary tree. More... | |
Public Member Functions | |
| EAGLE_BIN_PARSER () | |
| ~EAGLE_BIN_PARSER () | |
| std::unique_ptr< wxXmlDocument > | Parse (const std::vector< uint8_t > &aBytes) |
| Parse a binary Eagle board into an XML DOM compatible with the XML walker. | |
Static Public Member Functions | |
| static bool | IsBinaryEagle (wxInputStream &aStream) |
| Probe the first two bytes for the binary magic. | |
Private Member Functions | |
| int | readBlock (long &aNumBlocks, EGB_NODE *aParent) |
| bool | readNotes () |
| bool | readDrc (DRC_CTX &aDrc) |
| const wxString & | nextLongText () |
| void | postProcess (EGB_NODE *aRoot, const DRC_CTX &aDrc) |
| void | postprocLayers (EGB_NODE *aDrawing, EGB_NODE *aLayers) |
| void | postprocDrc (EGB_NODE *aDrcNode, const DRC_CTX &aDrc) |
| void | postprocLibs (EGB_NODE *aLibraries) |
| void | postprocElements (EGB_NODE *aElements) |
| void | postprocNames (EGB_NODE *aLibraries, EGB_NODE *aElements) |
| void | postprocSignals (EGB_NODE *aSignals) |
| void | postprocContactRefs (EGB_NODE *aSignals, EGB_NODE *aElements, EGB_NODE *aLibraries) |
| void | postprocWires (EGB_NODE *aRoot) |
| void | postprocArcs (EGB_NODE *aRoot) |
| void | postprocVias (EGB_NODE *aRoot) |
| void | postprocUnits (EGB_NODE *aRoot) |
| void | postprocCircles (EGB_NODE *aRoot) |
| void | postprocSmd (EGB_NODE *aRoot) |
| void | postprocDimensions (EGB_NODE *aRoot) |
| void | postprocFreeText (EGB_NODE *aRoot) |
| void | postprocRotation (EGB_NODE *aRoot) |
| bool | isRotatable (int aId) const |
| void | arcDecode (EGB_NODE *aElem, int aArcType, int aLineType) |
| void | fixLongText (EGB_NODE *aNode, const wxString &aField) |
| wxXmlNode * | toXml (const EGB_NODE *aNode) const |
| void | requireBytes (size_t aOffs, size_t aLen) const |
| uint32_t | loadU32 (size_t aOffs, unsigned aLen) const |
| int32_t | loadS32 (size_t aOffs, unsigned aLen) const |
| bool | loadBmb (size_t aOffs, uint32_t aMask) const |
| uint32_t | loadUbf (size_t aOffs, uint32_t aField) const |
| wxString | loadStr (size_t aOffs, unsigned aLen) const |
| double | loadDouble (size_t aOffs) const |
Private Attributes | |
| const std::vector< uint8_t > * | m_buf = nullptr |
| file contents, not owned | |
| size_t | m_pos = 0 |
| current read cursor | |
| std::unique_ptr< EGB_NODE > | m_root |
| std::vector< wxString > | m_freeText |
| NUL-delimited notes strings. | |
| size_t | m_freeTextCursor = 0 |
| wxString | m_invalidText |
| returned when out of strings | |
Read-only parser for the pre-v6 binary Eagle .brd format.
Eagle stored boards in a flat stream of fixed 24-byte records before the XML era (versions 6+). The binary is decoded into a node tree structurally identical to the Eagle XML DOM, then fed to the same XML tree-walker, so KiCad's existing PCB_IO_EAGLE::loadAllSections() can consume the result unchanged.
There is no separate binary-to-board mapping. The binary is parsed into a generic intermediate tree (EGB_NODE), rewritten in place by a series of post-processing passes so its element names and attribute names match the XML schema, and finally emitted as a wxXmlDocument.
Definition at line 62 of file eagle_bin_parser.h.
|
default |
|
default |
|
private |
Definition at line 1180 of file eagle_bin_parser.cpp.
References std::abs(), EAGLE_BIN_PARSER::EGB_NODE::HasProp(), M_PI, EAGLE_BIN_PARSER::EGB_NODE::PropLong(), EAGLE_BIN_PARSER::EGB_NODE::props, and radius.
Referenced by postprocArcs(), and postprocWires().
|
private |
Definition at line 1167 of file eagle_bin_parser.cpp.
References nextLongText(), and EAGLE_BIN_PARSER::EGB_NODE::props.
Referenced by postprocFreeText().
|
static |
Probe the first two bytes for the binary magic.
Definition at line 813 of file eagle_bin_parser.cpp.
Referenced by PCB_IO_EAGLE::checkHeader(), and PCB_IO_EAGLE::LoadBoard().
|
private |
Definition at line 1557 of file eagle_bin_parser.cpp.
References EGKW_SECT_ATTRIBUTE, EGKW_SECT_ELEMENT, EGKW_SECT_INSTANCE, EGKW_SECT_NETBUSLABEL, EGKW_SECT_PAD, EGKW_SECT_PIN, EGKW_SECT_RECTANGLE, EGKW_SECT_SMASHEDGATE, EGKW_SECT_SMASHEDNAME, EGKW_SECT_SMASHEDPART, EGKW_SECT_SMASHEDVALUE, EGKW_SECT_SMASHEDXREF, EGKW_SECT_SMD, and EGKW_SECT_TEXT.
Referenced by postprocRotation().
|
private |
Definition at line 874 of file eagle_bin_parser.cpp.
References m_buf, and requireBytes().
Referenced by readBlock().
|
private |
Definition at line 913 of file eagle_bin_parser.cpp.
References m_buf, and requireBytes().
Referenced by readBlock(), and readDrc().
|
private |
Definition at line 855 of file eagle_bin_parser.cpp.
References m_buf, and requireBytes().
Referenced by readBlock(), readDrc(), and readNotes().
|
private |
Definition at line 896 of file eagle_bin_parser.cpp.
References m_buf, and requireBytes().
Referenced by readBlock().
|
private |
Definition at line 839 of file eagle_bin_parser.cpp.
References requireBytes().
Referenced by loadUbf(), and readBlock().
|
private |
Definition at line 882 of file eagle_bin_parser.cpp.
References loadU32().
Referenced by readBlock().
|
private |
Definition at line 1091 of file eagle_bin_parser.cpp.
References m_freeText, m_freeTextCursor, m_invalidText, and traceEagleIo.
Referenced by fixLongText().
| std::unique_ptr< wxXmlDocument > EAGLE_BIN_PARSER::Parse | ( | const std::vector< uint8_t > & | aBytes | ) |
Parse a binary Eagle board into an XML DOM compatible with the XML walker.
| aBytes | is the entire file content. |
Definition at line 2103 of file eagle_bin_parser.cpp.
References _, drc, m_buf, m_pos, m_root, postProcess(), readBlock(), readDrc(), readNotes(), THROW_IO_ERROR, and toXml().
Referenced by PCB_IO_EAGLE::LoadBoard().
|
private |
Definition at line 1419 of file eagle_bin_parser.cpp.
References arcDecode(), EAGLE_BIN_PARSER::EGB_NODE::children, EGKW_SECT_ARC, EAGLE_BIN_PARSER::EGB_NODE::HasProp(), EAGLE_BIN_PARSER::EGB_NODE::id, postprocArcs(), EAGLE_BIN_PARSER::EGB_NODE::Prop(), EAGLE_BIN_PARSER::EGB_NODE::PropDoubled(), EAGLE_BIN_PARSER::EGB_NODE::PropLong(), and EAGLE_BIN_PARSER::EGB_NODE::props.
Referenced by postprocArcs(), and postProcess().
|
private |
Definition at line 1499 of file eagle_bin_parser.cpp.
References EAGLE_BIN_PARSER::EGB_NODE::children, EGKW_SECT_CIRCLE, EAGLE_BIN_PARSER::EGB_NODE::HasProp(), EAGLE_BIN_PARSER::EGB_NODE::id, postprocCircles(), EAGLE_BIN_PARSER::EGB_NODE::PropDoubled(), and EAGLE_BIN_PARSER::EGB_NODE::props.
Referenced by postprocCircles(), and postProcess().
|
private |
Definition at line 1936 of file eagle_bin_parser.cpp.
References EAGLE_BIN_PARSER::EGB_NODE::children, EGKW_SECT_CONTACTREF, EGKW_SECT_PACKAGES, EGKW_SECT_PAD, EGKW_SECT_PIN, EGKW_SECT_SMD, EAGLE_BIN_PARSER::EGB_NODE::FindChildById(), EAGLE_BIN_PARSER::EGB_NODE::HasProp(), EAGLE_BIN_PARSER::EGB_NODE::Prop(), EAGLE_BIN_PARSER::EGB_NODE::PropLong(), and EAGLE_BIN_PARSER::EGB_NODE::props.
Referenced by postProcess().
|
private |
Definition at line 1531 of file eagle_bin_parser.cpp.
References EAGLE_BIN_PARSER::EGB_NODE::children, EGKW_SECT_HOLE, EGKW_SECT_PAD, EGKW_SECT_TEXT, EGKW_SECT_VIA, EAGLE_BIN_PARSER::EGB_NODE::HasProp(), EAGLE_BIN_PARSER::EGB_NODE::id, postprocDimensions(), EAGLE_BIN_PARSER::EGB_NODE::PropDoubled(), and EAGLE_BIN_PARSER::EGB_NODE::props.
Referenced by postprocDimensions(), and postProcess().
Definition at line 1723 of file eagle_bin_parser.cpp.
References EAGLE_BIN_PARSER::EGB_NODE::AddChild(), EGKW_SECT_DRC, EAGLE_BIN_PARSER::DRC_CTX::mdWireWire, EAGLE_BIN_PARSER::DRC_CTX::msWidth, EAGLE_BIN_PARSER::EGB_NODE::props, EAGLE_BIN_PARSER::DRC_CTX::rvPadBottom, EAGLE_BIN_PARSER::DRC_CTX::rvPadInner, and EAGLE_BIN_PARSER::DRC_CTX::rvPadTop.
Referenced by postProcess().
|
private |
Definition at line 1772 of file eagle_bin_parser.cpp.
References EAGLE_BIN_PARSER::EGB_NODE::children, and EGKW_SECT_ELEMENT2.
Referenced by postProcess().
Definition at line 2025 of file eagle_bin_parser.cpp.
References _, EAGLE_BIN_PARSER::EGB_NODE::AddChild(), EAGLE_BIN_PARSER::EGB_NODE::children, EGKW_SECT_BOARD, EGKW_SECT_DRC, EGKW_SECT_LAYERS, EAGLE_BIN_PARSER::EGB_NODE::FindChildById(), EAGLE_BIN_PARSER::EGB_NODE::FindChildByName(), postprocArcs(), postprocCircles(), postprocContactRefs(), postprocDimensions(), postprocDrc(), postprocElements(), postprocFreeText(), postprocLayers(), postprocLibs(), postprocNames(), postprocRotation(), postprocSignals(), postprocSmd(), postprocUnits(), postprocVias(), postprocWires(), and THROW_IO_ERROR.
Referenced by Parse().
|
private |
Definition at line 1625 of file eagle_bin_parser.cpp.
References EAGLE_BIN_PARSER::EGB_NODE::children, EGKW_SECT_ATTRIBUTE, EGKW_SECT_ATTRIBUTEVALUE, EGKW_SECT_DEVICE, EGKW_SECT_DEVICES, EGKW_SECT_ELEMENT2, EGKW_SECT_GATE, EGKW_SECT_LAYER, EGKW_SECT_LIBRARY, EGKW_SECT_NETBUSLABEL, EGKW_SECT_PACKAGE, EGKW_SECT_PACKAGES, EGKW_SECT_PACKAGEVARIANT, EGKW_SECT_PAD, EGKW_SECT_PART, EGKW_SECT_PIN, EGKW_SECT_SCHEMA, EGKW_SECT_SCHEMANET, EGKW_SECT_SIGNAL, EGKW_SECT_SMASHEDGATE, EGKW_SECT_SMASHEDNAME, EGKW_SECT_SMASHEDPART, EGKW_SECT_SMASHEDVALUE, EGKW_SECT_SMASHEDXREF, EGKW_SECT_SMD, EGKW_SECT_SYMBOL, EGKW_SECT_SYMBOLS, EGKW_SECT_TEXT, fixLongText(), EAGLE_BIN_PARSER::EGB_NODE::id, and postprocFreeText().
Referenced by postProcess(), and postprocFreeText().
Definition at line 1693 of file eagle_bin_parser.cpp.
References EAGLE_BIN_PARSER::EGB_NODE::children, and EGKW_SECT_LAYER.
Referenced by postProcess().
|
private |
Definition at line 1740 of file eagle_bin_parser.cpp.
References EAGLE_BIN_PARSER::EGB_NODE::children, EGKW_SECT_LIBRARY, EGKW_SECT_PACKAGES, EAGLE_BIN_PARSER::EGB_NODE::FindChildById(), and EAGLE_BIN_PARSER::EGB_NODE::parent.
Referenced by postProcess().
Definition at line 1808 of file eagle_bin_parser.cpp.
References EAGLE_BIN_PARSER::EGB_NODE::children, EGKW_SECT_ELEMENT, EGKW_SECT_LIBRARY, EGKW_SECT_PACKAGES, EAGLE_BIN_PARSER::EGB_NODE::FindChildById(), EAGLE_BIN_PARSER::EGB_NODE::id, name, EAGLE_BIN_PARSER::EGB_NODE::Prop(), EAGLE_BIN_PARSER::EGB_NODE::PropLong(), and EAGLE_BIN_PARSER::EGB_NODE::props.
Referenced by postProcess().
|
private |
Definition at line 1580 of file eagle_bin_parser.cpp.
References EAGLE_BIN_PARSER::EGB_NODE::children, EAGLE_BIN_PARSER::EGB_NODE::HasProp(), EAGLE_BIN_PARSER::EGB_NODE::id, isRotatable(), postprocRotation(), EAGLE_BIN_PARSER::EGB_NODE::Prop(), EAGLE_BIN_PARSER::EGB_NODE::PropLong(), and EAGLE_BIN_PARSER::EGB_NODE::props.
Referenced by postProcess(), and postprocRotation().
|
private |
Definition at line 1893 of file eagle_bin_parser.cpp.
References EAGLE_BIN_PARSER::EGB_NODE::children, EGKW_SECT_SIGNAL, and EAGLE_BIN_PARSER::EGB_NODE::id.
Referenced by postProcess().
|
private |
Definition at line 1511 of file eagle_bin_parser.cpp.
References EAGLE_BIN_PARSER::EGB_NODE::children, EGKW_SECT_SMD, EAGLE_BIN_PARSER::EGB_NODE::HasProp(), EAGLE_BIN_PARSER::EGB_NODE::id, postprocSmd(), EAGLE_BIN_PARSER::EGB_NODE::PropDoubled(), and EAGLE_BIN_PARSER::EGB_NODE::props.
Referenced by postProcess(), and postprocSmd().
|
private |
Definition at line 1469 of file eagle_bin_parser.cpp.
References EAGLE_BIN_PARSER::EGB_NODE::children, postprocUnits(), and EAGLE_BIN_PARSER::EGB_NODE::props.
Referenced by postProcess(), and postprocUnits().
|
private |
Definition at line 1454 of file eagle_bin_parser.cpp.
References EAGLE_BIN_PARSER::EGB_NODE::children, EGKW_SECT_VIA, EAGLE_BIN_PARSER::EGB_NODE::id, postprocVias(), and EAGLE_BIN_PARSER::EGB_NODE::props.
Referenced by postProcess(), and postprocVias().
|
private |
Definition at line 1386 of file eagle_bin_parser.cpp.
References arcDecode(), EAGLE_BIN_PARSER::EGB_NODE::children, EGKW_SECT_LINE, EAGLE_BIN_PARSER::EGB_NODE::HasProp(), EAGLE_BIN_PARSER::EGB_NODE::id, postprocWires(), EAGLE_BIN_PARSER::EGB_NODE::Prop(), EAGLE_BIN_PARSER::EGB_NODE::PropDoubled(), EAGLE_BIN_PARSER::EGB_NODE::PropLong(), and EAGLE_BIN_PARSER::EGB_NODE::props.
Referenced by postProcess(), and postprocWires().
|
private |
Definition at line 934 of file eagle_bin_parser.cpp.
References _, EAGLE_BIN_PARSER::EGB_NODE::AddChild(), loadBmb(), loadDouble(), loadS32(), loadStr(), loadU32(), loadUbf(), m_buf, m_pos, EAGLE_BIN_PARSER::EGB_NODE::props, readBlock(), res, and THROW_IO_ERROR.
Referenced by Parse(), and readBlock().
|
private |
Definition at line 1104 of file eagle_bin_parser.cpp.
References loadDouble(), loadS32(), m_buf, m_pos, EAGLE_BIN_PARSER::DRC_CTX::mdWireWire, EAGLE_BIN_PARSER::DRC_CTX::msWidth, EAGLE_BIN_PARSER::DRC_CTX::rvPadBottom, EAGLE_BIN_PARSER::DRC_CTX::rvPadInner, and EAGLE_BIN_PARSER::DRC_CTX::rvPadTop.
Referenced by Parse().
|
private |
Definition at line 1047 of file eagle_bin_parser.cpp.
References end, loadS32(), m_buf, m_freeText, m_freeTextCursor, and m_pos.
Referenced by Parse().
|
private |
Definition at line 832 of file eagle_bin_parser.cpp.
References _, m_buf, and THROW_IO_ERROR.
Referenced by loadBmb(), loadDouble(), loadS32(), loadStr(), and loadU32().
|
private |
Definition at line 2087 of file eagle_bin_parser.cpp.
References EAGLE_BIN_PARSER::EGB_NODE::children, EAGLE_BIN_PARSER::EGB_NODE::name, EAGLE_BIN_PARSER::EGB_NODE::props, and toXml().
|
private |
file contents, not owned
Definition at line 161 of file eagle_bin_parser.h.
Referenced by loadBmb(), loadDouble(), loadS32(), loadStr(), Parse(), readBlock(), readDrc(), readNotes(), and requireBytes().
|
private |
NUL-delimited notes strings.
Definition at line 166 of file eagle_bin_parser.h.
Referenced by nextLongText(), and readNotes().
|
private |
Definition at line 167 of file eagle_bin_parser.h.
Referenced by nextLongText(), and readNotes().
|
private |
returned when out of strings
Definition at line 168 of file eagle_bin_parser.h.
Referenced by nextLongText().
|
private |
current read cursor
Definition at line 162 of file eagle_bin_parser.h.
Referenced by Parse(), readBlock(), readDrc(), and readNotes().
|
private |
Definition at line 164 of file eagle_bin_parser.h.
Referenced by Parse().