okser::internal namespace

Classes

struct DummyInOut
struct DummyContext
struct empty
class type

Typedefs

template<int Bytes>
using uint_bytes_to_type = std::conditional_t<Bytes<=1, uint8_t, std::conditional_t<Bytes<=2, uint16_t, std::conditional_t<Bytes<=4, uint32_t, std::conditional_t<Bytes<=8, uint64_t, void>>>>

Functions

template<class S>
auto get_configuration_from_struct(const S& input) -> configuration constexpr
template<class Pair, Output Out>
void serialize_one(Pair p, Out&& o) constexpr
template<typename F, std::size_t ... Is>
auto apply(F f, std::index_sequence<Is...>) -> auto constexpr
template<typename T, typename E, typename F>
auto transform(const std::expected<T, E>& e, F&& f) -> auto constexpr
template<class In>
requires(std::derived_from<In, okser::in::range<typename In::ContainedType>>)
template<class In>
requires(std::constructible_from<okser::in::range<In>, In>)

Typedef documentation

template<int Bytes>
using okser::internal::uint_bytes_to_type = std::conditional_t<Bytes<=1, uint8_t, std::conditional_t<Bytes<=2, uint16_t, std::conditional_t<Bytes<=4, uint32_t, std::conditional_t<Bytes<=8, uint64_t, void>>>>

Convert from a number of bytes to the smallest unsigned integer type that can hold that many bytes.

Function documentation

template<class S>
configuration okser::internal::get_configuration_from_struct(const S& input) constexpr

template<class Pair, Output Out>
void okser::internal::serialize_one(Pair p, Out&& o) constexpr

Template parameters
Pair The serializable_value type
Out The output type
Parameters
p The serializable_value
o The output

Append a single serializable_value to an output.

template<typename F, std::size_t ... Is>
auto okser::internal::apply(F f, std::index_sequence<Is...>) constexpr

Template parameters
F The function to apply. The return value of this function will be returned as a tuple. The only argument passed to this function is an std::integral_constant with the index.
Is An index sequence.
Parameters
f The function to apply.
Returns An std::tuple with the elements of each application of f.

Apply a function to all elements of an index sequence. This function is useful for looping over tuples at compile time with an index. The applications would be looping over two tuples at the same time.

template<typename T, typename E, typename F>
auto okser::internal::transform(const std::expected<T, E>& e, F&& f) constexpr

Template parameters
T Type of expected value
E Type of unexpected value
F Type of the function to invoke
Parameters
e The expected value
f The function to invoke on the expected value, if it is valid
Returns The resulting std::expected value. The type T may have been transformed by the function F.

Apply a function f to an expected item e if it has a value.

If e does not have a value, nothing is returned.

This is a polyfill of C++23's std::expected::transform, which may not be implemented on many compilers.

template<class In>
okser::internal::requires(std::derived_from<In, okser::in::range<typename In::ContainedType>>)

template<class In>
okser::internal::requires(std::constructible_from<okser::in::range<In>, In>)