mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 07:23:51 +00:00
split reclists find function into find and search functions (search can be used to check if an object does not exist, while find would see this as an error situation and would throw an exception)
This commit is contained in:
parent
2da51e5f5a
commit
f141fd0931
1 changed files with 37 additions and 3 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <assert.h>
|
||||
#include <stdexcept>
|
||||
|
||||
namespace ESMS
|
||||
{
|
||||
|
@ -45,7 +46,7 @@ namespace ESMS
|
|||
}
|
||||
|
||||
// Find the given object ID, or return NULL if not found.
|
||||
const X* find(const std::string &id) const
|
||||
const X* search(const std::string &id) const
|
||||
{
|
||||
std::string id2 = toLower (id);
|
||||
if(list.find(id2) == list.end())
|
||||
|
@ -53,6 +54,17 @@ namespace ESMS
|
|||
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(); }
|
||||
};
|
||||
|
||||
|
@ -76,7 +88,7 @@ namespace ESMS
|
|||
}
|
||||
|
||||
// Find the given object ID, or return NULL if not found.
|
||||
const X* find(const std::string &id) const
|
||||
const X* search(const std::string &id) const
|
||||
{
|
||||
std::string id2 = toLower (id);
|
||||
if(list.find(id2) == list.end())
|
||||
|
@ -84,6 +96,17 @@ namespace ESMS
|
|||
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(); }
|
||||
};
|
||||
|
||||
|
@ -177,7 +200,7 @@ namespace ESMS
|
|||
}
|
||||
|
||||
// Find the given object ID, or return NULL if not found.
|
||||
const X* find(const std::string &id) const
|
||||
const X* search(const std::string &id) const
|
||||
{
|
||||
std::string id2 = toLower (id);
|
||||
if(list.find(id2) == list.end())
|
||||
|
@ -185,6 +208,17 @@ namespace ESMS
|
|||
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(); }
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue