summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
authordeva <deva>2010-01-14 14:11:27 +0000
committerdeva <deva>2010-01-14 14:11:27 +0000
commit0485bd935b235e1162332ca145e7fbb6e5aecb3b (patch)
tree96708969f530428de2a9e01fd35dd97d5aa46893 /server
parent984d1dd9993aa5beffa4270b6421dea05ab04faa (diff)
Made EntityList able to handle several files with same macroname and version number, without corrupting the internal data structure (switched from map to multimap).
Diffstat (limited to 'server')
-rw-r--r--server/src/entitylist.cc4
-rw-r--r--server/src/entitylist.h3
-rw-r--r--server/src/macrolist.cc5
-rw-r--r--server/src/templatelist.cc3
4 files changed, 10 insertions, 5 deletions
diff --git a/server/src/entitylist.cc b/server/src/entitylist.cc
index 64bd49d..b84df61 100644
--- a/server/src/entitylist.cc
+++ b/server/src/entitylist.cc
@@ -139,8 +139,8 @@ bool EntityList::removeFile(std::string file)
while(j != i->second.end()) {
if(file == j->second) {
PRACRO_DEBUG(entitylist, "Removing file: %s\n", file.c_str());
- i->second.erase(j->first);
- if(i->second.size() == 0) erase(i->first);
+ i->second.erase(j);
+ if(i->second.size() == 0) erase(i);
return true;
}
j++;
diff --git a/server/src/entitylist.h b/server/src/entitylist.h
index b596c07..9185f67 100644
--- a/server/src/entitylist.h
+++ b/server/src/entitylist.h
@@ -30,6 +30,7 @@
#include <map>
#include <string>
+
#include "versionstr.h"
#include "mutex.h"
@@ -40,7 +41,7 @@
/**
* The Items contained in the EntityList.
*/
-typedef std::map<VersionStr, std::string> EntityListItem;
+typedef std::multimap<VersionStr, std::string> EntityListItem;
/**
* The EntityList class is intended for entity file caching, so that all entitys
diff --git a/server/src/macrolist.cc b/server/src/macrolist.cc
index 86584d4..9dadb12 100644
--- a/server/src/macrolist.cc
+++ b/server/src/macrolist.cc
@@ -27,6 +27,8 @@
*/
#include "macrolist.h"
+#include <utility>
+
#include "macroheaderparser.h"
#include "debug.h"
@@ -45,7 +47,8 @@ void MacroList::addFile(std::string file)
try {
parser.parse();
Macro *macro = parser.getMacro();
- (*this)[macro->attributes["name"]][VersionStr(macro->attributes["version"])] = file;
+ std::pair<VersionStr, std::string> p(VersionStr(macro->attributes["version"]), file);
+ (*this)[macro->attributes["name"]].insert(p);
} catch(Exception &e) {
PRACRO_WARN(macrolist, "Skipping %s: %s\n", file.c_str(), e.what());
}
diff --git a/server/src/templatelist.cc b/server/src/templatelist.cc
index b952467..0fc8ec5 100644
--- a/server/src/templatelist.cc
+++ b/server/src/templatelist.cc
@@ -44,7 +44,8 @@ void TemplateList::addFile(std::string file)
try {
parser.parse();
Template *templ = parser.getTemplate();
- (*this)[templ->attributes["name"]][VersionStr(templ->attributes["version"])] = file;
+ std::pair<VersionStr, std::string> p(VersionStr(templ->attributes["version"]), file);
+ (*this)[templ->attributes["name"]].insert(p);
} catch(Exception &e) {
PRACRO_WARN(templatelist, "Skipping %s: %s\n", file.c_str(), e.what());
}