|
|
|
@ -68,6 +68,44 @@ namespace ESMS
|
|
|
|
|
int getSize() { return list.size(); }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/// Modified version of RecListT for records, that need to store their own ID
|
|
|
|
|
template <typename X>
|
|
|
|
|
struct RecListWithIDT : RecList
|
|
|
|
|
{
|
|
|
|
|
typedef std::map<std::string,X> MapType;
|
|
|
|
|
|
|
|
|
|
MapType list;
|
|
|
|
|
|
|
|
|
|
// Load one object of this type
|
|
|
|
|
void load(ESMReader &esm, const std::string &id)
|
|
|
|
|
{
|
|
|
|
|
std::string id2 = toLower (id);
|
|
|
|
|
list[id2].load(esm, id2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Find the given object ID, or return NULL if not found.
|
|
|
|
|
const X* search(const std::string &id) const
|
|
|
|
|
{
|
|
|
|
|
std::string id2 = toLower (id);
|
|
|
|
|
if(list.find(id2) == list.end())
|
|
|
|
|
return NULL;
|
|
|
|
|
return &list.find(id2)->second;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Find the given object ID (throws an exception if not found)
|
|
|
|
|
const X* find(const std::string &id) const
|
|
|
|
|
{
|
|
|
|
|
const X *object = search (id);
|
|
|
|
|
|
|
|
|
|
if (!object)
|
|
|
|
|
throw std::runtime_error ("object " + id + " not found");
|
|
|
|
|
|
|
|
|
|
return object;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int getSize() { return list.size(); }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// The only difference to the above is a slight change to the load()
|
|
|
|
|
// function. We might merge these together later, and store the id
|
|
|
|
|
// in all the structs.
|
|
|
|
|