Blender V5.0
BKE_attribute_filters.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
12
13#include "BLI_set.hh"
14
15namespace blender::bke {
16
20template<typename Fn> struct AttributeFilterFromFunc : public AttributeFilter {
21 private:
22 Fn fn_;
23
24 static_assert(std::is_invocable_r_v<Result, Fn, StringRef>);
25
26 public:
27 constexpr AttributeFilterFromFunc(Fn fn) : fn_(std::move(fn)) {}
28
29 Result filter(const StringRef name) const override
30 {
31 return fn_(name);
32 }
33};
34
40{
41 return AttributeFilterFromFunc([filter, skip](const StringRef name) {
42 if (skip.contains(name)) {
44 }
45 return filter.filter(name);
46 });
47}
48
50template<typename StringT>
52{
53 return AttributeFilterFromFunc([filter, &skip](const StringRef name) {
54 if (skip.contains_as(name)) {
56 }
57 return filter.filter(name);
58 });
59}
60
66{
67 return AttributeFilterFromFunc([skip](const StringRef name) {
68 if (skip.contains(name)) {
70 }
72 });
73}
74
76template<typename StringT> inline auto attribute_filter_from_skip_ref(const Set<StringT> &skip)
77{
78 return AttributeFilterFromFunc([&skip](const StringRef name) {
79 if (skip.contains_as(name)) {
81 }
83 });
84}
85
86} // namespace blender::bke
bool contains_as(const ForwardKey &key) const
Definition BLI_set.hh:314
constexpr bool contains(const T &value) const
Definition BLI_span.hh:277
#define filter
auto attribute_filter_from_skip_ref(const Span< StringRef > skip)
auto attribute_filter_with_skip_ref(AttributeFilter filter, const Span< StringRef > skip)
const char * name
Result filter(const StringRef name) const override