34int32_t i32At(
const std::vector<uint8_t>& aBytes,
size_t aOffset )
36 return static_cast<int32_t
>(
static_cast<uint32_t
>( aBytes[aOffset] )
37 |
static_cast<uint32_t
>( aBytes[aOffset + 1] ) << 8
38 |
static_cast<uint32_t
>( aBytes[aOffset + 2] ) << 16
39 |
static_cast<uint32_t
>( aBytes[aOffset + 3] ) << 24 );
74 for( uint32_t&
flag : flags )
106 int fontCount = stream.
ReadU16();
108 for(
int i = 0; i < fontCount - 1; i++ )
111 std::vector<uint8_t> rec = stream.
ReadBytes( 60 );
114 font.
height = i32At( rec, 0 );
115 font.
width = i32At( rec, 4 );
118 font.
italic = rec[20] != 0;
119 font.
bold = i32At( rec, 16 ) >= 600;
124 while( faceLen < 32 && rec[28 + faceLen] != 0 )
127 font.
face.assign(
reinterpret_cast<const char*
>( rec.data() + 28 ), faceLen );
129 lib.
fonts.push_back( std::move( font ) );
135 uint16_t someLen = stream.
ReadU16();
138 for( uint16_t i = 0; i < someLen; ++i )
140 int fontIdx = stream.
ReadU16();
143 if( i == 10 && fontIdx > 0 )
145 else if( i == 11 && fontIdx > 0 )
156 for(
int i = 0; i < 17; ++i )
158 int fontIdx = stream.
ReadU16();
161 if( i == 10 && fontIdx > 0 )
163 else if( i == 11 && fontIdx > 0 )
171 for(
int i = 0; i < 8; i++ )
180 if( stringCount > 2000000
181 ||
static_cast<uint64_t
>( stringCount ) * 3 >
static_cast<uint64_t
>( stream.
Remaining() ) + 16 )
183 THROW_IO_ERRORF( wxS(
"OrCAD library: string table count %u does not fit the stream" ), stringCount );
186 lib.
strings.reserve( stringCount );
188 for( uint32_t i = 0; i < stringCount; i++ )
195 uint16_t aliasCount = stream.
ReadU16();
197 if(
static_cast<uint64_t
>( aliasCount ) * 2 <= stream.
Remaining() + 4 )
199 for( uint16_t i = 0; i < aliasCount; i++ )
201 std::string alias = stream.
ReadLzt();
202 std::string part = stream.
ReadLzt();
204 lib.
partAliases.emplace_back( std::move( alias ), std::move( part ) );
209 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.
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.