You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
779 B
38 lines
779 B
#include "configs.h"
|
|
#include "resources.h"
|
|
|
|
#include <otml/otml.h>
|
|
|
|
Configs g_configs;
|
|
|
|
bool Configs::load(const std::string& fileName)
|
|
{
|
|
m_fileName = fileName;
|
|
|
|
if(!g_resources.fileExists(fileName))
|
|
return false;
|
|
|
|
std::stringstream fin;
|
|
if(!g_resources.loadFile(fileName, fin))
|
|
return false;
|
|
|
|
try {
|
|
OTMLParser parser(fin, fileName);
|
|
parser.getDocument()->read(&m_confsMap);
|
|
} catch(OTMLException e) {
|
|
logError("ERROR: Malformed config file: ", e.what());
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
void Configs::save()
|
|
{
|
|
if(!m_fileName.empty()) {
|
|
OTMLEmitter emitter;
|
|
emitter.createDocument()->write(m_confsMap);
|
|
g_resources.saveFile(m_fileName, emitter.emitDocument());
|
|
}
|
|
}
|