Skip to content

API muesli format binary_format

Felix Jones edited this page Jan 15, 2026 · 1 revision

muesli/format/binary_format

Defined in header <muesli/format/binary_format>

StreamPush

concept StreamPush

Concept for streams that support push operations for move-only types


StreamPeekPop

concept StreamPeekPop

Concept for streams that support peek and pop operations for move-only types


OutputStream

concept OutputStream

Concept for output streams that can write values of type T

Supports streams with operator<<, write(), or sputn() methods. For move-only types, also requires StreamPush support.


InputStream

concept InputStream

Concept for input streams that can read values of type T

Supports streams with operator>>, read(), or sgetn() methods. For move-only types, also requires StreamPeekPop support.


binary_format

template<C, ByteT>
struct binary_format

Binary serialisation format for encoding/decoding codec values

Template Parameters

Parameter Description
C The codec to use for encoding/decoding
ByteT The byte type for the binary representation (default: std::byte)

Member Functions

serialize

Serialises multiple values from an input stream to a byte output stream

template<InputStream<value_type> ValueStream, OutputStream<ByteT> ByteStream> constexpr std::size_t serialize(ValueStream& input, ByteStream& output, std::size_t count) const
template<OutputStream<ByteT> ByteStream> constexpr bool serialize(auto&& value, ByteStream& output) const requires requires

Parameters:

  • input — Stream to read values from
  • output — Byte stream to write encoded data to
  • count — Number of values to serialise
  • value — The value to serialise
  • output — Byte stream to write encoded data to

Returns: Number of values successfully serialised


serialize

template<InputStream<value_type> ValueStream, OutputStream<ByteT> ByteStream> constexpr std::size_t serialize(ValueStream& input, ByteStream& output, std::size_t count) const

Serialises multiple values from an input stream to a byte output stream

Parameters

  • input — Stream to read values from
  • output — Byte stream to write encoded data to
  • count — Number of values to serialise

Returns: Number of values successfully serialised


deserialize

template<InputStream<ByteT> ByteStream, OutputStream<value_type> ValueStream> constexpr std::size_t deserialize(ByteStream& input, ValueStream& output, std::size_t count) const

Deserialises multiple values from a byte input stream to an output stream

Parameters

  • input — Byte stream to read encoded data from
  • output — Stream to write decoded values to
  • count — Number of values to deserialise

Returns: Number of values successfully deserialised


make_binary_format

template<typename C> binary_format(C&&) -> binary_format<std::decay_t<C>>; /** * @brief Helper function to create a binary_format with explicit byte type. * * @tparam ByteT The byte type to use for serialisation (char, std::byte) * @param c The codec to use for encoding/decoding * @return A binary_format configured with the specified codec and byte type */ template<typename ByteT> static constexpr auto make_binary_format(Codec auto&& c)

Deduction guide for binary_format.

Allows construction of binary_format without explicitly specifying template parameters.


Clone this wiki locally