Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
105 lines (79 loc) · 3.31 KB

File metadata and controls

105 lines (79 loc) · 3.31 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef THIRD_PARTY_CEL_CPP_BASE_FUNCTION_RESULT_SET_H_
#define THIRD_PARTY_CEL_CPP_BASE_FUNCTION_RESULT_SET_H_
#include <initializer_list>
#include <utility>
#include "absl/container/btree_set.h"
#include "base/function_result.h"
namespace google::api::expr::runtime {
class AttributeUtility;
} // namespace google::api::expr::runtime
namespace cel {
class UnknownValue;
namespace base_internal {
class UnknownSet;
}
// Represents a collection of unknown function results at a particular point in
// execution. Execution should advance further if this set of unknowns are
// provided. It may not advance if only a subset are provided.
// Set semantics use |IsEqualTo()| defined on |FunctionResult|.
class FunctionResultSet final {
private:
using Container = absl::btree_set<FunctionResult>;
public:
using value_type = typename Container::value_type;
using size_type = typename Container::size_type;
using iterator = typename Container::const_iterator;
using const_iterator = typename Container::const_iterator;
FunctionResultSet() = default;
FunctionResultSet(const FunctionResultSet&) = default;
FunctionResultSet(FunctionResultSet&&) = default;
FunctionResultSet& operator=(const FunctionResultSet&) = default;
FunctionResultSet& operator=(FunctionResultSet&&) = default;
// Merge constructor -- effectively union(lhs, rhs).
FunctionResultSet(const FunctionResultSet& lhs, const FunctionResultSet& rhs);
// Initialize with a single FunctionResult.
explicit FunctionResultSet(FunctionResult initial)
: function_results_{std::move(initial)} {}
FunctionResultSet(std::initializer_list<FunctionResult> il)
: function_results_(il) {}
iterator begin() const { return function_results_.begin(); }
const_iterator cbegin() const { return function_results_.cbegin(); }
iterator end() const { return function_results_.end(); }
const_iterator cend() const { return function_results_.cend(); }
size_type size() const { return function_results_.size(); }
bool empty() const { return function_results_.empty(); }
bool operator==(const FunctionResultSet& other) const {
return this == &other || function_results_ == other.function_results_;
}
bool operator!=(const FunctionResultSet& other) const {
return !operator==(other);
}
private:
friend class google::api::expr::runtime::AttributeUtility;
friend class UnknownValue;
friend class base_internal::UnknownSet;
void Add(const FunctionResult& function_result) {
function_results_.insert(function_result);
}
void Add(const FunctionResultSet& other) {
for (const auto& function_result : other) {
Add(function_result);
}
}
Container function_results_;
};
} // namespace cel
#endif // THIRD_PARTY_CEL_CPP_BASE_FUNCTION_RESULT_SET_H_
Morty Proxy This is a proxified and sanitized view of the page, visit original site.