Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Cap'n Proto #323

Merged
merged 62 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
5433262
Basic setup for Cap'n Proto
liuzicheng1987 Dec 22, 2024
23c76ff
Made sure the schema compiles
liuzicheng1987 Dec 22, 2024
c22abd0
Made sure that the schema compiles
liuzicheng1987 Dec 22, 2024
c8f9684
Merge branch 'main' into f/capnproto
liuzicheng1987 Dec 22, 2024
fd3b991
Set up the reader
liuzicheng1987 Dec 22, 2024
da8db50
Merge branch 'main' into f/capnproto
liuzicheng1987 Dec 22, 2024
c8afdf6
Added very rudimentary first draft of the Writer
liuzicheng1987 Dec 23, 2024
7c1b288
Started writing capnproto::write
liuzicheng1987 Dec 24, 2024
0376a31
rfl::capnproto::write(...) works in principle
liuzicheng1987 Dec 25, 2024
06ed35a
Implemented rfl::capnproto::read
liuzicheng1987 Dec 26, 2024
b7cdc35
Started developing the schema
liuzicheng1987 Dec 26, 2024
5a898af
First draft for the schema generator
liuzicheng1987 Dec 26, 2024
7419533
Added basic schema generation
liuzicheng1987 Dec 26, 2024
3031862
More robust handling of the type names
liuzicheng1987 Dec 26, 2024
9535f0f
Make sure that field names are automatically transformed to camelCase
liuzicheng1987 Dec 26, 2024
886017c
Use a memoization-like pattern to generate the schema
liuzicheng1987 Dec 28, 2024
eddff20
Minor code beautifications
liuzicheng1987 Dec 28, 2024
a396fed
Make sure arrays work as intended
liuzicheng1987 Dec 29, 2024
bb78efd
Started adding union support
liuzicheng1987 Dec 29, 2024
96c1ec8
Added support for optionals
liuzicheng1987 Dec 29, 2024
e5020bf
Filled the gaps in the writer for everything but maps
liuzicheng1987 Dec 29, 2024
c8defbf
Added (basic) support for variants
liuzicheng1987 Dec 29, 2024
840272c
Got rid of ugly warning message
liuzicheng1987 Dec 29, 2024
c7c8ae2
Added support for nested unions
liuzicheng1987 Dec 29, 2024
01e9786
Better name
liuzicheng1987 Dec 29, 2024
ea1e3e6
Make sure that there can be no duplicate field names
liuzicheng1987 Dec 29, 2024
8ed58b7
Make sure that the first letter of the snake case is lowercase
liuzicheng1987 Dec 30, 2024
9efd996
Moved string functions to source files
liuzicheng1987 Dec 30, 2024
7c6f5c8
Added support for standalone-unions
liuzicheng1987 Jan 1, 2025
c9f4452
Merge branch 'main' into f/capnproto
liuzicheng1987 Jan 1, 2025
1654c5d
Added maps as a schema type
liuzicheng1987 Jan 1, 2025
fd224d7
Variant -> Union
liuzicheng1987 Jan 1, 2025
163aafa
Implemented the writer functions for the map
liuzicheng1987 Jan 1, 2025
90676db
Made sure the tests for the maps run through
liuzicheng1987 Jan 1, 2025
f4aebd1
Make sure we support tuples
liuzicheng1987 Jan 2, 2025
2109008
Added benchmarks
liuzicheng1987 Jan 2, 2025
7a047e7
Bugfix processed_t
liuzicheng1987 Jan 3, 2025
b9e2672
Use unique_ptr in the tests, where appropriate
liuzicheng1987 Jan 3, 2025
6e14f2b
Added more tests for Cap'n Proto
liuzicheng1987 Jan 3, 2025
a398637
Merge branch 'main' into f/capnproto
liuzicheng1987 Jan 4, 2025
bebbd80
Removed noexcept
liuzicheng1987 Jan 4, 2025
9ceb5b5
Minor bugfixes
liuzicheng1987 Jan 4, 2025
541a2f2
Made sure custom classes work
liuzicheng1987 Jan 4, 2025
8e44af2
Added test for test_size
liuzicheng1987 Jan 4, 2025
b842e40
Made sure the last test passes
liuzicheng1987 Jan 4, 2025
b3b64d3
Added missing include
liuzicheng1987 Jan 4, 2025
66659b7
Added save_load
liuzicheng1987 Jan 4, 2025
c32523b
Make sure the avro schema is only generated once
liuzicheng1987 Jan 4, 2025
fb8cb60
Merge branch 'f/avro_schema_generation' into f/capnproto
liuzicheng1987 Jan 4, 2025
d6b3e9c
Revert "Make sure the avro schema is only generated once"
liuzicheng1987 Jan 4, 2025
ce6baa8
Added support for enums
liuzicheng1987 Jan 4, 2025
8d0a366
Make sure enums are properly supported too
liuzicheng1987 Jan 5, 2025
dc12e36
Added Cap'n Proto to the Github Action pipelines
liuzicheng1987 Jan 5, 2025
80b91c8
Added support for bytestrings
liuzicheng1987 Jan 6, 2025
c0ac3ce
Don't use local bindings
liuzicheng1987 Jan 6, 2025
da61174
Don't pass by reference
liuzicheng1987 Jan 6, 2025
f05323f
Don't use structured bindings
liuzicheng1987 Jan 6, 2025
13799e7
Added documentation for Cap'n Proto
liuzicheng1987 Jan 6, 2025
b0cc552
Added an explanatory note
liuzicheng1987 Jan 6, 2025
32868da
Added Cap'n Proto to the Conanfile
liuzicheng1987 Jan 6, 2025
83e7a63
Added the option to the test pipelines
liuzicheng1987 Jan 6, 2025
227339b
Do not print the schema
liuzicheng1987 Jan 6, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
pipx install conan
conan profile detect
- name: Make sure the library compiles with Conan
run: conan build . --build=missing -s compiler.cppstd=gnu20 -o *:with_cbor=True -o *:with_flatbuffers=True -o *:with_msgpack=True -o *:with_toml=True -o *:with_ubjson=True -o *:with_xml=True -o *:with_yaml=True
run: conan build . --build=missing -s compiler.cppstd=gnu20 -o *:with_capnproto=True -o *:with_cbor=True -o *:with_flatbuffers=True -o *:with_msgpack=True -o *:with_toml=True -o *:with_ubjson=True -o *:with_xml=True -o *:with_yaml=True
- name: Compile
run: |
if [[ "${{ matrix.compiler }}" == "llvm" ]]; then
Expand All @@ -66,7 +66,7 @@ jobs:
sudo ln -s $(which ccache) /usr/local/bin/$CC
sudo ln -s $(which ccache) /usr/local/bin/$CXX
$CXX --version
cmake -S . -B build -G Ninja -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_BUILD_BENCHMARKS=ON -DREFLECTCPP_BSON=ON -DREFLECTCPP_CBOR=ON -DREFLECTCPP_FLEXBUFFERS=ON -DREFLECTCPP_MSGPACK=ON -DREFLECTCPP_TOML=ON -DREFLECTCPP_XML=ON -DREFLECTCPP_YAML=ON -DCMAKE_BUILD_TYPE=Release
cmake -S . -B build -G Ninja -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_BUILD_BENCHMARKS=ON -DREFLECTCPP_BSON=ON -DREFLECTCPP_CAPNPROTO=ON -DREFLECTCPP_CBOR=ON -DREFLECTCPP_FLEXBUFFERS=ON -DREFLECTCPP_MSGPACK=ON -DREFLECTCPP_TOML=ON -DREFLECTCPP_XML=ON -DREFLECTCPP_YAML=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build
- name: Run tests
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/macos-clang.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
env:
CC: clang
CXX: clang++
run: conan build . --build=missing -s compiler.cppstd=gnu20 -o *:with_cbor=True -o *:with_flatbuffers=True -o *:with_msgpack=True -o *:with_toml=True -o *:with_ubjson=True -o *:with_xml=True -o *:with_yaml=True
run: conan build . --build=missing -s compiler.cppstd=gnu20 -o *:with_capnproto=True -o *:with_cbor=True -o *:with_flatbuffers=True -o *:with_msgpack=True -o *:with_toml=True -o *:with_ubjson=True -o *:with_xml=True -o *:with_yaml=True
- name: Compile
env:
CC: clang
Expand All @@ -55,7 +55,7 @@ jobs:
export CMAKE_GENERATOR=Ninja
fi
$CXX --version
cmake -S . -B build -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_BUILD_BENCHMARKS=ON -DREFLECTCPP_BSON=ON -DREFLECTCPP_CBOR=ON -DREFLECTCPP_FLEXBUFFERS=ON -DREFLECTCPP_MSGPACK=ON -DREFLECTCPP_TOML=ON -DREFLECTCPP_XML=ON -DREFLECTCPP_YAML=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
cmake -S . -B build -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_BUILD_BENCHMARKS=ON -DREFLECTCPP_BSON=ON -DREFLECTCPP_CAPNPROTO=ON -DREFLECTCPP_CBOR=ON -DREFLECTCPP_FLEXBUFFERS=ON -DREFLECTCPP_MSGPACK=ON -DREFLECTCPP_TOML=ON -DREFLECTCPP_XML=ON -DREFLECTCPP_YAML=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
cmake --build build -j 4
- name: Run tests
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-msvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- uses: lukka/run-vcpkg@v11
- name: Compile
run: |
cmake -S . -B build -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_BUILD_BENCHMARKS=ON -DREFLECTCPP_BSON=ON -DREFLECTCPP_CBOR=ON -DREFLECTCPP_FLEXBUFFERS=ON -DREFLECTCPP_MSGPACK=ON -DREFLECTCPP_XML=ON -DREFLECTCPP_TOML=ON -DREFLECTCPP_YAML=ON -DCMAKE_BUILD_TYPE=Release
cmake -S . -B build -DREFLECTCPP_BUILD_TESTS=ON -DREFLECTCPP_BUILD_BENCHMARKS=ON -DREFLECTCPP_BSON=ON -DREFLECTCPP_CAPNPROTO=ON -DREFLECTCPP_CBOR=ON -DREFLECTCPP_FLEXBUFFERS=ON -DREFLECTCPP_MSGPACK=ON -DREFLECTCPP_XML=ON -DREFLECTCPP_TOML=ON -DREFLECTCPP_YAML=ON -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release -j4
- name: Run tests
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
# Output files
*.avro
*.bson
*.capnproto
*.cbor
*.json
*.fb
Expand Down
15 changes: 14 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ option(REFLECTCPP_BUILD_SHARED "Build shared library" ${BUILD_SHARED_LIBS})
option(REFLECTCPP_JSON "Enable JSON support" ON) # enabled by default
option(REFLECTCPP_AVRO "Enable AVRO support" OFF)
option(REFLECTCPP_BSON "Enable BSON support" OFF)
option(REFLECTCPP_CAPNPROTO "Enable Cap’n Proto support" OFF)
option(REFLECTCPP_CBOR "Enable CBOR support" OFF)
option(REFLECTCPP_FLEXBUFFERS "Enable flexbuffers support" OFF)
option(REFLECTCPP_MSGPACK "Enable msgpack support" OFF)
Expand All @@ -24,6 +25,7 @@ if(REFLECTCPP_BUILD_BENCHMARKS)
set(REFLECTCPP_JSON ON CACHE BOOL "" FORCE)
set(REFLECTCPP_AVRO ON CACHE BOOL "" FORCE)
set(REFLECTCPP_BSON ON CACHE BOOL "" FORCE)
set(REFLECTCPP_CAPNPROTO ON CACHE BOOL "" FORCE)
set(REFLECTCPP_CBOR ON CACHE BOOL "" FORCE)
set(REFLECTCPP_FLEXBUFFERS ON CACHE BOOL "" FORCE)
set(REFLECTCPP_MSGPACK ON CACHE BOOL "" FORCE)
Expand All @@ -35,7 +37,8 @@ endif()

if (REFLECTCPP_BUILD_TESTS OR REFLECTCPP_BUILD_BENCHMARKS OR
(REFLECTCPP_JSON AND NOT REFLECTCPP_USE_BUNDLED_DEPENDENCIES) OR REFLECTCPP_AVRO OR
REFLECTCPP_BSON OR REFLECTCPP_CBOR OR REFLECTCPP_FLEXBUFFERS OR REFLECTCPP_MSGPACK OR REFLECTCPP_XML OR REFLECTCPP_TOML OR REFLECTCPP_UBJSON OR REFLECTCPP_YAML)
REFLECTCPP_BSON OR REFLECTCPP_CAPNPROTO OR REFLECTCPP_CBOR OR REFLECTCPP_FLEXBUFFERS OR
REFLECTCPP_MSGPACK OR REFLECTCPP_XML OR REFLECTCPP_TOML OR REFLECTCPP_UBJSON OR REFLECTCPP_YAML)
# enable vcpkg per default if require features other than JSON
set(REFLECTCPP_USE_VCPKG_DEFAULT ON)
endif()
Expand Down Expand Up @@ -130,6 +133,16 @@ if (REFLECTCPP_BSON)
target_link_libraries(reflectcpp PUBLIC $<IF:$<TARGET_EXISTS:mongo::bson_static>,mongo::bson_static,mongo::bson_shared>)
endif ()

if (REFLECTCPP_CAPNPROTO)
list(APPEND REFLECT_CPP_SOURCES
src/reflectcpp_capnproto.cpp
)
if (NOT TARGET CapnProto)
find_package(CapnProto CONFIG REQUIRED)
endif ()
target_link_libraries(reflectcpp PUBLIC CapnProto::kj CapnProto::capnp CapnProto::capnpc CapnProto::kj-gzip)
endif ()

if (REFLECTCPP_CBOR)
list(APPEND REFLECT_CPP_SOURCES
src/reflectcpp_cbor.cpp
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ The following table lists the serialization formats currently supported by refle
| JSON | [yyjson](https://github.com/ibireme/yyjson) | >= 0.8.0 | MIT | out-of-the-box support, included in this repository |
| Avro | [avro-c](https://avro.apache.org/docs/1.11.1/api/c/) | >= 1.11.3 | Apache 2.0 | Schemaful binary format |
| BSON | [libbson](https://github.com/mongodb/mongo-c-driver) | >= 1.25.1 | Apache 2.0 | JSON-like binary format |
| Cap'n Proto | [capnproto](https://capnproto.org) | >= 1.0.2 | MIT | Schemaful binary format |
| CBOR | [tinycbor](https://github.com/intel/tinycbor) | >= 0.6.0 | MIT | JSON-like binary format |
| flexbuffers | [flatbuffers](https://github.com/google/flatbuffers) | >= 23.5.26 | Apache 2.0 | Schema-less version of flatbuffers, binary format |
| msgpack | [msgpack-c](https://github.com/msgpack/msgpack-c) | >= 6.0.0 | BSL 1.0 | JSON-like binary format |
Expand Down Expand Up @@ -512,7 +513,7 @@ In addition, it supports the following custom containers:

- `rfl::Binary`: Used to express numbers in binary format.
- `rfl::Box`: Similar to `std::unique_ptr`, but (almost) guaranteed to never be null.
- `rfl::Bytestring`: An alias for `std::basic_string<std::byte>`. Supported by BSON, CBOR, flexbuffers, msgpack and UBJSON.
- `rfl::Bytestring`: An alias for `std::basic_string<std::byte>`. Supported by Avro, BSON, Cap'n Proto, CBOR, flexbuffers, msgpack and UBJSON.
- `rfl::Generic`: A catch-all type that can represent (almost) anything.
- `rfl::Hex`: Used to express numbers in hex format.
- `rfl::Literal`: An explicitly enumerated string.
Expand Down
13 changes: 13 additions & 0 deletions benchmarks/all/canada_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <optional>
#include <rfl/avro.hpp>
#include <rfl/bson.hpp>
#include <rfl/capnproto.hpp>
#include <rfl/cbor.hpp>
#include <rfl/flexbuf.hpp>
#include <rfl/json.hpp>
Expand Down Expand Up @@ -71,6 +72,18 @@ static void BM_canada_read_reflect_cpp_bson(benchmark::State &state) {
}
BENCHMARK(BM_canada_read_reflect_cpp_bson);

static void BM_canada_read_reflect_cpp_capnproto(benchmark::State &state) {
const auto schema = rfl::capnproto::to_schema<FeatureCollection>();
const auto data = rfl::capnproto::write(load_data(), schema);
for (auto _ : state) {
const auto res = rfl::capnproto::read<FeatureCollection>(data, schema);
if (!res) {
std::cout << res.error()->what() << std::endl;
}
}
}
BENCHMARK(BM_canada_read_reflect_cpp_capnproto);

static void BM_canada_read_reflect_cpp_cbor(benchmark::State &state) {
const auto data = rfl::cbor::write(load_data());
for (auto _ : state) {
Expand Down
13 changes: 13 additions & 0 deletions benchmarks/all/canada_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <optional>
#include <rfl/avro.hpp>
#include <rfl/bson.hpp>
#include <rfl/capnproto.hpp>
#include <rfl/cbor.hpp>
#include <rfl/flexbuf.hpp>
#include <rfl/json.hpp>
Expand Down Expand Up @@ -71,6 +72,18 @@ static void BM_canada_write_reflect_cpp_bson(benchmark::State &state) {
}
BENCHMARK(BM_canada_write_reflect_cpp_bson);

static void BM_canada_write_reflect_cpp_capnproto(benchmark::State &state) {
const auto schema = rfl::capnproto::to_schema<FeatureCollection>();
const auto data = load_data();
for (auto _ : state) {
const auto output = rfl::capnproto::write(data, schema);
if (output.size() == 0) {
std::cout << "No output" << std::endl;
}
}
}
BENCHMARK(BM_canada_write_reflect_cpp_capnproto);

static void BM_canada_write_reflect_cpp_cbor(benchmark::State &state) {
const auto data = load_data();
for (auto _ : state) {
Expand Down
13 changes: 13 additions & 0 deletions benchmarks/all/licenses_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <optional>
#include <rfl/avro.hpp>
#include <rfl/bson.hpp>
#include <rfl/capnproto.hpp>
#include <rfl/cbor.hpp>
#include <rfl/flexbuf.hpp>
#include <rfl/json.hpp>
Expand Down Expand Up @@ -87,6 +88,18 @@ static void BM_licenses_read_reflect_cpp_bson(benchmark::State &state) {
}
BENCHMARK(BM_licenses_read_reflect_cpp_bson);

static void BM_licenses_read_reflect_cpp_capnproto(benchmark::State &state) {
const auto schema = rfl::capnproto::to_schema<Licenses>();
const auto data = rfl::capnproto::write(load_data(), schema);
for (auto _ : state) {
const auto res = rfl::capnproto::read<Licenses>(data, schema);
if (!res) {
std::cout << res.error()->what() << std::endl;
}
}
}
BENCHMARK(BM_licenses_read_reflect_cpp_capnproto);

static void BM_licenses_read_reflect_cpp_cbor(benchmark::State &state) {
const auto data = rfl::cbor::write(load_data());
for (auto _ : state) {
Expand Down
13 changes: 13 additions & 0 deletions benchmarks/all/licenses_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <optional>
#include <rfl/avro.hpp>
#include <rfl/bson.hpp>
#include <rfl/capnproto.hpp>
#include <rfl/cbor.hpp>
#include <rfl/flexbuf.hpp>
#include <rfl/json.hpp>
Expand Down Expand Up @@ -87,6 +88,18 @@ static void BM_licenses_write_reflect_cpp_bson(benchmark::State &state) {
}
BENCHMARK(BM_licenses_write_reflect_cpp_bson);

static void BM_licenses_write_reflect_cpp_capnproto(benchmark::State &state) {
const auto schema = rfl::capnproto::to_schema<Licenses>();
const auto data = load_data();
for (auto _ : state) {
const auto output = rfl::capnproto::write(data, schema);
if (output.size() == 0) {
std::cout << "No output" << std::endl;
}
}
}
BENCHMARK(BM_licenses_write_reflect_cpp_capnproto);

static void BM_licenses_write_reflect_cpp_cbor(benchmark::State &state) {
const auto data = load_data();
for (auto _ : state) {
Expand Down
13 changes: 13 additions & 0 deletions benchmarks/all/person_read.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <optional>
#include <rfl/avro.hpp>
#include <rfl/bson.hpp>
#include <rfl/capnproto.hpp>
#include <rfl/cbor.hpp>
#include <rfl/flexbuf.hpp>
#include <rfl/json.hpp>
Expand Down Expand Up @@ -66,6 +67,18 @@ static void BM_person_read_reflect_cpp_bson(benchmark::State &state) {
}
BENCHMARK(BM_person_read_reflect_cpp_bson);

static void BM_person_read_reflect_cpp_capnproto(benchmark::State &state) {
const auto schema = rfl::capnproto::to_schema<Person>();
const auto data = rfl::capnproto::write(load_data(), schema);
for (auto _ : state) {
const auto res = rfl::capnproto::read<Person>(data, schema);
if (!res) {
std::cout << res.error()->what() << std::endl;
}
}
}
BENCHMARK(BM_person_read_reflect_cpp_capnproto);

static void BM_person_read_reflect_cpp_cbor(benchmark::State &state) {
const auto data = rfl::cbor::write(load_data());
for (auto _ : state) {
Expand Down
13 changes: 13 additions & 0 deletions benchmarks/all/person_write.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <optional>
#include <rfl/avro.hpp>
#include <rfl/bson.hpp>
#include <rfl/capnproto.hpp>
#include <rfl/cbor.hpp>
#include <rfl/flexbuf.hpp>
#include <rfl/json.hpp>
Expand Down Expand Up @@ -67,6 +68,18 @@ static void BM_person_write_reflect_cpp_bson(benchmark::State &state) {
}
BENCHMARK(BM_person_write_reflect_cpp_bson);

static void BM_person_write_reflect_cpp_capnproto(benchmark::State &state) {
const auto schema = rfl::capnproto::to_schema<Person>();
const auto data = load_data();
for (auto _ : state) {
const auto output = rfl::capnproto::write(data, schema);
if (output.size() == 0) {
std::cout << "No output" << std::endl;
}
}
}
BENCHMARK(BM_person_write_reflect_cpp_capnproto);

static void BM_person_write_reflect_cpp_cbor(benchmark::State &state) {
const auto data = load_data();
for (auto _ : state) {
Expand Down
6 changes: 6 additions & 0 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ReflectCppConan(ConanFile):
"reflection",
"serialization",
"memory",
"Cap'n Proto",
"cbor",
"flatbuffers",
"json",
Expand All @@ -37,6 +38,7 @@ class ReflectCppConan(ConanFile):
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_capnproto": [True, False],
"with_cbor": [True, False],
"with_flatbuffers": [True, False],
"with_msgpack": [True, False],
Expand All @@ -48,6 +50,7 @@ class ReflectCppConan(ConanFile):
default_options = {
"shared": False,
"fPIC": True,
"with_capnproto": False,
"with_cbor": False,
"with_flatbuffers": False,
"with_msgpack": False,
Expand All @@ -68,6 +71,8 @@ def configure(self):
def requirements(self):
self.requires("ctre/3.9.0", transitive_headers=True)
self.requires("yyjson/0.10.0", transitive_headers=True)
if self.options.with_capnproto:
self.requires("capnproto/1.1.0", transitive_headers=True)
if self.options.with_cbor:
self.requires("tinycbor/0.6.0", transitive_headers=True)
if self.options.with_flatbuffers:
Expand Down Expand Up @@ -105,6 +110,7 @@ def generate(self):
tc.cache_variables["REFLECTCPP_BUILD_SHARED"] = self.options.shared
tc.cache_variables["REFLECTCPP_USE_BUNDLED_DEPENDENCIES"] = False
tc.cache_variables["REFLECTCPP_USE_VCPKG"] = False
tc.cache_variables["REFLECTCPP_CAPNPROTO"] = self.options.with_capnproto
tc.cache_variables["REFLECTCPP_CBOR"] = self.options.with_cbor
tc.cache_variables["REFLECTCPP_FLEXBUFFERS"] = self.options.with_flatbuffers
tc.cache_variables["REFLECTCPP_MSGPACK"] = self.options.with_msgpack
Expand Down
2 changes: 1 addition & 1 deletion docs/supported_formats/avro.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ However, Avro is a schemaful format, so before you serialize or
deserialize, you have to declare a schema. In the two function calls
above, this is abstracted away.

But if you are repeated serializing or deserializing the same struct,
But if you are repeatedly serializing or deserializing the same struct,
it is more efficient to generate the schema explicitly:

```cpp
Expand Down
Loading
Loading