26#ifndef MYSQL_HARNESS_CONFIG_PARSER_INCLUDED
27#define MYSQL_HARNESS_CONFIG_PARSER_INCLUDED
38#include "harness_export.h"
146 ConfigSection(
const std::string &name_arg,
const std::string &key_arg,
147 const std::shared_ptr<const ConfigSection> &defaults);
150 const std::shared_ptr<const ConfigSection> &defaults);
181 std::string
get(std::string_view option)
const;
182 void set(std::string_view option,
183 const std::string &value);
184 void add(
const std::string &option,
const std::string &value);
185 bool has(std::string_view option)
const;
203 return OptionRange(options_.begin(), options_.end());
213 std::string get_section_name(std::string_view option)
const;
218 std::string get_section_name()
const;
222 return def == defaults_.
get();
231 std::string do_replace(
const std::string &value,
int depth = 0)
const;
233 const int kMaxInterpolationDepth = 10;
235 std::pair<OptionMap::const_iterator, bool> do_locate(
236 std::string_view option)
const noexcept;
260 std::map<std::string, std::string>>;
265 static constexpr unsigned int allow_keys = 1U;
272 static constexpr const char *DEFAULT_PATTERN =
"*.cfg";
292 template <
class AssocT>
296 for (
auto item : parameters)
297 defaults_->set(item.first, item.second);
316 template <
class AssocT,
class SeqT>
317 explicit Config(
const AssocT ¶meters,
const SeqT &reserved,
321 for (
auto word : reserved) reserved_.push_back(word);
328 template <
class SeqT>
330 reserved_.assign(reserved.begin(), reserved.end());
363 void read(std::istream &input);
373 void read(
const Path &
path,
const std::string &pattern);
399 bool remove(
const SectionKey §ion_key)
noexcept;
406 bool remove(
const std::string §ion,
407 const std::string &
key = std::string()) noexcept;
432 ConstSectionList
get(const
std::
string §ion) const;
435 SectionList
get(const
std::
string §ion);
460 const
std::
string &
key) const;
474 bool has(const
std::
string §ion,
475 const
std::
string &
key =
std::
string()) const;
480 bool has_any(
std::string_view section) const;
484 std::
string get_default(
std::string_view option) const;
485 bool has_default(
std::string_view option) const;
486 void set_default(
std::string_view option, const
std::
string &value);
491 decltype(section_names())
result;
492 for (
auto §ion : sections_)
result.push_back(section.first);
499 ConstSectionList sections()
const;
501 bool error_on_unsupported_option{
false};
521 virtual void do_read_file(
const Path &
path);
532 virtual void do_read_stream(std::istream &input);
534 void apply_overwrites();
A helper class for handling file paths.
Definition: path.h:38
Configuration section.
Definition: config_parser.h:141
OptionRange get_options() const
Range for options in section.
Definition: config_parser.h:202
const std::shared_ptr< const ConfigSection > defaults_
Definition: config_parser.h:238
OptionMap options_
Definition: config_parser.h:239
ConfigSection & operator=(const ConfigSection &)=delete
const std::string key
Definition: config_parser.h:228
std::string get(std::string_view option) const
Definition: config_parser.cc:163
bool assert_default(const ConfigSection *def) const
Definition: config_parser.h:221
ConfigSection(const ConfigSection &)=default
std::map< std::string, std::string > OptionMap
Definition: config_parser.h:143
const std::string name
Definition: config_parser.h:227
Configuration.
Definition: config_parser.h:253
std::pair< std::string, std::string > SectionKey
Definition: config_parser.h:255
Config(const AssocT ¶meters, unsigned int flags=0U, const ConfigOverwrites &config_overwrites={})
Construct a configuration.
Definition: config_parser.h:293
std::list< const ConfigSection * > ConstSectionList
Definition: config_parser.h:258
std::map< std::pair< std::string, std::string >, std::map< std::string, std::string > > ConfigOverwrites
Definition: config_parser.h:260
Config(const AssocT ¶meters, const SeqT &reserved, unsigned int flags=0U, const ConfigOverwrites &config_overwrites={})
Construct a configuration.
Definition: config_parser.h:317
std::vector< std::string > ReservedList
Definition: config_parser.h:505
Config & operator=(const Config &)=default
std::list< ConfigSection * > SectionList
Definition: config_parser.h:257
std::map< SectionKey, ConfigSection > SectionMap
Definition: config_parser.h:504
std::shared_ptr< ConfigSection > defaults_
Definition: config_parser.h:538
ConfigSection::OptionMap OptionMap
Definition: config_parser.h:256
void set_reserved(const SeqT &reserved)
Definition: config_parser.h:329
SectionMap sections_
Definition: config_parser.h:536
unsigned int flags_
Definition: config_parser.h:539
Config(const Config &)=default
ConfigOverwrites config_overwrites_
Definition: config_parser.h:540
virtual ~Config()=default
ReservedList reserved_
Definition: config_parser.h:537
Class representing a path in a file system.
Definition: filesystem.h:63
Convenience class for handling iterator range.
Definition: config_parser.h:53
bool empty() const
Check if range is empty.
Definition: config_parser.h:71
typename std::iterator_traits< Iter >::difference_type difference_type
Definition: config_parser.h:59
Iter end_
Definition: config_parser.h:84
difference_type size_type
Definition: config_parser.h:60
Iter end() const
Get iterator to end of range.
Definition: config_parser.h:68
Iter begin_
Definition: config_parser.h:83
size_type size() const
Get size of the range, that is, number of elements in the range.
Definition: config_parser.h:80
iterator const_iterator
Definition: config_parser.h:58
Iter iterator
Definition: config_parser.h:57
typename Iter::value_type value_type
Definition: config_parser.h:55
Range(Iter start, Iter finish)
Definition: config_parser.h:62
typename Iter::reference reference
Definition: config_parser.h:56
Iter begin() const
Get iterator to beginning of range.
Definition: config_parser.h:65
Exception thrown for option value problems.
Definition: config_parser.h:127
bad_option_value(const std::string &msg)
Definition: config_parser.h:129
Exception thrown for option problems.
Definition: config_parser.h:116
bad_option(const std::string &msg)
Definition: config_parser.h:118
Exception thrown for section problems.
Definition: config_parser.h:105
bad_section(const std::string &msg)
Definition: config_parser.h:107
Exception thrown for syntax errors.
Definition: config_parser.h:94
syntax_error(const std::string &msg)
Definition: config_parser.h:96
static int flags[50]
Definition: hp_test1.cc:40
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:180
static uint update
Definition: myisamlog.cc:94
static char * path
Definition: mysqldump.cc:149
uint16_t value_type
Definition: vt100.h:184
bool distance(const dd::Spatial_reference_system *srs, const Geometry *g1, const Geometry *g2, double *distance, bool *is_null) noexcept
Computes the distance between two geometries.
Definition: distance.cc:40
bool has(const Container &c, Value &&val)
Definition: generic.h:97
static mysql_service_status_t get(THD **thd) noexcept
Definition: mysql_current_thread_reader_all_empty.cc:31
bool HARNESS_EXPORT is_valid_conf_ident_char(const char ch)
Returns true if a character given as a parameter is valid for config identifier (section,...
Definition: config_parser.cc:57
static mysql_service_status_t remove(reference_caching_channel channel, const char *implementation_name) noexcept
Definition: component.cc:137
static mysql_service_status_t clear(reference_caching_channel channel) noexcept
Definition: component.cc:146
Definition: gcs_xcom_synode.h:64
bool is_reserved(space_id_t space_id)
Check if the space_id is an undo space ID in the reserved range.
Definition: trx0purge.h:166
std::set< Key, Compare, ut::allocator< Key > > set
Specialization of set which uses ut_allocator.
Definition: ut0new.h:2884
std::list< T, ut::allocator< T > > list
Specialization of list which uses ut_allocator.
Definition: ut0new.h:2880
struct result result
Definition: result.h:34
required string key
Definition: replication_asynchronous_connection_failover.proto:60
repeated Source source
Definition: replication_asynchronous_connection_failover.proto:42