| 1 |
/* |
| 2 |
* Copyright (C) 2023 Linux Studio Plugins Project <https://lsp-plug.in/> |
| 3 |
* (C) 2023 Vladimir Sadovnikov <[email protected]> |
| 4 |
* |
| 5 |
* This file is part of lsp-runtime-lib |
| 6 |
* Created on: 14 июн. 2018 г. |
| 7 |
* |
| 8 |
* lsp-runtime-lib is free software: you can redistribute it and/or modify |
| 9 |
* it under the terms of the GNU Lesser General Public License as published by |
| 10 |
* the Free Software Foundation, either version 3 of the License, or |
| 11 |
* any later version. |
| 12 |
* |
| 13 |
* lsp-runtime-lib is distributed in the hope that it will be useful, |
| 14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
* GNU Lesser General Public License for more details. |
| 17 |
* |
| 18 |
* You should have received a copy of the GNU Lesser General Public License |
| 19 |
* along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>. |
| 20 |
*/ |
| 21 |
|
| 22 |
#ifndef LSP_PLUG_IN_IO_STRINGREADER_H_ |
| 23 |
#define LSP_PLUG_IN_IO_STRINGREADER_H_ |
| 24 |
|
| 25 |
#include <lsp-plug.in/runtime/version.h> |
| 26 |
#include <lsp-plug.in/runtime/LSPString.h> |
| 27 |
#include <lsp-plug.in/io/IInSequence.h> |
| 28 |
|
| 29 |
namespace lsp |
| 30 |
{ |
| 31 |
namespace io |
| 32 |
{ |
| 33 |
class InStringSequence: public IInSequence |
| 34 |
{ |
| 35 |
private: |
| 36 |
LSPString *pString; |
| 37 |
size_t nOffset; |
| 38 |
bool bDelete; |
| 39 |
ssize_t nMark; |
| 40 |
ssize_t nMarkLen; |
| 41 |
|
| 42 |
protected: |
| 43 |
void do_close(); |
| 44 |
|
| 45 |
public: |
| 46 |
explicit InStringSequence(); |
| 47 |
explicit InStringSequence(const LSPString *s); |
| 48 |
explicit InStringSequence(LSPString *s, bool del = false); |
| 49 |
InStringSequence(const InStringSequence &) = delete; |
| 50 |
InStringSequence(InStringSequence &&) = delete; |
| 51 |
virtual ~InStringSequence() override; |
| 52 |
|
| 53 |
InStringSequence & operator = (const InStringSequence &) = delete; |
| 54 |
InStringSequence & operator = (InStringSequence &&) = delete; |
| 55 |
|
| 56 |
public: |
| 57 |
status_t wrap(const LSPString *in); |
| 58 |
status_t wrap(LSPString *in, bool del); |
| 59 |
status_t wrap(const char *s, const char *charset); |
| 60 |
status_t wrap(const char *s); |
| 61 |
|
| 62 |
public: |
| 63 |
virtual ssize_t read(lsp_wchar_t *dst, size_t count) override; |
| 64 |
virtual lsp_swchar_t read() override; |
| 65 |
virtual status_t read_line(LSPString *s, bool force = false) override; |
| 66 |
virtual ssize_t skip(size_t count) override; |
| 67 |
virtual status_t close() override; |
| 68 |
virtual status_t mark(ssize_t limit) override; |
| 69 |
virtual status_t reset() override; |
| 70 |
}; |
| 71 |
} /* namespace io */ |
| 72 |
} /* namespace lsp */ |
| 73 |
|
| 74 |
#endif /* LSP_PLUG_IN_IO_STRINGREADER_H_ */ |