TrinityCore
Loading...
Searching...
No Matches
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 TRINITYCORE_CONFIG_H
19#define TRINITYCORE_CONFIG_H
20
21#include "Define.h"
22#include <string>
23#include <string_view>
24#include <vector>
25
27{
28 ConfigMgr() = default;
29 ~ConfigMgr() = default;
30
31public:
32 ConfigMgr(ConfigMgr const&) = delete;
33 ConfigMgr(ConfigMgr&&) = delete;
34 ConfigMgr& operator=(ConfigMgr const&) = delete;
36
38 bool LoadInitial(std::string file, std::vector<std::string> args, std::string& error);
39 bool LoadAdditionalFile(std::string file, bool keepOnReload, std::string& error);
40 bool LoadAdditionalDir(std::string const& dir, bool keepOnReload, std::vector<std::string>& loadedFiles, std::vector<std::string>& errors);
41
43 std::vector<std::string> OverrideWithEnvVariablesIfAny();
44
45 static ConfigMgr* instance();
46
47 bool Reload(std::vector<std::string>& errors);
48
49 std::string GetStringDefault(std::string_view name, std::string_view def, bool quiet = false) const;
50 bool GetBoolDefault(std::string_view name, bool def, bool quiet = false) const;
51 int32 GetIntDefault(std::string_view name, int32 def, bool quiet = false) const;
52 int64 GetInt64Default(std::string_view name, int64 def, bool quiet = false) const;
53 float GetFloatDefault(std::string_view name, float def, bool quiet = false) const;
54
55 std::string const& GetFilename();
56 std::vector<std::string> const& GetArguments() const;
57 std::vector<std::string> GetKeysByString(std::string const& name);
58
59private:
60 template<class T, class R = T>
61 R GetValueDefault(std::string_view const& name, T def, bool quiet) const;
62};
63
64#define sConfigMgr ConfigMgr::instance()
65
66#endif
int64_t int64
Definition Define.h:149
#define TC_COMMON_API
Definition Define.h:99
int32_t int32
Definition Define.h:150
~ConfigMgr()=default
ConfigMgr(ConfigMgr const &)=delete
ConfigMgr(ConfigMgr &&)=delete
ConfigMgr & operator=(ConfigMgr const &)=delete
ConfigMgr & operator=(ConfigMgr &&)=delete
ConfigMgr()=default