|
KiCad PCB EDA Suite
|
Parser for PADS binary PCB file format (.pcb). More...
#include <pads_binary_parser.h>
Classes | |
| struct | DirEntry |
| struct | LineVertex |
| struct | RouteSegment |
| struct | ViaLocation |
Public Member Functions | |
| BINARY_PARSER () | |
| ~BINARY_PARSER () | |
| void | Parse (const wxString &aFileName) |
| const PARAMETERS & | GetParameters () const |
| const std::vector< PART > & | GetParts () const |
| const std::vector< NET > & | GetNets () const |
| const std::vector< ROUTE > & | GetRoutes () const |
| const std::vector< TEXT > & | GetTexts () const |
| const std::vector< POUR > & | GetPours () const |
| const std::vector< POLYLINE > & | GetBoardOutlines () const |
| const std::map< std::string, PART_DECAL > & | GetPartDecals () const |
| int | GetLayerCount () const |
| bool | IsBasicUnits () const |
| std::vector< LAYER_INFO > | GetLayerInfos () const |
Static Public Member Functions | |
| static bool | IsBinaryPadsFile (const wxString &aFileName) |
| Check if a file appears to be a PADS binary PCB file. | |
Private Member Functions | |
| bool | isOldFormat () const |
| int | dirEntryCount () const |
| uint8_t | readU8 (size_t aOffset) const |
| uint16_t | readU16 (size_t aOffset) const |
| uint32_t | readU32 (size_t aOffset) const |
| int32_t | readI32 (size_t aOffset) const |
| std::string | readFixedString (size_t aOffset, size_t aMaxLen) const |
| void | parseHeader () |
| void | parseFooter () |
| void | parseDirectory () |
| const uint8_t * | sectionData (int aIndex) const |
| uint32_t | sectionSize (int aIndex) const |
| const DirEntry * | getSection (int aIndex) const |
| void | parseBoardSetup () |
| void | parseStringPool () |
| void | parsePartPlacements () |
| void | parseSection19Parts () |
| void | parsePadStacks () |
| void | parsePartDecals () |
| void | parseFootprintDefs () |
| void | parseLineVertices () |
| void | parseBoardOutline () |
| void | parseNetNames () |
| void | parseMetadataRegion () |
| void | parseDftConfig (size_t aStart, size_t aEnd) |
| void | parseRouteVertices () |
| void | parseTextRecords () |
| void | parseCopperPours () |
| std::map< std::string, std::string > | parseDftDotPadded (size_t aPos, size_t aEnd) const |
| std::map< std::string, std::string > | parseDftNullSeparated (size_t aPos, size_t aEnd) const |
| std::string | extractNetName (const uint8_t *aData, size_t aOffset) const |
| bool | isValidNetName (const std::string &aName) const |
| std::string | resolveString (uint32_t aByteOffset) const |
| double | toBasicCoordX (int32_t aRawValue) const |
| double | toBasicCoordY (int32_t aRawValue) const |
| double | toBasicAngle (int32_t aRawAngle) const |
Private Attributes | |
| std::vector< uint8_t > | m_data |
| uint16_t | m_version = 0 |
| int | m_numDirEntries = 0 |
| std::vector< DirEntry > | m_dirEntries |
| std::vector< uint8_t > | m_stringPoolBytes |
| std::vector< LineVertex > | m_lineVertices |
| int32_t | m_originX = 0 |
| int32_t | m_originY = 0 |
| bool | m_originFound = false |
| std::map< int, std::vector< PAD_STACK_LAYER > > | m_padStackCache |
| std::map< std::string, std::string > | m_fpTypeToDecal |
| std::vector< RouteSegment > | m_routeSegments |
| std::vector< ViaLocation > | m_viaLocations |
| PARAMETERS | m_parameters |
| std::vector< PART > | m_parts |
| std::vector< NET > | m_nets |
| std::vector< ROUTE > | m_routes |
| std::vector< TEXT > | m_texts |
| std::vector< POUR > | m_pours |
| std::vector< POLYLINE > | m_boardOutlines |
| std::map< std::string, PART_DECAL > | m_decals |
Static Private Attributes | |
| static constexpr uint16_t | MAGIC = 0xFF00 |
| static constexpr int | HEADER_SIZE = 10 |
| static constexpr int | FOOTER_SIZE = 46 |
| static constexpr int | DIR_ENTRY_SIZE = 16 |
| static constexpr int32_t | ANGLE_SCALE = 1800000 |
Parser for PADS binary PCB file format (.pcb).
Reads the binary PADS file and populates the same intermediate structs as the ASCII PARSER class, allowing the existing struct-to-KiCad conversion code to be shared between both importers.
Binary file structure: [Header] 10 bytes: magic(2) + version(2) + reserved(6) [Section Directory] N*16 bytes per entry [Section Data] Concatenated section payloads [Metadata Region] Part types, components, nets, config, attributes [Footer] 46 bytes: padding(4) + GUID(38) + size_check(4)
Supported versions: 0x2021, 0x2025, 0x2026, 0x2027
Definition at line 54 of file pads_binary_parser.h.
|
default |
|
default |
|
private |
Definition at line 120 of file pads_binary_parser.cpp.
References m_version.
Referenced by parseHeader().
|
private |
Definition at line 838 of file pads_binary_parser.cpp.
References name, and readFixedString().
|
inline |
Definition at line 74 of file pads_binary_parser.h.
References m_boardOutlines.
|
inline |
Definition at line 76 of file pads_binary_parser.h.
References m_parameters.
| std::vector< LAYER_INFO > PADS_IO::BINARY_PARSER::GetLayerInfos | ( | ) | const |
Definition at line 1576 of file pads_binary_parser.cpp.
References info, m_parameters, and PADS_IO::ROUTING.
|
inline |
Definition at line 70 of file pads_binary_parser.h.
References m_nets.
|
inline |
Definition at line 68 of file pads_binary_parser.h.
References m_parameters.
|
inline |
Definition at line 75 of file pads_binary_parser.h.
References m_decals.
|
inline |
Definition at line 69 of file pads_binary_parser.h.
References m_parts.
|
inline |
Definition at line 73 of file pads_binary_parser.h.
References m_pours.
|
inline |
Definition at line 71 of file pads_binary_parser.h.
References m_routes.
|
private |
Definition at line 284 of file pads_binary_parser.cpp.
References m_dirEntries.
Referenced by parseBoardOutline(), parseFootprintDefs(), parseLineVertices(), parseNetNames(), parsePadStacks(), parsePartDecals(), parsePartPlacements(), parseRouteVertices(), parseSection19Parts(), parseTextRecords(), sectionData(), and sectionSize().
|
inline |
Definition at line 72 of file pads_binary_parser.h.
References m_texts.
|
inline |
Definition at line 77 of file pads_binary_parser.h.
|
static |
Check if a file appears to be a PADS binary PCB file.
Checks the 2-byte magic (0x00FF) and version field.
Definition at line 56 of file pads_binary_parser.cpp.
Referenced by PCB_IO_PADS_BINARY::CanReadBoard().
|
inlineprivate |
Definition at line 98 of file pads_binary_parser.h.
References m_version.
Referenced by parseFootprintDefs(), parseNetNames(), parsePadStacks(), parsePartDecals(), parsePartPlacements(), parseRouteVertices(), and parseSection19Parts().
|
private |
Definition at line 852 of file pads_binary_parser.cpp.
Referenced by parseNetNames().
| void PADS_IO::BINARY_PARSER::Parse | ( | const wxString & | aFileName | ) |
Definition at line 79 of file pads_binary_parser.cpp.
References m_data, m_parts, parseBoardOutline(), parseBoardSetup(), parseCopperPours(), parseDirectory(), parseFooter(), parseFootprintDefs(), parseHeader(), parseLineVertices(), parseMetadataRegion(), parseNetNames(), parsePadStacks(), parsePartDecals(), parsePartPlacements(), parseRouteVertices(), parseSection19Parts(), parseStringPool(), parseTextRecords(), and THROW_IO_ERROR.
Referenced by PCB_IO_PADS_BINARY::LoadBoard().
|
private |
Definition at line 772 of file pads_binary_parser.cpp.
References PADS_IO::POLYLINE::closed, PADS_IO::BINARY_PARSER::DirEntry::count, PADS_IO::BINARY_PARSER::DirEntry::dataOffset, getSection(), PADS_IO::POLYLINE::layer, m_boardOutlines, m_lineVertices, m_version, PADS_IO::POLYLINE::points, readU32(), sectionData(), PADS_IO::BINARY_PARSER::DirEntry::totalBytes, PADS_IO::POLYLINE::width, PADS_IO::BINARY_PARSER::LineVertex::x, and PADS_IO::BINARY_PARSER::LineVertex::y.
Referenced by Parse().
|
private |
Definition at line 339 of file pads_binary_parser.cpp.
References m_dirEntries, m_originFound, m_originX, m_originY, m_parameters, PADS_IO::MILS, readI32(), readU32(), sectionData(), and sectionSize().
Referenced by Parse().
|
private |
Definition at line 1564 of file pads_binary_parser.cpp.
Referenced by Parse().
|
private |
Definition at line 1075 of file pads_binary_parser.cpp.
References config, m_data, m_originFound, m_originX, m_originY, m_parameters, parseDftDotPadded(), and parseDftNullSeparated().
Referenced by parseMetadataRegion().
|
private |
Definition at line 1158 of file pads_binary_parser.cpp.
References config, and m_data.
Referenced by parseDftConfig().
|
private |
Definition at line 1230 of file pads_binary_parser.cpp.
References config, and m_data.
Referenced by parseDftConfig().
|
private |
Definition at line 245 of file pads_binary_parser.cpp.
References DIR_ENTRY_SIZE, HEADER_SIZE, PADS_IO::BINARY_PARSER::DirEntry::index, m_data, m_dirEntries, m_numDirEntries, readU32(), and THROW_IO_ERROR.
Referenced by Parse().
|
private |
Definition at line 226 of file pads_binary_parser.cpp.
References expected, PADS_IO::FOOTER_GUID, FOOTER_SIZE, m_data, readU32(), and THROW_IO_ERROR.
Referenced by Parse().
|
private |
Definition at line 668 of file pads_binary_parser.cpp.
References PADS_IO::BINARY_PARSER::DirEntry::count, PADS_IO::BINARY_PARSER::DirEntry::dataOffset, getSection(), isOldFormat(), m_fpTypeToDecal, PADS_IO::BINARY_PARSER::DirEntry::perItem, readFixedString(), readU32(), sectionData(), and PADS_IO::BINARY_PARSER::DirEntry::totalBytes.
Referenced by Parse().
|
private |
Definition at line 209 of file pads_binary_parser.cpp.
References dirEntryCount(), FOOTER_SIZE, HEADER_SIZE, m_data, m_numDirEntries, m_version, readU16(), and THROW_IO_ERROR.
Referenced by Parse().
|
private |
Definition at line 738 of file pads_binary_parser.cpp.
References PADS_IO::BINARY_PARSER::DirEntry::count, PADS_IO::BINARY_PARSER::DirEntry::dataOffset, PADS_IO::BINARY_PARSER::LineVertex::extra, getSection(), m_lineVertices, readI32(), readU32(), sectionData(), PADS_IO::BINARY_PARSER::DirEntry::totalBytes, PADS_IO::BINARY_PARSER::LineVertex::x, and PADS_IO::BINARY_PARSER::LineVertex::y.
Referenced by Parse().
|
private |
Definition at line 1045 of file pads_binary_parser.cpp.
References DIR_ENTRY_SIZE, end, FOOTER_SIZE, HEADER_SIZE, m_data, m_dirEntries, m_numDirEntries, m_originFound, and parseDftConfig().
Referenced by Parse().
|
private |
Definition at line 865 of file pads_binary_parser.cpp.
References PADS_IO::BINARY_PARSER::DirEntry::count, PADS_IO::BINARY_PARSER::DirEntry::dataOffset, getSection(), isOldFormat(), isValidNetName(), m_nets, name, PADS_IO::NET::name, PADS_IO::BINARY_PARSER::DirEntry::perItem, readFixedString(), readU32(), sectionData(), and PADS_IO::BINARY_PARSER::DirEntry::totalBytes.
Referenced by Parse().
|
private |
Definition at line 536 of file pads_binary_parser.cpp.
References PADS_IO::BINARY_PARSER::DirEntry::count, PADS_IO::BINARY_PARSER::DirEntry::dataOffset, PADS_IO::PAD_STACK_LAYER::drill, PADS_IO::PAD_STACK_LAYER::finger_offset, getSection(), isOldFormat(), PADS_IO::PAD_STACK_LAYER::layer, m_padStackCache, PADS_IO::PAD_SHAPE_NAMES, PADS_IO::BINARY_PARSER::DirEntry::perItem, PADS_IO::PAD_STACK_LAYER::plated, readI32(), readU16(), readU8(), PADS_IO::PAD_STACK_LAYER::rotation, sectionData(), PADS_IO::PAD_STACK_LAYER::shape, PADS_IO::PAD_STACK_LAYER::sizeA, PADS_IO::PAD_STACK_LAYER::sizeB, toBasicAngle(), and PADS_IO::BINARY_PARSER::DirEntry::totalBytes.
Referenced by Parse().
|
private |
Definition at line 615 of file pads_binary_parser.cpp.
References PADS_IO::BINARY_PARSER::DirEntry::count, PADS_IO::BINARY_PARSER::DirEntry::dataOffset, getSection(), isOldFormat(), m_decals, name, PADS_IO::PART_DECAL::name, PADS_IO::BINARY_PARSER::DirEntry::perItem, readFixedString(), readU8(), sectionData(), PADS_IO::BINARY_PARSER::DirEntry::totalBytes, and PADS_IO::PART_DECAL::units.
Referenced by Parse().
|
private |
Definition at line 389 of file pads_binary_parser.cpp.
References PADS_IO::PART::bottom_layer, PADS_IO::BINARY_PARSER::DirEntry::count, PADS_IO::BINARY_PARSER::DirEntry::dataOffset, getSection(), isOldFormat(), PADS_IO::PART::location, m_parts, PADS_IO::PART::name, PADS_IO::BINARY_PARSER::DirEntry::perItem, readFixedString(), readI32(), PADS_IO::PART::rotation, sectionData(), toBasicAngle(), toBasicCoordX(), toBasicCoordY(), PADS_IO::BINARY_PARSER::DirEntry::totalBytes, PADS_IO::PART::units, PADS_IO::POINT::x, and PADS_IO::POINT::y.
Referenced by Parse().
|
private |
Definition at line 1367 of file pads_binary_parser.cpp.
References PADS_IO::BINARY_PARSER::DirEntry::count, PADS_IO::BINARY_PARSER::DirEntry::dataOffset, getSection(), isOldFormat(), PADS_IO::TRACK::layer, PADS_IO::VIA::location, m_routes, m_routeSegments, m_viaLocations, PADS_IO::ROUTE::net_name, PADS_IO::BINARY_PARSER::DirEntry::perItem, PADS_IO::TRACK::points, readI32(), readU32(), readU8(), sectionData(), PADS_IO::BINARY_PARSER::DirEntry::totalBytes, PADS_IO::ROUTE::tracks, via, PADS_IO::ROUTE::vias, PADS_IO::BINARY_PARSER::RouteSegment::width, PADS_IO::TRACK::width, PADS_IO::POINT::x, PADS_IO::BINARY_PARSER::RouteSegment::x1, PADS_IO::BINARY_PARSER::RouteSegment::x2, PADS_IO::POINT::y, PADS_IO::BINARY_PARSER::RouteSegment::y1, and PADS_IO::BINARY_PARSER::RouteSegment::y2.
Referenced by Parse().
|
private |
Definition at line 454 of file pads_binary_parser.cpp.
References PADS_IO::PART::bottom_layer, PADS_IO::BINARY_PARSER::DirEntry::dataOffset, getSection(), isOldFormat(), PADS_IO::PART::location, m_parts, PADS_IO::PART::name, readFixedString(), readI32(), PADS_IO::PART::rotation, sectionData(), sectionSize(), toBasicAngle(), toBasicCoordX(), toBasicCoordY(), PADS_IO::BINARY_PARSER::DirEntry::totalBytes, PADS_IO::PART::units, PADS_IO::POINT::x, and PADS_IO::POINT::y.
Referenced by Parse().
|
private |
Definition at line 377 of file pads_binary_parser.cpp.
References m_stringPoolBytes, sectionData(), and sectionSize().
Referenced by Parse().
|
private |
Definition at line 1309 of file pads_binary_parser.cpp.
References PADS_IO::BINARY_PARSER::DirEntry::count, PADS_IO::BINARY_PARSER::DirEntry::dataOffset, getSection(), m_texts, PADS_IO::BINARY_PARSER::DirEntry::perItem, readI32(), readU32(), readU8(), resolveString(), sectionData(), text, toBasicAngle(), toBasicCoordX(), toBasicCoordY(), and PADS_IO::BINARY_PARSER::DirEntry::totalBytes.
Referenced by Parse().
|
private |
Definition at line 179 of file pads_binary_parser.cpp.
References end, m_data, and result.
Referenced by extractNetName(), parseFootprintDefs(), parseNetNames(), parsePartDecals(), parsePartPlacements(), and parseSection19Parts().
|
private |
Definition at line 173 of file pads_binary_parser.cpp.
References readU32().
Referenced by parseBoardSetup(), parseLineVertices(), parsePadStacks(), parsePartPlacements(), parseRouteVertices(), parseSection19Parts(), and parseTextRecords().
|
private |
Definition at line 145 of file pads_binary_parser.cpp.
References m_data, and THROW_IO_ERROR.
Referenced by parseHeader(), and parsePadStacks().
|
private |
Definition at line 158 of file pads_binary_parser.cpp.
References m_data, and THROW_IO_ERROR.
Referenced by parseBoardOutline(), parseBoardSetup(), parseDirectory(), parseFooter(), parseFootprintDefs(), parseLineVertices(), parseNetNames(), parseRouteVertices(), parseTextRecords(), and readI32().
|
private |
Definition at line 133 of file pads_binary_parser.cpp.
References m_data, and THROW_IO_ERROR.
Referenced by parsePadStacks(), parsePartDecals(), parseRouteVertices(), and parseTextRecords().
|
private |
Definition at line 1289 of file pads_binary_parser.cpp.
References end, and m_stringPoolBytes.
Referenced by parseTextRecords().
|
private |
Definition at line 293 of file pads_binary_parser.cpp.
References PADS_IO::BINARY_PARSER::DirEntry::dataOffset, getSection(), m_data, and PADS_IO::BINARY_PARSER::DirEntry::totalBytes.
Referenced by parseBoardOutline(), parseBoardSetup(), parseFootprintDefs(), parseLineVertices(), parseNetNames(), parsePadStacks(), parsePartDecals(), parsePartPlacements(), parseRouteVertices(), parseSection19Parts(), parseStringPool(), and parseTextRecords().
|
private |
Definition at line 307 of file pads_binary_parser.cpp.
References getSection(), and PADS_IO::BINARY_PARSER::DirEntry::totalBytes.
Referenced by parseBoardSetup(), parseSection19Parts(), and parseStringPool().
|
private |
Definition at line 330 of file pads_binary_parser.cpp.
References ANGLE_SCALE.
Referenced by parsePadStacks(), parsePartPlacements(), parseSection19Parts(), and parseTextRecords().
|
private |
Definition at line 318 of file pads_binary_parser.cpp.
References m_originFound, and m_originX.
Referenced by parsePartPlacements(), parseSection19Parts(), and parseTextRecords().
|
private |
Definition at line 324 of file pads_binary_parser.cpp.
References m_originFound, and m_originY.
Referenced by parsePartPlacements(), parseSection19Parts(), and parseTextRecords().
|
staticconstexprprivate |
Definition at line 86 of file pads_binary_parser.h.
Referenced by toBasicAngle().
|
staticconstexprprivate |
Definition at line 85 of file pads_binary_parser.h.
Referenced by parseDirectory(), and parseMetadataRegion().
|
staticconstexprprivate |
Definition at line 84 of file pads_binary_parser.h.
Referenced by parseFooter(), parseHeader(), and parseMetadataRegion().
|
staticconstexprprivate |
Definition at line 83 of file pads_binary_parser.h.
Referenced by parseDirectory(), parseHeader(), and parseMetadataRegion().
|
private |
Definition at line 208 of file pads_binary_parser.h.
Referenced by GetBoardOutlines(), and parseBoardOutline().
|
private |
Definition at line 152 of file pads_binary_parser.h.
Referenced by Parse(), parseDftConfig(), parseDftDotPadded(), parseDftNullSeparated(), parseDirectory(), parseFooter(), parseHeader(), parseMetadataRegion(), readFixedString(), readU16(), readU32(), readU8(), and sectionData().
|
private |
Definition at line 209 of file pads_binary_parser.h.
Referenced by GetPartDecals(), and parsePartDecals().
|
private |
Definition at line 157 of file pads_binary_parser.h.
Referenced by getSection(), parseBoardSetup(), parseDirectory(), and parseMetadataRegion().
|
private |
Definition at line 180 of file pads_binary_parser.h.
Referenced by parseFootprintDefs().
|
private |
Definition at line 169 of file pads_binary_parser.h.
Referenced by parseBoardOutline(), and parseLineVertices().
|
private |
Definition at line 204 of file pads_binary_parser.h.
Referenced by GetNets(), and parseNetNames().
|
private |
Definition at line 154 of file pads_binary_parser.h.
Referenced by parseDirectory(), parseHeader(), and parseMetadataRegion().
|
private |
Definition at line 174 of file pads_binary_parser.h.
Referenced by parseBoardSetup(), parseDftConfig(), parseMetadataRegion(), toBasicCoordX(), and toBasicCoordY().
|
private |
Definition at line 172 of file pads_binary_parser.h.
Referenced by parseBoardSetup(), parseDftConfig(), and toBasicCoordX().
|
private |
Definition at line 173 of file pads_binary_parser.h.
Referenced by parseBoardSetup(), parseDftConfig(), and toBasicCoordY().
|
private |
Definition at line 177 of file pads_binary_parser.h.
Referenced by parsePadStacks().
|
private |
Definition at line 202 of file pads_binary_parser.h.
Referenced by GetLayerCount(), GetLayerInfos(), GetParameters(), parseBoardSetup(), and parseDftConfig().
|
private |
Definition at line 203 of file pads_binary_parser.h.
Referenced by GetParts(), Parse(), parsePartPlacements(), and parseSection19Parts().
|
private |
Definition at line 207 of file pads_binary_parser.h.
Referenced by GetPours().
|
private |
Definition at line 205 of file pads_binary_parser.h.
Referenced by GetRoutes(), and parseRouteVertices().
|
private |
Definition at line 191 of file pads_binary_parser.h.
Referenced by parseRouteVertices().
|
private |
Definition at line 160 of file pads_binary_parser.h.
Referenced by parseStringPool(), and resolveString().
|
private |
Definition at line 206 of file pads_binary_parser.h.
Referenced by GetTexts(), and parseTextRecords().
|
private |
Definition at line 153 of file pads_binary_parser.h.
Referenced by dirEntryCount(), isOldFormat(), parseBoardOutline(), and parseHeader().
|
private |
Definition at line 199 of file pads_binary_parser.h.
Referenced by parseRouteVertices().
|
staticconstexprprivate |
Definition at line 82 of file pads_binary_parser.h.