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

The parsed container of a PADS .pcb file: header, the section directory, and the coordinate system. More...

#include <pads_sdb.h>

Public Member Functions

 PADS_SDB ()=default
 
 PADS_SDB (const PADS_SDB &)=delete
 
PADS_SDBoperator= (const PADS_SDB &)=delete
 
void Load (std::vector< uint8_t > aBytes)
 Validate the header and footer, parse the section directory, and derive the coordinate origin.
 
uint16_t Version () const
 
bool IsOldFormat () const
 
const std::vector< uint8_t > & Bytes () const
 
const BINARY_CURSORCursor () const
 
const SDB_COORDSCoords () const
 
size_t SectionCount () const
 
const SDB_SECTIONSection (int aIndex) const
 
SDB_RECORD RecordAt (uint32_t aBase) const
 A reader positioned at an absolute file offset, for walking a pool or byte region rather than a section's fixed-stride records.
 

Static Public Member Functions

static bool HasMagic (const std::vector< uint8_t > &aBytes)
 True if the first two bytes match the PADS binary magic.
 
static bool IsSupportedVersion (uint16_t aVersion)
 

Private Member Functions

void parseHeader ()
 
void parseDirectory ()
 
void parsePhysicalFraming ()
 
void verifyFooter () const
 
void readBoardSetup ()
 
int directoryEntryCount () const
 

Private Attributes

std::vector< uint8_t > m_data
 
BINARY_CURSOR m_cursor { m_data }
 
uint16_t m_version = 0
 
std::vector< SDB_SECTIONm_sections
 
SDB_COORDS m_coords
 

Static Private Attributes

static constexpr uint8_t MAGIC0 = 0x00
 
static constexpr uint8_t MAGIC1 = 0xFF
 
static constexpr int HEADER_SIZE = 10
 
static constexpr int FOOTER_SIZE = 42
 
static constexpr int DIR_ENTRY_SIZE = 16
 
static constexpr int VIEW_STATE_RECORD_BYTES = 48
 Stride of the section 2 view-state records that precede the board-setup block.
 

Detailed Description

The parsed container of a PADS .pcb file: header, the section directory, and the coordinate system.

Owns the file bytes and the bounds-checked read cursor.

Non-copyable because the cursor binds a reference to the owned byte buffer, so a copy would leave the clone's cursor pointing at the source's bytes.

Definition at line 110 of file pads_sdb.h.

Constructor & Destructor Documentation

◆ PADS_SDB() [1/2]

PADS_IO::PADS_SDB::PADS_SDB ( )
default

Referenced by operator=(), and PADS_SDB().

◆ PADS_SDB() [2/2]

PADS_IO::PADS_SDB::PADS_SDB ( const PADS_SDB & )
delete

References PADS_SDB().

Member Function Documentation

◆ Bytes()

const std::vector< uint8_t > & PADS_IO::PADS_SDB::Bytes ( ) const
inline

Definition at line 131 of file pads_sdb.h.

References m_data.

◆ Coords()

const SDB_COORDS & PADS_IO::PADS_SDB::Coords ( ) const
inline

Definition at line 133 of file pads_sdb.h.

References m_coords.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ Cursor()

const BINARY_CURSOR & PADS_IO::PADS_SDB::Cursor ( ) const
inline

Definition at line 132 of file pads_sdb.h.

References m_cursor.

◆ directoryEntryCount()

int PADS_IO::PADS_SDB::directoryEntryCount ( ) const
private

Definition at line 72 of file pads_sdb.cpp.

References DIR_ENTRY_SIZE, HEADER_SIZE, and m_cursor.

Referenced by parseDirectory().

◆ HasMagic()

bool PADS_IO::PADS_SDB::HasMagic ( const std::vector< uint8_t > & aBytes)
static

True if the first two bytes match the PADS binary magic.

Definition at line 37 of file pads_sdb.cpp.

References PADS_IO::HasSdbMagic(), and MAGIC1.

Referenced by parseHeader().

◆ IsOldFormat()

bool PADS_IO::PADS_SDB::IsOldFormat ( ) const
inline

Definition at line 130 of file pads_sdb.h.

References m_version.

Referenced by BOOST_AUTO_TEST_CASE().

◆ IsSupportedVersion()

bool PADS_IO::PADS_SDB::IsSupportedVersion ( uint16_t aVersion)
static

◆ Load()

void PADS_IO::PADS_SDB::Load ( std::vector< uint8_t > aBytes)

◆ operator=()

PADS_SDB & PADS_IO::PADS_SDB::operator= ( const PADS_SDB & )
delete

References PADS_SDB().

◆ parseDirectory()

void PADS_IO::PADS_SDB::parseDirectory ( )
private

◆ parseHeader()

void PADS_IO::PADS_SDB::parseHeader ( )
private

Definition at line 78 of file pads_sdb.cpp.

References FOOTER_SIZE, HasMagic(), HEADER_SIZE, IsSupportedVersion(), m_cursor, m_data, m_version, and THROW_IO_ERROR.

Referenced by Load().

◆ parsePhysicalFraming()

◆ readBoardSetup()

void PADS_IO::PADS_SDB::readBoardSetup ( )
private

◆ RecordAt()

SDB_RECORD PADS_IO::PADS_SDB::RecordAt ( uint32_t aBase) const
inline

A reader positioned at an absolute file offset, for walking a pool or byte region rather than a section's fixed-stride records.

Definition at line 140 of file pads_sdb.h.

References m_cursor.

◆ Section()

◆ SectionCount()

size_t PADS_IO::PADS_SDB::SectionCount ( ) const
inline

Definition at line 135 of file pads_sdb.h.

References m_sections.

Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ verifyFooter()

void PADS_IO::PADS_SDB::verifyFooter ( ) const
private

◆ Version()

uint16_t PADS_IO::PADS_SDB::Version ( ) const
inline

Definition at line 129 of file pads_sdb.h.

References m_version.

Referenced by BOOST_AUTO_TEST_CASE().

Member Data Documentation

◆ DIR_ENTRY_SIZE

int PADS_IO::PADS_SDB::DIR_ENTRY_SIZE = 16
staticconstexprprivate

◆ FOOTER_SIZE

int PADS_IO::PADS_SDB::FOOTER_SIZE = 42
staticconstexprprivate

Definition at line 153 of file pads_sdb.h.

Referenced by parseHeader(), parsePhysicalFraming(), and verifyFooter().

◆ HEADER_SIZE

int PADS_IO::PADS_SDB::HEADER_SIZE = 10
staticconstexprprivate

Definition at line 152 of file pads_sdb.h.

Referenced by directoryEntryCount(), parseDirectory(), parseHeader(), and readBoardSetup().

◆ m_coords

SDB_COORDS PADS_IO::PADS_SDB::m_coords
private

Definition at line 166 of file pads_sdb.h.

Referenced by Coords(), and readBoardSetup().

◆ m_cursor

BINARY_CURSOR PADS_IO::PADS_SDB::m_cursor { m_data }
private

◆ m_data

std::vector<uint8_t> PADS_IO::PADS_SDB::m_data
private

◆ m_sections

std::vector<SDB_SECTION> PADS_IO::PADS_SDB::m_sections
private

Definition at line 165 of file pads_sdb.h.

Referenced by parseDirectory(), parsePhysicalFraming(), Section(), and SectionCount().

◆ m_version

uint16_t PADS_IO::PADS_SDB::m_version = 0
private

Definition at line 164 of file pads_sdb.h.

Referenced by IsOldFormat(), parseHeader(), parsePhysicalFraming(), and Version().

◆ MAGIC0

uint8_t PADS_IO::PADS_SDB::MAGIC0 = 0x00
staticconstexprprivate

Definition at line 150 of file pads_sdb.h.

◆ MAGIC1

uint8_t PADS_IO::PADS_SDB::MAGIC1 = 0xFF
staticconstexprprivate

Definition at line 151 of file pads_sdb.h.

Referenced by HasMagic().

◆ VIEW_STATE_RECORD_BYTES

int PADS_IO::PADS_SDB::VIEW_STATE_RECORD_BYTES = 48
staticconstexprprivate

Stride of the section 2 view-state records that precede the board-setup block.

Definition at line 157 of file pads_sdb.h.

Referenced by readBoardSetup().


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