okser namespace
Namespaces
Classes
-
template<Input In>struct input_context
-
template<Output Out>struct output_context
- struct parse_error
- struct configuration
-
template<class T, configuration Config>struct default_serializers
-
template<std::unsigned_integral T, configuration Config>struct default_serializers<T, Config>
-
template<Serializer S, typename V>struct serializable_value
-
template<class... Types>class bundle
- struct sint
Enums
- enum class error_type: uint8_t { not_enough_bytes, io_error, redundant_mismatch }
- enum class end { le, be }
Typedefs
-
template<class T>using result = std::expected<T, parse_
error> -
template<end Endianness = end::be>using doublep = (Bytes==4||Bytes==8) struct floatp floatp<8, Endianness>
Functions
-
template<class Bundle, Output Out, typename... Values>void serialize(Out&& output, Values... values) constexpr
-
template<Deserializer Type, typename Value = typename Type::DefaultType, class In>auto deserialize(In&& input) -> result<Value> constexpr
-
template<Deserializer... Types, class... Values, std::derived_from<std::tuple<Values...>> Tuple = std::tuple<Values...>, class In>requires(sizeof...Values = =sizeof...(Types) && sizeof...(Types), 1)
-
template<Serializer... Types, typename... Values>auto simple_serialize(Values... values) -> std::string
-
template<class T, Output Out, auto config = internal::empty{}>void serialize_struct(Out&& output, const T& object) constexpr
-
template<class T, auto config = internal::empty{}>auto serialize_struct_to_string(const T& object) -> std::string constexpr
-
template<class T, class In, auto config = internal::empty{}>auto deserialize_struct(In&& input) -> T constexpr
-
template<class T, int N>requires(N>= 1) class redundant
Variables
-
template<typename T>concept Output
-
template<typename T>concept Input
-
template<typename T>concept Serializer
-
template<typename T>concept Deserializer
-
template<typename T>concept InputContext
-
template<typename T>concept OutputContext
Enum documentation
enum class okser:: error_type: uint8_t
#include <ok-serializer/errors.h>
enum class okser:: end
#include <ok-serializer/types_simple.h>
Enum to represent endianness
However, the user can specify the endianness of the serialized data at compile-time. Big endianness is used conventionally by default.
Enumerators | |
---|---|
le |
Little endian. |
be |
Big endian. |
Typedef documentation
#include <ok-serializer/errors.h>
template<class T>
using okser:: result = std::expected<T, parse_ error>
#include <ok-serializer/types_simple.h>
template<end Endianness = end::be>
using okser:: doublep = (Bytes==4||Bytes==8) struct floatp floatp<8, Endianness>
Template parameters | |
---|---|
Endianness | Shortcut to a double-precision floating point number |
IEEE 754 floating point number
Function documentation
#include <ok-serializer/ok-serializer.hpp>
template<class Bundle, Output Out, typename... Values>
void okser:: serialize(Out&& output,
Values... values) constexpr
Template parameters | |
---|---|
Bundle | The bundle containing each element of the serialized structure. |
Out | |
Values | The types of the values to serialize. These do not need to match the Bundle. |
Parameters | |
output | The output to append to at runtime. |
values | The values to serialize. This needs to match the number and order of Values . |
Take some values
, serialize them using a bundle
, and append them to an output
Example
using bundle = okser::bundle<okser::sint<1>, okser::uint<2>>; okser::serialize<bundle>(output, 100, 50000);
#include <ok-serializer/ok-serializer.hpp>
template<Deserializer Type, typename Value = typename Type::DefaultType, class In>
result<Value> okser:: deserialize(In&& input) constexpr
Shortcut to okser::
Example
okser::serialize<okser::sint<1>, okser::uint<2>>(output, 100, 50000);
#include <ok-serializer/ok-serializer.hpp>
template<Deserializer... Types, class... Values, std::derived_from<std::tuple<Values...>> Tuple = std::tuple<Values...>, class In>
okser:: requires(sizeof...Values = =sizeof...(Types) && sizeof...(Types),
1)
#include <ok-serializer/ok-serializer.hpp>
template<Serializer... Types, typename... Values>
std::string okser:: simple_serialize(Values... values)
Shortcut to okser::
Example
std::string out = okser::simple_serialize< okser::sint<1>, okser::uint<2> >(-5, 15);
#include <ok-serializer/reflection.h>
template<class T, Output Out, auto config = internal::empty{}>
void okser:: serialize_struct(Out&& output,
const T& object) constexpr
#include <ok-serializer/reflection.h>
template<class T, auto config = internal::empty{}>
std::string okser:: serialize_struct_to_string(const T& object) constexpr
#include <ok-serializer/reflection.h>
template<class T, class In, auto config = internal::empty{}>
T okser:: deserialize_struct(In&& input) constexpr
#include <ok-serializer/types_compound.h>
template<class T, int N>
okser:: requires(N>= 1) class redundant
Variable documentation
#include <ok-serializer/concepts.h>
template<typename T>
concept okser:: Output
A concept to check if a class can be used as an okser output.
#include <ok-serializer/concepts.h>
template<typename T>
concept okser:: Input
A concept to check if a class can be used as an okser input.
#include <ok-serializer/concepts.h>
template<typename T>
concept okser:: Serializer
A concept to check if a class can be used as an okser serializer and serialise values to binaries.
By default, every child of the okser::
template<> constexpr inline bool is_serializer<MySerializer> = true;
#include <ok-serializer/concepts.h>
template<typename T>
concept okser:: Deserializer
A concept to check if a class can be used as an okser deserializer, and deserialise values from binaries.
#include <ok-serializer/concepts.h>
template<typename T>
concept okser:: InputContext
A concept to check if a class can be used as an okser input context.
An input context needs to contain at least an okser::
#include <ok-serializer/concepts.h>
template<typename T>
concept okser:: OutputContext
A concept to check if a class can be used as an okser output context.
An output context needs to contain at least an okser::