diff options
Diffstat (limited to 'src/shared/Config/Config.cpp')
-rw-r--r-- | src/shared/Config/Config.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/shared/Config/Config.cpp b/src/shared/Config/Config.cpp index 5636e17fd6d..b56b804b50a 100644 --- a/src/shared/Config/Config.cpp +++ b/src/shared/Config/Config.cpp @@ -17,38 +17,49 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include "ConfigEnv.h" #include "Policies/SingletonImp.h" + INSTANTIATE_SINGLETON_1(Config); + Config::Config() : mIgnoreCase(true), mConf(NULL) { } + Config::~Config() { delete mConf; } + bool Config::SetSource(const char *file, bool ignorecase) { mIgnoreCase = ignorecase; mFilename = file; + return Reload(); } + bool Config::Reload() { delete mConf; + mConf = new DOTCONFDocument(mIgnoreCase ? DOTCONFDocument::CASEINSENSETIVE : DOTCONFDocument::CASESENSETIVE); + if (mConf->setContent(mFilename.c_str()) == -1) { delete mConf; mConf = NULL; return false; } + return true; } + std::string Config::GetStringDefault(const char * name, std::string def) { if(!mConf) @@ -58,6 +69,7 @@ std::string Config::GetStringDefault(const char * name, std::string def) return std::string(def); return std::string(node->getValue()); }; + bool Config::GetBoolDefault(const char * name, const bool def) { if(!mConf) @@ -73,6 +85,7 @@ bool Config::GetBoolDefault(const char * name, const bool def) else return false; }; + int32 Config::GetIntDefault(const char * name, const int32 def) { if(!mConf) @@ -82,6 +95,7 @@ int32 Config::GetIntDefault(const char * name, const int32 def) return def; return atoi(node->getValue()); }; + float Config::GetFloatDefault(const char * name, const float def) { if(!mConf) |