AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Config.cpp File Reference
#include "Config.h"
#include "Log.h"
#include "StringConvert.h"
#include "StringFormat.h"
#include "Tokenize.h"
#include "Util.h"
#include <cstdlib>
#include <fstream>
#include <mutex>
#include <unordered_map>

Go to the source code of this file.

Namespaces

namespace  anonymous_namespace{Config.cpp}
 

Macros

#define TEMPLATE_CONFIG_OPTION(__typename)    template __typename ConfigMgr::GetOption<__typename>(std::string const& name, __typename const& def, bool showLogs /*= true*/) const;
 

Functions

bool anonymous_namespace{Config.cpp}::IsAppConfig (std::string_view fileName)
 
bool anonymous_namespace{Config.cpp}::IsLoggingSystemOptions (std::string_view optionName)
 
template<typename Format , typename... Args>
void anonymous_namespace{Config.cpp}::PrintError (std::string_view filename, Format &&fmt, Args &&... args)
 
void anonymous_namespace{Config.cpp}::AddKey (std::string const &optionName, std::string const &optionKey, std::string_view fileName, bool isOptional, bool isReload)
 
bool anonymous_namespace{Config.cpp}::ParseFile (std::string const &file, bool isOptional, bool isReload)
 
bool anonymous_namespace{Config.cpp}::LoadFile (std::string const &file, bool isOptional, bool isReload)
 
std::string anonymous_namespace{Config.cpp}::IniKeyToEnvVarKey (std::string const &key)
 
Optional< std::string > anonymous_namespace{Config.cpp}::EnvVarForIniKey (std::string const &key)
 
template<>
std::string ConfigMgr::GetValueDefault< std::string > (std::string const &name, std::string const &def, bool showLogs) const
 

Variables

std::string anonymous_namespace{Config.cpp}::_filename
 
std::vector< std::string > anonymous_namespace{Config.cpp}::_additonalFiles
 
std::vector< std::string > anonymous_namespace{Config.cpp}::_args
 
std::unordered_map< std::string, std::string > anonymous_namespace{Config.cpp}::_configOptions
 
std::mutex anonymous_namespace{Config.cpp}::_configLock
 

Macro Definition Documentation

◆ TEMPLATE_CONFIG_OPTION

#define TEMPLATE_CONFIG_OPTION (   __typename)     template __typename ConfigMgr::GetOption<__typename>(std::string const& name, __typename const& def, bool showLogs /*= true*/) const;

Function Documentation

◆ ConfigMgr::GetValueDefault< std::string >()

template<>
std::string ConfigMgr::GetValueDefault< std::string > ( std::string const &  name,
std::string const &  def,
bool  showLogs 
) const
404{
405 auto const& itr = _configOptions.find(name);
406 if (itr == _configOptions.end())
407 {
409 if (envVar)
410 {
411 if (showLogs)
412 {
413 LOG_WARN("server.loading", "Missing property {} in config file {}, recovered with environment '{}' value.",
414 name.c_str(), _filename.c_str(), envVar->c_str());
415 }
416
417 return *envVar;
418 }
419
420 if (showLogs)
421 {
422 LOG_ERROR("server.loading", "> Config: Missing property {} in config file {}, add \"{} = {}\" to this file.",
423 name, _filename, name, def);
424 }
425
426 return def;
427 }
428
429 return itr->second;
430}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:159
#define LOG_WARN(filterType__,...)
Definition: Log.h:163
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:24
Optional< std::string > EnvVarForIniKey(std::string const &key)
Definition: Config.cpp:285
std::unordered_map< std::string, std::string > _configOptions
Definition: Config.cpp:34
std::string _filename
Definition: Config.cpp:31

References anonymous_namespace{Config.cpp}::_configOptions, anonymous_namespace{Config.cpp}::_filename, anonymous_namespace{Config.cpp}::EnvVarForIniKey(), LOG_ERROR, and LOG_WARN.