/src/libetonyek/src/lib/IWORKMemoryStream.h
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* |
3 | | * This file is part of the libetonyek project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | */ |
9 | | |
10 | | #ifndef IWORKMEMORYSTREAM_H_INCLUDED |
11 | | #define IWORKMEMORYSTREAM_H_INCLUDED |
12 | | |
13 | | #include <memory> |
14 | | #include <vector> |
15 | | |
16 | | #include "libetonyek_utils.h" |
17 | | |
18 | | namespace libetonyek |
19 | | { |
20 | | |
21 | | class IWORKMemoryStream : public librevenge::RVNGInputStream |
22 | | { |
23 | | // -Weffc++ |
24 | | IWORKMemoryStream(const IWORKMemoryStream &other); |
25 | | IWORKMemoryStream &operator=(const IWORKMemoryStream &other); |
26 | | |
27 | | public: |
28 | | explicit IWORKMemoryStream(const RVNGInputStreamPtr_t &input); |
29 | | IWORKMemoryStream(const RVNGInputStreamPtr_t &input, unsigned length); |
30 | | explicit IWORKMemoryStream(const std::vector<unsigned char> &data); |
31 | | IWORKMemoryStream(const unsigned char *data, unsigned length); |
32 | | ~IWORKMemoryStream() override; |
33 | | |
34 | | bool isStructured() override; |
35 | | unsigned subStreamCount() override; |
36 | | const char *subStreamName(unsigned id) override; |
37 | | bool existsSubStream(const char *) override |
38 | 0 | { |
39 | 0 | return false; |
40 | 0 | } |
41 | | librevenge::RVNGInputStream *getSubStreamByName(const char *name) override; |
42 | | librevenge::RVNGInputStream *getSubStreamById(unsigned id) override; |
43 | | |
44 | | const unsigned char *read(unsigned long numBytes, unsigned long &numBytesRead) override; |
45 | | int seek(long offset, librevenge::RVNG_SEEK_TYPE seekType) override; |
46 | | long tell() override; |
47 | | bool isEnd() override; |
48 | | |
49 | | private: |
50 | | void assign(const unsigned char *data, unsigned length); |
51 | | void read(const RVNGInputStreamPtr_t &input, unsigned length); |
52 | | |
53 | | private: |
54 | | std::unique_ptr<unsigned char[]> m_data; |
55 | | long m_length; |
56 | | long m_pos; |
57 | | }; |
58 | | |
59 | | } |
60 | | |
61 | | #endif // IWORKMEMORYSTREAM_H_INCLUDED |
62 | | |
63 | | /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ |