litert:: BufferRef

#include <litert_buffer_ref.h>

An immutable and non-owning view of a buffer.

Summary

Details
Template Parameters
ByteT
The byte type of the buffer.

Inheritance

Direct Known Subclasses: litert::MutableBufferRef< ByteT >

Constructors and Destructors

BufferRef ()
Constructs a null buffer.
BufferRef (const ByteT *data, size_t end_offset, size_t start_offset)
Constructs from an already allocated buffer.
BufferRef (const void *data, size_t end_offset, size_t start_offset)
BufferRef (absl::Span< const ByteT > data)
BufferRef (const BufferRef & other)

Public types

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

Protected attributes

data_ = nullptr
ByteT *
The original pointer to the memory.
size_t
The end offset of the actual data, relative to data_ .
size_t
The start offset of the actual data, relative to data_ .

Public functions

Data () const
const ByteT *
Returns a pointer to the start of the actual data.
Dump (std::ostream & out) const
void
Prints information about this buffer.
Get () const
TupleT
Returns the buffer details as a tuple.
Size () const
size_t
Returns the size of the actual data.
Span () const
absl::Span< const ByteT >
Returns a const span of the actual data.
StrData () const
const char *
Returns a pointer to the start of the actual data as a signed char.
StrView () const
absl::string_view
Returns a string view of the actual data.
ToVec () const
std::vector< ByteT >
Copies the buffer data to a vector.
WriteStr (std::ostream & out) const
void
Writes the string data to a stream.
operator= (const BufferRef & other)=default

Protected functions

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

Public types

TupleT

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

Protected attributes

data_

ByteT * data_ = nullptr

The original pointer to the memory.

end_offset_

size_t end_offset_

The end offset of the actual data, relative to data_ .

start_offset_

size_t start_offset_

The start offset of the actual data, relative to data_ .

Public functions

BufferRef

BufferRef()

Constructs a null buffer.

BufferRef

  
 BufferRef 
 ( 
  
 const 
  
 ByteT 
  
 * 
 data 
 , 
  
 size_t 
  
 end_offset 
 , 
  
 size_t 
  
 start_offset 
 ) 

Constructs from an already allocated buffer.

The view will only expose data[offset, offset + size] .

Details
Parameters
data
A pointer to the start of the buffer.
end_offset
The end offset of the buffer view.
start_offset
The start offset of the buffer view.

BufferRef

  
 BufferRef 
 ( 
  
 const 
  
 void 
  
 * 
 data 
 , 
  
 size_t 
  
 end_offset 
 , 
  
 size_t 
  
 start_offset 
 ) 

BufferRef

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

BufferRef

  
 BufferRef 
 ( 
  
 const 
  
  BufferRef 
 
 & 
 other 
 ) 
 = 
 default 

Data

 const 
  
 ByteT 
  
 * 
  
 Data 
 () 
  
 const 
  

Returns a pointer to the start of the actual data.

Dump

 void 
  
 Dump 
 ( 
  
 std 
 :: 
 ostream 
 & 
 out 
 ) 
  
 const 
  

Prints information about this buffer.

Get

 TupleT 
  
 Get 
 () 
  
 const 
  

Returns the buffer details as a tuple.

Size

 size_t 
  
 Size 
 () 
  
 const 
  

Returns the size of the actual data.

Span

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

Returns a const span of the actual data.

StrData

 const 
  
 char 
  
 * 
  
 StrData 
 () 
  
 const 
  

Returns a pointer to the start of the actual data as a signed char.

StrView

 absl 
 :: 
 string_view 
  
 StrView 
 () 
  
 const 
  

Returns a string view of the actual data.

ToVec

 std 
 :: 
 vector 
<  
 ByteT 
 > 
 ToVec 
 () 
  
 const 
  

Copies the buffer data to a vector.

WriteStr

 void 
  
 WriteStr 
 ( 
  
 std 
 :: 
 ostream 
 & 
 out 
 ) 
  
 const 
  

Writes the string data to a stream.

operator=

  BufferRef 
 
 & 
 operator 
 = 
 ( 
  
 const 
  
  BufferRef 
 
 & 
 other 
 ) 
 = 
 default 

~BufferRef

virtual  ~BufferRef()=default

Protected functions

TypeName

 virtual 
  
 absl 
 :: 
 string_view 
  
 TypeName 
 () 
  
 const 
  

Returns the debug name of the class.

Design a Mobile Site
View Site in Mobile | Classic
Share by: