12 sections_.reserve(source.sections_.size());
13 for (
auto § : source.sections_) {
14 sections_.push_back(std::make_shared<section_schema>(*sect));
18 for (
auto § : sections_) {
19 sections_map_.insert(sect_schema_map_pair(sect->get_name(), sect));
25 if (
this != &source) {
27 std::swap(*
this, new_src);
35 *
this = std::move(source);
40 if (
this != &source) {
41 sections_ = std::move(source.sections_);
42 sections_map_ = std::move(source.sections_map_);
50 auto add_it = sections_map_.find(sect_schema.
get_name());
51 if (add_it == sections_map_.end()) {
52 std::shared_ptr<section_schema> add = std::make_shared<section_schema>(sect_schema);
53 sections_.push_back(add);
54 sections_map_.insert(sect_schema_map_pair(add->get_name(), add));
62 auto add_it = sections_map_.find(arguments.
name);
63 if (add_it == sections_map_.end()) {
64 std::shared_ptr<section_schema> add = std::make_shared<section_schema>(arguments);
65 sections_.push_back(add);
66 sections_map_.insert(sect_schema_map_pair(add->get_name(), add));
74 auto sect_it = sections_map_.find(section_name);
75 if (sect_it != sections_map_.end()) {
76 sect_it->second->add_option(opt_schema);
84 return sections_.size();
89 if (index >= sections_.size()) {
93 return *sections_[index];
98 if (index >= sections_.size()) {
102 return *sections_[index];
107 std::shared_ptr<section_schema> result;
109 result = sections_map_.at(section_name);
110 }
catch (std::out_of_range) {
118 std::shared_ptr<section_schema> result;
120 result = sections_map_.at(section_name);
121 }
catch (std::out_of_range) {
130 sections_map_.at(section_name);
132 }
catch (std::out_of_range) {
148 for (
auto § : sections_) {
153 sect->validate_section(cfg[sect->get_name()], mode);
154 }
else if (sect->is_mandatory()) {
156 throw validation_exception(
"Mandatory section '" + sect->get_name() +
"' is missing in config");
161 for (
size_t i = 0; i < sect->size(); ++i) {
162 auto &opt = sect->operator[](i);
163 cfg.
add_option(sect->get_name(), opt.get_name(), opt.get_default_value());
169 for (
auto § : cfg) {
178 if (mode == schema_mode::strict) {
186 for (
auto § : schm.sections_) {
void add_option(const std::string §ion_name, const option &opt)
bool contains(const std::string §ion_name) const
INICPP_API friend std::ostream & operator<<(std::ostream &os, const schema &schm)
void validate_config(config &cfg, schema_mode mode) const
bool contains(const std::string §ion_name) const
void add_section(const section_schema §_schema)
section_schema & operator[](size_t index)
const std::string & get_name() const
void add_option(const std::string §ion_name, const option_schema &opt_schema)
schema & operator=(const schema &source)
void add_section(const section §)