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