compat.reflectcpp
Compile-time reflection and serialization for C++ structs (core + JSON)
mcpp add compat.reflectcpp@0.25.0
用法
來自本倉庫自己的測試專案 —— CI 真的編譯並執行過,不是為了網站寫的。
// Behavioral test: struct -> JSON -> struct, through the JSON backend.
//
// The package compiles two umbrella TUs plus the vendored yyjson. All three have
// to be present and agree: leave out src/yyjson.c and this fails to LINK; get the
// include roots wrong and rfl/json/save.hpp picks a different yyjson than the one
// compiled, which fails at runtime rather than at build time. So the assertions
// go all the way to parsed values.
#include <rfl.hpp>
#include <rfl/json.hpp>
#include <cassert>
#include <optional>
#include <string>
#include <vector>
struct Point {
int x;
int y;
};
struct Document {
std::string name;
// …
tests/examples/reflectcpp/tests/json_roundtrip.cpp · 專案 tests/examples/reflectcpp
建置
- targets
reflectcpp (lib)- language
c++23- C standard
c11- import std
- no
- include dirs
*/include, */include/rfl/thirdparty
原始檔 (3)
*/src/reflectcpp.cpp*/src/reflectcpp_json.cpp*/src/yyjson.c