Buffered little-endian binary writer with a running FNV-1a hash and byte count.
More...
#include </home/runner/work/Meshkit/Meshkit/src/native/file.hpp>
|
| | Output (std::FILE *file, Work &work) |
| | Bind the destination and work budget.
|
| |
| void | flush () |
| | Poll cancellation, then write out the buffered bytes.
|
| |
| void | raw (const void *data, std::size_t n, bool hashed=true) |
| | Append bytes, flushing whenever the buffer fills.
|
| |
| void | number (std::uint64_t value, int width, bool hashed=true) |
| | Append the low bytes of an unsigned value, least significant first.
|
| |
| void | real (double value) |
| | Append a double's 8-byte bit pattern, little-endian and hashed.
|
| |
| void | text (const std::string &s) |
| | Append a counted string: its uint64 byte length, then its bytes, both hashed.
|
| |
|
| std::uint64_t | bytes = 0 |
| | Bytes accepted by raw(), hashed or not.
|
| |
| std::uint64_t | hash = hashSeed |
| | FNV-1a hash of the bytes written with hashed true, starting at hashSeed.
|
| |
Buffered little-endian binary writer with a running FNV-1a hash and byte count.
Uses a 64 KiB buffer. The destructor does not flush: call flush() before committing, or buffered bytes are lost.
◆ Output()
| meshkit::native_detail::Output::Output |
( |
std::FILE * | file, |
|
|
Work & | work ) |
|
inline |
Bind the destination and work budget.
- Parameters
-
| [in] | file | Borrowed open stream; not closed by this object. |
| [in] | work | Borrowed budget polled for cancellation on each flush; must outlive this. |
◆ flush()
| void meshkit::native_detail::Output::flush |
( |
| ) |
|
|
inline |
Poll cancellation, then write out the buffered bytes.
- Exceptions
-
| Stop | cancelled, or write (status Failed) on a short write. |
◆ number()
| void meshkit::native_detail::Output::number |
( |
std::uint64_t | value, |
|
|
int | width, |
|
|
bool | hashed = true ) |
|
inline |
Append the low bytes of an unsigned value, least significant first.
- Parameters
-
| [in] | value | Value to write; bits above width bytes are dropped. |
| [in] | width | Byte count, 0 to 8 (unchecked). |
| [in] | hashed | Whether the bytes enter hash. |
◆ raw()
| void meshkit::native_detail::Output::raw |
( |
const void * | data, |
|
|
std::size_t | n, |
|
|
bool | hashed = true ) |
|
inline |
Append bytes, flushing whenever the buffer fills.
- Parameters
-
| [in] | data | Borrowed bytes; may be null only when n is 0. |
| [in] | n | Number of bytes. |
| [in] | hashed | Whether the bytes enter hash. |
- Exceptions
-
◆ real()
| void meshkit::native_detail::Output::real |
( |
double | value | ) |
|
|
inline |
Append a double's 8-byte bit pattern, little-endian and hashed.
- Parameters
-
| [in] | value | Value to write, NaN payloads and signed zero included. |
◆ text()
| void meshkit::native_detail::Output::text |
( |
const std::string & | s | ) |
|
|
inline |
Append a counted string: its uint64 byte length, then its bytes, both hashed.
- Parameters
-
| [in] | s | Bytes to write; UTF-8 is not checked here. |
◆ bytes
| std::uint64_t meshkit::native_detail::Output::bytes = 0 |
Bytes accepted by raw(), hashed or not.
◆ hash
| std::uint64_t meshkit::native_detail::Output::hash = hashSeed |
FNV-1a hash of the bytes written with hashed true, starting at hashSeed.
The documentation for this class was generated from the following file: