Thrill  0.1
BufferRef Class Reference

Detailed Description

BufferRef represents a reference to a memory area as pointer and valid length.

It is not deallocated or otherwise managed. This class can be used to pass around references to BufferBuilder and BufferReader objects.

Definition at line 33 of file buffer_ref.hpp.

+ Inheritance diagram for BufferRef:

#include <buffer_ref.hpp>

Public Member Functions

 BufferRef (const BufferBuilder &bb)
 Constructor, assign memory area from BufferBuilder. More...
 
 BufferRef (const void *data, size_t size)
 Constructor, assign memory area from pointer and length. More...
 
 BufferRef (const std::string &str)
 Constructor, assign memory area from string, does NOT copy. More...
 
 BufferRef (const Buffer &b)
 Constructor, assign memory area from net::Buffer, does NOT copy! More...
 
const void * data () const
 Return a pointer to the currently kept memory area. More...
 
bool operator!= (const BufferRef &br) const noexcept
 Compare contents of two BufferRefs. More...
 
bool operator== (const BufferRef &br) const noexcept
 Compare contents of two BufferRefs. More...
 
size_t size () const
 Return the currently valid length in bytes. More...
 
Buffer ToBuffer ()
 Explicit conversion to Buffer MOVING the memory ownership. More...
 
std::string ToString () const
 Explicit conversion to std::string (copies memory of course). More...
 

Protected Types

using Byte = unsigned char
 type used to store the bytes More...
 

Protected Attributes

const Bytedata_
 Allocated buffer pointer. More...
 
size_t size_
 Size of valid data. More...
 

Member Typedef Documentation

◆ Byte

using Byte = unsigned char
protected

type used to store the bytes

Definition at line 37 of file buffer_ref.hpp.

Constructor & Destructor Documentation

◆ BufferRef() [1/4]

BufferRef ( const BufferBuilder bb)
inlineexplicit

Constructor, assign memory area from BufferBuilder.

Definition at line 47 of file buffer_ref.hpp.

◆ BufferRef() [2/4]

BufferRef ( const void *  data,
size_t  size 
)
inline

Constructor, assign memory area from pointer and length.

Definition at line 52 of file buffer_ref.hpp.

◆ BufferRef() [3/4]

BufferRef ( const std::string &  str)
inlineexplicit

Constructor, assign memory area from string, does NOT copy.

Definition at line 57 of file buffer_ref.hpp.

◆ BufferRef() [4/4]

BufferRef ( const Buffer b)
inline

Constructor, assign memory area from net::Buffer, does NOT copy!

Definition at line 63 of file buffer_ref.hpp.

Member Function Documentation

◆ data()

const void* data ( ) const
inline

Return a pointer to the currently kept memory area.

Definition at line 68 of file buffer_ref.hpp.

References BufferRef::data_.

◆ operator!=()

bool operator!= ( const BufferRef br) const
inlinenoexcept

Compare contents of two BufferRefs.

Definition at line 95 of file buffer_ref.hpp.

References BufferRef::operator==().

◆ operator==()

bool operator== ( const BufferRef br) const
inlinenoexcept

Compare contents of two BufferRefs.

Definition at line 89 of file buffer_ref.hpp.

Referenced by BufferRef::operator!=().

◆ size()

size_t size ( ) const
inline

Return the currently valid length in bytes.

Definition at line 72 of file buffer_ref.hpp.

References BufferRef::size_.

◆ ToBuffer()

Buffer ToBuffer ( )
inline

Explicit conversion to Buffer MOVING the memory ownership.

Definition at line 80 of file buffer_ref.hpp.

References Buffer::Acquire(), and BufferRef::data_.

◆ ToString()

std::string ToString ( ) const
inline

Explicit conversion to std::string (copies memory of course).

Definition at line 76 of file buffer_ref.hpp.

Member Data Documentation

◆ data_

const Byte* data_
protected

◆ size_

size_t size_
protected

Size of valid data.

Definition at line 43 of file buffer_ref.hpp.

Referenced by BufferReader::available(), BufferReader::empty(), BufferRef::size(), and BufferReader::Size().


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