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>
|
| | 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.
|
| |
|
| 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.
|
| |
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.
◆ Input()
| meshkit::native_detail::Input::Input |
( |
std::istream & | stream, |
|
|
Work & | work ) |
|
inline |
Bind the source and work budget.
- Parameters
-
| [in] | stream | Borrowed binary stream; must outlive this object. |
| [in] | work | Borrowed budget polled for cancellation before each block read; must outlive this object. |
◆ 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] | value | Receives the byte; unchanged at end of stream. |
| [in] | hashed | Whether the byte enters hash. |
- Returns
- False at end of stream.
- Exceptions
-
| Stop | cancelled, or read (status Failed) when the stream reports a read error. |
◆ 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] | width | Byte count, 0 to 8 (unchecked). |
| [in] | hashed | Whether the bytes enter hash. |
- Returns
- The zero-extended value.
- Exceptions
-
◆ raw()
| void meshkit::native_detail::Input::raw |
( |
void * | target, |
|
|
std::size_t | n, |
|
|
bool | hashed = true ) |
|
inline |
Read exactly n bytes.
- Parameters
-
| [out] | target | Borrowed buffer of at least n bytes. |
| [in] | n | Number of bytes. |
| [in] | hashed | Whether the bytes enter hash. |
- Exceptions
-
| Stop | truncated (status Failed) when the stream ends first, or from byte(). |
◆ 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
-
◆ 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] | remaining | Metadata bytes still allowed; reduced by the string length. |
- Returns
- The bytes; UTF-8 is not checked here.
- Exceptions
-
| Stop | metadata_limit (status ResourceLimit) when the length exceeds remaining, or from raw(). |
◆ 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: