KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ORCAD_STRUCT_READER Class Reference

Stateful reader shared by all structure parsers. More...

#include <orcad_structures.h>

Public Member Functions

 ORCAD_STRUCT_READER (ORCAD_STREAM &aStream, const std::vector< std::string > *aStrings=nullptr, ORCAD_WARN_FN aWarn=nullptr)
 
ORCAD_STREAMStream ()
 
ORCAD_PREFIXES TryReadPrefixes (int aCount)
 Attempt to read exactly aCount prefixes (aCount - 1 long + 1 short) at the current position and verify that the preamble magic follows.
 
ORCAD_PREFIXES ReadPrefixes ()
 Discover the prefix count by trial from 10 down to 1 (longest chain first), then consume the prefixes, the preamble and its u32-length trailing block.
 
std::string Resolve (uint32_t aIndex) const
 String-table lookup; returns "" for out-of-range indices.
 
std::map< std::string, std::string > PropsDict (const ORCAD_PREFIXES &aPrefixes) const
 Resolve the short-prefix (nameIdx, valueIdx) pairs; empty names are dropped.
 
void SkipStructure (const ORCAD_PREFIXES &aPrefixes, const wxString &aWhat)
 Seek to the end of a structure using its outermost prefix length.
 
ORCAD_READ_RESULT ReadStructure ()
 Read one structure of any type: prefixes, then the type-specific body via the reader dispatch below.
 
void Warn (const wxString &aMsg) const
 Report a recoverable problem to the warning sink (no-op when none was given).
 

Private Attributes

ORCAD_STREAMm_stream
 
const std::vector< std::string > * m_strings
 
ORCAD_WARN_FN m_warn
 

Detailed Description

Stateful reader shared by all structure parsers.

Holds the stream cursor, the Library string table used to resolve property indices, and the warning sink.

Error model: all readers throw IO_ERROR on malformed data. ReadStructure() additionally implements the standard per-structure recovery: when a body parser throws and the prefix end offset is known, the structure is skipped with a warning and parsing continues (a single bad record never aborts a page).

Definition at line 104 of file orcad_structures.h.

Constructor & Destructor Documentation

◆ ORCAD_STRUCT_READER()

ORCAD_STRUCT_READER::ORCAD_STRUCT_READER ( ORCAD_STREAM & aStream,
const std::vector< std::string > * aStrings = nullptr,
ORCAD_WARN_FN aWarn = nullptr )

Definition at line 34 of file orcad_structures.cpp.

References m_stream, m_strings, m_warn, and move.

Member Function Documentation

◆ PropsDict()

std::map< std::string, std::string > ORCAD_STRUCT_READER::PropsDict ( const ORCAD_PREFIXES & aPrefixes) const

Resolve the short-prefix (nameIdx, valueIdx) pairs; empty names are dropped.

Definition at line 170 of file orcad_structures.cpp.

References name, ORCAD_PREFIXES::props, and Resolve().

Referenced by OrcadReadGraphicInst(), OrcadReadPlacedInstance(), and OrcadReadSymbolDef().

◆ ReadPrefixes()

ORCAD_PREFIXES ORCAD_STRUCT_READER::ReadPrefixes ( )

Discover the prefix count by trial from 10 down to 1 (longest chain first), then consume the prefixes, the preamble and its u32-length trailing block.

Fills bodyStart, and — when long prefixes exist — stops[] and end. Throws IO_ERROR (with the cursor restored to the start) when no chain fits.

Definition at line 112 of file orcad_structures.cpp.

References ORCAD_PREFIXES::bodyLens, ORCAD_PREFIXES::bodyStart, ORCAD_PREFIXES::end, m_stream, IO_ERROR::Problem(), ORCAD_PREFIXES::start, ORCAD_PREFIXES::stops, THROW_IO_ERROR, and TryReadPrefixes().

Referenced by OrcadParseCache(), OrcadParsePage(), OrcadParsePageOrder(), OrcadReadDevice(), OrcadReadDrawnInstance(), OrcadReadHierarchyLinks(), OrcadReadSymbolPin(), and ReadStructure().

◆ ReadStructure()

ORCAD_READ_RESULT ORCAD_STRUCT_READER::ReadStructure ( )

Read one structure of any type: prefixes, then the type-specific body via the reader dispatch below.

Unknown types are skipped (monostate). A body parse failure is recovered by seeking to the prefix end with a warning when possible, otherwise the IO_ERROR propagates.

Dispatch table (type -> reader): 20, 21 OrcadReadWire 49 OrcadReadAlias 39 OrcadReadDisplayProp 13 OrcadReadPlacedInstance 23 OrcadReadPort 37, 38 OrcadReadGraphicInst 65 OrcadReadTitleBlock 77 OrcadReadErcObject 29 OrcadReadBusEntry 16, 17 OrcadReadPinInst 55..62, 88, 89 OrcadReadGraphicInst 2 OrcadReadSthInPages0 (declared in orcad_cache.h) 12 OrcadReadDrawnInstance (declared in orcad_cache.h)

Definition at line 200 of file orcad_structures.cpp.

References ORCAD_PREFIXES::end, m_stream, ORCAD_ST_ALIAS, ORCAD_ST_BUS_ENTRY, ORCAD_ST_DRAWN_INSTANCE, ORCAD_ST_ERC_OBJECT, ORCAD_ST_GLOBAL, ORCAD_ST_GRAPHIC_ARC_INST, ORCAD_ST_GRAPHIC_BEZIER_INST, ORCAD_ST_GRAPHIC_BITMAP_INST, ORCAD_ST_GRAPHIC_BOX_INST, ORCAD_ST_GRAPHIC_COMMENT_TEXT_INST, ORCAD_ST_GRAPHIC_ELLIPSE_INST, ORCAD_ST_GRAPHIC_LINE_INST, ORCAD_ST_GRAPHIC_OLE_INST, ORCAD_ST_GRAPHIC_POLYGON_INST, ORCAD_ST_GRAPHIC_POLYLINE_INST, ORCAD_ST_OFFPAGE_CONNECTOR, ORCAD_ST_PLACED_INSTANCE, ORCAD_ST_PORT, ORCAD_ST_STH_IN_PAGES0, ORCAD_ST_SYMBOL_DISPLAY_PROP, ORCAD_ST_T0X10, ORCAD_ST_T0X11, ORCAD_ST_TITLEBLOCK, ORCAD_ST_WIRE_BUS, ORCAD_ST_WIRE_SCALAR, OrcadReadAlias(), OrcadReadBusEntry(), OrcadReadDisplayProp(), OrcadReadDrawnInstance(), OrcadReadErcObject(), OrcadReadGraphicInst(), OrcadReadPinInst(), OrcadReadPlacedInstance(), OrcadReadPort(), OrcadReadSthInPages0(), OrcadReadTitleBlock(), OrcadReadWire(), ReadPrefixes(), result, SkipStructure(), ORCAD_PREFIXES::typeId, and Warn().

Referenced by OrcadParsePage(), OrcadReadDisplayPropList(), OrcadReadDrawnInstance(), OrcadReadGraphicInst(), OrcadReadPlacedInstance(), OrcadReadSymbolDef(), and OrcadReadWire().

◆ Resolve()

std::string ORCAD_STRUCT_READER::Resolve ( uint32_t aIndex) const

String-table lookup; returns "" for out-of-range indices.

Definition at line 161 of file orcad_structures.cpp.

References m_strings.

Referenced by OrcadReadDisplayProp(), OrcadReadGraphicInst(), OrcadReadPlacedInstance(), and PropsDict().

◆ SkipStructure()

void ORCAD_STRUCT_READER::SkipStructure ( const ORCAD_PREFIXES & aPrefixes,
const wxString & aWhat )

Seek to the end of a structure using its outermost prefix length.

Throws IO_ERROR when end is unknown (0) or behind the cursor.

Definition at line 186 of file orcad_structures.cpp.

References ORCAD_PREFIXES::end, m_stream, and THROW_IO_ERROR.

Referenced by ReadStructure().

◆ Stream()

◆ TryReadPrefixes()

ORCAD_PREFIXES ORCAD_STRUCT_READER::TryReadPrefixes ( int aCount)

Attempt to read exactly aCount prefixes (aCount - 1 long + 1 short) at the current position and verify that the preamble magic follows.

All prefix type bytes must match; every long-prefix pad u32 must be zero; a negative short-prefix pair count is accepted as zero pairs. On success the cursor rests ON the preamble (not consumed) and the returned ORCAD_PREFIXES has typeId/bodyLens/props/start filled (not bodyStart/end/ stops). Throws IO_ERROR when the shape does not fit; the caller must restore the cursor itself.

Definition at line 51 of file orcad_structures.cpp.

References ORCAD_PREFIXES::bodyLens, m_stream, ORCAD_PREFIXES::props, ORCAD_PREFIXES::start, THROW_IO_ERROR, and ORCAD_PREFIXES::typeId.

Referenced by OrcadFindStructureStart(), and ReadPrefixes().

◆ Warn()

void ORCAD_STRUCT_READER::Warn ( const wxString & aMsg) const

Report a recoverable problem to the warning sink (no-op when none was given).

Definition at line 44 of file orcad_structures.cpp.

References m_warn.

Referenced by ReadStructure().

Member Data Documentation

◆ m_stream

ORCAD_STREAM& ORCAD_STRUCT_READER::m_stream
private

◆ m_strings

const std::vector<std::string>* ORCAD_STRUCT_READER::m_strings
private

Definition at line 172 of file orcad_structures.h.

Referenced by ORCAD_STRUCT_READER(), and Resolve().

◆ m_warn

ORCAD_WARN_FN ORCAD_STRUCT_READER::m_warn
private

Definition at line 173 of file orcad_structures.h.

Referenced by ORCAD_STRUCT_READER(), and Warn().


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