IWORKMemoryStream.h
Go to the documentation of this file.
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++
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  {
39  return false;
40  }
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: */
bool isStructured() override
Definition: IWORKMemoryStream.cpp:71
Definition: IWORKBezierElement.cpp:18
std::unique_ptr< unsigned char[]> m_data
Definition: IWORKMemoryStream.h:54
long m_length
Definition: IWORKMemoryStream.h:55
const unsigned char * read(unsigned long numBytes, unsigned long &numBytesRead) override
Definition: IWORKMemoryStream.cpp:96
bool isEnd() override
Definition: IWORKMemoryStream.cpp:151
long tell() override
Definition: IWORKMemoryStream.cpp:146
const char * name
Definition: IWORKToken.cpp:43
librevenge::RVNGInputStream * getSubStreamById(unsigned id) override
Definition: IWORKMemoryStream.cpp:91
long m_pos
Definition: IWORKMemoryStream.h:56
int seek(long offset, librevenge::RVNG_SEEK_TYPE seekType) override
Definition: IWORKMemoryStream.cpp:117
Definition: IWORKMemoryStream.h:21
bool existsSubStream(const char *) override
Definition: IWORKMemoryStream.h:37
void assign(const unsigned char *data, unsigned length)
Definition: IWORKMemoryStream.cpp:156
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr_t
Definition: libetonyek_utils.h:82
Definition: IWORKToken.h:101
librevenge::RVNGInputStream * getSubStreamByName(const char *name) override
Definition: IWORKMemoryStream.cpp:86
const char * subStreamName(unsigned id) override
Definition: IWORKMemoryStream.cpp:81
~IWORKMemoryStream() override
Definition: IWORKMemoryStream.cpp:67
Definition: IWORKToken.h:350
IWORKMemoryStream & operator=(const IWORKMemoryStream &other)
unsigned subStreamCount() override
Definition: IWORKMemoryStream.cpp:76
IWORKMemoryStream(const IWORKMemoryStream &other)

Generated for libetonyek by doxygen 1.8.13