Debian Codegraph @

modules/lsp-runtime-lib/include/lsp-plug.in/io/InMarkSequence.h

raw
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: 12 февр. 2021 г.
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_INMARKSEQUENCE_H_
23 #define LSP_PLUG_IN_IO_INMARKSEQUENCE_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 /**
34 * Buffered sequence, extends the underlying sequence with mark() and reset() methods
35 */
36 class InMarkSequence: public IInSequence
37 {
38 protected:
39 IInSequence *pSequence;
40 ssize_t nMarkPos;
41 ssize_t nMarkLen;
42 ssize_t nMarkMax;
43 lsp_wchar_t *pBuf;
44 size_t nBufCap;
45 bool bClose;
46
47 protected:
48 status_t do_close();
49 ssize_t grow_buffer(size_t amount);
50 void clear_mark();
51
52 public:
53 explicit InMarkSequence();
54 InMarkSequence(const InMarkSequence &) = delete;
55 InMarkSequence(InMarkSequence &&) = delete;
56 virtual ~InMarkSequence() override;
57
58 InMarkSequence & operator = (const InMarkSequence &) = delete;
59 InMarkSequence & operator = (InMarkSequence &&) = delete;
60
61 public:
62 status_t wrap(IInSequence *in, bool close = false);
63
64 public:
65 virtual status_t close() override;
66 virtual ssize_t read(lsp_wchar_t *dst, size_t count) override;
67 virtual lsp_swchar_t read() override;
68 virtual ssize_t skip(size_t count) override;
69 virtual status_t mark(ssize_t limit) override;
70 virtual status_t reset() override;
71 };
72
73 } /* namespace io */
74 } /* namespace lsp */
75
76
77 #endif /* LSP_PLUG_IN_IO_INMARKSEQUENCE_H_ */