194 FILE *_file =
nullptr;
196 bool _ownsFile =
false;
Lightweight error code wrapper for the promeki library.
Definition error.h:39
IODevice wrapping a C stdio FILE pointer.
Definition fileiodevice.h:47
bool atEnd() const override
Returns true if the current position is at the end.
void setFilename(const String &filename)
Sets the filename for fopen-based opening.
Error open(OpenMode mode) override
Opens the device.
bool isSequential() const override
Returns true if the device is sequential (non-seekable).
FILE * file() const
Returns the underlying FILE pointer, or nullptr.
Definition fileiodevice.h:152
Error close() override
Closes the device.
Flag
Flags for the FILE* constructor.
Definition fileiodevice.h:51
@ NoFlags
Default: device does not own the FILE.
Definition fileiodevice.h:52
@ OwnsFile
Device will fclose the FILE on close/destruct.
Definition fileiodevice.h:53
FileIODevice(const FileIODevice &)=delete
Deleted copy constructor (non-copyable).
static FileIODevice * stdoutDevice()
Returns a singleton FileIODevice wrapping C stdout.
bool isOpen() const override
Returns true if the device is open.
const String & filename() const
Returns the filename, or an empty string if none was set.
Definition fileiodevice.h:146
static FileIODevice * stderrDevice()
Returns a singleton FileIODevice wrapping C stderr.
static FileIODevice * stdinDevice()
Returns a singleton FileIODevice wrapping C stdin.
void flush() override
Flushes any buffered output data to the underlying device.
FileIODevice & operator=(const FileIODevice &)=delete
Deleted copy assignment (non-copyable).
FileIODevice(const String &filename, ObjectBase *parent=nullptr)
Constructs a FileIODevice with a filename.
FILE * takeFile()
Transfers ownership of the FILE pointer to the caller.
int64_t write(const void *data, int64_t maxSize) override
Writes up to maxSize bytes from data.
int64_t read(void *data, int64_t maxSize) override
Reads up to maxSize bytes into data.
FileIODevice(FILE *file, OpenMode mode, int flags=NoFlags, ObjectBase *parent=nullptr)
Constructs a FileIODevice wrapping an external FILE.
FileIODevice(ObjectBase *parent=nullptr)
Constructs a FileIODevice with no FILE or filename.
~FileIODevice() override
Destructor. Closes and fclose's if owned.
Error seek(int64_t pos) override
Seeks to the given byte offset from the beginning.
bool ownsFile() const
Returns true if the device owns the FILE pointer.
Definition fileiodevice.h:158
int64_t pos() const override
Returns the current read/write position.
Abstract base class for all I/O devices.
Definition iodevice.h:29
OpenMode
Mode flags controlling how a device is opened.
Definition iodevice.h:33
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
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
#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