KiCad PCB EDA Suite
Loading...
Searching...
No Matches
PADS_IO Namespace Reference

Namespaces

namespace  DRW_ITEM
 
namespace  DRW_ITEM_V2022
 
namespace  DRW_TAG
 

Classes

struct  ARC
 Arc as center, radius and angles. More...
 
struct  ARC_POINT
 A polyline point that may instead be an arc segment. More...
 
struct  ARC_VERTEX
 One board-outline vertex triplet: [i32 X, i32 Y, i32 attr] where attr -1 is a plain corner and attr >= 0 is the arc-parameter ordinal. More...
 
struct  ATTRIBUTE
 
struct  BIN_NET_CLASS_DEF
 A PADS net class recovered from the binary design-rule graph. More...
 
class  BINARY_CURSOR
 Bounds-checked little-endian read cursor over a PADS binary buffer. More...
 
class  BINARY_PARSER
 Reader for the PADS PowerPCB binary .pcb format. More...
 
struct  BOARD_ITEM
 
struct  CLUSTER
 
struct  COPPER_SHAPE
 Standalone copper area from the LINES section (type=COPPER), not part of a pour. More...
 
struct  DECAL_ITEM
 
struct  DECAL_PAD
 
struct  DESIGN_RULES
 
struct  DIFF_PAIR_DEF
 
struct  DIMENSION
 
struct  FILE_HEADER
 
struct  GATE_DEF
 
struct  GATE_PIN
 
struct  GRAPHIC_LINE
 Non-electrical drawing item from the LINES section (type=LINES). More...
 
struct  JUMPER_DEF
 
struct  JUMPER_MARKER
 
struct  KEEPOUT
 
struct  LAYER_INFO
 
struct  LINE
 
struct  NET
 
struct  NET_CLASS_DEF
 
struct  NET_CLASS_RULE_EDGE
 One type-66 net-class rule edge: its owner pointer, rule-detail page, full rule pointer (declaration order within a page), layer and file offset. More...
 
struct  NET_PIN
 
struct  PAD_STACK_LAYER
 
class  PADS_SDB
 The parsed container of a PADS .pcb file: header, the section directory, and the coordinate system. More...
 
struct  PADSTACK_LAYOUT
 
struct  PARAMETERS
 
class  PARSER
 
struct  PART
 
struct  PART_CLUSTER
 A PADS part cluster (named group of parts). More...
 
struct  PART_DECAL
 
struct  PART_TYPE
 
struct  POINT
 
struct  POLYLINE
 A polyline that may contain arc segments, used for board outlines and graphics. More...
 
struct  POUR
 
struct  REUSE_BLOCK
 A reuse block definition containing parts and routes that can be instantiated. More...
 
struct  REUSE_INSTANCE
 
struct  REUSE_NET
 
struct  ROUTE
 
class  SDB_COORDS
 The per-axis coordinate origin and the design <-> raw transform. More...
 
struct  SDB_FOOTER_ERROR
 Where a footer check failed and what was wrong with it. More...
 
class  SDB_RECORD
 A bounds-checked reader positioned at one record inside a buffer. More...
 
struct  SDB_SECTION
 The PADS PowerPCB .pcb file is a serialized snapshot of PADS' in-memory SDB (System DataBase) object store. More...
 
struct  SIGPIN
 
struct  TEARDROP
 
struct  TERMINAL
 
struct  TEST_POINT
 
struct  TEXT
 
struct  TRACK
 
struct  VIA
 
struct  VIA_DEF
 

Enumerations

enum class  SECTION : int {
  BoardSetup = 1 , PadStacks = 4 , PadShapes = 5 , FreeText = 8 ,
  StringPool = 9 , DrwItems = 10 , GraphicPieces = 11 , Vertices = 12 ,
  DecalLibrary = 13 , DecalHeader = 14 , TerminalPool = 15 , ParttypeDefs = 17 ,
  PartPins = 19 , Placements = 22 , Nets = 23 , Connections = 24 ,
  ClearanceRules = 49 , PourTokensA = 52 , PourTokensB = 53 , PourTokensC = 54 ,
  PourTokensD = 55 , Vias = 60 , RouteObjects = 62 , RouteLayers = 63 ,
  RouteCells = 64 , Clusters = 68 , LayerTable = 69
}
 Named section indices into the PADS binary section directory. More...
 
enum class  UNIT_TYPE { MILS , METRIC , INCHES }
 
enum class  PADS_FILE_TYPE {
  PCB , LIB_LINE , LIB_SCH_DECAL , LIB_PCB_DECAL ,
  LIB_PART_TYPE
}
 
enum class  VIA_TYPE { THROUGH , BLIND , BURIED , MICROVIA }
 
enum class  POUR_STYLE { SOLID , HATCHED , VOIDOUT }
 
enum class  THERMAL_TYPE { NONE , PAD , VIA }
 
enum class  PIN_ELEC_TYPE {
  UNDEFINED , SOURCE , BIDIRECTIONAL , OPEN_COLLECTOR ,
  TRISTATE , LOAD , TERMINATOR , POWER ,
  GROUND
}
 
enum class  LINE_STYLE {
  SOLID = 0 , DASHED = 1 , DOTTED = 2 , DASH_DOTTED = 3 ,
  DASH_DOUBLE_DOTTED = 4
}
 
enum class  PADS_LAYER_FUNCTION {
  UNKNOWN , ROUTING , PLANE , MIXED ,
  UNASSIGNED , SOLDER_MASK , PASTE_MASK , SILK_SCREEN ,
  ASSEMBLY , DOCUMENTATION , DRILL
}
 
enum class  KEEPOUT_TYPE {
  ALL , ROUTE , VIA , COPPER ,
  PLACEMENT
}
 

Functions

std::optional< SDB_FOOTER_ERRORCheckSdbFooter (const std::vector< uint8_t > &aData, size_t aFooterStart, const char *aGuid, size_t aGuidLen)
 Check a PADS SDB footer at aFooterStart: the ASCII GUID followed by an absolute back-pointer to the serialized container-item array.
 
void ValidateSdbFooter (const std::vector< uint8_t > &aData, size_t aFooterStart, const char *aGuid, size_t aGuidLen)
 As CheckSdbFooter, throwing a bare IO_ERROR on failure.
 
uint8_t getU8 (const std::vector< uint8_t > &aData, size_t aOffset)
 Little-endian byte assembly with no bounds checking.
 
uint16_t getU16LE (const std::vector< uint8_t > &aData, size_t aOffset)
 
uint32_t getU32LE (const std::vector< uint8_t > &aData, size_t aOffset)
 
double getF64LE (const std::vector< uint8_t > &aData, size_t aOffset)
 
float getF32LE (const std::vector< uint8_t > &aData, size_t aOffset)
 
bool ReadFileHeader (const wxString &aFileName, std::vector< uint8_t > &aOut, size_t aCount)
 Read at most aCount leading bytes of aFileName into aOut, which is sized to what was actually read.
 
bool ReadFileToBuffer (const wxString &aFileName, std::vector< uint8_t > &aOut)
 Read an entire file into aOut.
 
std::string readFixedStringRaw (const std::vector< uint8_t > &aData, size_t aOffset, size_t aMaxLen)
 Read a NUL-terminated fixed-width field starting at aOffset, scanning at most aMaxLen bytes, WITHOUT trimming.
 
std::string readFixedString (const std::vector< uint8_t > &aData, size_t aOffset, size_t aMaxLen)
 As readFixedStringRaw, then trim trailing spaces.
 
bool HasSdbMagic (const std::vector< uint8_t > &aData, uint8_t aMagic1)
 Check the PADS SDB container magic, a leading 0x00 followed by a format-specific second byte.
 
static const PADSTACK_LAYOUTpadstackLayout (uint16_t aVersion)
 
static void logParsePhase (const char *aWhat, std::chrono::steady_clock::time_point aStart)
 Enabled by setting KICAD_PADS_PROFILE.
 
static void logResolvedBase (int aSection, const char *aWhat, size_t aResolved, uint32_t aPhysical)
 Report a structurally derived physical section base for cross-checking the Kaitai grammar.
 
static bool viaRecordValid (const BINARY_CURSOR &aCur, size_t aTypeByte)
 
static ARC deriveArc (const SDB_RECORD &aArcRecord, const ARC_VERTEX &aStart, const ARC_VERTEX &aEnd, double aOriginX, double aOriginY)
 
bool IsThermalReliefPadRow (const PAD_STACK_LAYER &aLayer)
 RT and ST rows carry a plane's thermal-relief spoke pattern rather than the pad's own copper.
 
bool IsAntiPadRow (const PAD_STACK_LAYER &aLayer)
 RA and SA rows carry a plane's anti-pad clearance rather than the pad's own copper.
 
bool IsCopperPadRow (const PAD_STACK_LAYER &aLayer)
 True when the row describes pad or via copper.
 
static std::vector< std::string > expandShortcutPattern (const std::string &aPattern)
 Expand a shortcut format string like "PRE{n1-n2}" into individual names.
 
static std::string normalizeNetName (const std::string &aNetName)
 

Variables

constexpr uint16_t SDB_RECORD_SENTINEL = 0xFFFE
 
constexpr double SDB_BASIC_PER_MIL = 38100.0
 
static const std::map< uint8_t, std::string > PAD_SHAPE_NAMES
 
static constexpr int DECAL_NAME_OFFSET = 44
 Rotation between the physical section cursor and the logical record base.
 
static constexpr int VIA_TYPE = 0x0E
 
static const char FOOTER_GUID [] = "{2FE18320-6448-11d1-A412-000000000000}"
 
static constexpr size_t FOOTER_GUID_LEN = 38
 

Enumeration Type Documentation

◆ KEEPOUT_TYPE

enum class PADS_IO::KEEPOUT_TYPE
strong
Enumerator
ALL 
ROUTE 
VIA 
COPPER 
PLACEMENT 

Definition at line 640 of file pads_parser.h.

◆ LINE_STYLE

enum class PADS_IO::LINE_STYLE
strong
Enumerator
SOLID 
DASHED 
DOTTED 
DASH_DOTTED 
DASH_DOUBLE_DOTTED 

Definition at line 495 of file pads_parser.h.

◆ PADS_FILE_TYPE

enum class PADS_IO::PADS_FILE_TYPE
strong
Enumerator
PCB 
LIB_LINE 

Library line items (drafting)

LIB_SCH_DECAL 
LIB_PCB_DECAL 

Library footprints.

LIB_PART_TYPE 

Definition at line 93 of file pads_parser.h.

◆ PADS_LAYER_FUNCTION

enum class PADS_IO::PADS_LAYER_FUNCTION
strong
Enumerator
UNKNOWN 
ROUTING 
PLANE 
MIXED 
UNASSIGNED 
SOLDER_MASK 
PASTE_MASK 
SILK_SCREEN 
ASSEMBLY 
DOCUMENTATION 
DRILL 

Definition at line 549 of file pads_parser.h.

◆ PIN_ELEC_TYPE

enum class PADS_IO::PIN_ELEC_TYPE
strong
Enumerator
UNDEFINED 

U.

SOURCE 

S.

BIDIRECTIONAL 

B.

OPEN_COLLECTOR 

C, open collector or or-tieable source.

TRISTATE 

T.

LOAD 

L.

TERMINATOR 

Z.

POWER 

P.

GROUND 

G.

Definition at line 421 of file pads_parser.h.

◆ POUR_STYLE

enum class PADS_IO::POUR_STYLE
strong
Enumerator
SOLID 

POUROUT, POLY.

HATCHED 

HATOUT.

VOIDOUT 

Definition at line 340 of file pads_parser.h.

◆ SECTION

enum class PADS_IO::SECTION : int
strong

Named section indices into the PADS binary section directory.

Each enumerator's value IS the directory index, so a section constant reads as its role rather than a bare integer.

Enumerator
BoardSetup 
PadStacks 
PadShapes 
FreeText 
StringPool 
DrwItems 
GraphicPieces 
Vertices 
DecalLibrary 
DecalHeader 
TerminalPool 
ParttypeDefs 
PartPins 
Placements 
Nets 
Connections 
ClearanceRules 
PourTokensA 
PourTokensB 
PourTokensC 
PourTokensD 
Vias 
RouteObjects 
RouteLayers 
RouteCells 
Clusters 
LayerTable 

Definition at line 46 of file pads_binary_parser.h.

◆ THERMAL_TYPE

enum class PADS_IO::THERMAL_TYPE
strong
Enumerator
NONE 
PAD 

PADTHERM.

VIA 

VIATHERM.

Definition at line 347 of file pads_parser.h.

◆ UNIT_TYPE

enum class PADS_IO::UNIT_TYPE
strong
Enumerator
MILS 
METRIC 
INCHES 

Definition at line 33 of file pads_parser.h.

◆ VIA_TYPE

enum class PADS_IO::VIA_TYPE
strong
Enumerator
THROUGH 

Spans all copper layers.

BLIND 

Surface to inner layer.

BURIED 

Inner layers only.

MICROVIA 

Single-layer blind, typically HDI.

Definition at line 308 of file pads_parser.h.

Function Documentation

◆ CheckSdbFooter()

std::optional< SDB_FOOTER_ERROR > PADS_IO::CheckSdbFooter ( const std::vector< uint8_t > & aData,
size_t aFooterStart,
const char * aGuid,
size_t aGuidLen )

Check a PADS SDB footer at aFooterStart: the ASCII GUID followed by an absolute back-pointer to the serialized container-item array.

Returns the failing offset and reason, or an empty optional when the footer is well formed. The GUID differs per format, so the caller supplies it. Reporting rather than throwing keeps the offset with the check that knows it, so callers need not re-derive which check tripped.

Definition at line 31 of file pads_binary_utils.cpp.

References getU32LE().

Referenced by ValidateSdbFooter(), and PADS_SCH_BINARY::PADS_SCH_SDB::verifyFooter().

◆ deriveArc()

static ARC PADS_IO::deriveArc ( const SDB_RECORD & aArcRecord,
const ARC_VERTEX & aStart,
const ARC_VERTEX & aEnd,
double aOriginX,
double aOriginY )
static

◆ expandShortcutPattern()

static std::vector< std::string > PADS_IO::expandShortcutPattern ( const std::string & aPattern)
static

Expand a shortcut format string like "PRE{n1-n2}" into individual names.

Format: PREFIX{start-end} expands to PREFIX+start, PREFIX+(start+1), ..., PREFIX+end Example: "C{2-5}" expands to ["C2", "C3", "C4", "C5"]

Parameters
aPatternThe pattern string to expand
Returns
Vector of expanded names, or single-element vector with original if not a pattern

Definition at line 63 of file pads_parser.cpp.

References std::abs(), end, PADS_COMMON::ParseInt(), result, and tracePadsIo.

Referenced by PADS_IO::PARSER::parseSectionPARTS().

◆ getF32LE()

float PADS_IO::getF32LE ( const std::vector< uint8_t > & aData,
size_t aOffset )
inline

Definition at line 89 of file pads_binary_utils.h.

References getU32LE().

Referenced by PADS_IO::BINARY_CURSOR::F32At().

◆ getF64LE()

double PADS_IO::getF64LE ( const std::vector< uint8_t > & aData,
size_t aOffset )
inline

Definition at line 75 of file pads_binary_utils.h.

Referenced by PADS_IO::BINARY_CURSOR::F64At().

◆ getU16LE()

uint16_t PADS_IO::getU16LE ( const std::vector< uint8_t > & aData,
size_t aOffset )
inline

◆ getU32LE()

uint32_t PADS_IO::getU32LE ( const std::vector< uint8_t > & aData,
size_t aOffset )
inline

Definition at line 66 of file pads_binary_utils.h.

Referenced by CheckSdbFooter(), getF32LE(), and PADS_IO::BINARY_CURSOR::U32At().

◆ getU8()

uint8_t PADS_IO::getU8 ( const std::vector< uint8_t > & aData,
size_t aOffset )
inline

Little-endian byte assembly with no bounds checking.

Callers that need a bounds-checked policy wrap these.

Definition at line 53 of file pads_binary_utils.h.

Referenced by PADS_IO::BINARY_CURSOR::U8At().

◆ HasSdbMagic()

bool PADS_IO::HasSdbMagic ( const std::vector< uint8_t > & aData,
uint8_t aMagic1 )
inline

Check the PADS SDB container magic, a leading 0x00 followed by a format-specific second byte.

The version word at +2 is range-checked by the caller because the supported version set differs per format.

Definition at line 192 of file pads_binary_utils.h.

Referenced by PADS_SCH_BINARY::PADS_SCH_SDB::HasFamilyMagic(), PADS_IO::PADS_SDB::HasMagic(), and PADS_IO::BINARY_PARSER::IsBinaryPadsFile().

◆ IsAntiPadRow()

bool PADS_IO::IsAntiPadRow ( const PAD_STACK_LAYER & aLayer)

RA and SA rows carry a plane's anti-pad clearance rather than the pad's own copper.

Definition at line 42 of file pads_parser.cpp.

References PADS_IO::PAD_STACK_LAYER::shape.

Referenced by PCB_IO_PADS_BINARY::buildPad(), IsCopperPadRow(), and PCB_IO_PADS::loadFootprints().

◆ IsCopperPadRow()

bool PADS_IO::IsCopperPadRow ( const PAD_STACK_LAYER & aLayer)

True when the row describes pad or via copper.

Relief and anti-pad rows share the layer ordinals of the copper rows they qualify, so every consumer of a padstack has to skip them.

Definition at line 48 of file pads_parser.cpp.

References IsAntiPadRow(), and IsThermalReliefPadRow().

Referenced by PCB_IO_PADS_BINARY::buildPad(), PCB_IO_PADS::loadFootprints(), and PCB_IO_PADS_BINARY::loadTracksAndVias().

◆ IsThermalReliefPadRow()

bool PADS_IO::IsThermalReliefPadRow ( const PAD_STACK_LAYER & aLayer)

RT and ST rows carry a plane's thermal-relief spoke pattern rather than the pad's own copper.

Definition at line 36 of file pads_parser.cpp.

References PADS_IO::PAD_STACK_LAYER::shape.

Referenced by PCB_IO_PADS_BINARY::buildPad(), IsCopperPadRow(), and PCB_IO_PADS::loadFootprints().

◆ logParsePhase()

static void PADS_IO::logParsePhase ( const char * aWhat,
std::chrono::steady_clock::time_point aStart )
static

Enabled by setting KICAD_PADS_PROFILE.

Definition at line 192 of file pads_binary_parser.cpp.

◆ logResolvedBase()

static void PADS_IO::logResolvedBase ( int aSection,
const char * aWhat,
size_t aResolved,
uint32_t aPhysical )
static

Report a structurally derived physical section base for cross-checking the Kaitai grammar.

Enabled by setting KICAD_PADS_SECBASE.

Definition at line 675 of file pads_binary_parser.cpp.

Referenced by PADS_IO::BINARY_PARSER::decodeViaLocations(), and PADS_IO::BINARY_PARSER::parseNetConnectionsNew().

◆ normalizeNetName()

static std::string PADS_IO::normalizeNetName ( const std::string & aNetName)
static

◆ padstackLayout()

static const PADSTACK_LAYOUT & PADS_IO::padstackLayout ( uint16_t aVersion)
static

Definition at line 72 of file pads_binary_parser.cpp.

Referenced by PADS_IO::BINARY_PARSER::parsePadStacks().

◆ ReadFileHeader()

bool PADS_IO::ReadFileHeader ( const wxString & aFileName,
std::vector< uint8_t > & aOut,
size_t aCount )
inline

Read at most aCount leading bytes of aFileName into aOut, which is sized to what was actually read.

Returns false on open error. Format probes use this so recognizing a file does not cost a full read of it.

Definition at line 104 of file pads_binary_utils.h.

Referenced by PADS_IO::BINARY_PARSER::IsBinaryPadsFile(), and SCH_IO_PADS::isBinarySchematicFile().

◆ ReadFileToBuffer()

◆ readFixedString()

std::string PADS_IO::readFixedString ( const std::vector< uint8_t > & aData,
size_t aOffset,
size_t aMaxLen )
inline

As readFixedStringRaw, then trim trailing spaces.

Definition at line 174 of file pads_binary_utils.h.

References readFixedStringRaw().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and PADS_IO::BINARY_CURSOR::StringAt().

◆ readFixedStringRaw()

std::string PADS_IO::readFixedStringRaw ( const std::vector< uint8_t > & aData,
size_t aOffset,
size_t aMaxLen )
inline

Read a NUL-terminated fixed-width field starting at aOffset, scanning at most aMaxLen bytes, WITHOUT trimming.

Returns an empty string when the field contains a control byte. High bytes are kept because PADS names use a legacy 8-bit code page; decode them with PADS_COMMON::ConvertText. Use this where the field is compared byte-for-byte; use readFixedString to trim.

Definition at line 149 of file pads_binary_utils.h.

Referenced by readFixedString().

◆ ValidateSdbFooter()

void PADS_IO::ValidateSdbFooter ( const std::vector< uint8_t > & aData,
size_t aFooterStart,
const char * aGuid,
size_t aGuidLen )

As CheckSdbFooter, throwing a bare IO_ERROR on failure.

For callers that do not annotate their diagnostics with a file offset.

Definition at line 54 of file pads_binary_utils.cpp.

References CheckSdbFooter(), and THROW_IO_ERROR.

Referenced by BOOST_AUTO_TEST_CASE(), and PADS_IO::PADS_SDB::verifyFooter().

◆ viaRecordValid()

static bool PADS_IO::viaRecordValid ( const BINARY_CURSOR & aCur,
size_t aTypeByte )
static

Variable Documentation

◆ DECAL_NAME_OFFSET

int PADS_IO::DECAL_NAME_OFFSET = 44
staticconstexpr

Rotation between the physical section cursor and the logical record base.

Definition at line 671 of file pads_binary_parser.cpp.

Referenced by PADS_IO::BINARY_PARSER::parsePartTypeTable().

◆ FOOTER_GUID

const char PADS_IO::FOOTER_GUID[] = "{2FE18320-6448-11d1-A412-000000000000}"
static

Definition at line 33 of file pads_sdb.cpp.

Referenced by PADS_IO::PADS_SDB::verifyFooter().

◆ FOOTER_GUID_LEN

size_t PADS_IO::FOOTER_GUID_LEN = 38
staticconstexpr

Definition at line 34 of file pads_sdb.cpp.

Referenced by PADS_IO::PADS_SDB::verifyFooter().

◆ PAD_SHAPE_NAMES

const std::map<uint8_t, std::string> PADS_IO::PAD_SHAPE_NAMES
static
Initial value:
= {
{ 0x00, "OF" }, { 0x01, "RF" }, { 0x02, "R" }, { 0x03, "S" },
{ 0x06, "RT" }, { 0x07, "ST" }, { 0x08, "RA" }, { 0x09, "SA" },
}

Definition at line 48 of file pads_binary_parser.cpp.

Referenced by PADS_IO::BINARY_PARSER::parsePadStacks().

◆ SDB_BASIC_PER_MIL

double PADS_IO::SDB_BASIC_PER_MIL = 38100.0
constexpr

◆ SDB_RECORD_SENTINEL

uint16_t PADS_IO::SDB_RECORD_SENTINEL = 0xFFFE
constexpr

◆ VIA_TYPE

int PADS_IO::VIA_TYPE = 0x0E
staticconstexpr

Definition at line 2089 of file pads_binary_parser.cpp.