Lightweight error code wrapper for the promeki library.
Definition error.h:39
Abstract base class for all I/O devices.
Definition iodevice.h:29
bool isReadable() const
Returns true if the device is readable.
Definition iodevice.h:168
OpenMode openMode() const
Returns the current open mode.
Definition iodevice.h:160
IODevice(ObjectBase *parent=nullptr)
Constructs an IODevice.
Definition iodevice.h:45
PROMEKI_SIGNAL(errorOccurred, Error)
Emitted when an error occurs.
virtual Error seek(int64_t pos)
Seeks to the given byte offset from the beginning.
virtual bool waitForBytesWritten(unsigned int timeoutMs=0)
Waits until all pending data has been written or timeout.
virtual void flush()
Flushes any buffered output data to the underlying device.
PROMEKI_SIGNAL(aboutToClose)
Emitted just before the device is closed.
virtual ~IODevice()
Destructor.
virtual int64_t pos() const
Returns the current read/write position.
virtual bool isOpen() const =0
Returns true if the device is open.
void clearError()
Clears the error state to Ok.
Definition iodevice.h:191
virtual bool isSequential() const
Returns true if the device is sequential (non-seekable).
void setError(const Error &err)
Sets the error state and emits errorOccurred.
Definition iodevice.h:224
bool isWritable() const
Returns true if the device is writable.
Definition iodevice.h:176
virtual Error open(OpenMode mode)=0
Opens the device with the specified mode.
virtual int64_t bytesAvailable() const
Returns the number of bytes available for reading.
virtual bool atEnd() const
Returns true if the current position is at the end.
virtual int64_t read(void *data, int64_t maxSize)=0
Reads up to maxSize bytes into data.
Error error() const
Returns the current error state.
Definition iodevice.h:184
virtual Error close()=0
Closes the device.
virtual int64_t write(const void *data, int64_t maxSize)=0
Writes up to maxSize bytes from data.
OpenMode
Mode flags controlling how a device is opened.
Definition iodevice.h:33
@ WriteOnly
Open for writing only.
Definition iodevice.h:36
@ ReadOnly
Open for reading only.
Definition iodevice.h:35
@ NotOpen
Device is not open.
Definition iodevice.h:34
@ ReadWrite
Open for reading and writing.
Definition iodevice.h:37
@ Append
Open for appending (implies WriteOnly).
Definition iodevice.h:38
PROMEKI_SIGNAL(readyRead)
Emitted when data is available for reading.
virtual Result< int64_t > size() const
Returns the total size of the device in bytes.
virtual bool waitForReadyRead(unsigned int timeoutMs=0)
Waits until data is available for reading or timeout.
void setOpenMode(OpenMode mode)
Sets the open mode.
Definition iodevice.h:215
PROMEKI_SIGNAL(bytesWritten, int64_t)
Emitted when bytes have been written.
Dynamic array container wrapping std::vector.
Definition list.h:40
Base object for promeki.
Definition objectbase.h:129
ObjectBase * parent() const
Returns the parent object, if one. nullptr if none.
Definition objectbase.h:258
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19