Loading...
Searching...
No Matches
meshkit::native_detail::Input Class Reference

Buffered little-endian binary reader with a running FNV-1a hash and byte count. More...

#include </home/runner/work/Meshkit/Meshkit/src/native/file.hpp>

Collaboration diagram for meshkit::native_detail::Input:

Public Member Functions

 Input (std::istream &stream, Work &work)
 Bind the source and work budget.
 
bool byte (unsigned char &value, bool hashed=true)
 Read one byte, refilling the buffer when it is empty.
 
void raw (void *target, std::size_t n, bool hashed=true)
 Read exactly n bytes.
 
std::uint64_t number (int width, bool hashed=true)
 Read a little-endian unsigned value of width bytes.
 
double real ()
 Read 8 hashed bytes as a little-endian double bit pattern.
 
std::string text (std::uint64_t &remaining)
 Read a counted string (uint64 byte length, then bytes), charging a byte budget.
 

Public Attributes

std::uint64_t bytes = 0
 Bytes consumed through byte(), hashed or not.
 
std::uint64_t hash = hashSeed
 FNV-1a hash of the bytes read with hashed true, starting at hashSeed.
 

Detailed Description

Buffered little-endian binary reader with a running FNV-1a hash and byte count.

Reads the stream in 64 KiB blocks, so it may consume bytes beyond those decoded.

Constructor & Destructor Documentation

◆ Input()

meshkit::native_detail::Input::Input ( std::istream & stream,
Work & work )
inline

Bind the source and work budget.

Parameters
[in]streamBorrowed binary stream; must outlive this object.
[in]workBorrowed budget polled for cancellation before each block read; must outlive this object.

Member Function Documentation

◆ byte()

bool meshkit::native_detail::Input::byte ( unsigned char & value,
bool hashed = true )
inline

Read one byte, refilling the buffer when it is empty.

Parameters
[out]valueReceives the byte; unchanged at end of stream.
[in]hashedWhether the byte enters hash.
Returns
False at end of stream.
Exceptions
Stopcancelled, or read (status Failed) when the stream reports a read error.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ number()

std::uint64_t meshkit::native_detail::Input::number ( int width,
bool hashed = true )
inline

Read a little-endian unsigned value of width bytes.

Parameters
[in]widthByte count, 0 to 8 (unchecked).
[in]hashedWhether the bytes enter hash.
Returns
The zero-extended value.
Exceptions
Stopfrom raw().
Here is the call graph for this function:
Here is the caller graph for this function:

◆ raw()

void meshkit::native_detail::Input::raw ( void * target,
std::size_t n,
bool hashed = true )
inline

Read exactly n bytes.

Parameters
[out]targetBorrowed buffer of at least n bytes.
[in]nNumber of bytes.
[in]hashedWhether the bytes enter hash.
Exceptions
Stoptruncated (status Failed) when the stream ends first, or from byte().
Here is the call graph for this function:
Here is the caller graph for this function:

◆ real()

double meshkit::native_detail::Input::real ( )
inline

Read 8 hashed bytes as a little-endian double bit pattern.

Returns
The double, which may be NaN or infinite; not validated here.
Exceptions
Stopfrom raw().
Here is the call graph for this function:
Here is the caller graph for this function:

◆ text()

std::string meshkit::native_detail::Input::text ( std::uint64_t & remaining)
inline

Read a counted string (uint64 byte length, then bytes), charging a byte budget.

Parameters
[in,out]remainingMetadata bytes still allowed; reduced by the string length.
Returns
The bytes; UTF-8 is not checked here.
Exceptions
Stopmetadata_limit (status ResourceLimit) when the length exceeds remaining, or from raw().
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ bytes

std::uint64_t meshkit::native_detail::Input::bytes = 0

Bytes consumed through byte(), hashed or not.

◆ hash

std::uint64_t meshkit::native_detail::Input::hash = hashSeed

FNV-1a hash of the bytes read with hashed true, starting at hashSeed.


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