KiCad PCB EDA Suite
Loading...
Searching...
No Matches
orcad_page.h File Reference

Parsers for the per-page streams 'Views/<folder>/Pages/<page>', the per-folder page-order stream 'Views/<folder>/Schematic', and — for hierarchy DETECTION only — the 'Views/<folder>/Hierarchy/Hierarchy' stream. More...

#include <cstdint>
#include <map>
#include <string>
#include <vector>
#include <sch_io/orcad/orcad_records.h>

Go to the source code of this file.

Functions

ORCAD_RAW_PAGE OrcadParsePage (const std::vector< char > &aData, const std::vector< std::string > &aStrings, const ORCAD_WARN_FN &aWarn)
 Parse one 'Views/<folder>/Pages/<page>' stream into raw structure lists.
 
std::vector< std::string > OrcadParsePageOrder (const std::vector< char > &aData)
 Parse the 'Views/<folder>/Schematic' stream and return the folder's page names in display order.
 
std::map< uint32_t, std::string > OrcadReadHierarchyLinks (const std::vector< char > &aData, const std::vector< std::string > &aStrings, const ORCAD_WARN_FN &aWarn, std::map< uint32_t, std::string > *aOccurrenceRefs=nullptr)
 Parse a 'Views/<folder>/Hierarchy/Hierarchy' stream into block-instance links: block db id -> child folder name.
 
ORCAD_OCC_SCOPE OrcadReadOccurrenceTree (const std::vector< char > &aData, const ORCAD_WARN_FN &aWarn)
 Parse the root folder 'Hierarchy/Hierarchy' stream into the full occurrence tree: per-scope part reference designators (keyed by placed-instance db id) and the hierarchical block occurrences that descend into child schematics, each with its own nested scope so a schematic reused N times yields N per-occurrence ref sets.
 
ORCAD_RAW_PAGE OrcadParsePageV2 (const std::vector< char > &aData, const std::vector< std::string > &aStrings, const ORCAD_WARN_FN &aWarn)
 Parse one v2.0 (pre-2003) 'Views/<folder>/Pages/<page>' stream.
 
void OrcadParseOlbSymbolStreamV2 (const std::vector< char > &aData, const std::vector< std::string > &aStrings, std::map< std::string, ORCAD_SYMBOL_DEF > &aSymbols)
 Parse one v2.0 .OLB 'Symbols/<name>' stream (a single special symbol: power, port, off-page, title block or ERC) into aSymbols, keyed by symbol name.
 
void OrcadParseOlbPackageStreamV2 (const std::vector< char > &aData, const std::vector< std::string > &aStrings, std::map< std::string, ORCAD_SYMBOL_DEF > &aSymbols, std::map< std::string, ORCAD_PACKAGE > &aPackages)
 Parse one v2.0 .OLB 'Packages/<name>' stream (a part's inline symbol definitions plus its package/device pin maps) into aSymbols (keyed by view name, e.g.
 
bool OrcadPageHasHierarchyBlocks (const ORCAD_RAW_PAGE &aPage)
 True when the page contains hierarchical block instances (DrawnInstance, type 12).
 

Detailed Description

Parsers for the per-page streams 'Views/<folder>/Pages/<page>', the per-folder page-order stream 'Views/<folder>/Schematic', and — for hierarchy DETECTION only — the 'Views/<folder>/Hierarchy/Hierarchy' stream.

Implemented in orcad_page.cpp.

Definition in file orcad_page.h.

Function Documentation

◆ OrcadPageHasHierarchyBlocks()

bool OrcadPageHasHierarchyBlocks ( const ORCAD_RAW_PAGE & aPage)
inline

True when the page contains hierarchical block instances (DrawnInstance, type 12).

Definition at line 152 of file orcad_page.h.

References ORCAD_RAW_PAGE::blocks.

Referenced by SCH_IO_ORCAD::LoadSchematicFile().

◆ OrcadParseOlbPackageStreamV2()

void OrcadParseOlbPackageStreamV2 ( const std::vector< char > & aData,
const std::vector< std::string > & aStrings,
std::map< std::string, ORCAD_SYMBOL_DEF > & aSymbols,
std::map< std::string, ORCAD_PACKAGE > & aPackages )

Parse one v2.0 .OLB 'Packages/<name>' stream (a part's inline symbol definitions plus its package/device pin maps) into aSymbols (keyed by view name, e.g.

"7400.Normal") and aPackages (keyed by package name). Throws on a framing error.

Definition at line 1156 of file orcad_page.cpp.

References g_v2ShortDisplayProp, ORCAD_PACKAGE::name, ORCAD_SYMBOL_DEF::name, ORCAD_STREAM::ReadU16(), ORCAD_PACKAGE::refDes, ORCAD_STREAM::Remaining(), THROW_IO_ERROR, v2CheckCount(), v2Package(), and v2PartCell().

Referenced by SCH_IO_ORCAD::loadOlbSymbols().

◆ OrcadParseOlbSymbolStreamV2()

void OrcadParseOlbSymbolStreamV2 ( const std::vector< char > & aData,
const std::vector< std::string > & aStrings,
std::map< std::string, ORCAD_SYMBOL_DEF > & aSymbols )

Parse one v2.0 .OLB 'Symbols/<name>' stream (a single special symbol: power, port, off-page, title block or ERC) into aSymbols, keyed by symbol name.

Throws IO_ERROR on a framing error.

Definition at line 1119 of file orcad_page.cpp.

References g_v2ShortDisplayProp, ORCAD_SYMBOL_DEF::name, ORCAD_STREAM::Remaining(), THROW_IO_ERROR, v2LibSymbolDef(), and v2Prefix().

Referenced by SCH_IO_ORCAD::loadOlbSymbols().

◆ OrcadParsePage()

ORCAD_RAW_PAGE OrcadParsePage ( const std::vector< char > & aData,
const std::vector< std::string > & aStrings,
const ORCAD_WARN_FN & aWarn )

Parse one 'Views/<folder>/Pages/<page>' stream into raw structure lists.

Stream layout: one framed structure of type 10 (Page) whose body starts with lzt page name, lzt page-size name, then the 156-byte PageSettings block (OrcadParsePageSettings — supplies width/height/isMetric), followed by these u16-counted lists in order:

  1. title blocks framed structures (type 65)
  2. T0x34 records raw, NOT prefix-framed (OrcadReadT0x34Raw)
  3. T0x35 records raw, NOT prefix-framed (OrcadReadT0x35Raw)
  4. net table per entry: lzt net name + u32 net db id
  5. wires framed (types 20/21)
  6. placed parts framed; type 13 -> instances, type 12 -> blocks
  7. ports framed (type 23)
  8. globals framed (type 37), each entry followed by 5 bytes
  9. off-page connectors framed (type 38), each entry followed by 5 bytes

ERC objects framed (type 77)

  1. bus entries framed (type 29)
  2. graphic instances framed (types 55..62, 88, 89)

The net table is authoritative for net names and junction computation: wires carry ids that key it. Structures that fail to parse are skipped with a warning via aWarn (never aborting the page); only a structurally unreadable Page structure itself throws IO_ERROR.

Definition at line 68 of file orcad_page.cpp.

References ORCAD_RAW_PAGE::blocks, ORCAD_RAW_PAGE::busEntries, ORCAD_RAW_PAGE::ercObjects, ORCAD_RAW_PAGE::globals, ORCAD_RAW_PAGE::graphics, ORCAD_PAGE_SETTINGS::height, ORCAD_RAW_PAGE::height, ORCAD_RAW_PAGE::instances, ORCAD_PAGE_SETTINGS::isMetric, ORCAD_RAW_PAGE::isMetric, ORCAD_RAW_PAGE::name, ORCAD_RAW_PAGE::netmap, ORCAD_RAW_PAGE::offpage, ORCAD_ST_PAGE, OrcadParsePageSettings(), OrcadReadT0x34Raw(), OrcadReadT0x35Raw(), ORCAD_RAW_PAGE::pageSize, ORCAD_RAW_PAGE::ports, ORCAD_STREAM::ReadLzt(), ORCAD_STRUCT_READER::ReadPrefixes(), ORCAD_STRUCT_READER::ReadStructure(), ORCAD_STREAM::ReadU16(), ORCAD_STREAM::ReadU32(), result, ORCAD_STREAM::Skip(), THROW_IO_ERROR, ORCAD_RAW_PAGE::titleBlocks, ORCAD_PREFIXES::typeId, ORCAD_PAGE_SETTINGS::width, ORCAD_RAW_PAGE::width, and ORCAD_RAW_PAGE::wires.

Referenced by SCH_IO_ORCAD::LoadSchematicFile().

◆ OrcadParsePageOrder()

std::vector< std::string > OrcadParsePageOrder ( const std::vector< char > & aData)

Parse the 'Views/<folder>/Schematic' stream and return the folder's page names in display order.

Layout: one prefix chain, lzt folder name, 4 bytes, u16 page count, then the lzt page names stored LAST-FIRST (the returned vector is already reversed into display order).

The caller (plugin shell) must intersect the result with the page streams that actually exist under 'Views/<folder>/Pages/', append any pages missing from the order stream, and fall back to name-sorted order with a warning when this parser throws IO_ERROR.

Definition at line 159 of file orcad_page.cpp.

References ORCAD_STREAM::ReadLzt(), ORCAD_STRUCT_READER::ReadPrefixes(), ORCAD_STREAM::ReadU16(), and ORCAD_STREAM::Skip().

Referenced by SCH_IO_ORCAD::LoadSchematicFile().

◆ OrcadParsePageV2()

ORCAD_RAW_PAGE OrcadParsePageV2 ( const std::vector< char > & aData,
const std::vector< std::string > & aStrings,
const ORCAD_WARN_FN & aWarn )

◆ OrcadReadHierarchyLinks()

std::map< uint32_t, std::string > OrcadReadHierarchyLinks ( const std::vector< char > & aData,
const std::vector< std::string > & aStrings,
const ORCAD_WARN_FN & aWarn,
std::map< uint32_t, std::string > * aOccurrenceRefs = nullptr )

Parse a 'Views/<folder>/Hierarchy/Hierarchy' stream into block-instance links: block db id -> child folder name.

Used to name skipped child folders in hierarchy warnings (hierarchical designs are converted flat).

The stream header is version-fragile, so the reader scans for preambles and backtracks prefix chains (OrcadFindStructureStart), keeping only type-66 structures. Type-66 body: u32, u32 instance db id, u8 inner-frame marker that must equal 0x42, u32, u32, lzt child folder name, lzt occurrence reference. Bad candidates are skipped silently; the scan never throws.

When aOccurrenceRefs is non-null it receives instance db id -> reference designator from the second lzt, which occurrence-annotated designs use to store the real refdes that the placed instance itself leaves as "C?".

Definition at line 184 of file orcad_page.cpp.

References ORCAD_STREAM::Data(), ORCAD_PREFIXES::end, ORCAD_STREAM::ExpectByte(), ORCAD_STREAM::FindPreamble(), ORCAD_STREAM::GetOffset(), ORCAD_STREAM::npos, ORCAD_ST_HIERARCHY_LINK, OrcadFindStructureStart(), ORCAD_STREAM::ReadLzt(), ORCAD_STRUCT_READER::ReadPrefixes(), ORCAD_STREAM::ReadU32(), and ORCAD_STREAM::Seek().

Referenced by SCH_IO_ORCAD::LoadSchematicFile().

◆ OrcadReadOccurrenceTree()

ORCAD_OCC_SCOPE OrcadReadOccurrenceTree ( const std::vector< char > & aData,
const ORCAD_WARN_FN & aWarn )

Parse the root folder 'Hierarchy/Hierarchy' stream into the full occurrence tree: per-scope part reference designators (keyed by placed-instance db id) and the hierarchical block occurrences that descend into child schematics, each with its own nested scope so a schematic reused N times yields N per-occurrence ref sets.

Returns an empty scope for legacy pre-preamble streams (which are instance- annotated) and on any parse error (the caller then falls back to the scan-based OrcadReadHierarchyLinks for the flat root-scope refs).

Definition at line 1212 of file orcad_page.cpp.

References ORCAD_STREAM::ReadLzt(), readOccScope(), ORCAD_STREAM::ReadU32(), ORCAD_STREAM::ReadU8(), ORCAD_STREAM::Skip(), and IO_ERROR::What().

Referenced by SCH_IO_ORCAD::LoadSchematicFile().