22 lines
720 B
C++
22 lines
720 B
C++
#include <Void/Configuration/Bind.hpp>
|
|
#include <Void/Configuration/Config.hpp>
|
|
#include <Void/Configuration/Schema.hpp>
|
|
|
|
#include <string>
|
|
|
|
struct MinimalCfg {
|
|
[[= Void::Configuration::Required{}]] std::string name;
|
|
[[= Void::Configuration::IntRange{1, 100}]] int workers{4};
|
|
};
|
|
|
|
int main()
|
|
{
|
|
Void::Configuration::SourceSet ss;
|
|
ss.add_defaults_map("def", {{"name", "svc"}, {"workers", "8"}});
|
|
auto schema = Void::Configuration::Schema<MinimalCfg>::from_reflection();
|
|
auto merged = Void::Configuration::load_sources(ss, schema.limits());
|
|
if (!merged) return 1;
|
|
auto val = Void::Configuration::validate<MinimalCfg>(*merged, schema);
|
|
return val && val->value.name == "svc" && val->value.workers == 8 ? 0 : 2;
|
|
}
|