1 /* 2 Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. 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 MYSQL_HARNESS_LOADER_CONFIG_INCLUDED 26 #define MYSQL_HARNESS_LOADER_CONFIG_INCLUDED 27 28 #include <stdexcept> 29 30 #include "config_parser.h" 31 #include "harness_export.h" 32 33 namespace mysql_harness { 34 35 class Path; 36 37 /** 38 * Configuration file handler for the loader. 39 * 40 * @ingroup ConfigParser 41 * 42 * Specialized version of the config file read that does some extra 43 * checks after reading the configuration file. 44 */ 45 class HARNESS_EXPORT LoaderConfig : public Config { 46 public: 47 using Config::Config; 48 49 /** 50 * Fill and check the configuration. 51 * 52 * This function will fill in default values for any options that 53 * should have default values and check all sections to make sure 54 * that they have valid values. 55 * 56 * @exception bad_section Thrown if the configuration is not correct. 57 */ 58 void fill_and_check(); 59 60 /** 61 * Read a configuration entry. 62 * 63 * This will read one configuration entry and incorporate it into 64 * the configuration. The entry can be either a directory or a file. 65 * 66 * This function allows reading multiple configuration entries and 67 * can be used to load paths of configurations. An example of how it 68 * could be used is: 69 * 70 * @code 71 * LoaderConfig config; 72 * for (auto&& entry: my_path) 73 * config.read(entry); 74 * @endcode 75 * 76 * @param path Path to configuration entry to read. 77 * @throws std::invalid_argument, std::runtime_error, syntax_error, ... 78 */ 79 void read(const Path &path); 80 81 /** 82 * Return true if we are logging to a file, false if we are logging 83 * to console instead. 84 */ 85 bool logging_to_file() const; 86 87 /** 88 * Return log filename. 89 * 90 * @throws std::invalid_argument if not logging to file 91 */ 92 Path get_log_file() const; 93 }; 94 95 } // namespace mysql_harness 96 97 #endif // MYSQL_HARNESS_LOADER_CONFIG_INCLUDED 98