inicpp
C++ parser of INI files with schema validation.
|
#include <option.h>
Public Member Functions | |
option ()=delete | |
option (const option &source) | |
option & | operator= (const option &source) |
option (option &&source) | |
option & | operator= (option &&source) |
option (const std::string &name, const std::string &value="") | |
option (const std::string &name, const std::vector< std::string > &values) | |
const std::string & | get_name () const |
option_type | get_type () const |
bool | is_list () const |
template<typename ValueType > | |
void | set (ValueType value) |
option & | operator= (boolean_ini_t arg) |
option & | operator= (signed_ini_t arg) |
option & | operator= (unsigned_ini_t arg) |
option & | operator= (float_ini_t arg) |
option & | operator= (const char *arg) |
option & | operator= (string_ini_t arg) |
option & | operator= (enum_ini_t arg) |
template<typename ReturnType > | |
ReturnType | get () const |
template<typename ValueType > | |
void | set_list (const std::vector< ValueType > &list) |
template<typename ReturnType > | |
std::vector< ReturnType > | get_list () const |
template<typename ValueType > | |
void | add_to_list (ValueType value) |
template<typename ValueType > | |
void | add_to_list (ValueType value, size_t position) |
template<typename ValueType > | |
void | remove_from_list (ValueType value) |
void | remove_from_list_pos (size_t position) |
void | validate (const option_schema &opt_schema) |
bool | operator== (const option &other) const |
bool | operator!= (const option &other) const |
Friends | |
INICPP_API friend std::ostream & | operator<< (std::ostream &os, const option &opt) |
Represent ini configuration option. Can store one element or list of elements. Stored elements should have only supported types from option_type enum.
|
delete |
Default constructor is deleted.
inicpp::option::option | ( | const option & | source | ) |
Copy constructor.
Definition at line 5 of file option.cpp.
inicpp::option::option | ( | option && | source | ) |
Move constructor.
Definition at line 35 of file option.cpp.
inicpp::option::option | ( | const std::string & | name, |
const std::string & | value = "" |
||
) |
Construct ini option with specified value of specified type.
name | name of newly created option |
value | initial value |
Definition at line 54 of file option.cpp.
inicpp::option::option | ( | const std::string & | name, |
const std::vector< std::string > & | values | ||
) |
Construct ini option with specified value of specified list type.
name | name of newly created option |
values | initial value |
Definition at line 59 of file option.cpp.
|
inline |
Adds element to internal value list. If option was single value than its transformed to list.
value | pushed value |
bad_cast_exception | if ValueType cannot be casted |
|
inline |
Add element to list on specified position. If option was single value than its transformed to list.
value | added value |
position | position in internal list |
bad_cast_exception | if ValueType cannot be casted |
not_found_exception | if position is not in internal list |
|
inline |
Get single element value. If option value is list, than return first element of array.
bad_cast_exception | if internal type cannot be casted |
not_found_exception | if there is no value |
|
inline |
Get list of internal values. Returning list is newly created. If option contains single value than its returned list with one element.
bad_cast_exception | if internal type cannot be casted |
not_found_exception | if there is no value |
const std::string & inicpp::option::get_name | ( | ) | const |
option_type inicpp::option::get_type | ( | ) | const |
bool inicpp::option::is_list | ( | ) | const |
Determines if option is list or not.
Definition at line 143 of file option.cpp.
bool inicpp::option::operator!= | ( | const option & | other | ) | const |
Copy assignment.
Definition at line 10 of file option.cpp.
Move assignment.
Definition at line 43 of file option.cpp.
option & inicpp::option::operator= | ( | boolean_ini_t | arg | ) |
Overloaded alias for set() function.
arg | boolean_t |
Definition at line 148 of file option.cpp.
option & inicpp::option::operator= | ( | signed_ini_t | arg | ) |
Overloaded alias for set() function.
arg | signed_t |
Definition at line 156 of file option.cpp.
option & inicpp::option::operator= | ( | unsigned_ini_t | arg | ) |
Overloaded alias for set() function.
arg | unsigned_t |
Definition at line 164 of file option.cpp.
option & inicpp::option::operator= | ( | float_ini_t | arg | ) |
Overloaded alias for set() function.
arg | float_t |
Definition at line 172 of file option.cpp.
option & inicpp::option::operator= | ( | const char * | arg | ) |
Overloaded alias for set() function.
arg | string_t |
Definition at line 180 of file option.cpp.
option & inicpp::option::operator= | ( | string_ini_t | arg | ) |
Overloaded alias for set() function.
arg | string_t |
Definition at line 188 of file option.cpp.
option & inicpp::option::operator= | ( | enum_ini_t | arg | ) |
Overloaded alias for set() function.
arg | enum_t |
Definition at line 196 of file option.cpp.
bool inicpp::option::operator== | ( | const option & | other | ) | const |
|
inline |
Remove element with same value as given one.
value |
bad_cast_exception | if ValueType cannot be casted |
void inicpp::option::remove_from_list_pos | ( | size_t | position | ) |
Remove list element on specified position.
position |
not_found_exception | in case of out of range |
Definition at line 77 of file option.cpp.
|
inline |
|
inline |
Set internal list of values to given one. If option contained single value than its transformed to list with given values.
list | reference to list of new values |
bad_cast_exception | if ValueType cannot be casted to internal type |
void inicpp::option::validate | ( | const option_schema & | opt_schema | ) |
Validate this option against given option_schema.
opt_schema | validation schema |
validation_exception | if error occured |
Definition at line 85 of file option.cpp.
|
friend |
Classic stream operator for printing this instance to output stream.
os | output stream |
opt | reference to option instance to be written |
Definition at line 272 of file option.cpp.