Added support for Cap'n Proto (#323)

This commit is contained in:
Dr. Patrick Urbanke (劉自成)
2025-01-06 15:12:40 +01:00
committed by GitHub
parent 6b63b41b81
commit 1d58526869
111 changed files with 4035 additions and 171 deletions
+35
View File
@@ -0,0 +1,35 @@
#include <array>
#include <iostream>
#include <memory>
#include <rfl/capnproto.hpp>
#include <string>
// Make sure things still compile when
// rfl.hpp is included after rfl/capnproto.hpp.
#include <rfl.hpp>
#include "write_and_read.hpp"
namespace test_array {
struct Person {
rfl::Rename<"firstName", std::string> first_name;
rfl::Rename<"lastName", std::string> last_name = "Simpson";
std::unique_ptr<std::array<Person, 3>> children = nullptr;
};
TEST(capnproto, test_array) {
auto bart = Person{.first_name = "Bart"};
auto lisa = Person{.first_name = "Lisa"};
auto maggie = Person{.first_name = "Maggie"};
const auto homer = Person{
.first_name = "Homer",
.children = std::make_unique<std::array<Person, 3>>(std::array<Person, 3>{
std::move(bart), std::move(lisa), std::move(maggie)})};
write_and_read(homer);
}
} // namespace test_array