NIST Biometric Evaluation Framework
Software components for biometric technology evaluations
Public Member Functions | List of all members
BiometricEvaluation::Memory::IndexedBuffer Class Reference

Wrap a memory buffer with an index. More...

#include <be_memory_indexedbuffer.h>

Inherited by BiometricEvaluation::Memory::MutableIndexedBuffer.

Public Member Functions

 IndexedBuffer ()
 Wrap a nullptr buffer. More...
 
 IndexedBuffer (const uint8_t *data, uint64_t size)
 Wrap an existing buffer of a given length. More...
 
 IndexedBuffer (const uint8Array &aa)
 Wrap an existing uint8Array. More...
 
 IndexedBuffer (const IndexedBuffer &copy)=default
 Copy constructor (default). More...
 
uint32_t getSize () const
 Obtain the current size of the buffer. More...
 
uint32_t getIndex () const
 Obtain the current index into the buffer. More...
 
void setIndex (uint64_t index)
 Set the current index into the buffer. More...
 
uint8_t scanU8Val ()
 Obtain the next element of the buffer and increment the current index value. More...
 
uint16_t scanU16Val ()
 Obtain the next two elements of the buffer and increment the current index value. More...
 
uint16_t scanBeU16Val ()
 Obtain the next two elements of the buffer, scanned as a big-endian value, and increment the current index value. More...
 
uint32_t scanU32Val ()
 Obtain the next four elements of the buffer and increment the current index value by four. More...
 
uint32_t scanBeU32Val ()
 Obtain the next four elements of the buffer, scanned as a big-endian value, and increment the current index value. More...
 
uint64_t scanU64Val ()
 Obtain the next eight elements of the buffer and increment the current index value by eight. More...
 
uint64_t scan (void *buf, uint64_t len)
 Obtain the next 'n' elements of the buffer and increment the current index value by n. More...
 
virtual const uint8_t * get () const
 Returns a pointer to the managed buffer. More...
 
virtual ~IndexedBuffer ()=default
 Destructor (default). More...
 

Detailed Description

Wrap a memory buffer with an index.

The memory buffer is treated as an array of unsigned eight bit values. This class provides safe access to the array with methods to retrieve 8/16/32/64-bit elements, or and arbitrary segment starting at the index, from the array while advancing the current index. An exception is thrown by these methods whenever the retrieval would reach beyond the size of the buffer. IndexedBuffers do not own the memory of the buffers they wrap.

Definition at line 33 of file be_memory_indexedbuffer.h.

Constructor & Destructor Documentation

◆ IndexedBuffer() [1/4]

BiometricEvaluation::Memory::IndexedBuffer::IndexedBuffer ( )

Wrap a nullptr buffer.

◆ IndexedBuffer() [2/4]

BiometricEvaluation::Memory::IndexedBuffer::IndexedBuffer ( const uint8_t *  data,
uint64_t  size 
)

Wrap an existing buffer of a given length.

Parameters
dataBuffer to wrap.
sizeSize of buffer.

◆ IndexedBuffer() [3/4]

BiometricEvaluation::Memory::IndexedBuffer::IndexedBuffer ( const uint8Array aa)

Wrap an existing uint8Array.

Parameters
aauint8Array to wrap.

◆ IndexedBuffer() [4/4]

BiometricEvaluation::Memory::IndexedBuffer::IndexedBuffer ( const IndexedBuffer copy)
default

Copy constructor (default).

◆ ~IndexedBuffer()

virtual BiometricEvaluation::Memory::IndexedBuffer::~IndexedBuffer ( )
virtualdefault

Destructor (default).

Member Function Documentation

◆ getSize()

uint32_t BiometricEvaluation::Memory::IndexedBuffer::getSize ( ) const

Obtain the current size of the buffer.

Returns
The current buffer size.

◆ getIndex()

uint32_t BiometricEvaluation::Memory::IndexedBuffer::getIndex ( ) const

Obtain the current index into the buffer.

Returns
The current buffer index.
Note
When getIndex() == getSize(), the buffer is exhausted from scanning.

◆ setIndex()

void BiometricEvaluation::Memory::IndexedBuffer::setIndex ( uint64_t  index)

Set the current index into the buffer.

Parameters
[in]indexThe index value to set.
Exceptions
Error::ParameterErrorThe index parameter is too large.

◆ scanU8Val()

uint8_t BiometricEvaluation::Memory::IndexedBuffer::scanU8Val ( )

Obtain the next element of the buffer and increment the current index value.

Returns
The next element of the buffer as an unsigned 8-bit value.
Exceptions
Error::DataErrorThe buffer is exhausted.

◆ scanU16Val()

uint16_t BiometricEvaluation::Memory::IndexedBuffer::scanU16Val ( )

Obtain the next two elements of the buffer and increment the current index value.

Returns
The next element of the buffer as an unsigned 16-bit value.
Exceptions
Error::DataErrorThe buffer is exhausted.

◆ scanBeU16Val()

uint16_t BiometricEvaluation::Memory::IndexedBuffer::scanBeU16Val ( )

Obtain the next two elements of the buffer, scanned as a big-endian value, and increment the current index value.

Returns
The next element of the buffer as an unsigned 16-bit value.
Exceptions
Error::DataErrorThe buffer is exhausted.

◆ scanU32Val()

uint32_t BiometricEvaluation::Memory::IndexedBuffer::scanU32Val ( )

Obtain the next four elements of the buffer and increment the current index value by four.

Returns
The next element of the buffer as an unsigned 32-bit value.
Exceptions
Error::DataErrorThe buffer is exhausted.

◆ scanBeU32Val()

uint32_t BiometricEvaluation::Memory::IndexedBuffer::scanBeU32Val ( )

Obtain the next four elements of the buffer, scanned as a big-endian value, and increment the current index value.

Returns
The next element of the buffer as an unsigned 32-bit value.
Exceptions
Error::DataErrorThe buffer is exhausted.

◆ scanU64Val()

uint64_t BiometricEvaluation::Memory::IndexedBuffer::scanU64Val ( )

Obtain the next eight elements of the buffer and increment the current index value by eight.

Returns
The next element of the buffer as an unsigned 64-bit value.
Exceptions
Error::DataErrorThe buffer is exhausted.

◆ scan()

uint64_t BiometricEvaluation::Memory::IndexedBuffer::scan ( void *  buf,
uint64_t  len 
)

Obtain the next 'n' elements of the buffer and increment the current index value by n.

Parameters
[in]bufBuffer to store the copied data, or nullptr.
[in]lenThe number of elements to copy.
Exceptions
Error::DataErrorThe buffer is exhausted.
Returns
The number of elements copied.

◆ get()

virtual const uint8_t * BiometricEvaluation::Memory::IndexedBuffer::get ( ) const
virtual

Returns a pointer to the managed buffer.

Returns
Pointer to the managed buffer.

Reimplemented in BiometricEvaluation::Memory::MutableIndexedBuffer.


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