-
Notifications
You must be signed in to change notification settings - Fork 0
API muesli format binary_format
Defined in header <muesli/format/binary_format>
concept StreamPushConcept for streams that support push operations for move-only types
concept StreamPeekPopConcept for streams that support peek and pop operations for move-only types
concept OutputStreamConcept 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.
concept InputStreamConcept 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.
template<C, ByteT>
struct binary_formatBinary serialisation format for encoding/decoding codec values
| Parameter | Description |
|---|---|
C |
The codec to use for encoding/decoding |
ByteT |
The byte type for the binary representation (default: std::byte) |
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 requiresParameters:
-
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
template<InputStream<value_type> ValueStream, OutputStream<ByteT> ByteStream> constexpr std::size_t serialize(ValueStream& input, ByteStream& output, std::size_t count) constSerialises multiple values from an input stream to a byte output stream
-
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
template<InputStream<ByteT> ByteStream, OutputStream<value_type> ValueStream> constexpr std::size_t deserialize(ByteStream& input, ValueStream& output, std::size_t count) constDeserialises multiple values from a byte input stream to an output stream
-
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
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.