NuriaProject Framework
0.1
The NuriaProject Framework
|
In-memory buffer device with fallback to a temporary file. More...
#include <temporarybufferdevice.hpp>
Public Types | |
enum | { DefaultMemorySize = 4096 * 1024 } |
enum | StorageMode { NoDevice = 0, InMemory, TemporaryFile } |
Signals | |
void | storageModeChanged (Nuria::TemporaryBufferDevice::StorageMode storageMode) |
Public Member Functions | |
TemporaryBufferDevice (int maximumMemorySize, QObject *parent=0) | |
TemporaryBufferDevice (QObject *parent=0) | |
~TemporaryBufferDevice () override | |
bool | atEnd () const |
qint64 | bytesAvailable () const |
qint64 | bytesToWrite () const |
bool | canReadLine () const |
void | close () |
void | discard () |
QIODevice * | internalDevice () const |
bool | isSequential () const |
int | maximumMemorySize () const |
bool | open (OpenMode mode) |
qint64 | pos () const |
bool | reset () |
bool | seek (qint64 pos) |
void | setMaximumMemorySize (int maximumSize) |
qint64 | size () const |
QIODevice * | stealInternalDevice () |
StorageMode | storageMode () const |
bool | waitForBytesWritten (int msecs) |
bool | waitForReadyRead (int msecs) |
Protected Member Functions | |
qint64 | readData (char *data, qint64 maxlen) |
qint64 | readLineData (char *data, qint64 maxlen) |
qint64 | writeData (const char *data, qint64 len) |
In-memory buffer device with fallback to a temporary file.
This buffer uses internally a QBuffer to store data, but will start using a temporary file as storage when the buffer gets bigger than a given amount of bytes.
The device itself is usually opened for read and write access. You can change this using open(), though this has no effect on the internal device.
|
explicit |
Constructor. Initializes maximumMemorySize directly.
|
explicit |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
override |
Destructor.
void Nuria::TemporaryBufferDevice::close | ( | ) |
Closes the internal device, deleting all buffered data.
void Nuria::TemporaryBufferDevice::discard | ( | ) |
Discards the internal buffer. Doing so will loose all buffered data.
QIODevice* Nuria::TemporaryBufferDevice::internalDevice | ( | ) | const |
Returns the currently used internal storage device.
int Nuria::TemporaryBufferDevice::maximumMemorySize | ( | ) | const |
Returns the maximum size of the in-memory buffer. After the buffer grows beyond this barrier, a temporary file will be used instead.
void Nuria::TemporaryBufferDevice::setMaximumMemorySize | ( | int | maximumSize | ) |
Sets the maximum size of the in-memory buffer. The new value is applied immediately, thus if the buffer is exceeding the limit, a temporary file will be used.
QIODevice* Nuria::TemporaryBufferDevice::stealInternalDevice | ( | ) |
Steals the internal storage device from the instance. Ownership of the device is transferred to the caller. The TemporaryBufferDevice instance will act as if it was just created, thus contain no data.
StorageMode Nuria::TemporaryBufferDevice::storageMode | ( | ) | const |
Returns the current storage mode.
|
signal |
Triggered when the storage mode has been changed.