MySQL 8.1.0
Source Code Documentation
config_files.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2017, 2023, 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 also distributed 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 included with MySQL.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23*/
24
25#ifndef ROUTER_CONFIG_FILES_INCLUDED
26#define ROUTER_CONFIG_FILES_INCLUDED
27
28#include <cstddef>
29#include <string>
30#include <system_error>
31#include <vector>
32
35
36/*
37 * @brief Converts configuration file name into legacy configuration file name.
38 * @return legacy configuration file name (ends with .ini suffix) if
39 * configuration file has .conf suffix, empty string otherwise
40 */
41std::string use_ini_extension(const std::string &file_name);
42
44 kDuplicate = 1,
45 kNotReadable = 2,
47 kNoConfigfile = 4,
48};
49
50namespace std {
51template <>
52struct is_error_code_enum<ConfigFilePathValidatorErrc> : true_type {};
53} // namespace std
54
56
57/*
58 * @class ConfigFilePathValidator
59 *
60 * The class ConfigFiles encapsulates handling of configuration files
61 * of different types. There are 3 types of configuration files: default
62 * configuration files, configuration files, extra configuration files.
63 */
65 public:
66 /*
67 * @brief Constructor with configuration files.
68 *
69 * There are 3 types of configuration files: default configuration files,
70 * configuration files and extra configuration files.
71 *
72 * @param default_config_files list of configuration files which will be read
73 * (if available) by default
74 * @param config_files list of configuration files passed using command line
75 * @param extra_config_files list of extra configuration files passed using
76 * command line
77 */
78 ConfigFilePathValidator(std::vector<std::string> default_config_files,
79 std::vector<std::string> config_files,
80 std::vector<std::string> extra_config_files)
81 : default_config_files_{std::move(default_config_files)},
82 config_files_{std::move(config_files)},
83 extra_config_files_{std::move(extra_config_files)} {}
84
86 std::error_code ec;
87 std::string current_filename;
88 std::vector<std::string> paths_attempted;
89 };
90
92 bool main_config_file_required = true) const;
93
94 private:
95 std::vector<std::string> default_config_files_;
96 std::vector<std::string> config_files_;
97 std::vector<std::string> extra_config_files_;
98};
99
100#endif // ROUTER_CONFIG_FILES_INCLUDED
Definition: config_files.h:64
std::vector< std::string > config_files_
Definition: config_files.h:96
std::vector< std::string > extra_config_files_
Definition: config_files.h:97
std::vector< std::string > default_config_files_
Definition: config_files.h:95
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:78
Definition: expected.h:943
std::error_code ROUTER_LIB_EXPORT make_error_code(ConfigFilePathValidatorErrc)
Definition: config_files.cc:155
std::string use_ini_extension(const std::string &file_name)
Definition: config_files.cc:32
ConfigFilePathValidatorErrc
Definition: config_files.h:43
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:93
Definition: varlen_sort.h:183
#define ROUTER_LIB_EXPORT
Definition: router_export.h:15
Definition: config_files.h:85
std::error_code ec
Definition: config_files.h:86
std::vector< std::string > paths_attempted
Definition: config_files.h:88
std::string current_filename
Definition: config_files.h:87