NSUNI/NSLAR Library a250670
Loading...
Searching...
No Matches
Input/Output

Provides classes for reading and writing binary data to and from various sources. More...

Classes

class  nnl::RWBase
 Base interface for data reading/writing classes. More...
class  nnl::Reader
 Abstract class for reading data. More...
class  nnl::Writer
 Abstract class for writing data. More...
class  nnl::FileReader
 Reader implementation for reading from a file. More...
class  nnl::FileRW
 Reader/Writer implementation for file io operations. More...
class  nnl::BufferView
 Reader implementation for read-only memory buffers. More...
class  nnl::BufferSpan
 Reader/Writer implementation for mutable memory buffers. More...
class  nnl::BufferRW
 Reader/Writer implementation that writes to an internal growable buffer. More...

Typedefs

using nnl::Buffer = std::vector<u8>
 A type alias for std::vector<u8> that denotes a raw, contiguous memory region that may be interpreted in multiple ways.

Detailed Description

Provides classes for reading and writing binary data to and from various sources.

See also
nnl::Reader
nnl::Writer
nnl::BufferView
nnl::BufferRW
nnl::FileReader
nnl::FileRW
nnl::BufferSpan

Class Documentation

◆ nnl::RWBase

class nnl::RWBase

Base interface for data reading/writing classes.

Provides basic functionality for data "streams".

See also
nnl::Reader
nnl::Writer

Inherited by nnl::Reader [virtual], and nnl::Writer [virtual].

Public Member Functions

virtual void Seek (std::size_t offset)=0
 Seeks to a specific offset in the data.
virtual std::size_t Tell ()=0
 Gets the current position in the data.
virtual std::size_t Len ()=0
 Gets the available length of the data.

Member Function Documentation

◆ Len()

virtual std::size_t nnl::RWBase::Len ( )
pure virtual

Gets the available length of the data.

Returns
The length of the data.

Implemented in nnl::BufferRW, nnl::BufferSpan, nnl::BufferView, nnl::FileReader, and nnl::FileRW.

◆ Seek()

virtual void nnl::RWBase::Seek ( std::size_t offset)
pure virtual

Seeks to a specific offset in the data.

Parameters
offsetThe offset to seek to.

Implemented in nnl::BufferRW, nnl::BufferSpan, nnl::BufferView, nnl::FileReader, and nnl::FileRW.

◆ Tell()

virtual std::size_t nnl::RWBase::Tell ( )
pure virtual

Gets the current position in the data.

Returns
The current position as a size_t.

Implemented in nnl::BufferRW, nnl::BufferSpan, nnl::BufferView, nnl::FileReader, and nnl::FileRW.

◆ nnl::Reader

class nnl::Reader

Abstract class for reading data.

Inherits from RWBase and provides methods to read trivially copyable data from various sources.

Inherits nnl::RWBase.

Inherited by nnl::BufferRW, nnl::BufferSpan, nnl::BufferView, nnl::FileRW, and nnl::FileReader.

Public Member Functions

void ReadBuf (void *dst, std::size_t size)
 Reads a block of data into the specified destination.
template<typename T, typename = std::enable_if_t<std::is_trivially_copyable_v<T>>>
ReadLE ()
 Reads a trivially copyable object.
template<typename T>
std::vector< T > ReadArrayLE (std::size_t num_elements)
 Reads multiple trivially copyable objects into a vector.
Public Member Functions inherited from nnl::RWBase
virtual void Seek (std::size_t offset)=0
 Seeks to a specific offset in the data.
virtual std::size_t Tell ()=0
 Gets the current position in the data.
virtual std::size_t Len ()=0
 Gets the available length of the data.

Protected Member Functions

virtual void ReadData (void *dst, std::size_t size)=0
 Low-level data reading implementation.

Member Function Documentation

◆ ReadArrayLE()

template<typename T>
std::vector< T > nnl::Reader::ReadArrayLE ( std::size_t num_elements)
inline

Reads multiple trivially copyable objects into a vector.

Template Parameters
TType to read (must be trivially copyable)
Parameters
num_elementsNumber of elements to read
Returns
Container filled with read elements

◆ ReadBuf()

void nnl::Reader::ReadBuf ( void * dst,
std::size_t size )
inline

Reads a block of data into the specified destination.

Parameters
dstPointer to the destination buffer.
sizeSize of the data to read in bytes.

◆ ReadData()

virtual void nnl::Reader::ReadData ( void * dst,
std::size_t size )
protectedpure virtual

Low-level data reading implementation.

Parameters
dstDestination buffer
sizeNumber of bytes to read

Implemented in nnl::BufferRW, nnl::BufferSpan, nnl::BufferView, nnl::FileReader, and nnl::FileRW.

◆ ReadLE()

template<typename T, typename = std::enable_if_t<std::is_trivially_copyable_v<T>>>
T nnl::Reader::ReadLE ( )
inline

Reads a trivially copyable object.

Template Parameters
TType to read (must be trivially copyable)
Returns
The read value

◆ nnl::Writer

class nnl::Writer

Abstract class for writing data.

Inherits from RWBase and provides methods to write trivially copyable data to various destinations.

Inherits nnl::RWBase.

Inherited by nnl::BufferRW, nnl::BufferSpan, and nnl::FileRW.

Public Member Functions

template<typename T, typename = std::enable_if_t<std::is_trivially_copyable_v<T>>>
Offset< T > MakeOffsetLE ()
 Creates an Offset pointing to the current position.
Offset< u8WriteBuf (const void *src, std::size_t size)
 Writes raw binary data.
template<typename T, std::enable_if_t< std::is_trivially_copyable_v< T >, int > = 0>
Offset< T > WriteLE (const T &value)
 Writes a trivially copyable value.
template<typename T>
Offset< T > WriteArrayLE (const std::vector< T > &container)
 Writes contents of a vector.
void AlignData (std::size_t multiple, unsigned char value=0)
 Aligns the current position to a specified multiple.
Public Member Functions inherited from nnl::RWBase
virtual void Seek (std::size_t offset)=0
 Seeks to a specific offset in the data.
virtual std::size_t Tell ()=0
 Gets the current position in the data.
virtual std::size_t Len ()=0
 Gets the available length of the data.

Protected Member Functions

virtual void WriteData (const void *src, std::size_t size)=0
 Low-level data writing implementation.

Member Function Documentation

◆ AlignData()

void nnl::Writer::AlignData ( std::size_t multiple,
unsigned char value = 0 )
inline

Aligns the current position to a specified multiple.

Parameters
multipleAlignment boundary (e.g., 4 for 4-byte alignment)
valueByte value to use for padding

◆ MakeOffsetLE()

template<typename T, typename = std::enable_if_t<std::is_trivially_copyable_v<T>>>
Offset< T > nnl::Writer::MakeOffsetLE ( )
inline

Creates an Offset pointing to the current position.

Template Parameters
TType of the object to reference
Returns
Offset object at current position

◆ WriteArrayLE()

template<typename T>
Offset< T > nnl::Writer::WriteArrayLE ( const std::vector< T > & container)
inline

Writes contents of a vector.

Parameters
containerContainer to write
Returns
Offset pointing to the first written element

◆ WriteBuf()

Offset< u8 > nnl::Writer::WriteBuf ( const void * src,
std::size_t size )
inline

Writes raw binary data.

Parameters
srcSource buffer
sizeNumber of bytes to write
Returns
Offset pointing to the written data

◆ WriteData()

virtual void nnl::Writer::WriteData ( const void * src,
std::size_t size )
protectedpure virtual

Low-level data writing implementation.

Parameters
srcSource buffer
sizeNumber of bytes to write

Implemented in nnl::BufferRW, nnl::BufferSpan, and nnl::FileRW.

◆ WriteLE()

template<typename T, std::enable_if_t< std::is_trivially_copyable_v< T >, int > = 0>
Offset< T > nnl::Writer::WriteLE ( const T & value)
inline

Writes a trivially copyable value.

Template Parameters
TValue type (must be trivially copyable)
Parameters
valueValue to write
Returns
Offset pointing to the written value

◆ nnl::FileReader

class nnl::FileReader

Reader implementation for reading from a file.

Inherits nnl::Reader.

Public Member Functions

 FileReader (const std::filesystem::path &path)
 Constructs a FileReader from the specified file.
void Seek (std::size_t offset) override
 Seeks to a specific offset in the data.
std::size_t Tell () override
 Gets the current position in the data.
std::size_t Len () override
 Gets the available length of the data.
void ClearState ()
 Clears any error flags on the file stream.
void Close ()
 Closes the file.
Public Member Functions inherited from nnl::Reader
void ReadBuf (void *dst, std::size_t size)
 Reads a block of data into the specified destination.
template<typename T, typename = std::enable_if_t<std::is_trivially_copyable_v<T>>>
ReadLE ()
 Reads a trivially copyable object.
template<typename T>
std::vector< T > ReadArrayLE (std::size_t num_elements)
 Reads multiple trivially copyable objects into a vector.

Protected Member Functions

void ReadData (void *dst, std::size_t size) override
 Low-level data reading implementation.

Constructor & Destructor Documentation

◆ FileReader()

nnl::FileReader::FileReader ( const std::filesystem::path & path)
inline

Constructs a FileReader from the specified file.

Parameters
pathThe filesystem path to the file.
Exceptions
nnl::IOError

Member Function Documentation

◆ ClearState()

void nnl::FileReader::ClearState ( )
inline

Clears any error flags on the file stream.

◆ Close()

void nnl::FileReader::Close ( )
inline

Closes the file.

◆ Len()

std::size_t nnl::FileReader::Len ( )
inlineoverridevirtual

Gets the available length of the data.

Returns
The length of the data.

Implements nnl::RWBase.

◆ ReadData()

void nnl::FileReader::ReadData ( void * dst,
std::size_t size )
inlineoverrideprotectedvirtual

Low-level data reading implementation.

Parameters
dstDestination buffer
sizeNumber of bytes to read

Implements nnl::Reader.

◆ Seek()

void nnl::FileReader::Seek ( std::size_t offset)
inlineoverridevirtual

Seeks to a specific offset in the data.

Parameters
offsetThe offset to seek to.

Implements nnl::RWBase.

◆ Tell()

std::size_t nnl::FileReader::Tell ( )
inlineoverridevirtual

Gets the current position in the data.

Returns
The current position as a size_t.

Implements nnl::RWBase.

◆ nnl::FileRW

class nnl::FileRW

Reader/Writer implementation for file io operations.

Inherits nnl::Writer, and nnl::Reader.

Public Member Functions

 FileRW (const std::filesystem::path &path, bool truncate)
 Constructs a FileRW from the specified file.
void Seek (std::size_t offset) override
 Seeks to a specific offset in the data.
std::size_t Tell () override
 Gets the current position in the data.
std::size_t Len () override
 Gets the available length of the data.
void ClearState ()
 Clears any error flags on the file stream.
void Close ()
 Closes the file.
Public Member Functions inherited from nnl::Writer
template<typename T, typename = std::enable_if_t<std::is_trivially_copyable_v<T>>>
Offset< T > MakeOffsetLE ()
 Creates an Offset pointing to the current position.
Offset< u8WriteBuf (const void *src, std::size_t size)
 Writes raw binary data.
template<typename T, std::enable_if_t< std::is_trivially_copyable_v< T >, int > = 0>
Offset< T > WriteLE (const T &value)
 Writes a trivially copyable value.
template<typename T>
Offset< T > WriteArrayLE (const std::vector< T > &container)
 Writes contents of a vector.
void AlignData (std::size_t multiple, unsigned char value=0)
 Aligns the current position to a specified multiple.
Public Member Functions inherited from nnl::Reader
void ReadBuf (void *dst, std::size_t size)
 Reads a block of data into the specified destination.
template<typename T, typename = std::enable_if_t<std::is_trivially_copyable_v<T>>>
ReadLE ()
 Reads a trivially copyable object.
template<typename T>
std::vector< T > ReadArrayLE (std::size_t num_elements)
 Reads multiple trivially copyable objects into a vector.

Protected Member Functions

void WriteData (const void *src, std::size_t size) override
 Low-level data writing implementation.
void ReadData (void *dst, std::size_t size) override
 Low-level data reading implementation.

Constructor & Destructor Documentation

◆ FileRW()

nnl::FileRW::FileRW ( const std::filesystem::path & path,
bool truncate )
inline

Constructs a FileRW from the specified file.

Parameters
pathThe filesystem path to the file.
truncateIf the contents should be discarded
Note
The file must exist if truncate is false
Exceptions
nnl::IOError

Member Function Documentation

◆ ClearState()

void nnl::FileRW::ClearState ( )
inline

Clears any error flags on the file stream.

◆ Close()

void nnl::FileRW::Close ( )
inline

Closes the file.

◆ Len()

std::size_t nnl::FileRW::Len ( )
inlineoverridevirtual

Gets the available length of the data.

Returns
The length of the data.

Implements nnl::RWBase.

◆ ReadData()

void nnl::FileRW::ReadData ( void * dst,
std::size_t size )
inlineoverrideprotectedvirtual

Low-level data reading implementation.

Parameters
dstDestination buffer
sizeNumber of bytes to read

Implements nnl::Reader.

◆ Seek()

void nnl::FileRW::Seek ( std::size_t offset)
inlineoverridevirtual

Seeks to a specific offset in the data.

Parameters
offsetThe offset to seek to.

Implements nnl::RWBase.

◆ Tell()

std::size_t nnl::FileRW::Tell ( )
inlineoverridevirtual

Gets the current position in the data.

Returns
The current position as a size_t.

Implements nnl::RWBase.

◆ WriteData()

void nnl::FileRW::WriteData ( const void * src,
std::size_t size )
inlineoverrideprotectedvirtual

Low-level data writing implementation.

Parameters
srcSource buffer
sizeNumber of bytes to write

Implements nnl::Writer.

◆ nnl::BufferView

class nnl::BufferView

Reader implementation for read-only memory buffers.

Provides a view into existing memory without taking ownership. Suitable for reading from buffers or memory-mapped files. Offers an interface similar to std::vector.

std::vector<unsigned char> buffer(64,0);
nnl::BufferView view{buffer};
nnl::BufferView c_view{buffer.data(), buffer.size()*sizeof(unsigned char)};
// Implicitly constructed
bool is_model = nnl::model::IsOfType(buffer);
Reader implementation for read-only memory buffers.
Definition io.hpp:598
bool IsOfType(BufferView buffer)
Tests if the provided file is a model.

Inherits nnl::Reader.

Public Member Functions

 BufferView (const void *buffer, std::size_t size) noexcept
 Constructs a BufferView from a pointer/size pair.
template<typename TContainer, typename = std::enable_if_t<std::is_trivially_copyable_v<typename TContainer::value_type>>>
 BufferView (const TContainer &buffer) noexcept
 Constructs a BufferView from a generic contiguous container.
void Seek (std::size_t offset) override
 Seeks to a specific offset in the data.
std::size_t Tell () override
 Gets the current position in the data.
std::size_t Len () override
 Gets the available length of the data.
BufferView SubView (std::size_t offset, std::size_t size) const
 Creates a view into a subrange of the buffer.
const u8data () const noexcept
 Gets pointer to the underlying buffer.
Public Member Functions inherited from nnl::Reader
void ReadBuf (void *dst, std::size_t size)
 Reads a block of data into the specified destination.
template<typename T, typename = std::enable_if_t<std::is_trivially_copyable_v<T>>>
ReadLE ()
 Reads a trivially copyable object.
template<typename T>
std::vector< T > ReadArrayLE (std::size_t num_elements)
 Reads multiple trivially copyable objects into a vector.

Protected Member Functions

void ReadData (void *dst, std::size_t size) override
 Low-level data reading implementation.

Constructor & Destructor Documentation

◆ BufferView() [1/2]

nnl::BufferView::BufferView ( const void * buffer,
std::size_t size )
inlinenoexcept

Constructs a BufferView from a pointer/size pair.

Parameters
bufferPointer to the buffer.
sizeThe byte size of the buffer.

◆ BufferView() [2/2]

template<typename TContainer, typename = std::enable_if_t<std::is_trivially_copyable_v<typename TContainer::value_type>>>
nnl::BufferView::BufferView ( const TContainer & buffer)
inlinenoexcept

Constructs a BufferView from a generic contiguous container.

Parameters
bufferReference to the container to use as the source.

Member Function Documentation

◆ data()

const u8 * nnl::BufferView::data ( ) const
inlinenoexcept

Gets pointer to the underlying buffer.

Returns
Const pointer to buffer data

◆ Len()

std::size_t nnl::BufferView::Len ( )
inlineoverridevirtual

Gets the available length of the data.

Returns
The length of the data.

Implements nnl::RWBase.

◆ ReadData()

void nnl::BufferView::ReadData ( void * dst,
std::size_t size )
inlineoverrideprotectedvirtual

Low-level data reading implementation.

Parameters
dstDestination buffer
sizeNumber of bytes to read

Implements nnl::Reader.

◆ Seek()

void nnl::BufferView::Seek ( std::size_t offset)
inlineoverridevirtual

Seeks to a specific offset in the data.

Parameters
offsetThe offset to seek to.

Implements nnl::RWBase.

◆ SubView()

BufferView nnl::BufferView::SubView ( std::size_t offset,
std::size_t size ) const
inlinenodiscard

Creates a view into a subrange of the buffer.

Parameters
offsetStarting offset
sizeSize of the subview
Returns
A BufferView for the subrange

◆ Tell()

std::size_t nnl::BufferView::Tell ( )
inlineoverridevirtual

Gets the current position in the data.

Returns
The current position as a size_t.

Implements nnl::RWBase.

◆ nnl::BufferSpan

class nnl::BufferSpan

Reader/Writer implementation for mutable memory buffers.

Provides read/write access to existing memory without taking ownership. Suitable for modification of buffers or memory-mapped files. Offers an interface similar to std::vector.

See also
nnl::BufferView

Inherits nnl::Reader, and nnl::Writer.

Public Member Functions

 BufferSpan (void *buffer, std::size_t size) noexcept
 Constructs a BufferSpan from a pointer/size pair.
template<typename TContainer, typename = std::enable_if_t<std::is_trivially_copyable_v<typename TContainer::value_type>>>
 BufferSpan (TContainer &buffer) noexcept
 Constructs a BufferView from a generic contiguous container.
void Seek (std::size_t offset) override
 Seeks to a specific offset in the data.
std::size_t Tell () override
 Gets the current position in the data.
std::size_t Len () override
 Gets the available length of the data.
void Clear (u8 val=0)
 Clears the buffer with a specific value.
BufferView SubView (std::size_t offset, std::size_t size) const
 Creates a read-only view into a subrange.
BufferSpan SubSpan (std::size_t offset, std::size_t size)
 Creates a mutable span into a subrange.
 operator BufferView () const noexcept
 Implicit conversion to BufferView.
u8data () noexcept
 Gets the pointer to the underlying buffer.
Public Member Functions inherited from nnl::Reader
void ReadBuf (void *dst, std::size_t size)
 Reads a block of data into the specified destination.
template<typename T, typename = std::enable_if_t<std::is_trivially_copyable_v<T>>>
ReadLE ()
 Reads a trivially copyable object.
template<typename T>
std::vector< T > ReadArrayLE (std::size_t num_elements)
 Reads multiple trivially copyable objects into a vector.
Public Member Functions inherited from nnl::Writer
template<typename T, typename = std::enable_if_t<std::is_trivially_copyable_v<T>>>
Offset< T > MakeOffsetLE ()
 Creates an Offset pointing to the current position.
Offset< u8WriteBuf (const void *src, std::size_t size)
 Writes raw binary data.
template<typename T, std::enable_if_t< std::is_trivially_copyable_v< T >, int > = 0>
Offset< T > WriteLE (const T &value)
 Writes a trivially copyable value.
template<typename T>
Offset< T > WriteArrayLE (const std::vector< T > &container)
 Writes contents of a vector.
void AlignData (std::size_t multiple, unsigned char value=0)
 Aligns the current position to a specified multiple.

Protected Member Functions

void ReadData (void *dst, std::size_t size) override
 Low-level data reading implementation.
void WriteData (const void *src, std::size_t size) override
 Low-level data writing implementation.

Constructor & Destructor Documentation

◆ BufferSpan() [1/2]

nnl::BufferSpan::BufferSpan ( void * buffer,
std::size_t size )
inlinenoexcept

Constructs a BufferSpan from a pointer/size pair.

Parameters
bufferPointer to the buffer.
sizeThe byte size of the buffer.

◆ BufferSpan() [2/2]

template<typename TContainer, typename = std::enable_if_t<std::is_trivially_copyable_v<typename TContainer::value_type>>>
nnl::BufferSpan::BufferSpan ( TContainer & buffer)
inlinenoexcept

Constructs a BufferView from a generic contiguous container.

Parameters
bufferReference to the container to use as the source.

Member Function Documentation

◆ Clear()

void nnl::BufferSpan::Clear ( u8 val = 0)
inline

Clears the buffer with a specific value.

Parameters
valValue to fill with

◆ data()

u8 * nnl::BufferSpan::data ( )
inlinenoexcept

Gets the pointer to the underlying buffer.

Returns
Mutable pointer to buffer data

◆ Len()

std::size_t nnl::BufferSpan::Len ( )
inlineoverridevirtual

Gets the available length of the data.

Returns
The length of the data.

Implements nnl::RWBase.

◆ operator BufferView()

nnl::BufferSpan::operator BufferView ( ) const
inlinenoexcept

Implicit conversion to BufferView.

◆ ReadData()

void nnl::BufferSpan::ReadData ( void * dst,
std::size_t size )
inlineoverrideprotectedvirtual

Low-level data reading implementation.

Parameters
dstDestination buffer
sizeNumber of bytes to read

Implements nnl::Reader.

◆ Seek()

void nnl::BufferSpan::Seek ( std::size_t offset)
inlineoverridevirtual

Seeks to a specific offset in the data.

Parameters
offsetThe offset to seek to.

Implements nnl::RWBase.

◆ SubSpan()

BufferSpan nnl::BufferSpan::SubSpan ( std::size_t offset,
std::size_t size )
inlinenodiscard

Creates a mutable span into a subrange.

Parameters
offsetStarting offset
sizeSize of the subspan
Returns
BufferSpan for the subrange
See also
nnl::BufferSpan::SubView

◆ SubView()

BufferView nnl::BufferSpan::SubView ( std::size_t offset,
std::size_t size ) const
inlinenodiscard

Creates a read-only view into a subrange.

Parameters
offsetStarting offset
sizeSize of the subview
Returns
BufferView for the subrange
See also
nnl::BufferSpan::SubSpan

◆ Tell()

std::size_t nnl::BufferSpan::Tell ( )
inlineoverridevirtual

Gets the current position in the data.

Returns
The current position as a size_t.

Implements nnl::RWBase.

◆ WriteData()

void nnl::BufferSpan::WriteData ( const void * src,
std::size_t size )
inlineoverrideprotectedvirtual

Low-level data writing implementation.

Parameters
srcSource buffer
sizeNumber of bytes to write

Implements nnl::Writer.

◆ nnl::BufferRW

class nnl::BufferRW

Reader/Writer implementation that writes to an internal growable buffer.

Automatically manages memory allocation and grows the buffer as needed. The written data can be extracted as an std::vector<u8> by a copy or move operation.

Inherits nnl::Writer, and nnl::Reader.

Public Member Functions

void Seek (std::size_t offset) override
 Seeks to a specific offset in the data.
std::size_t Tell () override
 Gets the current position in the data.
std::size_t Len () override
 Gets the available length of the data.
Buffer CopyBuf () const
 Makes a copy of the data.
Buffer ReleaseBuf () noexcept
 Transfers the ownership of the internal buffer_.
 operator Buffer && () &&noexcept
 Implicit conversion to std::vector<u8>&&.
Public Member Functions inherited from nnl::Writer
template<typename T, typename = std::enable_if_t<std::is_trivially_copyable_v<T>>>
Offset< T > MakeOffsetLE ()
 Creates an Offset pointing to the current position.
Offset< u8WriteBuf (const void *src, std::size_t size)
 Writes raw binary data.
template<typename T, std::enable_if_t< std::is_trivially_copyable_v< T >, int > = 0>
Offset< T > WriteLE (const T &value)
 Writes a trivially copyable value.
template<typename T>
Offset< T > WriteArrayLE (const std::vector< T > &container)
 Writes contents of a vector.
void AlignData (std::size_t multiple, unsigned char value=0)
 Aligns the current position to a specified multiple.
Public Member Functions inherited from nnl::Reader
void ReadBuf (void *dst, std::size_t size)
 Reads a block of data into the specified destination.
template<typename T, typename = std::enable_if_t<std::is_trivially_copyable_v<T>>>
ReadLE ()
 Reads a trivially copyable object.
template<typename T>
std::vector< T > ReadArrayLE (std::size_t num_elements)
 Reads multiple trivially copyable objects into a vector.

Protected Member Functions

void WriteData (const void *src, std::size_t size) override
 Low-level data writing implementation.
void ReadData (void *dst, std::size_t size) override
 Low-level data reading implementation.

Member Function Documentation

◆ CopyBuf()

Buffer nnl::BufferRW::CopyBuf ( ) const
inline

Makes a copy of the data.

Returns
The copied buffer_

◆ Len()

std::size_t nnl::BufferRW::Len ( )
inlineoverridevirtual

Gets the available length of the data.

Returns
The length of the data.

Implements nnl::RWBase.

◆ operator Buffer &&()

nnl::BufferRW::operator Buffer && ( ) &&
inlinenoexcept

Implicit conversion to std::vector<u8>&&.

This function can be used to move the contents of the buffer_ to std::vector<u8>.

Returns
The moved buffer_

◆ ReadData()

void nnl::BufferRW::ReadData ( void * dst,
std::size_t size )
inlineoverrideprotectedvirtual

Low-level data reading implementation.

Parameters
dstDestination buffer
sizeNumber of bytes to read

Implements nnl::Reader.

◆ ReleaseBuf()

Buffer nnl::BufferRW::ReleaseBuf ( )
inlinenodiscardnoexcept

Transfers the ownership of the internal buffer_.

Returns
The internal buffer_

◆ Seek()

void nnl::BufferRW::Seek ( std::size_t offset)
inlineoverridevirtual

Seeks to a specific offset in the data.

Parameters
offsetThe offset to seek to.

Implements nnl::RWBase.

◆ Tell()

std::size_t nnl::BufferRW::Tell ( )
inlineoverridevirtual

Gets the current position in the data.

Returns
The current position as a size_t.

Implements nnl::RWBase.

◆ WriteData()

void nnl::BufferRW::WriteData ( const void * src,
std::size_t size )
inlineoverrideprotectedvirtual

Low-level data writing implementation.

Parameters
srcSource buffer
sizeNumber of bytes to write

Implements nnl::Writer.

Typedef Documentation

◆ Buffer

using nnl::Buffer = std::vector<u8>

A type alias for std::vector<u8> that denotes a raw, contiguous memory region that may be interpreted in multiple ways.