11 void Tags::appendFlat(std::vector<std::string>& out,
const std::string& tag)
18 void Tags::appendFlat(std::vector<std::string>& out,
const char* tag)
21 out.emplace_back(tag);
25 void Tags::appendFlat(std::vector<std::string>& out,
const std::vector<std::string>& tags)
27 for (
const auto& tag : tags) {
32 void Tags::appendFlat(std::vector<std::string>& out,
const std::initializer_list<std::string> tags)
34 for (
const auto& tag : tags) {
39 void Tags::appendQuery(std::vector<std::vector<std::string>>& out,
const std::string& tag)
46 void Tags::appendQuery(std::vector<std::vector<std::string>>& out,
const char* tag)
49 out.push_back({std::string(tag)});
53 void Tags::appendQuery(std::vector<std::vector<std::string>>& out,
const std::vector<std::string>& tags)
55 std::vector<std::string> group;
56 group.reserve(tags.size());
57 for (
const auto& tag : tags) {
63 out.push_back(std::move(group));
67 void Tags::appendQuery(std::vector<std::vector<std::string>>& out,
const std::initializer_list<std::string> tags)
69 std::vector<std::string> group;
70 group.reserve(tags.size());
71 for (
const auto& tag : tags) {
77 out.push_back(std::move(group));
87 if (_index.contains(tag)) {
99 bool Tags::add(
const std::vector<std::string>& tags)
101 bool changed =
false;
102 for (
const auto& tag : tags) {
107 if (_index.contains(tag)) {
113 _list.push_back(tag);
126 return add(std::vector<std::string>(tags));
131 return add(std::string(tag ? tag :
""));
140 if (!_index.contains(tag)) {
145 _list.erase(std::remove(_list.begin(), _list.end(), tag), _list.end());
154 bool changed =
false;
155 for (
const auto& tag : tags) {
160 if (!_index.contains(tag)) {
166 _list.erase(std::remove(_list.begin(), _list.end(), tag), _list.end());
179 return remove(std::vector<std::string>(tags));
184 return remove(std::string(tag ? tag :
""));
193 auto tagsCopy = _list;
197 for (
const std::string& tag : tagsCopy) {
205 return !tag.empty() && _index.contains(tag);
208 bool Tags::has(
const std::vector<std::string>& tags)
const
210 return hasInternal({tags});
213 bool Tags::has(std::initializer_list<std::string> tags)
const
215 return has(std::vector<std::string>(tags));
220 return has(std::string(tag ? tag :
""));
223 bool Tags::has(
const std::vector<std::vector<std::string>>& query)
const
225 return hasInternal(query);
228 bool Tags::hasInternal(
const std::vector<std::vector<std::string>>& query)
const
230 if (_list.empty() || query.empty()) {
234 for (
const auto& group : query) {
235 if (group.size() == 1) {
236 if (_index.contains(group[0])) {
242 bool allPresent =
true;
243 for (
const std::string& tag : group) {
244 if (!_index.contains(tag)) {
EventHandler * fire(const std::string &name, Args &&... args)