KiCad PCB EDA Suite
Loading...
Searching...
No Matches
PADS_IO::BINARY_PARSER Class Reference

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 PARAMETERSGetParameters () 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_INFOGetLayerInfos () 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 DirEntrygetSection (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< DirEntrym_dirEntries
 
std::vector< uint8_t > m_stringPoolBytes
 
std::vector< LineVertexm_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< RouteSegmentm_routeSegments
 
std::vector< ViaLocationm_viaLocations
 
PARAMETERS m_parameters
 
std::vector< PARTm_parts
 
std::vector< NETm_nets
 
std::vector< ROUTEm_routes
 
std::vector< TEXTm_texts
 
std::vector< POURm_pours
 
std::vector< POLYLINEm_boardOutlines
 
std::map< std::string, PART_DECALm_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
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ BINARY_PARSER()

PADS_IO::BINARY_PARSER::BINARY_PARSER ( )
default

◆ ~BINARY_PARSER()

PADS_IO::BINARY_PARSER::~BINARY_PARSER ( )
default

Member Function Documentation

◆ dirEntryCount()

int PADS_IO::BINARY_PARSER::dirEntryCount ( ) const
private

Definition at line 120 of file pads_binary_parser.cpp.

References m_version.

Referenced by parseHeader().

◆ extractNetName()

std::string PADS_IO::BINARY_PARSER::extractNetName ( const uint8_t * aData,
size_t aOffset ) const
private

Definition at line 838 of file pads_binary_parser.cpp.

References name, and readFixedString().

◆ GetBoardOutlines()

const std::vector< POLYLINE > & PADS_IO::BINARY_PARSER::GetBoardOutlines ( ) const
inline

Definition at line 74 of file pads_binary_parser.h.

References m_boardOutlines.

◆ GetLayerCount()

int PADS_IO::BINARY_PARSER::GetLayerCount ( ) const
inline

Definition at line 76 of file pads_binary_parser.h.

References m_parameters.

◆ GetLayerInfos()

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.

◆ GetNets()

const std::vector< NET > & PADS_IO::BINARY_PARSER::GetNets ( ) const
inline

Definition at line 70 of file pads_binary_parser.h.

References m_nets.

◆ GetParameters()

const PARAMETERS & PADS_IO::BINARY_PARSER::GetParameters ( ) const
inline

Definition at line 68 of file pads_binary_parser.h.

References m_parameters.

◆ GetPartDecals()

const std::map< std::string, PART_DECAL > & PADS_IO::BINARY_PARSER::GetPartDecals ( ) const
inline

Definition at line 75 of file pads_binary_parser.h.

References m_decals.

◆ GetParts()

const std::vector< PART > & PADS_IO::BINARY_PARSER::GetParts ( ) const
inline

Definition at line 69 of file pads_binary_parser.h.

References m_parts.

◆ GetPours()

const std::vector< POUR > & PADS_IO::BINARY_PARSER::GetPours ( ) const
inline

Definition at line 73 of file pads_binary_parser.h.

References m_pours.

◆ GetRoutes()

const std::vector< ROUTE > & PADS_IO::BINARY_PARSER::GetRoutes ( ) const
inline

Definition at line 71 of file pads_binary_parser.h.

References m_routes.

◆ getSection()

◆ GetTexts()

const std::vector< TEXT > & PADS_IO::BINARY_PARSER::GetTexts ( ) const
inline

Definition at line 72 of file pads_binary_parser.h.

References m_texts.

◆ IsBasicUnits()

bool PADS_IO::BINARY_PARSER::IsBasicUnits ( ) const
inline

Definition at line 77 of file pads_binary_parser.h.

◆ IsBinaryPadsFile()

bool PADS_IO::BINARY_PARSER::IsBinaryPadsFile ( const wxString & aFileName)
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().

◆ isOldFormat()

bool PADS_IO::BINARY_PARSER::isOldFormat ( ) const
inlineprivate

◆ isValidNetName()

bool PADS_IO::BINARY_PARSER::isValidNetName ( const std::string & aName) const
private

Definition at line 852 of file pads_binary_parser.cpp.

Referenced by parseNetNames().

◆ Parse()

◆ parseBoardOutline()

◆ parseBoardSetup()

void PADS_IO::BINARY_PARSER::parseBoardSetup ( )
private

◆ parseCopperPours()

void PADS_IO::BINARY_PARSER::parseCopperPours ( )
private

Definition at line 1564 of file pads_binary_parser.cpp.

Referenced by Parse().

◆ parseDftConfig()

void PADS_IO::BINARY_PARSER::parseDftConfig ( size_t aStart,
size_t aEnd )
private

◆ parseDftDotPadded()

std::map< std::string, std::string > PADS_IO::BINARY_PARSER::parseDftDotPadded ( size_t aPos,
size_t aEnd ) const
private

Definition at line 1158 of file pads_binary_parser.cpp.

References config, and m_data.

Referenced by parseDftConfig().

◆ parseDftNullSeparated()

std::map< std::string, std::string > PADS_IO::BINARY_PARSER::parseDftNullSeparated ( size_t aPos,
size_t aEnd ) const
private

Definition at line 1230 of file pads_binary_parser.cpp.

References config, and m_data.

Referenced by parseDftConfig().

◆ parseDirectory()

void PADS_IO::BINARY_PARSER::parseDirectory ( )
private

◆ parseFooter()

void PADS_IO::BINARY_PARSER::parseFooter ( )
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().

◆ parseFootprintDefs()

◆ parseHeader()

void PADS_IO::BINARY_PARSER::parseHeader ( )
private

◆ parseLineVertices()

◆ parseMetadataRegion()

void PADS_IO::BINARY_PARSER::parseMetadataRegion ( )
private

◆ parseNetNames()

◆ parsePadStacks()

◆ parsePartDecals()

◆ parsePartPlacements()

◆ parseRouteVertices()

◆ parseSection19Parts()

◆ parseStringPool()

void PADS_IO::BINARY_PARSER::parseStringPool ( )
private

Definition at line 377 of file pads_binary_parser.cpp.

References m_stringPoolBytes, sectionData(), and sectionSize().

Referenced by Parse().

◆ parseTextRecords()

◆ readFixedString()

std::string PADS_IO::BINARY_PARSER::readFixedString ( size_t aOffset,
size_t aMaxLen ) const
private

◆ readI32()

int32_t PADS_IO::BINARY_PARSER::readI32 ( size_t aOffset) const
private

◆ readU16()

uint16_t PADS_IO::BINARY_PARSER::readU16 ( size_t aOffset) const
private

Definition at line 145 of file pads_binary_parser.cpp.

References m_data, and THROW_IO_ERROR.

Referenced by parseHeader(), and parsePadStacks().

◆ readU32()

uint32_t PADS_IO::BINARY_PARSER::readU32 ( size_t aOffset) const
private

◆ readU8()

uint8_t PADS_IO::BINARY_PARSER::readU8 ( size_t aOffset) const
private

◆ resolveString()

std::string PADS_IO::BINARY_PARSER::resolveString ( uint32_t aByteOffset) const
private

Definition at line 1289 of file pads_binary_parser.cpp.

References end, and m_stringPoolBytes.

Referenced by parseTextRecords().

◆ sectionData()

◆ sectionSize()

uint32_t PADS_IO::BINARY_PARSER::sectionSize ( int aIndex) const
private

◆ toBasicAngle()

double PADS_IO::BINARY_PARSER::toBasicAngle ( int32_t aRawAngle) const
private

◆ toBasicCoordX()

double PADS_IO::BINARY_PARSER::toBasicCoordX ( int32_t aRawValue) const
private

Definition at line 318 of file pads_binary_parser.cpp.

References m_originFound, and m_originX.

Referenced by parsePartPlacements(), parseSection19Parts(), and parseTextRecords().

◆ toBasicCoordY()

double PADS_IO::BINARY_PARSER::toBasicCoordY ( int32_t aRawValue) const
private

Definition at line 324 of file pads_binary_parser.cpp.

References m_originFound, and m_originY.

Referenced by parsePartPlacements(), parseSection19Parts(), and parseTextRecords().

Member Data Documentation

◆ ANGLE_SCALE

int32_t PADS_IO::BINARY_PARSER::ANGLE_SCALE = 1800000
staticconstexprprivate

Definition at line 86 of file pads_binary_parser.h.

Referenced by toBasicAngle().

◆ DIR_ENTRY_SIZE

int PADS_IO::BINARY_PARSER::DIR_ENTRY_SIZE = 16
staticconstexprprivate

Definition at line 85 of file pads_binary_parser.h.

Referenced by parseDirectory(), and parseMetadataRegion().

◆ FOOTER_SIZE

int PADS_IO::BINARY_PARSER::FOOTER_SIZE = 46
staticconstexprprivate

Definition at line 84 of file pads_binary_parser.h.

Referenced by parseFooter(), parseHeader(), and parseMetadataRegion().

◆ HEADER_SIZE

int PADS_IO::BINARY_PARSER::HEADER_SIZE = 10
staticconstexprprivate

Definition at line 83 of file pads_binary_parser.h.

Referenced by parseDirectory(), parseHeader(), and parseMetadataRegion().

◆ m_boardOutlines

std::vector<POLYLINE> PADS_IO::BINARY_PARSER::m_boardOutlines
private

Definition at line 208 of file pads_binary_parser.h.

Referenced by GetBoardOutlines(), and parseBoardOutline().

◆ m_data

◆ m_decals

std::map<std::string, PART_DECAL> PADS_IO::BINARY_PARSER::m_decals
private

Definition at line 209 of file pads_binary_parser.h.

Referenced by GetPartDecals(), and parsePartDecals().

◆ m_dirEntries

std::vector<DirEntry> PADS_IO::BINARY_PARSER::m_dirEntries
private

◆ m_fpTypeToDecal

std::map<std::string, std::string> PADS_IO::BINARY_PARSER::m_fpTypeToDecal
private

Definition at line 180 of file pads_binary_parser.h.

Referenced by parseFootprintDefs().

◆ m_lineVertices

std::vector<LineVertex> PADS_IO::BINARY_PARSER::m_lineVertices
private

Definition at line 169 of file pads_binary_parser.h.

Referenced by parseBoardOutline(), and parseLineVertices().

◆ m_nets

std::vector<NET> PADS_IO::BINARY_PARSER::m_nets
private

Definition at line 204 of file pads_binary_parser.h.

Referenced by GetNets(), and parseNetNames().

◆ m_numDirEntries

int PADS_IO::BINARY_PARSER::m_numDirEntries = 0
private

Definition at line 154 of file pads_binary_parser.h.

Referenced by parseDirectory(), parseHeader(), and parseMetadataRegion().

◆ m_originFound

bool PADS_IO::BINARY_PARSER::m_originFound = false
private

◆ m_originX

int32_t PADS_IO::BINARY_PARSER::m_originX = 0
private

Definition at line 172 of file pads_binary_parser.h.

Referenced by parseBoardSetup(), parseDftConfig(), and toBasicCoordX().

◆ m_originY

int32_t PADS_IO::BINARY_PARSER::m_originY = 0
private

Definition at line 173 of file pads_binary_parser.h.

Referenced by parseBoardSetup(), parseDftConfig(), and toBasicCoordY().

◆ m_padStackCache

std::map<int, std::vector<PAD_STACK_LAYER> > PADS_IO::BINARY_PARSER::m_padStackCache
private

Definition at line 177 of file pads_binary_parser.h.

Referenced by parsePadStacks().

◆ m_parameters

PARAMETERS PADS_IO::BINARY_PARSER::m_parameters
private

◆ m_parts

std::vector<PART> PADS_IO::BINARY_PARSER::m_parts
private

Definition at line 203 of file pads_binary_parser.h.

Referenced by GetParts(), Parse(), parsePartPlacements(), and parseSection19Parts().

◆ m_pours

std::vector<POUR> PADS_IO::BINARY_PARSER::m_pours
private

Definition at line 207 of file pads_binary_parser.h.

Referenced by GetPours().

◆ m_routes

std::vector<ROUTE> PADS_IO::BINARY_PARSER::m_routes
private

Definition at line 205 of file pads_binary_parser.h.

Referenced by GetRoutes(), and parseRouteVertices().

◆ m_routeSegments

std::vector<RouteSegment> PADS_IO::BINARY_PARSER::m_routeSegments
private

Definition at line 191 of file pads_binary_parser.h.

Referenced by parseRouteVertices().

◆ m_stringPoolBytes

std::vector<uint8_t> PADS_IO::BINARY_PARSER::m_stringPoolBytes
private

Definition at line 160 of file pads_binary_parser.h.

Referenced by parseStringPool(), and resolveString().

◆ m_texts

std::vector<TEXT> PADS_IO::BINARY_PARSER::m_texts
private

Definition at line 206 of file pads_binary_parser.h.

Referenced by GetTexts(), and parseTextRecords().

◆ m_version

uint16_t PADS_IO::BINARY_PARSER::m_version = 0
private

Definition at line 153 of file pads_binary_parser.h.

Referenced by dirEntryCount(), isOldFormat(), parseBoardOutline(), and parseHeader().

◆ m_viaLocations

std::vector<ViaLocation> PADS_IO::BINARY_PARSER::m_viaLocations
private

Definition at line 199 of file pads_binary_parser.h.

Referenced by parseRouteVertices().

◆ MAGIC

uint16_t PADS_IO::BINARY_PARSER::MAGIC = 0xFF00
staticconstexprprivate

Definition at line 82 of file pads_binary_parser.h.


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