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

Method ConvertToJsonObject

common/value.cc:204–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202}
203
204absl::Status Value::ConvertToJsonObject(
205 const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool,
206 google::protobuf::MessageFactory* absl_nonnull message_factory,
207 google::protobuf::Message* absl_nonnull json) const {
208 ABSL_DCHECK(descriptor_pool != nullptr);
209 ABSL_DCHECK(message_factory != nullptr);
210 ABSL_DCHECK(json != nullptr);
211 ABSL_DCHECK_EQ(json->GetDescriptor()->well_known_type(),
212 google::protobuf::Descriptor::WELLKNOWNTYPE_STRUCT);
213
214 return variant_.Visit(absl::Overload(
215 [](absl::monostate) -> absl::Status {
216 return absl::InternalError("use of invalid Value");
217 },
218 [descriptor_pool, message_factory, json](
219 const common_internal::LegacyMapValue& alternative) -> absl::Status {
220 return alternative.ConvertToJsonObject(descriptor_pool, message_factory,
221 json);
222 },
223 [descriptor_pool, message_factory,
224 json](const CustomMapValue& alternative) -> absl::Status {
225 return alternative.ConvertToJsonObject(descriptor_pool, message_factory,
226 json);
227 },
228 [descriptor_pool, message_factory,
229 json](const ParsedMapFieldValue& alternative) -> absl::Status {
230 return alternative.ConvertToJsonObject(descriptor_pool, message_factory,
231 json);
232 },
233 [descriptor_pool, message_factory,
234 json](const ParsedJsonMapValue& alternative) -> absl::Status {
235 return alternative.ConvertToJsonObject(descriptor_pool, message_factory,
236 json);
237 },
238 [descriptor_pool, message_factory,
239 json](const common_internal::LegacyStructValue& alternative)
240 -> absl::Status {
241 return alternative.ConvertToJsonObject(descriptor_pool, message_factory,
242 json);
243 },
244 [descriptor_pool, message_factory,
245 json](const CustomStructValue& alternative) -> absl::Status {
246 return alternative.ConvertToJsonObject(descriptor_pool, message_factory,
247 json);
248 },
249 [descriptor_pool, message_factory,
250 json](const ParsedMessageValue& alternative) -> absl::Status {
251 return alternative.ConvertToJsonObject(descriptor_pool, message_factory,
252 json);
253 },
254 [](const auto& alternative) -> absl::Status {
255 return TypeConversionError(alternative.GetTypeName(),
256 "google.protobuf.Struct")
257 .NativeValue();
258 }));
259}
260
261absl::Status Value::Equal(

Callers

nothing calls this directly

Calls 5

TypeConversionErrorFunction · 0.85
GetDescriptorMethod · 0.45
VisitMethod · 0.45
NativeValueMethod · 0.45
GetTypeNameMethod · 0.45

Tested by

no test coverage detected