dodo
0.0.1
A C++ library to create containerized Linux services
|
Go to the documentation of this file.
26 #include <yaml-cpp/yaml.h>
31 #ifndef common_config_hpp
32 #define common_config_hpp
174 std::string
getAppName()
const {
return getValue<std::string>( {
"dodo",
"common",
"application",
"name"} ); }
188 YAML::Node ref = Clone(
yaml_ );
189 for(
const auto &k : keypath ) {
202 YAML::Node ref = Clone(
yaml_ );
203 for(
const auto &k : keypath ) {
204 if ( ! ref[k] )
return false;
223 Config(
const std::string path );
static const Config::KeyPath config_dodo_common_logger
The dodo.common.logger node.
bool exists(const KeyPath &keypath) const
Return true if the KeyPath exists.
static Config * getConfig()
return the singleton.
std::string secret_
The encryption secret / key.
std::string getAppName() const
Return the application name.
static Config * config_
The singleton pointer.
static const Config::KeyPath config_dodo_common_application_secret_file
The dodo.common.application.secret.file node.
An array of Octets with size elements.
static const Config::KeyPath config_dodo_common_logger_syslog_level
The dodo.common.logger.syslog.level node.
std::string getSecret() const
Get the application secret.
static const Config::KeyPath config_dodo
The dodo root node.
static const Config::KeyPath config_dodo_common_application
The dodo.common.application node.
static const Config::KeyPath config_dodo_common_logger_file_directory
The dodo.common.logger.file.directory node.
YAML::Node yaml_
The root YAML node.
Config(const Config &)=delete
Disallow the copy constructor as this is a singleton.
static const Config::KeyPath config_dodo_common_logger_syslog
The dodo.common.logger.syslog node.
Config & operator=(const Config &)=delete
Disallow assignment from another Config, as this is a singleton.
void readConfig()
Read the configuration file.
static const Config::KeyPath config_dodo_common_logger_console_level
The dodo.common.logger.console.level node.
static const Config::KeyPath config_dodo_common
The dodo.common node.
Singleton interface to a (read-only) deployment configuration, combining data from the deployment con...
static const Config::KeyPath config_dodo_common_logger_file_max_file_trail
The dodo.common.logger.file.max-file-trail node.
#define throw_Exception(what)
Throws an Exception, passes FILE and LINE to constructor.
static std::string path_
The path to the configuration file.
void checkConfig()
Check for required elements in the config file.
Common and utility interfaces.
static const Config::KeyPath config_dodo_common_logger_file_level
The dodo.common.logger.file.level node.
static const Config::KeyPath config_dodo_common_logger_syslog_facility
The dodo.common.logger.syslog.facility node.
T getValue(const KeyPath &keypath) const
Get the value at keypath.
std::list< std::string > KeyPath
Used by getValue, enable use of list initializers as path specification, eg.
Red tape wrapper class for applications, from command line to services.
static const Config::KeyPath config_dodo_common_application_secret
The dodo.common.application.secret node.
static const Config::KeyPath config_dodo_common_application_name
The dodo.common.application.name node.
static Config * initialize(const std::string path)
Initialize the singleton.
std::string getConfigPath() const
Return the path of the configuration file.
static const Config::KeyPath config_dodo_common_logger_console
The dodo.common.logger.console node.
static const Config::KeyPath config_dodo_common_application_secret_env
The dodo.common.application.secret.env node.
virtual ~Config()
Destructor.
static const Config::KeyPath config_dodo_common_logger_file
The dodo.common.logger.file node.
static std::string flattenKeyPath(const KeyPath &keypath)
Transform a keypath to a string with ":" as seperator between levels.
static const Config::KeyPath config_dodo_common_logger_file_max_size_mib
The dodo.common.logger.file.max-size-mib node.
void getDecryptedValue(const KeyPath &keypath, Bytes &decrypted)
Get the decrypted value from KeyPath - decrypted using the secret from getSecret().