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

Class Value

common/value.h:99–2554  ·  view source on GitHub ↗

`Value` is a composition type which encompasses all values supported by the Common Expression Language. When default constructed or moved, `Value` is in a known but invalid state. Any attempt to use it from then on, without assigning another type, is undefined behavior. In debug builds, we do our best to fail.

Source from the content-addressed store, hash-verified

97// assigning another type, is undefined behavior. In debug builds, we do our
98// best to fail.
99class Value final : private common_internal::ValueMixin<Value> {
100 public:
101 // Returns an appropriate `Value` for the dynamic protobuf enum. For open
102 // enums, returns `cel::IntValue`. For closed enums, returns `cel::ErrorValue`
103 // if the value is not present in the enum otherwise returns `cel::IntValue`.
104 static Value Enum(const google::protobuf::EnumValueDescriptor* absl_nonnull value);
105 static Value Enum(const google::protobuf::EnumDescriptor* absl_nonnull type,
106 int32_t number);
107
108 // SFINAE overload for generated protobuf enums which are not well-known.
109 // Always returns `cel::IntValue`.
110 template <typename T>
111 static common_internal::EnableIfGeneratedEnum<T, IntValue> Enum(T value) {
112 return IntValue(value);
113 }
114
115 // SFINAE overload for google::protobuf::NullValue. Always returns
116 // `cel::NullValue`.
117 template <typename T>
118 static common_internal::EnableIfWellKnownEnum<T, google::protobuf::NullValue,
119 NullValue>
120 Enum(T) {
121 return NullValue();
122 }
123
124 // Returns an appropriate `Value` for the dynamic protobuf message. If
125 // `message` is the well known type `google.protobuf.Any`, `descriptor_pool`
126 // and `message_factory` will be used to unpack the value. Both must outlive
127 // the resulting value and any of its shallow copies. Otherwise the message is
128 // copied using `arena`.
129 static Value FromMessage(
130 const google::protobuf::Message& message,
131 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool
132 ABSL_ATTRIBUTE_LIFETIME_BOUND,
133 google::protobuf::MessageFactory* absl_nonnull message_factory
134 ABSL_ATTRIBUTE_LIFETIME_BOUND,
135 google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND);
136 static Value FromMessage(
137 google::protobuf::Message&& message,
138 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool
139 ABSL_ATTRIBUTE_LIFETIME_BOUND,
140 google::protobuf::MessageFactory* absl_nonnull message_factory
141 ABSL_ATTRIBUTE_LIFETIME_BOUND,
142 google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND);
143
144 // Returns an appropriate `Value` for the dynamic protobuf message. If
145 // `message` is the well known type `google.protobuf.Any`, `descriptor_pool`
146 // and `message_factory` will be used to unpack the value. Both must outlive
147 // the resulting value and any of its shallow copies. Otherwise the message is
148 // borrowed (no copying). If the message is on an arena, that arena will be
149 // attributed as the owner. Otherwise `arena` is used.
150 static Value WrapMessage(
151 const google::protobuf::Message* absl_nonnull message ABSL_ATTRIBUTE_LIFETIME_BOUND,
152 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool
153 ABSL_ATTRIBUTE_LIFETIME_BOUND,
154 google::protobuf::MessageFactory* absl_nonnull message_factory
155 ABSL_ATTRIBUTE_LIFETIME_BOUND,
156 google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND);

Callers 6

CloneMethod · 0.70
TESTFunction · 0.70
InitializeMethod · 0.50
IsInitializedMethod · 0.50
ListFirstFunction · 0.50
ListLastFunction · 0.50

Calls 15

AsOptionalFunction · 0.85
GetStringFunction · 0.85
ToValueVariantMethod · 0.45
AssignMethod · 0.45
AsBytesMethod · 0.45
AsErrorMethod · 0.45
AsOpaqueMethod · 0.45
AsOptionalMethod · 0.45
AsParsedJsonListMethod · 0.45
AsParsedJsonMapMethod · 0.45
AsCustomListMethod · 0.45
AsCustomMapMethod · 0.45

Tested by 1

TESTFunction · 0.56