QXPMemoryStream.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 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: */
libqxp::QXPMemoryStream::QXPMemoryStream
QXPMemoryStream(const QXPMemoryStream &other)=delete
libqxp::QXPMemoryStream::m_data
std::unique_ptr< unsigned char[]> m_data
Definition QXPMemoryStream.h:43
libqxp::QXPMemoryStream::existsSubStream
bool existsSubStream(const char *name) override
Definition QXPMemoryStream.cpp:48
libqxp::QXPMemoryStream::isStructured
bool isStructured() override
Definition QXPMemoryStream.cpp:33
libqxp::QXPMemoryStream::getSubStreamByName
librevenge::RVNGInputStream * getSubStreamByName(const char *name) override
Definition QXPMemoryStream.cpp:53
libqxp::QXPMemoryStream::isEnd
bool isEnd() override
Definition QXPMemoryStream.cpp:118
libqxp::QXPMemoryStream::~QXPMemoryStream
~QXPMemoryStream() override
Definition QXPMemoryStream.cpp:29
libqxp::QXPMemoryStream::subStreamCount
unsigned subStreamCount() override
Definition QXPMemoryStream.cpp:38
libqxp::QXPMemoryStream::seek
int seek(long offset, librevenge::RVNG_SEEK_TYPE seekType) override
Definition QXPMemoryStream.cpp:84
libqxp::QXPMemoryStream::m_pos
long m_pos
Definition QXPMemoryStream.h:45
libqxp::QXPMemoryStream::getSubStreamById
RVNGInputStream * getSubStreamById(unsigned id) override
Definition QXPMemoryStream.cpp:58
libqxp::QXPMemoryStream::read
const unsigned char * read(unsigned long numBytes, unsigned long &numBytesRead) override
Definition QXPMemoryStream.cpp:63
libqxp::QXPMemoryStream::tell
long tell() override
Definition QXPMemoryStream.cpp:113
libqxp::QXPMemoryStream::operator=
QXPMemoryStream & operator=(const QXPMemoryStream &other)=delete
libqxp::QXPMemoryStream::m_length
const long m_length
Definition QXPMemoryStream.h:44
libqxp::QXPMemoryStream::subStreamName
const char * subStreamName(unsigned id) override
Definition QXPMemoryStream.cpp:43
libqxp::RVNGInputStream
libqxp
Definition libqxp_utils.cpp:25