AttributeSet is a container for CEL attributes that are identified as unknown during expression evaluation.
| 33 | // AttributeSet is a container for CEL attributes that are identified as |
| 34 | // unknown during expression evaluation. |
| 35 | class AttributeSet final { |
| 36 | private: |
| 37 | using Container = absl::btree_set<Attribute>; |
| 38 | |
| 39 | public: |
| 40 | using value_type = typename Container::value_type; |
| 41 | using size_type = typename Container::size_type; |
| 42 | using iterator = typename Container::const_iterator; |
| 43 | using const_iterator = typename Container::const_iterator; |
| 44 | |
| 45 | AttributeSet() = default; |
| 46 | AttributeSet(const AttributeSet&) = default; |
| 47 | AttributeSet(AttributeSet&&) = default; |
| 48 | AttributeSet& operator=(const AttributeSet&) = default; |
| 49 | AttributeSet& operator=(AttributeSet&&) = default; |
| 50 | |
| 51 | explicit AttributeSet(absl::Span<const Attribute> attributes) { |
| 52 | for (const auto& attr : attributes) { |
| 53 | Add(attr); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | AttributeSet(const AttributeSet& set1, const AttributeSet& set2) |
| 58 | : attributes_(set1.attributes_) { |
| 59 | for (const auto& attr : set2.attributes_) { |
| 60 | Add(attr); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | iterator begin() const { return attributes_.begin(); } |
| 65 | |
| 66 | const_iterator cbegin() const { return attributes_.cbegin(); } |
| 67 | |
| 68 | iterator end() const { return attributes_.end(); } |
| 69 | |
| 70 | const_iterator cend() const { return attributes_.cend(); } |
| 71 | |
| 72 | size_type size() const { return attributes_.size(); } |
| 73 | |
| 74 | bool empty() const { return attributes_.empty(); } |
| 75 | |
| 76 | bool operator==(const AttributeSet& other) const { |
| 77 | return this == &other || attributes_ == other.attributes_; |
| 78 | } |
| 79 | |
| 80 | bool operator!=(const AttributeSet& other) const { |
| 81 | return !operator==(other); |
| 82 | } |
| 83 | |
| 84 | static AttributeSet Merge(const AttributeSet& set1, |
| 85 | const AttributeSet& set2) { |
| 86 | return AttributeSet(set1, set2); |
| 87 | } |
| 88 | |
| 89 | private: |
| 90 | friend class google::api::expr::runtime::AttributeUtility; |
| 91 | friend class UnknownValue; |
| 92 | friend class base_internal::UnknownSet; |
no outgoing calls