Go to the documentation of this file.
15 #ifndef GRPC_EVENT_ENGINE_SLICE_H
16 #define GRPC_EVENT_ENGINE_SLICE_H
26 #include "absl/strings/string_view.h"
37 namespace experimental {
43 namespace slice_detail {
46 static constexpr
grpc_slice EmptySlice() {
return {
nullptr, {}}; }
71 slice_ = EmptySlice();
77 return absl::string_view(
reinterpret_cast<const char*
>(
data()),
size());
100 uint32_t
Hash()
const;
158 template <
typename Out>
177 template <
typename Buffer>
214 uint8_t*
begin() {
return mutable_data(); }
215 uint8_t*
end() {
return mutable_data() + size(); }
216 uint8_t*
data() {
return mutable_data(); }
230 : slice_detail::BaseSlice(other.TakeCSlice()) {}
254 Slice AsOwned()
const;
287 static Slice FromRefcountAndBytes(grpc_slice_refcount* r,
288 const uint8_t* begin,
const uint8_t* end);
311 #endif // GRPC_EVENT_ENGINE_SLICE_H
GPRAPI int grpc_slice_eq(grpc_slice a, grpc_slice b)
BaseSlice()
Definition: slice.h:103
static Out FromCopiedBuffer(const char *p, size_t len)
Definition: slice.h:168
bool operator==(const BaseSlice &a, const BaseSlice &b)
Definition: slice.h:118
#define GRPC_SLICE_START_PTR(slice)
Definition: slice_type.h:99
#define GRPC_SLICE_END_PTR(slice)
Definition: slice_type.h:108
uint8_t & operator[](size_t i)
Definition: slice.h:219
MutableSlice & operator=(MutableSlice &&other) noexcept
Definition: slice.h:198
BaseSlice(const grpc_slice &slice)
Definition: slice.h:104
GPRAPI grpc_slice grpc_slice_malloc(size_t length)
Equivalent to grpc_slice_new(malloc(len), len, free), but saves one malloc() call.
Slice RefSubSlice(size_t pos, size_t n) const
Definition: slice.h:273
Slice(slice_detail::BaseSlice &&other)
Definition: slice.h:229
const uint8_t * cbegin() const
Definition: slice.h:61
GPRAPI grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t len)
Create a slice by copying a buffer.
Slice & operator=(Slice &&other) noexcept
Definition: slice.h:235
static Out FromCopiedBuffer(const Buffer &buffer)
Definition: slice.h:178
const uint8_t * begin() const
Definition: slice.h:59
Definition: slice_cast.h:30
const grpc_slice & c_slice() const
Definition: slice.h:65
uint8_t operator[](size_t i) const
Definition: slice.h:81
bool operator!=(const BaseSlice &a, const BaseSlice &b)
Definition: slice.h:122
BaseSlice & operator=(const BaseSlice &)=delete
uint8_t * end()
Definition: slice.h:215
Slice(Slice &&other) noexcept
Definition: slice.h:234
static Out FromCopiedBuffer(const uint8_t *p, size_t len)
Definition: slice.h:172
Slice TakeSubSlice(size_t pos, size_t n)
Definition: slice.h:268
static Out FromCopiedString(const char *s)
Definition: slice.h:160
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice_type.h:63
static MutableSlice CreateUninitialized(size_t length)
Definition: slice.h:203
uint8_t * begin()
Definition: slice.h:214
Slice Copy() const
Definition: slice.h:285
Slice Split(size_t split)
Definition: slice.h:279
GPRAPI grpc_slice grpc_slice_sub(grpc_slice s, size_t begin, size_t end)
Return a result slice derived from s, which shares a ref count with s, where result....
void Swap(BaseSlice *other)
Definition: slice.h:107
size_t length() const
Definition: slice.h:90
bool empty() const
Definition: slice.h:91
GPRAPI grpc_slice grpc_slice_split_tail(grpc_slice *s, size_t split)
Splits s into two: modifies s to be s[0:split], and returns a new slice, sharing a refcount with s,...
const uint8_t * data() const
Definition: slice.h:86
Definition: endpoint_config.h:24
bool is_equivalent(const BaseSlice &other) const
Definition: slice.h:96
const uint8_t * cend() const
Definition: slice.h:62
GPRAPI grpc_slice grpc_slice_sub_no_ref(grpc_slice s, size_t begin, size_t end)
The same as grpc_slice_sub, but without altering the ref count.
#define GRPC_SLICE_LENGTH(slice)
Definition: slice_type.h:102
uint8_t * data()
Definition: slice.h:216
GPRAPI int grpc_slice_is_equivalent(grpc_slice a, grpc_slice b)
Do two slices point at the same memory, with the same length If a or b is inlined,...
MutableSlice TakeSubSlice(size_t pos, size_t n)
Definition: slice.h:209
static Out FromCopiedString(absl::string_view s)
Definition: slice.h:163
GPRAPI grpc_slice grpc_slice_copy(grpc_slice s)
Copy slice - create a new slice that contains the same data as s.
Slice(const grpc_slice &slice)
Definition: slice.h:228
const uint8_t * end() const
Definition: slice.h:60
MutableSlice(MutableSlice &&other) noexcept
Definition: slice.h:196
uint8_t * mutable_data()
Definition: slice.h:110
grpc_slice TakeCSlice()
Definition: slice.h:69
absl::string_view as_string_view() const
Definition: slice.h:76
grpc_slice * c_slice_ptr()
Definition: slice.h:112
void SetCSlice(const grpc_slice &slice)
Definition: slice.h:108
size_t size() const
Definition: slice.h:89