OregonCore  revision fb2a440-git
Your Favourite TBC server
Config Class Reference

#include <Config.h>

Public Member Functions

 Config ()
 
 ~Config ()
 
bool SetSource (const char *file)
 
bool Reload ()
 
std::string GetStringDefault (const char *name, const char *def)
 
bool GetBoolDefault (const char *name, const bool def=false)
 
int32 GetIntDefault (const char *name, const int32 def)
 
float GetFloatDefault (const char *name, const float def)
 
std::string GetFilename () const
 

Private Attributes

std::string mFilename
 
ACE_Configuration_Heap * mConf
 

Detailed Description

Definition at line 27 of file Config.h.

Constructor & Destructor Documentation

Config::Config ( )

Definition at line 49 of file Config.cpp.

50  : mConf(NULL)
51 {
52 }
ACE_Configuration_Heap * mConf
Definition: Config.h:49
Config::~Config ( )

Definition at line 54 of file Config.cpp.

References mConf.

55 {
56  delete mConf;
57 }
ACE_Configuration_Heap * mConf
Definition: Config.h:49

Member Function Documentation

bool Config::GetBoolDefault ( const char *  name,
const bool  def = false 
)

Definition at line 88 of file Config.cpp.

89 {
90  ACE_TString val;
91  if (!GetValueHelper(mConf, name, val))
92  return def;
93 
94  const char* str = val.c_str();
95  if (strcmp(str, "true") == 0 || strcmp(str, "TRUE") == 0 ||
96  strcmp(str, "yes") == 0 || strcmp(str, "YES") == 0 ||
97  strcmp(str, "1") == 0)
98  return true;
99  else
100  return false;
101 }
ACE_Configuration_Heap * mConf
Definition: Config.h:49
std::string Config::GetFilename ( ) const
inline

Definition at line 41 of file Config.h.

References mFilename.

42  {
43  return mFilename;
44  }
std::string mFilename
Definition: Config.h:48
float Config::GetFloatDefault ( const char *  name,
const float  def 
)

Definition at line 110 of file Config.cpp.

111 {
112  ACE_TString val;
113  return GetValueHelper(mConf, name, val) ? (float)atof(val.c_str()) : def;
114 }
ACE_Configuration_Heap * mConf
Definition: Config.h:49
int32 Config::GetIntDefault ( const char *  name,
const int32  def 
)

Definition at line 103 of file Config.cpp.

104 {
105  ACE_TString val;
106  return GetValueHelper(mConf, name, val) ? atoi(val.c_str()) : def;
107 }
ACE_Configuration_Heap * mConf
Definition: Config.h:49
std::string Config::GetStringDefault ( const char *  name,
const char *  def 
)

Definition at line 82 of file Config.cpp.

83 {
84  ACE_TString val;
85  return GetValueHelper(mConf, name, val) ? val.c_str() : def;
86 }
ACE_Configuration_Heap * mConf
Definition: Config.h:49
bool Config::Reload ( )

Definition at line 65 of file Config.cpp.

References mConf, and mFilename.

Referenced by SetSource().

66 {
67  delete mConf;
68  mConf = new ACE_Configuration_Heap;
69 
70  if (mConf->open() == 0)
71  {
72  ACE_Ini_ImpExp config_importer(*mConf);
73  if (config_importer.import_config(mFilename.c_str()) == 0)
74  return true;
75  }
76 
77  delete mConf;
78  mConf = NULL;
79  return false;
80 }
std::string mFilename
Definition: Config.h:48
ACE_Configuration_Heap * mConf
Definition: Config.h:49
bool Config::SetSource ( const char *  file)

Definition at line 59 of file Config.cpp.

References mFilename, and Reload().

60 {
61  mFilename = file;
62  return Reload();
63 }
bool Reload()
Definition: Config.cpp:65
std::string mFilename
Definition: Config.h:48

Member Data Documentation

ACE_Configuration_Heap* Config::mConf
private

Definition at line 49 of file Config.h.

Referenced by Reload(), and ~Config().

std::string Config::mFilename
private

Definition at line 48 of file Config.h.

Referenced by GetFilename(), Reload(), and SetSource().


The documentation for this class was generated from the following files: