libQuotient
A Qt library for building matrix clients
Quotient::FixedBufferBase Class Reference

Non-template base for owning byte span classes. More...

#include <e2ee_common.h>

Inheritance diagram for Quotient::FixedBufferBase:

Public Types

enum  InitOptions { Uninitialized , FillWithZeros , FillWithRandom }
 
using value_type = byte_t
 
using size_type = size_t
 

Public Member Functions

auto size () const
 
auto empty () const
 
void clear ()
 
QByteArray viewAsByteArray () const
 Access the bytes of the fixed buffer via QByteArray interface. More...
 
QByteArray copyToByteArray (QByteArray::size_type untilPos=-1) const
 Copy the contents of the buffer to a QByteArray. More...
 
QByteArray toBase64 () const
 
QByteArray toBase64 (QByteArray::Base64Options options) const
 
FixedBufferBaseoperator= (FixedBufferBase &&)=delete
 

Static Public Attributes

static constexpr auto TotalSecureHeapSize = 65'536
 

Protected Member Functions

 FixedBufferBase (size_t bufferSize, InitOptions options)
 
 ~FixedBufferBase ()
 
 FixedBufferBase (FixedBufferBase &&other)
 
void fillFrom (QByteArray &&source)
 
uint8_t * dataForWriting ()
 
const uint8_t * data () const
 

Detailed Description

Non-template base for owning byte span classes.

Definition at line 165 of file e2ee_common.h.

Member Typedef Documentation

◆ size_type

Definition at line 170 of file e2ee_common.h.

◆ value_type

Definition at line 169 of file e2ee_common.h.

Member Enumeration Documentation

◆ InitOptions

Enumerator
Uninitialized 
FillWithZeros 
FillWithRandom 

Definition at line 167 of file e2ee_common.h.

Constructor & Destructor Documentation

◆ FixedBufferBase() [1/2]

Quotient::FixedBufferBase::FixedBufferBase ( size_t  bufferSize,
InitOptions  options 
)
protected

◆ ~FixedBufferBase()

Quotient::FixedBufferBase::~FixedBufferBase ( )
inlineprotected

Definition at line 219 of file e2ee_common.h.

◆ FixedBufferBase() [2/2]

Quotient::FixedBufferBase::FixedBufferBase ( FixedBufferBase &&  other)
inlineprotected

Definition at line 221 of file e2ee_common.h.

Member Function Documentation

◆ clear()

void Quotient::FixedBufferBase::clear ( )

◆ copyToByteArray()

QByteArray Quotient::FixedBufferBase::copyToByteArray ( QByteArray::size_type  untilPos = -1) const
inline

Copy the contents of the buffer to a QByteArray.

Unlike viewAsByteArray(), this function actually copies the buffer to non-secure memory.

Definition at line 199 of file e2ee_common.h.

◆ data()

const uint8_t* Quotient::FixedBufferBase::data ( ) const
inlineprotected

Definition at line 228 of file e2ee_common.h.

◆ dataForWriting()

uint8_t* Quotient::FixedBufferBase::dataForWriting ( )
inlineprotected

Definition at line 227 of file e2ee_common.h.

◆ empty()

auto Quotient::FixedBufferBase::empty ( ) const
inline

Definition at line 175 of file e2ee_common.h.

◆ fillFrom()

void Quotient::FixedBufferBase::fillFrom ( QByteArray &&  source)
protected

◆ operator=()

FixedBufferBase& Quotient::FixedBufferBase::operator= ( FixedBufferBase &&  )
delete

◆ size()

auto Quotient::FixedBufferBase::size ( ) const
inline

Definition at line 174 of file e2ee_common.h.

◆ toBase64() [1/2]

QByteArray Quotient::FixedBufferBase::toBase64 ( ) const
inline

Definition at line 208 of file e2ee_common.h.

◆ toBase64() [2/2]

QByteArray Quotient::FixedBufferBase::toBase64 ( QByteArray::Base64Options  options) const
inline

Definition at line 209 of file e2ee_common.h.

◆ viewAsByteArray()

QByteArray Quotient::FixedBufferBase::viewAsByteArray ( ) const
inline

Access the bytes of the fixed buffer via QByteArray interface.

This uses QByteArray::fromRawData() to create a QByteArray object that refers to the original fixed buffer, without copying.

Warning
the lifetime of the returned QByteArray should not exceed the lifetime of the underlying buffer; in particular, you should never try using the result of viewAsByteArray() as a return value of your function
See also
copyToByteArray

Definition at line 188 of file e2ee_common.h.

Member Data Documentation

◆ TotalSecureHeapSize

constexpr auto Quotient::FixedBufferBase::TotalSecureHeapSize = 65'536
staticconstexpr

Definition at line 172 of file e2ee_common.h.


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