8 options_.reserve(source.options_.size());
9 for (
auto &opt : source.options_) {
10 options_.push_back(std::make_shared<option>(*opt));
14 for (
auto &opt : options_) {
15 options_map_.insert(options_map_pair(opt->get_name(), opt));
21 if (
this != &source) {
24 std::swap(*
this, new_src);
37 if (
this != &source) {
38 options_ = std::move(source.options_);
39 options_map_ = std::move(source.options_map_);
40 name_ = std::move(source.name_);
56 auto add_it = options_map_.find(opt.
get_name());
57 if (add_it == options_map_.end()) {
58 std::shared_ptr<option> add = std::make_shared<option>(opt);
59 options_.push_back(add);
60 options_map_.insert(options_map_pair(add->get_name(), add));
68 auto del_it = options_map_.find(option_name);
69 if (del_it != options_map_.end()) {
71 options_map_.erase(del_it);
74 std::remove_if(options_.begin(),
76 [&](std::shared_ptr<option> opt) {
return (opt->get_name() == option_name ?
true :
false); }),
85 return options_.size();
90 if (index >=
size()) {
94 return *options_[index];
99 if (index >=
size()) {
103 return *options_[index];
108 std::shared_ptr<option> result;
110 result = options_map_.at(option_name);
111 }
catch (std::out_of_range) {
119 std::shared_ptr<option> result;
121 result = options_map_.at(option_name);
122 }
catch (std::out_of_range) {
131 options_map_.at(option_name);
133 }
catch (std::out_of_range) {
145 if (name_ != other.name_) {
149 return std::equal(options_.begin(),
151 other.options_.begin(),
152 [](
const std::shared_ptr<option> &first,
const std::shared_ptr<option> &second) {
153 return *first == *second;
159 return !(*
this == other);
169 return iterator(*
this, options_.size());
179 return const_iterator(const_cast<section &>(*
this), options_.size());
189 return const_iterator(const_cast<section &>(*
this), options_.size());
194 os <<
"[" << sect.
get_name() <<
"]" << std::endl;
195 for (
auto &opt : sect.options_) {
bool contains(const std::string &option_name) const
void validate(const section_schema §_schema, schema_mode mode)
void remove_option(const std::string &option_name)
section & operator=(const section &source)
section_iterator< option > iterator
const std::string & get_name() const
bool operator!=(const section &other) const
void add_option(const std::string &option_name, ValueType value)
void validate_section(section §, schema_mode mode) const
bool operator==(const section &other) const
option & operator[](size_t index)
const_iterator cend() const
INICPP_API friend std::ostream & operator<<(std::ostream &os, const section §)
const_iterator cbegin() const
section_iterator< const option > const_iterator
const std::string & get_name() const