23#ifndef ORCAD_STREAM_H_
24#define ORCAD_STREAM_H_
39 static constexpr uint8_t
PREAMBLE[4] = { 0xFF, 0xE4, 0x5C, 0x39 };
42 static constexpr size_t npos =
static_cast<size_t>( -1 );
99 std::vector<uint8_t>
ReadBytes(
size_t aCount );
102 void Skip(
size_t aCount );
105 void Seek(
size_t aOffset );
121 int PeekU8(
size_t aAhead = 0 )
const;
124 bool PeekMatches(
const uint8_t* aBytes,
size_t aCount,
size_t aAhead = 0 )
const;
132 void Expect(
const uint8_t* aBytes,
size_t aCount,
const wxString& aWhat );
135 void ExpectByte( uint8_t aValue,
const wxString& aWhat );
LIMIT_GUARD & operator=(const LIMIT_GUARD &)=delete
LIMIT_GUARD(const LIMIT_GUARD &)=delete
LIMIT_GUARD(ORCAD_STREAM &aStream, size_t aEnd)
NEST_GUARD & operator=(const NEST_GUARD &)=delete
NEST_GUARD(const NEST_GUARD &)=delete
NEST_GUARD(ORCAD_STREAM &aStream, const wxString &aWhat)
static constexpr int MAX_NESTING
Nesting limit of the recursive readers; real files stay far below it.
void ExpectPreamble(const wxString &aWhat)
Consume the 4 preamble bytes; throws IO_ERROR naming aWhat when absent.
size_t Remaining() const
Bytes left; 0 when the cursor is at or past the end.
int PeekU8(size_t aAhead=0) const
– non-throwing lookahead ---------------------------------------------------—
void SkipOptionalPreambleBlock()
Legacy primitives have no trailing preamble.
bool AtPreamble(size_t aAhead=0) const
True when the 4 preamble bytes FF E4 5C 39 sit at cursor + aAhead.
uint8_t ReadU8()
– scalars (little-endian, bounds-checked, throw IO_ERROR on overrun) ----—
static constexpr size_t npos
Generic invalid offset sentinel.
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.
static constexpr uint8_t PREAMBLE[4]
Magic preceding every framed structure body: FF E4 5C 39.
std::string ReadLzt()
– strings ----------------------------------------------------------------—
ORCAD_STREAM(const void *aData, size_t aLength)
void requireBytes(size_t aCount) const
Throw IO_ERROR unless aCount bytes remain at the cursor.
const uint8_t * Data() const
Raw buffer access for bounded lexical lookahead and payload extraction.
std::string ReadZt()
Consumes the NUL; throws IO_ERROR if no terminator remains.
bool PeekMatches(const uint8_t *aBytes, size_t aCount, size_t aAhead=0) const
Returns false if fewer than aCount bytes remain; does not advance the cursor.
void Seek(size_t aOffset)
Set the absolute cursor position; throws IO_ERROR when aOffset exceeds Size().
void ExpectByte(uint8_t aValue, const wxString &aWhat)
Consume one byte and require the given value.
void Expect(const uint8_t *aBytes, size_t aCount, const wxString &aWhat)
– validated reads ------------------------------------------------------------—
wxString FromOrcadString(const std::string &aText)
Use an 8-bit fallback if Windows-1252 decoding fails.