rippled
|
Holds a collection of configuration values. More...
Public Member Functions | |
Section (std::string const &name="") | |
Create an empty section. More... | |
std::string const & | name () const |
Returns the name of this section. More... | |
std::vector< std::string > const & | lines () const |
Returns all the lines in the section. More... | |
std::vector< std::string > const & | values () const |
Returns all the values in the section. More... | |
void | legacy (std::string value) |
Set the legacy value for this section. More... | |
std::string | legacy () const |
Get the legacy value for this section. More... | |
void | set (std::string const &key, std::string const &value) |
Set a key/value pair. More... | |
void | append (std::vector< std::string > const &lines) |
Append a set of lines to this section. More... | |
void | append (std::string const &line) |
Append a line to this section. More... | |
bool | exists (std::string const &name) const |
Returns true if a key with the given name exists. More... | |
template<class T = std::string> | |
std::optional< T > | get (std::string const &name) const |
template<class T > | |
T | value_or (std::string const &name, T const &other) const |
Returns a value if present, else another value. More... | |
bool | had_trailing_comments () const |
bool | empty () const |
std::size_t | size () const |
const_iterator | begin () const |
const_iterator | cbegin () const |
const_iterator | end () const |
const_iterator | cend () const |
Private Types | |
using | const_iterator = decltype(lookup_)::const_iterator |
Private Attributes | |
std::string | name_ |
std::map< std::string, std::string > | lookup_ |
std::vector< std::string > | lines_ |
std::vector< std::string > | values_ |
bool | had_trailing_comments_ = false |
Friends | |
std::ostream & | operator<< (std::ostream &, Section const §ion) |
Holds a collection of configuration values.
A configuration file contains zero or more sections.
Definition at line 42 of file BasicConfig.h.
|
private |
Definition at line 51 of file BasicConfig.h.
|
explicit |
Create an empty section.
Definition at line 27 of file BasicConfig.cpp.
std::string const& ripple::Section::name | ( | ) | const |
Returns the name of this section.
Definition at line 59 of file BasicConfig.h.
std::vector<std::string> const& ripple::Section::lines | ( | ) | const |
Returns all the lines in the section.
This includes everything.
Definition at line 68 of file BasicConfig.h.
std::vector<std::string> const& ripple::Section::values | ( | ) | const |
Returns all the values in the section.
Values are non-empty lines which are not key/value pairs.
Definition at line 77 of file BasicConfig.h.
void ripple::Section::legacy | ( | std::string | value | ) |
Set the legacy value for this section.
Definition at line 86 of file BasicConfig.h.
std::string ripple::Section::legacy | ( | ) | const |
Get the legacy value for this section.
Definition at line 101 of file BasicConfig.h.
void ripple::Section::set | ( | std::string const & | key, |
std::string const & | value | ||
) |
Set a key/value pair.
The previous value is discarded.
Definition at line 32 of file BasicConfig.cpp.
void ripple::Section::append | ( | std::vector< std::string > const & | lines | ) |
Append a set of lines to this section.
Lines containing key/value pairs are added to the map, else they are added to the values list. Everything is added to the lines list.
Definition at line 38 of file BasicConfig.cpp.
void ripple::Section::append | ( | std::string const & | line | ) |
Append a line to this section.
Definition at line 127 of file BasicConfig.h.
bool ripple::Section::exists | ( | std::string const & | name | ) | const |
Returns true
if a key with the given name exists.
Definition at line 105 of file BasicConfig.cpp.
std::optional<T> ripple::Section::get | ( | std::string const & | name | ) | const |
Definition at line 138 of file BasicConfig.h.
T ripple::Section::value_or | ( | std::string const & | name, |
T const & | other | ||
) | const |
Returns a value if present, else another value.
Definition at line 149 of file BasicConfig.h.
bool ripple::Section::had_trailing_comments | ( | ) | const |
Definition at line 158 of file BasicConfig.h.
bool ripple::Section::empty | ( | ) | const |
Definition at line 168 of file BasicConfig.h.
std::size_t ripple::Section::size | ( | ) | const |
Definition at line 175 of file BasicConfig.h.
const_iterator ripple::Section::begin | ( | ) | const |
Definition at line 182 of file BasicConfig.h.
const_iterator ripple::Section::cbegin | ( | ) | const |
Definition at line 189 of file BasicConfig.h.
const_iterator ripple::Section::end | ( | ) | const |
Definition at line 196 of file BasicConfig.h.
const_iterator ripple::Section::cend | ( | ) | const |
Definition at line 203 of file BasicConfig.h.
|
friend |
Definition at line 111 of file BasicConfig.cpp.
|
private |
Definition at line 45 of file BasicConfig.h.
|
private |
Definition at line 46 of file BasicConfig.h.
|
private |
Definition at line 47 of file BasicConfig.h.
|
private |
Definition at line 48 of file BasicConfig.h.
|
private |
Definition at line 49 of file BasicConfig.h.