MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / ComprehensionSlot

Class ComprehensionSlot

eval/eval/comprehension_slots.h:32–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30namespace google::api::expr::runtime {
31
32class ComprehensionSlot final {
33 public:
34 ComprehensionSlot() = default;
35 ComprehensionSlot(const ComprehensionSlot&) = delete;
36 ComprehensionSlot(ComprehensionSlot&&) = delete;
37 ComprehensionSlot& operator=(const ComprehensionSlot&) = delete;
38 ComprehensionSlot& operator=(ComprehensionSlot&&) = delete;
39
40 const cel::Value& value() const ABSL_ATTRIBUTE_LIFETIME_BOUND {
41 ABSL_DCHECK(Has());
42
43 return value_;
44 }
45
46 cel::Value* absl_nonnull mutable_value() ABSL_ATTRIBUTE_LIFETIME_BOUND {
47 ABSL_DCHECK(Has());
48
49 return &value_;
50 }
51
52 const AttributeTrail& attribute() const ABSL_ATTRIBUTE_LIFETIME_BOUND {
53 ABSL_DCHECK(Has());
54
55 return attribute_;
56 }
57
58 AttributeTrail* absl_nonnull mutable_attribute()
59 ABSL_ATTRIBUTE_LIFETIME_BOUND {
60 ABSL_DCHECK(Has());
61
62 return &attribute_;
63 }
64
65 bool Has() const { return has_; }
66
67 void Set() { Set(cel::NullValue(), absl::nullopt); }
68
69 template <typename V>
70 void Set(V&& value) {
71 Set(std::forward<V>(value), absl::nullopt);
72 }
73
74 template <typename V, typename A>
75 void Set(V&& value, A&& attribute) {
76 value_ = std::forward<V>(value);
77 attribute_ = std::forward<A>(attribute);
78 has_ = true;
79 }
80
81 void Clear() {
82 if (has_) {
83 value_ = cel::NullValue();
84 attribute_ = absl::nullopt;
85 has_ = false;
86 }
87 }
88
89 private:

Callers

nothing calls this directly

Calls 1

HasFunction · 0.50

Tested by

no test coverage detected