GRPC Core  43.0.0
Public Member Functions | Static Public Member Functions
grpc_event_engine::experimental::SliceBuffer Class Reference

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...
 
SliceBufferoperator= (const SliceBuffer &)=delete
 
SliceBufferoperator= (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 Sliceoperator[] (size_t index) const
 Array access into the SliceBuffer. More...
 
SliceMutableSliceAt (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_bufferc_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)
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ SliceBuffer() [1/3]

grpc_event_engine::experimental::SliceBuffer::SliceBuffer ( )
inline

◆ SliceBuffer() [2/3]

grpc_event_engine::experimental::SliceBuffer::SliceBuffer ( const SliceBuffer other)
delete

◆ SliceBuffer() [3/3]

grpc_event_engine::experimental::SliceBuffer::SliceBuffer ( SliceBuffer &&  other)
inlinenoexcept

◆ ~SliceBuffer()

grpc_event_engine::experimental::SliceBuffer::~SliceBuffer ( )
inline

Upon destruction, the underlying raw slice buffer is cleaned out and all slices are unreffed.

Member Function Documentation

◆ Append()

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.

◆ AppendIndexed()

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.

◆ c_slice_buffer()

grpc_slice_buffer* grpc_event_engine::experimental::SliceBuffer::c_slice_buffer ( )
inline

Return a pointer to the back raw grpc_slice_buffer.

◆ Clear()

void grpc_event_engine::experimental::SliceBuffer::Clear ( )
inline

Removes and unrefs all slices in the SliceBuffer.

◆ Count()

size_t grpc_event_engine::experimental::SliceBuffer::Count ( )
inline

Returns the number of slices held by the SliceBuffer.

◆ Length()

size_t grpc_event_engine::experimental::SliceBuffer::Length ( ) const
inline

The total number of bytes held by the SliceBuffer.

◆ MoveFirstNBytesIntoBuffer()

void grpc_event_engine::experimental::SliceBuffer::MoveFirstNBytesIntoBuffer ( size_t  n,
void *  dst 
)
inline

Move the first n bytes of the SliceBuffer into a memory pointed to by dst.

◆ MoveFirstNBytesIntoSliceBuffer()

void grpc_event_engine::experimental::SliceBuffer::MoveFirstNBytesIntoSliceBuffer ( size_t  n,
SliceBuffer other 
)
inline

Move the first n bytes of the SliceBuffer into the other SliceBuffer.

◆ MoveLastNBytesIntoSliceBuffer()

void grpc_event_engine::experimental::SliceBuffer::MoveLastNBytesIntoSliceBuffer ( size_t  n,
SliceBuffer other 
)
inline

Removes/deletes the last n bytes in the SliceBuffer and add it to the other SliceBuffer.

◆ MutableSliceAt()

Slice& grpc_event_engine::experimental::SliceBuffer::MutableSliceAt ( size_t  index) const
inline

Return mutable reference to the slice at the specified index.

◆ operator=() [1/2]

SliceBuffer& grpc_event_engine::experimental::SliceBuffer::operator= ( const SliceBuffer )
delete

◆ operator=() [2/2]

SliceBuffer& grpc_event_engine::experimental::SliceBuffer::operator= ( SliceBuffer &&  other)
inlinenoexcept

◆ operator[]()

const Slice& grpc_event_engine::experimental::SliceBuffer::operator[] ( size_t  index) const
inline

Array access into the SliceBuffer.

It returns a non mutable reference to the slice at the specified index

◆ Prepend()

void grpc_event_engine::experimental::SliceBuffer::Prepend ( Slice  slice)

Prepends the slice to the the front of the SliceBuffer.

◆ RefSlice()

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.

◆ RemoveLastNBytes()

void grpc_event_engine::experimental::SliceBuffer::RemoveLastNBytes ( size_t  n)
inline

Removes/deletes the last n bytes in the SliceBuffer.

◆ Swap()

void grpc_event_engine::experimental::SliceBuffer::Swap ( SliceBuffer other)
inline

Swap the contents of this SliceBuffer with the contents of another.

◆ TakeCSliceBuffer()

static SliceBuffer grpc_event_engine::experimental::SliceBuffer::TakeCSliceBuffer ( grpc_slice_buffer slice_buffer)
inlinestatic

◆ TakeFirst()

Slice grpc_event_engine::experimental::SliceBuffer::TakeFirst ( )

Removes the first slice in the SliceBuffer and returns it.


The documentation for this class was generated from the following file: