Go to the documentation of this file.
15 #ifndef GRPC_EVENT_ENGINE_SLICE_H
16 #define GRPC_EVENT_ENGINE_SLICE_H
27 #include "absl/strings/string_view.h"
34 namespace experimental {
40 namespace slice_detail {
43 static constexpr
grpc_slice EmptySlice() {
return {
nullptr, {}}; }
68 slice_ = EmptySlice();
74 return absl::string_view(
reinterpret_cast<const char*
>(
data()),
size());
97 uint32_t
Hash()
const;
155 template <
typename Out>
174 template <
typename Buffer>
211 uint8_t*
begin() {
return mutable_data(); }
212 uint8_t*
end() {
return mutable_data() + size(); }
213 uint8_t*
data() {
return mutable_data(); }
227 : slice_detail::BaseSlice(other.TakeCSlice()) {}
251 Slice AsOwned()
const;
284 static Slice FromRefcountAndBytes(grpc_slice_refcount* r,
285 const uint8_t* begin,
const uint8_t* end);
308 #endif // GRPC_EVENT_ENGINE_SLICE_H
BaseSlice()
Definition: slice.h:100
static Out FromCopiedBuffer(const char *p, size_t len)
Definition: slice.h:165
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:115
#define GRPC_SLICE_START_PTR(slice)
Definition: slice_type.h:98
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:107
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:216
MutableSlice & operator=(MutableSlice &&other) noexcept
Definition: slice.h:195
BaseSlice(const grpc_slice &slice)
Definition: slice.h:101
Slice RefSubSlice(size_t pos, size_t n) const
Definition: slice.h:270
Slice(slice_detail::BaseSlice &&other)
Definition: slice.h:226
const uint8_t * cbegin() const
Definition: slice.h:58
Slice & operator=(Slice &&other) noexcept
Definition: slice.h:232
GPRAPI int grpc_slice_eq(grpc_slice a, grpc_slice b)
static Out FromCopiedBuffer(const Buffer &buffer)
Definition: slice.h:175
const uint8_t * begin() const
Definition: slice.h:56
Definition: slice_cast.h:30
const grpc_slice & c_slice() const
Definition: slice.h:62
uint8_t operator[](size_t i) const
Definition: slice.h:78
bool operator!=(const BaseSlice &a, const BaseSlice &b)
Definition: slice.h:119
BaseSlice & operator=(const BaseSlice &)=delete
uint8_t * end()
Definition: slice.h:212
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:231
static Out FromCopiedBuffer(const uint8_t *p, size_t len)
Definition: slice.h:169
Slice TakeSubSlice(size_t pos, size_t n)
Definition: slice.h:265
static Out FromCopiedString(const char *s)
Definition: slice.h:157
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice_type.h:62
static MutableSlice CreateUninitialized(size_t length)
Definition: slice.h:200
uint8_t * begin()
Definition: slice.h:211
Slice Copy() const
Definition: slice.h:282
Slice Split(size_t split)
Definition: slice.h:276
void Swap(BaseSlice *other)
Definition: slice.h:104
size_t length() const
Definition: slice.h:87
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:88
const uint8_t * data() const
Definition: slice.h:83
Definition: endpoint_config.h:24
bool is_equivalent(const BaseSlice &other) const
Definition: slice.h:93
const uint8_t * cend() const
Definition: slice.h:59
#define GRPC_SLICE_LENGTH(slice)
Definition: slice_type.h:101
uint8_t * data()
Definition: slice.h:213
MutableSlice TakeSubSlice(size_t pos, size_t n)
Definition: slice.h:206
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:160
Slice(const grpc_slice &slice)
Definition: slice.h:225
const uint8_t * end() const
Definition: slice.h:57
MutableSlice(MutableSlice &&other) noexcept
Definition: slice.h:193
uint8_t * mutable_data()
Definition: slice.h:107
grpc_slice TakeCSlice()
Definition: slice.h:66
absl::string_view as_string_view() const
Definition: slice.h:73
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:109
void SetCSlice(const grpc_slice &slice)
Definition: slice.h:105
size_t size() const
Definition: slice.h:86