MySQL 8.0.39
Source Code Documentation
loader_config.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2017, 2024, Oracle and/or its affiliates.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2.0,
6 as published by the Free Software Foundation.
7
8 This program is designed to work with certain software (including
9 but not limited to OpenSSL) that is licensed under separate terms,
10 as designated in a particular file or component or in included license
11 documentation. The authors of MySQL hereby grant you an additional
12 permission to link the program and your derivative works with the
13 separately licensed software that they have either included with
14 the program or referenced in the documentation.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24*/
25
26#ifndef MYSQL_HARNESS_LOADER_CONFIG_INCLUDED
27#define MYSQL_HARNESS_LOADER_CONFIG_INCLUDED
28
29#include <stdexcept>
30
31#include "config_parser.h"
32#include "harness_export.h"
33
34namespace mysql_harness {
35
36class Path;
37
38/**
39 * Configuration file handler for the loader.
40 *
41 * @ingroup ConfigParser
42 *
43 * Specialized version of the config file read that does some extra
44 * checks after reading the configuration file.
45 */
46class HARNESS_EXPORT LoaderConfig : public Config {
47 public:
48 using Config::Config;
49
50 /**
51 * Fill and check the configuration.
52 *
53 * This function will fill in default values for any options that
54 * should have default values and check all sections to make sure
55 * that they have valid values.
56 *
57 * @exception bad_section Thrown if the configuration is not correct.
58 */
59 void fill_and_check();
60
61 /**
62 * Read a configuration entry.
63 *
64 * This will read one configuration entry and incorporate it into
65 * the configuration. The entry can be either a directory or a file.
66 *
67 * This function allows reading multiple configuration entries and
68 * can be used to load paths of configurations. An example of how it
69 * could be used is:
70 *
71 * @code
72 * LoaderConfig config;
73 * for (auto&& entry: my_path)
74 * config.read(entry);
75 * @endcode
76 *
77 * @param path Path to configuration entry to read.
78 * @throws std::invalid_argument, std::runtime_error, syntax_error, ...
79 */
80 void read(const Path &path);
81
82 /**
83 * Return true if we are logging to a file, false if we are logging
84 * to console instead.
85 */
86 bool logging_to_file() const;
87
88 /**
89 * Return log filename.
90 *
91 * @throws std::invalid_argument if not logging to file
92 */
93 Path get_log_file() const;
94};
95
96} // namespace mysql_harness
97
98#endif // MYSQL_HARNESS_LOADER_CONFIG_INCLUDED
A helper class for handling file paths.
Definition: path.h:38
Configuration.
Definition: config_parser.h:253
Config(unsigned int flags=0U, const ConfigOverwrites &config_overwrites={})
Construct a configuration.
Definition: config_parser.cc:208
Configuration file handler for the loader.
Definition: loader_config.h:46
Class representing a path in a file system.
Definition: filesystem.h:63
static char * path
Definition: mysqldump.cc:137
Definition: common.h:42