12 sections_.reserve(source.sections_.size());
13 for (
auto § : source.sections_) {
14 sections_.push_back(std::make_shared<section>(*sect));
18 for (
auto § : sections_) {
19 sections_map_.insert(sections_map_pair(sect->get_name(), sect));
25 if (
this != &source) {
28 std::swap(*
this, new_src);
41 if (
this != &source) {
42 sections_ = std::move(source.sections_);
43 sections_map_ = std::move(source.sections_map_);
50 auto add_it = sections_map_.find(sect.
get_name());
51 if (add_it == sections_map_.end()) {
52 std::shared_ptr<section> add = std::make_shared<section>(sect);
53 sections_.push_back(add);
54 sections_map_.insert(sections_map_pair(add->get_name(), add));
62 auto add_it = sections_map_.find(section_name);
63 if (add_it == sections_map_.end()) {
64 std::shared_ptr<section> add = std::make_shared<section>(section_name);
65 sections_.push_back(add);
66 sections_map_.insert(sections_map_pair(add->get_name(), add));
74 auto del_it = sections_map_.find(section_name);
75 if (del_it != sections_map_.end()) {
77 sections_map_.erase(del_it);
80 std::remove_if(sections_.begin(),
82 [&](std::shared_ptr<section> sect) {
return (sect->get_name() == section_name ?
true :
false); }),
91 auto sect_it = sections_map_.find(section_name);
92 if (sect_it != sections_map_.end()) {
93 sect_it->second->add_option(opt);
101 auto sect_it = sections_map_.find(section_name);
102 if (sect_it != sections_map_.end()) {
103 sect_it->second->remove_option(option_name);
111 return sections_.size();
116 if (index >= sections_.size()) {
120 return *sections_[index];
125 if (index >= sections_.size()) {
129 return *sections_[index];
134 std::shared_ptr<section> result;
136 result = sections_map_.at(section_name);
137 }
catch (std::out_of_range) {
145 std::shared_ptr<section> result;
147 result = sections_map_.at(section_name);
148 }
catch (std::out_of_range) {
157 sections_map_.at(section_name);
159 }
catch (std::out_of_range) {
171 return std::equal(sections_.begin(),
173 other.sections_.begin(),
174 [](
const std::shared_ptr<section> &first,
const std::shared_ptr<section> &second) {
175 return *first == *second;
181 return !(*
this == other);
191 return iterator(*
this, sections_.size());
201 return const_iterator(const_cast<config &>(*
this), sections_.size());
211 return const_iterator(const_cast<config &>(*
this), sections_.size());
216 for (
auto § : conf.sections_) {
bool operator!=(const config &other) const
config_iterator< const section > const_iterator
bool operator==(const config &other) const
config & operator=(const config &source)
section & operator[](size_t index)
void remove_option(const std::string §ion_name, const std::string &option_name)
void add_option(const std::string §ion_name, const option &opt)
config_iterator< section > iterator
const_iterator cbegin() const
void validate_config(config &cfg, schema_mode mode) const
INICPP_API friend std::ostream & operator<<(std::ostream &os, const config &conf)
bool contains(const std::string §ion_name) const
const_iterator cend() const
void validate(const schema &schm, schema_mode mode)
void remove_section(const std::string §ion_name)
const std::string & get_name() const
void add_section(const section §)