/proc/self/cwd/common/values/struct_value.cc
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 | | #include <cstddef> |
16 | | #include <cstdint> |
17 | | #include <string> |
18 | | #include <type_traits> |
19 | | #include <utility> |
20 | | |
21 | | #include "absl/base/nullability.h" |
22 | | #include "absl/container/flat_hash_map.h" |
23 | | #include "absl/log/absl_check.h" |
24 | | #include "absl/status/status.h" |
25 | | #include "absl/status/statusor.h" |
26 | | #include "absl/strings/string_view.h" |
27 | | #include "absl/types/optional.h" |
28 | | #include "absl/types/span.h" |
29 | | #include "base/attribute.h" |
30 | | #include "common/native_type.h" |
31 | | #include "common/optional_ref.h" |
32 | | #include "common/type.h" |
33 | | #include "common/value.h" |
34 | | #include "common/values/value_variant.h" |
35 | | #include "internal/status_macros.h" |
36 | | #include "runtime/runtime_options.h" |
37 | | #include "google/protobuf/arena.h" |
38 | | #include "google/protobuf/descriptor.h" |
39 | | #include "google/protobuf/io/zero_copy_stream.h" |
40 | | #include "google/protobuf/message.h" |
41 | | |
42 | | #undef GetMessage |
43 | | |
44 | | namespace cel { |
45 | | |
46 | 328 | StructType StructValue::GetRuntimeType() const { |
47 | 328 | return variant_.Visit([](const auto& alternative) -> StructType { |
48 | 328 | return alternative.GetRuntimeType(); |
49 | 328 | }); Unexecuted instantiation: struct_value.cc:cel::StructType cel::StructValue::GetRuntimeType() const::$_0::operator()<cel::CustomStructValue>(cel::CustomStructValue const&) const Unexecuted instantiation: struct_value.cc:cel::StructType cel::StructValue::GetRuntimeType() const::$_0::operator()<cel::ParsedMessageValue>(cel::ParsedMessageValue const&) const struct_value.cc:cel::StructType cel::StructValue::GetRuntimeType() const::$_0::operator()<cel::common_internal::LegacyStructValue>(cel::common_internal::LegacyStructValue const&) const Line | Count | Source | 47 | 328 | return variant_.Visit([](const auto& alternative) -> StructType { | 48 | 328 | return alternative.GetRuntimeType(); | 49 | 328 | }); |
|
50 | 328 | } |
51 | | |
52 | 0 | absl::string_view StructValue::GetTypeName() const { |
53 | 0 | return variant_.Visit([](const auto& alternative) -> absl::string_view { |
54 | 0 | return alternative.GetTypeName(); |
55 | 0 | }); Unexecuted instantiation: struct_value.cc:std::__1::basic_string_view<char, std::__1::char_traits<char> > cel::StructValue::GetTypeName() const::$_0::operator()<cel::CustomStructValue>(cel::CustomStructValue const&) const Unexecuted instantiation: struct_value.cc:std::__1::basic_string_view<char, std::__1::char_traits<char> > cel::StructValue::GetTypeName() const::$_0::operator()<cel::ParsedMessageValue>(cel::ParsedMessageValue const&) const Unexecuted instantiation: struct_value.cc:std::__1::basic_string_view<char, std::__1::char_traits<char> > cel::StructValue::GetTypeName() const::$_0::operator()<cel::common_internal::LegacyStructValue>(cel::common_internal::LegacyStructValue const&) const |
56 | 0 | } |
57 | | |
58 | 0 | NativeTypeId StructValue::GetTypeId() const { |
59 | 0 | return variant_.Visit([](const auto& alternative) -> NativeTypeId { |
60 | 0 | return NativeTypeId::Of(alternative); |
61 | 0 | }); Unexecuted instantiation: struct_value.cc:cel::TypeInfo cel::StructValue::GetTypeId() const::$_0::operator()<cel::CustomStructValue>(cel::CustomStructValue const&) const Unexecuted instantiation: struct_value.cc:cel::TypeInfo cel::StructValue::GetTypeId() const::$_0::operator()<cel::ParsedMessageValue>(cel::ParsedMessageValue const&) const Unexecuted instantiation: struct_value.cc:cel::TypeInfo cel::StructValue::GetTypeId() const::$_0::operator()<cel::common_internal::LegacyStructValue>(cel::common_internal::LegacyStructValue const&) const |
62 | 0 | } |
63 | | |
64 | 0 | std::string StructValue::DebugString() const { |
65 | 0 | return variant_.Visit([](const auto& alternative) -> std::string { |
66 | 0 | return alternative.DebugString(); |
67 | 0 | }); Unexecuted instantiation: struct_value.cc:std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > cel::StructValue::DebugString() const::$_0::operator()<cel::CustomStructValue>(cel::CustomStructValue const&) const Unexecuted instantiation: struct_value.cc:std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > cel::StructValue::DebugString() const::$_0::operator()<cel::ParsedMessageValue>(cel::ParsedMessageValue const&) const Unexecuted instantiation: struct_value.cc:std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > cel::StructValue::DebugString() const::$_0::operator()<cel::common_internal::LegacyStructValue>(cel::common_internal::LegacyStructValue const&) const |
68 | 0 | } |
69 | | |
70 | | absl::Status StructValue::SerializeTo( |
71 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
72 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
73 | 0 | google::protobuf::io::ZeroCopyOutputStream* absl_nonnull output) const { |
74 | 0 | ABSL_DCHECK(descriptor_pool != nullptr); |
75 | 0 | ABSL_DCHECK(message_factory != nullptr); |
76 | 0 | ABSL_DCHECK(output != nullptr); |
77 | |
|
78 | 0 | return variant_.Visit([&](const auto& alternative) -> absl::Status { |
79 | 0 | return alternative.SerializeTo(descriptor_pool, message_factory, output); |
80 | 0 | }); Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::SerializeTo(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::io::ZeroCopyOutputStream*) const::$_0::operator()<cel::CustomStructValue>(cel::CustomStructValue const&) const Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::SerializeTo(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::io::ZeroCopyOutputStream*) const::$_0::operator()<cel::ParsedMessageValue>(cel::ParsedMessageValue const&) const Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::SerializeTo(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::io::ZeroCopyOutputStream*) const::$_0::operator()<cel::common_internal::LegacyStructValue>(cel::common_internal::LegacyStructValue const&) const |
81 | 0 | } |
82 | | |
83 | | absl::Status StructValue::ConvertToJson( |
84 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
85 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
86 | 0 | google::protobuf::Message* absl_nonnull json) const { |
87 | 0 | ABSL_DCHECK(descriptor_pool != nullptr); |
88 | 0 | ABSL_DCHECK(message_factory != nullptr); |
89 | 0 | ABSL_DCHECK(json != nullptr); |
90 | 0 | ABSL_DCHECK_EQ(json->GetDescriptor()->well_known_type(), |
91 | 0 | google::protobuf::Descriptor::WELLKNOWNTYPE_VALUE); |
92 | |
|
93 | 0 | return variant_.Visit([&](const auto& alternative) -> absl::Status { |
94 | 0 | return alternative.ConvertToJson(descriptor_pool, message_factory, json); |
95 | 0 | }); Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::ConvertToJson(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Message*) const::$_0::operator()<cel::CustomStructValue>(cel::CustomStructValue const&) const Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::ConvertToJson(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Message*) const::$_0::operator()<cel::ParsedMessageValue>(cel::ParsedMessageValue const&) const Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::ConvertToJson(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Message*) const::$_0::operator()<cel::common_internal::LegacyStructValue>(cel::common_internal::LegacyStructValue const&) const |
96 | 0 | } |
97 | | |
98 | | absl::Status StructValue::ConvertToJsonObject( |
99 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
100 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
101 | 0 | google::protobuf::Message* absl_nonnull json) const { |
102 | 0 | ABSL_DCHECK(descriptor_pool != nullptr); |
103 | 0 | ABSL_DCHECK(message_factory != nullptr); |
104 | 0 | ABSL_DCHECK(json != nullptr); |
105 | 0 | ABSL_DCHECK_EQ(json->GetDescriptor()->well_known_type(), |
106 | 0 | google::protobuf::Descriptor::WELLKNOWNTYPE_STRUCT); |
107 | |
|
108 | 0 | return variant_.Visit([&](const auto& alternative) -> absl::Status { |
109 | 0 | return alternative.ConvertToJsonObject(descriptor_pool, message_factory, |
110 | 0 | json); |
111 | 0 | }); Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::ConvertToJsonObject(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Message*) const::$_0::operator()<cel::CustomStructValue>(cel::CustomStructValue const&) const Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::ConvertToJsonObject(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Message*) const::$_0::operator()<cel::ParsedMessageValue>(cel::ParsedMessageValue const&) const Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::ConvertToJsonObject(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Message*) const::$_0::operator()<cel::common_internal::LegacyStructValue>(cel::common_internal::LegacyStructValue const&) const |
112 | 0 | } |
113 | | |
114 | | absl::Status StructValue::Equal( |
115 | | const Value& other, |
116 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
117 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
118 | 0 | google::protobuf::Arena* absl_nonnull arena, Value* absl_nonnull result) const { |
119 | 0 | ABSL_DCHECK(descriptor_pool != nullptr); |
120 | 0 | ABSL_DCHECK(message_factory != nullptr); |
121 | 0 | ABSL_DCHECK(arena != nullptr); |
122 | 0 | ABSL_DCHECK(result != nullptr); |
123 | |
|
124 | 0 | return variant_.Visit([&](const auto& alternative) -> absl::Status { |
125 | 0 | return alternative.Equal(other, descriptor_pool, message_factory, arena, |
126 | 0 | result); |
127 | 0 | }); Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<cel::CustomStructValue>(cel::CustomStructValue const&) const Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<cel::ParsedMessageValue>(cel::ParsedMessageValue const&) const Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<cel::common_internal::LegacyStructValue>(cel::common_internal::LegacyStructValue const&) const |
128 | 0 | } |
129 | | |
130 | 0 | bool StructValue::IsZeroValue() const { |
131 | 0 | return variant_.Visit([](const auto& alternative) -> bool { |
132 | 0 | return alternative.IsZeroValue(); |
133 | 0 | }); Unexecuted instantiation: struct_value.cc:bool cel::StructValue::IsZeroValue() const::$_0::operator()<cel::CustomStructValue>(cel::CustomStructValue const&) const Unexecuted instantiation: struct_value.cc:bool cel::StructValue::IsZeroValue() const::$_0::operator()<cel::ParsedMessageValue>(cel::ParsedMessageValue const&) const Unexecuted instantiation: struct_value.cc:bool cel::StructValue::IsZeroValue() const::$_0::operator()<cel::common_internal::LegacyStructValue>(cel::common_internal::LegacyStructValue const&) const |
134 | 0 | } |
135 | | |
136 | 0 | absl::StatusOr<bool> StructValue::HasFieldByName(absl::string_view name) const { |
137 | 0 | return variant_.Visit( |
138 | 0 | [name](const auto& alternative) -> absl::StatusOr<bool> { |
139 | 0 | return alternative.HasFieldByName(name); |
140 | 0 | }); Unexecuted instantiation: struct_value.cc:absl::lts_20260526::StatusOr<bool> cel::StructValue::HasFieldByName(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const::$_0::operator()<cel::CustomStructValue>(cel::CustomStructValue const&) const Unexecuted instantiation: struct_value.cc:absl::lts_20260526::StatusOr<bool> cel::StructValue::HasFieldByName(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const::$_0::operator()<cel::ParsedMessageValue>(cel::ParsedMessageValue const&) const Unexecuted instantiation: struct_value.cc:absl::lts_20260526::StatusOr<bool> cel::StructValue::HasFieldByName(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const::$_0::operator()<cel::common_internal::LegacyStructValue>(cel::common_internal::LegacyStructValue const&) const |
141 | 0 | } |
142 | | |
143 | 0 | absl::StatusOr<bool> StructValue::HasFieldByNumber(int64_t number) const { |
144 | 0 | return variant_.Visit( |
145 | 0 | [number](const auto& alternative) -> absl::StatusOr<bool> { |
146 | 0 | return alternative.HasFieldByNumber(number); |
147 | 0 | }); Unexecuted instantiation: struct_value.cc:absl::lts_20260526::StatusOr<bool> cel::StructValue::HasFieldByNumber(long) const::$_0::operator()<cel::CustomStructValue>(cel::CustomStructValue const&) const Unexecuted instantiation: struct_value.cc:absl::lts_20260526::StatusOr<bool> cel::StructValue::HasFieldByNumber(long) const::$_0::operator()<cel::ParsedMessageValue>(cel::ParsedMessageValue const&) const Unexecuted instantiation: struct_value.cc:absl::lts_20260526::StatusOr<bool> cel::StructValue::HasFieldByNumber(long) const::$_0::operator()<cel::common_internal::LegacyStructValue>(cel::common_internal::LegacyStructValue const&) const |
148 | 0 | } |
149 | | |
150 | | absl::Status StructValue::GetFieldByName( |
151 | | absl::string_view name, ProtoWrapperTypeOptions unboxing_options, |
152 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
153 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
154 | 497k | google::protobuf::Arena* absl_nonnull arena, Value* absl_nonnull result) const { |
155 | 497k | ABSL_DCHECK(descriptor_pool != nullptr); |
156 | 497k | ABSL_DCHECK(message_factory != nullptr); |
157 | 497k | ABSL_DCHECK(arena != nullptr); |
158 | 497k | ABSL_DCHECK(result != nullptr); |
159 | | |
160 | 497k | return variant_.Visit([&](const auto& alternative) -> absl::Status { |
161 | 497k | return alternative.GetFieldByName(name, unboxing_options, descriptor_pool, |
162 | 497k | message_factory, arena, result); |
163 | 497k | }); Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::GetFieldByName(std::__1::basic_string_view<char, std::__1::char_traits<char> >, cel::ProtoWrapperTypeOptions, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<cel::CustomStructValue>(cel::CustomStructValue const&) const Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::GetFieldByName(std::__1::basic_string_view<char, std::__1::char_traits<char> >, cel::ProtoWrapperTypeOptions, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<cel::ParsedMessageValue>(cel::ParsedMessageValue const&) const struct_value.cc:absl::lts_20260526::Status cel::StructValue::GetFieldByName(std::__1::basic_string_view<char, std::__1::char_traits<char> >, cel::ProtoWrapperTypeOptions, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<cel::common_internal::LegacyStructValue>(cel::common_internal::LegacyStructValue const&) const Line | Count | Source | 160 | 497k | return variant_.Visit([&](const auto& alternative) -> absl::Status { | 161 | 497k | return alternative.GetFieldByName(name, unboxing_options, descriptor_pool, | 162 | 497k | message_factory, arena, result); | 163 | 497k | }); |
|
164 | 497k | } |
165 | | |
166 | | absl::Status StructValue::GetFieldByNumber( |
167 | | int64_t number, ProtoWrapperTypeOptions unboxing_options, |
168 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
169 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
170 | 0 | google::protobuf::Arena* absl_nonnull arena, Value* absl_nonnull result) const { |
171 | 0 | ABSL_DCHECK(descriptor_pool != nullptr); |
172 | 0 | ABSL_DCHECK(message_factory != nullptr); |
173 | 0 | ABSL_DCHECK(arena != nullptr); |
174 | 0 | ABSL_DCHECK(result != nullptr); |
175 | |
|
176 | 0 | return variant_.Visit([&](const auto& alternative) -> absl::Status { |
177 | 0 | return alternative.GetFieldByNumber(number, unboxing_options, |
178 | 0 | descriptor_pool, message_factory, arena, |
179 | 0 | result); |
180 | 0 | }); Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::GetFieldByNumber(long, cel::ProtoWrapperTypeOptions, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<cel::CustomStructValue>(cel::CustomStructValue const&) const Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::GetFieldByNumber(long, cel::ProtoWrapperTypeOptions, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<cel::ParsedMessageValue>(cel::ParsedMessageValue const&) const Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::GetFieldByNumber(long, cel::ProtoWrapperTypeOptions, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<cel::common_internal::LegacyStructValue>(cel::common_internal::LegacyStructValue const&) const |
181 | 0 | } |
182 | | |
183 | | absl::Status StructValue::ForEachField( |
184 | | ForEachFieldCallback callback, |
185 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
186 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
187 | 0 | google::protobuf::Arena* absl_nonnull arena) const { |
188 | 0 | ABSL_DCHECK(descriptor_pool != nullptr); |
189 | 0 | ABSL_DCHECK(message_factory != nullptr); |
190 | 0 | ABSL_DCHECK(arena != nullptr); |
191 | |
|
192 | 0 | return variant_.Visit([&](const auto& alternative) -> absl::Status { |
193 | 0 | return alternative.ForEachField(callback, descriptor_pool, message_factory, |
194 | 0 | arena); |
195 | 0 | }); Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::ForEachField(absl::lts_20260526::FunctionRef<absl::lts_20260526::StatusOr<bool> (std::__1::basic_string_view<char, std::__1::char_traits<char> >, cel::Value const&)>, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*) const::$_0::operator()<cel::CustomStructValue>(cel::CustomStructValue const&) const Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::ForEachField(absl::lts_20260526::FunctionRef<absl::lts_20260526::StatusOr<bool> (std::__1::basic_string_view<char, std::__1::char_traits<char> >, cel::Value const&)>, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*) const::$_0::operator()<cel::ParsedMessageValue>(cel::ParsedMessageValue const&) const Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::ForEachField(absl::lts_20260526::FunctionRef<absl::lts_20260526::StatusOr<bool> (std::__1::basic_string_view<char, std::__1::char_traits<char> >, cel::Value const&)>, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*) const::$_0::operator()<cel::common_internal::LegacyStructValue>(cel::common_internal::LegacyStructValue const&) const |
196 | 0 | } |
197 | | |
198 | | absl::Status StructValue::Qualify( |
199 | | absl::Span<const SelectQualifier> qualifiers, bool presence_test, |
200 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
201 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
202 | | google::protobuf::Arena* absl_nonnull arena, Value* absl_nonnull result, |
203 | 0 | int* absl_nonnull count) const { |
204 | 0 | ABSL_DCHECK(!qualifiers.empty()); |
205 | 0 | ABSL_DCHECK(descriptor_pool != nullptr); |
206 | 0 | ABSL_DCHECK(message_factory != nullptr); |
207 | 0 | ABSL_DCHECK(arena != nullptr); |
208 | 0 | ABSL_DCHECK(result != nullptr); |
209 | 0 | ABSL_DCHECK(count != nullptr); |
210 | |
|
211 | 0 | return variant_.Visit([&](const auto& alternative) -> absl::Status { |
212 | 0 | return alternative.Qualify(qualifiers, presence_test, descriptor_pool, |
213 | 0 | message_factory, arena, result, count); |
214 | 0 | }); Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::Qualify(absl::lts_20260526::Span<std::__1::variant<cel::FieldSpecifier, cel::AttributeQualifier> const>, bool, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*, int*) const::$_0::operator()<cel::CustomStructValue>(cel::CustomStructValue const&) const Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::Qualify(absl::lts_20260526::Span<std::__1::variant<cel::FieldSpecifier, cel::AttributeQualifier> const>, bool, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*, int*) const::$_0::operator()<cel::ParsedMessageValue>(cel::ParsedMessageValue const&) const Unexecuted instantiation: struct_value.cc:absl::lts_20260526::Status cel::StructValue::Qualify(absl::lts_20260526::Span<std::__1::variant<cel::FieldSpecifier, cel::AttributeQualifier> const>, bool, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*, int*) const::$_0::operator()<cel::common_internal::LegacyStructValue>(cel::common_internal::LegacyStructValue const&) const |
215 | 0 | } |
216 | | |
217 | | namespace common_internal { |
218 | | |
219 | | absl::Status StructValueEqual( |
220 | | const StructValue& lhs, const StructValue& rhs, |
221 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
222 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
223 | 0 | google::protobuf::Arena* absl_nonnull arena, Value* absl_nonnull result) { |
224 | 0 | ABSL_DCHECK(descriptor_pool != nullptr); |
225 | 0 | ABSL_DCHECK(message_factory != nullptr); |
226 | 0 | ABSL_DCHECK(arena != nullptr); |
227 | 0 | ABSL_DCHECK(result != nullptr); |
228 | |
|
229 | 0 | if (lhs.GetTypeName() != rhs.GetTypeName()) { |
230 | 0 | *result = FalseValue(); |
231 | 0 | return absl::OkStatus(); |
232 | 0 | } |
233 | 0 | absl::flat_hash_map<std::string, Value> lhs_fields; |
234 | 0 | CEL_RETURN_IF_ERROR(lhs.ForEachField( |
235 | 0 | [&lhs_fields](absl::string_view name, |
236 | 0 | const Value& lhs_value) -> absl::StatusOr<bool> { |
237 | 0 | lhs_fields.insert_or_assign(std::string(name), Value(lhs_value)); |
238 | 0 | return true; |
239 | 0 | }, |
240 | 0 | descriptor_pool, message_factory, arena)); |
241 | 0 | bool equal = true; |
242 | 0 | size_t rhs_fields_count = 0; |
243 | 0 | CEL_RETURN_IF_ERROR(rhs.ForEachField( |
244 | 0 | [&](absl::string_view name, |
245 | 0 | const Value& rhs_value) -> absl::StatusOr<bool> { |
246 | 0 | auto lhs_field = lhs_fields.find(name); |
247 | 0 | if (lhs_field == lhs_fields.end()) { |
248 | 0 | equal = false; |
249 | 0 | return false; |
250 | 0 | } |
251 | 0 | CEL_RETURN_IF_ERROR(lhs_field->second.Equal( |
252 | 0 | rhs_value, descriptor_pool, message_factory, arena, result)); |
253 | 0 | if (result->IsFalse()) { |
254 | 0 | equal = false; |
255 | 0 | return false; |
256 | 0 | } |
257 | 0 | ++rhs_fields_count; |
258 | 0 | return true; |
259 | 0 | }, |
260 | 0 | descriptor_pool, message_factory, arena)); |
261 | 0 | if (!equal || rhs_fields_count != lhs_fields.size()) { |
262 | 0 | *result = FalseValue(); |
263 | 0 | return absl::OkStatus(); |
264 | 0 | } |
265 | 0 | *result = TrueValue(); |
266 | 0 | return absl::OkStatus(); |
267 | 0 | } |
268 | | |
269 | | absl::Status StructValueEqual( |
270 | | const CustomStructValueInterface& lhs, const StructValue& rhs, |
271 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
272 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
273 | 0 | google::protobuf::Arena* absl_nonnull arena, Value* absl_nonnull result) { |
274 | 0 | ABSL_DCHECK(descriptor_pool != nullptr); |
275 | 0 | ABSL_DCHECK(message_factory != nullptr); |
276 | 0 | ABSL_DCHECK(arena != nullptr); |
277 | 0 | ABSL_DCHECK(result != nullptr); |
278 | |
|
279 | 0 | if (lhs.GetTypeName() != rhs.GetTypeName()) { |
280 | 0 | *result = FalseValue(); |
281 | 0 | return absl::OkStatus(); |
282 | 0 | } |
283 | 0 | absl::flat_hash_map<std::string, Value> lhs_fields; |
284 | 0 | CEL_RETURN_IF_ERROR(lhs.ForEachField( |
285 | 0 | [&lhs_fields](absl::string_view name, |
286 | 0 | const Value& lhs_value) -> absl::StatusOr<bool> { |
287 | 0 | lhs_fields.insert_or_assign(std::string(name), Value(lhs_value)); |
288 | 0 | return true; |
289 | 0 | }, |
290 | 0 | descriptor_pool, message_factory, arena)); |
291 | 0 | bool equal = true; |
292 | 0 | size_t rhs_fields_count = 0; |
293 | 0 | CEL_RETURN_IF_ERROR(rhs.ForEachField( |
294 | 0 | [&](absl::string_view name, |
295 | 0 | const Value& rhs_value) -> absl::StatusOr<bool> { |
296 | 0 | auto lhs_field = lhs_fields.find(name); |
297 | 0 | if (lhs_field == lhs_fields.end()) { |
298 | 0 | equal = false; |
299 | 0 | return false; |
300 | 0 | } |
301 | 0 | CEL_RETURN_IF_ERROR(lhs_field->second.Equal( |
302 | 0 | rhs_value, descriptor_pool, message_factory, arena, result)); |
303 | 0 | if (result->IsFalse()) { |
304 | 0 | equal = false; |
305 | 0 | return false; |
306 | 0 | } |
307 | 0 | ++rhs_fields_count; |
308 | 0 | return true; |
309 | 0 | }, |
310 | 0 | descriptor_pool, message_factory, arena)); |
311 | 0 | if (!equal || rhs_fields_count != lhs_fields.size()) { |
312 | 0 | *result = FalseValue(); |
313 | 0 | return absl::OkStatus(); |
314 | 0 | } |
315 | 0 | *result = TrueValue(); |
316 | 0 | return absl::OkStatus(); |
317 | 0 | } |
318 | | |
319 | | } // namespace common_internal |
320 | | |
321 | 0 | absl::optional<MessageValue> StructValue::AsMessage() const& { |
322 | 0 | if (const auto* alternative = variant_.As<ParsedMessageValue>(); |
323 | 0 | alternative != nullptr) { |
324 | 0 | return *alternative; |
325 | 0 | } |
326 | 0 | return std::nullopt; |
327 | 0 | } |
328 | | |
329 | 0 | absl::optional<MessageValue> StructValue::AsMessage() && { |
330 | 0 | if (auto* alternative = variant_.As<ParsedMessageValue>(); |
331 | 0 | alternative != nullptr) { |
332 | 0 | return std::move(*alternative); |
333 | 0 | } |
334 | 0 | return std::nullopt; |
335 | 0 | } |
336 | | |
337 | 0 | optional_ref<const ParsedMessageValue> StructValue::AsParsedMessage() const& { |
338 | 0 | if (const auto* alternative = variant_.As<ParsedMessageValue>(); |
339 | 0 | alternative != nullptr) { |
340 | 0 | return *alternative; |
341 | 0 | } |
342 | 0 | return std::nullopt; |
343 | 0 | } |
344 | | |
345 | 0 | absl::optional<ParsedMessageValue> StructValue::AsParsedMessage() && { |
346 | 0 | if (auto* alternative = variant_.As<ParsedMessageValue>(); |
347 | 0 | alternative != nullptr) { |
348 | 0 | return std::move(*alternative); |
349 | 0 | } |
350 | 0 | return std::nullopt; |
351 | 0 | } |
352 | | |
353 | 0 | MessageValue StructValue::GetMessage() const& { |
354 | 0 | ABSL_DCHECK(IsMessage()) << *this; |
355 | |
|
356 | 0 | return variant_.Get<ParsedMessageValue>(); |
357 | 0 | } |
358 | | |
359 | 0 | MessageValue StructValue::GetMessage() && { |
360 | 0 | ABSL_DCHECK(IsMessage()) << *this; |
361 | |
|
362 | 0 | return std::move(variant_).Get<ParsedMessageValue>(); |
363 | 0 | } |
364 | | |
365 | 0 | const ParsedMessageValue& StructValue::GetParsedMessage() const& { |
366 | 0 | ABSL_DCHECK(IsParsedMessage()) << *this; |
367 | |
|
368 | 0 | return variant_.Get<ParsedMessageValue>(); |
369 | 0 | } |
370 | | |
371 | 0 | ParsedMessageValue StructValue::GetParsedMessage() && { |
372 | 0 | ABSL_DCHECK(IsParsedMessage()) << *this; |
373 | |
|
374 | 0 | return std::move(variant_).Get<ParsedMessageValue>(); |
375 | 0 | } |
376 | | |
377 | 0 | common_internal::ValueVariant StructValue::ToValueVariant() const& { |
378 | 0 | return variant_.Visit( |
379 | 0 | [](const auto& alternative) -> common_internal::ValueVariant { |
380 | 0 | return common_internal::ValueVariant(alternative); |
381 | 0 | }); Unexecuted instantiation: struct_value.cc:cel::common_internal::ValueVariant cel::StructValue::ToValueVariant() const &::$_0::operator()<cel::CustomStructValue>(cel::CustomStructValue const&) const Unexecuted instantiation: struct_value.cc:cel::common_internal::ValueVariant cel::StructValue::ToValueVariant() const &::$_0::operator()<cel::ParsedMessageValue>(cel::ParsedMessageValue const&) const Unexecuted instantiation: struct_value.cc:cel::common_internal::ValueVariant cel::StructValue::ToValueVariant() const &::$_0::operator()<cel::common_internal::LegacyStructValue>(cel::common_internal::LegacyStructValue const&) const |
382 | 0 | } |
383 | | |
384 | 0 | common_internal::ValueVariant StructValue::ToValueVariant() && { |
385 | 0 | return std::move(variant_).Visit( |
386 | 0 | [](auto&& alternative) -> common_internal::ValueVariant { |
387 | | // NOLINTNEXTLINE(bugprone-move-forwarding-reference) |
388 | 0 | return common_internal::ValueVariant(std::move(alternative)); |
389 | 0 | }); Unexecuted instantiation: struct_value.cc:cel::common_internal::ValueVariant cel::StructValue::ToValueVariant() &&::$_0::operator()<cel::CustomStructValue const&>(cel::CustomStructValue const&) const Unexecuted instantiation: struct_value.cc:cel::common_internal::ValueVariant cel::StructValue::ToValueVariant() &&::$_0::operator()<cel::ParsedMessageValue const&>(cel::ParsedMessageValue const&) const Unexecuted instantiation: struct_value.cc:cel::common_internal::ValueVariant cel::StructValue::ToValueVariant() &&::$_0::operator()<cel::common_internal::LegacyStructValue const&>(cel::common_internal::LegacyStructValue const&) const |
390 | 0 | } |
391 | | |
392 | | } // namespace cel |