feat(reflect-cpp): Switched from glaze -> reflect cpp
A bug was discovered in glaze which prevented valid toml output. We have switched to toml++ and reflect-cpp. The interface has remained the same so this should not break any code
This commit is contained in:
@@ -1,2 +1,5 @@
|
||||
executable('simple_config_test', 'simple.cpp', dependencies: [config_dep])
|
||||
executable('simple_config_wasm_test', 'wasm.cpp', dependencies: [config_dep])
|
||||
|
||||
if meson.is_cross_build() and host_machine.system() == 'wasm'
|
||||
executable('simple_config_wasm_test', 'wasm.cpp', dependencies: [config_dep])
|
||||
endif
|
||||
|
||||
@@ -1,46 +1,37 @@
|
||||
#include "fourdst/config/config.h"
|
||||
#include "glaze/glaze.hpp"
|
||||
#include "rfl.hpp"
|
||||
#include "rfl/toml.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <print>
|
||||
|
||||
using namespace fourdst::config;
|
||||
#include "fourdst/config/config.h"
|
||||
|
||||
struct sub {
|
||||
struct Other {
|
||||
std::array<int, 3> a{};
|
||||
std::vector<std::string> b{};
|
||||
double c;
|
||||
};
|
||||
|
||||
struct Location {
|
||||
double x;
|
||||
double y;
|
||||
};
|
||||
|
||||
struct BoundaryConditions {
|
||||
double pressure = 1e6;
|
||||
sub sub;
|
||||
};
|
||||
|
||||
struct ExampleConfig {
|
||||
double parameterA = 1.0;
|
||||
int parameterB = 1.0;
|
||||
std::string parameterC = "default_value";
|
||||
std::vector<double> parameterD = {0.1, 0.2, 0.3};
|
||||
BoundaryConditions boundaryConditions;
|
||||
Other other{};
|
||||
};
|
||||
|
||||
struct Person {
|
||||
int age;
|
||||
std::string name;
|
||||
};
|
||||
|
||||
struct AppConfig {
|
||||
double x;
|
||||
double y;
|
||||
Person person;
|
||||
std::string name{};
|
||||
std::string address{};
|
||||
double height{};
|
||||
Location location{};
|
||||
};
|
||||
|
||||
int main() {
|
||||
const Config<ExampleConfig> cfg;
|
||||
cfg.save();
|
||||
cfg.save_schema(".");
|
||||
const fourdst::config::Config<Person> personConfig;
|
||||
personConfig.save("Example.toml");
|
||||
|
||||
Config<AppConfig> loaded;
|
||||
loaded.save_schema(".");
|
||||
loaded.load("config_example.toml");
|
||||
std::println("{}", loaded);
|
||||
fourdst::config::Config<Person> personConfigToLoad;
|
||||
personConfigToLoad.load("Example.toml");
|
||||
|
||||
personConfigToLoad.save_schema("ExampleSchema.schema.json");
|
||||
}
|
||||
Reference in New Issue
Block a user