Go to the documentation of this file.
15 #ifndef GRPC_EVENT_ENGINE_SLICE_H
16 #define GRPC_EVENT_ENGINE_SLICE_H
24 #include "absl/strings/string_view.h"
36 namespace experimental {
42 namespace slice_detail {
45 static constexpr
grpc_slice EmptySlice() {
return {
nullptr, {}}; }
70 slice_ = EmptySlice();
76 return absl::string_view(
reinterpret_cast<const char*
>(
data()),
size());
99 uint32_t
Hash()
const;
157 template <
typename Out>
176 template <
typename Buffer>
213 uint8_t*
begin() {
return mutable_data(); }
214 uint8_t*
end() {
return mutable_data() + size(); }
215 uint8_t*
data() {
return mutable_data(); }
229 : slice_detail::BaseSlice(other.TakeCSlice()) {}
253 Slice AsOwned()
const;
286 static Slice FromRefcountAndBytes(grpc_slice_refcount* r,
287 const uint8_t* begin,
const uint8_t* end);
310 #endif // GRPC_EVENT_ENGINE_SLICE_H
BaseSlice()
Definition: slice.h:102
static Out FromCopiedBuffer(const char *p, size_t len)
Definition: slice.h:167
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,...
bool operator==(const BaseSlice &a, const BaseSlice &b)
Definition: slice.h:117
#define GRPC_SLICE_START_PTR(slice)
Definition: slice_type.h:99
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,...
#define GRPC_SLICE_END_PTR(slice)
Definition: slice_type.h:108
GPRAPI grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t len)
Create a slice by copying a buffer.
uint8_t & operator[](size_t i)
Definition: slice.h:218
MutableSlice & operator=(MutableSlice &&other) noexcept
Definition: slice.h:197
BaseSlice(const grpc_slice &slice)
Definition: slice.h:103
Slice RefSubSlice(size_t pos, size_t n) const
Definition: slice.h:272
Slice(slice_detail::BaseSlice &&other)
Definition: slice.h:228
const uint8_t * cbegin() const
Definition: slice.h:60
Slice & operator=(Slice &&other) noexcept
Definition: slice.h:234
GPRAPI int grpc_slice_eq(grpc_slice a, grpc_slice b)
static Out FromCopiedBuffer(const Buffer &buffer)
Definition: slice.h:177
const uint8_t * begin() const
Definition: slice.h:58
Definition: slice_cast.h:30
const grpc_slice & c_slice() const
Definition: slice.h:64
uint8_t operator[](size_t i) const
Definition: slice.h:80
bool operator!=(const BaseSlice &a, const BaseSlice &b)
Definition: slice.h:121
BaseSlice & operator=(const BaseSlice &)=delete
uint8_t * end()
Definition: slice.h:214
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.
Slice(Slice &&other) noexcept
Definition: slice.h:233
static Out FromCopiedBuffer(const uint8_t *p, size_t len)
Definition: slice.h:171
Slice TakeSubSlice(size_t pos, size_t n)
Definition: slice.h:267
static Out FromCopiedString(const char *s)
Definition: slice.h:159
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:202
uint8_t * begin()
Definition: slice.h:213
Slice Copy() const
Definition: slice.h:284
Slice Split(size_t split)
Definition: slice.h:278
void Swap(BaseSlice *other)
Definition: slice.h:106
size_t length() const
Definition: slice.h:89
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....
bool empty() const
Definition: slice.h:90
const uint8_t * data() const
Definition: slice.h:85
Definition: endpoint_config.h:24
bool is_equivalent(const BaseSlice &other) const
Definition: slice.h:95
const uint8_t * cend() const
Definition: slice.h:61
#define GRPC_SLICE_LENGTH(slice)
Definition: slice_type.h:102
uint8_t * data()
Definition: slice.h:215
MutableSlice TakeSubSlice(size_t pos, size_t n)
Definition: slice.h:208
GPRAPI grpc_slice grpc_slice_malloc(size_t length)
Equivalent to grpc_slice_new(malloc(len), len, free), but saves one malloc() call.
static Out FromCopiedString(absl::string_view s)
Definition: slice.h:162
Slice(const grpc_slice &slice)
Definition: slice.h:227
const uint8_t * end() const
Definition: slice.h:59
MutableSlice(MutableSlice &&other) noexcept
Definition: slice.h:195
uint8_t * mutable_data()
Definition: slice.h:109
grpc_slice TakeCSlice()
Definition: slice.h:68
absl::string_view as_string_view() const
Definition: slice.h:75
GPRAPI grpc_slice grpc_slice_copy(grpc_slice s)
Copy slice - create a new slice that contains the same data as s.
grpc_slice * c_slice_ptr()
Definition: slice.h:111
void SetCSlice(const grpc_slice &slice)
Definition: slice.h:107
size_t size() const
Definition: slice.h:88