#include <Config.h>
ConfigMgr::~ConfigMgr |
( |
| ) |
|
|
privatedefault |
bool ConfigMgr::GetBoolDefault |
( |
std::string const & |
name, |
|
|
bool |
def |
|
) |
| const |
124 val.erase(std::remove(val.begin(), val.end(),
'"'), val.end());
125 return (val ==
"1" || val ==
"true" || val ==
"TRUE" || val ==
"yes" || val ==
"YES");
T GetValueDefault(std::string const &name, T def) const
Definition: Config.cpp:73
std::string const & ConfigMgr::GetFilename |
( |
| ) |
|
std::mutex _configLock
Definition: Config.h:55
std::string _filename
Definition: Config.h:53
float ConfigMgr::GetFloatDefault |
( |
std::string const & |
name, |
|
|
float |
def |
|
) |
| const |
T GetValueDefault(std::string const &name, T def) const
Definition: Config.cpp:73
int ConfigMgr::GetIntDefault |
( |
std::string const & |
name, |
|
|
int |
def |
|
) |
| const |
T GetValueDefault(std::string const &name, T def) const
Definition: Config.cpp:73
std::list< std::string > ConfigMgr::GetKeysByString |
( |
std::string const & |
name | ) |
|
148 std::list<std::string> keys;
150 for (
const ptree::value_type& child :
_config)
151 if (child.first.compare(0, name.length(), name) == 0)
152 keys.push_back(child.first);
std::mutex _configLock
Definition: Config.h:55
boost::property_tree::ptree _config
Definition: Config.h:54
std::string ConfigMgr::GetStringDefault |
( |
std::string const & |
name, |
|
|
const std::string & |
def |
|
) |
| const |
117 val.erase(std::remove(val.begin(), val.end(),
'"'), val.end());
T GetValueDefault(std::string const &name, T def) const
Definition: Config.cpp:73
template<class T >
T ConfigMgr::GetValueDefault |
( |
std::string const & |
name, |
|
|
T |
def |
|
) |
| const |
|
private |
77 return _config.get<T>(ptree::path_type(name,
'/'));
79 catch (boost::property_tree::ptree_bad_path)
81 TC_LOG_WARN(
"server.loading",
"Missing name %s in config file %s, add \"%s = %s\" to this file",
82 name.c_str(),
_filename.c_str(), name.c_str(), std::to_string(def).c_str());
84 catch (boost::property_tree::ptree_bad_data)
86 TC_LOG_ERROR(
"server.loading",
"Bad value defined for name %s in config file %s, going to use %s instead",
87 name.c_str(),
_filename.c_str(), std::to_string(def).c_str());
std::string _filename
Definition: Config.h:53
boost::property_tree::ptree _config
Definition: Config.h:54
#define TC_LOG_WARN(filterType__,...)
Definition: Log.h:204
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
static ConfigMgr * instance()
Definition: Config.cpp:61
bool ConfigMgr::LoadInitial |
( |
std::string const & |
file, |
|
|
std::string & |
error |
|
) |
| |
Method used only for loading main configuration files.
38 ini_parser::read_ini(file, fullTree);
42 error =
"empty file (" + file +
")";
47 _config = fullTree.begin()->second;
49 catch (ini_parser::ini_parser_error
const& e)
52 error = e.message() +
" (" + e.filename() +
")";
54 error = e.message() +
" (" + e.filename() +
":" + std::to_string(e.line()) +
")";
std::mutex _configLock
Definition: Config.h:55
std::string _filename
Definition: Config.h:53
boost::property_tree::ptree _config
Definition: Config.h:54
bool ConfigMgr::Reload |
( |
std::string & |
error | ) |
|
std::string _filename
Definition: Config.h:53
bool LoadInitial(std::string const &file, std::string &error)
Method used only for loading main configuration files.
Definition: Config.cpp:29
boost::property_tree::ptree ConfigMgr::_config |
|
private |
std::mutex ConfigMgr::_configLock |
|
private |
std::string ConfigMgr::_filename |
|
private |
The documentation for this class was generated from the following files: