MySQL 8.0.40
Source Code Documentation
mysql_harness::LoaderConfig Class Reference

Configuration file handler for the loader. More...

#include <loader_config.h>

Inheritance diagram for mysql_harness::LoaderConfig:
[legend]

Public Member Functions

void fill_and_check ()
 Fill and check the configuration. More...
 
void read (const Path &path)
 Read a configuration entry. More...
 
bool logging_to_file () const
 Return true if we are logging to a file, false if we are logging to console instead. More...
 
Path get_log_file () const
 Return log filename. More...
 
 Config (unsigned int flags=0U, const ConfigOverwrites &config_overwrites={})
 Construct a configuration. More...
 
template<class AssocT >
 Config (const AssocT &parameters, unsigned int flags=0U, const ConfigOverwrites &config_overwrites={})
 Construct a configuration. More...
 
template<class AssocT , class SeqT >
 Config (const AssocT &parameters, const SeqT &reserved, unsigned int flags=0U, const ConfigOverwrites &config_overwrites={})
 Construct a configuration. More...
 
 Config (const Config &)=default
 
- Public Member Functions inherited from mysql_harness::Config
 Config (unsigned int flags=0U, const ConfigOverwrites &config_overwrites={})
 Construct a configuration. More...
 
template<class AssocT >
 Config (const AssocT &parameters, unsigned int flags=0U, const ConfigOverwrites &config_overwrites={})
 Construct a configuration. More...
 
template<class AssocT , class SeqT >
 Config (const AssocT &parameters, const SeqT &reserved, unsigned int flags=0U, const ConfigOverwrites &config_overwrites={})
 Construct a configuration. More...
 
 Config (const Config &)=default
 
Configoperator= (const Config &)=default
 
virtual ~Config ()=default
 
template<class SeqT >
void set_reserved (const SeqT &reserved)
 
void read (std::istream &input)
 Read configuration file from file, directory, or input stream. More...
 
void read (const Path &path)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void read (const Path &path, const std::string &pattern)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
bool empty () const
 Check if the configuration is empty. More...
 
void clear ()
 Clear the configuration. More...
 
bool remove (const SectionKey &section_key) noexcept
 Remove section from configuration. More...
 
bool remove (const std::string &section, const std::string &key=std::string()) noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
void update (const Config &other)
 Update configuration using another configuration. More...
 
ConstSectionList get (const std::string &section) const
 Get a list of sections having a name. More...
 
SectionList get (const std::string &section)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
ConfigSectionget_default_section () const
 
ConfigSectionget (const std::string &section, const std::string &key)
 Get a section by name and key. More...
 
const ConfigSectionget (const std::string &section, const std::string &key) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
ConfigSectionadd (const std::string &section, const std::string &key=std::string())
 Add a new section to the configuration. More...
 
bool has (const std::string &section, const std::string &key=std::string()) const
 
bool has_any (const std::string &section) const
 
std::string get_default (const std::string &option) const
 
bool has_default (const std::string &option) const
 
void set_default (const std::string &option, const std::string &value)
 
bool is_reserved (const std::string &word) const
 
std::list< Config::SectionKeysection_names () const
 
ConstSectionList sections () const
 Get a list of all sections in the configuration. More...
 

Additional Inherited Members

- Public Types inherited from mysql_harness::Config
using SectionKey = std::pair< std::string, std::string >
 
using OptionMap = ConfigSection::OptionMap
 
using SectionList = std::list< ConfigSection * >
 
using ConstSectionList = std::list< const ConfigSection * >
 
using ConfigOverwrites = std::map< std::pair< std::string, std::string >, std::map< std::string, std::string > >
 
- Public Attributes inherited from mysql_harness::Config
bool error_on_unsupported_option {false}
 
- Static Public Attributes inherited from mysql_harness::Config
static constexpr const char * DEFAULT_PATTERN = "*.cfg"
 Default pattern to used to identify configuration files. More...
 
static constexpr unsigned int allow_keys = 1U
 Flags for construction of configurations. More...
 
- Protected Types inherited from mysql_harness::Config
using SectionMap = std::map< SectionKey, ConfigSection >
 
using ReservedList = std::vector< std::string >
 
- Protected Member Functions inherited from mysql_harness::Config
void copy_guts (const Config &source) noexcept
 Copy the guts of another configuration. More...
 
virtual void do_read_file (const Path &path)
 Function to read single file. More...
 
virtual void do_read_stream (std::istream &input)
 Function to read the configuration from a stream. More...
 
void apply_overwrites ()
 
- Protected Attributes inherited from mysql_harness::Config
SectionMap sections_
 
ReservedList reserved_
 
std::shared_ptr< ConfigSectiondefaults_
 
unsigned int flags_
 
ConfigOverwrites config_overwrites_
 

Detailed Description

Configuration file handler for the loader.

Specialized version of the config file read that does some extra checks after reading the configuration file.

Member Function Documentation

◆ Config() [1/4]

template<class AssocT , class SeqT >
mysql_harness::Config::Config ( const AssocT &  parameters,
const SeqT &  reserved,
unsigned int  flags = 0U,
const ConfigOverwrites config_overwrites = {} 
)
inlineexplicit

Construct a configuration.

Construct a configuration instance by reading a configuration file and overriding the values read from a list of supplied parameters.

Template Parameters
AssocTAssociate container type
SeqTSequence container type
  • parameters Associative container with parameters.
  • reserved Sequence container of reserved words.
  • flags flags.
  • config_overwrites overwrites for selected configuration options.
Exceptions
bad_optionon bad options

◆ Config() [2/4]

template<class AssocT >
mysql_harness::Config::Config ( const AssocT &  parameters,
unsigned int  flags = 0U,
const ConfigOverwrites config_overwrites = {} 
)
inlineexplicit

Construct a configuration.

Template Parameters
AssocTAssociate container type
  • parameters Associative container with parameters.
  • flags flags.
  • config_overwrites overwrites for selected configuration options.
Exceptions
bad_optionon bad options

◆ Config() [3/4]

mysql_harness::Config::Config ( const Config )
default

◆ Config() [4/4]

mysql_harness::Config::Config ( unsigned int  flags = 0U,
const ConfigOverwrites config_overwrites = {} 
)
explicit

Construct a configuration.

Parameters
flagsflags.
config_overwritesoverwrites for selected configuration options.

◆ fill_and_check()

void mysql_harness::LoaderConfig::fill_and_check ( )

Fill and check the configuration.

This function will fill in default values for any options that should have default values and check all sections to make sure that they have valid values.

Exceptions
bad_sectionThrown if the configuration is not correct.

◆ get_log_file()

Path mysql_harness::LoaderConfig::get_log_file ( ) const

Return log filename.

Exceptions
std::invalid_argumentif not logging to file

◆ logging_to_file()

bool mysql_harness::LoaderConfig::logging_to_file ( ) const

Return true if we are logging to a file, false if we are logging to console instead.

◆ read()

void mysql_harness::LoaderConfig::read ( const Path path)

Read a configuration entry.

This will read one configuration entry and incorporate it into the configuration. The entry can be either a directory or a file.

This function allows reading multiple configuration entries and can be used to load paths of configurations. An example of how it could be used is:

LoaderConfig config;
for (auto&& entry: my_path)
config.read(entry);
char * my_path(char *to, const char *progname, const char *own_pathname_part)
Definition: mf_path.cc:62
Definition: completion_hash.h:35
Parameters
pathPath to configuration entry to read.
Exceptions
std::invalid_argument,std::runtime_error,syntax_error,...

The documentation for this class was generated from the following files: