/proc/self/cwd/common/values/unknown_value.cc
Line | Count | Source |
1 | | // Copyright 2024 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 "absl/base/nullability.h" |
16 | | #include "absl/log/absl_check.h" |
17 | | #include "absl/status/status.h" |
18 | | #include "absl/strings/str_cat.h" |
19 | | #include "common/value.h" |
20 | | #include "google/protobuf/arena.h" |
21 | | #include "google/protobuf/descriptor.h" |
22 | | #include "google/protobuf/io/zero_copy_stream.h" |
23 | | #include "google/protobuf/message.h" |
24 | | |
25 | | namespace cel { |
26 | | |
27 | | absl::Status UnknownValue::SerializeTo( |
28 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
29 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
30 | 0 | google::protobuf::io::ZeroCopyOutputStream* absl_nonnull output) const { |
31 | 0 | ABSL_DCHECK(descriptor_pool != nullptr); |
32 | 0 | ABSL_DCHECK(message_factory != nullptr); |
33 | 0 | ABSL_DCHECK(output != nullptr); |
34 | |
|
35 | 0 | return absl::FailedPreconditionError( |
36 | 0 | absl::StrCat(GetTypeName(), " is unserializable")); |
37 | 0 | } |
38 | | |
39 | | absl::Status UnknownValue::ConvertToJson( |
40 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
41 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
42 | 0 | google::protobuf::Message* absl_nonnull json) const { |
43 | 0 | ABSL_DCHECK(descriptor_pool != nullptr); |
44 | 0 | ABSL_DCHECK(message_factory != nullptr); |
45 | 0 | ABSL_DCHECK(json != nullptr); |
46 | 0 | ABSL_DCHECK_EQ(json->GetDescriptor()->well_known_type(), |
47 | 0 | google::protobuf::Descriptor::WELLKNOWNTYPE_VALUE); |
48 | |
|
49 | 0 | return absl::FailedPreconditionError( |
50 | 0 | absl::StrCat(GetTypeName(), " is not convertable to JSON")); |
51 | 0 | } |
52 | | |
53 | | absl::Status UnknownValue::Equal( |
54 | | const Value&, const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
55 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
56 | 0 | google::protobuf::Arena* absl_nonnull arena, Value* absl_nonnull result) const { |
57 | 0 | ABSL_DCHECK(descriptor_pool != nullptr); |
58 | 0 | ABSL_DCHECK(message_factory != nullptr); |
59 | 0 | ABSL_DCHECK(arena != nullptr); |
60 | 0 | ABSL_DCHECK(result != nullptr); |
61 | |
|
62 | 0 | *result = FalseValue(); |
63 | 0 | return absl::OkStatus(); |
64 | 0 | } |
65 | | |
66 | | } // namespace cel |