60 for( uint32_t&
flag : flags )
92 int fontCount = stream.
ReadU16();
94 for(
int i = 0; i < fontCount - 1; i++ )
107 std::vector<uint8_t> face = stream.
ReadBytes( 32 );
110 while( faceLen < face.size() && face[faceLen] != 0 )
113 font.
face.assign(
reinterpret_cast<const char*
>( face.data() ), faceLen );
115 lib.
fonts.push_back( std::move( font ) );
122 for( uint16_t i = 0; i < templateFontCount; ++i )
124 int fontIdx = stream.
ReadU16();
127 if( i == 10 && fontIdx > 0 )
129 else if( i == 11 && fontIdx > 0 )
136 for(
int i = 0; i < 8; i++ )
145 if( stringCount > 2000000
146 ||
static_cast<uint64_t
>( stringCount ) * 3 >
static_cast<uint64_t
>( stream.
Remaining() ) + 16 )
148 THROW_IO_ERRORF( wxS(
"OrCAD library: string table count %u does not fit the stream" ), stringCount );
151 lib.
strings.reserve( stringCount );
153 for( uint32_t i = 0; i < stringCount; i++ )
160 uint16_t aliasCount = stream.
ReadU16();
162 if(
static_cast<uint64_t
>( aliasCount ) * 2 <= stream.
Remaining() + 4 )
164 for( uint16_t i = 0; i < aliasCount; i++ )
166 std::string alias = stream.
ReadLzt();
167 std::string part = stream.
ReadLzt();
169 lib.
partAliases.emplace_back( std::move( alias ), std::move( part ) );
174 if( lib.
introduction.rfind(
"OrCAD Windows Design", 0 ) == 0 )
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
The caller owns the buffer.
size_t Remaining() const
Bytes left; 0 when the cursor is at or past the end.
uint8_t ReadU8()
– scalars (little-endian, bounds-checked, throw IO_ERROR on overrun) ----—
std::vector< uint8_t > ReadBytes(size_t aCount)
– buffers / cursor ---------------------------------------------------------—
void Skip(size_t aCount)
Advance the cursor; throws IO_ERROR when aCount exceeds the remaining bytes.
std::string ReadLzt()
– strings ----------------------------------------------------------------—
std::string ReadZt()
Consumes the NUL; throws IO_ERROR if no terminator remains.
void Seek(size_t aOffset)
Set the absolute cursor position; throws IO_ERROR when aOffset exceeds Size().
#define THROW_IO_ERRORF(msg,...)
ORCAD_PAGE_SETTINGS OrcadParsePageSettings(ORCAD_STREAM &aStream)
Consumes 156 bytes; throws IO_ERROR on overrun.
ORCAD_LIBRARY_INFO OrcadParseLibrary(const std::vector< char > &aData)
The Library version selects the string-count width.
Font indices are one-based; zero selects the default.
int orientation
glyph direction in tenths of a degree
int width
raw lfWidth; zero lets the font choose its natural aspect ratio
int escapement
baseline direction in tenths of a degree
int height
raw lfHeight (typically negative)
std::string introduction
fixed 32-byte NUL-terminated buffer
std::vector< std::string > strings
global string table
std::vector< ORCAD_FONT > fonts
int pinNumberFont
Design Template font ID (slot 11)
std::vector< std::pair< std::string, std::string > > partAliases
std::vector< int > templateFonts
template font ID -> 1-based LOGFONT index
std::string schematicName
root schematic folder name
int pinNameFont
Design Template font ID (slot 10)
std::vector< std::string > partFields
the 8 named part fields
Dimensions use mils when isMetric is zero, otherwise micrometres.