data: saving file contents to sqlite db
This commit is contained in:
@@ -18,6 +18,11 @@ std::shared_ptr<ConfigManager> ConfigManager::createAndLoad(const std::shared_pt
|
||||
return configManager;
|
||||
}
|
||||
|
||||
void ConfigManager::clear()
|
||||
{
|
||||
m_values.clear();
|
||||
}
|
||||
|
||||
bool ConfigManager::getValue(const std::string& key, std::string& value) const
|
||||
{
|
||||
std::multimap<std::string, std::string>::const_iterator it = m_values.find(key);
|
||||
@@ -246,13 +251,19 @@ bool ConfigManager::createXmlDocument(bool saveAsFile, const std::string filepat
|
||||
|
||||
for(std::multimap<std::string,std::string>::iterator it = m_values.begin(); it != m_values.end(); ++it)
|
||||
{
|
||||
if (!it->first.size() || !it->second.size())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
std::vector<std::string> tokens = utility::splitToVector(it->first, "/");
|
||||
|
||||
TiXmlElement* element = doc.RootElement();
|
||||
TiXmlElement* child;
|
||||
while(tokens.size() > 1)
|
||||
while (tokens.size() > 1)
|
||||
{
|
||||
child = element->FirstChildElement(tokens.front().c_str());
|
||||
if(!child)
|
||||
if (!child)
|
||||
{
|
||||
child = new TiXmlElement(tokens.front().c_str());
|
||||
element->LinkEndChild(child);
|
||||
|
||||
@@ -15,6 +15,8 @@ public:
|
||||
static std::shared_ptr<ConfigManager> createEmpty();
|
||||
static std::shared_ptr<ConfigManager> createAndLoad(const std::shared_ptr<TextAccess> textAccess);
|
||||
|
||||
void clear();
|
||||
|
||||
bool getValue(const std::string& key, std::string& value) const;
|
||||
bool getValue(const std::string& key, int& value) const;
|
||||
bool getValue(const std::string& key, float& value) const;
|
||||
@@ -46,6 +48,7 @@ private:
|
||||
|
||||
void parseSubtree(TiXmlNode* parentElement, const std::string& currentPath);
|
||||
bool createXmlDocument(bool saveAsFile, std::string filepath, std::string& output);
|
||||
|
||||
std::multimap<std::string, std::string> m_values;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#ifndef MESSAGE_SHOW_FILE_H
|
||||
#define MESSAGE_SHOW_FILE_H
|
||||
|
||||
#include "utility/file/FilePath.h"
|
||||
#include "utility/messaging/Message.h"
|
||||
#include "utility/types.h"
|
||||
|
||||
class MessageShowFile: public Message<MessageShowFile>
|
||||
class MessageShowFile
|
||||
: public Message<MessageShowFile>
|
||||
{
|
||||
public:
|
||||
MessageShowFile(const std::string& filePath, uint startLineNumber, uint endLineNumber)
|
||||
MessageShowFile(const FilePath& filePath, uint startLineNumber, uint endLineNumber)
|
||||
: filePath(filePath)
|
||||
, startLineNumber(startLineNumber)
|
||||
, endLineNumber(endLineNumber)
|
||||
@@ -19,7 +21,7 @@ public:
|
||||
return "MessageShowFile";
|
||||
}
|
||||
|
||||
const std::string filePath;
|
||||
const FilePath filePath;
|
||||
const uint startLineNumber;
|
||||
const uint endLineNumber;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user