src/core/lib/slice/slice.h
Go to the documentation of this file.
1 // Copyright 2021 gRPC authors.
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 // http://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 #ifndef GRPC_CORE_LIB_SLICE_SLICE_H
16 #define GRPC_CORE_LIB_SLICE_SLICE_H
17 
19 
20 #include <string.h>
21 
22 #include <cstdint>
23 #include <string>
24 #include <utility>
25 
26 #include "absl/strings/string_view.h"
27 
28 #include <grpc/slice.h>
29 #include <grpc/support/log.h>
30 
35 
36 // Herein lies grpc_core::Slice and its team of thin wrappers around grpc_slice.
37 // They aim to keep you safe by providing strong guarantees around lifetime and
38 // mutability.
39 //
40 // The team:
41 // Slice - provides a wrapper around an unknown type of slice.
42 // Immutable (since we don't know who else might be referencing
43 // it), and potentially ref counted.
44 // StaticSlice - provides a wrapper around a static slice. Not refcounted,
45 // fast to copy.
46 // MutableSlice - provides a guarantee of unique ownership, meaning the
47 // underlying data can be mutated safely.
48 
49 // This slice implementation is an extension of the event engine Slice
50 // implementation defined in <grpc/event_engine/slice.h>. Changes to this
51 // implementation might warrant changes to the public event engine Slice
52 // type as well.
53 
54 namespace grpc_core {
55 
56 namespace slice_detail {
57 
58 // Returns an empty slice.
59 static constexpr grpc_slice EmptySlice() { return {nullptr, {}}; }
60 
61 // BaseSlice holds the grpc_slice object, but does not apply refcounting policy.
62 // It does export immutable access into the slice, such that this can be shared
63 // by all storage policies.
64 class BaseSlice {
65  public:
66  BaseSlice(const BaseSlice&) = delete;
67  BaseSlice& operator=(const BaseSlice&) = delete;
68  BaseSlice(BaseSlice&& other) = delete;
69  BaseSlice& operator=(BaseSlice&& other) = delete;
70 
71  // Iterator access to the underlying bytes
72  const uint8_t* begin() const { return GRPC_SLICE_START_PTR(c_slice()); }
73  const uint8_t* end() const { return GRPC_SLICE_END_PTR(c_slice()); }
74  const uint8_t* cbegin() const { return GRPC_SLICE_START_PTR(c_slice()); }
75  const uint8_t* cend() const { return GRPC_SLICE_END_PTR(c_slice()); }
76 
77  // Retrieve a borrowed reference to the underlying grpc_slice.
78  const grpc_slice& c_slice() const { return slice_; }
79 
80  // Retrieve the underlying grpc_slice, and replace the one in this object with
81  // EmptySlice().
84  slice_ = EmptySlice();
85  return out;
86  }
87 
88  // As other things... borrowed references.
90  return absl::string_view(reinterpret_cast<const char*>(data()), size());
91  }
92 
93  // Array access
94  uint8_t operator[](size_t i) const {
95  return GRPC_SLICE_START_PTR(c_slice())[i];
96  }
97 
98  // Access underlying data
99  const uint8_t* data() const { return GRPC_SLICE_START_PTR(c_slice()); }
100 
101  // Size of the slice
102  size_t size() const { return GRPC_SLICE_LENGTH(c_slice()); }
103  size_t length() const { return size(); }
104  bool empty() const { return size() == 0; }
105 
106  // For inlined slices - are these two slices equal?
107  // For non-inlined slices - do these two slices refer to the same block of
108  // memory?
109  bool is_equivalent(const BaseSlice& other) const {
110  return grpc_slice_is_equivalent(slice_, other.slice_);
111  }
112 
114 
115  protected:
117  explicit BaseSlice(const grpc_slice& slice) : slice_(slice) {}
118  ~BaseSlice() = default;
119 
120  void Swap(BaseSlice* other) { std::swap(slice_, other->slice_); }
121  void SetCSlice(const grpc_slice& slice) { slice_ = slice; }
122 
124 
125  grpc_slice* c_slice_ptr() { return &slice_; }
126 
127  private:
129 };
130 
131 inline bool operator==(const BaseSlice& a, const BaseSlice& b) {
132  return grpc_slice_eq(a.c_slice(), b.c_slice()) != 0;
133 }
134 
135 inline bool operator!=(const BaseSlice& a, const BaseSlice& b) {
136  return grpc_slice_eq(a.c_slice(), b.c_slice()) == 0;
137 }
138 
139 inline bool operator==(const BaseSlice& a, absl::string_view b) {
140  return a.as_string_view() == b;
141 }
142 
143 inline bool operator!=(const BaseSlice& a, absl::string_view b) {
144  return a.as_string_view() != b;
145 }
146 
147 inline bool operator==(absl::string_view a, const BaseSlice& b) {
148  return a == b.as_string_view();
149 }
150 
151 inline bool operator!=(absl::string_view a, const BaseSlice& b) {
152  return a != b.as_string_view();
153 }
154 
155 inline bool operator==(const BaseSlice& a, const grpc_slice& b) {
156  return grpc_slice_eq(a.c_slice(), b) != 0;
157 }
158 
159 inline bool operator!=(const BaseSlice& a, const grpc_slice& b) {
160  return grpc_slice_eq(a.c_slice(), b) == 0;
161 }
162 
163 inline bool operator==(const grpc_slice& a, const BaseSlice& b) {
164  return grpc_slice_eq(a, b.c_slice()) != 0;
165 }
166 
167 inline bool operator!=(const grpc_slice& a, const BaseSlice& b) {
168  return grpc_slice_eq(a, b.c_slice()) == 0;
169 }
170 
171 template <typename Out>
173  static Out FromCopiedString(const char* s) {
174  return FromCopiedBuffer(s, strlen(s));
175  }
177  return FromCopiedBuffer(s.data(), s.size());
178  }
180  return Out(grpc_slice_from_cpp_string(std::move(s)));
181  }
182  static Out FromCopiedBuffer(const char* p, size_t len) {
183  return Out(grpc_slice_from_copied_buffer(p, len));
184  }
185 
186  template <typename Buffer>
187  static Out FromCopiedBuffer(const Buffer& buffer) {
188  return FromCopiedBuffer(reinterpret_cast<const char*>(buffer.data()),
189  buffer.size());
190  }
191 
192  static Out FromInt64(int64_t i) {
194  gpr_ltoa(i, buffer);
195  return FromCopiedString(buffer);
196  }
197 };
198 
199 template <typename Out>
201  static Out FromStaticString(const char* s) {
202  return FromStaticBuffer(s, strlen(s));
203  }
204 
206  return FromStaticBuffer(s.data(), s.size());
207  }
208 
209  static Out FromStaticBuffer(const void* s, size_t len) {
213  const_cast<uint8_t*>(static_cast<const uint8_t*>(s));
215  return Out(slice);
216  }
217 };
218 
219 } // namespace slice_detail
220 
222  public slice_detail::StaticConstructors<StaticSlice> {
223  public:
224  StaticSlice() = default;
225  explicit StaticSlice(const grpc_slice& slice)
226  : slice_detail::BaseSlice(slice) {
228  }
229 
230  StaticSlice(const StaticSlice& other)
231  : slice_detail::BaseSlice(other.c_slice()) {}
233  SetCSlice(other.c_slice());
234  return *this;
235  }
236  StaticSlice(StaticSlice&& other) noexcept
237  : slice_detail::BaseSlice(other.TakeCSlice()) {}
238  StaticSlice& operator=(StaticSlice&& other) noexcept {
239  Swap(&other);
240  return *this;
241  }
242 };
243 
245  public slice_detail::CopyConstructors<MutableSlice> {
246  public:
247  MutableSlice() = default;
248  explicit MutableSlice(const grpc_slice& slice)
249  : slice_detail::BaseSlice(slice) {
251  }
253 
254  MutableSlice(const MutableSlice&) = delete;
255  MutableSlice& operator=(const MutableSlice&) = delete;
256  MutableSlice(MutableSlice&& other) noexcept
257  : slice_detail::BaseSlice(other.TakeCSlice()) {}
258  MutableSlice& operator=(MutableSlice&& other) noexcept {
259  Swap(&other);
260  return *this;
261  }
262 
265  }
266 
267  // Return a sub slice of this one. Leaves this slice in an indeterminate but
268  // valid state.
269  MutableSlice TakeSubSlice(size_t pos, size_t n) {
271  }
272 
273  // Iterator access to the underlying bytes
274  uint8_t* begin() { return mutable_data(); }
275  uint8_t* end() { return mutable_data() + size(); }
276  uint8_t* data() { return mutable_data(); }
277 
278  // Array access
279  uint8_t& operator[](size_t i) { return mutable_data()[i]; }
280 };
281 
283  public slice_detail::CopyConstructors<Slice>,
284  public slice_detail::StaticConstructors<Slice> {
285  public:
286  Slice() = default;
288  explicit Slice(const grpc_slice& slice) : slice_detail::BaseSlice(slice) {}
289  explicit Slice(slice_detail::BaseSlice&& other)
290  : slice_detail::BaseSlice(other.TakeCSlice()) {}
291 
292  Slice(const Slice&) = delete;
293  Slice& operator=(const Slice&) = delete;
294  Slice(Slice&& other) noexcept : slice_detail::BaseSlice(other.TakeCSlice()) {}
295  Slice& operator=(Slice&& other) noexcept {
296  Swap(&other);
297  return *this;
298  }
299 
300  // A slice might refer to some memory that we keep a refcount to (this is
301  // owned), or some memory that's inlined into the slice (also owned), or some
302  // other block of memory that we know will be available for the lifetime of
303  // some operation in the common case (not owned). In the *less common* case
304  // that we need to keep that slice text for longer than our API's guarantee us
305  // access, we need to take a copy and turn this into something that we do own.
306 
307  // TakeOwned returns an owned slice regardless of current ownership, and
308  // leaves the current slice in a valid but externally unpredictable state - in
309  // doing so it can avoid adding a ref to the underlying slice.
311  if (c_slice().refcount == nullptr) {
312  return Slice(c_slice());
313  }
315  return Slice(grpc_slice_copy(c_slice()));
316  }
317  return Slice(TakeCSlice());
318  }
319 
320  // AsOwned returns an owned slice but does not mutate the current slice,
321  // meaning that it may add a reference to the underlying slice.
322  Slice AsOwned() const {
323  if (c_slice().refcount == nullptr) {
324  return Slice(c_slice());
325  }
327  return Slice(grpc_slice_copy(c_slice()));
328  }
330  }
331 
332  // TakeMutable returns a MutableSlice, and leaves the current slice in an
333  // indeterminate but valid state.
334  // A mutable slice requires only one reference to the bytes of the slice -
335  // this can be achieved either with inlined storage or with a single
336  // reference.
337  // If the current slice is refcounted and there are more than one references
338  // to that slice, then the slice is copied in order to achieve a mutable
339  // version.
341  if (c_slice().refcount == nullptr) {
342  return MutableSlice(c_slice());
343  }
345  c_slice().refcount->IsUnique()) {
346  return MutableSlice(TakeCSlice());
347  }
349  }
350 
351  // Return a sub slice of this one. Leaves this slice in an indeterminate but
352  // valid state.
353  Slice TakeSubSlice(size_t pos, size_t n) {
355  }
356 
357  // Return a sub slice of this one. Adds a reference to the underlying slice.
358  Slice RefSubSlice(size_t pos, size_t n) const {
359  return Slice(grpc_slice_sub(c_slice(), pos, pos + n));
360  }
361 
362  // Split this slice, returning a new slice containing (split:end] and
363  // leaving this slice with [begin:split).
364  Slice Split(size_t split) {
366  }
367 
369 
370  Slice Copy() const { return Slice(grpc_slice_copy(c_slice())); }
371 
373  const uint8_t* begin, const uint8_t* end) {
374  grpc_slice out;
375  out.refcount = r;
376  if (r != grpc_slice_refcount::NoopRefcount()) r->Ref();
377  out.data.refcounted.bytes = const_cast<uint8_t*>(begin);
378  out.data.refcounted.length = end - begin;
379  return Slice(out);
380  }
381 
383  return FromStaticString(str);
384  }
385 };
386 
387 } // namespace grpc_core
388 
389 #endif // GRPC_CORE_LIB_SLICE_SLICE_H
grpc_core::slice_detail::BaseSlice::BaseSlice
BaseSlice(const grpc_slice &slice)
Definition: src/core/lib/slice/slice.h:117
xds_interop_client.str
str
Definition: xds_interop_client.py:487
grpc_core::slice_detail::CopyConstructors::FromCopiedString
static Out FromCopiedString(std::string s)
Definition: src/core/lib/slice/slice.h:179
grpc_core::slice_detail::BaseSlice::TakeCSlice
grpc_slice TakeCSlice()
Definition: src/core/lib/slice/slice.h:82
grpc_core::Slice::Split
Slice Split(size_t split)
Definition: src/core/lib/slice/slice.h:364
grpc_core::Slice::Slice
Slice(Slice &&other) noexcept
Definition: src/core/lib/slice/slice.h:294
gen_build_yaml.out
dictionary out
Definition: src/benchmark/gen_build_yaml.py:24
grpc_core::Slice::Ref
Slice Ref() const
Definition: src/core/lib/slice/slice.h:368
log.h
pos
int pos
Definition: libuv/docs/code/tty-gravity/main.c:11
grpc_core::slice_detail::BaseSlice::SetCSlice
void SetCSlice(const grpc_slice &slice)
Definition: src/core/lib/slice/slice.h:121
grpc_slice::refcount
struct grpc_slice_refcount * refcount
Definition: include/grpc/impl/codegen/slice.h:66
grpc_slice_ref_internal
const grpc_slice & grpc_slice_ref_internal(const grpc_slice &slice)
Definition: slice_refcount.h:32
GPR_DEBUG_ASSERT
#define GPR_DEBUG_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:103
grpc_core::MutableSlice::begin
uint8_t * begin()
Definition: src/core/lib/slice/slice.h:274
slice.h
grpc_core::StaticSlice::operator=
StaticSlice & operator=(const StaticSlice &other)
Definition: src/core/lib/slice/slice.h:232
grpc_slice::grpc_slice_data::grpc_slice_refcounted::length
size_t length
Definition: include/grpc/impl/codegen/slice.h:69
grpc_core
Definition: call_metric_recorder.h:31
grpc_core::Slice
Definition: src/core/lib/slice/slice.h:282
grpc_core::MutableSlice::MutableSlice
MutableSlice(MutableSlice &&other) noexcept
Definition: src/core/lib/slice/slice.h:256
string.h
grpc_core::MutableSlice::operator[]
uint8_t & operator[](size_t i)
Definition: src/core/lib/slice/slice.h:279
grpc_core::slice_detail::StaticConstructors::FromStaticString
static Out FromStaticString(const char *s)
Definition: src/core/lib/slice/slice.h:201
grpc_core::slice_detail::BaseSlice::Hash
uint32_t Hash() const
Definition: src/core/lib/slice/slice.h:113
grpc_core::Slice::Slice
Slice(slice_detail::BaseSlice &&other)
Definition: src/core/lib/slice/slice.h:289
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
grpc_core::slice_detail::StaticConstructors
Definition: src/core/lib/slice/slice.h:200
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
grpc_core::slice_detail::BaseSlice::cend
const uint8_t * cend() const
Definition: src/core/lib/slice/slice.h:75
grpc_core::Slice::Slice
Slice()=default
grpc_core::slice_detail::BaseSlice::c_slice_ptr
grpc_slice * c_slice_ptr()
Definition: src/core/lib/slice/slice.h:125
grpc_slice_sub
GPRAPI grpc_slice grpc_slice_sub(grpc_slice s, size_t begin, size_t end)
Definition: slice/slice.cc:268
a
int a
Definition: abseil-cpp/absl/container/internal/hash_policy_traits_test.cc:88
grpc_core::MutableSlice::MutableSlice
MutableSlice()=default
grpc_core::slice_detail::BaseSlice::operator=
BaseSlice & operator=(const BaseSlice &)=delete
grpc_slice_sub_no_ref
GPRAPI grpc_slice grpc_slice_sub_no_ref(grpc_slice s, size_t begin, size_t end)
Definition: slice/slice.cc:264
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
grpc_core::slice_detail::BaseSlice::operator[]
uint8_t operator[](size_t i) const
Definition: src/core/lib/slice/slice.h:94
grpc_slice_malloc
GPRAPI grpc_slice grpc_slice_malloc(size_t length)
Definition: slice/slice.cc:227
slice_refcount_base.h
grpc_core::Slice::AsOwned
Slice AsOwned() const
Definition: src/core/lib/slice/slice.h:322
grpc_core::slice_detail::BaseSlice::cbegin
const uint8_t * cbegin() const
Definition: src/core/lib/slice/slice.h:74
grpc_core::slice_detail::operator!=
bool operator!=(const BaseSlice &a, const BaseSlice &b)
Definition: src/core/lib/slice/slice.h:135
grpc_core::MutableSlice::~MutableSlice
~MutableSlice()
Definition: src/core/lib/slice/slice.h:252
grpc_core::StaticSlice::StaticSlice
StaticSlice(const StaticSlice &other)
Definition: src/core/lib/slice/slice.h:230
grpc_slice_refcount::IsUnique
bool IsUnique() const
Definition: slice_refcount_base.h:53
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
grpc_core::MutableSlice::CreateUninitialized
static MutableSlice CreateUninitialized(size_t length)
Definition: src/core/lib/slice/slice.h:263
grpc_slice_refcount::NoopRefcount
static grpc_slice_refcount * NoopRefcount()
Definition: slice_refcount_base.h:29
refcount
size_t refcount
Definition: abseil-cpp/absl/strings/internal/cordz_info.cc:122
grpc_core::slice_detail::CopyConstructors::FromCopiedString
static Out FromCopiedString(const char *s)
Definition: src/core/lib/slice/slice.h:173
grpc_slice_is_equivalent
GPRAPI int grpc_slice_is_equivalent(grpc_slice a, grpc_slice b)
Definition: slice/slice.cc:433
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
grpc_core::slice_detail::BaseSlice::begin
const uint8_t * begin() const
Definition: src/core/lib/slice/slice.h:72
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
GPR_LTOA_MIN_BUFSIZE
#define GPR_LTOA_MIN_BUFSIZE
Definition: string.h:51
grpc_core::slice_detail::CopyConstructors::FromCopiedBuffer
static Out FromCopiedBuffer(const char *p, size_t len)
Definition: src/core/lib/slice/slice.h:182
slice
grpc_slice slice
Definition: src/core/lib/surface/server.cc:467
grpc_core::Slice::TakeSubSlice
Slice TakeSubSlice(size_t pos, size_t n)
Definition: src/core/lib/slice/slice.h:353
grpc_core::Slice::TakeOwned
Slice TakeOwned()
Definition: src/core/lib/slice/slice.h:310
grpc_core::slice_detail::EmptySlice
static constexpr grpc_slice EmptySlice()
Definition: src/core/lib/slice/slice.h:59
grpc_core::slice_detail::BaseSlice::c_slice
const grpc_slice & c_slice() const
Definition: src/core/lib/slice/slice.h:78
grpc_slice_refcount
Definition: slice_refcount_base.h:25
grpc_core::slice_detail::CopyConstructors::FromCopiedString
static Out FromCopiedString(absl::string_view s)
Definition: src/core/lib/slice/slice.h:176
grpc_core::Slice::RefSubSlice
Slice RefSubSlice(size_t pos, size_t n) const
Definition: src/core/lib/slice/slice.h:358
GRPC_SLICE_START_PTR
#define GRPC_SLICE_START_PTR(slice)
Definition: include/grpc/impl/codegen/slice.h:101
grpc_core::slice_detail::BaseSlice::data
const uint8_t * data() const
Definition: src/core/lib/slice/slice.h:99
std::swap
void swap(Json::Value &a, Json::Value &b)
Specialize std::swap() for Json::Value.
Definition: third_party/bloaty/third_party/protobuf/conformance/third_party/jsoncpp/json.h:1226
grpc_slice
Definition: include/grpc/impl/codegen/slice.h:65
grpc_core::slice_detail::BaseSlice::BaseSlice
BaseSlice()
Definition: src/core/lib/slice/slice.h:116
grpc_core::Slice::FromRefcountAndBytes
static Slice FromRefcountAndBytes(grpc_slice_refcount *r, const uint8_t *begin, const uint8_t *end)
Definition: src/core/lib/slice/slice.h:372
grpc_core::slice_detail::BaseSlice::as_string_view
absl::string_view as_string_view() const
Definition: src/core/lib/slice/slice.h:89
grpc_core::slice_detail::BaseSlice::size
size_t size() const
Definition: src/core/lib/slice/slice.h:102
buffer
char buffer[1024]
Definition: libuv/docs/code/idle-compute/main.c:8
slice_internal.h
b
uint64_t b
Definition: abseil-cpp/absl/container/internal/layout_test.cc:53
GRPC_SLICE_END_PTR
#define GRPC_SLICE_END_PTR(slice)
Definition: include/grpc/impl/codegen/slice.h:110
grpc_core::slice_detail::BaseSlice::~BaseSlice
~BaseSlice()=default
n
int n
Definition: abseil-cpp/absl/container/btree_test.cc:1080
grpc_core::StaticSlice::operator=
StaticSlice & operator=(StaticSlice &&other) noexcept
Definition: src/core/lib/slice/slice.h:238
GRPC_SLICE_LENGTH
#define GRPC_SLICE_LENGTH(slice)
Definition: include/grpc/impl/codegen/slice.h:104
grpc_core::slice_detail::CopyConstructors::FromInt64
static Out FromInt64(int64_t i)
Definition: src/core/lib/slice/slice.h:192
grpc_core::slice_detail::BaseSlice::slice_
grpc_slice slice_
Definition: src/core/lib/slice/slice.h:128
grpc_core::Slice::operator=
Slice & operator=(Slice &&other) noexcept
Definition: src/core/lib/slice/slice.h:295
grpc_core::slice_detail::BaseSlice::length
size_t length() const
Definition: src/core/lib/slice/slice.h:103
grpc_core::StaticSlice
Definition: src/core/lib/slice/slice.h:221
grpc_slice::grpc_slice_data::refcounted
struct grpc_slice::grpc_slice_data::grpc_slice_refcounted refcounted
grpc_slice_from_copied_buffer
GPRAPI grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t len)
Definition: slice/slice.cc:170
grpc_core::slice_detail::StaticConstructors::FromStaticBuffer
static Out FromStaticBuffer(const void *s, size_t len)
Definition: src/core/lib/slice/slice.h:209
grpc_core::Slice::Copy
Slice Copy() const
Definition: src/core/lib/slice/slice.h:370
grpc_core::slice_detail::CopyConstructors::FromCopiedBuffer
static Out FromCopiedBuffer(const Buffer &buffer)
Definition: src/core/lib/slice/slice.h:187
grpc_core::Slice::~Slice
~Slice()
Definition: src/core/lib/slice/slice.h:287
grpc_core::slice_detail::operator==
bool operator==(const BaseSlice &a, const BaseSlice &b)
Definition: src/core/lib/slice/slice.h:131
grpc_core::Slice::FromExternalString
static Slice FromExternalString(absl::string_view str)
Definition: src/core/lib/slice/slice.h:382
grpc_core::Slice::TakeMutable
MutableSlice TakeMutable()
Definition: src/core/lib/slice/slice.h:340
fix_build_deps.r
r
Definition: fix_build_deps.py:491
string_view
absl::string_view string_view
Definition: attr.cc:22
grpc_slice::data
union grpc_slice::grpc_slice_data data
grpc_core::slice_detail::BaseSlice::end
const uint8_t * end() const
Definition: src/core/lib/slice/slice.h:73
grpc_slice_hash_internal
uint32_t grpc_slice_hash_internal(const grpc_slice &s)
Definition: slice_internal.h:67
grpc_slice_from_cpp_string
grpc_slice grpc_slice_from_cpp_string(std::string str)
Definition: slice/slice.cc:202
slice_refcount.h
grpc_core::slice_detail::BaseSlice
Definition: src/core/lib/slice/slice.h:64
grpc_core::slice_detail::BaseSlice::Swap
void Swap(BaseSlice *other)
Definition: src/core/lib/slice/slice.h:120
grpc_core::slice_detail::StaticConstructors::FromStaticString
static Out FromStaticString(absl::string_view s)
Definition: src/core/lib/slice/slice.h:205
grpc_core::MutableSlice::data
uint8_t * data()
Definition: src/core/lib/slice/slice.h:276
grpc_core::slice_detail::BaseSlice::mutable_data
uint8_t * mutable_data()
Definition: src/core/lib/slice/slice.h:123
grpc_core::Slice::Slice
Slice(const grpc_slice &slice)
Definition: src/core/lib/slice/slice.h:288
grpc_core::MutableSlice::operator=
MutableSlice & operator=(MutableSlice &&other) noexcept
Definition: src/core/lib/slice/slice.h:258
grpc_slice::grpc_slice_data::grpc_slice_refcounted::bytes
uint8_t * bytes
Definition: include/grpc/impl/codegen/slice.h:70
grpc_core::slice_detail::CopyConstructors
Definition: src/core/lib/slice/slice.h:172
grpc_core::StaticSlice::StaticSlice
StaticSlice(const grpc_slice &slice)
Definition: src/core/lib/slice/slice.h:225
grpc_core::MutableSlice::MutableSlice
MutableSlice(const grpc_slice &slice)
Definition: src/core/lib/slice/slice.h:248
grpc_core::MutableSlice::TakeSubSlice
MutableSlice TakeSubSlice(size_t pos, size_t n)
Definition: src/core/lib/slice/slice.h:269
grpc_core::Slice::operator=
Slice & operator=(const Slice &)=delete
grpc_core::StaticSlice::StaticSlice
StaticSlice()=default
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
grpc_core::MutableSlice
Definition: src/core/lib/slice/slice.h:244
grpc_core::MutableSlice::operator=
MutableSlice & operator=(const MutableSlice &)=delete
split
static void split(const char *s, char ***ss, size_t *ns)
Definition: debug/trace.cc:111
grpc_core::StaticSlice::StaticSlice
StaticSlice(StaticSlice &&other) noexcept
Definition: src/core/lib/slice/slice.h:236
grpc_core::slice_detail::BaseSlice::is_equivalent
bool is_equivalent(const BaseSlice &other) const
Definition: src/core/lib/slice/slice.h:109
grpc_slice_eq
GPRAPI int grpc_slice_eq(grpc_slice a, grpc_slice b)
Definition: slice/slice.cc:387
grpc_core::MutableSlice::end
uint8_t * end()
Definition: src/core/lib/slice/slice.h:275
grpc_core::slice_detail::BaseSlice::empty
bool empty() const
Definition: src/core/lib/slice/slice.h:104
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
grpc_slice_unref_internal
void grpc_slice_unref_internal(const grpc_slice &slice)
Definition: slice_refcount.h:39
grpc_slice_split_tail
GPRAPI grpc_slice grpc_slice_split_tail(grpc_slice *s, size_t split)
Definition: slice/slice.cc:343
gpr_ltoa
int gpr_ltoa(long value, char *output)
Definition: string.cc:176
grpc_slice_copy
GPRAPI grpc_slice grpc_slice_copy(grpc_slice s)
Definition: slice/slice.cc:46
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:13