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

Parser for the DSN root 'Library' stream: format version, fonts, page settings and the global string table that property name/value indices reference throughout the file. More...

#include <vector>
#include <sch_io/orcad/orcad_records.h>
#include <sch_io/orcad/orcad_stream.h>

Go to the source code of this file.

Functions

ORCAD_PAGE_SETTINGS OrcadParsePageSettings (ORCAD_STREAM &aStream)
 Read one 156-byte PageSettings block at the current cursor (embedded both in the Library stream and in every Page stream).
 
ORCAD_LIBRARY_INFO OrcadParseLibrary (const std::vector< char > &aData)
 Parse the whole 'Library' stream.
 

Detailed Description

Parser for the DSN root 'Library' stream: format version, fonts, page settings and the global string table that property name/value indices reference throughout the file.

Implemented in orcad_library.cpp.

Definition in file orcad_library.h.

Function Documentation

◆ OrcadParseLibrary()

ORCAD_LIBRARY_INFO OrcadParseLibrary ( const std::vector< char > & aData)

Parse the whole 'Library' stream.

Layout: NUL-terminated introduction inside a fixed 32-byte buffer, u16 major version, u16 minor version, 8 bytes create/modify dates, 4 zero bytes, u16 font count (stores count + 1: read count - 1 LOGFONTA records of 60 bytes each), then for versionMajor >= 2 a u16 length (always 24) + 2 * length bytes + 8 bytes (versionMajor < 2: a fixed 42 bytes instead), 8 lzt part-field names, the 156-byte PageSettings block, the string table, u16 alias-pair count with lzt/lzt pairs, and — when the introduction starts with "OrCAD Windows Design" — 8 bytes followed by the lzt schematic (root folder) name.

String table length field: modern files use u32, legacy pre-16.x files use u16. Detection: read u32 first and reject it as implausible when it exceeds 2,000,000 or when count * 3 > remaining + 16; on rejection (or a string parse failure) rewind and re-read with a u16 count.

The caller must gate on versionMajor: designs with versionMajor < 3 use a different framing and are rejected by this importer (clean IO_ERROR from the plugin, not from here).

Exceptions
IO_ERRORwhen the stream is structurally unreadable.

Definition at line 75 of file orcad_library.cpp.

References ORCAD_FONT::bold, ORCAD_FONT::face, ORCAD_LIBRARY_INFO::fonts, ORCAD_STREAM::GetOffset(), ORCAD_FONT::height, ORCAD_LIBRARY_INFO::introduction, ORCAD_FONT::italic, OrcadParsePageSettings(), ORCAD_LIBRARY_INFO::partAliases, ORCAD_LIBRARY_INFO::partFields, ORCAD_LIBRARY_INFO::pinToPin, ORCAD_PAGE_SETTINGS::pinToPin, ORCAD_STREAM::ReadBytes(), ORCAD_STREAM::ReadLzt(), ORCAD_STREAM::ReadU16(), ORCAD_STREAM::ReadU32(), ORCAD_STREAM::ReadZt(), ORCAD_STREAM::Remaining(), ORCAD_LIBRARY_INFO::schematicName, ORCAD_STREAM::Seek(), ORCAD_STREAM::Skip(), ORCAD_LIBRARY_INFO::strings, ORCAD_LIBRARY_INFO::versionMajor, and ORCAD_LIBRARY_INFO::versionMinor.

Referenced by SCH_IO_ORCAD::loadOlbSymbols(), and SCH_IO_ORCAD::LoadSchematicFile().

◆ OrcadParsePageSettings()

ORCAD_PAGE_SETTINGS OrcadParsePageSettings ( ORCAD_STREAM & aStream)

Read one 156-byte PageSettings block at the current cursor (embedded both in the Library stream and in every Page stream).

Layout documented on ORCAD_PAGE_SETTINGS. Consumes exactly 156 bytes; throws IO_ERROR on overrun.

Definition at line 45 of file orcad_library.cpp.

References flag, ORCAD_PAGE_SETTINGS::height, ORCAD_PAGE_SETTINGS::isMetric, ORCAD_PAGE_SETTINGS::pinToPin, ORCAD_STREAM::ReadU32(), ORCAD_STREAM::Skip(), and ORCAD_PAGE_SETTINGS::width.

Referenced by OrcadParseLibrary(), OrcadParsePage(), and OrcadParsePageV2().