2014-07-21 10:15:21 +00:00
|
|
|
#include "blacklist.hpp"
|
|
|
|
|
|
|
|
#include <algorithm>
|
2022-10-19 17:02:00 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
#include <apps/opencs/model/world/universalid.hpp>
|
2014-07-21 10:15:21 +00:00
|
|
|
|
2022-08-02 22:00:54 +00:00
|
|
|
#include <components/misc/strings/lower.hpp>
|
2014-07-21 10:15:21 +00:00
|
|
|
|
|
|
|
bool CSMDoc::Blacklist::isBlacklisted(const CSMWorld::UniversalId& id) const
|
|
|
|
{
|
|
|
|
std::map<CSMWorld::UniversalId::Type, std::vector<std::string>>::const_iterator iter = mIds.find(id.getType());
|
|
|
|
|
|
|
|
if (iter == mIds.end())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return std::binary_search(iter->second.begin(), iter->second.end(), Misc::StringUtils::lowerCase(id.getId()));
|
|
|
|
}
|
|
|
|
|
|
|
|
void CSMDoc::Blacklist::add(CSMWorld::UniversalId::Type type, const std::vector<std::string>& ids)
|
|
|
|
{
|
|
|
|
std::vector<std::string>& list = mIds[type];
|
|
|
|
|
2021-05-02 06:43:44 +00:00
|
|
|
size_t size = list.size();
|
2014-07-21 10:15:21 +00:00
|
|
|
|
|
|
|
list.resize(size + ids.size());
|
|
|
|
|
2022-07-02 22:02:29 +00:00
|
|
|
std::transform(ids.begin(), ids.end(), list.begin() + size,
|
|
|
|
[](const std::string& s) { return Misc::StringUtils::lowerCase(s); });
|
2014-07-21 10:15:21 +00:00
|
|
|
std::sort(list.begin(), list.end());
|
2015-03-11 14:54:45 +00:00
|
|
|
}
|