Pixie
Loading...
Searching...
No Matches
pixie::SpanOutputSink Class Reference

Non-owning fixed-capacity output sink. More...

#include <serialization.h>

Public Member Functions

 SpanOutputSink (std::span< std::byte > storage)
 Construct an empty output over caller-owned storage.
 
bool empty () const noexcept
 Return whether no output bytes have been written.
 
std::size_t size_bytes () const noexcept
 Return the number of output bytes written.
 
std::size_t capacity_bytes () const noexcept
 Return the fixed output capacity in bytes.
 
std::span< const std::byte > bytes () const noexcept
 Return the prefix written so far.
 
void write (std::span< const std::byte > bytes)
 Append bytes to the output.
 
void write_at (std::size_t position, std::span< const std::byte > bytes)
 Replace output bytes beginning at position.
 
void finish () noexcept
 Complete this fixed-span output.
 

Detailed Description

Non-owning fixed-capacity output sink.

The caller keeps the writable span alive and stable until the associated writer is finished.

Member Function Documentation

◆ write()

void pixie::SpanOutputSink::write ( std::span< const std::byte > bytes)
inline

Append bytes to the output.

Exceptions
std::length_errorif the fixed output capacity is insufficient.

◆ write_at()

void pixie::SpanOutputSink::write_at ( std::size_t position,
std::span< const std::byte > bytes )
inline

Replace output bytes beginning at position.

Exceptions
std::out_of_rangeif the range is outside the written prefix.

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