MAGE  v0.171.0
Matthias Advanced Game Engine
mage::BigEndianBinaryReader Class Referenceabstract

#include <binary_reader.hpp>

Inheritance diagram for mage::BigEndianBinaryReader:
mage::rendering::loader::MSHReader< VertexT, IndexT > mage::rendering::loader::SpriteFontReader

Public Member Functions

BigEndianBinaryReaderoperator= (const BigEndianBinaryReader &reader)=delete
 
BigEndianBinaryReaderoperator= (BigEndianBinaryReader &&reader) noexcept
 
void ReadFromFile (std::filesystem::path path)
 
void ReadFromMemory (gsl::span< const U8 > input)
 

Protected Member Functions

 BigEndianBinaryReader ()
 
 BigEndianBinaryReader (const BigEndianBinaryReader &reader)=delete
 
 BigEndianBinaryReader (BigEndianBinaryReader &&reader) noexcept
 
 ~BigEndianBinaryReader ()
 
const std::filesystem::path & GetPath () const noexcept
 
bool ContainsChars () const noexcept
 
template<typename T >
const T Read ()
 
template<typename T >
const T * ReadArray (std::size_t count)
 

Private Member Functions

virtual void ReadData ()=0
 

Private Attributes

std::filesystem::path m_path
 
const U8m_pos
 
const U8m_end
 
UniquePtr< U8[] > m_data
 

Detailed Description

A class of readers for reading (big endian) binary files.

Constructor & Destructor Documentation

◆ BigEndianBinaryReader() [1/3]

mage::BigEndianBinaryReader::BigEndianBinaryReader ( )
protected

Constructs a big endian binary reader.

◆ BigEndianBinaryReader() [2/3]

mage::BigEndianBinaryReader::BigEndianBinaryReader ( const BigEndianBinaryReader reader)
protecteddelete

Constructs a big endian binary reader from the given big endian binary reader.

Parameters
[in]readerA reference to the big endian binary reader to copy.

◆ BigEndianBinaryReader() [3/3]

mage::BigEndianBinaryReader::BigEndianBinaryReader ( BigEndianBinaryReader &&  reader)
protecteddefaultnoexcept

Constructs a big endian binary reader by moving the given big endian binary reader.

Parameters
[in]readerA reference to the big endian binary reader to move.

◆ ~BigEndianBinaryReader()

mage::BigEndianBinaryReader::~BigEndianBinaryReader ( )
protecteddefault

Destructs this big endian binary reader.

Member Function Documentation

◆ ContainsChars()

bool mage::BigEndianBinaryReader::ContainsChars ( ) const
protectednoexcept

Checks if there are characters left to read by this big endian binary reader.

Returns
true if there are characters left to read by this binary reader. false otherwise.

◆ GetPath()

const std::filesystem::path& mage::BigEndianBinaryReader::GetPath ( ) const
protectednoexcept

Returns the current path of this big endian binary reader.

Returns
A reference to the current path of this big endian binary reader.

◆ operator=() [1/2]

BigEndianBinaryReader& mage::BigEndianBinaryReader::operator= ( const BigEndianBinaryReader reader)
delete

Copies the given big endian binary reader to this big endian binary reader.

Parameters
[in]readerA reference to a big endian binary reader to copy.
Returns
A reference to the copy of the given big endian binary reader (i.e. this big endian binary reader).

◆ operator=() [2/2]

BigEndianBinaryReader & mage::BigEndianBinaryReader::operator= ( BigEndianBinaryReader &&  reader)
defaultnoexcept

Moves the given big endian binary reader to this big endian binary reader.

Parameters
[in]readerA reference to a big endian binary reader to move.
Returns
A reference to the moved big endian binary reader (i.e. this big endian binary reader).

◆ Read()

template<typename T >
const T mage::BigEndianBinaryReader::Read ( )
protected

Reads a T value.

Template Parameters
TThe data type.
Returns
The T value read.
Exceptions
ExceptionFailed to read a T value.

◆ ReadArray()

template<typename T >
const T* mage::BigEndianBinaryReader::ReadArray ( std::size_t  count)
protected

Reads an array of T values.

Template Parameters
TThe data type.
Parameters
countThe number of T values to read.
Returns
A pointer to the array of T value read.
Exceptions
ExceptionFailed to read count T values.

◆ ReadData()

virtual void mage::BigEndianBinaryReader::ReadData ( )
privatepure virtual

Starts reading.

Exceptions
ExceptionFailed to read from the given file.

Implemented in mage::rendering::loader::MSHReader< VertexT, IndexT >, and mage::rendering::loader::SpriteFontReader.

◆ ReadFromFile()

void mage::BigEndianBinaryReader::ReadFromFile ( std::filesystem::path  path)

Reads from the file associated with the given path.

Parameters
[in]pathThe path.
Exceptions
ExceptionFailed to read from the file.

◆ ReadFromMemory()

void mage::BigEndianBinaryReader::ReadFromMemory ( gsl::span< const U8 input)

Reads the input string.

Parameters
[in]inputThe input byte string.
Exceptions
ExceptionFailed to read from the given input string.

Member Data Documentation

◆ m_data

UniquePtr< U8[] > mage::BigEndianBinaryReader::m_data
private

A pointer to the data to read of this big endian binary reader.

◆ m_end

const U8* mage::BigEndianBinaryReader::m_end
private

A pointer to the end position of this big endian binary reader.

◆ m_path

std::filesystem::path mage::BigEndianBinaryReader::m_path
private

The current path of this big endian binary reader.

◆ m_pos

const U8* mage::BigEndianBinaryReader::m_pos
private

A pointer to the current position of this big endian binary reader.