/proc/self/cwd/common/value.h
Line | Count | Source |
1 | | // Copyright 2023 Google LLC |
2 | | // |
3 | | // Licensed under the Apache License, Version 2.0 (the "License"); |
4 | | // you may not use this file except in compliance with the License. |
5 | | // You may obtain a copy of the License at |
6 | | // |
7 | | // https://www.apache.org/licenses/LICENSE-2.0 |
8 | | // |
9 | | // Unless required by applicable law or agreed to in writing, software |
10 | | // distributed under the License is distributed on an "AS IS" BASIS, |
11 | | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | | // See the License for the specific language governing permissions and |
13 | | // limitations under the License. |
14 | | |
15 | | #ifndef THIRD_PARTY_CEL_CPP_COMMON_VALUE_H_ |
16 | | #define THIRD_PARTY_CEL_CPP_COMMON_VALUE_H_ |
17 | | |
18 | | #include <cstddef> |
19 | | #include <cstdint> |
20 | | #include <cstring> |
21 | | #include <memory> |
22 | | #include <optional> |
23 | | #include <ostream> |
24 | | #include <string> |
25 | | #include <type_traits> |
26 | | #include <utility> |
27 | | |
28 | | #include "absl/base/attributes.h" |
29 | | #include "absl/base/nullability.h" |
30 | | #include "absl/log/absl_check.h" |
31 | | #include "absl/meta/type_traits.h" |
32 | | #include "absl/status/status.h" |
33 | | #include "absl/status/statusor.h" |
34 | | #include "absl/strings/string_view.h" |
35 | | #include "absl/types/optional.h" |
36 | | #include "absl/types/span.h" |
37 | | #include "absl/utility/utility.h" |
38 | | #include "base/attribute.h" |
39 | | #include "common/arena.h" |
40 | | #include "common/native_type.h" |
41 | | #include "common/optional_ref.h" |
42 | | #include "common/type.h" |
43 | | #include "common/typeinfo.h" |
44 | | #include "common/value_kind.h" |
45 | | #include "common/values/bool_value.h" // IWYU pragma: export |
46 | | #include "common/values/bytes_value.h" // IWYU pragma: export |
47 | | #include "common/values/bytes_value_input_stream.h" // IWYU pragma: export |
48 | | #include "common/values/bytes_value_output_stream.h" // IWYU pragma: export |
49 | | #include "common/values/custom_list_value.h" // IWYU pragma: export |
50 | | #include "common/values/custom_map_value.h" // IWYU pragma: export |
51 | | #include "common/values/custom_struct_value.h" // IWYU pragma: export |
52 | | #include "common/values/double_value.h" // IWYU pragma: export |
53 | | #include "common/values/duration_value.h" // IWYU pragma: export |
54 | | #include "common/values/enum_value.h" // IWYU pragma: export |
55 | | #include "common/values/error_value.h" // IWYU pragma: export |
56 | | #include "common/values/int_value.h" // IWYU pragma: export |
57 | | #include "common/values/list_value.h" // IWYU pragma: export |
58 | | #include "common/values/map_value.h" // IWYU pragma: export |
59 | | #include "common/values/message_value.h" // IWYU pragma: export |
60 | | #include "common/values/null_value.h" // IWYU pragma: export |
61 | | #include "common/values/opaque_value.h" // IWYU pragma: export |
62 | | #include "common/values/optional_value.h" // IWYU pragma: export |
63 | | #include "common/values/parsed_json_list_value.h" // IWYU pragma: export |
64 | | #include "common/values/parsed_json_map_value.h" // IWYU pragma: export |
65 | | #include "common/values/parsed_map_field_value.h" // IWYU pragma: export |
66 | | #include "common/values/parsed_message_value.h" // IWYU pragma: export |
67 | | #include "common/values/parsed_repeated_field_value.h" // IWYU pragma: export |
68 | | #include "common/values/string_value.h" // IWYU pragma: export |
69 | | #include "common/values/struct_value.h" // IWYU pragma: export |
70 | | #include "common/values/timestamp_value.h" // IWYU pragma: export |
71 | | #include "common/values/type_value.h" // IWYU pragma: export |
72 | | #include "common/values/uint_value.h" // IWYU pragma: export |
73 | | #include "common/values/unknown_value.h" // IWYU pragma: export |
74 | | #include "common/values/value_variant.h" |
75 | | #include "common/values/values.h" |
76 | | #include "internal/status_macros.h" |
77 | | #include "runtime/runtime_options.h" |
78 | | #include "google/protobuf/arena.h" |
79 | | #include "google/protobuf/descriptor.h" |
80 | | #include "google/protobuf/generated_enum_reflection.h" |
81 | | #include "google/protobuf/io/zero_copy_stream.h" |
82 | | #include "google/protobuf/map_field.h" |
83 | | #include "google/protobuf/message.h" |
84 | | |
85 | | #pragma push_macro("GetMessage") |
86 | | #ifdef GetMessage |
87 | | // GetMessage in windows API headers might be defined as a macro. Depending on |
88 | | // ordering, might cause issues with Value::GetMessage or |
89 | | // google::protobuf::Reflection::GetMessage. |
90 | | #undef GetMessage |
91 | | #endif |
92 | | |
93 | | namespace cel { |
94 | | |
95 | | // `Value` is a composition type which encompasses all values supported by the |
96 | | // Common Expression Language. When default constructed or moved, `Value` is in |
97 | | // a known but invalid state. Any attempt to use it from then on, without |
98 | | // assigning another type, is undefined behavior. In debug builds, we do our |
99 | | // best to fail. |
100 | | class Value final : private common_internal::ValueMixin<Value> { |
101 | | public: |
102 | | // Returns an appropriate `Value` for the dynamic protobuf enum. For open |
103 | | // enums, returns `cel::IntValue`. For closed enums, returns `cel::ErrorValue` |
104 | | // if the value is not present in the enum otherwise returns `cel::IntValue`. |
105 | | static Value Enum(const google::protobuf::EnumValueDescriptor* absl_nonnull value); |
106 | | ABSL_DEPRECATED("Use overload which takes an arena pointer") |
107 | | static Value Enum(const google::protobuf::EnumDescriptor* absl_nonnull type, |
108 | | int32_t number); |
109 | | static Value Enum(const google::protobuf::EnumDescriptor* absl_nonnull type, |
110 | | int32_t number, google::protobuf::Arena* absl_nonnull arena); |
111 | | |
112 | | // SFINAE overload for generated protobuf enums which are not well-known. |
113 | | // Always returns `cel::IntValue`. |
114 | | template <typename T> |
115 | | static common_internal::EnableIfGeneratedEnum<T, IntValue> Enum(T value) { |
116 | | return IntValue(value); |
117 | | } |
118 | | |
119 | | // SFINAE overload for google::protobuf::NullValue. Always returns |
120 | | // `cel::NullValue`. |
121 | | template <typename T> |
122 | | static common_internal::EnableIfWellKnownEnum<T, google::protobuf::NullValue, |
123 | | NullValue> |
124 | | Enum(T) { |
125 | | return NullValue(); |
126 | | } |
127 | | |
128 | | // Returns an appropriate `Value` for the dynamic protobuf message. If |
129 | | // `message` is the well known type `google.protobuf.Any`, `descriptor_pool` |
130 | | // and `message_factory` will be used to unpack the value. Both must outlive |
131 | | // the resulting value and any of its shallow copies. Otherwise the message is |
132 | | // copied using `arena`. |
133 | | static Value FromMessage( |
134 | | const google::protobuf::Message& message, |
135 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool |
136 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
137 | | google::protobuf::MessageFactory* absl_nonnull message_factory |
138 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
139 | | google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND); |
140 | | static Value FromMessage( |
141 | | google::protobuf::Message&& message, |
142 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool |
143 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
144 | | google::protobuf::MessageFactory* absl_nonnull message_factory |
145 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
146 | | google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND); |
147 | | |
148 | | // Returns an appropriate `Value` for the dynamic protobuf message. If |
149 | | // `message` is the well known type `google.protobuf.Any`, `descriptor_pool` |
150 | | // and `message_factory` will be used to unpack the value. Both must outlive |
151 | | // the resulting value and any of its shallow copies. Otherwise the message is |
152 | | // borrowed (no copying). If the message is on an arena, that arena will be |
153 | | // attributed as the owner. Otherwise `arena` is used. |
154 | | static Value WrapMessage( |
155 | | const google::protobuf::Message* absl_nonnull message ABSL_ATTRIBUTE_LIFETIME_BOUND, |
156 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool |
157 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
158 | | google::protobuf::MessageFactory* absl_nonnull message_factory |
159 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
160 | | google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND); |
161 | | |
162 | | // Returns an appropriate `Value` for the dynamic protobuf message. If |
163 | | // `message` is the well known type `google.protobuf.Any`, `descriptor_pool` |
164 | | // and `message_factory` will be used to unpack the value. Both must outlive |
165 | | // the resulting value and any of its shallow copies. Otherwise the message is |
166 | | // borrowed (no copying). This function does not attempt to validate arena |
167 | | // ownership of a dynamic message that was not unpacked from a well known |
168 | | // type. Caller is responsible for ensuring the resulting value and any |
169 | | // derived values do not outlive the input message. |
170 | | static Value WrapMessageUnsafe( |
171 | | const google::protobuf::Message* absl_nonnull message ABSL_ATTRIBUTE_LIFETIME_BOUND, |
172 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool |
173 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
174 | | google::protobuf::MessageFactory* absl_nonnull message_factory |
175 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
176 | | google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND); |
177 | | |
178 | | // Returns an appropriate `Value` for the dynamic protobuf message field. If |
179 | | // `field` in `message` is the well known type `google.protobuf.Any`, |
180 | | // `descriptor_pool` and `message_factory` will be used to unpack the value. |
181 | | // Both must outlive the resulting value and any of its shallow copies. |
182 | | // Otherwise the field is borrowed (no copying). If the message is on an |
183 | | // arena, that arena will be attributed as the owner. Otherwise `arena` is |
184 | | // used. |
185 | | static Value WrapField( |
186 | | ProtoWrapperTypeOptions wrapper_type_options, |
187 | | const google::protobuf::Message* absl_nonnull message ABSL_ATTRIBUTE_LIFETIME_BOUND, |
188 | | const google::protobuf::FieldDescriptor* absl_nonnull field |
189 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
190 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool |
191 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
192 | | google::protobuf::MessageFactory* absl_nonnull message_factory |
193 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
194 | | google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND); |
195 | | static Value WrapField( |
196 | | const google::protobuf::Message* absl_nonnull message ABSL_ATTRIBUTE_LIFETIME_BOUND, |
197 | | const google::protobuf::FieldDescriptor* absl_nonnull field |
198 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
199 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool |
200 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
201 | | google::protobuf::MessageFactory* absl_nonnull message_factory |
202 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
203 | 0 | google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND) { |
204 | 0 | return WrapField(ProtoWrapperTypeOptions::kUnsetNull, message, field, |
205 | 0 | descriptor_pool, message_factory, arena); |
206 | 0 | } |
207 | | |
208 | | // Returns an appropriate `Value` for the dynamic protobuf message field. If |
209 | | // `field` in `message` is the well known type `google.protobuf.Any`, |
210 | | // `descriptor_pool` and `message_factory` will be used to unpack the value. |
211 | | // Both must outlive the resulting value and any of its shallow copies. |
212 | | // Otherwise the field is borrowed (no copying). Caller is responsible for |
213 | | // ensuring the resulting value and any derived values do not outlive the |
214 | | // input message. |
215 | | static Value WrapFieldUnsafe( |
216 | | ProtoWrapperTypeOptions wrapper_type_options, |
217 | | const google::protobuf::Message* absl_nonnull message ABSL_ATTRIBUTE_LIFETIME_BOUND, |
218 | | const google::protobuf::FieldDescriptor* absl_nonnull field |
219 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
220 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool |
221 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
222 | | google::protobuf::MessageFactory* absl_nonnull message_factory |
223 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
224 | | google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND); |
225 | | |
226 | | // Returns an appropriate `Value` for the dynamic protobuf message repeated |
227 | | // field. If `field` in `message` is the well known type |
228 | | // `google.protobuf.Any`, `descriptor_pool` and `message_factory` will be used |
229 | | // to unpack the value. Both must outlive the resulting value and any of its |
230 | | // shallow copies. |
231 | | static Value WrapRepeatedField( |
232 | | int index, |
233 | | const google::protobuf::Message* absl_nonnull message ABSL_ATTRIBUTE_LIFETIME_BOUND, |
234 | | const google::protobuf::FieldDescriptor* absl_nonnull field |
235 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
236 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool |
237 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
238 | | google::protobuf::MessageFactory* absl_nonnull message_factory |
239 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
240 | | google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND); |
241 | | |
242 | | // Returns an appropriate `Value` for the dynamic protobuf message repeated |
243 | | // field. If `field` in `message` is the well known type |
244 | | // `google.protobuf.Any`, `descriptor_pool` and `message_factory` will be used |
245 | | // to unpack the value. Both must outlive the resulting value and any of its |
246 | | // shallow copies. |
247 | | static Value WrapRepeatedFieldUnsafe( |
248 | | int index, |
249 | | const google::protobuf::Message* absl_nonnull message ABSL_ATTRIBUTE_LIFETIME_BOUND, |
250 | | const google::protobuf::FieldDescriptor* absl_nonnull field |
251 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
252 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool |
253 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
254 | | google::protobuf::MessageFactory* absl_nonnull message_factory |
255 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
256 | | google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND); |
257 | | |
258 | | // Returns an appropriate `StringValue` for the dynamic protobuf message map |
259 | | // field key. The map field key must be a string or the behavior is undefined. |
260 | | static StringValue WrapMapFieldKeyString( |
261 | | const google::protobuf::MapKey& key, |
262 | | const google::protobuf::Message* absl_nonnull message ABSL_ATTRIBUTE_LIFETIME_BOUND, |
263 | | google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND); |
264 | | |
265 | | // Returns an appropriate `Value` for the dynamic protobuf message map |
266 | | // field value. If `field` in `message`, which is `value`, is the well known |
267 | | // type `google.protobuf.Any`, `descriptor_pool` and `message_factory` will be |
268 | | // used to unpack the value. Both must outlive the resulting value and any of |
269 | | // its shallow copies. |
270 | | static Value WrapMapFieldValue( |
271 | | const google::protobuf::MapValueConstRef& value, |
272 | | const google::protobuf::Message* absl_nonnull message ABSL_ATTRIBUTE_LIFETIME_BOUND, |
273 | | const google::protobuf::FieldDescriptor* absl_nonnull field |
274 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
275 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool |
276 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
277 | | google::protobuf::MessageFactory* absl_nonnull message_factory |
278 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
279 | | google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND); |
280 | | |
281 | | // Returns an appropriate `Value` for the dynamic protobuf message map |
282 | | // field value. If `field` in `message`, which is `value`, is the well known |
283 | | // type `google.protobuf.Any`, `descriptor_pool` and `message_factory` will be |
284 | | // used to unpack the value. Both must outlive the resulting value and any of |
285 | | // its shallow copies. Caller is responsible for ensuring the resulting value |
286 | | // and any derived values do not outlive the input message. |
287 | | static Value WrapMapFieldValueUnsafe( |
288 | | const google::protobuf::MapValueConstRef& value, |
289 | | const google::protobuf::Message* absl_nonnull message ABSL_ATTRIBUTE_LIFETIME_BOUND, |
290 | | const google::protobuf::FieldDescriptor* absl_nonnull field |
291 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
292 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool |
293 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
294 | | google::protobuf::MessageFactory* absl_nonnull message_factory |
295 | | ABSL_ATTRIBUTE_LIFETIME_BOUND, |
296 | | google::protobuf::Arena* absl_nonnull arena ABSL_ATTRIBUTE_LIFETIME_BOUND); |
297 | | |
298 | 3.80M | Value() = default; |
299 | | Value(const Value&) = default; |
300 | | Value& operator=(const Value&) = default; |
301 | | |
302 | | // NOLINTNEXTLINE(google-explicit-constructor) |
303 | 474k | Value(const ListValue& value) : variant_(value.ToValueVariant()) {} |
304 | | |
305 | | // NOLINTNEXTLINE(google-explicit-constructor) |
306 | 1.88M | Value& operator=(const ListValue& value) { |
307 | 1.88M | variant_ = value.ToValueVariant(); |
308 | 1.88M | return *this; |
309 | 1.88M | } |
310 | | |
311 | | // NOLINTNEXTLINE(google-explicit-constructor) |
312 | 708k | Value(const MapValue& value) : variant_(value.ToValueVariant()) {} |
313 | | |
314 | | // NOLINTNEXTLINE(google-explicit-constructor) |
315 | 0 | Value& operator=(const MapValue& value) { |
316 | 0 | variant_ = value.ToValueVariant(); |
317 | 0 | return *this; |
318 | 0 | } |
319 | | |
320 | | // NOLINTNEXTLINE(google-explicit-constructor) |
321 | 0 | Value(const StructValue& value) : variant_(value.ToValueVariant()) {} |
322 | | |
323 | | // NOLINTNEXTLINE(google-explicit-constructor) |
324 | 0 | Value& operator=(const StructValue& value) { |
325 | 0 | variant_ = value.ToValueVariant(); |
326 | 0 | return *this; |
327 | 0 | } |
328 | | |
329 | | // NOLINTNEXTLINE(google-explicit-constructor) |
330 | 0 | Value(const MessageValue& value) : variant_(value.ToValueVariant()) {} |
331 | | |
332 | | // NOLINTNEXTLINE(google-explicit-constructor) |
333 | 0 | Value& operator=(const MessageValue& value) { |
334 | 0 | variant_ = value.ToValueVariant(); |
335 | 0 | return *this; |
336 | 0 | } |
337 | | |
338 | | // NOLINTNEXTLINE(google-explicit-constructor) |
339 | | Value(const OptionalValue& value) |
340 | | : variant_(absl::in_place_type<OpaqueValue>, |
341 | 0 | static_cast<const OpaqueValue&>(value)) {} |
342 | | |
343 | | // NOLINTNEXTLINE(google-explicit-constructor) |
344 | 0 | Value& operator=(const OptionalValue& value) { |
345 | 0 | variant_.Assign(static_cast<const OpaqueValue&>(value)); |
346 | 0 | return *this; |
347 | 0 | } |
348 | | |
349 | | template <typename T, |
350 | | typename = std::enable_if_t< |
351 | | common_internal::IsValueAlternativeV<absl::remove_cvref_t<T>>>> |
352 | | // NOLINTNEXTLINE(google-explicit-constructor) |
353 | | Value(T&& alternative) noexcept |
354 | 14.2M | : variant_(absl::in_place_type<absl::remove_cvref_t<T>>, |
355 | 14.2M | std::forward<T>(alternative)) {}cel::Value::Value<cel::ErrorValue, void>(cel::ErrorValue&&) Line | Count | Source | 354 | 9.16M | : variant_(absl::in_place_type<absl::remove_cvref_t<T>>, | 355 | 9.16M | std::forward<T>(alternative)) {} |
cel::Value::Value<cel::IntValue, void>(cel::IntValue&&) Line | Count | Source | 354 | 1.14M | : variant_(absl::in_place_type<absl::remove_cvref_t<T>>, | 355 | 1.14M | std::forward<T>(alternative)) {} |
cel::Value::Value<cel::UintValue, void>(cel::UintValue&&) Line | Count | Source | 354 | 2.11M | : variant_(absl::in_place_type<absl::remove_cvref_t<T>>, | 355 | 2.11M | std::forward<T>(alternative)) {} |
cel::Value::Value<cel::BoolValue, void>(cel::BoolValue&&) Line | Count | Source | 354 | 550k | : variant_(absl::in_place_type<absl::remove_cvref_t<T>>, | 355 | 550k | std::forward<T>(alternative)) {} |
cel::Value::Value<cel::StringValue, void>(cel::StringValue&&) Line | Count | Source | 354 | 20.9k | : variant_(absl::in_place_type<absl::remove_cvref_t<T>>, | 355 | 20.9k | std::forward<T>(alternative)) {} |
cel::Value::Value<cel::TypeValue, void>(cel::TypeValue&&) Line | Count | Source | 354 | 10.0k | : variant_(absl::in_place_type<absl::remove_cvref_t<T>>, | 355 | 10.0k | std::forward<T>(alternative)) {} |
Unexecuted instantiation: cel::Value::Value<cel::UnknownValue&, void>(cel::UnknownValue&) cel::Value::Value<cel::StringValue const&, void>(cel::StringValue const&) Line | Count | Source | 354 | 67.2k | : variant_(absl::in_place_type<absl::remove_cvref_t<T>>, | 355 | 67.2k | std::forward<T>(alternative)) {} |
cel::Value::Value<cel::NullValue, void>(cel::NullValue&&) Line | Count | Source | 354 | 1.22k | : variant_(absl::in_place_type<absl::remove_cvref_t<T>>, | 355 | 1.22k | std::forward<T>(alternative)) {} |
cel::Value::Value<cel::DoubleValue, void>(cel::DoubleValue&&) Line | Count | Source | 354 | 65.6k | : variant_(absl::in_place_type<absl::remove_cvref_t<T>>, | 355 | 65.6k | std::forward<T>(alternative)) {} |
cel::Value::Value<cel::BytesValue, void>(cel::BytesValue&&) Line | Count | Source | 354 | 13.4k | : variant_(absl::in_place_type<absl::remove_cvref_t<T>>, | 355 | 13.4k | std::forward<T>(alternative)) {} |
cel::Value::Value<cel::DurationValue, void>(cel::DurationValue&&) Line | Count | Source | 354 | 48.5k | : variant_(absl::in_place_type<absl::remove_cvref_t<T>>, | 355 | 48.5k | std::forward<T>(alternative)) {} |
cel::Value::Value<cel::TimestampValue, void>(cel::TimestampValue&&) Line | Count | Source | 354 | 31.3k | : variant_(absl::in_place_type<absl::remove_cvref_t<T>>, | 355 | 31.3k | std::forward<T>(alternative)) {} |
Unexecuted instantiation: cel::Value::Value<cel::UnknownValue, void>(cel::UnknownValue&&) Unexecuted instantiation: cel::Value::Value<cel::OpaqueValue const&, void>(cel::OpaqueValue const&) cel::Value::Value<cel::ParsedJsonListValue, void>(cel::ParsedJsonListValue&&) Line | Count | Source | 354 | 414k | : variant_(absl::in_place_type<absl::remove_cvref_t<T>>, | 355 | 414k | std::forward<T>(alternative)) {} |
cel::Value::Value<cel::ParsedJsonMapValue, void>(cel::ParsedJsonMapValue&&) Line | Count | Source | 354 | 18.3k | : variant_(absl::in_place_type<absl::remove_cvref_t<T>>, | 355 | 18.3k | std::forward<T>(alternative)) {} |
cel::Value::Value<cel::CustomListValue&, void>(cel::CustomListValue&) Line | Count | Source | 354 | 79 | : variant_(absl::in_place_type<absl::remove_cvref_t<T>>, | 355 | 79 | std::forward<T>(alternative)) {} |
cel::Value::Value<cel::CustomMapValue&, void>(cel::CustomMapValue&) Line | Count | Source | 354 | 1 | : variant_(absl::in_place_type<absl::remove_cvref_t<T>>, | 355 | 1 | std::forward<T>(alternative)) {} |
cel::Value::Value<cel::ParsedMessageValue&, void>(cel::ParsedMessageValue&) Line | Count | Source | 354 | 26.7k | : variant_(absl::in_place_type<absl::remove_cvref_t<T>>, | 355 | 26.7k | std::forward<T>(alternative)) {} |
Unexecuted instantiation: cel::Value::Value<cel::common_internal::LegacyStructValue, void>(cel::common_internal::LegacyStructValue&&) Unexecuted instantiation: cel::Value::Value<cel::NullValue const&, void>(cel::NullValue const&) Unexecuted instantiation: cel::Value::Value<cel::BoolValue const&, void>(cel::BoolValue const&) Unexecuted instantiation: cel::Value::Value<cel::IntValue const&, void>(cel::IntValue const&) Unexecuted instantiation: cel::Value::Value<cel::UintValue const&, void>(cel::UintValue const&) Unexecuted instantiation: cel::Value::Value<cel::DoubleValue const&, void>(cel::DoubleValue const&) Unexecuted instantiation: cel::Value::Value<cel::DurationValue const&, void>(cel::DurationValue const&) Unexecuted instantiation: cel::Value::Value<cel::TimestampValue const&, void>(cel::TimestampValue const&) Unexecuted instantiation: cel::Value::Value<cel::TypeValue const&, void>(cel::TypeValue const&) Unexecuted instantiation: cel::Value::Value<cel::common_internal::LegacyListValue const&, void>(cel::common_internal::LegacyListValue const&) Unexecuted instantiation: cel::Value::Value<cel::ParsedRepeatedFieldValue, void>(cel::ParsedRepeatedFieldValue&&) Unexecuted instantiation: cel::Value::Value<cel::CustomListValue, void>(cel::CustomListValue&&) Unexecuted instantiation: cel::Value::Value<cel::common_internal::LegacyMapValue const&, void>(cel::common_internal::LegacyMapValue const&) Unexecuted instantiation: cel::Value::Value<cel::ParsedMapFieldValue, void>(cel::ParsedMapFieldValue&&) Unexecuted instantiation: cel::Value::Value<cel::CustomMapValue, void>(cel::CustomMapValue&&) Unexecuted instantiation: cel::Value::Value<cel::common_internal::LegacyStructValue const&, void>(cel::common_internal::LegacyStructValue const&) cel::Value::Value<cel::ParsedMessageValue, void>(cel::ParsedMessageValue&&) Line | Count | Source | 354 | 585k | : variant_(absl::in_place_type<absl::remove_cvref_t<T>>, | 355 | 585k | std::forward<T>(alternative)) {} |
Unexecuted instantiation: cel::Value::Value<cel::CustomStructValue, void>(cel::CustomStructValue&&) Unexecuted instantiation: cel::Value::Value<cel::OpaqueValue, void>(cel::OpaqueValue&&) Unexecuted instantiation: cel::Value::Value<cel::UnknownValue const&, void>(cel::UnknownValue const&) |
356 | | |
357 | | template <typename T, |
358 | | typename = std::enable_if_t< |
359 | | common_internal::IsValueAlternativeV<absl::remove_cvref_t<T>>>> |
360 | | // NOLINTNEXTLINE(google-explicit-constructor) |
361 | 39.2M | Value& operator=(T&& alternative) noexcept { |
362 | 39.2M | variant_.Assign(std::forward<T>(alternative)); |
363 | 39.2M | return *this; |
364 | 39.2M | } cel::Value& cel::Value::operator=<cel::ErrorValue, void>(cel::ErrorValue&&) Line | Count | Source | 361 | 1.36M | Value& operator=(T&& alternative) noexcept { | 362 | 1.36M | variant_.Assign(std::forward<T>(alternative)); | 363 | 1.36M | return *this; | 364 | 1.36M | } |
Unexecuted instantiation: cel::Value& cel::Value::operator=<cel::UnknownValue, void>(cel::UnknownValue&&) cel::Value& cel::Value::operator=<cel::NullValue, void>(cel::NullValue&&) Line | Count | Source | 361 | 3.32M | Value& operator=(T&& alternative) noexcept { | 362 | 3.32M | variant_.Assign(std::forward<T>(alternative)); | 363 | 3.32M | return *this; | 364 | 3.32M | } |
cel::Value& cel::Value::operator=<cel::BoolValue, void>(cel::BoolValue&&) Line | Count | Source | 361 | 2.02M | Value& operator=(T&& alternative) noexcept { | 362 | 2.02M | variant_.Assign(std::forward<T>(alternative)); | 363 | 2.02M | return *this; | 364 | 2.02M | } |
Unexecuted instantiation: cel::Value& cel::Value::operator=<cel::CustomMapValue, void>(cel::CustomMapValue&&) Unexecuted instantiation: cel::Value& cel::Value::operator=<cel::UnknownValue&, void>(cel::UnknownValue&) Unexecuted instantiation: cel::Value& cel::Value::operator=<cel::CustomListValue, void>(cel::CustomListValue&&) cel::Value& cel::Value::operator=<cel::IntValue, void>(cel::IntValue&&) Line | Count | Source | 361 | 23.6M | Value& operator=(T&& alternative) noexcept { | 362 | 23.6M | variant_.Assign(std::forward<T>(alternative)); | 363 | 23.6M | return *this; | 364 | 23.6M | } |
cel::Value& cel::Value::operator=<cel::DoubleValue, void>(cel::DoubleValue&&) Line | Count | Source | 361 | 766k | Value& operator=(T&& alternative) noexcept { | 362 | 766k | variant_.Assign(std::forward<T>(alternative)); | 363 | 766k | return *this; | 364 | 766k | } |
cel::Value& cel::Value::operator=<cel::UintValue, void>(cel::UintValue&&) Line | Count | Source | 361 | 7.48M | Value& operator=(T&& alternative) noexcept { | 362 | 7.48M | variant_.Assign(std::forward<T>(alternative)); | 363 | 7.48M | return *this; | 364 | 7.48M | } |
cel::Value& cel::Value::operator=<cel::common_internal::LegacyStructValue, void>(cel::common_internal::LegacyStructValue&&) Line | Count | Source | 361 | 585k | Value& operator=(T&& alternative) noexcept { | 362 | 585k | variant_.Assign(std::forward<T>(alternative)); | 363 | 585k | return *this; | 364 | 585k | } |
Unexecuted instantiation: cel::Value& cel::Value::operator=<cel::DurationValue, void>(cel::DurationValue&&) Unexecuted instantiation: cel::Value& cel::Value::operator=<cel::TimestampValue, void>(cel::TimestampValue&&) cel::Value& cel::Value::operator=<cel::StringValue, void>(cel::StringValue&&) Line | Count | Source | 361 | 3.89k | Value& operator=(T&& alternative) noexcept { | 362 | 3.89k | variant_.Assign(std::forward<T>(alternative)); | 363 | 3.89k | return *this; | 364 | 3.89k | } |
Unexecuted instantiation: cel::Value& cel::Value::operator=<cel::StringValue const&, void>(cel::StringValue const&) Unexecuted instantiation: cel::Value& cel::Value::operator=<cel::BytesValue, void>(cel::BytesValue&&) Unexecuted instantiation: cel::Value& cel::Value::operator=<cel::TypeValue, void>(cel::TypeValue&&) |
365 | | |
366 | 175M | ValueKind kind() const { return variant_.kind(); } |
367 | | |
368 | | Type GetRuntimeType() const; |
369 | | |
370 | | absl::string_view GetTypeName() const; |
371 | | |
372 | | std::string DebugString() const; |
373 | | |
374 | | // `SerializeTo` serializes this value to `output`. If an error is returned, |
375 | | // `output` is in a valid but unspecified state. If this value does not |
376 | | // support serialization, `FAILED_PRECONDITION` is returned. |
377 | | absl::Status SerializeTo( |
378 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
379 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
380 | | google::protobuf::io::ZeroCopyOutputStream* absl_nonnull output) const; |
381 | | |
382 | | // `ConvertToJson` converts this value to its JSON representation. The |
383 | | // argument `json` **MUST** be an instance of `google.protobuf.Value` which is |
384 | | // can either be the generated message or a dynamic message. The descriptor |
385 | | // pool `descriptor_pool` and message factory `message_factory` are used to |
386 | | // deal with serialized messages and a few corners cases. |
387 | | absl::Status ConvertToJson( |
388 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
389 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
390 | | google::protobuf::Message* absl_nonnull json) const; |
391 | | |
392 | | // `ConvertToJsonArray` converts this value to its JSON representation if and |
393 | | // only if it can be represented as an array. The argument `json` **MUST** be |
394 | | // an instance of `google.protobuf.ListValue` which is can either be the |
395 | | // generated message or a dynamic message. The descriptor pool |
396 | | // `descriptor_pool` and message factory `message_factory` are used to deal |
397 | | // with serialized messages and a few corners cases. |
398 | | absl::Status ConvertToJsonArray( |
399 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
400 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
401 | | google::protobuf::Message* absl_nonnull json) const; |
402 | | |
403 | | // `ConvertToJsonArray` converts this value to its JSON representation if and |
404 | | // only if it can be represented as an object. The argument `json` **MUST** be |
405 | | // an instance of `google.protobuf.Struct` which is can either be the |
406 | | // generated message or a dynamic message. The descriptor pool |
407 | | // `descriptor_pool` and message factory `message_factory` are used to deal |
408 | | // with serialized messages and a few corners cases. |
409 | | absl::Status ConvertToJsonObject( |
410 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
411 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
412 | | google::protobuf::Message* absl_nonnull json) const; |
413 | | |
414 | | absl::Status Equal(const Value& other, |
415 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
416 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
417 | | google::protobuf::Arena* absl_nonnull arena, |
418 | | Value* absl_nonnull result) const; |
419 | | using ValueMixin::Equal; |
420 | | |
421 | | bool IsZeroValue() const; |
422 | | |
423 | | // Clones the value to another arena, if necessary, such that the lifetime of |
424 | | // the value is tied to the arena. |
425 | | Value Clone(google::protobuf::Arena* absl_nonnull arena) const; |
426 | | |
427 | 373k | friend void swap(Value& lhs, Value& rhs) noexcept { |
428 | 373k | using std::swap; |
429 | 373k | swap(lhs.variant_, rhs.variant_); |
430 | 373k | } |
431 | | |
432 | | friend std::ostream& operator<<(std::ostream& out, const Value& value); |
433 | | |
434 | | ABSL_DEPRECATED("Just use operator.()") |
435 | 0 | Value* operator->() { return this; } |
436 | | |
437 | | ABSL_DEPRECATED("Just use operator.()") |
438 | 172M | const Value* operator->() const { return this; } |
439 | | |
440 | | // Returns `true` if this value is an instance of a bool value. |
441 | 242k | bool IsBool() const { return variant_.Is<BoolValue>(); } |
442 | | |
443 | | // Returns `true` if this value is an instance of a bool value and true. |
444 | 14.5k | bool IsTrue() const { return IsBool() && GetBool().NativeValue(); } |
445 | | |
446 | | // Returns `true` if this value is an instance of a bool value and false. |
447 | 1.49k | bool IsFalse() const { return IsBool() && !GetBool().NativeValue(); } |
448 | | |
449 | | // Returns `true` if this value is an instance of a bytes value. |
450 | 7.91k | bool IsBytes() const { return variant_.Is<BytesValue>(); } |
451 | | |
452 | | // Returns `true` if this value is an instance of a double value. |
453 | 263k | bool IsDouble() const { return variant_.Is<DoubleValue>(); } |
454 | | |
455 | | // Returns `true` if this value is an instance of a duration value. |
456 | 13.4k | bool IsDuration() const { return variant_.Is<DurationValue>(); } |
457 | | |
458 | | // Returns `true` if this value is an instance of an error value. |
459 | 58.5M | bool IsError() const { return variant_.Is<ErrorValue>(); } |
460 | | |
461 | | // Returns `true` if this value is an instance of an int value. |
462 | 12.4M | bool IsInt() const { return variant_.Is<IntValue>(); } |
463 | | |
464 | | // Returns `true` if this value is an instance of a list value. |
465 | 1.15M | bool IsList() const { |
466 | 1.15M | return variant_.Is<common_internal::LegacyListValue>() || |
467 | 1.15M | variant_.Is<CustomListValue>() || |
468 | 24.2k | variant_.Is<ParsedRepeatedFieldValue>() || |
469 | 24.2k | variant_.Is<ParsedJsonListValue>(); |
470 | 1.15M | } |
471 | | |
472 | | // Returns `true` if this value is an instance of a map value. |
473 | 948k | bool IsMap() const { |
474 | 948k | return variant_.Is<common_internal::LegacyMapValue>() || |
475 | 948k | variant_.Is<CustomMapValue>() || |
476 | 867k | variant_.Is<ParsedMapFieldValue>() || |
477 | 867k | variant_.Is<ParsedJsonMapValue>(); |
478 | 948k | } |
479 | | |
480 | | // Returns `true` if this value is an instance of a message value. If `true` |
481 | | // is returned, it is implied that `IsStruct()` would also return true. |
482 | 1.04M | bool IsMessage() const { return variant_.Is<ParsedMessageValue>(); } |
483 | | |
484 | | // Returns `true` if this value is an instance of a null value. |
485 | 4.86k | bool IsNull() const { return variant_.Is<NullValue>(); } |
486 | | |
487 | | // Returns `true` if this value is an instance of an opaque value. |
488 | 0 | bool IsOpaque() const { return variant_.Is<OpaqueValue>(); } |
489 | | |
490 | | // Returns `true` if this value is an instance of an optional value. If `true` |
491 | | // is returned, it is implied that `IsOpaque()` would also return true. |
492 | 0 | bool IsOptional() const { |
493 | 0 | if (const auto* alternative = variant_.As<OpaqueValue>(); |
494 | 0 | alternative != nullptr) { |
495 | 0 | return alternative->IsOptional(); |
496 | 0 | } |
497 | 0 | return false; |
498 | 0 | } |
499 | | |
500 | | // Returns `true` if this value is an instance of a parsed JSON list value. If |
501 | | // `true` is returned, it is implied that `IsList()` would also return |
502 | | // true. |
503 | 0 | bool IsParsedJsonList() const { return variant_.Is<ParsedJsonListValue>(); } |
504 | | |
505 | | // Returns `true` if this value is an instance of a parsed JSON map value. If |
506 | | // `true` is returned, it is implied that `IsMap()` would also return |
507 | | // true. |
508 | 0 | bool IsParsedJsonMap() const { return variant_.Is<ParsedJsonMapValue>(); } |
509 | | |
510 | | // Returns `true` if this value is an instance of a custom list value. If |
511 | | // `true` is returned, it is implied that `IsList()` would also return |
512 | | // true. |
513 | 0 | bool IsCustomList() const { return variant_.Is<CustomListValue>(); } |
514 | | |
515 | | // Returns `true` if this value is an instance of a custom map value. If |
516 | | // `true` is returned, it is implied that `IsMap()` would also return |
517 | | // true. |
518 | 0 | bool IsCustomMap() const { return variant_.Is<CustomMapValue>(); } |
519 | | |
520 | | // Returns `true` if this value is an instance of a parsed map field value. If |
521 | | // `true` is returned, it is implied that `IsMap()` would also return |
522 | | // true. |
523 | 0 | bool IsParsedMapField() const { return variant_.Is<ParsedMapFieldValue>(); } |
524 | | |
525 | | // Returns `true` if this value is an instance of a parsed message value. If |
526 | | // `true` is returned, it is implied that `IsMessage()` would also return |
527 | | // true. |
528 | 0 | bool IsParsedMessage() const { return variant_.Is<ParsedMessageValue>(); } |
529 | | |
530 | | // Returns `true` if this value is an instance of a parsed repeated field |
531 | | // value. If `true` is returned, it is implied that `IsList()` would also |
532 | | // return true. |
533 | 0 | bool IsParsedRepeatedField() const { |
534 | 0 | return variant_.Is<ParsedRepeatedFieldValue>(); |
535 | 0 | } |
536 | | |
537 | | // Returns `true` if this value is an instance of a custom struct value. If |
538 | | // `true` is returned, it is implied that `IsStruct()` would also return |
539 | | // true. |
540 | 0 | bool IsCustomStruct() const { return variant_.Is<CustomStructValue>(); } |
541 | | |
542 | | // Returns `true` if this value is an instance of a string value. |
543 | 246k | bool IsString() const { return variant_.Is<StringValue>(); } |
544 | | |
545 | | // Returns `true` if this value is an instance of a struct value. |
546 | 884k | bool IsStruct() const { |
547 | 884k | return variant_.Is<common_internal::LegacyStructValue>() || |
548 | 386k | variant_.Is<CustomStructValue>() || |
549 | 386k | variant_.Is<ParsedMessageValue>(); |
550 | 884k | } |
551 | | |
552 | | // Returns `true` if this value is an instance of a timestamp value. |
553 | 7.99k | bool IsTimestamp() const { return variant_.Is<TimestampValue>(); } |
554 | | |
555 | | // Returns `true` if this value is an instance of a type value. |
556 | 0 | bool IsType() const { return variant_.Is<TypeValue>(); } |
557 | | |
558 | | // Returns `true` if this value is an instance of a uint value. |
559 | 7.05M | bool IsUint() const { return variant_.Is<UintValue>(); } |
560 | | |
561 | | // Returns `true` if this value is an instance of an unknown value. |
562 | 22.7M | bool IsUnknown() const { return variant_.Is<UnknownValue>(); } |
563 | | |
564 | | // Convenience method for use with template metaprogramming. See |
565 | | // `IsBool()`. |
566 | | template <typename T> |
567 | | std::enable_if_t<std::is_same_v<BoolValue, T>, bool> Is() const { |
568 | | return IsBool(); |
569 | | } |
570 | | |
571 | | // Convenience method for use with template metaprogramming. See |
572 | | // `IsBytes()`. |
573 | | template <typename T> |
574 | 7.91k | std::enable_if_t<std::is_same_v<BytesValue, T>, bool> Is() const { |
575 | 7.91k | return IsBytes(); |
576 | 7.91k | } |
577 | | |
578 | | // Convenience method for use with template metaprogramming. See |
579 | | // `IsDouble()`. |
580 | | template <typename T> |
581 | 26.8k | std::enable_if_t<std::is_same_v<DoubleValue, T>, bool> Is() const { |
582 | 26.8k | return IsDouble(); |
583 | 26.8k | } |
584 | | |
585 | | // Convenience method for use with template metaprogramming. See |
586 | | // `IsDuration()`. |
587 | | template <typename T> |
588 | | std::enable_if_t<std::is_same_v<DurationValue, T>, bool> Is() const { |
589 | | return IsDuration(); |
590 | | } |
591 | | |
592 | | // Convenience method for use with template metaprogramming. See |
593 | | // `IsError()`. |
594 | | template <typename T> |
595 | 0 | std::enable_if_t<std::is_same_v<ErrorValue, T>, bool> Is() const { |
596 | 0 | return IsError(); |
597 | 0 | } |
598 | | |
599 | | // Convenience method for use with template metaprogramming. See |
600 | | // `IsInt()`. |
601 | | template <typename T> |
602 | 67.0k | std::enable_if_t<std::is_same_v<IntValue, T>, bool> Is() const { |
603 | 67.0k | return IsInt(); |
604 | 67.0k | } |
605 | | |
606 | | // Convenience method for use with template metaprogramming. See |
607 | | // `IsList()`. |
608 | | template <typename T> |
609 | 948k | std::enable_if_t<std::is_same_v<ListValue, T>, bool> Is() const { |
610 | 948k | return IsList(); |
611 | 948k | } |
612 | | |
613 | | // Convenience method for use with template metaprogramming. See |
614 | | // `IsMap()`. |
615 | | template <typename T> |
616 | 226 | std::enable_if_t<std::is_same_v<MapValue, T>, bool> Is() const { |
617 | 226 | return IsMap(); |
618 | 226 | } |
619 | | |
620 | | // Convenience method for use with template metaprogramming. See |
621 | | // `IsMessage()`. |
622 | | template <typename T> |
623 | 1.04M | std::enable_if_t<std::is_same_v<MessageValue, T>, bool> Is() const { |
624 | 1.04M | return IsMessage(); |
625 | 1.04M | } |
626 | | |
627 | | // Convenience method for use with template metaprogramming. See |
628 | | // `IsNull()`. |
629 | | template <typename T> |
630 | 0 | std::enable_if_t<std::is_same_v<NullValue, T>, bool> Is() const { |
631 | 0 | return IsNull(); |
632 | 0 | } |
633 | | |
634 | | // Convenience method for use with template metaprogramming. See |
635 | | // `IsOpaque()`. |
636 | | template <typename T> |
637 | 0 | std::enable_if_t<std::is_same_v<OpaqueValue, T>, bool> Is() const { |
638 | 0 | return IsOpaque(); |
639 | 0 | } |
640 | | |
641 | | // Convenience method for use with template metaprogramming. See |
642 | | // `IsOptional()`. |
643 | | template <typename T> |
644 | | std::enable_if_t<std::is_same_v<OptionalValue, T>, bool> Is() const { |
645 | | return IsOptional(); |
646 | | } |
647 | | |
648 | | // Convenience method for use with template metaprogramming. See |
649 | | // `IsParsedJsonList()`. |
650 | | template <typename T> |
651 | | std::enable_if_t<std::is_same_v<ParsedJsonListValue, T>, bool> Is() const { |
652 | | return IsParsedJsonList(); |
653 | | } |
654 | | |
655 | | // Convenience method for use with template metaprogramming. See |
656 | | // `IsParsedJsonMap()`. |
657 | | template <typename T> |
658 | | std::enable_if_t<std::is_same_v<ParsedJsonMapValue, T>, bool> Is() const { |
659 | | return IsParsedJsonMap(); |
660 | | } |
661 | | |
662 | | // Convenience method for use with template metaprogramming. See |
663 | | // `IsCustomList()`. |
664 | | template <typename T> |
665 | | std::enable_if_t<std::is_same_v<CustomListValue, T>, bool> Is() const { |
666 | | return IsCustomList(); |
667 | | } |
668 | | |
669 | | // Convenience method for use with template metaprogramming. See |
670 | | // `IsCustomMap()`. |
671 | | template <typename T> |
672 | | std::enable_if_t<std::is_same_v<CustomMapValue, T>, bool> Is() const { |
673 | | return IsCustomMap(); |
674 | | } |
675 | | |
676 | | // Convenience method for use with template metaprogramming. See |
677 | | // `IsParsedMapField()`. |
678 | | template <typename T> |
679 | | std::enable_if_t<std::is_same_v<ParsedMapFieldValue, T>, bool> Is() const { |
680 | | return IsParsedMapField(); |
681 | | } |
682 | | |
683 | | // Convenience method for use with template metaprogramming. See |
684 | | // `IsParsedMessage()`. |
685 | | template <typename T> |
686 | | std::enable_if_t<std::is_same_v<ParsedMessageValue, T>, bool> Is() const { |
687 | | return IsParsedMessage(); |
688 | | } |
689 | | |
690 | | // Convenience method for use with template metaprogramming. See |
691 | | // `IsParsedRepeatedField()`. |
692 | | template <typename T> |
693 | | std::enable_if_t<std::is_same_v<ParsedRepeatedFieldValue, T>, bool> Is() |
694 | | const { |
695 | | return IsParsedRepeatedField(); |
696 | | } |
697 | | |
698 | | // Convenience method for use with template metaprogramming. See |
699 | | // `IsParsedStruct()`. |
700 | | template <typename T> |
701 | | std::enable_if_t<std::is_same_v<CustomStructValue, T>, bool> Is() const { |
702 | | return IsCustomStruct(); |
703 | | } |
704 | | |
705 | | // Convenience method for use with template metaprogramming. See |
706 | | // `IsString()`. |
707 | | template <typename T> |
708 | 246k | std::enable_if_t<std::is_same_v<StringValue, T>, bool> Is() const { |
709 | 246k | return IsString(); |
710 | 246k | } |
711 | | |
712 | | // Convenience method for use with template metaprogramming. See |
713 | | // `IsStruct()`. |
714 | | template <typename T> |
715 | 0 | std::enable_if_t<std::is_same_v<StructValue, T>, bool> Is() const { |
716 | 0 | return IsStruct(); |
717 | 0 | } |
718 | | |
719 | | // Convenience method for use with template metaprogramming. See |
720 | | // `IsTimestamp()`. |
721 | | template <typename T> |
722 | | std::enable_if_t<std::is_same_v<TimestampValue, T>, bool> Is() const { |
723 | | return IsTimestamp(); |
724 | | } |
725 | | |
726 | | // Convenience method for use with template metaprogramming. See |
727 | | // `IsType()`. |
728 | | template <typename T> |
729 | 0 | std::enable_if_t<std::is_same_v<TypeValue, T>, bool> Is() const { |
730 | 0 | return IsType(); |
731 | 0 | } |
732 | | |
733 | | // Convenience method for use with template metaprogramming. See |
734 | | // `IsUint()`. |
735 | | template <typename T> |
736 | 358k | std::enable_if_t<std::is_same_v<UintValue, T>, bool> Is() const { |
737 | 358k | return IsUint(); |
738 | 358k | } |
739 | | |
740 | | // Convenience method for use with template metaprogramming. See |
741 | | // `IsUnknown()`. |
742 | | template <typename T> |
743 | 0 | std::enable_if_t<std::is_same_v<UnknownValue, T>, bool> Is() const { |
744 | 0 | return IsUnknown(); |
745 | 0 | } |
746 | | |
747 | | // Performs a checked cast from a value to a bool value, |
748 | | // returning a non-empty optional with either a value or reference to the |
749 | | // bool value. Otherwise an empty optional is returned. |
750 | 215k | absl::optional<BoolValue> AsBool() const { |
751 | 215k | if (const auto* alternative = variant_.As<BoolValue>(); |
752 | 215k | alternative != nullptr) { |
753 | 204k | return *alternative; |
754 | 204k | } |
755 | 10.7k | return absl::nullopt; |
756 | 215k | } |
757 | | |
758 | | // Performs a checked cast from a value to a bytes value, |
759 | | // returning a non-empty optional with either a value or reference to the |
760 | | // bytes value. Otherwise an empty optional is returned. |
761 | 0 | optional_ref<const BytesValue> AsBytes() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
762 | 0 | return std::as_const(*this).AsBytes(); |
763 | 0 | } |
764 | | optional_ref<const BytesValue> AsBytes() const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
765 | | absl::optional<BytesValue> AsBytes() &&; |
766 | 0 | absl::optional<BytesValue> AsBytes() const&& { |
767 | 0 | return common_internal::AsOptional(AsBytes()); |
768 | 0 | } |
769 | | |
770 | | // Performs a checked cast from a value to a double value, |
771 | | // returning a non-empty optional with either a value or reference to the |
772 | | // double value. Otherwise an empty optional is returned. |
773 | | absl::optional<DoubleValue> AsDouble() const; |
774 | | |
775 | | // Performs a checked cast from a value to a duration value, |
776 | | // returning a non-empty optional with either a value or reference to the |
777 | | // duration value. Otherwise an empty optional is returned. |
778 | | absl::optional<DurationValue> AsDuration() const; |
779 | | |
780 | | // Performs a checked cast from a value to an error value, |
781 | | // returning a non-empty optional with either a value or reference to the |
782 | | // error value. Otherwise an empty optional is returned. |
783 | 0 | optional_ref<const ErrorValue> AsError() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
784 | 0 | return std::as_const(*this).AsError(); |
785 | 0 | } |
786 | | optional_ref<const ErrorValue> AsError() const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
787 | | absl::optional<ErrorValue> AsError() &&; |
788 | 0 | absl::optional<ErrorValue> AsError() const&& { |
789 | 0 | return common_internal::AsOptional(AsError()); |
790 | 0 | } |
791 | | |
792 | | // Performs a checked cast from a value to an int value, |
793 | | // returning a non-empty optional with either a value or reference to the |
794 | | // int value. Otherwise an empty optional is returned. |
795 | | absl::optional<IntValue> AsInt() const; |
796 | | |
797 | | // Performs a checked cast from a value to a list value, |
798 | | // returning a non-empty optional with either a value or reference to the |
799 | | // list value. Otherwise an empty optional is returned. |
800 | 0 | absl::optional<ListValue> AsList() & { return std::as_const(*this).AsList(); } |
801 | | absl::optional<ListValue> AsList() const&; |
802 | | absl::optional<ListValue> AsList() &&; |
803 | 0 | absl::optional<ListValue> AsList() const&& { |
804 | 0 | return common_internal::AsOptional(AsList()); |
805 | 0 | } |
806 | | |
807 | | // Performs a checked cast from a value to a map value, |
808 | | // returning a non-empty optional with either a value or reference to the |
809 | | // map value. Otherwise an empty optional is returned. |
810 | 1 | absl::optional<MapValue> AsMap() & { return std::as_const(*this).AsMap(); } |
811 | | absl::optional<MapValue> AsMap() const&; |
812 | | absl::optional<MapValue> AsMap() &&; |
813 | 0 | absl::optional<MapValue> AsMap() const&& { |
814 | 0 | return common_internal::AsOptional(AsMap()); |
815 | 0 | } |
816 | | |
817 | | // Performs a checked cast from a value to a message value, |
818 | | // returning a non-empty optional with either a value or reference to the |
819 | | // message value. Otherwise an empty optional is returned. |
820 | 0 | absl::optional<MessageValue> AsMessage() & { |
821 | 0 | return std::as_const(*this).AsMessage(); |
822 | 0 | } |
823 | | absl::optional<MessageValue> AsMessage() const&; |
824 | | absl::optional<MessageValue> AsMessage() &&; |
825 | 0 | absl::optional<MessageValue> AsMessage() const&& { |
826 | 0 | return common_internal::AsOptional(AsMessage()); |
827 | 0 | } |
828 | | |
829 | | // Performs a checked cast from a value to a null value, |
830 | | // returning a non-empty optional with either a value or reference to the |
831 | | // null value. Otherwise an empty optional is returned. |
832 | | absl::optional<NullValue> AsNull() const; |
833 | | |
834 | | // Performs a checked cast from a value to an opaque value, |
835 | | // returning a non-empty optional with either a value or reference to the |
836 | | // opaque value. Otherwise an empty optional is returned. |
837 | 0 | optional_ref<const OpaqueValue> AsOpaque() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
838 | 0 | return std::as_const(*this).AsOpaque(); |
839 | 0 | } |
840 | | optional_ref<const OpaqueValue> AsOpaque() |
841 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
842 | | absl::optional<OpaqueValue> AsOpaque() &&; |
843 | 0 | absl::optional<OpaqueValue> AsOpaque() const&& { |
844 | 0 | return common_internal::AsOptional(AsOpaque()); |
845 | 0 | } |
846 | | |
847 | | // Performs a checked cast from a value to an optional value, |
848 | | // returning a non-empty optional with either a value or reference to the |
849 | | // optional value. Otherwise an empty optional is returned. |
850 | | optional_ref<const OptionalValue> AsOptional() & |
851 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND { |
852 | 0 | return std::as_const(*this).AsOptional(); |
853 | 0 | } |
854 | | optional_ref<const OptionalValue> AsOptional() |
855 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
856 | | absl::optional<OptionalValue> AsOptional() &&; |
857 | 0 | absl::optional<OptionalValue> AsOptional() const&& { |
858 | 0 | return common_internal::AsOptional(AsOptional()); |
859 | 0 | } |
860 | | |
861 | | // Performs a checked cast from a value to a parsed JSON list value, |
862 | | // returning a non-empty optional with either a value or reference to the |
863 | | // parsed message value. Otherwise an empty optional is returned. |
864 | | optional_ref<const ParsedJsonListValue> AsParsedJsonList() & |
865 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND { |
866 | 0 | return std::as_const(*this).AsParsedJsonList(); |
867 | 0 | } |
868 | | optional_ref<const ParsedJsonListValue> AsParsedJsonList() |
869 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
870 | | absl::optional<ParsedJsonListValue> AsParsedJsonList() &&; |
871 | 0 | absl::optional<ParsedJsonListValue> AsParsedJsonList() const&& { |
872 | 0 | return common_internal::AsOptional(AsParsedJsonList()); |
873 | 0 | } |
874 | | |
875 | | // Performs a checked cast from a value to a parsed JSON map value, |
876 | | // returning a non-empty optional with either a value or reference to the |
877 | | // parsed message value. Otherwise an empty optional is returned. |
878 | | optional_ref<const ParsedJsonMapValue> AsParsedJsonMap() & |
879 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND { |
880 | 0 | return std::as_const(*this).AsParsedJsonMap(); |
881 | 0 | } |
882 | | optional_ref<const ParsedJsonMapValue> AsParsedJsonMap() |
883 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
884 | | absl::optional<ParsedJsonMapValue> AsParsedJsonMap() &&; |
885 | 0 | absl::optional<ParsedJsonMapValue> AsParsedJsonMap() const&& { |
886 | 0 | return common_internal::AsOptional(AsParsedJsonMap()); |
887 | 0 | } |
888 | | |
889 | | // Performs a checked cast from a value to a custom list value, |
890 | | // returning a non-empty optional with either a value or reference to the |
891 | | // custom list value. Otherwise an empty optional is returned. |
892 | | optional_ref<const CustomListValue> AsCustomList() & |
893 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND { |
894 | 0 | return std::as_const(*this).AsCustomList(); |
895 | 0 | } |
896 | | optional_ref<const CustomListValue> AsCustomList() |
897 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
898 | | absl::optional<CustomListValue> AsCustomList() &&; |
899 | 0 | absl::optional<CustomListValue> AsCustomList() const&& { |
900 | 0 | return common_internal::AsOptional(AsCustomList()); |
901 | 0 | } |
902 | | |
903 | | // Performs a checked cast from a value to a custom map value, |
904 | | // returning a non-empty optional with either a value or reference to the |
905 | | // custom map value. Otherwise an empty optional is returned. |
906 | | optional_ref<const CustomMapValue> AsCustomMap() & |
907 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND { |
908 | 0 | return std::as_const(*this).AsCustomMap(); |
909 | 0 | } |
910 | | optional_ref<const CustomMapValue> AsCustomMap() |
911 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
912 | | absl::optional<CustomMapValue> AsCustomMap() &&; |
913 | 0 | absl::optional<CustomMapValue> AsCustomMap() const&& { |
914 | 0 | return common_internal::AsOptional(AsCustomMap()); |
915 | 0 | } |
916 | | |
917 | | // Performs a checked cast from a value to a parsed map field value, |
918 | | // returning a non-empty optional with either a value or reference to the |
919 | | // parsed map field value. Otherwise an empty optional is returned. |
920 | | optional_ref<const ParsedMapFieldValue> AsParsedMapField() & |
921 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND { |
922 | 0 | return std::as_const(*this).AsParsedMapField(); |
923 | 0 | } |
924 | | optional_ref<const ParsedMapFieldValue> AsParsedMapField() |
925 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
926 | | absl::optional<ParsedMapFieldValue> AsParsedMapField() &&; |
927 | 0 | absl::optional<ParsedMapFieldValue> AsParsedMapField() const&& { |
928 | 0 | return common_internal::AsOptional(AsParsedMapField()); |
929 | 0 | } |
930 | | |
931 | | // Performs a checked cast from a value to a parsed message value, |
932 | | // returning a non-empty optional with either a value or reference to the |
933 | | // parsed message value. Otherwise an empty optional is returned. |
934 | | optional_ref<const ParsedMessageValue> AsParsedMessage() & |
935 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND { |
936 | 0 | return std::as_const(*this).AsParsedMessage(); |
937 | 0 | } |
938 | | optional_ref<const ParsedMessageValue> AsParsedMessage() |
939 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
940 | | absl::optional<ParsedMessageValue> AsParsedMessage() &&; |
941 | 0 | absl::optional<ParsedMessageValue> AsParsedMessage() const&& { |
942 | 0 | return common_internal::AsOptional(AsParsedMessage()); |
943 | 0 | } |
944 | | |
945 | | // Performs a checked cast from a value to a parsed repeated field value, |
946 | | // returning a non-empty optional with either a value or reference to the |
947 | | // parsed repeated field value. Otherwise an empty optional is returned. |
948 | | optional_ref<const ParsedRepeatedFieldValue> AsParsedRepeatedField() & |
949 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND { |
950 | 0 | return std::as_const(*this).AsParsedRepeatedField(); |
951 | 0 | } |
952 | | optional_ref<const ParsedRepeatedFieldValue> AsParsedRepeatedField() |
953 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
954 | | absl::optional<ParsedRepeatedFieldValue> AsParsedRepeatedField() &&; |
955 | 0 | absl::optional<ParsedRepeatedFieldValue> AsParsedRepeatedField() const&& { |
956 | 0 | return common_internal::AsOptional(AsParsedRepeatedField()); |
957 | 0 | } |
958 | | |
959 | | // Performs a checked cast from a value to a custom struct value, |
960 | | // returning a non-empty optional with either a value or reference to the |
961 | | // custom struct value. Otherwise an empty optional is returned. |
962 | | optional_ref<const CustomStructValue> AsCustomStruct() & |
963 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND { |
964 | 0 | return std::as_const(*this).AsCustomStruct(); |
965 | 0 | } |
966 | | optional_ref<const CustomStructValue> AsCustomStruct() |
967 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
968 | | absl::optional<CustomStructValue> AsCustomStruct() &&; |
969 | 0 | absl::optional<CustomStructValue> AsCustomStruct() const&& { |
970 | 0 | return common_internal::AsOptional(AsCustomStruct()); |
971 | 0 | } |
972 | | |
973 | | // Performs a checked cast from a value to a string value, |
974 | | // returning a non-empty optional with either a value or reference to the |
975 | | // string value. Otherwise an empty optional is returned. |
976 | 0 | optional_ref<const StringValue> AsString() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
977 | 0 | return std::as_const(*this).AsString(); |
978 | 0 | } |
979 | | optional_ref<const StringValue> AsString() |
980 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
981 | | absl::optional<StringValue> AsString() &&; |
982 | 0 | absl::optional<StringValue> AsString() const&& { |
983 | 0 | return common_internal::AsOptional(AsString()); |
984 | 0 | } |
985 | | |
986 | | // Performs a checked cast from a value to a struct value, |
987 | | // returning a non-empty optional with either a value or reference to the |
988 | | // struct value. Otherwise an empty optional is returned. |
989 | 0 | absl::optional<StructValue> AsStruct() & { |
990 | 0 | return std::as_const(*this).AsStruct(); |
991 | 0 | } |
992 | | absl::optional<StructValue> AsStruct() const&; |
993 | | absl::optional<StructValue> AsStruct() &&; |
994 | 0 | absl::optional<StructValue> AsStruct() const&& { |
995 | 0 | return common_internal::AsOptional(AsStruct()); |
996 | 0 | } |
997 | | |
998 | | // Performs a checked cast from a value to a timestamp value, |
999 | | // returning a non-empty optional with either a value or reference to the |
1000 | | // timestamp value. Otherwise an empty optional is returned. |
1001 | | absl::optional<TimestampValue> AsTimestamp() const; |
1002 | | |
1003 | | // Performs a checked cast from a value to a type value, |
1004 | | // returning a non-empty optional with either a value or reference to the |
1005 | | // type value. Otherwise an empty optional is returned. |
1006 | 0 | optional_ref<const TypeValue> AsType() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1007 | 0 | return std::as_const(*this).AsType(); |
1008 | 0 | } |
1009 | | optional_ref<const TypeValue> AsType() const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
1010 | | absl::optional<TypeValue> AsType() &&; |
1011 | 0 | absl::optional<TypeValue> AsType() const&& { |
1012 | 0 | return common_internal::AsOptional(AsType()); |
1013 | 0 | } |
1014 | | |
1015 | | // Performs a checked cast from a value to an uint value, |
1016 | | // returning a non-empty optional with either a value or reference to the |
1017 | | // uint value. Otherwise an empty optional is returned. |
1018 | | absl::optional<UintValue> AsUint() const; |
1019 | | |
1020 | | // Performs a checked cast from a value to an unknown value, |
1021 | | // returning a non-empty optional with either a value or reference to the |
1022 | | // unknown value. Otherwise an empty optional is returned. |
1023 | | optional_ref<UnknownValue> AsUnknown() & ABSL_ATTRIBUTE_LIFETIME_BOUND; |
1024 | | optional_ref<const UnknownValue> AsUnknown() |
1025 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
1026 | | absl::optional<UnknownValue> AsUnknown() &&; |
1027 | 0 | absl::optional<UnknownValue> AsUnknown() const&& { |
1028 | 0 | return common_internal::AsOptional(AsUnknown()); |
1029 | 0 | } |
1030 | | |
1031 | | // Convenience method for use with template metaprogramming. See |
1032 | | // `AsBool()`. |
1033 | | template <typename T> |
1034 | | std::enable_if_t<std::is_same_v<BoolValue, T>, absl::optional<BoolValue>> |
1035 | 0 | As() & { |
1036 | 0 | return AsBool(); |
1037 | 0 | } |
1038 | | template <typename T> |
1039 | | std::enable_if_t<std::is_same_v<BoolValue, T>, absl::optional<BoolValue>> As() |
1040 | 0 | const& { |
1041 | 0 | return AsBool(); |
1042 | 0 | } |
1043 | | template <typename T> |
1044 | | std::enable_if_t<std::is_same_v<BoolValue, T>, absl::optional<BoolValue>> |
1045 | | As() && { |
1046 | | return AsBool(); |
1047 | | } |
1048 | | template <typename T> |
1049 | | std::enable_if_t<std::is_same_v<BoolValue, T>, absl::optional<BoolValue>> As() |
1050 | | const&& { |
1051 | | return AsBool(); |
1052 | | } |
1053 | | |
1054 | | // Convenience method for use with template metaprogramming. See |
1055 | | // `AsBytes()`. |
1056 | | template <typename T> |
1057 | | std::enable_if_t<std::is_same_v<BytesValue, T>, |
1058 | | optional_ref<const BytesValue>> |
1059 | | As() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1060 | | return AsBytes(); |
1061 | | } |
1062 | | template <typename T> |
1063 | | std::enable_if_t<std::is_same_v<BytesValue, T>, |
1064 | | optional_ref<const BytesValue>> |
1065 | 0 | As() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1066 | 0 | return AsBytes(); |
1067 | 0 | } |
1068 | | template <typename T> |
1069 | | std::enable_if_t<std::is_same_v<BytesValue, T>, absl::optional<BytesValue>> |
1070 | | As() && { |
1071 | | return std::move(*this).AsBytes(); |
1072 | | } |
1073 | | template <typename T> |
1074 | | std::enable_if_t<std::is_same_v<BytesValue, T>, absl::optional<BytesValue>> |
1075 | | As() const&& { |
1076 | | return std::move(*this).AsBytes(); |
1077 | | } |
1078 | | |
1079 | | // Convenience method for use with template metaprogramming. See |
1080 | | // `AsDouble()`. |
1081 | | template <typename T> |
1082 | | std::enable_if_t<std::is_same_v<DoubleValue, T>, absl::optional<DoubleValue>> |
1083 | | As() & { |
1084 | | return AsDouble(); |
1085 | | } |
1086 | | template <typename T> |
1087 | | std::enable_if_t<std::is_same_v<DoubleValue, T>, absl::optional<DoubleValue>> |
1088 | 0 | As() const& { |
1089 | 0 | return AsDouble(); |
1090 | 0 | } |
1091 | | template <typename T> |
1092 | | std::enable_if_t<std::is_same_v<DoubleValue, T>, absl::optional<DoubleValue>> |
1093 | | As() && { |
1094 | | return AsDouble(); |
1095 | | } |
1096 | | template <typename T> |
1097 | | std::enable_if_t<std::is_same_v<DoubleValue, T>, absl::optional<DoubleValue>> |
1098 | | As() const&& { |
1099 | | return AsDouble(); |
1100 | | } |
1101 | | |
1102 | | // Convenience method for use with template metaprogramming. See |
1103 | | // `AsDuration()`. |
1104 | | template <typename T> |
1105 | | std::enable_if_t<std::is_same_v<DurationValue, T>, |
1106 | | absl::optional<DurationValue>> |
1107 | | As() & { |
1108 | | return AsDuration(); |
1109 | | } |
1110 | | template <typename T> |
1111 | | std::enable_if_t<std::is_same_v<DurationValue, T>, |
1112 | | absl::optional<DurationValue>> |
1113 | | As() const& { |
1114 | | return AsDuration(); |
1115 | | } |
1116 | | template <typename T> |
1117 | | std::enable_if_t<std::is_same_v<DurationValue, T>, |
1118 | | absl::optional<DurationValue>> |
1119 | | As() && { |
1120 | | return AsDuration(); |
1121 | | } |
1122 | | template <typename T> |
1123 | | std::enable_if_t<std::is_same_v<DurationValue, T>, |
1124 | | absl::optional<DurationValue>> |
1125 | | As() const&& { |
1126 | | return AsDuration(); |
1127 | | } |
1128 | | |
1129 | | // Convenience method for use with template metaprogramming. See |
1130 | | // `AsError()`. |
1131 | | template <typename T> |
1132 | | std::enable_if_t<std::is_same_v<ErrorValue, T>, |
1133 | | optional_ref<const ErrorValue>> |
1134 | | As() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1135 | | return AsError(); |
1136 | | } |
1137 | | template <typename T> |
1138 | | std::enable_if_t<std::is_same_v<ErrorValue, T>, |
1139 | | optional_ref<const ErrorValue>> |
1140 | | As() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1141 | | return AsError(); |
1142 | | } |
1143 | | template <typename T> |
1144 | | std::enable_if_t<std::is_same_v<ErrorValue, T>, absl::optional<ErrorValue>> |
1145 | | As() && { |
1146 | | return std::move(*this).AsError(); |
1147 | | } |
1148 | | template <typename T> |
1149 | | std::enable_if_t<std::is_same_v<ErrorValue, T>, absl::optional<ErrorValue>> |
1150 | | As() const&& { |
1151 | | return std::move(*this).AsError(); |
1152 | | } |
1153 | | |
1154 | | // Convenience method for use with template metaprogramming. See |
1155 | | // `AsInt()`. |
1156 | | template <typename T> |
1157 | | std::enable_if_t<std::is_same_v<IntValue, T>, absl::optional<IntValue>> |
1158 | | As() & { |
1159 | | return AsInt(); |
1160 | | } |
1161 | | template <typename T> |
1162 | | std::enable_if_t<std::is_same_v<IntValue, T>, absl::optional<IntValue>> As() |
1163 | 0 | const& { |
1164 | 0 | return AsInt(); |
1165 | 0 | } |
1166 | | template <typename T> |
1167 | | std::enable_if_t<std::is_same_v<IntValue, T>, absl::optional<IntValue>> |
1168 | | As() && { |
1169 | | return AsInt(); |
1170 | | } |
1171 | | template <typename T> |
1172 | | std::enable_if_t<std::is_same_v<IntValue, T>, absl::optional<IntValue>> As() |
1173 | | const&& { |
1174 | | return AsInt(); |
1175 | | } |
1176 | | |
1177 | | // Convenience method for use with template metaprogramming. See |
1178 | | // `AsList()`. |
1179 | | template <typename T> |
1180 | | std::enable_if_t<std::is_same_v<ListValue, T>, absl::optional<ListValue>> |
1181 | | As() & { |
1182 | | return AsList(); |
1183 | | } |
1184 | | template <typename T> |
1185 | | std::enable_if_t<std::is_same_v<ListValue, T>, absl::optional<ListValue>> As() |
1186 | | const& { |
1187 | | return AsList(); |
1188 | | } |
1189 | | template <typename T> |
1190 | | std::enable_if_t<std::is_same_v<ListValue, T>, absl::optional<ListValue>> |
1191 | | As() && { |
1192 | | return std::move(*this).AsList(); |
1193 | | } |
1194 | | template <typename T> |
1195 | | std::enable_if_t<std::is_same_v<ListValue, T>, absl::optional<ListValue>> As() |
1196 | | const&& { |
1197 | | return std::move(*this).AsList(); |
1198 | | } |
1199 | | |
1200 | | // Convenience method for use with template metaprogramming. See |
1201 | | // `AsMap()`. |
1202 | | template <typename T> |
1203 | | std::enable_if_t<std::is_same_v<MapValue, T>, absl::optional<MapValue>> |
1204 | | As() & { |
1205 | | return AsMap(); |
1206 | | } |
1207 | | template <typename T> |
1208 | | std::enable_if_t<std::is_same_v<MapValue, T>, absl::optional<MapValue>> As() |
1209 | | const& { |
1210 | | return AsMap(); |
1211 | | } |
1212 | | template <typename T> |
1213 | | std::enable_if_t<std::is_same_v<MapValue, T>, absl::optional<MapValue>> |
1214 | | As() && { |
1215 | | return std::move(*this).AsMap(); |
1216 | | } |
1217 | | template <typename T> |
1218 | | std::enable_if_t<std::is_same_v<MapValue, T>, absl::optional<MapValue>> As() |
1219 | | const&& { |
1220 | | return std::move(*this).AsMap(); |
1221 | | } |
1222 | | |
1223 | | // Convenience method for use with template metaprogramming. See |
1224 | | // `AsMessage()`. |
1225 | | template <typename T> |
1226 | | std::enable_if_t<std::is_same_v<MessageValue, T>, |
1227 | | absl::optional<MessageValue>> |
1228 | | As() & { |
1229 | | return AsMessage(); |
1230 | | } |
1231 | | template <typename T> |
1232 | | std::enable_if_t<std::is_same_v<MessageValue, T>, |
1233 | | absl::optional<MessageValue>> |
1234 | | As() const& { |
1235 | | return AsMessage(); |
1236 | | } |
1237 | | template <typename T> |
1238 | | std::enable_if_t<std::is_same_v<MessageValue, T>, |
1239 | | absl::optional<MessageValue>> |
1240 | | As() && { |
1241 | | return std::move(*this).AsMessage(); |
1242 | | } |
1243 | | template <typename T> |
1244 | | std::enable_if_t<std::is_same_v<MessageValue, T>, |
1245 | | absl::optional<MessageValue>> |
1246 | | As() const&& { |
1247 | | return std::move(*this).AsMessage(); |
1248 | | } |
1249 | | |
1250 | | // Convenience method for use with template metaprogramming. See |
1251 | | // `AsNull()`. |
1252 | | template <typename T> |
1253 | | std::enable_if_t<std::is_same_v<NullValue, T>, absl::optional<NullValue>> |
1254 | | As() & { |
1255 | | return AsNull(); |
1256 | | } |
1257 | | template <typename T> |
1258 | | std::enable_if_t<std::is_same_v<NullValue, T>, absl::optional<NullValue>> As() |
1259 | | const& { |
1260 | | return AsNull(); |
1261 | | } |
1262 | | template <typename T> |
1263 | | std::enable_if_t<std::is_same_v<NullValue, T>, absl::optional<NullValue>> |
1264 | | As() && { |
1265 | | return AsNull(); |
1266 | | } |
1267 | | template <typename T> |
1268 | | std::enable_if_t<std::is_same_v<NullValue, T>, absl::optional<NullValue>> As() |
1269 | | const&& { |
1270 | | return AsNull(); |
1271 | | } |
1272 | | |
1273 | | // Convenience method for use with template metaprogramming. See |
1274 | | // `AsOpaque()`. |
1275 | | template <typename T> |
1276 | | std::enable_if_t<std::is_same_v<OpaqueValue, T>, |
1277 | | optional_ref<const OpaqueValue>> |
1278 | | As() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1279 | | return AsOpaque(); |
1280 | | } |
1281 | | template <typename T> |
1282 | | std::enable_if_t<std::is_same_v<OpaqueValue, T>, |
1283 | | optional_ref<const OpaqueValue>> |
1284 | | As() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1285 | | return AsOpaque(); |
1286 | | } |
1287 | | template <typename T> |
1288 | | std::enable_if_t<std::is_same_v<OpaqueValue, T>, absl::optional<OpaqueValue>> |
1289 | | As() && { |
1290 | | return std::move(*this).AsOpaque(); |
1291 | | } |
1292 | | template <typename T> |
1293 | | std::enable_if_t<std::is_same_v<OpaqueValue, T>, absl::optional<OpaqueValue>> |
1294 | | As() const&& { |
1295 | | return std::move(*this).AsOpaque(); |
1296 | | } |
1297 | | |
1298 | | // Convenience method for use with template metaprogramming. See |
1299 | | // `AsOptional()`. |
1300 | | template <typename T> |
1301 | | std::enable_if_t<std::is_same_v<OptionalValue, T>, |
1302 | | optional_ref<const OptionalValue>> |
1303 | | As() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1304 | | return AsOptional(); |
1305 | | } |
1306 | | template <typename T> |
1307 | | std::enable_if_t<std::is_same_v<OptionalValue, T>, |
1308 | | optional_ref<const OptionalValue>> |
1309 | | As() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1310 | | return AsOptional(); |
1311 | | } |
1312 | | template <typename T> |
1313 | | std::enable_if_t<std::is_same_v<OptionalValue, T>, |
1314 | | absl::optional<OptionalValue>> |
1315 | | As() && { |
1316 | | return std::move(*this).AsOptional(); |
1317 | | } |
1318 | | template <typename T> |
1319 | | std::enable_if_t<std::is_same_v<OptionalValue, T>, |
1320 | | absl::optional<OptionalValue>> |
1321 | | As() const&& { |
1322 | | return std::move(*this).AsOptional(); |
1323 | | } |
1324 | | |
1325 | | // Convenience method for use with template metaprogramming. See |
1326 | | // `AsParsedJsonList()`. |
1327 | | template <typename T> |
1328 | | std::enable_if_t<std::is_same_v<ParsedJsonListValue, T>, |
1329 | | optional_ref<const ParsedJsonListValue>> |
1330 | | As() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1331 | | return AsParsedJsonList(); |
1332 | | } |
1333 | | template <typename T> |
1334 | | std::enable_if_t<std::is_same_v<ParsedJsonListValue, T>, |
1335 | | optional_ref<const ParsedJsonListValue>> |
1336 | | As() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1337 | | return AsParsedJsonList(); |
1338 | | } |
1339 | | template <typename T> |
1340 | | std::enable_if_t<std::is_same_v<ParsedJsonListValue, T>, |
1341 | | absl::optional<ParsedJsonListValue>> |
1342 | | As() && { |
1343 | | return std::move(*this).AsParsedJsonList(); |
1344 | | } |
1345 | | template <typename T> |
1346 | | std::enable_if_t<std::is_same_v<ParsedJsonListValue, T>, |
1347 | | absl::optional<ParsedJsonListValue>> |
1348 | | As() const&& { |
1349 | | return std::move(*this).AsParsedJsonList(); |
1350 | | } |
1351 | | |
1352 | | // Convenience method for use with template metaprogramming. See |
1353 | | // `AsParsedJsonMap()`. |
1354 | | template <typename T> |
1355 | | std::enable_if_t<std::is_same_v<ParsedJsonMapValue, T>, |
1356 | | optional_ref<const ParsedJsonMapValue>> |
1357 | | As() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1358 | | return AsParsedJsonMap(); |
1359 | | } |
1360 | | template <typename T> |
1361 | | std::enable_if_t<std::is_same_v<ParsedJsonMapValue, T>, |
1362 | | optional_ref<const ParsedJsonMapValue>> |
1363 | | As() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1364 | | return AsParsedJsonMap(); |
1365 | | } |
1366 | | template <typename T> |
1367 | | std::enable_if_t<std::is_same_v<ParsedJsonMapValue, T>, |
1368 | | absl::optional<ParsedJsonMapValue>> |
1369 | | As() && { |
1370 | | return std::move(*this).AsParsedJsonMap(); |
1371 | | } |
1372 | | template <typename T> |
1373 | | std::enable_if_t<std::is_same_v<ParsedJsonMapValue, T>, |
1374 | | absl::optional<ParsedJsonMapValue>> |
1375 | | As() const&& { |
1376 | | return std::move(*this).AsParsedJsonMap(); |
1377 | | } |
1378 | | |
1379 | | // Convenience method for use with template metaprogramming. See |
1380 | | // `AsCustomList()`. |
1381 | | template <typename T> |
1382 | | std::enable_if_t<std::is_same_v<CustomListValue, T>, |
1383 | | optional_ref<const CustomListValue>> |
1384 | | As() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1385 | | return AsCustomList(); |
1386 | | } |
1387 | | template <typename T> |
1388 | | std::enable_if_t<std::is_same_v<CustomListValue, T>, |
1389 | | optional_ref<const CustomListValue>> |
1390 | | As() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1391 | | return AsCustomList(); |
1392 | | } |
1393 | | template <typename T> |
1394 | | std::enable_if_t<std::is_same_v<CustomListValue, T>, |
1395 | | absl::optional<CustomListValue>> |
1396 | | As() && { |
1397 | | return std::move(*this).AsCustomList(); |
1398 | | } |
1399 | | template <typename T> |
1400 | | std::enable_if_t<std::is_same_v<CustomListValue, T>, |
1401 | | absl::optional<CustomListValue>> |
1402 | | As() const&& { |
1403 | | return std::move(*this).AsCustomList(); |
1404 | | } |
1405 | | |
1406 | | // Convenience method for use with template metaprogramming. See |
1407 | | // `AsCustomMap()`. |
1408 | | template <typename T> |
1409 | | std::enable_if_t<std::is_same_v<CustomMapValue, T>, |
1410 | | optional_ref<const CustomMapValue>> |
1411 | | As() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1412 | | return AsCustomMap(); |
1413 | | } |
1414 | | template <typename T> |
1415 | | std::enable_if_t<std::is_same_v<CustomMapValue, T>, |
1416 | | optional_ref<const CustomMapValue>> |
1417 | | As() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1418 | | return AsCustomMap(); |
1419 | | } |
1420 | | template <typename T> |
1421 | | std::enable_if_t<std::is_same_v<CustomMapValue, T>, |
1422 | | absl::optional<CustomMapValue>> |
1423 | | As() && { |
1424 | | return std::move(*this).AsCustomMap(); |
1425 | | } |
1426 | | template <typename T> |
1427 | | std::enable_if_t<std::is_same_v<CustomMapValue, T>, |
1428 | | absl::optional<CustomMapValue>> |
1429 | | As() const&& { |
1430 | | return std::move(*this).AsCustomMap(); |
1431 | | } |
1432 | | |
1433 | | // Convenience method for use with template metaprogramming. See |
1434 | | // `AsParsedMapField()`. |
1435 | | template <typename T> |
1436 | | std::enable_if_t<std::is_same_v<ParsedMapFieldValue, T>, |
1437 | | optional_ref<const ParsedMapFieldValue>> |
1438 | | As() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1439 | | return AsParsedMapField(); |
1440 | | } |
1441 | | template <typename T> |
1442 | | std::enable_if_t<std::is_same_v<ParsedMapFieldValue, T>, |
1443 | | optional_ref<const ParsedMapFieldValue>> |
1444 | | As() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1445 | | return AsParsedMapField(); |
1446 | | } |
1447 | | template <typename T> |
1448 | | std::enable_if_t<std::is_same_v<ParsedMapFieldValue, T>, |
1449 | | absl::optional<ParsedMapFieldValue>> |
1450 | | As() && { |
1451 | | return std::move(*this).AsParsedMapField(); |
1452 | | } |
1453 | | template <typename T> |
1454 | | std::enable_if_t<std::is_same_v<ParsedMapFieldValue, T>, |
1455 | | absl::optional<ParsedMapFieldValue>> |
1456 | | As() const&& { |
1457 | | return std::move(*this).AsParsedMapField(); |
1458 | | } |
1459 | | |
1460 | | // Convenience method for use with template metaprogramming. See |
1461 | | // `AsParsedMessage()`. |
1462 | | template <typename T> |
1463 | | std::enable_if_t<std::is_same_v<ParsedMessageValue, T>, |
1464 | | optional_ref<const ParsedMessageValue>> |
1465 | | As() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1466 | | return AsParsedMessage(); |
1467 | | } |
1468 | | template <typename T> |
1469 | | std::enable_if_t<std::is_same_v<ParsedMessageValue, T>, |
1470 | | optional_ref<const ParsedMessageValue>> |
1471 | | As() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1472 | | return AsParsedMessage(); |
1473 | | } |
1474 | | template <typename T> |
1475 | | std::enable_if_t<std::is_same_v<ParsedMessageValue, T>, |
1476 | | absl::optional<ParsedMessageValue>> |
1477 | | As() && { |
1478 | | return std::move(*this).AsParsedMessage(); |
1479 | | } |
1480 | | template <typename T> |
1481 | | std::enable_if_t<std::is_same_v<ParsedMessageValue, T>, |
1482 | | absl::optional<ParsedMessageValue>> |
1483 | | As() const&& { |
1484 | | return std::move(*this).AsParsedMessage(); |
1485 | | } |
1486 | | |
1487 | | // Convenience method for use with template metaprogramming. See |
1488 | | // `AsParsedRepeatedField()`. |
1489 | | template <typename T> |
1490 | | std::enable_if_t<std::is_same_v<ParsedRepeatedFieldValue, T>, |
1491 | | optional_ref<const ParsedRepeatedFieldValue>> |
1492 | | As() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1493 | | return AsParsedRepeatedField(); |
1494 | | } |
1495 | | template <typename T> |
1496 | | std::enable_if_t<std::is_same_v<ParsedRepeatedFieldValue, T>, |
1497 | | optional_ref<const ParsedRepeatedFieldValue>> |
1498 | | As() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1499 | | return AsParsedRepeatedField(); |
1500 | | } |
1501 | | template <typename T> |
1502 | | std::enable_if_t<std::is_same_v<ParsedRepeatedFieldValue, T>, |
1503 | | absl::optional<ParsedRepeatedFieldValue>> |
1504 | | As() && { |
1505 | | return std::move(*this).AsParsedRepeatedField(); |
1506 | | } |
1507 | | template <typename T> |
1508 | | std::enable_if_t<std::is_same_v<ParsedRepeatedFieldValue, T>, |
1509 | | absl::optional<ParsedRepeatedFieldValue>> |
1510 | | As() const&& { |
1511 | | return std::move(*this).AsParsedRepeatedField(); |
1512 | | } |
1513 | | |
1514 | | // Convenience method for use with template metaprogramming. See |
1515 | | // `AsCustomStruct()`. |
1516 | | template <typename T> |
1517 | | std::enable_if_t<std::is_same_v<CustomStructValue, T>, |
1518 | | optional_ref<const CustomStructValue>> |
1519 | | As() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1520 | | return AsCustomStruct(); |
1521 | | } |
1522 | | template <typename T> |
1523 | | std::enable_if_t<std::is_same_v<CustomStructValue, T>, |
1524 | | optional_ref<const CustomStructValue>> |
1525 | | As() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1526 | | return AsCustomStruct(); |
1527 | | } |
1528 | | template <typename T> |
1529 | | std::enable_if_t<std::is_same_v<CustomStructValue, T>, |
1530 | | absl::optional<CustomStructValue>> |
1531 | | As() && { |
1532 | | return std::move(*this).AsCustomStruct(); |
1533 | | } |
1534 | | template <typename T> |
1535 | | std::enable_if_t<std::is_same_v<CustomStructValue, T>, |
1536 | | absl::optional<CustomStructValue>> |
1537 | | As() const&& { |
1538 | | return std::move(*this).AsCustomStruct(); |
1539 | | } |
1540 | | |
1541 | | // Convenience method for use with template metaprogramming. See |
1542 | | // `AsString()`. |
1543 | | template <typename T> |
1544 | | std::enable_if_t<std::is_same_v<StringValue, T>, |
1545 | | optional_ref<const StringValue>> |
1546 | | As() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1547 | | return AsString(); |
1548 | | } |
1549 | | template <typename T> |
1550 | | std::enable_if_t<std::is_same_v<StringValue, T>, |
1551 | | optional_ref<const StringValue>> |
1552 | 0 | As() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1553 | 0 | return AsString(); |
1554 | 0 | } |
1555 | | template <typename T> |
1556 | | std::enable_if_t<std::is_same_v<StringValue, T>, absl::optional<StringValue>> |
1557 | | As() && { |
1558 | | return std::move(*this).AsString(); |
1559 | | } |
1560 | | template <typename T> |
1561 | | std::enable_if_t<std::is_same_v<StringValue, T>, absl::optional<StringValue>> |
1562 | | As() const&& { |
1563 | | return std::move(*this).AsString(); |
1564 | | } |
1565 | | |
1566 | | // Convenience method for use with template metaprogramming. See |
1567 | | // `AsStruct()`. |
1568 | | template <typename T> |
1569 | | std::enable_if_t<std::is_same_v<StructValue, T>, absl::optional<StructValue>> |
1570 | | As() & { |
1571 | | return AsStruct(); |
1572 | | } |
1573 | | template <typename T> |
1574 | | std::enable_if_t<std::is_same_v<StructValue, T>, absl::optional<StructValue>> |
1575 | | As() const& { |
1576 | | return AsStruct(); |
1577 | | } |
1578 | | template <typename T> |
1579 | | std::enable_if_t<std::is_same_v<StructValue, T>, absl::optional<StructValue>> |
1580 | | As() && { |
1581 | | return std::move(*this).AsStruct(); |
1582 | | } |
1583 | | template <typename T> |
1584 | | std::enable_if_t<std::is_same_v<StructValue, T>, absl::optional<StructValue>> |
1585 | | As() const&& { |
1586 | | return std::move(*this).AsStruct(); |
1587 | | } |
1588 | | |
1589 | | // Convenience method for use with template metaprogramming. See |
1590 | | // `AsTimestamp()`. |
1591 | | template <typename T> |
1592 | | std::enable_if_t<std::is_same_v<TimestampValue, T>, |
1593 | | absl::optional<TimestampValue>> |
1594 | | As() & { |
1595 | | return AsTimestamp(); |
1596 | | } |
1597 | | template <typename T> |
1598 | | std::enable_if_t<std::is_same_v<TimestampValue, T>, |
1599 | | absl::optional<TimestampValue>> |
1600 | | As() const& { |
1601 | | return AsTimestamp(); |
1602 | | } |
1603 | | template <typename T> |
1604 | | std::enable_if_t<std::is_same_v<TimestampValue, T>, |
1605 | | absl::optional<TimestampValue>> |
1606 | | As() && { |
1607 | | return AsTimestamp(); |
1608 | | } |
1609 | | template <typename T> |
1610 | | std::enable_if_t<std::is_same_v<TimestampValue, T>, |
1611 | | absl::optional<TimestampValue>> |
1612 | | As() const&& { |
1613 | | return AsTimestamp(); |
1614 | | } |
1615 | | |
1616 | | // Convenience method for use with template metaprogramming. See |
1617 | | // `AsType()`. |
1618 | | template <typename T> |
1619 | | std::enable_if_t<std::is_same_v<TypeValue, T>, |
1620 | | optional_ref<const TypeValue>> |
1621 | | As() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1622 | | return AsType(); |
1623 | | } |
1624 | | template <typename T> |
1625 | | std::enable_if_t<std::is_same_v<TypeValue, T>, optional_ref<const TypeValue>> |
1626 | | As() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1627 | | return AsType(); |
1628 | | } |
1629 | | template <typename T> |
1630 | | std::enable_if_t<std::is_same_v<TypeValue, T>, absl::optional<TypeValue>> |
1631 | | As() && { |
1632 | | return std::move(*this).AsType(); |
1633 | | } |
1634 | | template <typename T> |
1635 | | std::enable_if_t<std::is_same_v<TypeValue, T>, absl::optional<TypeValue>> As() |
1636 | | const&& { |
1637 | | return std::move(*this).AsType(); |
1638 | | } |
1639 | | |
1640 | | // Convenience method for use with template metaprogramming. See |
1641 | | // `AsUint()`. |
1642 | | template <typename T> |
1643 | | std::enable_if_t<std::is_same_v<UintValue, T>, absl::optional<UintValue>> |
1644 | | As() & { |
1645 | | return AsUint(); |
1646 | | } |
1647 | | template <typename T> |
1648 | | std::enable_if_t<std::is_same_v<UintValue, T>, absl::optional<UintValue>> As() |
1649 | 0 | const& { |
1650 | 0 | return AsUint(); |
1651 | 0 | } |
1652 | | template <typename T> |
1653 | | std::enable_if_t<std::is_same_v<UintValue, T>, absl::optional<UintValue>> |
1654 | | As() && { |
1655 | | return AsUint(); |
1656 | | } |
1657 | | template <typename T> |
1658 | | std::enable_if_t<std::is_same_v<UintValue, T>, absl::optional<UintValue>> As() |
1659 | | const&& { |
1660 | | return AsUint(); |
1661 | | } |
1662 | | |
1663 | | // Convenience method for use with template metaprogramming. See |
1664 | | // `AsUnknown()`. |
1665 | | template <typename T> |
1666 | | std::enable_if_t<std::is_same_v<UnknownValue, T>, |
1667 | | optional_ref<UnknownValue>> |
1668 | | As() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1669 | | return AsUnknown(); |
1670 | | } |
1671 | | template <typename T> |
1672 | | std::enable_if_t<std::is_same_v<UnknownValue, T>, |
1673 | | optional_ref<const UnknownValue>> |
1674 | | As() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1675 | | return AsUnknown(); |
1676 | | } |
1677 | | template <typename T> |
1678 | | std::enable_if_t<std::is_same_v<UnknownValue, T>, |
1679 | | absl::optional<UnknownValue>> |
1680 | | As() && { |
1681 | | return std::move(*this).AsUnknown(); |
1682 | | } |
1683 | | template <typename T> |
1684 | | std::enable_if_t<std::is_same_v<UnknownValue, T>, |
1685 | | absl::optional<UnknownValue>> |
1686 | | As() const&& { |
1687 | | return std::move(*this).AsUnknown(); |
1688 | | } |
1689 | | |
1690 | | // Performs an unchecked cast from a value to a bool value. In |
1691 | | // debug builds a best effort is made to crash. If `IsBool()` would return |
1692 | | // false, calling this method is undefined behavior. |
1693 | 1.88M | BoolValue GetBool() const { |
1694 | 3.76M | ABSL_DCHECK(IsBool()) << *this; |
1695 | 1.88M | return variant_.Get<BoolValue>(); |
1696 | 1.88M | } |
1697 | | |
1698 | | // Performs an unchecked cast from a value to a bytes value. In |
1699 | | // debug builds a best effort is made to crash. If `IsBytes()` would return |
1700 | | // false, calling this method is undefined behavior. |
1701 | 0 | const BytesValue& GetBytes() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1702 | 0 | return std::as_const(*this).GetBytes(); |
1703 | 0 | } |
1704 | | const BytesValue& GetBytes() const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
1705 | | BytesValue GetBytes() &&; |
1706 | 0 | BytesValue GetBytes() const&& { return GetBytes(); } |
1707 | | |
1708 | | // Performs an unchecked cast from a value to a double value. In |
1709 | | // debug builds a best effort is made to crash. If `IsDouble()` would return |
1710 | | // false, calling this method is undefined behavior. |
1711 | | DoubleValue GetDouble() const; |
1712 | | |
1713 | | // Performs an unchecked cast from a value to a duration value. In |
1714 | | // debug builds a best effort is made to crash. If `IsDuration()` would return |
1715 | | // false, calling this method is undefined behavior. |
1716 | | DurationValue GetDuration() const; |
1717 | | |
1718 | | // Performs an unchecked cast from a value to an error value. In |
1719 | | // debug builds a best effort is made to crash. If `IsError()` would return |
1720 | | // false, calling this method is undefined behavior. |
1721 | 0 | const ErrorValue& GetError() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1722 | 0 | return std::as_const(*this).GetError(); |
1723 | 0 | } |
1724 | | const ErrorValue& GetError() const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
1725 | | ErrorValue GetError() &&; |
1726 | 0 | ErrorValue GetError() const&& { return GetError(); } |
1727 | | |
1728 | | // Performs an unchecked cast from a value to an int value. In |
1729 | | // debug builds a best effort is made to crash. If `IsInt()` would return |
1730 | | // false, calling this method is undefined behavior. |
1731 | | IntValue GetInt() const; |
1732 | | |
1733 | | // Performs an unchecked cast from a value to a list value. In |
1734 | | // debug builds a best effort is made to crash. If `IsList()` would return |
1735 | | // false, calling this method is undefined behavior. |
1736 | 0 | ListValue GetList() & { return std::as_const(*this).GetList(); } |
1737 | | ListValue GetList() const&; |
1738 | | ListValue GetList() &&; |
1739 | 0 | ListValue GetList() const&& { return GetList(); } |
1740 | | |
1741 | | // Performs an unchecked cast from a value to a map value. In |
1742 | | // debug builds a best effort is made to crash. If `IsMap()` would return |
1743 | | // false, calling this method is undefined behavior. |
1744 | 0 | MapValue GetMap() & { return std::as_const(*this).GetMap(); } |
1745 | | MapValue GetMap() const&; |
1746 | | MapValue GetMap() &&; |
1747 | 0 | MapValue GetMap() const&& { return GetMap(); } |
1748 | | |
1749 | | // Performs an unchecked cast from a value to a message value. In |
1750 | | // debug builds a best effort is made to crash. If `IsMessage()` would return |
1751 | | // false, calling this method is undefined behavior. |
1752 | 0 | MessageValue GetMessage() & { return std::as_const(*this).GetMessage(); } |
1753 | | MessageValue GetMessage() const&; |
1754 | | MessageValue GetMessage() &&; |
1755 | 0 | MessageValue GetMessage() const&& { return GetMessage(); } |
1756 | | |
1757 | | // Performs an unchecked cast from a value to a null value. In |
1758 | | // debug builds a best effort is made to crash. If `IsNull()` would return |
1759 | | // false, calling this method is undefined behavior. |
1760 | | NullValue GetNull() const; |
1761 | | |
1762 | | // Performs an unchecked cast from a value to an opaque value. In |
1763 | | // debug builds a best effort is made to crash. If `IsOpaque()` would return |
1764 | | // false, calling this method is undefined behavior. |
1765 | 0 | const OpaqueValue& GetOpaque() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1766 | 0 | return std::as_const(*this).GetOpaque(); |
1767 | 0 | } |
1768 | | const OpaqueValue& GetOpaque() const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
1769 | | OpaqueValue GetOpaque() &&; |
1770 | 0 | OpaqueValue GetOpaque() const&& { return GetOpaque(); } |
1771 | | |
1772 | | // Performs an unchecked cast from a value to an optional value. In |
1773 | | // debug builds a best effort is made to crash. If `IsOptional()` would return |
1774 | | // false, calling this method is undefined behavior. |
1775 | 0 | const OptionalValue& GetOptional() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1776 | 0 | return std::as_const(*this).GetOptional(); |
1777 | 0 | } |
1778 | | const OptionalValue& GetOptional() const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
1779 | | OptionalValue GetOptional() &&; |
1780 | 0 | OptionalValue GetOptional() const&& { return GetOptional(); } |
1781 | | |
1782 | | // Performs an unchecked cast from a value to a parsed message value. In |
1783 | | // debug builds a best effort is made to crash. If `IsParsedJsonList()` would |
1784 | | // return false, calling this method is undefined behavior. |
1785 | | const ParsedJsonListValue& GetParsedJsonList() & |
1786 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1787 | 0 | return std::as_const(*this).GetParsedJsonList(); |
1788 | 0 | } |
1789 | | const ParsedJsonListValue& GetParsedJsonList() |
1790 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
1791 | | ParsedJsonListValue GetParsedJsonList() &&; |
1792 | 0 | ParsedJsonListValue GetParsedJsonList() const&& { |
1793 | 0 | return GetParsedJsonList(); |
1794 | 0 | } |
1795 | | |
1796 | | // Performs an unchecked cast from a value to a parsed message value. In |
1797 | | // debug builds a best effort is made to crash. If `IsParsedJsonMap()` would |
1798 | | // return false, calling this method is undefined behavior. |
1799 | 0 | const ParsedJsonMapValue& GetParsedJsonMap() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1800 | 0 | return std::as_const(*this).GetParsedJsonMap(); |
1801 | 0 | } |
1802 | | const ParsedJsonMapValue& GetParsedJsonMap() |
1803 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
1804 | | ParsedJsonMapValue GetParsedJsonMap() &&; |
1805 | 0 | ParsedJsonMapValue GetParsedJsonMap() const&& { return GetParsedJsonMap(); } |
1806 | | |
1807 | | // Performs an unchecked cast from a value to a custom list value. In |
1808 | | // debug builds a best effort is made to crash. If `IsCustomList()` would |
1809 | | // return false, calling this method is undefined behavior. |
1810 | 0 | const CustomListValue& GetCustomList() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1811 | 0 | return std::as_const(*this).GetCustomList(); |
1812 | 0 | } |
1813 | | const CustomListValue& GetCustomList() const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
1814 | | CustomListValue GetCustomList() &&; |
1815 | 0 | CustomListValue GetCustomList() const&& { return GetCustomList(); } |
1816 | | |
1817 | | // Performs an unchecked cast from a value to a custom map value. In |
1818 | | // debug builds a best effort is made to crash. If `IsCustomMap()` would |
1819 | | // return false, calling this method is undefined behavior. |
1820 | 0 | const CustomMapValue& GetCustomMap() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1821 | 0 | return std::as_const(*this).GetCustomMap(); |
1822 | 0 | } |
1823 | | const CustomMapValue& GetCustomMap() const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
1824 | | CustomMapValue GetCustomMap() &&; |
1825 | 0 | CustomMapValue GetCustomMap() const&& { return GetCustomMap(); } |
1826 | | |
1827 | | // Performs an unchecked cast from a value to a parsed map field value. In |
1828 | | // debug builds a best effort is made to crash. If `IsParsedMapField()` would |
1829 | | // return false, calling this method is undefined behavior. |
1830 | | const ParsedMapFieldValue& GetParsedMapField() & |
1831 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1832 | 0 | return std::as_const(*this).GetParsedMapField(); |
1833 | 0 | } |
1834 | | const ParsedMapFieldValue& GetParsedMapField() |
1835 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
1836 | | ParsedMapFieldValue GetParsedMapField() &&; |
1837 | 0 | ParsedMapFieldValue GetParsedMapField() const&& { |
1838 | 0 | return GetParsedMapField(); |
1839 | 0 | } |
1840 | | |
1841 | | // Performs an unchecked cast from a value to a parsed message value. In |
1842 | | // debug builds a best effort is made to crash. If `IsParsedMessage()` would |
1843 | | // return false, calling this method is undefined behavior. |
1844 | 0 | const ParsedMessageValue& GetParsedMessage() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1845 | 0 | return std::as_const(*this).GetParsedMessage(); |
1846 | 0 | } |
1847 | | const ParsedMessageValue& GetParsedMessage() |
1848 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
1849 | | ParsedMessageValue GetParsedMessage() &&; |
1850 | 0 | ParsedMessageValue GetParsedMessage() const&& { return GetParsedMessage(); } |
1851 | | |
1852 | | // Performs an unchecked cast from a value to a parsed repeated field value. |
1853 | | // In debug builds a best effort is made to crash. If |
1854 | | // `IsParsedRepeatedField()` would return false, calling this method is |
1855 | | // undefined behavior. |
1856 | | const ParsedRepeatedFieldValue& GetParsedRepeatedField() & |
1857 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1858 | 0 | return std::as_const(*this).GetParsedRepeatedField(); |
1859 | 0 | } |
1860 | | const ParsedRepeatedFieldValue& GetParsedRepeatedField() |
1861 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
1862 | | ParsedRepeatedFieldValue GetParsedRepeatedField() &&; |
1863 | 0 | ParsedRepeatedFieldValue GetParsedRepeatedField() const&& { |
1864 | 0 | return GetParsedRepeatedField(); |
1865 | 0 | } |
1866 | | |
1867 | | // Performs an unchecked cast from a value to a custom struct value. In |
1868 | | // debug builds a best effort is made to crash. If `IsCustomStruct()` would |
1869 | | // return false, calling this method is undefined behavior. |
1870 | 0 | const CustomStructValue& GetCustomStruct() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1871 | 0 | return std::as_const(*this).GetCustomStruct(); |
1872 | 0 | } |
1873 | | const CustomStructValue& GetCustomStruct() |
1874 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
1875 | | CustomStructValue GetCustomStruct() &&; |
1876 | 0 | CustomStructValue GetCustomStruct() const&& { return GetCustomStruct(); } |
1877 | | |
1878 | | // Performs an unchecked cast from a value to a string value. In |
1879 | | // debug builds a best effort is made to crash. If `IsString()` would return |
1880 | | // false, calling this method is undefined behavior. |
1881 | 0 | const StringValue& GetString() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1882 | 0 | return std::as_const(*this).GetString(); |
1883 | 0 | } |
1884 | | const StringValue& GetString() const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
1885 | | StringValue GetString() &&; |
1886 | 0 | StringValue GetString() const&& { return GetString(); } |
1887 | | |
1888 | | // Performs an unchecked cast from a value to a struct value. In |
1889 | | // debug builds a best effort is made to crash. If `IsStruct()` would return |
1890 | | // false, calling this method is undefined behavior. |
1891 | 0 | StructValue GetStruct() & { return std::as_const(*this).GetStruct(); } |
1892 | | StructValue GetStruct() const&; |
1893 | | StructValue GetStruct() &&; |
1894 | 0 | StructValue GetStruct() const&& { return GetStruct(); } |
1895 | | |
1896 | | // Performs an unchecked cast from a value to a timestamp value. In |
1897 | | // debug builds a best effort is made to crash. If `IsTimestamp()` would |
1898 | | // return false, calling this method is undefined behavior. |
1899 | | TimestampValue GetTimestamp() const; |
1900 | | |
1901 | | // Performs an unchecked cast from a value to a type value. In |
1902 | | // debug builds a best effort is made to crash. If `IsType()` would return |
1903 | | // false, calling this method is undefined behavior. |
1904 | 0 | const TypeValue& GetType() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1905 | 0 | return std::as_const(*this).GetType(); |
1906 | 0 | } |
1907 | | const TypeValue& GetType() const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
1908 | | TypeValue GetType() &&; |
1909 | 0 | TypeValue GetType() const&& { return GetType(); } |
1910 | | |
1911 | | // Performs an unchecked cast from a value to an uint value. In |
1912 | | // debug builds a best effort is made to crash. If `IsUint()` would return |
1913 | | // false, calling this method is undefined behavior. |
1914 | | UintValue GetUint() const; |
1915 | | |
1916 | | // Performs an unchecked cast from a value to an unknown value. In |
1917 | | // debug builds a best effort is made to crash. If `IsUnknown()` would return |
1918 | | // false, calling this method is undefined behavior. |
1919 | 0 | const UnknownValue& GetUnknown() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1920 | 0 | return std::as_const(*this).GetUnknown(); |
1921 | 0 | } |
1922 | | const UnknownValue& GetUnknown() const& ABSL_ATTRIBUTE_LIFETIME_BOUND; |
1923 | | UnknownValue GetUnknown() &&; |
1924 | 0 | UnknownValue GetUnknown() const&& { return GetUnknown(); } |
1925 | | |
1926 | | // Convenience method for use with template metaprogramming. See |
1927 | | // `GetBool()`. |
1928 | | template <typename T> |
1929 | | std::enable_if_t<std::is_same_v<BoolValue, T>, BoolValue> Get() & { |
1930 | | return GetBool(); |
1931 | | } |
1932 | | template <typename T> |
1933 | 4.29k | std::enable_if_t<std::is_same_v<BoolValue, T>, BoolValue> Get() const& { |
1934 | 4.29k | return GetBool(); |
1935 | 4.29k | } |
1936 | | template <typename T> |
1937 | | std::enable_if_t<std::is_same_v<BoolValue, T>, BoolValue> Get() && { |
1938 | | return GetBool(); |
1939 | | } |
1940 | | template <typename T> |
1941 | | std::enable_if_t<std::is_same_v<BoolValue, T>, BoolValue> Get() const&& { |
1942 | | return GetBool(); |
1943 | | } |
1944 | | |
1945 | | // Convenience method for use with template metaprogramming. See |
1946 | | // `GetBytes()`. |
1947 | | template <typename T> |
1948 | | std::enable_if_t<std::is_same_v<BytesValue, T>, const BytesValue&> Get() & |
1949 | | ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1950 | | return GetBytes(); |
1951 | | } |
1952 | | template <typename T> |
1953 | | std::enable_if_t<std::is_same_v<BytesValue, T>, const BytesValue&> Get() |
1954 | 7.91k | const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
1955 | 7.91k | return GetBytes(); |
1956 | 7.91k | } |
1957 | | template <typename T> |
1958 | | std::enable_if_t<std::is_same_v<BytesValue, T>, BytesValue> Get() && { |
1959 | | return std::move(*this).GetBytes(); |
1960 | | } |
1961 | | template <typename T> |
1962 | | std::enable_if_t<std::is_same_v<BytesValue, T>, BytesValue> Get() const&& { |
1963 | | return std::move(*this).GetBytes(); |
1964 | | } |
1965 | | |
1966 | | // Convenience method for use with template metaprogramming. See |
1967 | | // `GetDouble()`. |
1968 | | template <typename T> |
1969 | | std::enable_if_t<std::is_same_v<DoubleValue, T>, DoubleValue> Get() & { |
1970 | | return GetDouble(); |
1971 | | } |
1972 | | template <typename T> |
1973 | 758 | std::enable_if_t<std::is_same_v<DoubleValue, T>, DoubleValue> Get() const& { |
1974 | 758 | return GetDouble(); |
1975 | 758 | } |
1976 | | template <typename T> |
1977 | | std::enable_if_t<std::is_same_v<DoubleValue, T>, DoubleValue> Get() && { |
1978 | | return GetDouble(); |
1979 | | } |
1980 | | template <typename T> |
1981 | | std::enable_if_t<std::is_same_v<DoubleValue, T>, DoubleValue> Get() const&& { |
1982 | | return GetDouble(); |
1983 | | } |
1984 | | |
1985 | | // Convenience method for use with template metaprogramming. See |
1986 | | // `GetDuration()`. |
1987 | | template <typename T> |
1988 | | std::enable_if_t<std::is_same_v<DurationValue, T>, DurationValue> Get() & { |
1989 | | return GetDuration(); |
1990 | | } |
1991 | | template <typename T> |
1992 | | std::enable_if_t<std::is_same_v<DurationValue, T>, DurationValue> Get() |
1993 | 473 | const& { |
1994 | 473 | return GetDuration(); |
1995 | 473 | } |
1996 | | template <typename T> |
1997 | | std::enable_if_t<std::is_same_v<DurationValue, T>, DurationValue> Get() && { |
1998 | | return GetDuration(); |
1999 | | } |
2000 | | template <typename T> |
2001 | | std::enable_if_t<std::is_same_v<DurationValue, T>, DurationValue> Get() |
2002 | | const&& { |
2003 | | return GetDuration(); |
2004 | | } |
2005 | | |
2006 | | // Convenience method for use with template metaprogramming. See |
2007 | | // `GetError()`. |
2008 | | template <typename T> |
2009 | | std::enable_if_t<std::is_same_v<ErrorValue, T>, const ErrorValue&> Get() & |
2010 | | ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2011 | | return GetError(); |
2012 | | } |
2013 | | template <typename T> |
2014 | | std::enable_if_t<std::is_same_v<ErrorValue, T>, const ErrorValue&> Get() |
2015 | 10.4k | const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2016 | 10.4k | return GetError(); |
2017 | 10.4k | } |
2018 | | template <typename T> |
2019 | | std::enable_if_t<std::is_same_v<ErrorValue, T>, ErrorValue> Get() && { |
2020 | | return std::move(*this).GetError(); |
2021 | | } |
2022 | | template <typename T> |
2023 | | std::enable_if_t<std::is_same_v<ErrorValue, T>, ErrorValue> Get() const&& { |
2024 | | return std::move(*this).GetError(); |
2025 | | } |
2026 | | |
2027 | | // Convenience method for use with template metaprogramming. See |
2028 | | // `GetInt()`. |
2029 | | template <typename T> |
2030 | | std::enable_if_t<std::is_same_v<IntValue, T>, IntValue> Get() & { |
2031 | | return GetInt(); |
2032 | | } |
2033 | | template <typename T> |
2034 | 608 | std::enable_if_t<std::is_same_v<IntValue, T>, IntValue> Get() const& { |
2035 | 608 | return GetInt(); |
2036 | 608 | } |
2037 | | template <typename T> |
2038 | | std::enable_if_t<std::is_same_v<IntValue, T>, IntValue> Get() && { |
2039 | | return GetInt(); |
2040 | | } |
2041 | | template <typename T> |
2042 | | std::enable_if_t<std::is_same_v<IntValue, T>, IntValue> Get() const&& { |
2043 | | return GetInt(); |
2044 | | } |
2045 | | |
2046 | | // Convenience method for use with template metaprogramming. See |
2047 | | // `GetList()`. |
2048 | | template <typename T> |
2049 | | std::enable_if_t<std::is_same_v<ListValue, T>, ListValue> Get() & { |
2050 | | return GetList(); |
2051 | | } |
2052 | | template <typename T> |
2053 | 948k | std::enable_if_t<std::is_same_v<ListValue, T>, ListValue> Get() const& { |
2054 | 948k | return GetList(); |
2055 | 948k | } |
2056 | | template <typename T> |
2057 | | std::enable_if_t<std::is_same_v<ListValue, T>, ListValue> Get() && { |
2058 | | return std::move(*this).GetList(); |
2059 | | } |
2060 | | template <typename T> |
2061 | | std::enable_if_t<std::is_same_v<ListValue, T>, ListValue> Get() const&& { |
2062 | | return std::move(*this).GetList(); |
2063 | | } |
2064 | | |
2065 | | // Convenience method for use with template metaprogramming. See |
2066 | | // `GetMap()`. |
2067 | | template <typename T> |
2068 | | std::enable_if_t<std::is_same_v<MapValue, T>, MapValue> Get() & { |
2069 | | return GetMap(); |
2070 | | } |
2071 | | template <typename T> |
2072 | 226 | std::enable_if_t<std::is_same_v<MapValue, T>, MapValue> Get() const& { |
2073 | 226 | return GetMap(); |
2074 | 226 | } |
2075 | | template <typename T> |
2076 | | std::enable_if_t<std::is_same_v<MapValue, T>, MapValue> Get() && { |
2077 | | return std::move(*this).GetMap(); |
2078 | | } |
2079 | | template <typename T> |
2080 | | std::enable_if_t<std::is_same_v<MapValue, T>, MapValue> Get() const&& { |
2081 | | return std::move(*this).GetMap(); |
2082 | | } |
2083 | | |
2084 | | // Convenience method for use with template metaprogramming. See |
2085 | | // `GetMessage()`. |
2086 | | template <typename T> |
2087 | | std::enable_if_t<std::is_same_v<MessageValue, T>, MessageValue> Get() & { |
2088 | | return GetMessage(); |
2089 | | } |
2090 | | template <typename T> |
2091 | | std::enable_if_t<std::is_same_v<MessageValue, T>, MessageValue> Get() const& { |
2092 | | return GetMessage(); |
2093 | | } |
2094 | | template <typename T> |
2095 | | std::enable_if_t<std::is_same_v<MessageValue, T>, MessageValue> Get() && { |
2096 | | return std::move(*this).GetMessage(); |
2097 | | } |
2098 | | template <typename T> |
2099 | | std::enable_if_t<std::is_same_v<MessageValue, T>, MessageValue> Get() |
2100 | | const&& { |
2101 | | return std::move(*this).GetMessage(); |
2102 | | } |
2103 | | |
2104 | | // Convenience method for use with template metaprogramming. See |
2105 | | // `GetNull()`. |
2106 | | template <typename T> |
2107 | | std::enable_if_t<std::is_same_v<NullValue, T>, NullValue> Get() & { |
2108 | | return GetNull(); |
2109 | | } |
2110 | | template <typename T> |
2111 | 0 | std::enable_if_t<std::is_same_v<NullValue, T>, NullValue> Get() const& { |
2112 | 0 | return GetNull(); |
2113 | 0 | } |
2114 | | template <typename T> |
2115 | | std::enable_if_t<std::is_same_v<NullValue, T>, NullValue> Get() && { |
2116 | | return GetNull(); |
2117 | | } |
2118 | | template <typename T> |
2119 | | std::enable_if_t<std::is_same_v<NullValue, T>, NullValue> Get() const&& { |
2120 | | return GetNull(); |
2121 | | } |
2122 | | |
2123 | | // Convenience method for use with template metaprogramming. See |
2124 | | // `GetOpaque()`. |
2125 | | template <typename T> |
2126 | | std::enable_if_t<std::is_same_v<OpaqueValue, T>, const OpaqueValue&> |
2127 | | Get() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2128 | | return GetOpaque(); |
2129 | | } |
2130 | | template <typename T> |
2131 | | std::enable_if_t<std::is_same_v<OpaqueValue, T>, const OpaqueValue&> Get() |
2132 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2133 | | return GetOpaque(); |
2134 | | } |
2135 | | template <typename T> |
2136 | | std::enable_if_t<std::is_same_v<OpaqueValue, T>, OpaqueValue> Get() && { |
2137 | | return std::move(*this).GetOpaque(); |
2138 | | } |
2139 | | template <typename T> |
2140 | | std::enable_if_t<std::is_same_v<OpaqueValue, T>, OpaqueValue> Get() const&& { |
2141 | | return std::move(*this).GetOpaque(); |
2142 | | } |
2143 | | |
2144 | | // Convenience method for use with template metaprogramming. See |
2145 | | // `GetOptional()`. |
2146 | | template <typename T> |
2147 | | std::enable_if_t<std::is_same_v<OptionalValue, T>, const OptionalValue&> |
2148 | | Get() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2149 | | return GetOptional(); |
2150 | | } |
2151 | | template <typename T> |
2152 | | std::enable_if_t<std::is_same_v<OptionalValue, T>, const OptionalValue&> Get() |
2153 | | const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2154 | | return GetOptional(); |
2155 | | } |
2156 | | template <typename T> |
2157 | | std::enable_if_t<std::is_same_v<OptionalValue, T>, OptionalValue> Get() && { |
2158 | | return std::move(*this).GetOptional(); |
2159 | | } |
2160 | | template <typename T> |
2161 | | std::enable_if_t<std::is_same_v<OptionalValue, T>, OptionalValue> Get() |
2162 | | const&& { |
2163 | | return std::move(*this).GetOptional(); |
2164 | | } |
2165 | | |
2166 | | // Convenience method for use with template metaprogramming. See |
2167 | | // `GetParsedJsonList()`. |
2168 | | template <typename T> |
2169 | | std::enable_if_t<std::is_same_v<ParsedJsonListValue, T>, |
2170 | | const ParsedJsonListValue&> |
2171 | | Get() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2172 | | return GetParsedJsonList(); |
2173 | | } |
2174 | | template <typename T> |
2175 | | std::enable_if_t<std::is_same_v<ParsedJsonListValue, T>, |
2176 | | const ParsedJsonListValue&> |
2177 | | Get() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2178 | | return GetParsedJsonList(); |
2179 | | } |
2180 | | template <typename T> |
2181 | | std::enable_if_t<std::is_same_v<ParsedJsonListValue, T>, ParsedJsonListValue> |
2182 | | Get() && { |
2183 | | return std::move(*this).GetParsedJsonList(); |
2184 | | } |
2185 | | template <typename T> |
2186 | | std::enable_if_t<std::is_same_v<ParsedJsonListValue, T>, ParsedJsonListValue> |
2187 | | Get() const&& { |
2188 | | return std::move(*this).GetParsedJsonList(); |
2189 | | } |
2190 | | |
2191 | | // Convenience method for use with template metaprogramming. See |
2192 | | // `GetParsedJsonMap()`. |
2193 | | template <typename T> |
2194 | | std::enable_if_t<std::is_same_v<ParsedJsonMapValue, T>, |
2195 | | const ParsedJsonMapValue&> |
2196 | | Get() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2197 | | return GetParsedJsonMap(); |
2198 | | } |
2199 | | template <typename T> |
2200 | | std::enable_if_t<std::is_same_v<ParsedJsonMapValue, T>, |
2201 | | const ParsedJsonMapValue&> |
2202 | | Get() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2203 | | return GetParsedJsonMap(); |
2204 | | } |
2205 | | template <typename T> |
2206 | | std::enable_if_t<std::is_same_v<ParsedJsonMapValue, T>, ParsedJsonMapValue> |
2207 | | Get() && { |
2208 | | return std::move(*this).GetParsedJsonMap(); |
2209 | | } |
2210 | | template <typename T> |
2211 | | std::enable_if_t<std::is_same_v<ParsedJsonMapValue, T>, ParsedJsonMapValue> |
2212 | | Get() const&& { |
2213 | | return std::move(*this).GetParsedJsonMap(); |
2214 | | } |
2215 | | |
2216 | | // Convenience method for use with template metaprogramming. See |
2217 | | // `GetCustomList()`. |
2218 | | template <typename T> |
2219 | | std::enable_if_t<std::is_same_v<CustomListValue, T>, |
2220 | | const CustomListValue&> |
2221 | | Get() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2222 | | return GetCustomList(); |
2223 | | } |
2224 | | template <typename T> |
2225 | | std::enable_if_t<std::is_same_v<CustomListValue, T>, const CustomListValue&> |
2226 | | Get() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2227 | | return GetCustomList(); |
2228 | | } |
2229 | | template <typename T> |
2230 | | std::enable_if_t<std::is_same_v<CustomListValue, T>, CustomListValue> |
2231 | | Get() && { |
2232 | | return std::move(*this).GetCustomList(); |
2233 | | } |
2234 | | template <typename T> |
2235 | | std::enable_if_t<std::is_same_v<CustomListValue, T>, CustomListValue> Get() |
2236 | | const&& { |
2237 | | return std::move(*this).GetCustomList(); |
2238 | | } |
2239 | | |
2240 | | // Convenience method for use with template metaprogramming. See |
2241 | | // `GetCustomMap()`. |
2242 | | template <typename T> |
2243 | | std::enable_if_t<std::is_same_v<CustomMapValue, T>, const CustomMapValue&> |
2244 | | Get() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2245 | | return GetCustomMap(); |
2246 | | } |
2247 | | template <typename T> |
2248 | | std::enable_if_t<std::is_same_v<CustomMapValue, T>, const CustomMapValue&> |
2249 | | Get() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2250 | | return GetCustomMap(); |
2251 | | } |
2252 | | template <typename T> |
2253 | | std::enable_if_t<std::is_same_v<CustomMapValue, T>, CustomMapValue> Get() && { |
2254 | | return std::move(*this).GetCustomMap(); |
2255 | | } |
2256 | | template <typename T> |
2257 | | std::enable_if_t<std::is_same_v<CustomMapValue, T>, CustomMapValue> Get() |
2258 | | const&& { |
2259 | | return std::move(*this).GetCustomMap(); |
2260 | | } |
2261 | | |
2262 | | // Convenience method for use with template metaprogramming. See |
2263 | | // `GetParsedMapField()`. |
2264 | | template <typename T> |
2265 | | std::enable_if_t<std::is_same_v<ParsedMapFieldValue, T>, |
2266 | | const ParsedMapFieldValue&> |
2267 | | Get() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2268 | | return GetParsedMapField(); |
2269 | | } |
2270 | | template <typename T> |
2271 | | std::enable_if_t<std::is_same_v<ParsedMapFieldValue, T>, |
2272 | | const ParsedMapFieldValue&> |
2273 | | Get() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2274 | | return GetParsedMapField(); |
2275 | | } |
2276 | | template <typename T> |
2277 | | std::enable_if_t<std::is_same_v<ParsedMapFieldValue, T>, ParsedMapFieldValue> |
2278 | | Get() && { |
2279 | | return std::move(*this).GetParsedMapField(); |
2280 | | } |
2281 | | template <typename T> |
2282 | | std::enable_if_t<std::is_same_v<ParsedMapFieldValue, T>, ParsedMapFieldValue> |
2283 | | Get() const&& { |
2284 | | return std::move(*this).GetParsedMapField(); |
2285 | | } |
2286 | | |
2287 | | // Convenience method for use with template metaprogramming. See |
2288 | | // `GetParsedMessage()`. |
2289 | | template <typename T> |
2290 | | std::enable_if_t<std::is_same_v<ParsedMessageValue, T>, |
2291 | | const ParsedMessageValue&> |
2292 | | Get() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2293 | | return GetParsedMessage(); |
2294 | | } |
2295 | | template <typename T> |
2296 | | std::enable_if_t<std::is_same_v<ParsedMessageValue, T>, |
2297 | | const ParsedMessageValue&> |
2298 | | Get() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2299 | | return GetParsedMessage(); |
2300 | | } |
2301 | | template <typename T> |
2302 | | std::enable_if_t<std::is_same_v<ParsedMessageValue, T>, ParsedMessageValue> |
2303 | | Get() && { |
2304 | | return std::move(*this).GetParsedMessage(); |
2305 | | } |
2306 | | template <typename T> |
2307 | | std::enable_if_t<std::is_same_v<ParsedMessageValue, T>, ParsedMessageValue> |
2308 | | Get() const&& { |
2309 | | return std::move(*this).GetParsedMessage(); |
2310 | | } |
2311 | | |
2312 | | // Convenience method for use with template metaprogramming. See |
2313 | | // `GetParsedRepeatedField()`. |
2314 | | template <typename T> |
2315 | | std::enable_if_t<std::is_same_v<ParsedRepeatedFieldValue, T>, |
2316 | | const ParsedRepeatedFieldValue&> |
2317 | | Get() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2318 | | return GetParsedRepeatedField(); |
2319 | | } |
2320 | | template <typename T> |
2321 | | std::enable_if_t<std::is_same_v<ParsedRepeatedFieldValue, T>, |
2322 | | const ParsedRepeatedFieldValue&> |
2323 | | Get() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2324 | | return GetParsedRepeatedField(); |
2325 | | } |
2326 | | template <typename T> |
2327 | | std::enable_if_t<std::is_same_v<ParsedRepeatedFieldValue, T>, |
2328 | | ParsedRepeatedFieldValue> |
2329 | | Get() && { |
2330 | | return std::move(*this).GetParsedRepeatedField(); |
2331 | | } |
2332 | | template <typename T> |
2333 | | std::enable_if_t<std::is_same_v<ParsedRepeatedFieldValue, T>, |
2334 | | ParsedRepeatedFieldValue> |
2335 | | Get() const&& { |
2336 | | return std::move(*this).GetParsedRepeatedField(); |
2337 | | } |
2338 | | |
2339 | | // Convenience method for use with template metaprogramming. See |
2340 | | // `GetCustomStruct()`. |
2341 | | template <typename T> |
2342 | | std::enable_if_t<std::is_same_v<CustomStructValue, T>, |
2343 | | const CustomStructValue&> |
2344 | | Get() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2345 | | return GetCustomStruct(); |
2346 | | } |
2347 | | template <typename T> |
2348 | | std::enable_if_t<std::is_same_v<CustomStructValue, T>, |
2349 | | const CustomStructValue&> |
2350 | | Get() const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2351 | | return GetCustomStruct(); |
2352 | | } |
2353 | | template <typename T> |
2354 | | std::enable_if_t<std::is_same_v<CustomStructValue, T>, CustomStructValue> |
2355 | | Get() && { |
2356 | | return std::move(*this).GetCustomStruct(); |
2357 | | } |
2358 | | template <typename T> |
2359 | | std::enable_if_t<std::is_same_v<CustomStructValue, T>, CustomStructValue> |
2360 | | Get() const&& { |
2361 | | return std::move(*this).GetCustomStruct(); |
2362 | | } |
2363 | | |
2364 | | // Convenience method for use with template metaprogramming. See |
2365 | | // `GetString()`. |
2366 | | template <typename T> |
2367 | | std::enable_if_t<std::is_same_v<StringValue, T>, const StringValue&> |
2368 | | Get() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2369 | | return GetString(); |
2370 | | } |
2371 | | template <typename T> |
2372 | | std::enable_if_t<std::is_same_v<StringValue, T>, const StringValue&> Get() |
2373 | 246k | const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2374 | 246k | return GetString(); |
2375 | 246k | } |
2376 | | template <typename T> |
2377 | | std::enable_if_t<std::is_same_v<StringValue, T>, StringValue> Get() && { |
2378 | | return std::move(*this).GetString(); |
2379 | | } |
2380 | | template <typename T> |
2381 | | std::enable_if_t<std::is_same_v<StringValue, T>, StringValue> Get() const&& { |
2382 | | return std::move(*this).GetString(); |
2383 | | } |
2384 | | |
2385 | | // Convenience method for use with template metaprogramming. See |
2386 | | // `GetStruct()`. |
2387 | | template <typename T> |
2388 | | std::enable_if_t<std::is_same_v<StructValue, T>, StructValue> Get() & { |
2389 | | return GetStruct(); |
2390 | | } |
2391 | | template <typename T> |
2392 | 0 | std::enable_if_t<std::is_same_v<StructValue, T>, StructValue> Get() const& { |
2393 | 0 | return GetStruct(); |
2394 | 0 | } |
2395 | | template <typename T> |
2396 | | std::enable_if_t<std::is_same_v<StructValue, T>, StructValue> Get() && { |
2397 | | return std::move(*this).GetStruct(); |
2398 | | } |
2399 | | template <typename T> |
2400 | | std::enable_if_t<std::is_same_v<StructValue, T>, StructValue> Get() const&& { |
2401 | | return std::move(*this).GetStruct(); |
2402 | | } |
2403 | | |
2404 | | // Convenience method for use with template metaprogramming. See |
2405 | | // `GetTimestamp()`. |
2406 | | template <typename T> |
2407 | | std::enable_if_t<std::is_same_v<TimestampValue, T>, TimestampValue> Get() & { |
2408 | | return GetTimestamp(); |
2409 | | } |
2410 | | template <typename T> |
2411 | | std::enable_if_t<std::is_same_v<TimestampValue, T>, TimestampValue> Get() |
2412 | 220 | const& { |
2413 | 220 | return GetTimestamp(); |
2414 | 220 | } |
2415 | | template <typename T> |
2416 | | std::enable_if_t<std::is_same_v<TimestampValue, T>, TimestampValue> Get() && { |
2417 | | return GetTimestamp(); |
2418 | | } |
2419 | | template <typename T> |
2420 | | std::enable_if_t<std::is_same_v<TimestampValue, T>, TimestampValue> Get() |
2421 | | const&& { |
2422 | | return GetTimestamp(); |
2423 | | } |
2424 | | |
2425 | | // Convenience method for use with template metaprogramming. See |
2426 | | // `GetType()`. |
2427 | | template <typename T> |
2428 | | std::enable_if_t<std::is_same_v<TypeValue, T>, const TypeValue&> Get() & |
2429 | | ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2430 | | return GetType(); |
2431 | | } |
2432 | | template <typename T> |
2433 | | std::enable_if_t<std::is_same_v<TypeValue, T>, const TypeValue&> Get() |
2434 | 21 | const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2435 | 21 | return GetType(); |
2436 | 21 | } |
2437 | | template <typename T> |
2438 | | std::enable_if_t<std::is_same_v<TypeValue, T>, TypeValue> Get() && { |
2439 | | return std::move(*this).GetType(); |
2440 | | } |
2441 | | template <typename T> |
2442 | | std::enable_if_t<std::is_same_v<TypeValue, T>, TypeValue> Get() const&& { |
2443 | | return std::move(*this).GetType(); |
2444 | | } |
2445 | | |
2446 | | // Convenience method for use with template metaprogramming. See |
2447 | | // `GetUint()`. |
2448 | | template <typename T> |
2449 | | std::enable_if_t<std::is_same_v<UintValue, T>, UintValue> Get() & { |
2450 | | return GetUint(); |
2451 | | } |
2452 | | template <typename T> |
2453 | 229 | std::enable_if_t<std::is_same_v<UintValue, T>, UintValue> Get() const& { |
2454 | 229 | return GetUint(); |
2455 | 229 | } |
2456 | | template <typename T> |
2457 | | std::enable_if_t<std::is_same_v<UintValue, T>, UintValue> Get() && { |
2458 | | return GetUint(); |
2459 | | } |
2460 | | template <typename T> |
2461 | | std::enable_if_t<std::is_same_v<UintValue, T>, UintValue> Get() const&& { |
2462 | | return GetUint(); |
2463 | | } |
2464 | | |
2465 | | // Convenience method for use with template metaprogramming. See |
2466 | | // `GetUnknown()`. |
2467 | | template <typename T> |
2468 | | std::enable_if_t<std::is_same_v<UnknownValue, T>, const UnknownValue&> |
2469 | | Get() & ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2470 | | return GetUnknown(); |
2471 | | } |
2472 | | template <typename T> |
2473 | | std::enable_if_t<std::is_same_v<UnknownValue, T>, const UnknownValue&> Get() |
2474 | 0 | const& ABSL_ATTRIBUTE_LIFETIME_BOUND { |
2475 | 0 | return GetUnknown(); |
2476 | 0 | } |
2477 | | template <typename T> |
2478 | | std::enable_if_t<std::is_same_v<UnknownValue, T>, UnknownValue> Get() && { |
2479 | | return std::move(*this).GetUnknown(); |
2480 | | } |
2481 | | template <typename T> |
2482 | | std::enable_if_t<std::is_same_v<UnknownValue, T>, UnknownValue> Get() |
2483 | | const&& { |
2484 | | return std::move(*this).GetUnknown(); |
2485 | | } |
2486 | | |
2487 | | // When `Value` is default constructed, it is in a valid but undefined state. |
2488 | | // Any attempt to use it invokes undefined behavior. This mention can be used |
2489 | | // to test whether this value is valid. |
2490 | 0 | explicit operator bool() const { return true; } |
2491 | | |
2492 | | private: |
2493 | | friend struct NativeTypeTraits<Value>; |
2494 | | friend bool common_internal::IsLegacyListValue(const Value& value); |
2495 | | friend common_internal::LegacyListValue common_internal::GetLegacyListValue( |
2496 | | const Value& value); |
2497 | | friend bool common_internal::IsLegacyMapValue(const Value& value); |
2498 | | friend common_internal::LegacyMapValue common_internal::GetLegacyMapValue( |
2499 | | const Value& value); |
2500 | | friend bool common_internal::IsLegacyStructValue(const Value& value); |
2501 | | friend common_internal::LegacyStructValue |
2502 | | common_internal::GetLegacyStructValue(const Value& value); |
2503 | | friend class common_internal::ValueMixin<Value>; |
2504 | | friend struct ArenaTraits<Value>; |
2505 | | |
2506 | | common_internal::ValueVariant variant_; |
2507 | | }; |
2508 | | |
2509 | | // Overloads for heterogeneous equality of numeric values. |
2510 | | bool operator==(IntValue lhs, UintValue rhs); |
2511 | | bool operator==(UintValue lhs, IntValue rhs); |
2512 | | bool operator==(IntValue lhs, DoubleValue rhs); |
2513 | | bool operator==(DoubleValue lhs, IntValue rhs); |
2514 | | bool operator==(UintValue lhs, DoubleValue rhs); |
2515 | | bool operator==(DoubleValue lhs, UintValue rhs); |
2516 | 0 | inline bool operator!=(IntValue lhs, UintValue rhs) { |
2517 | 0 | return !operator==(lhs, rhs); |
2518 | 0 | } |
2519 | 0 | inline bool operator!=(UintValue lhs, IntValue rhs) { |
2520 | 0 | return !operator==(lhs, rhs); |
2521 | 0 | } |
2522 | 0 | inline bool operator!=(IntValue lhs, DoubleValue rhs) { |
2523 | 0 | return !operator==(lhs, rhs); |
2524 | 0 | } |
2525 | 0 | inline bool operator!=(DoubleValue lhs, IntValue rhs) { |
2526 | 0 | return !operator==(lhs, rhs); |
2527 | 0 | } |
2528 | 0 | inline bool operator!=(UintValue lhs, DoubleValue rhs) { |
2529 | 0 | return !operator==(lhs, rhs); |
2530 | 0 | } |
2531 | 0 | inline bool operator!=(DoubleValue lhs, UintValue rhs) { |
2532 | 0 | return !operator==(lhs, rhs); |
2533 | 0 | } |
2534 | | |
2535 | | template <> |
2536 | | struct NativeTypeTraits<Value> final { |
2537 | 0 | static NativeTypeId Id(const Value& value) { |
2538 | 0 | return value.variant_.Visit([](const auto& alternative) -> NativeTypeId { |
2539 | 0 | return NativeTypeId::Of(alternative); |
2540 | 0 | }); Unexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::NullValue>(cel::NullValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::BoolValue>(cel::BoolValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::IntValue>(cel::IntValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::UintValue>(cel::UintValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::DoubleValue>(cel::DoubleValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::DurationValue>(cel::DurationValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::TimestampValue>(cel::TimestampValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::TypeValue>(cel::TypeValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::common_internal::LegacyListValue>(cel::common_internal::LegacyListValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::ParsedJsonListValue>(cel::ParsedJsonListValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::ParsedRepeatedFieldValue>(cel::ParsedRepeatedFieldValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::CustomListValue>(cel::CustomListValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::common_internal::LegacyMapValue>(cel::common_internal::LegacyMapValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::ParsedJsonMapValue>(cel::ParsedJsonMapValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::ParsedMapFieldValue>(cel::ParsedMapFieldValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::CustomMapValue>(cel::CustomMapValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::common_internal::LegacyStructValue>(cel::common_internal::LegacyStructValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::ParsedMessageValue>(cel::ParsedMessageValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::CustomStructValue>(cel::CustomStructValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::OpaqueValue>(cel::OpaqueValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::BytesValue>(cel::BytesValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::StringValue>(cel::StringValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::ErrorValue>(cel::ErrorValue const&) constUnexecuted instantiation: cel::TypeInfo cel::NativeTypeTraits<cel::Value, void>::Id(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::UnknownValue>(cel::UnknownValue const&) const |
2541 | 0 | } |
2542 | | }; |
2543 | | |
2544 | | template <> |
2545 | | struct ArenaTraits<Value> { |
2546 | 0 | static bool trivially_destructible(const Value& value) { |
2547 | 0 | return value.variant_.Visit([](const auto& alternative) -> bool { |
2548 | 0 | return ArenaTraits<>::trivially_destructible(alternative); |
2549 | 0 | }); Unexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::NullValue>(cel::NullValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::BoolValue>(cel::BoolValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::IntValue>(cel::IntValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::UintValue>(cel::UintValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::DoubleValue>(cel::DoubleValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::DurationValue>(cel::DurationValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::TimestampValue>(cel::TimestampValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::TypeValue>(cel::TypeValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::common_internal::LegacyListValue>(cel::common_internal::LegacyListValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::ParsedJsonListValue>(cel::ParsedJsonListValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::ParsedRepeatedFieldValue>(cel::ParsedRepeatedFieldValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::CustomListValue>(cel::CustomListValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::common_internal::LegacyMapValue>(cel::common_internal::LegacyMapValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::ParsedJsonMapValue>(cel::ParsedJsonMapValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::ParsedMapFieldValue>(cel::ParsedMapFieldValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::CustomMapValue>(cel::CustomMapValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::common_internal::LegacyStructValue>(cel::common_internal::LegacyStructValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::ParsedMessageValue>(cel::ParsedMessageValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::CustomStructValue>(cel::CustomStructValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::OpaqueValue>(cel::OpaqueValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::BytesValue>(cel::BytesValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::StringValue>(cel::StringValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::ErrorValue>(cel::ErrorValue const&) constUnexecuted instantiation: bool cel::ArenaTraits<cel::Value>::trivially_destructible(cel::Value const&)::{lambda(auto:1 const&)#1}::operator()<cel::UnknownValue>(cel::UnknownValue const&) const |
2550 | 0 | } |
2551 | | }; |
2552 | | |
2553 | | // Statically assert some expectations. |
2554 | | static_assert(sizeof(Value) <= 32); |
2555 | | static_assert(alignof(Value) <= alignof(std::max_align_t)); |
2556 | | static_assert(std::is_default_constructible_v<Value>); |
2557 | | static_assert(std::is_copy_constructible_v<Value>); |
2558 | | static_assert(std::is_copy_assignable_v<Value>); |
2559 | | static_assert(std::is_nothrow_move_constructible_v<Value>); |
2560 | | static_assert(std::is_nothrow_move_assignable_v<Value>); |
2561 | | static_assert(std::is_nothrow_swappable_v<Value>); |
2562 | | |
2563 | | inline common_internal::ImplicitlyConvertibleStatus |
2564 | 0 | ErrorValueAssign::operator()(absl::Status status) const { |
2565 | 0 | *value_ = ErrorValue::From(std::move(status), arena_); |
2566 | 0 | return common_internal::ImplicitlyConvertibleStatus(); |
2567 | 0 | } |
2568 | | |
2569 | | namespace common_internal { |
2570 | | |
2571 | | template <typename Base> |
2572 | | absl::StatusOr<Value> ValueMixin<Base>::Equal( |
2573 | | const Value& other, |
2574 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
2575 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
2576 | 0 | google::protobuf::Arena* absl_nonnull arena) const { |
2577 | 0 | ABSL_DCHECK(descriptor_pool != nullptr); |
2578 | 0 | ABSL_DCHECK(message_factory != nullptr); |
2579 | 0 | ABSL_DCHECK(arena != nullptr); |
2580 | |
|
2581 | 0 | Value result; |
2582 | 0 | CEL_RETURN_IF_ERROR(static_cast<const Base*>(this)->Equal( |
2583 | 0 | other, descriptor_pool, message_factory, arena, &result)); |
2584 | 0 | return result; |
2585 | 0 | } |
2586 | | |
2587 | | template <typename Base> |
2588 | | absl::StatusOr<Value> ListValueMixin<Base>::Get( |
2589 | | size_t index, const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
2590 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
2591 | 1.57M | google::protobuf::Arena* absl_nonnull arena) const { |
2592 | 1.57M | ABSL_DCHECK(descriptor_pool != nullptr); |
2593 | 1.57M | ABSL_DCHECK(message_factory != nullptr); |
2594 | 1.57M | ABSL_DCHECK(arena != nullptr); |
2595 | | |
2596 | 1.57M | Value result; |
2597 | 1.57M | CEL_RETURN_IF_ERROR(static_cast<const Base*>(this)->Get( |
2598 | 1.57M | index, descriptor_pool, message_factory, arena, &result)); |
2599 | 1.57M | return result; |
2600 | 1.57M | } |
2601 | | |
2602 | | template <typename Base> |
2603 | | absl::StatusOr<Value> ListValueMixin<Base>::Contains( |
2604 | | const Value& other, |
2605 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
2606 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
2607 | 183k | google::protobuf::Arena* absl_nonnull arena) const { |
2608 | 183k | ABSL_DCHECK(descriptor_pool != nullptr); |
2609 | 183k | ABSL_DCHECK(message_factory != nullptr); |
2610 | 183k | ABSL_DCHECK(arena != nullptr); |
2611 | | |
2612 | 183k | Value result; |
2613 | 183k | CEL_RETURN_IF_ERROR(static_cast<const Base*>(this)->Contains( |
2614 | 183k | other, descriptor_pool, message_factory, arena, &result)); |
2615 | 183k | return result; |
2616 | 183k | } |
2617 | | |
2618 | | template <typename Base> |
2619 | | absl::StatusOr<Value> MapValueMixin<Base>::Get( |
2620 | | const Value& key, |
2621 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
2622 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
2623 | 1.09k | google::protobuf::Arena* absl_nonnull arena) const { |
2624 | 1.09k | ABSL_DCHECK(descriptor_pool != nullptr); |
2625 | 1.09k | ABSL_DCHECK(message_factory != nullptr); |
2626 | 1.09k | ABSL_DCHECK(arena != nullptr); |
2627 | | |
2628 | 1.09k | Value result; |
2629 | 1.09k | CEL_RETURN_IF_ERROR(static_cast<const Base*>(this)->Get( |
2630 | 1.09k | key, descriptor_pool, message_factory, arena, &result)); |
2631 | 1.09k | return result; |
2632 | 1.09k | } |
2633 | | |
2634 | | template <typename Base> |
2635 | | absl::StatusOr<absl::optional<Value>> MapValueMixin<Base>::Find( |
2636 | | const Value& other, |
2637 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
2638 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
2639 | 5.93k | google::protobuf::Arena* absl_nonnull arena) const { |
2640 | 5.93k | ABSL_DCHECK(descriptor_pool != nullptr); |
2641 | 5.93k | ABSL_DCHECK(message_factory != nullptr); |
2642 | 5.93k | ABSL_DCHECK(arena != nullptr); |
2643 | | |
2644 | 5.93k | Value result; |
2645 | 5.93k | CEL_ASSIGN_OR_RETURN( |
2646 | 5.93k | bool found, static_cast<const Base*>(this)->Find( |
2647 | 5.93k | other, descriptor_pool, message_factory, arena, &result)); |
2648 | 5.93k | if (found) { |
2649 | 1.09k | return result; |
2650 | 1.09k | } |
2651 | 4.83k | return absl::nullopt; |
2652 | 5.93k | } |
2653 | | |
2654 | | template <typename Base> |
2655 | | absl::StatusOr<Value> MapValueMixin<Base>::Has( |
2656 | | const Value& key, |
2657 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
2658 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
2659 | 0 | google::protobuf::Arena* absl_nonnull arena) const { |
2660 | 0 | ABSL_DCHECK(descriptor_pool != nullptr); |
2661 | 0 | ABSL_DCHECK(message_factory != nullptr); |
2662 | 0 | ABSL_DCHECK(arena != nullptr); |
2663 | |
|
2664 | 0 | Value result; |
2665 | 0 | CEL_RETURN_IF_ERROR(static_cast<const Base*>(this)->Has( |
2666 | 0 | key, descriptor_pool, message_factory, arena, &result)); |
2667 | 0 | return result; |
2668 | 0 | } |
2669 | | |
2670 | | template <typename Base> |
2671 | | absl::StatusOr<ListValue> MapValueMixin<Base>::ListKeys( |
2672 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
2673 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
2674 | | google::protobuf::Arena* absl_nonnull arena) const { |
2675 | | ABSL_DCHECK(descriptor_pool != nullptr); |
2676 | | ABSL_DCHECK(message_factory != nullptr); |
2677 | | ABSL_DCHECK(arena != nullptr); |
2678 | | |
2679 | | ListValue result; |
2680 | | CEL_RETURN_IF_ERROR(static_cast<const Base*>(this)->ListKeys( |
2681 | | descriptor_pool, message_factory, arena, &result)); |
2682 | | return result; |
2683 | | } |
2684 | | |
2685 | | template <typename Base> |
2686 | | absl::StatusOr<Value> StructValueMixin<Base>::GetFieldByName( |
2687 | | absl::string_view name, |
2688 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
2689 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
2690 | 0 | google::protobuf::Arena* absl_nonnull arena) const { |
2691 | 0 | ABSL_DCHECK(descriptor_pool != nullptr); |
2692 | 0 | ABSL_DCHECK(message_factory != nullptr); |
2693 | 0 | ABSL_DCHECK(arena != nullptr); |
2694 | |
|
2695 | 0 | Value result; |
2696 | 0 | CEL_RETURN_IF_ERROR(static_cast<const Base*>(this)->GetFieldByName( |
2697 | 0 | name, ProtoWrapperTypeOptions::kUnsetNull, descriptor_pool, |
2698 | 0 | message_factory, arena, &result)); |
2699 | 0 | return result; |
2700 | 0 | } |
2701 | | |
2702 | | template <typename Base> |
2703 | | absl::StatusOr<Value> StructValueMixin<Base>::GetFieldByName( |
2704 | | absl::string_view name, ProtoWrapperTypeOptions unboxing_options, |
2705 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
2706 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
2707 | | google::protobuf::Arena* absl_nonnull arena) const { |
2708 | | ABSL_DCHECK(descriptor_pool != nullptr); |
2709 | | ABSL_DCHECK(message_factory != nullptr); |
2710 | | ABSL_DCHECK(arena != nullptr); |
2711 | | |
2712 | | Value result; |
2713 | | CEL_RETURN_IF_ERROR(static_cast<const Base*>(this)->GetFieldByName( |
2714 | | name, unboxing_options, descriptor_pool, message_factory, arena, |
2715 | | &result)); |
2716 | | return result; |
2717 | | } |
2718 | | |
2719 | | template <typename Base> |
2720 | | absl::StatusOr<Value> StructValueMixin<Base>::GetFieldByNumber( |
2721 | | int64_t number, const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
2722 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
2723 | | google::protobuf::Arena* absl_nonnull arena) const { |
2724 | | ABSL_DCHECK(descriptor_pool != nullptr); |
2725 | | ABSL_DCHECK(message_factory != nullptr); |
2726 | | ABSL_DCHECK(arena != nullptr); |
2727 | | |
2728 | | Value result; |
2729 | | CEL_RETURN_IF_ERROR(static_cast<const Base*>(this)->GetFieldByNumber( |
2730 | | number, ProtoWrapperTypeOptions::kUnsetNull, descriptor_pool, |
2731 | | message_factory, arena, &result)); |
2732 | | return result; |
2733 | | } |
2734 | | |
2735 | | template <typename Base> |
2736 | | absl::StatusOr<Value> StructValueMixin<Base>::GetFieldByNumber( |
2737 | | int64_t number, ProtoWrapperTypeOptions unboxing_options, |
2738 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
2739 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
2740 | | google::protobuf::Arena* absl_nonnull arena) const { |
2741 | | ABSL_DCHECK(descriptor_pool != nullptr); |
2742 | | ABSL_DCHECK(message_factory != nullptr); |
2743 | | ABSL_DCHECK(arena != nullptr); |
2744 | | |
2745 | | Value result; |
2746 | | CEL_RETURN_IF_ERROR(static_cast<const Base*>(this)->GetFieldByNumber( |
2747 | | number, unboxing_options, descriptor_pool, message_factory, arena, |
2748 | | &result)); |
2749 | | return result; |
2750 | | } |
2751 | | |
2752 | | template <typename Base> |
2753 | | absl::StatusOr<std::pair<Value, int>> StructValueMixin<Base>::Qualify( |
2754 | | absl::Span<const SelectQualifier> qualifiers, bool presence_test, |
2755 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
2756 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
2757 | 0 | google::protobuf::Arena* absl_nonnull arena) const { |
2758 | 0 | ABSL_DCHECK(!qualifiers.empty()); |
2759 | 0 | ABSL_DCHECK(descriptor_pool != nullptr); |
2760 | 0 | ABSL_DCHECK(message_factory != nullptr); |
2761 | 0 | ABSL_DCHECK(arena != nullptr); |
2762 | |
|
2763 | 0 | Value result; |
2764 | 0 | int count; |
2765 | 0 | CEL_RETURN_IF_ERROR(static_cast<const Base*>(this)->Qualify( |
2766 | 0 | qualifiers, presence_test, descriptor_pool, message_factory, arena, |
2767 | 0 | &result, &count)); |
2768 | 0 | return std::pair{std::move(result), count}; |
2769 | 0 | } |
2770 | | |
2771 | | } // namespace common_internal |
2772 | | |
2773 | | using ValueIteratorPtr = std::unique_ptr<ValueIterator>; |
2774 | | |
2775 | | inline absl::StatusOr<Value> ValueIterator::Next( |
2776 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
2777 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
2778 | 5.03k | google::protobuf::Arena* absl_nonnull arena) { |
2779 | 5.03k | ABSL_DCHECK(descriptor_pool != nullptr); |
2780 | 5.03k | ABSL_DCHECK(message_factory != nullptr); |
2781 | 5.03k | ABSL_DCHECK(arena != nullptr); |
2782 | | |
2783 | 5.03k | Value result; |
2784 | 5.03k | CEL_RETURN_IF_ERROR(Next(descriptor_pool, message_factory, arena, &result)); |
2785 | 5.03k | return result; |
2786 | 5.03k | } |
2787 | | |
2788 | | inline absl::StatusOr<absl::optional<Value>> ValueIterator::Next1( |
2789 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
2790 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
2791 | 0 | google::protobuf::Arena* absl_nonnull arena) { |
2792 | 0 | ABSL_DCHECK(descriptor_pool != nullptr); |
2793 | 0 | ABSL_DCHECK(message_factory != nullptr); |
2794 | 0 | ABSL_DCHECK(arena != nullptr); |
2795 | |
|
2796 | 0 | Value key_or_value; |
2797 | 0 | CEL_ASSIGN_OR_RETURN( |
2798 | 0 | bool ok, Next1(descriptor_pool, message_factory, arena, &key_or_value)); |
2799 | 0 | if (!ok) { |
2800 | 0 | return absl::nullopt; |
2801 | 0 | } |
2802 | 0 | return key_or_value; |
2803 | 0 | } |
2804 | | |
2805 | | inline absl::StatusOr<absl::optional<std::pair<Value, Value>>> |
2806 | | ValueIterator::Next2(const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
2807 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
2808 | 0 | google::protobuf::Arena* absl_nonnull arena) { |
2809 | 0 | ABSL_DCHECK(descriptor_pool != nullptr); |
2810 | 0 | ABSL_DCHECK(message_factory != nullptr); |
2811 | 0 | ABSL_DCHECK(arena != nullptr); |
2812 | 0 |
|
2813 | 0 | Value key; |
2814 | 0 | Value value; |
2815 | 0 | CEL_ASSIGN_OR_RETURN( |
2816 | 0 | bool ok, Next2(descriptor_pool, message_factory, arena, &key, &value)); |
2817 | 0 | if (!ok) { |
2818 | 0 | return absl::nullopt; |
2819 | 0 | } |
2820 | 0 | return std::pair{std::move(key), std::move(value)}; |
2821 | 0 | } |
2822 | | |
2823 | | absl_nonnull std::unique_ptr<ValueIterator> NewEmptyValueIterator(); |
2824 | | |
2825 | | class ValueBuilder { |
2826 | | public: |
2827 | 2.11M | virtual ~ValueBuilder() = default; |
2828 | | |
2829 | | virtual absl::StatusOr<absl::optional<ErrorValue>> SetFieldByName( |
2830 | | absl::string_view name, Value value) = 0; |
2831 | | |
2832 | | virtual absl::StatusOr<absl::optional<ErrorValue>> SetFieldByNumber( |
2833 | | int64_t number, Value value) = 0; |
2834 | | |
2835 | | virtual absl::StatusOr<Value> Build() && = 0; |
2836 | | }; |
2837 | | |
2838 | | using ValueBuilderPtr = std::unique_ptr<ValueBuilder>; |
2839 | | |
2840 | | absl_nonnull ListValueBuilderPtr |
2841 | | NewListValueBuilder(google::protobuf::Arena* absl_nonnull arena); |
2842 | | |
2843 | | absl_nonnull MapValueBuilderPtr |
2844 | | NewMapValueBuilder(google::protobuf::Arena* absl_nonnull arena); |
2845 | | |
2846 | | // Returns a new `StructValueBuilder`. Returns `nullptr` if there is no such |
2847 | | // message type with the name `name` in `descriptor_pool`. Returns an error if |
2848 | | // `message_factory` is unable to provide a prototype for the descriptor |
2849 | | // returned from `descriptor_pool`. |
2850 | | absl_nullable StructValueBuilderPtr NewStructValueBuilder( |
2851 | | google::protobuf::Arena* absl_nonnull arena, |
2852 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
2853 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
2854 | | absl::string_view name); |
2855 | | |
2856 | | using ListValueBuilderInterface = ListValueBuilder; |
2857 | | using MapValueBuilderInterface = MapValueBuilder; |
2858 | | using StructValueBuilderInterface = StructValueBuilder; |
2859 | | |
2860 | | // Now that Value is complete, we can define various parts of list, map, opaque, |
2861 | | // and struct which depend on Value. |
2862 | | |
2863 | | namespace common_internal { |
2864 | | |
2865 | | using MapFieldKeyAccessor = void (*)(const google::protobuf::MapKey&, |
2866 | | const google::protobuf::Message* absl_nonnull, |
2867 | | google::protobuf::Arena* absl_nonnull, |
2868 | | Value* absl_nonnull); |
2869 | | |
2870 | | absl::StatusOr<MapFieldKeyAccessor> MapFieldKeyAccessorFor( |
2871 | | const google::protobuf::FieldDescriptor* absl_nonnull field); |
2872 | | |
2873 | | using MapFieldValueAccessor = void (*)( |
2874 | | const google::protobuf::MapValueConstRef&, const google::protobuf::Message* absl_nonnull, |
2875 | | const google::protobuf::FieldDescriptor* absl_nonnull, |
2876 | | const google::protobuf::DescriptorPool* absl_nonnull, |
2877 | | google::protobuf::MessageFactory* absl_nonnull, google::protobuf::Arena* absl_nonnull, |
2878 | | Value* absl_nonnull); |
2879 | | |
2880 | | absl::StatusOr<MapFieldValueAccessor> MapFieldValueAccessorFor( |
2881 | | const google::protobuf::FieldDescriptor* absl_nonnull field); |
2882 | | |
2883 | | using RepeatedFieldAccessor = |
2884 | | void (*)(int, const google::protobuf::Message* absl_nonnull, |
2885 | | const google::protobuf::FieldDescriptor* absl_nonnull, |
2886 | | const google::protobuf::Reflection* absl_nonnull, |
2887 | | const google::protobuf::DescriptorPool* absl_nonnull, |
2888 | | google::protobuf::MessageFactory* absl_nonnull, google::protobuf::Arena* absl_nonnull, |
2889 | | Value* absl_nonnull); |
2890 | | |
2891 | | absl::StatusOr<RepeatedFieldAccessor> RepeatedFieldAccessorFor( |
2892 | | const google::protobuf::FieldDescriptor* absl_nonnull field); |
2893 | | |
2894 | | } // namespace common_internal |
2895 | | |
2896 | | inline BytesValue::BytesValue(const StringValue& other) |
2897 | 194 | : BytesValue(other.value_) {} |
2898 | | |
2899 | 895 | inline optional_ref<const BytesValue> Value::AsBytes() const& { |
2900 | 895 | if (const auto* alternative = variant_.As<BytesValue>(); |
2901 | 895 | alternative != nullptr) { |
2902 | 679 | return *alternative; |
2903 | 679 | } |
2904 | 216 | return std::nullopt; |
2905 | 895 | } |
2906 | | |
2907 | 0 | inline absl::optional<BytesValue> Value::AsBytes() && { |
2908 | 0 | if (auto* alternative = variant_.As<BytesValue>(); alternative != nullptr) { |
2909 | 0 | return std::move(*alternative); |
2910 | 0 | } |
2911 | 0 | return std::nullopt; |
2912 | 0 | } |
2913 | | |
2914 | 160k | inline absl::optional<DoubleValue> Value::AsDouble() const { |
2915 | 160k | if (const auto* alternative = variant_.As<DoubleValue>(); |
2916 | 160k | alternative != nullptr) { |
2917 | 136k | return *alternative; |
2918 | 136k | } |
2919 | 24.0k | return std::nullopt; |
2920 | 160k | } |
2921 | | |
2922 | 678 | inline absl::optional<DurationValue> Value::AsDuration() const { |
2923 | 678 | if (const auto* alternative = variant_.As<DurationValue>(); |
2924 | 678 | alternative != nullptr) { |
2925 | 442 | return *alternative; |
2926 | 442 | } |
2927 | 236 | return std::nullopt; |
2928 | 678 | } |
2929 | | |
2930 | 9.92M | inline optional_ref<const ErrorValue> Value::AsError() const& { |
2931 | 9.92M | if (const auto* alternative = variant_.As<ErrorValue>(); |
2932 | 9.92M | alternative != nullptr) { |
2933 | 0 | return *alternative; |
2934 | 0 | } |
2935 | 9.92M | return std::nullopt; |
2936 | 9.92M | } |
2937 | | |
2938 | 0 | inline absl::optional<ErrorValue> Value::AsError() && { |
2939 | 0 | if (auto* alternative = variant_.As<ErrorValue>(); alternative != nullptr) { |
2940 | 0 | return std::move(*alternative); |
2941 | 0 | } |
2942 | 0 | return std::nullopt; |
2943 | 0 | } |
2944 | | |
2945 | 41.5k | inline absl::optional<IntValue> Value::AsInt() const { |
2946 | 41.5k | if (const auto* alternative = variant_.As<IntValue>(); |
2947 | 41.5k | alternative != nullptr) { |
2948 | 20.3k | return *alternative; |
2949 | 20.3k | } |
2950 | 21.2k | return std::nullopt; |
2951 | 41.5k | } |
2952 | | |
2953 | 0 | inline absl::optional<MessageValue> Value::AsMessage() const& { |
2954 | 0 | if (const auto* alternative = variant_.As<ParsedMessageValue>(); |
2955 | 0 | alternative != nullptr) { |
2956 | 0 | return *alternative; |
2957 | 0 | } |
2958 | 0 | return std::nullopt; |
2959 | 0 | } |
2960 | | |
2961 | 0 | inline absl::optional<MessageValue> Value::AsMessage() && { |
2962 | 0 | if (auto* alternative = variant_.As<ParsedMessageValue>(); |
2963 | 0 | alternative != nullptr) { |
2964 | 0 | return std::move(*alternative); |
2965 | 0 | } |
2966 | 0 | return std::nullopt; |
2967 | 0 | } |
2968 | | |
2969 | 0 | inline absl::optional<NullValue> Value::AsNull() const { |
2970 | 0 | if (const auto* alternative = variant_.As<NullValue>(); |
2971 | 0 | alternative != nullptr) { |
2972 | 0 | return *alternative; |
2973 | 0 | } |
2974 | 0 | return std::nullopt; |
2975 | 0 | } |
2976 | | |
2977 | 0 | inline optional_ref<const OpaqueValue> Value::AsOpaque() const& { |
2978 | 0 | if (const auto* alternative = variant_.As<OpaqueValue>(); |
2979 | 0 | alternative != nullptr) { |
2980 | 0 | return *alternative; |
2981 | 0 | } |
2982 | 0 | return std::nullopt; |
2983 | 0 | } |
2984 | | |
2985 | 0 | inline absl::optional<OpaqueValue> Value::AsOpaque() && { |
2986 | 0 | if (auto* alternative = variant_.As<OpaqueValue>(); alternative != nullptr) { |
2987 | 0 | return std::move(*alternative); |
2988 | 0 | } |
2989 | 0 | return std::nullopt; |
2990 | 0 | } |
2991 | | |
2992 | 0 | inline optional_ref<const OptionalValue> Value::AsOptional() const& { |
2993 | 0 | if (const auto* alternative = variant_.As<OpaqueValue>(); |
2994 | 0 | alternative != nullptr && alternative->IsOptional()) { |
2995 | 0 | return static_cast<const OptionalValue&>(*alternative); |
2996 | 0 | } |
2997 | 0 | return std::nullopt; |
2998 | 0 | } |
2999 | | |
3000 | 0 | inline absl::optional<OptionalValue> Value::AsOptional() && { |
3001 | 0 | if (auto* alternative = variant_.As<OpaqueValue>(); |
3002 | 0 | alternative != nullptr && alternative->IsOptional()) { |
3003 | 0 | return static_cast<OptionalValue&&>(*alternative); |
3004 | 0 | } |
3005 | 0 | return std::nullopt; |
3006 | 0 | } |
3007 | | |
3008 | | inline optional_ref<const ParsedJsonListValue> Value::AsParsedJsonList() |
3009 | 868 | const& { |
3010 | 868 | if (const auto* alternative = variant_.As<ParsedJsonListValue>(); |
3011 | 868 | alternative != nullptr) { |
3012 | 145 | return *alternative; |
3013 | 145 | } |
3014 | 723 | return std::nullopt; |
3015 | 868 | } |
3016 | | |
3017 | 0 | inline absl::optional<ParsedJsonListValue> Value::AsParsedJsonList() && { |
3018 | 0 | if (auto* alternative = variant_.As<ParsedJsonListValue>(); |
3019 | 0 | alternative != nullptr) { |
3020 | 0 | return std::move(*alternative); |
3021 | 0 | } |
3022 | 0 | return std::nullopt; |
3023 | 0 | } |
3024 | | |
3025 | 503 | inline optional_ref<const ParsedJsonMapValue> Value::AsParsedJsonMap() const& { |
3026 | 503 | if (const auto* alternative = variant_.As<ParsedJsonMapValue>(); |
3027 | 503 | alternative != nullptr) { |
3028 | 268 | return *alternative; |
3029 | 268 | } |
3030 | 235 | return std::nullopt; |
3031 | 503 | } |
3032 | | |
3033 | 0 | inline absl::optional<ParsedJsonMapValue> Value::AsParsedJsonMap() && { |
3034 | 0 | if (auto* alternative = variant_.As<ParsedJsonMapValue>(); |
3035 | 0 | alternative != nullptr) { |
3036 | 0 | return std::move(*alternative); |
3037 | 0 | } |
3038 | 0 | return std::nullopt; |
3039 | 0 | } |
3040 | | |
3041 | 1.12k | inline optional_ref<const CustomListValue> Value::AsCustomList() const& { |
3042 | 1.12k | if (const auto* alternative = variant_.As<CustomListValue>(); |
3043 | 1.12k | alternative != nullptr) { |
3044 | 1.04k | return *alternative; |
3045 | 1.04k | } |
3046 | 79 | return std::nullopt; |
3047 | 1.12k | } |
3048 | | |
3049 | 0 | inline absl::optional<CustomListValue> Value::AsCustomList() && { |
3050 | 0 | if (auto* alternative = variant_.As<CustomListValue>(); |
3051 | 0 | alternative != nullptr) { |
3052 | 0 | return std::move(*alternative); |
3053 | 0 | } |
3054 | 0 | return std::nullopt; |
3055 | 0 | } |
3056 | | |
3057 | 23 | inline optional_ref<const CustomMapValue> Value::AsCustomMap() const& { |
3058 | 23 | if (const auto* alternative = variant_.As<CustomMapValue>(); |
3059 | 23 | alternative != nullptr) { |
3060 | 22 | return *alternative; |
3061 | 22 | } |
3062 | 1 | return std::nullopt; |
3063 | 23 | } |
3064 | | |
3065 | 0 | inline absl::optional<CustomMapValue> Value::AsCustomMap() && { |
3066 | 0 | if (auto* alternative = variant_.As<CustomMapValue>(); |
3067 | 0 | alternative != nullptr) { |
3068 | 0 | return std::move(*alternative); |
3069 | 0 | } |
3070 | 0 | return std::nullopt; |
3071 | 0 | } |
3072 | | |
3073 | | inline optional_ref<const ParsedMapFieldValue> Value::AsParsedMapField() |
3074 | 236 | const& { |
3075 | 236 | if (const auto* alternative = variant_.As<ParsedMapFieldValue>(); |
3076 | 236 | alternative != nullptr) { |
3077 | 0 | return *alternative; |
3078 | 0 | } |
3079 | 236 | return std::nullopt; |
3080 | 236 | } |
3081 | | |
3082 | 0 | inline absl::optional<ParsedMapFieldValue> Value::AsParsedMapField() && { |
3083 | 0 | if (auto* alternative = variant_.As<ParsedMapFieldValue>(); |
3084 | 0 | alternative != nullptr) { |
3085 | 0 | return std::move(*alternative); |
3086 | 0 | } |
3087 | 0 | return std::nullopt; |
3088 | 0 | } |
3089 | | |
3090 | 614k | inline optional_ref<const ParsedMessageValue> Value::AsParsedMessage() const& { |
3091 | 614k | if (const auto* alternative = variant_.As<ParsedMessageValue>(); |
3092 | 614k | alternative != nullptr) { |
3093 | 612k | return *alternative; |
3094 | 612k | } |
3095 | 2.63k | return std::nullopt; |
3096 | 614k | } |
3097 | | |
3098 | 0 | inline absl::optional<ParsedMessageValue> Value::AsParsedMessage() && { |
3099 | 0 | if (auto* alternative = variant_.As<ParsedMessageValue>(); |
3100 | 0 | alternative != nullptr) { |
3101 | 0 | return std::move(*alternative); |
3102 | 0 | } |
3103 | 0 | return std::nullopt; |
3104 | 0 | } |
3105 | | |
3106 | | inline optional_ref<const ParsedRepeatedFieldValue> |
3107 | 802 | Value::AsParsedRepeatedField() const& { |
3108 | 802 | if (const auto* alternative = variant_.As<ParsedRepeatedFieldValue>(); |
3109 | 802 | alternative != nullptr) { |
3110 | 0 | return *alternative; |
3111 | 0 | } |
3112 | 802 | return std::nullopt; |
3113 | 802 | } |
3114 | | |
3115 | | inline absl::optional<ParsedRepeatedFieldValue> |
3116 | 0 | Value::AsParsedRepeatedField() && { |
3117 | 0 | if (auto* alternative = variant_.As<ParsedRepeatedFieldValue>(); |
3118 | 0 | alternative != nullptr) { |
3119 | 0 | return std::move(*alternative); |
3120 | 0 | } |
3121 | 0 | return std::nullopt; |
3122 | 0 | } |
3123 | | |
3124 | 0 | inline optional_ref<const CustomStructValue> Value::AsCustomStruct() const& { |
3125 | 0 | if (const auto* alternative = variant_.As<CustomStructValue>(); |
3126 | 0 | alternative != nullptr) { |
3127 | 0 | return *alternative; |
3128 | 0 | } |
3129 | 0 | return std::nullopt; |
3130 | 0 | } |
3131 | | |
3132 | 0 | inline absl::optional<CustomStructValue> Value::AsCustomStruct() && { |
3133 | 0 | if (auto* alternative = variant_.As<CustomStructValue>(); |
3134 | 0 | alternative != nullptr) { |
3135 | 0 | return std::move(*alternative); |
3136 | 0 | } |
3137 | 0 | return std::nullopt; |
3138 | 0 | } |
3139 | | |
3140 | 23.3k | inline optional_ref<const StringValue> Value::AsString() const& { |
3141 | 23.3k | if (const auto* alternative = variant_.As<StringValue>(); |
3142 | 23.3k | alternative != nullptr) { |
3143 | 12.6k | return *alternative; |
3144 | 12.6k | } |
3145 | 10.7k | return std::nullopt; |
3146 | 23.3k | } |
3147 | | |
3148 | 0 | inline absl::optional<StringValue> Value::AsString() && { |
3149 | 0 | if (auto* alternative = variant_.As<StringValue>(); alternative != nullptr) { |
3150 | 0 | return std::move(*alternative); |
3151 | 0 | } |
3152 | 0 | return std::nullopt; |
3153 | 0 | } |
3154 | | |
3155 | 234 | inline absl::optional<TimestampValue> Value::AsTimestamp() const { |
3156 | 234 | if (const auto* alternative = variant_.As<TimestampValue>(); |
3157 | 234 | alternative != nullptr) { |
3158 | 0 | return *alternative; |
3159 | 0 | } |
3160 | 234 | return std::nullopt; |
3161 | 234 | } |
3162 | | |
3163 | 645 | inline optional_ref<const TypeValue> Value::AsType() const& { |
3164 | 645 | if (const auto* alternative = variant_.As<TypeValue>(); |
3165 | 645 | alternative != nullptr) { |
3166 | 0 | return *alternative; |
3167 | 0 | } |
3168 | 645 | return std::nullopt; |
3169 | 645 | } |
3170 | | |
3171 | 0 | inline absl::optional<TypeValue> Value::AsType() && { |
3172 | 0 | if (auto* alternative = variant_.As<TypeValue>(); alternative != nullptr) { |
3173 | 0 | return std::move(*alternative); |
3174 | 0 | } |
3175 | 0 | return std::nullopt; |
3176 | 0 | } |
3177 | | |
3178 | 144k | inline absl::optional<UintValue> Value::AsUint() const { |
3179 | 144k | if (const auto* alternative = variant_.As<UintValue>(); |
3180 | 144k | alternative != nullptr) { |
3181 | 3.48k | return *alternative; |
3182 | 3.48k | } |
3183 | 141k | return std::nullopt; |
3184 | 144k | } |
3185 | | |
3186 | 9.92M | inline optional_ref<const UnknownValue> Value::AsUnknown() const& { |
3187 | 9.92M | if (const auto* alternative = variant_.As<UnknownValue>(); |
3188 | 9.92M | alternative != nullptr) { |
3189 | 0 | return *alternative; |
3190 | 0 | } |
3191 | 9.92M | return std::nullopt; |
3192 | 9.92M | } |
3193 | | |
3194 | 0 | inline optional_ref<UnknownValue> Value::AsUnknown() & { |
3195 | 0 | if (auto* alternative = variant_.As<UnknownValue>(); alternative != nullptr) { |
3196 | 0 | return *alternative; |
3197 | 0 | } |
3198 | 0 | return std::nullopt; |
3199 | 0 | } |
3200 | | |
3201 | 0 | inline absl::optional<UnknownValue> Value::AsUnknown() && { |
3202 | 0 | if (auto* alternative = variant_.As<UnknownValue>(); alternative != nullptr) { |
3203 | 0 | return std::move(*alternative); |
3204 | 0 | } |
3205 | 0 | return std::nullopt; |
3206 | 0 | } |
3207 | | |
3208 | 8.50k | inline const BytesValue& Value::GetBytes() const& { |
3209 | 17.0k | ABSL_DCHECK(IsBytes()) << *this; |
3210 | 8.50k | return variant_.Get<BytesValue>(); |
3211 | 8.50k | } |
3212 | | |
3213 | 0 | inline BytesValue Value::GetBytes() && { |
3214 | 0 | ABSL_DCHECK(IsBytes()) << *this; |
3215 | 0 | return std::move(variant_).Get<BytesValue>(); |
3216 | 0 | } |
3217 | | |
3218 | 306k | inline DoubleValue Value::GetDouble() const { |
3219 | 613k | ABSL_DCHECK(IsDouble()) << *this; |
3220 | 306k | return variant_.Get<DoubleValue>(); |
3221 | 306k | } |
3222 | | |
3223 | 15.9k | inline DurationValue Value::GetDuration() const { |
3224 | 31.8k | ABSL_DCHECK(IsDuration()) << *this; |
3225 | 15.9k | return variant_.Get<DurationValue>(); |
3226 | 15.9k | } |
3227 | | |
3228 | 10.4k | inline const ErrorValue& Value::GetError() const& { |
3229 | 20.8k | ABSL_DCHECK(IsError()) << *this; |
3230 | 10.4k | return variant_.Get<ErrorValue>(); |
3231 | 10.4k | } |
3232 | | |
3233 | 0 | inline ErrorValue Value::GetError() && { |
3234 | 0 | ABSL_DCHECK(IsError()) << *this; |
3235 | 0 | return std::move(variant_).Get<ErrorValue>(); |
3236 | 0 | } |
3237 | | |
3238 | 13.0M | inline IntValue Value::GetInt() const { |
3239 | 26.0M | ABSL_DCHECK(IsInt()) << *this; |
3240 | 13.0M | return variant_.Get<IntValue>(); |
3241 | 13.0M | } |
3242 | | |
3243 | 0 | inline MessageValue Value::GetMessage() const& { |
3244 | 0 | ABSL_DCHECK(IsMessage()) << *this; |
3245 | 0 | return variant_.Get<ParsedMessageValue>(); |
3246 | 0 | } |
3247 | | |
3248 | 0 | inline MessageValue Value::GetMessage() && { |
3249 | 0 | ABSL_DCHECK(IsMessage()) << *this; |
3250 | 0 | return std::move(variant_).Get<ParsedMessageValue>(); |
3251 | 0 | } |
3252 | | |
3253 | 0 | inline NullValue Value::GetNull() const { |
3254 | 0 | ABSL_DCHECK(IsNull()) << *this; |
3255 | 0 | return variant_.Get<NullValue>(); |
3256 | 0 | } |
3257 | | |
3258 | 0 | inline const OpaqueValue& Value::GetOpaque() const& { |
3259 | 0 | ABSL_DCHECK(IsOpaque()) << *this; |
3260 | 0 | return variant_.Get<OpaqueValue>(); |
3261 | 0 | } |
3262 | | |
3263 | 0 | inline OpaqueValue Value::GetOpaque() && { |
3264 | 0 | ABSL_DCHECK(IsOpaque()) << *this; |
3265 | 0 | return std::move(variant_).Get<OpaqueValue>(); |
3266 | 0 | } |
3267 | | |
3268 | 0 | inline const OptionalValue& Value::GetOptional() const& { |
3269 | 0 | ABSL_DCHECK(IsOptional()) << *this; |
3270 | 0 | return static_cast<const OptionalValue&>(variant_.Get<OpaqueValue>()); |
3271 | 0 | } |
3272 | | |
3273 | 0 | inline OptionalValue Value::GetOptional() && { |
3274 | 0 | ABSL_DCHECK(IsOptional()) << *this; |
3275 | 0 | return static_cast<OptionalValue&&>(std::move(variant_).Get<OpaqueValue>()); |
3276 | 0 | } |
3277 | | |
3278 | 0 | inline const ParsedJsonListValue& Value::GetParsedJsonList() const& { |
3279 | 0 | ABSL_DCHECK(IsParsedJsonList()) << *this; |
3280 | 0 | return variant_.Get<ParsedJsonListValue>(); |
3281 | 0 | } |
3282 | | |
3283 | 0 | inline ParsedJsonListValue Value::GetParsedJsonList() && { |
3284 | 0 | ABSL_DCHECK(IsParsedJsonList()) << *this; |
3285 | 0 | return std::move(variant_).Get<ParsedJsonListValue>(); |
3286 | 0 | } |
3287 | | |
3288 | 0 | inline const ParsedJsonMapValue& Value::GetParsedJsonMap() const& { |
3289 | 0 | ABSL_DCHECK(IsParsedJsonMap()) << *this; |
3290 | 0 | return variant_.Get<ParsedJsonMapValue>(); |
3291 | 0 | } |
3292 | | |
3293 | 0 | inline ParsedJsonMapValue Value::GetParsedJsonMap() && { |
3294 | 0 | ABSL_DCHECK(IsParsedJsonMap()) << *this; |
3295 | 0 | return std::move(variant_).Get<ParsedJsonMapValue>(); |
3296 | 0 | } |
3297 | | |
3298 | 0 | inline const CustomListValue& Value::GetCustomList() const& { |
3299 | 0 | ABSL_DCHECK(IsCustomList()) << *this; |
3300 | 0 | return variant_.Get<CustomListValue>(); |
3301 | 0 | } |
3302 | | |
3303 | 0 | inline CustomListValue Value::GetCustomList() && { |
3304 | 0 | ABSL_DCHECK(IsCustomList()) << *this; |
3305 | 0 | return std::move(variant_).Get<CustomListValue>(); |
3306 | 0 | } |
3307 | | |
3308 | 0 | inline const CustomMapValue& Value::GetCustomMap() const& { |
3309 | 0 | ABSL_DCHECK(IsCustomMap()) << *this; |
3310 | 0 | return variant_.Get<CustomMapValue>(); |
3311 | 0 | } |
3312 | | |
3313 | 0 | inline CustomMapValue Value::GetCustomMap() && { |
3314 | 0 | ABSL_DCHECK(IsCustomMap()) << *this; |
3315 | 0 | return std::move(variant_).Get<CustomMapValue>(); |
3316 | 0 | } |
3317 | | |
3318 | 0 | inline const ParsedMapFieldValue& Value::GetParsedMapField() const& { |
3319 | 0 | ABSL_DCHECK(IsParsedMapField()) << *this; |
3320 | 0 | return variant_.Get<ParsedMapFieldValue>(); |
3321 | 0 | } |
3322 | | |
3323 | 0 | inline ParsedMapFieldValue Value::GetParsedMapField() && { |
3324 | 0 | ABSL_DCHECK(IsParsedMapField()) << *this; |
3325 | 0 | return std::move(variant_).Get<ParsedMapFieldValue>(); |
3326 | 0 | } |
3327 | | |
3328 | 0 | inline const ParsedMessageValue& Value::GetParsedMessage() const& { |
3329 | 0 | ABSL_DCHECK(IsParsedMessage()) << *this; |
3330 | 0 | return variant_.Get<ParsedMessageValue>(); |
3331 | 0 | } |
3332 | | |
3333 | 0 | inline ParsedMessageValue Value::GetParsedMessage() && { |
3334 | 0 | ABSL_DCHECK(IsParsedMessage()) << *this; |
3335 | 0 | return std::move(variant_).Get<ParsedMessageValue>(); |
3336 | 0 | } |
3337 | | |
3338 | 0 | inline const ParsedRepeatedFieldValue& Value::GetParsedRepeatedField() const& { |
3339 | 0 | ABSL_DCHECK(IsParsedRepeatedField()) << *this; |
3340 | 0 | return variant_.Get<ParsedRepeatedFieldValue>(); |
3341 | 0 | } |
3342 | | |
3343 | 0 | inline ParsedRepeatedFieldValue Value::GetParsedRepeatedField() && { |
3344 | 0 | ABSL_DCHECK(IsParsedRepeatedField()) << *this; |
3345 | 0 | return std::move(variant_).Get<ParsedRepeatedFieldValue>(); |
3346 | 0 | } |
3347 | | |
3348 | 0 | inline const CustomStructValue& Value::GetCustomStruct() const& { |
3349 | 0 | ABSL_DCHECK(IsCustomStruct()) << *this; |
3350 | 0 | return variant_.Get<CustomStructValue>(); |
3351 | 0 | } |
3352 | | |
3353 | 0 | inline CustomStructValue Value::GetCustomStruct() && { |
3354 | 0 | ABSL_DCHECK(IsCustomStruct()) << *this; |
3355 | 0 | return std::move(variant_).Get<CustomStructValue>(); |
3356 | 0 | } |
3357 | | |
3358 | 1.18M | inline const StringValue& Value::GetString() const& { |
3359 | 2.36M | ABSL_DCHECK(IsString()) << *this; |
3360 | 1.18M | return variant_.Get<StringValue>(); |
3361 | 1.18M | } |
3362 | | |
3363 | 0 | inline StringValue Value::GetString() && { |
3364 | 0 | ABSL_DCHECK(IsString()) << *this; |
3365 | 0 | return std::move(variant_).Get<StringValue>(); |
3366 | 0 | } |
3367 | | |
3368 | 10.7k | inline TimestampValue Value::GetTimestamp() const { |
3369 | 21.4k | ABSL_DCHECK(IsTimestamp()) << *this; |
3370 | 10.7k | return variant_.Get<TimestampValue>(); |
3371 | 10.7k | } |
3372 | | |
3373 | 16.1k | inline const TypeValue& Value::GetType() const& { |
3374 | 32.3k | ABSL_DCHECK(IsType()) << *this; |
3375 | 16.1k | return variant_.Get<TypeValue>(); |
3376 | 16.1k | } |
3377 | | |
3378 | 0 | inline TypeValue Value::GetType() && { |
3379 | 0 | ABSL_DCHECK(IsType()) << *this; |
3380 | 0 | return std::move(variant_).Get<TypeValue>(); |
3381 | 0 | } |
3382 | | |
3383 | 6.73M | inline UintValue Value::GetUint() const { |
3384 | 13.4M | ABSL_DCHECK(IsUint()) << *this; |
3385 | 6.73M | return variant_.Get<UintValue>(); |
3386 | 6.73M | } |
3387 | | |
3388 | 0 | inline const UnknownValue& Value::GetUnknown() const& { |
3389 | 0 | ABSL_DCHECK(IsUnknown()) << *this; |
3390 | 0 | return variant_.Get<UnknownValue>(); |
3391 | 0 | } |
3392 | | |
3393 | 0 | inline UnknownValue Value::GetUnknown() && { |
3394 | 0 | ABSL_DCHECK(IsUnknown()) << *this; |
3395 | 0 | return std::move(variant_).Get<UnknownValue>(); |
3396 | 0 | } |
3397 | | |
3398 | | } // namespace cel |
3399 | | |
3400 | | #pragma pop_macro("GetMessage") |
3401 | | |
3402 | | #endif // THIRD_PARTY_CEL_CPP_COMMON_VALUE_H_ |