1 #ifndef INICPP_CONFIG_H 2 #define INICPP_CONFIG_H 31 using sections_vector = std::vector<std::shared_ptr<section>>;
32 using sections_map = std::map<std::string, std::shared_ptr<section>>;
33 using sections_map_pair = std::pair<std::string, std::shared_ptr<section>>;
36 sections_vector sections_;
38 sections_map sections_map_;
75 void add_section(
const section §);
81 void add_section(
const std::string §ion_name);
87 void remove_section(
const std::string §ion_name);
96 void add_option(
const std::string §ion_name,
const option &opt);
104 template <
typename ValueType>
105 void add_option(
const std::string §ion_name,
const std::string &option_name, ValueType value)
107 auto sect_it = sections_map_.find(section_name);
108 if (sect_it != sections_map_.end()) {
110 opt.
set<ValueType>(value);
111 sect_it->second->add_option(opt);
125 void remove_option(
const std::string §ion_name,
const std::string &option_name);
138 section &operator[](
size_t index);
145 const section &operator[](
size_t index)
const;
152 section &operator[](
const std::string §ion_name);
159 const section &operator[](
const std::string §ion_name)
const;
165 bool contains(
const std::string §ion_name)
const;
173 void validate(
const schema &schm, schema_mode mode);
180 bool operator==(
const config &other)
const;
186 bool operator!=(
const config &other)
const;
225 INICPP_API
friend std::ostream &operator<<(std::ostream &os,
const config &conf);
228 INICPP_API std::ostream &operator<<(std::ostream &os,
const config &conf);
236 template <
typename Element>
class config_iterator :
public std::iterator<std::random_access_iterator_tag, Element>
245 using typename std::iterator<std::random_access_iterator_tag, Element>::reference;
246 using typename std::iterator<std::random_access_iterator_tag, Element>::pointer;
313 return &container_ == &second.container_ && position_ == second.position_;
322 return !(*
this == second);
331 return position_ < second.position_;
340 return *container_.sections_.at(position_);
349 return &(operator*());
config_iterator(config &source)
config_iterator & operator++()
bool operator!=(const config_iterator &second) const
void add_option(const std::string §ion_name, const std::string &option_name, ValueType value)
bool operator==(const config_iterator &second) const
bool operator<(const config_iterator &second) const
config_iterator operator++(int)
config_iterator(config &source, size_t position)
void set(ValueType value)