/proc/self/cwd/common/values/bytes_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 | | // IWYU pragma: private, include "common/value.h" |
16 | | // IWYU pragma: friend "common/value.h" |
17 | | |
18 | | #ifndef THIRD_PARTY_CEL_CPP_COMMON_VALUES_BYTES_VALUE_H_ |
19 | | #define THIRD_PARTY_CEL_CPP_COMMON_VALUES_BYTES_VALUE_H_ |
20 | | |
21 | | #include <cstddef> |
22 | | #include <ostream> |
23 | | #include <string> |
24 | | #include <type_traits> |
25 | | #include <utility> |
26 | | |
27 | | #include "absl/base/attributes.h" |
28 | | #include "absl/base/nullability.h" |
29 | | #include "absl/log/absl_check.h" |
30 | | #include "absl/status/status.h" |
31 | | #include "absl/strings/cord.h" |
32 | | #include "absl/strings/string_view.h" |
33 | | #include "absl/types/optional.h" |
34 | | #include "common/allocator.h" |
35 | | #include "common/arena.h" |
36 | | #include "common/internal/byte_string.h" |
37 | | #include "common/memory.h" |
38 | | #include "common/type.h" |
39 | | #include "common/value_kind.h" |
40 | | #include "common/values/values.h" |
41 | | #include "google/protobuf/arena.h" |
42 | | #include "google/protobuf/descriptor.h" |
43 | | #include "google/protobuf/io/zero_copy_stream.h" |
44 | | #include "google/protobuf/message.h" |
45 | | |
46 | | namespace cel { |
47 | | |
48 | | class Value; |
49 | | class BytesValue; |
50 | | class BytesValueInputStream; |
51 | | class BytesValueOutputStream; |
52 | | |
53 | | namespace common_internal { |
54 | | absl::string_view LegacyBytesValue(const BytesValue& value, bool stable, |
55 | | google::protobuf::Arena* absl_nonnull arena); |
56 | | } // namespace common_internal |
57 | | |
58 | | // `BytesValue` represents values of the primitive `bytes` type. |
59 | | class BytesValue final : private common_internal::ValueMixin<BytesValue> { |
60 | | public: |
61 | | static constexpr ValueKind kKind = ValueKind::kBytes; |
62 | | |
63 | | static BytesValue From(const char* absl_nullable value, |
64 | | google::protobuf::Arena* absl_nonnull arena |
65 | | ABSL_ATTRIBUTE_LIFETIME_BOUND); |
66 | | static BytesValue From(absl::string_view value, |
67 | | google::protobuf::Arena* absl_nonnull arena |
68 | | ABSL_ATTRIBUTE_LIFETIME_BOUND); |
69 | | static BytesValue From(const absl::Cord& value); |
70 | | static BytesValue From(std::string&& value, |
71 | | google::protobuf::Arena* absl_nonnull arena |
72 | | ABSL_ATTRIBUTE_LIFETIME_BOUND); |
73 | | |
74 | | static BytesValue Wrap(absl::string_view value, |
75 | | google::protobuf::Arena* absl_nullable arena |
76 | | ABSL_ATTRIBUTE_LIFETIME_BOUND); |
77 | | static BytesValue Wrap(absl::string_view value) = delete; |
78 | | static BytesValue Wrap(const absl::Cord& value); |
79 | | static BytesValue Wrap(std::string&& value) = delete; |
80 | | static BytesValue Wrap(std::string&& value, |
81 | | google::protobuf::Arena* absl_nullable arena |
82 | | ABSL_ATTRIBUTE_LIFETIME_BOUND) = delete; |
83 | | |
84 | | // Returns a BytesValue that aliases the provided string. Caller must ensure |
85 | | // the provided string outlives the use of the returned BytesValue. |
86 | | static BytesValue WrapUnsafe(absl::string_view value); |
87 | | |
88 | | static BytesValue Concat(const BytesValue& lhs, const BytesValue& rhs, |
89 | | google::protobuf::Arena* absl_nonnull arena |
90 | | ABSL_ATTRIBUTE_LIFETIME_BOUND); |
91 | | |
92 | | ABSL_DEPRECATED("Use From") |
93 | 0 | explicit BytesValue(const char* absl_nullable value) : value_(value) {} |
94 | | |
95 | | ABSL_DEPRECATED("Use From") |
96 | 0 | explicit BytesValue(absl::string_view value) : value_(value) {} |
97 | | |
98 | | ABSL_DEPRECATED("Use From") |
99 | 0 | explicit BytesValue(const absl::Cord& value) : value_(value) {} |
100 | | |
101 | | ABSL_DEPRECATED("Use From") |
102 | 0 | explicit BytesValue(std::string&& value) : value_(std::move(value)) {} |
103 | | |
104 | | ABSL_DEPRECATED("Use From") |
105 | | BytesValue(Allocator<> allocator, const char* absl_nullable value) |
106 | 0 | : value_(allocator, value) {} |
107 | | |
108 | | ABSL_DEPRECATED("Use From") |
109 | | BytesValue(Allocator<> allocator, absl::string_view value) |
110 | 3.06k | : value_(allocator, value) {} |
111 | | |
112 | | ABSL_DEPRECATED("Use From") |
113 | | BytesValue(Allocator<> allocator, const absl::Cord& value) |
114 | 0 | : value_(allocator, value) {} |
115 | | |
116 | | ABSL_DEPRECATED("Use From") |
117 | | BytesValue(Allocator<> allocator, std::string&& value) |
118 | 0 | : value_(allocator, std::move(value)) {} |
119 | | |
120 | | ABSL_DEPRECATED("Use Wrap") |
121 | | BytesValue(Borrower borrower, absl::string_view value) |
122 | 102 | : value_(borrower, value) {} |
123 | | |
124 | | ABSL_DEPRECATED("Use Wrap") |
125 | | BytesValue(Borrower borrower, const absl::Cord& value) |
126 | 0 | : value_(borrower, value) {} |
127 | | |
128 | 0 | BytesValue() = default; |
129 | 5.01k | BytesValue(const BytesValue&) = default; |
130 | 28.2k | BytesValue(BytesValue&&) = default; |
131 | 0 | BytesValue& operator=(const BytesValue&) = default; |
132 | 96 | BytesValue& operator=(BytesValue&&) = default; |
133 | | |
134 | 0 | constexpr ValueKind kind() const { return kKind; } |
135 | | |
136 | 0 | absl::string_view GetTypeName() const { return BytesType::kName; } |
137 | | |
138 | | std::string DebugString() const; |
139 | | |
140 | | // See Value::SerializeTo(). |
141 | | absl::Status SerializeTo( |
142 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
143 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
144 | | google::protobuf::io::ZeroCopyOutputStream* absl_nonnull output) const; |
145 | | |
146 | | // See Value::ConvertToJson(). |
147 | | absl::Status ConvertToJson( |
148 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
149 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
150 | | google::protobuf::Message* absl_nonnull json) const; |
151 | | |
152 | | absl::Status Equal(const Value& other, |
153 | | const google::protobuf::DescriptorPool* absl_nonnull descriptor_pool, |
154 | | google::protobuf::MessageFactory* absl_nonnull message_factory, |
155 | | google::protobuf::Arena* absl_nonnull arena, |
156 | | Value* absl_nonnull result) const; |
157 | | using ValueMixin::Equal; |
158 | | |
159 | 0 | bool IsZeroValue() const { |
160 | 0 | return NativeValue([](const auto& value) -> bool { return value.empty(); });Unexecuted instantiation: bool cel::BytesValue::IsZeroValue() const::{lambda(auto:1 const&)#1}::operator()<std::__1::basic_string_view<char, {lambda(auto:1 const&)#1}::operator()::char_traits<char> > >(std::__1::basic_string_view<char, {lambda(auto:1 const&)#1}::operator()::char_traits<char> > const&) constUnexecuted instantiation: bool cel::BytesValue::IsZeroValue() const::{lambda(auto:1 const&)#1}::operator()<absl::lts_20260107::Cord>(absl::lts_20260107::Cord const&) const |
161 | 0 | } |
162 | | |
163 | | BytesValue Clone(google::protobuf::Arena* absl_nonnull arena) const; |
164 | | |
165 | | ABSL_DEPRECATED("Use ToString()") |
166 | 0 | std::string NativeString() const { return value_.ToString(); } |
167 | | |
168 | | ABSL_DEPRECATED("Use ToStringView()") |
169 | | absl::string_view NativeString( |
170 | | std::string& scratch |
171 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND) const ABSL_ATTRIBUTE_LIFETIME_BOUND { |
172 | 0 | return value_.ToStringView(&scratch); |
173 | 0 | } |
174 | | |
175 | | ABSL_DEPRECATED("Use ToCord()") |
176 | 0 | absl::Cord NativeCord() const { return value_.ToCord(); } |
177 | | |
178 | | template <typename Visitor> |
179 | | ABSL_DEPRECATED("Use TryFlat()") |
180 | | std::common_type_t< |
181 | | std::invoke_result_t<Visitor, absl::string_view>, |
182 | | std::invoke_result_t<Visitor, const absl::Cord&>> NativeValue(Visitor&& |
183 | | visitor) |
184 | 1.14k | const { |
185 | 1.14k | return value_.Visit(std::forward<Visitor>(visitor)); |
186 | 1.14k | } Unexecuted instantiation: std::__1::common_type<cel::BytesValue::IsZeroValue() const::{lambda(auto:1 const&)#1}::__invoke_result_impl<void, cel::BytesValue::IsZeroValue() const::{lambda(auto:1 const&)#1}, cel::BytesValue::IsZeroValue() const::{lambda(auto:1 const&)#1}::basic_string_view<char, cel::BytesValue::IsZeroValue() const::{lambda(auto:1 const&)#1}::char_traits<char> > >::type, std::__1::common_type<void, cel::BytesValue::IsZeroValue() const::{lambda(auto:1 const&)#1}, absl::lts_20260107::Cord const&>::type>::type cel::BytesValue::NativeValue<cel::BytesValue::IsZeroValue() const::{lambda(auto:1 const&)#1}>(cel::BytesValue::IsZeroValue() const::{lambda(auto:1 const&)#1}&&) consttype_conversion_functions.cc:std::__1::common_type<cel::(anonymous namespace)::RegisterStringConversionFunctions(cel::FunctionRegistry&, cel::RuntimeOptions const&)::$_0::operator()(cel::BytesValue const&) const::{lambda(auto:1 const&)#1}::__invoke_result_impl<void, cel::(anonymous namespace)::RegisterStringConversionFunctions(cel::FunctionRegistry&, cel::RuntimeOptions const&)::$_0::operator()(cel::BytesValue const&) const::{lambda(auto:1 const&)#1}, cel::(anonymous namespace)::RegisterStringConversionFunctions(cel::FunctionRegistry&, cel::RuntimeOptions const&)::$_0::operator()(cel::BytesValue const&) const::{lambda(auto:1 const&)#1}::basic_string_view<char, cel::(anonymous namespace)::RegisterStringConversionFunctions(cel::FunctionRegistry&, cel::RuntimeOptions const&)::$_0::operator()(cel::BytesValue const&) const::{lambda(auto:1 const&)#1}::char_traits<char> > >::type, std::__1::common_type<void, cel::(anonymous namespace)::RegisterStringConversionFunctions(cel::FunctionRegistry&, cel::RuntimeOptions const&)::$_0::operator()(cel::BytesValue const&) const::{lambda(auto:1 const&)#1}, absl::lts_20260107::Cord const&>::type>::type cel::BytesValue::NativeValue<cel::(anonymous namespace)::RegisterStringConversionFunctions(cel::FunctionRegistry&, cel::RuntimeOptions const&)::$_0::operator()(cel::BytesValue const&) const::{lambda(auto:1 const&)#1}>(cel::(anonymous namespace)::RegisterStringConversionFunctions(cel::FunctionRegistry&, cel::RuntimeOptions const&)::$_0::operator()(cel::BytesValue const&) const::{lambda(auto:1 const&)#1}&&) constLine | Count | Source | 184 | 7 | const { | 185 | 7 | return value_.Visit(std::forward<Visitor>(visitor)); | 186 | 7 | } |
Unexecuted instantiation: bytes_value.cc:std::__1::common_type<std::__1::__invoke_result_impl<void, absl::lts_20260107::Overload<cel::(anonymous namespace)::BytesDebugString<cel::BytesValue>(cel::BytesValue const&)::{lambda(std::__1::basic_string_view<char, std::__1::char_traits<char> >)#1}, cel::(anonymous namespace)::BytesDebugString<cel::BytesValue>(cel::BytesValue const&)::{lambda(absl::lts_20260107::Cord const&)#1}>, std::__1::basic_string_view<char, std::__1::char_traits<char> > >::type, absl::lts_20260107::Overload<cel::(anonymous namespace)::BytesDebugString<cel::BytesValue>(cel::BytesValue const&)::{lambda(std::__1::basic_string_view<char, std::__1::char_traits<char> >)#1}, cel::(anonymous namespace)::BytesDebugString<cel::BytesValue>(cel::BytesValue const&)::{lambda(absl::lts_20260107::Cord const&)#1}><void, absl::lts_20260107::Overload<cel::(anonymous namespace)::BytesDebugString<cel::BytesValue>(cel::BytesValue const&)::{lambda(std::__1::basic_string_view<char, std::__1::char_traits<char> >)#1}, cel::(anonymous namespace)::BytesDebugString<cel::BytesValue>(cel::BytesValue const&)::{lambda(absl::lts_20260107::Cord const&)#1}>, absl::lts_20260107::Cord const>::type>::type cel::BytesValue::NativeValue<absl::lts_20260107::Overload<cel::(anonymous namespace)::BytesDebugString<cel::BytesValue>(cel::BytesValue const&)::{lambda(std::__1::basic_string_view<char, std::__1::char_traits<char> >)#1}, cel::(anonymous namespace)::BytesDebugString<cel::BytesValue>(cel::BytesValue const&)::{lambda(absl::lts_20260107::Cord const&)#1}> >(absl::lts_20260107::Overload<cel::(anonymous namespace)::BytesDebugString<cel::BytesValue>(cel::BytesValue const&)::{lambda(std::__1::basic_string_view<char, std::__1::char_traits<char> >)#1}, cel::(anonymous namespace)::BytesDebugString<cel::BytesValue>(cel::BytesValue const&)::{lambda(absl::lts_20260107::Cord const&)#1}>&&) constUnexecuted instantiation: bytes_value.cc:std::__1::common_type<std::__1::__invoke_result_impl<void, cel::BytesValue::ConvertToJson(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Message*) const::$_0, std::__1::basic_string_view<char, std::__1::char_traits<char> > >::type, std::__1::__invoke_result_impl<void, cel::BytesValue::ConvertToJson(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Message*) const::$_0, absl::lts_20260107::Cord const&>::type>::type cel::BytesValue::NativeValue<cel::BytesValue::ConvertToJson(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Message*) const::$_0>(cel::BytesValue::ConvertToJson(google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Message*) const::$_0&&) const bytes_value.cc:std::__1::common_type<std::__1::__invoke_result_impl<void, cel::BytesValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0, std::__1::basic_string_view<char, std::__1::char_traits<char> > >::type, std::__1::__invoke_result_impl<void, cel::BytesValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0, absl::lts_20260107::Cord const&>::type>::type cel::BytesValue::NativeValue<cel::BytesValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0>(cel::BytesValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0&&) const Line | Count | Source | 184 | 152 | const { | 185 | 152 | return value_.Visit(std::forward<Visitor>(visitor)); | 186 | 152 | } |
bytes_value.cc:std::__1::common_type<std::__1::__invoke_result_impl<void, cel::BytesValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<std::__1::basic_string_view<char, std::__1::char_traits<char> > >(std::__1::basic_string_view<char, std::__1::char_traits<char> > const&) const::{lambda(auto:1 const&)#1}, std::__1::basic_string_view<char, std::__1::char_traits<char> > >::type, std::__1::common_type<void, cel::BytesValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<std::__1::basic_string_view<char, std::__1::char_traits<char> > >(std::__1::basic_string_view<char, std::__1::char_traits<char> > const&) const::{lambda(auto:1 const&)#1}, absl::lts_20260107::Cord const&>::type>::type cel::BytesValue::NativeValue<cel::BytesValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<std::__1::basic_string_view<char, std::__1::char_traits<char> > >(std::__1::basic_string_view<char, std::__1::char_traits<char> > const&) const::{lambda(auto:1 const&)#1}>(cel::BytesValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<std::__1::basic_string_view<char, std::__1::char_traits<char> > >(std::__1::basic_string_view<char, std::__1::char_traits<char> > const&) const::{lambda(auto:1 const&)#1}&&) constLine | Count | Source | 184 | 152 | const { | 185 | 152 | return value_.Visit(std::forward<Visitor>(visitor)); | 186 | 152 | } |
Unexecuted instantiation: bytes_value.cc:std::__1::common_type<cel::BytesValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<absl::lts_20260107::Cord>(absl::lts_20260107::Cord const&) const::{lambda(auto:1 const&)#1}::__invoke_result_impl<void, cel::BytesValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<absl::lts_20260107::Cord>(absl::lts_20260107::Cord const&) const::{lambda(auto:1 const&)#1}, cel::BytesValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<absl::lts_20260107::Cord>(absl::lts_20260107::Cord const&) const::{lambda(auto:1 const&)#1}::basic_string_view<char, cel::BytesValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<absl::lts_20260107::Cord>(absl::lts_20260107::Cord const&) const::{lambda(auto:1 const&)#1}::char_traits<char> > >::type, std::__1::common_type<void, cel::BytesValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<absl::lts_20260107::Cord>(absl::lts_20260107::Cord const&) const::{lambda(auto:1 const&)#1}, absl::lts_20260107::Cord const&>::type>::type cel::BytesValue::NativeValue<cel::BytesValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<absl::lts_20260107::Cord>(absl::lts_20260107::Cord const&) const::{lambda(auto:1 const&)#1}>(cel::BytesValue::Equal(cel::Value const&, google::protobuf::DescriptorPool const*, google::protobuf::MessageFactory*, google::protobuf::Arena*, cel::Value*) const::$_0::operator()<absl::lts_20260107::Cord>(absl::lts_20260107::Cord const&) const::{lambda(auto:1 const&)#1}&&) constbytes_value.cc:std::__1::common_type<std::__1::__invoke_result_impl<void, cel::BytesValue::Size() const::$_0, std::__1::basic_string_view<char, std::__1::char_traits<char> > >::type, std::__1::__invoke_result_impl<void, cel::BytesValue::Size() const::$_0, absl::lts_20260107::Cord const&>::type>::type cel::BytesValue::NativeValue<cel::BytesValue::Size() const::$_0>(cel::BytesValue::Size() const::$_0&&) const Line | Count | Source | 184 | 2 | const { | 185 | 2 | return value_.Visit(std::forward<Visitor>(visitor)); | 186 | 2 | } |
Unexecuted instantiation: bytes_value.cc:std::__1::common_type<std::__1::__invoke_result_impl<void, cel::BytesValue::IsEmpty() const::$_0, std::__1::basic_string_view<char, std::__1::char_traits<char> > >::type, std::__1::__invoke_result_impl<void, cel::BytesValue::IsEmpty() const::$_0, absl::lts_20260107::Cord const&>::type>::type cel::BytesValue::NativeValue<cel::BytesValue::IsEmpty() const::$_0>(cel::BytesValue::IsEmpty() const::$_0&&) const bytes_value.cc:std::__1::common_type<std::__1::__invoke_result_impl<void, cel::BytesValue::Equals(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const::$_0, std::__1::basic_string_view<char, std::__1::char_traits<char> > >::type, std::__1::__invoke_result_impl<void, cel::BytesValue::Equals(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const::$_0, absl::lts_20260107::Cord const&>::type>::type cel::BytesValue::NativeValue<cel::BytesValue::Equals(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const::$_0>(cel::BytesValue::Equals(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const::$_0&&) const Line | Count | Source | 184 | 18 | const { | 185 | 18 | return value_.Visit(std::forward<Visitor>(visitor)); | 186 | 18 | } |
Unexecuted instantiation: bytes_value.cc:std::__1::common_type<std::__1::__invoke_result_impl<void, cel::BytesValue::Equals(absl::lts_20260107::Cord const&) const::$_0, std::__1::basic_string_view<char, std::__1::char_traits<char> > >::type, std::__1::__invoke_result_impl<void, cel::BytesValue::Equals(absl::lts_20260107::Cord const&) const::$_0, absl::lts_20260107::Cord const&>::type>::type cel::BytesValue::NativeValue<cel::BytesValue::Equals(absl::lts_20260107::Cord const&) const::$_0>(cel::BytesValue::Equals(absl::lts_20260107::Cord const&) const::$_0&&) const bytes_value.cc:std::__1::common_type<std::__1::__invoke_result_impl<void, cel::BytesValue::Equals(cel::BytesValue const&) const::$_0, std::__1::basic_string_view<char, std::__1::char_traits<char> > >::type, std::__1::__invoke_result_impl<void, cel::BytesValue::Equals(cel::BytesValue const&) const::$_0, absl::lts_20260107::Cord const&>::type>::type cel::BytesValue::NativeValue<cel::BytesValue::Equals(cel::BytesValue const&) const::$_0>(cel::BytesValue::Equals(cel::BytesValue const&) const::$_0&&) const Line | Count | Source | 184 | 18 | const { | 185 | 18 | return value_.Visit(std::forward<Visitor>(visitor)); | 186 | 18 | } |
bytes_value.cc:std::__1::common_type<std::__1::__invoke_result_impl<void, cel::BytesValue::Compare(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const::$_0, std::__1::basic_string_view<char, std::__1::char_traits<char> > >::type, std::__1::__invoke_result_impl<void, cel::BytesValue::Compare(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const::$_0, absl::lts_20260107::Cord const&>::type>::type cel::BytesValue::NativeValue<cel::BytesValue::Compare(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const::$_0>(cel::BytesValue::Compare(std::__1::basic_string_view<char, std::__1::char_traits<char> >) const::$_0&&) const Line | Count | Source | 184 | 400 | const { | 185 | 400 | return value_.Visit(std::forward<Visitor>(visitor)); | 186 | 400 | } |
Unexecuted instantiation: bytes_value.cc:std::__1::common_type<std::__1::__invoke_result_impl<void, cel::BytesValue::Compare(absl::lts_20260107::Cord const&) const::$_0, std::__1::basic_string_view<char, std::__1::char_traits<char> > >::type, std::__1::__invoke_result_impl<void, cel::BytesValue::Compare(absl::lts_20260107::Cord const&) const::$_0, absl::lts_20260107::Cord const&>::type>::type cel::BytesValue::NativeValue<cel::BytesValue::Compare(absl::lts_20260107::Cord const&) const::$_0>(cel::BytesValue::Compare(absl::lts_20260107::Cord const&) const::$_0&&) const bytes_value.cc:std::__1::common_type<std::__1::__invoke_result_impl<void, cel::BytesValue::Compare(cel::BytesValue const&) const::$_0, std::__1::basic_string_view<char, std::__1::char_traits<char> > >::type, std::__1::__invoke_result_impl<void, cel::BytesValue::Compare(cel::BytesValue const&) const::$_0, absl::lts_20260107::Cord const&>::type>::type cel::BytesValue::NativeValue<cel::BytesValue::Compare(cel::BytesValue const&) const::$_0>(cel::BytesValue::Compare(cel::BytesValue const&) const::$_0&&) const Line | Count | Source | 184 | 400 | const { | 185 | 400 | return value_.Visit(std::forward<Visitor>(visitor)); | 186 | 400 | } |
Unexecuted instantiation: struct_value_builder.cc:std::__1::common_type<std::__1::__invoke_result_impl<void, absl::lts_20260107::Overload<cel::common_internal::(anonymous namespace)::MessageValueBuilderImpl::SetSingularField(google::protobuf::FieldDescriptor const*, cel::Value)::{lambda(std::__1::basic_string_view<char, std::__1::char_traits<char> >)#1}, cel::common_internal::(anonymous namespace)::MessageValueBuilderImpl::SetSingularField(google::protobuf::FieldDescriptor const*, cel::Value)::{lambda(absl::lts_20260107::Cord const&)#1}>, std::__1::basic_string_view<char, std::__1::char_traits<char> > >::type, absl::lts_20260107::Overload<cel::common_internal::(anonymous namespace)::MessageValueBuilderImpl::SetSingularField(google::protobuf::FieldDescriptor const*, cel::Value)::{lambda(std::__1::basic_string_view<char, std::__1::char_traits<char> >)#1}, cel::common_internal::(anonymous namespace)::MessageValueBuilderImpl::SetSingularField(google::protobuf::FieldDescriptor const*, cel::Value)::{lambda(absl::lts_20260107::Cord const&)#1}><void, std::__1::common_type, absl::lts_20260107::Cord const>::type>::type cel::BytesValue::NativeValue<absl::lts_20260107::Overload<cel::common_internal::(anonymous namespace)::MessageValueBuilderImpl::SetSingularField(google::protobuf::FieldDescriptor const*, cel::Value)::{lambda(std::__1::basic_string_view<char, std::__1::char_traits<char> >)#1}, cel::common_internal::(anonymous namespace)::MessageValueBuilderImpl::SetSingularField(google::protobuf::FieldDescriptor const*, cel::Value)::{lambda(absl::lts_20260107::Cord const&)#1}> >(std::__1::common_type&&) const |
187 | | |
188 | 0 | void swap(BytesValue& other) noexcept { |
189 | 0 | using std::swap; |
190 | 0 | swap(value_, other.value_); |
191 | 0 | } |
192 | | |
193 | | size_t Size() const; |
194 | | |
195 | | bool IsEmpty() const; |
196 | | |
197 | | bool Equals(absl::string_view bytes) const; |
198 | | bool Equals(const absl::Cord& bytes) const; |
199 | | bool Equals(const BytesValue& bytes) const; |
200 | | |
201 | | int Compare(absl::string_view bytes) const; |
202 | | int Compare(const absl::Cord& bytes) const; |
203 | | int Compare(const BytesValue& bytes) const; |
204 | | |
205 | | absl::optional<absl::string_view> TryFlat() const |
206 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND { |
207 | 0 | return value_.TryFlat(); |
208 | 0 | } |
209 | | |
210 | 4 | std::string ToString() const { return value_.ToString(); } |
211 | | |
212 | 0 | void CopyToString(std::string* absl_nonnull out) const { |
213 | 0 | value_.CopyToString(out); |
214 | 0 | } |
215 | | |
216 | 0 | void AppendToString(std::string* absl_nonnull out) const { |
217 | 0 | value_.AppendToString(out); |
218 | 0 | } |
219 | | |
220 | 0 | absl::Cord ToCord() const { return value_.ToCord(); } |
221 | | |
222 | 0 | void CopyToCord(absl::Cord* absl_nonnull out) const { |
223 | 0 | value_.CopyToCord(out); |
224 | 0 | } |
225 | | |
226 | 0 | void AppendToCord(absl::Cord* absl_nonnull out) const { |
227 | 0 | value_.AppendToCord(out); |
228 | 0 | } |
229 | | |
230 | | absl::string_view ToStringView( |
231 | | std::string* absl_nonnull scratch |
232 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND) const ABSL_ATTRIBUTE_LIFETIME_BOUND { |
233 | 0 | return value_.ToStringView(scratch); |
234 | 0 | } |
235 | | |
236 | 0 | friend bool operator<(const BytesValue& lhs, const BytesValue& rhs) { |
237 | 0 | return lhs.value_ < rhs.value_; |
238 | 0 | } |
239 | | |
240 | | private: |
241 | | friend class common_internal::ValueMixin<BytesValue>; |
242 | | friend class BytesValueInputStream; |
243 | | friend class BytesValueOutputStream; |
244 | | friend absl::string_view common_internal::LegacyBytesValue( |
245 | | const BytesValue& value, bool stable, google::protobuf::Arena* absl_nonnull arena); |
246 | | friend struct ArenaTraits<BytesValue>; |
247 | | |
248 | | explicit BytesValue(common_internal::ByteString value) noexcept |
249 | 558 | : value_(std::move(value)) {} |
250 | | |
251 | | common_internal::ByteString value_; |
252 | | }; |
253 | | |
254 | 0 | inline void swap(BytesValue& lhs, BytesValue& rhs) noexcept { lhs.swap(rhs); } |
255 | | |
256 | 0 | inline std::ostream& operator<<(std::ostream& out, const BytesValue& value) { |
257 | 0 | return out << value.DebugString(); |
258 | 0 | } |
259 | | |
260 | 0 | inline bool operator==(const BytesValue& lhs, absl::string_view rhs) { |
261 | 0 | return lhs.Equals(rhs); |
262 | 0 | } |
263 | | |
264 | 0 | inline bool operator==(absl::string_view lhs, const BytesValue& rhs) { |
265 | 0 | return rhs == lhs; |
266 | 0 | } |
267 | | |
268 | 0 | inline bool operator!=(const BytesValue& lhs, absl::string_view rhs) { |
269 | 0 | return !lhs.Equals(rhs); |
270 | 0 | } |
271 | | |
272 | 0 | inline bool operator!=(absl::string_view lhs, const BytesValue& rhs) { |
273 | 0 | return rhs != lhs; |
274 | 0 | } |
275 | | |
276 | | inline BytesValue BytesValue::From(const char* absl_nullable value, |
277 | | google::protobuf::Arena* absl_nonnull arena |
278 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND) { |
279 | 0 | return From(absl::NullSafeStringView(value), arena); |
280 | 0 | } |
281 | | |
282 | | inline BytesValue BytesValue::From(absl::string_view value, |
283 | | google::protobuf::Arena* absl_nonnull arena |
284 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND) { |
285 | 0 | ABSL_DCHECK(arena != nullptr); |
286 | 0 |
|
287 | 0 | return BytesValue(arena, value); |
288 | 0 | } |
289 | | |
290 | 0 | inline BytesValue BytesValue::From(const absl::Cord& value) { |
291 | 0 | return BytesValue(value); |
292 | 0 | } |
293 | | |
294 | | inline BytesValue BytesValue::From(std::string&& value, |
295 | | google::protobuf::Arena* absl_nonnull arena |
296 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND) { |
297 | 0 | ABSL_DCHECK(arena != nullptr); |
298 | 0 |
|
299 | 0 | return BytesValue(arena, std::move(value)); |
300 | 0 | } |
301 | | |
302 | | inline BytesValue BytesValue::Wrap(absl::string_view value, |
303 | | google::protobuf::Arena* absl_nullable arena |
304 | 0 | ABSL_ATTRIBUTE_LIFETIME_BOUND) { |
305 | 0 | ABSL_DCHECK(arena != nullptr); |
306 | 0 |
|
307 | 0 | return BytesValue(Borrower::Arena(arena), value); |
308 | 0 | } |
309 | | |
310 | 0 | inline BytesValue BytesValue::WrapUnsafe(absl::string_view value) { |
311 | 0 | return BytesValue(common_internal::ByteString::FromExternal(value)); |
312 | 0 | } |
313 | | |
314 | 0 | inline BytesValue BytesValue::Wrap(const absl::Cord& value) { |
315 | 0 | return BytesValue(value); |
316 | 0 | } |
317 | | |
318 | | namespace common_internal { |
319 | | |
320 | | inline absl::string_view LegacyBytesValue(const BytesValue& value, bool stable, |
321 | 67 | google::protobuf::Arena* absl_nonnull arena) { |
322 | 67 | return LegacyByteString(value.value_, stable, arena); |
323 | 67 | } |
324 | | |
325 | | } // namespace common_internal |
326 | | |
327 | | template <> |
328 | | struct ArenaTraits<BytesValue> { |
329 | | using constructible = std::true_type; |
330 | | |
331 | 6.40k | static bool trivially_destructible(const BytesValue& value) { |
332 | 6.40k | return ArenaTraits<>::trivially_destructible(value.value_); |
333 | 6.40k | } |
334 | | }; |
335 | | |
336 | | } // namespace cel |
337 | | |
338 | | #endif // THIRD_PARTY_CEL_CPP_COMMON_VALUES_BYTES_VALUE_H_ |