KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ALLEGRO::FILE_STREAM Class Reference

Stream that reads primitive types from a memory buffer containing Allegro .brd (or .dra) file data. More...

#include <allegro_stream.h>

Public Member Functions

 FILE_STREAM (const uint8_t *aData, size_t aSize)
 
size_t Position () const
 
void Seek (size_t aPos)
 
void Skip (size_t aBytes)
 
bool Eof () const
 
void ReadBytes (void *aDest, size_t aSize)
 Read a number of bytes from the stream into the destination buffer.
 
template<typename T>
T Read ()
 
std::string ReadString (bool aRoundToNextU32)
 
std::string ReadStringFixed (size_t aLen, bool aRoundToNextU32)
 
bool GetU8 (uint8_t &value)
 
uint8_t ReadU8 ()
 
uint16_t ReadU16 ()
 
int16_t ReadS16 ()
 
uint32_t ReadU32 ()
 
int32_t ReadS32 ()
 
void SkipU32 (size_t n=1)
 

Static Private Member Functions

template<typename T>
static void swapBytes (T &value)
 

Private Attributes

const uint8_t * m_data
 
size_t m_size
 
size_t m_pos
 

Static Private Attributes

static constexpr bool m_kNeedsSwap = std::endian::native != std::endian::little
 

Detailed Description

Stream that reads primitive types from a memory buffer containing Allegro .brd (or .dra) file data.

All multi-byte values are little-endian.

Definition at line 43 of file allegro_stream.h.

Constructor & Destructor Documentation

◆ FILE_STREAM()

ALLEGRO::FILE_STREAM::FILE_STREAM ( const uint8_t * aData,
size_t aSize )
inline

Definition at line 48 of file allegro_stream.h.

References m_data, m_pos, and m_size.

Member Function Documentation

◆ Eof()

bool ALLEGRO::FILE_STREAM::Eof ( ) const
inline

Definition at line 76 of file allegro_stream.h.

References m_pos, and m_size.

◆ GetU8()

bool ALLEGRO::FILE_STREAM::GetU8 ( uint8_t & value)
inline

Definition at line 167 of file allegro_stream.h.

References m_data, m_pos, and m_size.

◆ Position()

◆ Read()

template<typename T>
T ALLEGRO::FILE_STREAM::Read ( )
inline

Definition at line 99 of file allegro_stream.h.

References m_kNeedsSwap, ReadBytes(), swapBytes(), and T.

Referenced by ReadS16(), ReadS32(), ReadU16(), ReadU32(), and ReadU8().

◆ ReadBytes()

void ALLEGRO::FILE_STREAM::ReadBytes ( void * aDest,
size_t aSize )
inline

Read a number of bytes from the stream into the destination buffer.

It is your responsibility to ensure that the destination buffer is large enough to hold the requested number of bytes.

Definition at line 84 of file allegro_stream.h.

References m_data, m_pos, m_size, and THROW_IO_ERROR.

Referenced by ParseBlock_0x0F(), ParseBlock_0x1D(), ParseBlock_0x1F(), ParseBlock_0x21(), ParseBlock_0x35(), ParseBlock_0x36(), and Read().

◆ ReadS16()

int16_t ALLEGRO::FILE_STREAM::ReadS16 ( )
inline

Definition at line 178 of file allegro_stream.h.

References Read().

Referenced by ReadField().

◆ ReadS32()

◆ ReadString()

std::string ALLEGRO::FILE_STREAM::ReadString ( bool aRoundToNextU32)
inline

Definition at line 114 of file allegro_stream.h.

References end, m_data, m_pos, m_size, Skip(), and THROW_IO_ERROR.

Referenced by ReadStringMap().

◆ ReadStringFixed()

std::string ALLEGRO::FILE_STREAM::ReadStringFixed ( size_t aLen,
bool aRoundToNextU32 )
inline

◆ ReadU16()

◆ ReadU32()

◆ ReadU8()

◆ Seek()

void ALLEGRO::FILE_STREAM::Seek ( size_t aPos)
inline

Definition at line 54 of file allegro_stream.h.

References m_pos, m_size, and THROW_IO_ERROR.

Referenced by ReadStringMap().

◆ Skip()

◆ SkipU32()

void ALLEGRO::FILE_STREAM::SkipU32 ( size_t n = 1)
inline

Definition at line 182 of file allegro_stream.h.

References Skip().

◆ swapBytes()

template<typename T>
static void ALLEGRO::FILE_STREAM::swapBytes ( T & value)
inlinestaticprivate

Definition at line 186 of file allegro_stream.h.

References T.

Referenced by Read().

Member Data Documentation

◆ m_data

const uint8_t* ALLEGRO::FILE_STREAM::m_data
private

Definition at line 192 of file allegro_stream.h.

Referenced by FILE_STREAM(), GetU8(), ReadBytes(), ReadString(), and ReadStringFixed().

◆ m_kNeedsSwap

bool ALLEGRO::FILE_STREAM::m_kNeedsSwap = std::endian::native != std::endian::little
staticconstexprprivate

Definition at line 45 of file allegro_stream.h.

Referenced by Read().

◆ m_pos

size_t ALLEGRO::FILE_STREAM::m_pos
private

◆ m_size

size_t ALLEGRO::FILE_STREAM::m_size
private

Definition at line 193 of file allegro_stream.h.

Referenced by Eof(), FILE_STREAM(), GetU8(), ReadBytes(), ReadString(), ReadStringFixed(), Seek(), and Skip().


The documentation for this class was generated from the following file: