inicpp
C++ parser of INI files with schema validation.
|
#include <section.h>
Public Types | |
using | iterator = section_iterator< option > |
using | const_iterator = section_iterator< const option > |
Public Member Functions | |
section ()=delete | |
section (const section &source) | |
section & | operator= (const section &source) |
section (section &&source) | |
section & | operator= (section &&source) |
section (const std::string &name) | |
const std::string & | get_name () const |
template<typename ValueType > | |
void | add_option (const std::string &option_name, ValueType value) |
void | add_option (const option &opt) |
void | remove_option (const std::string &option_name) |
size_t | size () const |
option & | operator[] (size_t index) |
const option & | operator[] (size_t index) const |
option & | operator[] (const std::string &option_name) |
const option & | operator[] (const std::string &option_name) const |
bool | contains (const std::string &option_name) const |
void | validate (const section_schema §_schema, schema_mode mode) |
bool | operator== (const section &other) const |
bool | operator!= (const section &other) const |
iterator | begin () |
iterator | end () |
const_iterator | begin () const |
const_iterator | end () const |
const_iterator | cbegin () const |
const_iterator | cend () const |
Friends | |
class | section_iterator< option > |
class | section_iterator< const option > |
INICPP_API friend std::ostream & | operator<< (std::ostream &os, const section §) |
Represents section from ini format. Can contain multiple options. Always should be in config container class.
using inicpp::section::const_iterator = section_iterator<const option> |
|
delete |
Default constructor is deleted.
inicpp::section::section | ( | const section & | source | ) |
Copy constructor.
Definition at line 5 of file section.cpp.
inicpp::section::section | ( | section && | source | ) |
Move constructor.
Definition at line 30 of file section.cpp.
inicpp::section::section | ( | const std::string & | name | ) |
Construct instance of section class with given name.
name | name of newly created section class |
Definition at line 45 of file section.cpp.
|
inline |
Creates and add option to this section.
option_name | name of newly created option class |
value | value which will be stored in option |
ambiguity_exception | if option with specified name exists |
void inicpp::section::add_option | ( | const option & | opt | ) |
Add given option instance to options container.
opt | particular instance of option class |
ambiguity_exception | if option with specified name exists |
Definition at line 54 of file section.cpp.
section::iterator inicpp::section::begin | ( | ) |
Iterator pointing at the beginning of options list.
Definition at line 162 of file section.cpp.
section::const_iterator inicpp::section::begin | ( | ) | const |
Constant iterator pointing at the beginning of options list.
Definition at line 172 of file section.cpp.
section::const_iterator inicpp::section::cbegin | ( | ) | const |
Constant iterator pointing at the beginning of options list.
Definition at line 182 of file section.cpp.
section::const_iterator inicpp::section::cend | ( | ) | const |
Constant iterator pointing at the end of options list.
Definition at line 187 of file section.cpp.
bool inicpp::section::contains | ( | const std::string & | option_name | ) | const |
Tries to find option with specified name inside this section.
option_name | name which is searched |
Definition at line 128 of file section.cpp.
section::iterator inicpp::section::end | ( | ) |
Iterator pointing at the end of options list.
Definition at line 167 of file section.cpp.
section::const_iterator inicpp::section::end | ( | ) | const |
Constant iterator pointing at the end of options list.
Definition at line 177 of file section.cpp.
const std::string & inicpp::section::get_name | ( | ) | const |
bool inicpp::section::operator!= | ( | const section & | other | ) | const |
Copy assignment.
Definition at line 19 of file section.cpp.
Move assignment.
Definition at line 35 of file section.cpp.
bool inicpp::section::operator== | ( | const section & | other | ) | const |
option & inicpp::section::operator[] | ( | size_t | index | ) |
Access option on specified index.
index |
not_found_exception | in case of out of range |
Definition at line 88 of file section.cpp.
const option & inicpp::section::operator[] | ( | size_t | index | ) | const |
Access constant reference on option specified index.
index |
not_found_exception | in case of out of range |
Definition at line 97 of file section.cpp.
option & inicpp::section::operator[] | ( | const std::string & | option_name | ) |
Access option with specified name
option_name |
not_found_exception | if option with given name does not exist |
Definition at line 106 of file section.cpp.
const option & inicpp::section::operator[] | ( | const std::string & | option_name | ) | const |
Access constant reference on option with specified name
option_name |
not_found_exception | if option with given name does not exist |
Definition at line 117 of file section.cpp.
void inicpp::section::remove_option | ( | const std::string & | option_name | ) |
From list of options remove the one with specified name
option_name | name of option which will be removed |
not_found_exception | if option with given name was not found |
Definition at line 66 of file section.cpp.
size_t inicpp::section::size | ( | ) | const |
void inicpp::section::validate | ( | const section_schema & | sect_schema, |
schema_mode | mode | ||
) |
Validates this section agains given section_schema.
sect_schema | rules how this section should look like |
mode | validation mode |
validation_exception | if error occured |
Definition at line 138 of file section.cpp.
|
friend |
Classic stream operator for printing this instance to output stream.
os | output stream |
sect | reference to section instance to be written |
Definition at line 192 of file section.cpp.