Skip to content

QuantumGate::Buffer

Karel Donk edited this page Jun 16, 2018 · 9 revisions

QuantumGate::Buffer is a class that represents a memory buffer. It's used to pass data into and out of a QuantumGate instance. QuantumGate::Buffer shares the same underlying implementation (and thus the same interface) with QuantumGate::ProtectedBuffer; the only difference between them is the memory allocator being used.

QuantumGate::ProtectedBuffer uses a special allocator that adds some extra protection to sensitive data in memory (the data gets locked in memory and prevented from being swapped to disk, and the buffer gets wiped (filled with zeros) whenever it's freed).

Member functions

Name Description
Constructor Constructs a Buffer object.
operator= Assigns a value to the buffer.
operator[] Returns a reference to the Byte at the specified position in the buffer.
operator+= Adds data to the buffer.
GetVector Returns a reference to the underlying std::vector object with the buffer data.
GetBytes Returns a pointer to the data contained in the buffer.
GetSize Returns the size of the data in the buffer in bytes.
IsEmpty Returns whether the buffer is empty.
operator bool Returns whether the buffer is empty.
Swap Swaps the contents of two buffer objects.
Allocate Allocates memory for the buffer.
Preallocate Preallocates memory for the buffer.
FreeUnused Frees any unused memory that was allocated.
Resize Resizes the buffer.
RemoveFirst Removes the first specified number of bytes from the buffer.
RemoveLast Removes the last specified number of bytes from the buffer.
Clear Clears the buffer.
Clone this wiki locally