2025-12-03 08:54:33 -05:00
|
|
|
#include "fourdst/config/config.h"
|
2025-12-05 14:26:22 -05:00
|
|
|
#include "glaze/glaze.hpp"
|
2025-12-03 08:54:33 -05:00
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2025-12-05 14:26:22 -05:00
|
|
|
using namespace fourdst::config;
|
|
|
|
|
|
|
|
|
|
struct sub {
|
|
|
|
|
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;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Person {
|
|
|
|
|
int age;
|
|
|
|
|
std::string name;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct AppConfig {
|
|
|
|
|
double x;
|
|
|
|
|
double y;
|
|
|
|
|
Person person;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
const Config<ExampleConfig> cfg;
|
|
|
|
|
cfg.save();
|
|
|
|
|
cfg.save_schema(".");
|
|
|
|
|
|
|
|
|
|
Config<AppConfig> loaded;
|
|
|
|
|
loaded.save_schema(".");
|
|
|
|
|
loaded.load("config_example.toml");
|
|
|
|
|
std::println("{}", loaded);
|
|
|
|
|
}
|