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

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>

Collaboration diagram for meshkit::native_detail::Output:

Public Member Functions

 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.
 

Public Attributes

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ Output()

meshkit::native_detail::Output::Output ( std::FILE * file,
Work & work )
inline

Bind the destination and work budget.

Parameters
[in]fileBorrowed open stream; not closed by this object.
[in]workBorrowed budget polled for cancellation on each flush; must outlive this.

Member Function Documentation

◆ flush()

void meshkit::native_detail::Output::flush ( )
inline

Poll cancellation, then write out the buffered bytes.

Exceptions
Stopcancelled, or write (status Failed) on a short write.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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]valueValue to write; bits above width bytes are dropped.
[in]widthByte count, 0 to 8 (unchecked).
[in]hashedWhether the bytes enter hash.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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]dataBorrowed bytes; may be null only when n is 0.
[in]nNumber of bytes.
[in]hashedWhether the bytes enter hash.
Exceptions
Stopfrom flush().
Here is the call graph for this function:
Here is the caller graph for this function:

◆ real()

void meshkit::native_detail::Output::real ( double value)
inline

Append a double's 8-byte bit pattern, little-endian and hashed.

Parameters
[in]valueValue to write, NaN payloads and signed zero included.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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]sBytes to write; UTF-8 is not checked here.
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::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: