2010-10-07 15:54:07 +02:00
|
|
|
/*
|
2018-01-01 00:40:17 +01:00
|
|
|
* Copyright (C) 2008-2018 TrinityCore <https://www.trinitycore.org/>
|
2010-10-07 15:54:07 +02:00
|
|
|
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
|
* option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
|
* more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-10-02 16:23:55 -05:00
|
|
|
*/
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
#ifndef CONFIG_H
|
|
|
|
|
#define CONFIG_H
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2016-03-22 19:58:32 +01:00
|
|
|
#include "Define.h"
|
2011-09-28 13:00:43 +02:00
|
|
|
#include <string>
|
2016-04-18 20:29:42 +02:00
|
|
|
#include <vector>
|
2013-07-15 17:31:44 +02:00
|
|
|
|
2016-03-22 19:58:32 +01:00
|
|
|
class TC_COMMON_API ConfigMgr
|
2008-10-02 16:23:55 -05:00
|
|
|
{
|
2016-03-31 03:19:13 +01:00
|
|
|
ConfigMgr() = default;
|
|
|
|
|
ConfigMgr(ConfigMgr const&) = delete;
|
|
|
|
|
ConfigMgr& operator=(ConfigMgr const&) = delete;
|
|
|
|
|
~ConfigMgr() = default;
|
2013-07-15 17:31:44 +02:00
|
|
|
|
|
|
|
|
public:
|
2016-04-18 20:29:42 +02:00
|
|
|
/// Method used only for loading main configuration files (bnetserver.conf and worldserver.conf)
|
2017-05-11 22:29:51 +02:00
|
|
|
bool LoadInitial(std::string const& file, std::vector<std::string> args, std::string& error);
|
2013-07-15 17:31:44 +02:00
|
|
|
|
2016-03-11 15:50:17 +01:00
|
|
|
static ConfigMgr* instance();
|
2013-07-15 17:31:44 +02:00
|
|
|
|
2014-07-29 01:47:00 +01:00
|
|
|
bool Reload(std::string& error);
|
2010-08-15 16:55:44 +02:00
|
|
|
|
2016-02-21 15:52:42 +01:00
|
|
|
std::string GetStringDefault(std::string const& name, const std::string& def) const;
|
|
|
|
|
bool GetBoolDefault(std::string const& name, bool def) const;
|
2018-09-26 21:34:56 +02:00
|
|
|
int32 GetIntDefault(std::string const& name, int32 def) const;
|
|
|
|
|
int64 GetInt64Default(std::string const& name, int64 def) const;
|
2016-02-21 15:52:42 +01:00
|
|
|
float GetFloatDefault(std::string const& name, float def) const;
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2013-07-15 17:31:44 +02:00
|
|
|
std::string const& GetFilename();
|
2017-05-11 22:29:51 +02:00
|
|
|
std::vector<std::string> const& GetArguments() const;
|
|
|
|
|
std::vector<std::string> GetKeysByString(std::string const& name);
|
2013-07-15 17:31:44 +02:00
|
|
|
|
|
|
|
|
private:
|
2016-03-31 03:19:13 +01:00
|
|
|
template<class T>
|
|
|
|
|
T GetValueDefault(std::string const& name, T def) const;
|
2013-07-15 17:31:44 +02:00
|
|
|
};
|
|
|
|
|
|
2014-06-22 15:45:54 +02:00
|
|
|
#define sConfigMgr ConfigMgr::instance()
|
2009-10-17 15:51:44 -07:00
|
|
|
|
2008-10-02 16:23:55 -05:00
|
|
|
#endif
|