libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
bufferiodevice.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_CORE
13#include <promeki/namespace.h>
14#include <promeki/iodevice.h>
15#include <promeki/buffer.h>
16
17PROMEKI_NAMESPACE_BEGIN
18
44class BufferIODevice : public IODevice {
45 PROMEKI_OBJECT(BufferIODevice, IODevice)
46 public:
53 explicit BufferIODevice(Buffer *buffer, ObjectBase *parent = nullptr);
54
62 explicit BufferIODevice(ObjectBase *parent = nullptr);
63
65 ~BufferIODevice() override;
66
73 void setBuffer(Buffer *buffer);
74
79 Buffer *buffer() const { return _buffer; }
80
94 void setAutoGrow(bool enabled) { _autoGrow = enabled; }
95
97 bool autoGrow() const { return _autoGrow; }
98
99 Error open(OpenMode mode) override;
100 Error close() override;
101 bool isOpen() const override;
102 int64_t read(void *data, int64_t maxSize) override;
103 int64_t write(const void *data, int64_t maxSize) override;
104 int64_t bytesAvailable() const override;
105 bool isSequential() const override;
106 Error seek(int64_t pos) override;
107 int64_t pos() const override;
108 Result<int64_t> size() const override;
109 bool atEnd() const override;
110
111 private:
112 Buffer *_buffer = nullptr;
113 int64_t _pos = 0;
114 bool _autoGrow = false;
115};
116
117PROMEKI_NAMESPACE_END
118
119#endif // PROMEKI_ENABLE_CORE