14#define CIRCUS_ENTRY(VAR) std::make_pair(#VAR, VAR)
26template <
typename OStreamT>
27 requires(std::is_base_of_v<std::ostream, OStreamT>)
30 using TK = tokens__::TYPE;
36 template <std::
size_t I, std::
size_t Max, traits::OutStreamableLiteral Arg>
37 void handle_value_type(Arg &&arg) {
48 template <std::
size_t I, std::
size_t Max, traits::Serializable Arg>
49 void handle_value_type(Arg &&arg) {
57 template <std::
size_t I, std::
size_t Max, traits::StreamableVector Arg>
58 void handle_value_type(Arg &&arg) {
60 for (std::size_t i = 0; i < arg.size(); i++) {
62 if (i < arg.size() - 1) {
71 template <std::
size_t I, std::
size_t Max, traits::Container Arg>
72 void handle_value_type(Arg &&arg) {
80 template <std::
size_t I, std::
size_t Max, traits::PairSerializable Arg>
81 void handle_pair(Arg &&arg) {
83 handle_value_type<I - 1, Max>(arg.second);
84 if constexpr (I < Max - 1) {
91 template <std::
size_t I,
typename Arg>
92 constexpr static auto make_pair_serializable(Arg &&arg) {
96 return std::forward<Arg>(arg);
102 template <std::size_t... Is,
typename... Args>
103 void handler(std::index_sequence<Is...>, Args &&...args) {
104 constexpr std::size_t MAXARG =
sizeof...(Args);
105 (handle_pair<Is, MAXARG>(make_pair_serializable<Is>(std::forward<Args>(args))), ...);
115 stream <<
"$root : {";
126 template <
typename... Args>
128 handler(std::index_sequence_for<Args...>{}, std::forward<Args>(args)...);
141 template <
typename... Args>
143 handler(std::index_sequence_for<Args...>{}, std::forward<Args>(args)...);
Provides compile-time traits and C++20 concepts for type introspection used throughout the Circus lib...
A flexible serializer for C++ objects, primitives, STL containers, and user-defined types.
Definition serializer.hpp:28
serializer(OStreamT &s)
Constructs a serializer with the given output stream.
Definition serializer.hpp:114
serializer & operator<<(Args &&...args)
Serializes the given arguments using stream-like syntax.
Definition serializer.hpp:142
void operator()(Args &&...args) &
Serializes the given arguments using function-call syntax.
Definition serializer.hpp:127
Concept for types that behave like key-value pairs.
Definition circus_traits.hpp:100
Concept for types that can be converted to a string-like view.
Definition circus_traits.hpp:105
static constexpr std::string to_literal(TYPE type) noexcept
Convert the token literal to a std::string without surrounding quotes.
Definition token.hpp:100
Converts a compile-time unsigned integer to a string literal.
Definition to_chars.hpp:58
Compile-time conversion of unsigned integers to string literals.