Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions include/rfl/boost_serialization/Parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,34 +57,6 @@ struct Parser<boost_serialization::Reader<IArchive>,
/*_all_required=*/true, ProcessorsType,
std::tuple<Ts...>> {};

template <class IArchive, class OArchive, class ProcessorsType>
requires AreReaderAndWriter<boost_serialization::Reader<IArchive>,
boost_serialization::Writer<OArchive>, Generic>
struct Parser<boost_serialization::Reader<IArchive>,
boost_serialization::Writer<OArchive>, Generic, ProcessorsType> {
template <class T>
static Result<Generic> read(const boost_serialization::Reader<IArchive>&,
const T&) noexcept {
static_assert(always_false_v<T>,
"Generics are unsupported in Boost.Serialization.");
return error("Unsupported");
}

template <class P>
static void write(const boost_serialization::Writer<OArchive>&,
const Generic&, const P&) noexcept {
static_assert(always_false_v<P>,
"Generics are unsupported in Boost.Serialization.");
}

template <class T>
static schema::Type to_schema(T*) {
static_assert(always_false_v<T>,
"Generics are unsupported in Boost.Serialization.");
return schema::Type{};
}
};

template <class IArchive, class OArchive, class T, bool _skip_serialization,
bool _skip_deserialization, class ProcessorsType>
requires AreReaderAndWriter<
Expand Down
151 changes: 114 additions & 37 deletions include/rfl/boost_serialization/Writer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,28 @@ class Writer {
using OutputUnionType = BoostOutputUnion;
using OutputVarType = BoostOutputVar;

Writer(OArchive* _ar);
Writer(OArchive* _ar) : ar_(_ar) {}

~Writer() = default;

OutputArrayType array_as_root(const size_t _size) const;
OutputArrayType array_as_root(const size_t _size) const {
write_size(_size);
return OutputArrayType{};
}

OutputMapType map_as_root(const size_t _size) const;
OutputMapType map_as_root(const size_t _size) const {
write_size(_size);
return OutputMapType{};
}

OutputObjectType object_as_root(const size_t _size) const;
OutputObjectType object_as_root(const size_t _size) const {
write_size(_size);
return OutputObjectType{};
}

OutputVarType null_as_root() const;
OutputVarType null_as_root() const { return OutputVarType{}; }

OutputUnionType union_as_root() const;
OutputUnionType union_as_root() const { return OutputUnionType{}; }

template <class T>
OutputVarType value_as_root(const T& _var) const {
Expand All @@ -51,57 +60,109 @@ class Writer {
}

OutputArrayType add_array_to_array(const size_t _size,
OutputArrayType* _parent) const;
OutputArrayType* /*_parent*/) const {
write_size(_size);
return OutputArrayType{};
}

OutputArrayType add_array_to_map(const std::string_view& _name,
const size_t _size,
OutputMapType* _parent) const;
OutputMapType* /*_parent*/) const {
write_key(_name);
write_size(_size);
return OutputArrayType{};
}

OutputArrayType add_array_to_object(const std::string_view& _name,
OutputArrayType add_array_to_object(const std::string_view& /*_name*/,
const size_t _size,
OutputObjectType* _parent) const;
OutputObjectType* /*_parent*/) const {
write_size(_size);
return OutputArrayType{};
}

OutputArrayType add_array_to_union(const size_t _index, const size_t _size,
OutputUnionType* _parent) const;
OutputUnionType* /*_parent*/) const {
write_index(_index);
write_size(_size);
return OutputArrayType{};
}

OutputMapType add_map_to_array(const size_t _size,
OutputArrayType* _parent) const;
OutputArrayType* /*_parent*/) const {
write_size(_size);
return OutputMapType{};
}

OutputMapType add_map_to_map(const std::string_view& _name,
const size_t _size,
OutputMapType* _parent) const;
OutputMapType* /*_parent*/) const {
write_key(_name);
write_size(_size);
return OutputMapType{};
}

OutputMapType add_map_to_object(const std::string_view& _name,
OutputMapType add_map_to_object(const std::string_view& /*_name*/,
const size_t _size,
OutputObjectType* _parent) const;
OutputObjectType* /*_parent*/) const {
write_size(_size);
return OutputMapType{};
}

OutputMapType add_map_to_union(const size_t _index, const size_t _size,
OutputUnionType* _parent) const;
OutputUnionType* /*_parent*/) const {
write_index(_index);
write_size(_size);
return OutputMapType{};
}

OutputObjectType add_object_to_array(const size_t _size,
OutputArrayType* _parent) const;
OutputArrayType* /*_parent*/) const {
write_size(_size);
return OutputObjectType{};
}

OutputObjectType add_object_to_map(const std::string_view& _name,
const size_t _size,
OutputMapType* _parent) const;
OutputMapType* /*_parent*/) const {
write_key(_name);
write_size(_size);
return OutputObjectType{};
}

OutputObjectType add_object_to_object(const std::string_view& _name,
OutputObjectType add_object_to_object(const std::string_view& /*_name*/,
const size_t _size,
OutputObjectType* _parent) const;
OutputObjectType* /*_parent*/) const {
write_size(_size);
return OutputObjectType{};
}

OutputObjectType add_object_to_union(const size_t _index, const size_t _size,
OutputUnionType* _parent) const;
OutputUnionType* /*_parent*/) const {
write_index(_index);
write_size(_size);
return OutputObjectType{};
}

OutputUnionType add_union_to_array(OutputArrayType* _parent) const;
OutputUnionType add_union_to_array(OutputArrayType* /*_parent*/) const {
return OutputUnionType{};
}

OutputUnionType add_union_to_map(const std::string_view& _name,
OutputMapType* _parent) const;
OutputMapType* /*_parent*/) const {
write_key(_name);
return OutputUnionType{};
}

OutputUnionType add_union_to_object(const std::string_view& _name,
OutputObjectType* _parent) const;
OutputUnionType add_union_to_object(const std::string_view& /*_name*/,
OutputObjectType* /*_parent*/) const {
return OutputUnionType{};
}

OutputUnionType add_union_to_union(const size_t _index,
OutputUnionType* _parent) const;
OutputUnionType* /*_parent*/) const {
write_index(_index);
return OutputUnionType{};
}

template <class T>
OutputVarType add_value_to_array(const T& _var,
Expand Down Expand Up @@ -134,29 +195,45 @@ class Writer {
return OutputVarType{};
}

OutputVarType add_null_to_array(OutputArrayType* _parent) const;
OutputVarType add_null_to_array(OutputArrayType* /*_parent*/) const {
return OutputVarType{};
}

OutputVarType add_null_to_map(const std::string_view& _name,
OutputMapType* _parent) const;
OutputMapType* /*_parent*/) const {
write_key(_name);
return OutputVarType{};
}

OutputVarType add_null_to_object(const std::string_view& _name,
OutputObjectType* _parent) const;
OutputVarType add_null_to_object(const std::string_view& /*_name*/,
OutputObjectType* /*_parent*/) const {
return OutputVarType{};
}

OutputVarType add_null_to_union(const size_t _index,
OutputUnionType* _parent) const;
OutputUnionType* /*_parent*/) const {
write_index(_index);
return OutputVarType{};
}

void end_array(OutputArrayType* _arr) const;
void end_array(OutputArrayType* /*_arr*/) const {}

void end_map(OutputMapType* _obj) const;
void end_map(OutputMapType* /*_obj*/) const {}

void end_object(OutputObjectType* _obj) const;
void end_object(OutputObjectType* /*_obj*/) const {}

private:
void write_size(const size_t _size) const;
void write_size(const size_t _size) const {
*ar_ << static_cast<std::uint64_t>(_size);
}

void write_index(const size_t _index) const;
void write_index(const size_t _index) const {
*ar_ << static_cast<std::uint64_t>(_index);
}

void write_key(const std::string_view& _name) const;
void write_key(const std::string_view& _name) const {
*ar_ << std::string(_name);
}

template <class T>
void new_value(const T& _var) const {
Expand Down
3 changes: 2 additions & 1 deletion mkdocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ site_url: https://rfl.getml.com/
site_author: Code17 GmbH
site_description: >-
A C++20 library for fast serialization, deserialization and validation using reflection.
Supports JSON, AVRO, BSON, Cap'n Proto, CBOR, Cereal, CSV, flexbuffers, msgpack, parquet, TOML, UBJSON, XML, YAML
Supports JSON, AVRO, BSON, Boost Serialization, Cap'n Proto, CBOR, Cereal, CSV, flexbuffers, msgpack, parquet, TOML, UBJSON, XML, YAML

theme:
name: "material"
Expand Down Expand Up @@ -93,6 +93,7 @@ nav:
# # - Errors handling: concepts/errors.md
- Supported Formats:
- Avro: supported_formats/avro.md
- Boost Serialization: supported_formats/boost_serialization.md
- BSON: supported_formats/bson.md
- Cap'n Proto: supported_formats/capnproto.md
- CBOR: supported_formats/cbor.md
Expand Down
Loading
Loading