00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 00002 /* 00003 * This file is part of the libetonyek 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 IWORKMEMORYSTREAM_H_INCLUDED 00011 #define IWORKMEMORYSTREAM_H_INCLUDED 00012 00013 #include <vector> 00014 00015 #include "libetonyek_utils.h" 00016 00017 namespace libetonyek 00018 { 00019 00020 class IWORKMemoryStream : public librevenge::RVNGInputStream 00021 { 00022 // -Weffc++ 00023 IWORKMemoryStream(const IWORKMemoryStream &other); 00024 IWORKMemoryStream &operator=(const IWORKMemoryStream &other); 00025 00026 public: 00027 explicit IWORKMemoryStream(const RVNGInputStreamPtr_t &input); 00028 IWORKMemoryStream(const RVNGInputStreamPtr_t &input, unsigned length); 00029 explicit IWORKMemoryStream(const std::vector<unsigned char> &data); 00030 IWORKMemoryStream(const unsigned char *data, unsigned length); 00031 ~IWORKMemoryStream(); 00032 00033 bool isStructured(); 00034 unsigned subStreamCount(); 00035 const char *subStreamName(unsigned id); 00036 bool existsSubStream(const char *) 00037 { 00038 return false; 00039 } 00040 librevenge::RVNGInputStream *getSubStreamByName(const char *name); 00041 librevenge::RVNGInputStream *getSubStreamById(unsigned id); 00042 00043 const unsigned char *read(unsigned long numBytes, unsigned long &numBytesRead); 00044 int seek(long offset, librevenge::RVNG_SEEK_TYPE seekType); 00045 long tell(); 00046 bool isEnd(); 00047 00048 private: 00049 void assign(const unsigned char *data, unsigned length); 00050 void read(const RVNGInputStreamPtr_t &input, unsigned length); 00051 00052 private: 00053 const unsigned char *m_data; 00054 long m_length; 00055 long m_pos; 00056 }; 00057 00058 } 00059 00060 #endif // IWORKMEMORYSTREAM_H_INCLUDED 00061 00062 /* vim:set shiftwidth=2 softtabstop=2 expandtab: */