RetroLinker
Linker for several 8-bit, 16-bit and 32-bit formats
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | List of all members
Linker::WindowReader Class Reference

Reader subclass that restricts access of another Reader to fixed window. More...

#include <reader.h>

Inheritance diagram for Linker::WindowReader:
Linker::Reader

Public Member Functions

 WindowReader (EndianType endiantype, std::shared_ptr< Reader > reader, offset_t start_offset, offset_t maximum_size, offset_t displacement=0)
 
 WindowReader (std::shared_ptr< Reader > reader, offset_t start_offset, offset_t maximum_size, offset_t displacement=0)
 
size_t Read (void *data, size_t max_count=size_t(-1)) override
 Read in as many bytes as possible.
 
void Seek (offset_t offset) override
 Jump to a specific location in the input stream.
 
void Skip (relative_offset_t offset) override
 Jump to a distance in the input stream.
 
void SeekEnd (relative_offset_t offset=0) override
 Jump to end of the input stream.
 
offset_t Tell () override
 Retrieve the current location.
 
offset_t GetImageEnd () override
 Returns the last location that can be read.
 
- Public Member Functions inherited from Linker::Reader
OverflowHandlingMode GetActionOnOverflow ()
 
 Reader (EndianType endiantype)
 
std::shared_ptr< Reader > CreateWindow (offset_t new_start_offset, offset_t new_maximum_size=offset_t(-1), offset_t displacement=0)
 
void ReadData (size_t count, void *data)
 Read in a sequence of bytes.
 
void ReadData (size_t count, std::vector< uint8_t > &data, size_t offset=0)
 Read in a sequence of bytes, resize the vector.
 
void ReadData (std::vector< uint8_t > &data, size_t offset=0)
 Read in a sequence of bytes, filling the vector.
 
std::string ReadData (size_t count, bool terminate_at_null=false)
 Read in a sequence of bytes.
 
std::string ReadUTF16Data (size_t count, bool terminate_at_null=false)
 Read in a sequence of 16-bit words.
 
template<class T , std::size_t N>
void ReadData (std::array< T, N > &data, size_t offset=0)
 Read in a sequence of bytes.
 
std::string ReadASCII (char terminator, size_t maximum=size_t(-1))
 Read an ASCII string up to a terminator.
 
std::string ReadASCIIZ (size_t maximum=size_t(-1))
 Read a zero terminated ASCII string.
 
std::string ReadUTF16Data (const char terminator[2], size_t maximum=size_t(-1))
 Read a string of 16-bit words up to a terminator.
 
std::string ReadUTF16Data (char16_t terminator, size_t maximum, EndianType endiantype)
 Read a string of 16-bit words up to a terminator.
 
std::string ReadUTF16Data (char16_t terminator, size_t maximum=size_t(-1))
 Read a string of 16-bit words up to a terminator.
 
std::string ReadUTF16Data (char16_t terminator, EndianType endiantype)
 Read a string of 16-bit words up to a terminator.
 
std::string ReadUTF16ZData (size_t maximum=size_t(-1))
 Read a zero terminated string of 16-bit words.
 
uint64_t ReadUnsigned (size_t bytes, EndianType endiantype)
 Read an unsigned word.
 
uint64_t ReadUnsigned (size_t bytes)
 Read an unsigned word.
 
uint64_t ReadSigned (size_t bytes, EndianType endiantype)
 Read a signed word.
 
uint64_t ReadSigned (size_t bytes)
 Read a signed word.
 
template<typename Clock >
Timestamp< Clock > ReadTimestamp (EndianType endiantype)
 Read a date-time value according to some epoch.
 
template<typename Clock >
Timestamp< Clock > ReadTimestamp ()
 Read a date-time value according to some epoch.
 
offset_t GetRemainingCount ()
 Returns the byte count until the last location that can be read.
 

Public Attributes

std::shared_ptr< Reader > reader
 
offset_t start_offset
 The first offset in the base reader that is accessible, 0 meaning all.
 
offset_t maximum_size
 The maximum number of bytes in the base reader that are accessible, offset_t(-1) is reserved to mean all.
 
offset_t window_offset
 The lowest address that is allowed to be accessed, the offset at which the byte at start_offset is found.
 
- Public Attributes inherited from Linker::Reader
EndianType endiantype
 The default endianness of the binary format, used for reading multibyte numeric data.
 
OverflowHandlingMode on_overflow = TerminateOnOverflow
 Intended behavior of reading routines on read overflow.
 

Protected Member Functions

void _ValidateParameters ()
 
void _ShiftStartOffset (offset_t addend)
 Decrease the window by shifting its lower bound by addend.
 
void _RestrictMaximumSize (offset_t new_maximum)
 Decrease the window by decrementing its upper bound.
 
void _AddDisplacement (offset_t displacement)
 Shift the address values at which the window is accessed, so the previous offset O is accessed at O + extra_displacement.
 

Static Protected Member Functions

static std::shared_ptr< Reader > _GetReader (std::shared_ptr< Reader > reader)
 
static offset_t _GetStartOffset (std::shared_ptr< Reader > reader)
 
static offset_t _GetMaximumSize (std::shared_ptr< Reader > reader)
 
static offset_t _GetWindowOffset (std::shared_ptr< Reader > reader)
 

Additional Inherited Members

- Public Types inherited from Linker::Reader
enum  OverflowHandlingMode { IgnoreOnOverflow , ReportOnOverflow , TerminateOnOverflow }
 Describes how ReadData and all other reading routines should behave when reading exceeds limits (end of file or dynamic boundary) More...
 
enum class  OverflowHandlingRequest { Default , Force , Report }
 Describes how the user expects the parser to behave on read overflow. More...
 
- Static Public Attributes inherited from Linker::Reader
static OverflowHandlingRequest global_overflow_behavior = Reader::OverflowHandlingRequest::Default
 Global flag to control how reading overflow should be handled.
 

Detailed Description

Reader subclass that restricts access of another Reader to fixed window.

Member Function Documentation

◆ GetImageEnd()

offset_t WindowReader::GetImageEnd ( )
overridevirtual

Returns the last location that can be read.

Reimplemented from Linker::Reader.

◆ Read()

size_t WindowReader::Read ( void *  data,
size_t  max_count = size_t(-1) 
)
overridevirtual

Read in as many bytes as possible.

Implements Linker::Reader.

◆ Seek()

void WindowReader::Seek ( offset_t  offset)
overridevirtual

Jump to a specific location in the input stream.

Implements Linker::Reader.

◆ SeekEnd()

void WindowReader::SeekEnd ( relative_offset_t  offset = 0)
overridevirtual

Jump to end of the input stream.

Implements Linker::Reader.

◆ Skip()

void WindowReader::Skip ( relative_offset_t  offset)
overridevirtual

Jump to a distance in the input stream.

Implements Linker::Reader.

◆ Tell()

offset_t WindowReader::Tell ( )
overridevirtual

Retrieve the current location.

Implements Linker::Reader.


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