IWORKMemoryStream.h Source File documentation

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
18namespace libetonyek
19{
20
21 class IWORKMemoryStream : public librevenge::RVNGInputStream
22{
23 // -Weffc++
24 IWORKMemoryStream(const IWORKMemoryStream &other);
25 IWORKMemoryStream &operator=(const IWORKMemoryStream &other);
26
27public:
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
49private:
50 void assign(const unsigned char *data, unsigned length);
51 void read(const RVNGInputStreamPtr_t &input, unsigned length);
52
53private:
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: */
libetonyek::IWORKMemoryStream
Definition IWORKMemoryStream.h:22
libetonyek::IWORKMemoryStream::tell
long tell() override
Definition IWORKMemoryStream.cpp:146
libetonyek::IWORKMemoryStream::getSubStreamByName
librevenge::RVNGInputStream * getSubStreamByName(const char *name) override
Definition IWORKMemoryStream.cpp:86
libetonyek::IWORKMemoryStream::m_length
long m_length
Definition IWORKMemoryStream.h:55
libetonyek::IWORKMemoryStream::isEnd
bool isEnd() override
Definition IWORKMemoryStream.cpp:151
libetonyek::IWORKMemoryStream::m_pos
long m_pos
Definition IWORKMemoryStream.h:56
libetonyek::IWORKMemoryStream::assign
void assign(const unsigned char *data, unsigned length)
Definition IWORKMemoryStream.cpp:156
libetonyek::IWORKMemoryStream::m_data
std::unique_ptr< unsigned char[]> m_data
Definition IWORKMemoryStream.h:54
libetonyek::IWORKMemoryStream::operator=
IWORKMemoryStream & operator=(const IWORKMemoryStream &other)
libetonyek::IWORKMemoryStream::getSubStreamById
librevenge::RVNGInputStream * getSubStreamById(unsigned id) override
Definition IWORKMemoryStream.cpp:91
libetonyek::IWORKMemoryStream::existsSubStream
bool existsSubStream(const char *) override
Definition IWORKMemoryStream.h:37
libetonyek::IWORKMemoryStream::read
const unsigned char * read(unsigned long numBytes, unsigned long &numBytesRead) override
Definition IWORKMemoryStream.cpp:96
libetonyek::IWORKMemoryStream::IWORKMemoryStream
IWORKMemoryStream(const IWORKMemoryStream &other)
libetonyek::IWORKMemoryStream::seek
int seek(long offset, librevenge::RVNG_SEEK_TYPE seekType) override
Definition IWORKMemoryStream.cpp:117
libetonyek::IWORKMemoryStream::subStreamName
const char * subStreamName(unsigned id) override
Definition IWORKMemoryStream.cpp:81
libetonyek::IWORKMemoryStream::subStreamCount
unsigned subStreamCount() override
Definition IWORKMemoryStream.cpp:76
libetonyek::IWORKMemoryStream::isStructured
bool isStructured() override
Definition IWORKMemoryStream.cpp:71
libetonyek::IWORKMemoryStream::~IWORKMemoryStream
~IWORKMemoryStream() override
Definition IWORKMemoryStream.cpp:67
libetonyek_utils.h
libetonyek::IWORKToken::offset
@ offset
Definition IWORKToken.h:594
libetonyek::IWORKToken::data
@ data
Definition IWORKToken.h:178
libetonyek::IWORKToken::name
@ name
Definition IWORKToken.h:585
libetonyek
Definition IWORKBezierElement.cpp:21
libetonyek::RVNGInputStreamPtr_t
std::shared_ptr< librevenge::RVNGInputStream > RVNGInputStreamPtr_t
Definition libetonyek_utils.h:82