ZMFInternalStream.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 a part of the libzmf 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 ZMFINTERNALSTREAM_H_INCLUDED
00011 #define ZMFINTERNALSTREAM_H_INCLUDED
00012 
00013 #include <vector>
00014 
00015 #include <librevenge-stream/librevenge-stream.h>
00016 
00017 #include "libzmf_utils.h"
00018 
00019 namespace libzmf
00020 {
00021 
00022 class ZMFInternalStream : public librevenge::RVNGInputStream
00023 {
00024 public:
00025   ZMFInternalStream(const unsigned char *data, unsigned long size);
00026   ZMFInternalStream(const std::vector<unsigned char> &data);
00027   ZMFInternalStream(const RVNGInputStreamPtr &input, unsigned long size);
00028   virtual ~ZMFInternalStream();
00029 
00030   virtual bool isStructured();
00031   virtual unsigned subStreamCount();
00032   virtual const char *subStreamName(unsigned id);
00033   virtual bool existsSubStream(const char *name);
00034   virtual librevenge::RVNGInputStream *getSubStreamByName(const char *name);
00035   virtual librevenge::RVNGInputStream *getSubStreamById(unsigned id);
00036 
00037   const virtual unsigned char *read(unsigned long numBytes, unsigned long &numBytesRead);
00038   virtual int seek(long offset, librevenge::RVNG_SEEK_TYPE seekType);
00039   virtual long tell();
00040   virtual bool isEnd();
00041 
00042 private:
00043   long m_offset;
00044   unsigned long m_size;
00045   const unsigned char *m_data;
00046   unsigned char *m_tmpBuf;
00047   bool m_dataOwner;
00048   ZMFInternalStream(const ZMFInternalStream &);
00049   ZMFInternalStream &operator=(const ZMFInternalStream &);
00050 };
00051 
00052 }
00053 
00054 #endif // ZMFINTERNALSTREAM_H_INCLUDED
00055 
00056 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */