QXPMemoryStream.h
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /*
00003  * This file is part of the libqxp project.
00004  *
00005  * This Source Code Form is subject to the terms of the Mozilla Public
00006  * License, v. 2.0. If a copy of the MPL was not distributed with this
00007  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00008  */
00009 
00010 #ifndef QXPMEMORYSTREAM_H_INCLUDED
00011 #define QXPMEMORYSTREAM_H_INCLUDED
00012 
00013 #include <memory>
00014 
00015 #include <librevenge-stream/librevenge-stream.h>
00016 
00017 namespace libqxp
00018 {
00019 
00020 class QXPMemoryStream : public librevenge::RVNGInputStream
00021 {
00022 // disable copying
00023   QXPMemoryStream(const QXPMemoryStream &other) = delete;
00024   QXPMemoryStream &operator=(const QXPMemoryStream &other) = delete;
00025 
00026 public:
00027   QXPMemoryStream(const unsigned char *data, unsigned length);
00028   ~QXPMemoryStream() override;
00029 
00030   bool isStructured() override;
00031   unsigned subStreamCount() override;
00032   const char *subStreamName(unsigned id) override;
00033   bool existsSubStream(const char *name) override;
00034   librevenge::RVNGInputStream *getSubStreamByName(const char *name) override;
00035   RVNGInputStream *getSubStreamById(unsigned id) override;
00036 
00037   const unsigned char *read(unsigned long numBytes, unsigned long &numBytesRead) override;
00038   int seek(long offset, librevenge::RVNG_SEEK_TYPE seekType) override;
00039   long tell() override;
00040   bool isEnd() override;
00041 
00042 private:
00043   std::unique_ptr<unsigned char[]> m_data;
00044   const long m_length;
00045   long m_pos;
00046 };
00047 
00048 }
00049 
00050 #endif // QXPMEMORYSTREAM_H_INCLUDED
00051 
00052 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */