MySQL 9.1.0
Source Code Documentation
config_files.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 ROUTER_CONFIG_FILES_INCLUDED
27#define ROUTER_CONFIG_FILES_INCLUDED
28
29#include <cstddef>
30#include <string>
31#include <system_error>
32#include <vector>
33
36
37/*
38 * @brief Converts configuration file name into legacy configuration file name.
39 * @return legacy configuration file name (ends with .ini suffix) if
40 * configuration file has .conf suffix, empty string otherwise
41 */
42std::string use_ini_extension(const std::string &file_name);
43
45 kDuplicate = 1,
46 kNotReadable = 2,
48 kNoConfigfile = 4,
49};
50
51namespace std {
52template <>
53struct is_error_code_enum<ConfigFilePathValidatorErrc> : true_type {};
54} // namespace std
55
57
58/*
59 * @class ConfigFilePathValidator
60 *
61 * The class ConfigFiles encapsulates handling of configuration files
62 * of different types. There are 3 types of configuration files: default
63 * configuration files, configuration files, extra configuration files.
64 */
66 public:
67 /*
68 * @brief Constructor with configuration files.
69 *
70 * There are 3 types of configuration files: default configuration files,
71 * configuration files and extra configuration files.
72 *
73 * @param default_config_files list of configuration files which will be read
74 * (if available) by default
75 * @param config_files list of configuration files passed using command line
76 * @param extra_config_files list of extra configuration files passed using
77 * command line
78 */
79 ConfigFilePathValidator(std::vector<std::string> default_config_files,
80 std::vector<std::string> config_files,
81 std::vector<std::string> extra_config_files)
82 : default_config_files_{std::move(default_config_files)},
83 config_files_{std::move(config_files)},
84 extra_config_files_{std::move(extra_config_files)} {}
85
87 std::error_code ec;
88 std::string current_filename;
89 std::vector<std::string> paths_attempted;
90 };
91
93 bool main_config_file_required = true) const;
94
95 private:
96 std::vector<std::string> default_config_files_;
97 std::vector<std::string> config_files_;
98 std::vector<std::string> extra_config_files_;
99};
100
101#endif // ROUTER_CONFIG_FILES_INCLUDED
Definition: config_files.h:65
std::vector< std::string > config_files_
Definition: config_files.h:97
std::vector< std::string > extra_config_files_
Definition: config_files.h:98
std::vector< std::string > default_config_files_
Definition: config_files.h:96
ConfigFilePathValidator(std::vector< std::string > default_config_files, std::vector< std::string > config_files, std::vector< std::string > extra_config_files)
Definition: config_files.h:79
Definition: expected.h:286
std::error_code ROUTER_LIB_EXPORT make_error_code(ConfigFilePathValidatorErrc)
Definition: config_files.cc:156
std::string use_ini_extension(const std::string &file_name)
Definition: config_files.cc:33
ConfigFilePathValidatorErrc
Definition: config_files.h:44
std::string file_name(Log_file_id file_id)
Provides name of the log file with the given file id, e.g.
Definition: log0pre_8_0_30.cc:94
Definition: gcs_xcom_synode.h:64
#define ROUTER_LIB_EXPORT
Definition: router_export.h:15
Definition: config_files.h:86
std::error_code ec
Definition: config_files.h:87
std::vector< std::string > paths_attempted
Definition: config_files.h:89
std::string current_filename
Definition: config_files.h:88