1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 10:23:56 +00:00
openmw/apps/opencs/model/world/scope.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

45 lines
1 KiB
C++
Raw Normal View History

#include "scope.hpp"
2022-10-19 17:02:00 +00:00
#include <string_view>
#include <components/esm/refid.hpp>
#include <components/misc/strings/algorithm.hpp>
namespace CSMWorld
{
namespace
{
struct GetScope
{
Scope operator()(ESM::StringRefId v) const
{
std::string_view namespace_;
const std::string::size_type i = v.getValue().find("::");
if (i != std::string::npos)
namespace_ = std::string_view(v.getValue()).substr(0, i);
if (Misc::StringUtils::ciEqual(namespace_, "project"))
return Scope_Project;
if (Misc::StringUtils::ciEqual(namespace_, "session"))
return Scope_Session;
return Scope_Content;
}
template <class T>
Scope operator()(const T& /*v*/) const
{
return Scope_Content;
}
};
}
}
CSMWorld::Scope CSMWorld::getScopeFromId(ESM::RefId id)
{
return visit(GetScope{}, id);
2015-03-11 14:54:45 +00:00
}