Template Function liberate::serialization::serialize_int

Function Documentation

template<typename outT, typename inT, std::enable_if_t<liberate::types::is_8bit_type<outT>::value, int> = 0>
constexpr integer_serialization_enabled<inT> liberate::serialization::serialize_int(outT *output, std::size_t output_length, inT const &value)

Serialize to buffer.

The buffer is defined by a pointer and a size. The input is an integer value for which serialize_int is explicitly enabled (see above).

If the buffer is too small, zero is returned. Otherwise, the number of units written to the buffer is.

Note: the function is restricted to 8-bit output buffer types only, though the detail implementation works for other values. The reason is that for actual cross-platform value serialization, only 8-bit buffers matter.

See also deserialize_int

  • outT The output type, which can be any 8-bit integer type.

  • inT The input type, which can be any of the types enabled by integer_serialization_enabled.

Parameters
  • output[out] The output buffer to serialize to.

  • output_length[in] The size of the output buffer.

  • value[in] The value to serialize.

Returns

The number of bytes of output buffer consumed, or 0 on errors.