19 #ifndef GRPCPP_IMPL_CODEGEN_SLICE_H
20 #define GRPCPP_IMPL_CODEGEN_SLICE_H
56 Slice(
const void* buf,
size_t len)
58 reinterpret_cast<const char*>(buf), len)) {}
64 str.c_str(), str.length())) {}
71 reinterpret_cast<const char*>(buf), len)) {}
84 std::swap(slice_, other.slice_);
93 Slice(
void* buf,
size_t len,
void (*destroy)(
void*),
void* user_data)
95 buf, len, destroy, user_data)) {}
98 Slice(
void* buf,
size_t len,
void (*destroy)(
void*))
99 :
Slice(buf, len, destroy, buf) {}
102 Slice(
void* buf,
size_t len,
void (*destroy)(
void*,
size_t))
A sequence of bytes.
Definition: byte_buffer.h:60
virtual grpc_slice grpc_empty_slice()=0
virtual void grpc_slice_unref(grpc_slice slice)=0
virtual grpc_slice grpc_slice_sub(grpc_slice s, size_t begin, size_t end)=0
virtual grpc_slice grpc_slice_from_copied_buffer(const void *buffer, size_t length)=0
virtual grpc_slice grpc_slice_ref(grpc_slice slice)=0
virtual grpc_slice grpc_slice_from_static_buffer(const void *buffer, size_t length)=0
A wrapper around grpc_slice.
Definition: slice.h:35
Slice(const Slice &other)
Copy constructor, adds a reference.
Definition: slice.h:74
Slice(const std::string &str)
Construct a slice from a copied string.
Definition: slice.h:62
StealRef
Definition: slice.h:47
@ STEAL_REF
Definition: slice.h:47
~Slice()
Destructor - drops one reference.
Definition: slice.h:40
Slice(void *buf, size_t len, void(*destroy)(void *), void *user_data)
Create a slice pointing at some data.
Definition: slice.h:93
Slice sub(size_t begin, size_t end) const
Returns a substring of the slice as another slice.
Definition: slice.h:116
Slice(const void *buf, size_t len, StaticSlice)
Construct a slice from a static buffer.
Definition: slice.h:69
Slice(grpc_slice slice, AddRef)
Construct a slice from slice, adding a reference.
Definition: slice.h:44
StaticSlice
Definition: slice.h:66
@ STATIC_SLICE
Definition: slice.h:66
const uint8_t * begin() const
Raw pointer to the beginning (first element) of the slice.
Definition: slice.h:110
Slice()
Construct an empty slice.
Definition: slice.h:38
Slice(void *buf, size_t len, void(*destroy)(void *, size_t))
Similar to the above but has a destroy that also takes slice length.
Definition: slice.h:102
grpc_slice c_slice() const
Raw C slice. Caller needs to call grpc_slice_unref when done.
Definition: slice.h:122
Slice(void *buf, size_t len, void(*destroy)(void *))
Specialization of above for common case where buf == user_data.
Definition: slice.h:98
AddRef
Definition: slice.h:42
@ ADD_REF
Definition: slice.h:42
Slice & operator=(Slice other)
Assignment, reference count is unchanged.
Definition: slice.h:83
Slice(size_t len)
Allocate a slice of specified size.
Definition: slice.h:52
Slice(const void *buf, size_t len)
Construct a slice from a copied buffer.
Definition: slice.h:56
size_t size() const
Byte size.
Definition: slice.h:107
const uint8_t * end() const
Raw pointer to the end (one byte past the last element) of the slice.
Definition: slice.h:113
Slice(Slice &&other) noexcept
Move constructor, steals a reference.
Definition: slice.h:78
Slice(grpc_slice slice, StealRef)
Construct a slice from slice, stealing a reference.
Definition: slice.h:49
This class is a non owning reference to a string.
Definition: string_ref.h:41
#define GRPC_SLICE_START_PTR(slice)
Definition: slice.h:96
#define GRPC_SLICE_END_PTR(slice)
Definition: slice.h:105
#define GRPC_SLICE_LENGTH(slice)
Definition: slice.h:99
GPRAPI grpc_slice grpc_slice_from_static_buffer(const void *source, size_t len)
Create a slice pointing to constant memory.
GPRAPI grpc_slice grpc_slice_malloc(size_t length)
Equivalent to grpc_slice_new(malloc(len), len, free), but saves one malloc() call.
GPRAPI grpc_slice grpc_slice_new_with_user_data(void *p, size_t len, void(*destroy)(void *), void *user_data)
Equivalent to grpc_slice_new, but with a separate pointer that is passed to the destroy function.
GPRAPI grpc_slice grpc_slice_new_with_len(void *p, size_t len, void(*destroy)(void *, size_t))
Equivalent to grpc_slice_new, but with a two argument destroy function that also takes the slice leng...
GPRAPI grpc_slice grpc_empty_slice(void)
GPRAPI grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t len)
Create a slice by copying a buffer.
GPRAPI grpc_slice grpc_slice_ref(grpc_slice s)
Increment the refcount of s.
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
grpc_slice SliceFromCopiedString(const std::string &str)
Definition: slice.h:148
grpc_slice SliceReferencingString(const std::string &str)
Definition: slice.h:143
grpc::string_ref StringRefFromSlice(const grpc_slice *slice)
Definition: slice.h:132
std::string StringFromCopiedSlice(grpc_slice slice)
Definition: slice.h:138
CoreCodegenInterface * g_core_codegen_interface
Definition: completion_queue.h:96
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice.h:60