FHInternalStream.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 libfreehand 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 
00011 #ifndef __FHINTERNALSTREAM_H__
00012 #define __FHINTERNALSTREAM_H__
00013 
00014 #include <vector>
00015 
00016 #include <librevenge-stream/librevenge-stream.h>
00017 
00018 namespace libfreehand
00019 {
00020 
00021 class FHInternalStream : public librevenge::RVNGInputStream
00022 {
00023 public:
00024   FHInternalStream(librevenge::RVNGInputStream *input, unsigned long size, bool compressed=false);
00025   ~FHInternalStream() {}
00026   virtual bool isStructured()
00027   {
00028     return false;
00029   }
00030   virtual unsigned subStreamCount()
00031   {
00032     return 0;
00033   }
00034   virtual const char *subStreamName(unsigned)
00035   {
00036     return 0;
00037   }
00038   virtual bool existsSubStream(const char *)
00039   {
00040     return false;
00041   }
00042   virtual librevenge::RVNGInputStream *getSubStreamByName(const char *)
00043   {
00044     return 0;
00045   }
00046   virtual librevenge::RVNGInputStream *getSubStreamById(unsigned)
00047   {
00048     return 0;
00049   }
00050   const unsigned char *read(unsigned long numBytes, unsigned long &numBytesRead);
00051   int seek(long offset, librevenge::RVNG_SEEK_TYPE seekType);
00052   long tell();
00053   bool isEnd();
00054   unsigned long getSize() const
00055   {
00056     return m_buffer.size();
00057   }
00058 
00059 private:
00060   volatile long m_offset;
00061   std::vector<unsigned char> m_buffer;
00062   FHInternalStream(const FHInternalStream &);
00063   FHInternalStream &operator=(const FHInternalStream &);
00064 };
00065 
00066 } // namespace libfreehand
00067 
00068 #endif
00069 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */