|
xrpld
|
Holds a collection of configuration values. More...
#include <BasicConfig.h>

Public Member Functions | |
| Section (std::string name="") | |
| Create an empty section. | |
| std::string const & | name () const |
| Returns the name of this section. | |
| std::vector< std::string > const & | lines () const |
| Returns all the lines in the section. | |
| std::vector< std::string > const & | values () const |
| Returns all the values in the section. | |
| void | legacy (std::string value) |
| Set the legacy value for this section. | |
| std::string | legacy () const |
| Get the legacy value for this section. | |
| void | set (std::string const &key, std::string const &value) |
| Set a key/value pair. | |
| void | append (std::vector< std::string > const &lines) |
| Append a set of lines to this section. | |
| void | append (std::string const &line) |
| Append a line to this section. | |
| bool | exists (std::string const &name) const |
| Returns true if a key with the given name exists. | |
| template<class T = std::string> | |
| std::optional< T > | get (std::string const &name) const |
| template<class T> | |
| T | valueOr (std::string const &name, T const &other) const |
| Returns a value if present, else another value. | |
| bool | hadTrailingComments () 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::unordered_map< std::string, std::string > | lookup_ |
| std::vector< std::string > | lines_ |
| std::vector< std::string > | values_ |
| bool | hadTrailingComments_ = false |
Friends | |
| std::ostream & | operator<< (std::ostream &os, Section const §ion) |
Holds a collection of configuration values.
A configuration file contains zero or more sections.
Definition at line 23 of file BasicConfig.h.
|
private |
Definition at line 32 of file BasicConfig.h.
|
explicit |
Create an empty section.
Definition at line 17 of file BasicConfig.cpp.
|
nodiscard |
Returns the name of this section.
Definition at line 40 of file BasicConfig.h.
|
nodiscard |
Returns all the lines in the section.
This includes everything.
Definition at line 49 of file BasicConfig.h.
|
nodiscard |
Returns all the values in the section.
Values are non-empty lines which are not key/value pairs.
Definition at line 58 of file BasicConfig.h.
| void xrpl::Section::legacy | ( | std::string | value | ) |
Set the legacy value for this section.
Definition at line 67 of file BasicConfig.h.
|
nodiscard |
Get the legacy value for this section.
Definition at line 86 of file BasicConfig.h.
| void xrpl::Section::set | ( | std::string const & | key, |
| std::string const & | value ) |
Set a key/value pair.
The previous value is discarded.
Definition at line 22 of file BasicConfig.cpp.
| void xrpl::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 28 of file BasicConfig.cpp.
| void xrpl::Section::append | ( | std::string const & | line | ) |
Append a line to this section.
Definition at line 114 of file BasicConfig.h.
|
nodiscard |
Returns true if a key with the given name exists.
Definition at line 99 of file BasicConfig.cpp.
|
nodiscard |
Definition at line 125 of file BasicConfig.h.
|
nodiscard |
Returns a value if present, else another value.
Definition at line 136 of file BasicConfig.h.
|
nodiscard |
Definition at line 145 of file BasicConfig.h.
|
nodiscard |
Definition at line 155 of file BasicConfig.h.
|
nodiscard |
Definition at line 162 of file BasicConfig.h.
|
nodiscard |
Definition at line 169 of file BasicConfig.h.
|
nodiscard |
Definition at line 176 of file BasicConfig.h.
|
nodiscard |
Definition at line 183 of file BasicConfig.h.
|
nodiscard |
Definition at line 190 of file BasicConfig.h.
|
friend |
Definition at line 104 of file BasicConfig.cpp.
|
private |
Definition at line 26 of file BasicConfig.h.
|
private |
Definition at line 27 of file BasicConfig.h.
|
private |
Definition at line 28 of file BasicConfig.h.
|
private |
Definition at line 29 of file BasicConfig.h.
|
private |
Definition at line 30 of file BasicConfig.h.