| 1 |
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the libqxp 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 QXPMEMORYSTREAM_H_INCLUDED |
| 11 |
#define QXPMEMORYSTREAM_H_INCLUDED |
| 12 |
|
| 13 |
#include <memory> |
| 14 |
|
| 15 |
#include <librevenge-stream/librevenge-stream.h> |
| 16 |
|
| 17 |
namespace libqxp |
| 18 |
{ |
| 19 |
|
| 20 |
class QXPMemoryStream : public librevenge::RVNGInputStream |
| 21 |
{ |
| 22 |
// disable copying |
| 23 |
QXPMemoryStream(const QXPMemoryStream &other) = delete; |
| 24 |
QXPMemoryStream &operator=(const QXPMemoryStream &other) = delete; |
| 25 |
|
| 26 |
public: |
| 27 |
QXPMemoryStream(const unsigned char *data, unsigned length); |
| 28 |
~QXPMemoryStream() override; |
| 29 |
|
| 30 |
bool isStructured() override; |
| 31 |
unsigned subStreamCount() override; |
| 32 |
const char *subStreamName(unsigned id) override; |
| 33 |
bool existsSubStream(const char *name) override; |
| 34 |
librevenge::RVNGInputStream *getSubStreamByName(const char *name) override; |
| 35 |
RVNGInputStream *getSubStreamById(unsigned id) override; |
| 36 |
|
| 37 |
const unsigned char *read(unsigned long numBytes, unsigned long &numBytesRead) override; |
| 38 |
int seek(long offset, librevenge::RVNG_SEEK_TYPE seekType) override; |
| 39 |
long tell() override; |
| 40 |
bool isEnd() override; |
| 41 |
|
| 42 |
private: |
| 43 |
std::unique_ptr<unsigned char[]> m_data; |
| 44 |
const long m_length; |
| 45 |
long m_pos; |
| 46 |
}; |
| 47 |
|
| 48 |
} |
| 49 |
|
| 50 |
#endif // QXPMEMORYSTREAM_H_INCLUDED |
| 51 |
|
| 52 |
/* vim:set shiftwidth=2 softtabstop=2 expandtab: */ |