|
KiCad PCB EDA Suite
|
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_STREAM & | Stream () |
| 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_STREAM & | m_stream |
| const std::vector< std::string > * | m_strings |
| ORCAD_WARN_FN | m_warn |
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.
| ORCAD_STRUCT_READER::ORCAD_STRUCT_READER | ( | ORCAD_STREAM & | aStream, |
| const std::vector< std::string > * | aStrings = nullptr, | ||
| ORCAD_WARN_FN | aWarn = nullptr ) |
| 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().
| 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().
| 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().
| 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().
| 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().
|
inline |
Definition at line 110 of file orcad_structures.h.
References m_stream.
Referenced by OrcadReadAlias(), OrcadReadBusEntry(), OrcadReadDevice(), OrcadReadDisplayProp(), OrcadReadDisplayPropList(), OrcadReadDrawnInstance(), OrcadReadErcObject(), OrcadReadGraphicInst(), OrcadReadPackage(), OrcadReadPinInst(), OrcadReadPlacedInstance(), OrcadReadPort(), OrcadReadSymbolDef(), OrcadReadSymbolPin(), OrcadReadTitleBlock(), and OrcadReadWire().
| 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().
| 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().
|
private |
Definition at line 171 of file orcad_structures.h.
Referenced by ORCAD_STRUCT_READER(), ReadPrefixes(), ReadStructure(), SkipStructure(), Stream(), and TryReadPrefixes().
|
private |
Definition at line 172 of file orcad_structures.h.
Referenced by ORCAD_STRUCT_READER(), and Resolve().
|
private |
Definition at line 173 of file orcad_structures.h.
Referenced by ORCAD_STRUCT_READER(), and Warn().