TrinityCore
Config.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef CONFIG_H
19#define CONFIG_H
20
21#include "Define.h"
22#include <string>
23#include <string_view>
24#include <vector>
25
27{
28 ConfigMgr() = default;
29 ConfigMgr(ConfigMgr const&) = delete;
30 ConfigMgr& operator=(ConfigMgr const&) = delete;
31 ~ConfigMgr() = default;
32
33public:
35 bool LoadInitial(std::string file, std::vector<std::string> args, std::string& error);
36 bool LoadAdditionalFile(std::string file, bool keepOnReload, std::string& error);
37 bool LoadAdditionalDir(std::string const& dir, bool keepOnReload, std::vector<std::string>& loadedFiles, std::vector<std::string>& errors);
38
40 std::vector<std::string> OverrideWithEnvVariablesIfAny();
41
42 static ConfigMgr* instance();
43
44 bool Reload(std::vector<std::string>& errors);
45
46 std::string GetStringDefault(std::string const& name, const std::string& def, bool quiet = false) const;
47 bool GetBoolDefault(std::string const& name, bool def, bool quiet = false) const;
48 int32 GetIntDefault(std::string const& name, int32 def, bool quiet = false) const;
49 int64 GetInt64Default(std::string const& name, int64 def, bool quiet = false) const;
50 float GetFloatDefault(std::string const& name, float def, bool quiet = false) const;
51
52 std::string const& GetFilename();
53 std::vector<std::string> const& GetArguments() const;
54 std::vector<std::string> GetKeysByString(std::string const& name);
55
56private:
57 template<class T>
58 T GetValueDefault(std::string const& name, T def, bool quiet) const;
59};
60
61#define sConfigMgr ConfigMgr::instance()
62
63#endif
int64_t int64
Definition: Define.h:137
#define TC_COMMON_API
Definition: Define.h:99
int32_t int32
Definition: Define.h:138
~ConfigMgr()=default
ConfigMgr(ConfigMgr const &)=delete
ConfigMgr & operator=(ConfigMgr const &)=delete
ConfigMgr()=default