|
OpenCBDC Transaction Processor
|
Reads configuration parameters line-by-line from a file. More...
#include <config.hpp>
Public Member Functions | |
| parser (const std::string &filename) | |
| Constructor. | |
| parser (std::istream &stream) | |
| Constructor. | |
| auto | get_string (const std::string &key) const -> std::optional< std::string > |
| Returns the given key if its value is a string. | |
| auto | get_ulong (const std::string &key) const -> std::optional< size_t > |
| Return the value for the given key if its value is a long. | |
| auto | get_endpoint (const std::string &key) const -> std::optional< network::endpoint_t > |
| Return the value for the given key if its value is an endpoint. | |
| auto | get_loglevel (const std::string &key) const -> std::optional< logging::log_level > |
| Return the value for the given key if its value is a loglevel. | |
| auto | get_decimal (const std::string &key) const -> std::optional< double > |
| Return the value for the given key if its value is a double. | |
Reads configuration parameters line-by-line from a file.
Expects a file of line-separated parameters with each line in the form key=value, where the key is a lower-case string that may contain numbers and symbols. Acceptable value types:
The class will override file-enumerated config parameters with values from environment variables, where the environment variable key is the upper-case version of the config file string. For example, a window_size=40000 line in the config file would be overridden by setting the environment variable WINDOW_SIZE=50000. String options supplied through environment variables must be quoted, e.g. SOMEKEY='"some_value"'. See the example configuration files and README.md for more detail and valid options.
Definition at line 323 of file config.hpp.
|
explicit |
Constructor.
| filename | path to the config file to read. |
Definition at line 765 of file config.cpp.
|
explicit |
Constructor.
| stream | the generic stream used to add config values. |
Definition at line 772 of file config.cpp.
|
nodiscard |
Return the value for the given key if its value is a double.
| key | key to retrieve. |
Definition at line 819 of file config.cpp.
Referenced by cbdc::config::read_loadgen_options().
|
nodiscard |
Return the value for the given key if its value is an endpoint.
| key | key to retrieve. |
Definition at line 800 of file config.cpp.
References cbdc::config::parse_ip_port().

|
nodiscard |
Return the value for the given key if its value is a loglevel.
| key | key to retrieve. |
Definition at line 810 of file config.cpp.
References cbdc::logging::parse_loglevel().

|
nodiscard |
Returns the given key if its value is a string.
| key | key to retrieve. |
Definition at line 790 of file config.cpp.
|
nodiscard |
Return the value for the given key if its value is a long.
| key | key to retrieve. |
Definition at line 795 of file config.cpp.
Referenced by cbdc::config::read_loadgen_options(), and cbdc::config::read_raft_options().