2024-06-05 19:04:53 -04:00
|
|
|
#ifndef RFL_CBOR_PARSER_HPP_
|
|
|
|
#define RFL_CBOR_PARSER_HPP_
|
|
|
|
|
|
|
|
#include "../parsing/Parser.hpp"
|
|
|
|
#include "Reader.hpp"
|
|
|
|
#include "Writer.hpp"
|
|
|
|
|
|
|
|
namespace rfl {
|
2024-06-08 14:10:59 -04:00
|
|
|
namespace parsing {
|
|
|
|
|
|
|
|
/// CBOR requires us to explicitly set the number of fields in advance.
|
|
|
|
/// Because of that, we require all of the fields and then set them to
|
|
|
|
/// nullptr, if necessary.
|
|
|
|
template <class ProcessorsType, class... FieldTypes>
|
2024-06-16 00:13:15 -04:00
|
|
|
requires AreReaderAndWriter<cbor::Reader, cbor::Writer, NamedTuple<FieldTypes...>>
|
|
|
|
struct Parser<cbor::Reader, cbor::Writer, NamedTuple<FieldTypes...>, ProcessorsType>
|
|
|
|
: public NamedTupleParser<
|
2024-06-08 15:53:06 -04:00
|
|
|
cbor::Reader,
|
|
|
|
cbor::Writer,
|
2024-06-16 00:13:15 -04:00
|
|
|
/*_ignore_empty_containers=*/false,
|
|
|
|
/*_all_required=*/true,
|
|
|
|
ProcessorsType,
|
|
|
|
FieldTypes...> {};
|
2024-06-08 14:10:59 -04:00
|
|
|
|
|
|
|
template <class ProcessorsType, class... Ts>
|
|
|
|
requires AreReaderAndWriter<cbor::Reader, cbor::Writer, std::tuple<Ts...>>
|
|
|
|
struct Parser<cbor::Reader, cbor::Writer, std::tuple<Ts...>, ProcessorsType>
|
2024-06-16 00:13:15 -04:00
|
|
|
: public TupleParser<
|
|
|
|
cbor::Reader,
|
|
|
|
cbor::Writer,
|
|
|
|
/*_ignore_empty_containers=*/false,
|
|
|
|
/*_all_required=*/true,
|
|
|
|
ProcessorsType,
|
|
|
|
Ts...> {};
|
2024-06-08 14:10:59 -04:00
|
|
|
|
|
|
|
} // namespace parsing
|
|
|
|
} // namespace rfl
|
2024-06-05 19:04:53 -04:00
|
|
|
|
|
|
|
namespace rfl {
|
2024-06-08 14:10:59 -04:00
|
|
|
namespace cbor {
|
2024-06-05 19:04:53 -04:00
|
|
|
|
2024-06-08 14:10:59 -04:00
|
|
|
template <class T, class ProcessorsType>
|
|
|
|
using Parser = parsing::Parser<Reader, Writer, T, ProcessorsType>;
|
2024-06-05 19:04:53 -04:00
|
|
|
|
2024-06-08 14:10:59 -04:00
|
|
|
}
|
|
|
|
} // namespace rfl
|
2024-06-05 19:04:53 -04:00
|
|
|
|
|
|
|
#endif
|