auth 0.0.1
Authenticated computation with C++26 modules
Loading...
Searching...
No Matches
auth::writer Struct Referenceexport

Appends deterministic, byte-aligned fields to an owned buffer. More...

Public Member Functions

template<std::unsigned_integral T>
void field (T value)
 Writes an unsigned integer in little-endian order.
template<class T, std::size_t N>
void field (const std::array< T, N > &value)
 Writes each array element in order, without a length prefix.
template<class... Ts>
void field (const std::variant< Ts... > &value)
 Writes a variant's alternative index and active value.
template<class T>
void field (const std::unique_ptr< T > &value)
 Writes a boxed value without pointer or presence bytes.
template<class T>
requires requires(const T& v, writer& s) { v.serialize(s); }
void field (const T &value)
 Invokes a custom type's serialize method through a const reference.
template<class... Ts>
void operator() (const Ts &... values)
 Writes fields from left to right using the matching field overloads.

Public Attributes

bytes data
 Serialized output in field order.

Static Public Attributes

static constexpr bool reading = false
 Selects the writing path in serializers.

Detailed Description

Appends deterministic, byte-aligned fields to an owned buffer.

Note
Custom serializers must preserve their input values when writing.

Definition at line 39 of file serialization.ccm.

Member Function Documentation

◆ field() [1/5]

template<class T, std::size_t N>
void auth::writer::field ( const std::array< T, N > & value)
inline

Writes each array element in order, without a length prefix.

Parameters
valueFixed-size array to encode.

Definition at line 60 of file serialization.ccm.

◆ field() [2/5]

template<class T>
void auth::writer::field ( const std::unique_ptr< T > & value)
inline

Writes a boxed value without pointer or presence bytes.

Parameters
valueNon-null owning pointer used for recursive structure.
Exceptions
auth_errorIf the pointer is null. Use a variant for an empty alternative.

Definition at line 81 of file serialization.ccm.

◆ field() [3/5]

template<class... Ts>
void auth::writer::field ( const std::variant< Ts... > & value)
inline

Writes a variant's alternative index and active value.

Parameters
valueVariant to encode; indices use one byte for up to 256 alternatives, otherwise four little-endian bytes.
Exceptions
auth_errorIf the variant is valueless.

Definition at line 70 of file serialization.ccm.

◆ field() [4/5]

template<class T>
requires requires(const T& v, writer& s) { v.serialize(s); }
void auth::writer::field ( const T & value)
inline

Invokes a custom type's serialize method through a const reference.

Parameters
valueValue whose serializer writes its fields to this stream.
Note
A private serializer may grant friendship to writer.

Definition at line 91 of file serialization.ccm.

◆ field() [5/5]

template<std::unsigned_integral T>
void auth::writer::field ( T value)
inline

Writes an unsigned integer in little-endian order.

Parameters
valueInteger encoded in sizeof(T) bytes, or a bool encoded as one byte, 0 or 1.

Definition at line 47 of file serialization.ccm.

◆ operator()()

template<class... Ts>
void auth::writer::operator() ( const Ts &... values)
inline

Writes fields from left to right using the matching field overloads.

Parameters
valuesFields to encode.

Definition at line 97 of file serialization.ccm.


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