Debian Codegraph @

modules/lsp-runtime-lib/include/lsp-plug.in/io/OutSequence.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: 18 июн. 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_OUTSEQUENCE_H_
23 #define LSP_PLUG_IN_IO_OUTSEQUENCE_H_
24
25 #include <lsp-plug.in/runtime/version.h>
26 #include <lsp-plug.in/common/types.h>
27 #include <lsp-plug.in/io/charset.h>
28 #include <lsp-plug.in/io/Path.h>
29 #include <lsp-plug.in/io/File.h>
30 #include <lsp-plug.in/io/CharsetEncoder.h>
31 #include <lsp-plug.in/io/IOutStream.h>
32 #include <lsp-plug.in/io/IOutSequence.h>
33 #include <lsp-plug.in/stdlib/stdio.h>
34
35 namespace lsp
36 {
37 namespace io
38 {
39 class OutSequence: public IOutSequence
40 {
41 protected:
42 IOutStream *pOS;
43 size_t nWrapFlags;
44 CharsetEncoder sEncoder;
45
46 protected:
47 status_t flush_buffer_internal(bool force);
48
49 public:
50 explicit OutSequence();
51 OutSequence(const OutSequence &) = delete;
52 OutSequence(OutSequence &&) = delete;
53 virtual ~OutSequence() override;
54
55 OutSequence & operator = (const OutSequence &) = delete;
56 OutSequence & operator = (OutSequence &&) = delete;
57
58 public:
59 using IOutSequence::write;
60 using IOutSequence::write_ascii;
61
62 public:
63 status_t wrap(FILE *fd, bool close, const char *charset = NULL);
64
65 status_t wrap_native(fhandle_t fd, bool close, const char *charset = NULL);
66
67 status_t wrap(File *fd, size_t flags, const char *charset = NULL);
68
69 status_t wrap(IOutStream *os, size_t flags, const char *charset = NULL);
70
71 status_t open(const char *path, size_t mode, const char *charset = NULL);
72
73 status_t open(const LSPString *path, size_t mode, const char *charset = NULL);
74
75 status_t open(const Path *path, size_t mode, const char *charset = NULL);
76
77 public:
78 virtual status_t write(lsp_wchar_t c) override;
79 virtual status_t write(const lsp_wchar_t *c, size_t count) override;
80 virtual status_t write_ascii(const char *s, size_t count) override;
81 virtual status_t flush() override;
82 virtual status_t close() override;
83 };
84
85 } /* namespace io */
86 } /* namespace lsp */
87
88 #endif /* LSP_PLUG_IN_IO_OUTSEQUENCE_H_ */