MAGE  v0.171.0
Matthias Advanced Game Engine
mage::loader::VARReader Class Reference

#include <var_reader.hpp>

Inheritance diagram for mage::loader::VARReader:
mage::LineReader

Public Member Functions

 VARReader (ValueMap &variable_buffer)
 
 VARReader (const VARReader &reader)=delete
 
 VARReader (VARReader &&reader) noexcept
 
 ~VARReader ()
 
VARReaderoperator= (const VARReader &reader)=delete
 
VARReaderoperator= (VARReader &&reader)=delete
 
void ReadFromFile (std::filesystem::path path, std::regex regex=s_default_regex, SelectionFunction selection_function=s_default_selection_function)
 
void ReadFromMemory (const std::string &input, std::regex regex=s_default_regex, SelectionFunction selection_function=s_default_selection_function)
 

Private Member Functions

virtual void ReadLine () override
 
template<typename T >
void ReadVARVariable ()
 
template<typename T , std::size_t N, size_t A = alignof(T)>
void ReadVARVariable ()
 
- Private Member Functions inherited from mage::LineReader
LineReaderoperator= (const LineReader &reader)=delete
 
LineReaderoperator= (LineReader &&reader) noexcept
 
void ReadFromFile (std::filesystem::path path, std::regex regex=s_default_regex, SelectionFunction selection_function=s_default_selection_function)
 
void ReadFromMemory (const std::string &input, std::regex regex=s_default_regex, SelectionFunction selection_function=s_default_selection_function)
 
 LineReader ()
 
 LineReader (const LineReader &reader)=delete
 
 LineReader (LineReader &&reader) noexcept
 
 ~LineReader ()
 
const std::filesystem::path & GetPath () const noexcept
 
U32 GetCurrentLineNumber () const noexcept
 
template<typename T >
const T Read ()
 
template<typename T , std::size_t N, size_t A = alignof(T)>
const Array< T, N, A > Read ()
 
void ReadRemainingTokens ()
 
template<typename T >
bool Contains () const noexcept
 
bool ContainsTokens () const noexcept
 

Private Attributes

ValueMapm_variable_buffer
 

Additional Inherited Members

- Private Types inherited from mage::LineReader
using SelectionFunction = std::function< const std::ssub_match(const std::smatch &) >
 
- Static Private Attributes inherited from mage::LineReader
static const std::regex s_default_regex = std::regex(R"((\"([^\"]*)\")|(\S+))")
 
static const SelectionFunction s_default_selection_function
 

Detailed Description

A class of VAR file readers for reading variable scripts.

Constructor & Destructor Documentation

◆ VARReader() [1/3]

mage::loader::VARReader::VARReader ( ValueMap variable_buffer)
explicit

Constructs a VAR reader.

Parameters
[in]variable_bufferA reference to a map for storing the read variables from file.

◆ VARReader() [2/3]

mage::loader::VARReader::VARReader ( const VARReader reader)
delete

Constructs a VAR reader from the given VAR reader.

Parameters
[in]readerA reference to the VAR reader to copy.

◆ VARReader() [3/3]

mage::loader::VARReader::VARReader ( VARReader &&  reader)
defaultnoexcept

Constructs a VAR reader by moving the given VAR reader.

Parameters
[in]readerA reference to the VAR reader to move.

◆ ~VARReader()

mage::loader::VARReader::~VARReader ( )
default

Destructs this VAR reader.

Member Function Documentation

◆ operator=() [1/2]

VARReader& mage::loader::VARReader::operator= ( const VARReader reader)
delete

Copies the given VAR reader to this VAR reader.

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

◆ operator=() [2/2]

VARReader& mage::loader::VARReader::operator= ( VARReader &&  reader)
delete

Moves the given VAR reader to this VAR reader.

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

◆ ReadFromFile()

void mage::LineReader::ReadFromFile

Reads from the file associated with the given path.

Parameters
[in]pathThe path.
[in]regexThe (line) regex.
[in]selection_functionThe selection function.
Exceptions
ExceptionFailed to read from the file.

◆ ReadFromMemory()

void mage::LineReader::ReadFromMemory

Reads from the given input string.

Parameters
[in]inputA reference to the input string.
[in]regexThe (line) regex.
[in]selection_functionThe selection function.
Exceptions
ExceptionFailed to read from the given input string.

◆ ReadLine()

void mage::loader::VARReader::ReadLine ( )
overrideprivatevirtual

Reads the current line of this VAR reader.

Exceptions
ExceptionFailed to the current line of this VAR reader.

Implements mage::LineReader.

◆ ReadVARVariable() [1/2]

template<typename T >
void mage::loader::VARReader::ReadVARVariable ( )
private

Reads a variable definition.

Template Parameters
TThe variable type.
Exceptions
ExceptionFailed to read a variable definition.

◆ ReadVARVariable() [2/2]

template<typename T , std::size_t N, size_t A = alignof(T)>
void mage::loader::VARReader::ReadVARVariable ( )
private

Reads an array variable definition.

Template Parameters
TThe variable type.
NThe number of values in the array.
AThe alignment of the array.
Exceptions
ExceptionFailed to read an array variable definition.

Member Data Documentation

◆ m_variable_buffer

ValueMap& mage::loader::VARReader::m_variable_buffer
private

A reference to a map containing the read variables of this VAR reader.