libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
stringiodevice.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/string.h>
16
17PROMEKI_NAMESPACE_BEGIN
18
40class StringIODevice : public IODevice {
41 PROMEKI_OBJECT(StringIODevice, IODevice)
42 public:
49 explicit StringIODevice(String *string, ObjectBase *parent = nullptr);
50
58 explicit StringIODevice(ObjectBase *parent = nullptr);
59
61 ~StringIODevice() override;
62
69 void setString(String *string);
70
75 String *string() const { return _string; }
76
77 Error open(OpenMode mode) override;
78 Error close() override;
79 bool isOpen() const override;
80 int64_t read(void *data, int64_t maxSize) override;
81 int64_t write(const void *data, int64_t maxSize) override;
82 int64_t bytesAvailable() const override;
83 bool isSequential() const override;
84 Error seek(int64_t pos) override;
85 int64_t pos() const override;
86 Result<int64_t> size() const override;
87 bool atEnd() const override;
88
89 private:
90 String *_string = nullptr;
91 int64_t _pos = 0;
92};
93
94PROMEKI_NAMESPACE_END
95
96#endif // PROMEKI_ENABLE_CORE