litert::OwningBufferRef

#include <litert_buffer_ref.h>

A writable and owning buffer reference.

Summary

This class can allocate new buffers internally and take ownership of existing ones. It does not support resizing.

Details
Template Parameters
ByteT
The byte type of the buffer.
Allocator
The allocator to use for memory management.

Inheritance

Inherits from: litert::MutableBufferRef< ByteT >

Constructors and Destructors

OwningBufferRef()
Constructs a null buffer.
OwningBufferRef(size_t size)
Initializes a new buffer reference and allocates it internally.
OwningBufferRef(ByteT *data, size_t size, size_t offset)
Takes ownership of a given buffer.
OwningBufferRef(void *data, size_t size, size_t offset)
OwningBufferRef(absl::Span< ByteT > data)
OwningBufferRef(const ByteT *data, size_t size)
Copies the given buffer.
OwningBufferRef(absl::Span< const ByteT > data)
OwningBufferRef(absl::string_view data)
Copies data from a given string.
OwningBufferRef(const char *data)
Copies data from a given C-style string.
OwningBufferRef(OwningBufferRef && other)
OwningBufferRef(const OwningBufferRef & other)
~OwningBufferRef()

Public types

TupleT using
std::tuple< ByteT *const, const size_t, const size_t >
WeakTupleT using
std::tuple< ByteT *&, size_t &, size_t & >

Public functions

Assign(const ByteT *buf, size_t end_offset, size_t start_offset)
void
Resets any existing data and copies in the given buffer.
Drop()
void
Drops the reference to any owned memory.
GetWeak()
WeakTupleT
Returns weak references to buffer data.
Release()
TupleT
Returns the buffer details and drops references to them.
Reset()
void
Frees any owned memory.
operator=(OwningBufferRef && other)
operator=(const OwningBufferRef & other)

Protected functions

TypeName() const override
virtual absl::string_view
Returns the debug name of the class.

Public types

TupleT

std::tuple< ByteT *const, const size_t, const size_t > TupleT

WeakTupleT

std::tuple< ByteT *&, size_t &, size_t & > WeakTupleT

Public functions

Assign

void Assign(
  const ByteT *buf,
  size_t end_offset,
  size_t start_offset
)

Resets any existing data and copies in the given buffer.

Drop

void Drop()

Drops the reference to any owned memory.

GetWeak

WeakTupleT GetWeak()

Returns weak references to buffer data.

Takes ownership of any data that is swapped in.

OwningBufferRef

 OwningBufferRef()

Constructs a null buffer.

OwningBufferRef

 OwningBufferRef(
  size_t size
)

Initializes a new buffer reference and allocates it internally.

Details
Parameters
size
The size of the buffer to allocate.

OwningBufferRef

 OwningBufferRef(
  ByteT *data,
  size_t size,
  size_t offset
)

Takes ownership of a given buffer.

OwningBufferRef

 OwningBufferRef(
  void *data,
  size_t size,
  size_t offset
)

OwningBufferRef

 OwningBufferRef(
  absl::Span< ByteT > data
)

OwningBufferRef

 OwningBufferRef(
  const ByteT *data,
  size_t size
)

Copies the given buffer.

OwningBufferRef

 OwningBufferRef(
  absl::Span< const ByteT > data
)

OwningBufferRef

 OwningBufferRef(
  absl::string_view data
)

Copies data from a given string.

OwningBufferRef

 OwningBufferRef(
  const char *data
)

Copies data from a given C-style string.

OwningBufferRef

 OwningBufferRef(
  OwningBufferRef && other
)

OwningBufferRef

 OwningBufferRef(
  const OwningBufferRef & other
)

Release

TupleT Release()

Returns the buffer details and drops references to them.

Reset

void Reset()

Frees any owned memory.

operator=

OwningBufferRef & operator=(
  OwningBufferRef && other
)

operator=

OwningBufferRef & operator=(
  const OwningBufferRef & other
)

~OwningBufferRef

 ~OwningBufferRef() override

Protected functions

TypeName

virtual absl::string_view TypeName() const override

Returns the debug name of the class.