-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRenderTagList.cpp
More file actions
38 lines (36 loc) · 907 Bytes
/
Copy pathRenderTagList.cpp
File metadata and controls
38 lines (36 loc) · 907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "RenderTagList.h"
#include <algorithm>
#include <cassert>
namespace sh::render
{
SH_RENDER_API void RenderTagList::AddTag(const std::string& name)
{
assert(tags.size() < 32);
uint32_t nextId = 1 << tags.size();
tags.push_back({ name, nextId });
}
SH_RENDER_API auto RenderTagList::GetTagId(const std::string& name) const -> uint32_t
{
auto it = std::find_if(tags.begin(), tags.end(), [&](const Tag& tag)
{
return tag.name == name;
});
if (it == tags.end())
return 0;
return it->id;
}
SH_RENDER_API auto RenderTagList::GetTagName(uint32_t tagId) const -> const std::string*
{
auto it = std::find_if(tags.begin(), tags.end(), [&](const Tag& tag)
{
return tag.id == tagId;
});
if (it == tags.end())
return nullptr;
return &it->name;
}
SH_RENDER_API auto RenderTagList::GetAllTags() const -> const std::vector<Tag>&
{
return tags;
}
}//namespace