GRPC C++
1.66.0
|
A Wrapper around grpc_slice_buffer pointer. More...
#include <slice_buffer.h>
Public Member Functions | |
SliceBuffer () | |
SliceBuffer (const SliceBuffer &other)=delete | |
SliceBuffer (SliceBuffer &&other) noexcept | |
~SliceBuffer () | |
Upon destruction, the underlying raw slice buffer is cleaned out and all slices are unreffed. More... | |
SliceBuffer & | operator= (const SliceBuffer &)=delete |
SliceBuffer & | operator= (SliceBuffer &&other) noexcept |
void | Swap (SliceBuffer &other) |
Swap the contents of this SliceBuffer with the contents of another. More... | |
void | Append (Slice slice) |
Appends a new slice into the SliceBuffer and makes an attempt to merge this slice with the last slice in the SliceBuffer. More... | |
size_t | AppendIndexed (Slice slice) |
Adds a new slice into the SliceBuffer at the next available index. More... | |
size_t | Count () |
Returns the number of slices held by the SliceBuffer. More... | |
void | RemoveLastNBytes (size_t n) |
Removes/deletes the last n bytes in the SliceBuffer. More... | |
void | MoveFirstNBytesIntoBuffer (size_t n, void *dst) |
Move the first n bytes of the SliceBuffer into a memory pointed to by dst. More... | |
void | MoveLastNBytesIntoSliceBuffer (size_t n, SliceBuffer &other) |
Removes/deletes the last n bytes in the SliceBuffer and add it to the other SliceBuffer. More... | |
void | MoveFirstNBytesIntoSliceBuffer (size_t n, SliceBuffer &other) |
Move the first n bytes of the SliceBuffer into the other SliceBuffer. More... | |
void | Clear () |
Removes and unrefs all slices in the SliceBuffer. More... | |
Slice | TakeFirst () |
Removes the first slice in the SliceBuffer and returns it. More... | |
void | Prepend (Slice slice) |
Prepends the slice to the the front of the SliceBuffer. More... | |
Slice | RefSlice (size_t index) |
Increased the ref-count of slice at the specified index and returns the associated slice. More... | |
const Slice & | operator[] (size_t index) const |
Array access into the SliceBuffer. More... | |
Slice & | MutableSliceAt (size_t index) const |
Return mutable reference to the slice at the specified index. More... | |
size_t | Length () const |
The total number of bytes held by the SliceBuffer. More... | |
grpc_slice_buffer * | c_slice_buffer () |
Return a pointer to the back raw grpc_slice_buffer. More... | |
Static Public Member Functions | |
static SliceBuffer | TakeCSliceBuffer (grpc_slice_buffer &slice_buffer) |
A Wrapper around grpc_slice_buffer pointer.
A slice buffer holds the memory for a collection of slices. The SliceBuffer object itself is meant to only hide the C-style API, and won't hold the data itself. In terms of lifespan, the grpc_slice_buffer ought to be kept somewhere inside the caller's objects, like a transport or an endpoint.
This lifespan rule is likely to change in the future, as we may collapse the grpc_slice_buffer structure straight into this class.
The SliceBuffer API is basically a replica of the grpc_slice_buffer's, and its documentation will move here once we remove the C structure, which should happen before the EventEngine's API is no longer an experimental API.
|
inline |
|
delete |
|
inlinenoexcept |
|
inline |
Upon destruction, the underlying raw slice buffer is cleaned out and all slices are unreffed.
void grpc_event_engine::experimental::SliceBuffer::Append | ( | Slice | slice | ) |
Appends a new slice into the SliceBuffer and makes an attempt to merge this slice with the last slice in the SliceBuffer.
size_t grpc_event_engine::experimental::SliceBuffer::AppendIndexed | ( | Slice | slice | ) |
Adds a new slice into the SliceBuffer at the next available index.
Returns the index at which the new slice is added.
|
inline |
Return a pointer to the back raw grpc_slice_buffer.
|
inline |
Removes and unrefs all slices in the SliceBuffer.
|
inline |
Returns the number of slices held by the SliceBuffer.
|
inline |
The total number of bytes held by the SliceBuffer.
|
inline |
Move the first n bytes of the SliceBuffer into a memory pointed to by dst.
|
inline |
Move the first n bytes of the SliceBuffer into the other SliceBuffer.
|
inline |
Removes/deletes the last n bytes in the SliceBuffer and add it to the other SliceBuffer.
|
inline |
Return mutable reference to the slice at the specified index.
|
delete |
|
inlinenoexcept |
|
inline |
Array access into the SliceBuffer.
It returns a non mutable reference to the slice at the specified index
void grpc_event_engine::experimental::SliceBuffer::Prepend | ( | Slice | slice | ) |
Prepends the slice to the the front of the SliceBuffer.
Slice grpc_event_engine::experimental::SliceBuffer::RefSlice | ( | size_t | index | ) |
Increased the ref-count of slice at the specified index and returns the associated slice.
|
inline |
Removes/deletes the last n bytes in the SliceBuffer.
|
inline |
Swap the contents of this SliceBuffer with the contents of another.
|
inlinestatic |
Slice grpc_event_engine::experimental::SliceBuffer::TakeFirst | ( | ) |
Removes the first slice in the SliceBuffer and returns it.