From be21321393a7ef6e56fcd520bce49096b0cd3ea8 Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Tue, 16 Aug 2011 10:06:16 -0300 Subject: [PATCH] ... --- src/framework/core/configs.cpp | 35 ++++++++++++++++++ src/framework/core/configs.h | 22 +++++++++++ src/otclient/core/.spritemanager.cpp.kate-swp | Bin 0 -> 127 bytes 3 files changed, 57 insertions(+) create mode 100644 src/framework/core/configs.cpp create mode 100644 src/framework/core/configs.h create mode 100644 src/otclient/core/.spritemanager.cpp.kate-swp diff --git a/src/framework/core/configs.cpp b/src/framework/core/configs.cpp new file mode 100644 index 00000000..b871055f --- /dev/null +++ b/src/framework/core/configs.cpp @@ -0,0 +1,35 @@ +#include "configs.h" +#include "resourcemanager.h" + +#include + +Configs g_configs; + +bool Configs::load(const std::string& fileName) +{ + m_fileName = fileName; + + if(!g_resources.fileExists(fileName)) + return false; + + try { + OTMLDocumentPtr doc = OTMLDocument::parse(fileName); + for(const OTMLNodePtr& child : doc->childNodes()) + m_confsMap[child->tag()] = child->value(); + } catch(std::exception& e) { + logError("ERROR: could not load configurations: ", e.what()); + return false; + } + + return true; +} + +bool Configs::save() +{ + if(!m_fileName.empty()) { + OTMLDocumentPtr doc = OTMLDocument::create(); + doc->write(m_confsMap); + return doc->save(m_fileName); + } + return false; +} diff --git a/src/framework/core/configs.h b/src/framework/core/configs.h new file mode 100644 index 00000000..097741f3 --- /dev/null +++ b/src/framework/core/configs.h @@ -0,0 +1,22 @@ +#ifndef CONFIGMANAGER_H +#define CONFIGMANAGER_H + +#include "declarations.h" + +class Configs +{ +public: + bool load(const std::string& fileName); + bool save(); + + void set(const std::string& key, const std::string& value) { m_confsMap[key] = value; } + std::string get(const std::string& key) { return m_confsMap[key]; } + +private: + std::string m_fileName; + std::map m_confsMap; +}; + +extern Configs g_configs; + +#endif diff --git a/src/otclient/core/.spritemanager.cpp.kate-swp b/src/otclient/core/.spritemanager.cpp.kate-swp new file mode 100644 index 0000000000000000000000000000000000000000..29acdc978e9889ac25ca6a2051bf49a9ddb82c5c GIT binary patch literal 127 zcmZQzV36@nEJ;-eE>A2_aLdd|RnS!kOD!tS%+FIW)H4VUXJBB617ZeGAdUwyfPh5- n2wa0