| 1 |
/* -*- Mode: C++; c-default-style: "k&r"; indent-tabs-mode: nil; tab-width: 2; c-basic-offset: 2 -*- */ |
| 2 |
|
| 3 |
/* libmwaw |
| 4 |
* Version: MPL 2.0 / LGPLv2+ |
| 5 |
* |
| 6 |
* The contents of this file are subject to the Mozilla Public License Version |
| 7 |
* 2.0 (the "License"); you may not use this file except in compliance with |
| 8 |
* the License or as specified alternatively below. You may obtain a copy of |
| 9 |
* the License at http://www.mozilla.org/MPL/ |
| 10 |
* |
| 11 |
* Software distributed under the License is distributed on an "AS IS" basis, |
| 12 |
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| 13 |
* for the specific language governing rights and limitations under the |
| 14 |
* License. |
| 15 |
* |
| 16 |
* Alternatively, the contents of this file may be used under the terms of |
| 17 |
* the GNU Lesser General Public License Version 2 or later (the "LGPLv2+"), |
| 18 |
* in which case the provisions of the LGPLv2+ are applicable |
| 19 |
* instead of those above. |
| 20 |
*/ |
| 21 |
|
| 22 |
#ifndef MWAW_STRING_STREAM_HXX |
| 23 |
#define MWAW_STRING_STREAM_HXX |
| 24 |
|
| 25 |
#include <memory> |
| 26 |
|
| 27 |
#include <librevenge-stream/librevenge-stream.h> |
| 28 |
|
| 29 |
class MWAWStringStreamPrivate; |
| 30 |
|
| 31 |
/** internal class used to create a RVNGInputStream from a unsigned char's pointer |
| 32 |
|
| 33 |
\note this class (highly inspired from librevenge) does not |
| 34 |
implement the isStructured's protocol, ie. it only returns false. |
| 35 |
*/ |
| 36 |
class MWAWStringStream final : public librevenge::RVNGInputStream |
| 37 |
{ |
| 38 |
public: |
| 39 |
//! constructor |
| 40 |
MWAWStringStream(const unsigned char *data, const unsigned int dataSize); |
| 41 |
//! destructor |
| 42 |
~MWAWStringStream() final; |
| 43 |
|
| 44 |
//! append some data at the end of the string |
| 45 |
void append(const unsigned char *data, const unsigned int dataSize); |
| 46 |
//! resize the buffer stream (very low level) |
| 47 |
void resize(unsigned long newSize); |
| 48 |
|
| 49 |
/**! reads numbytes data. |
| 50 |
|
| 51 |
* \return a pointer to the read elements |
| 52 |
*/ |
| 53 |
const unsigned char *read(unsigned long numBytes, unsigned long &numBytesRead) final; |
| 54 |
//! returns actual offset position |
| 55 |
long tell() final; |
| 56 |
/*! \brief seeks to a offset position, from actual, beginning or ending position |
| 57 |
* \return 0 if ok |
| 58 |
*/ |
| 59 |
int seek(long offset, librevenge::RVNG_SEEK_TYPE seekType) final; |
| 60 |
//! returns true if we are at the end of the section/file |
| 61 |
bool isEnd() final; |
| 62 |
|
| 63 |
/** returns true if the stream is ole |
| 64 |
|
| 65 |
\sa returns always false*/ |
| 66 |
bool isStructured() final; |
| 67 |
/** returns the number of sub streams. |
| 68 |
|
| 69 |
\sa returns always 0*/ |
| 70 |
unsigned subStreamCount() final; |
| 71 |
/** returns the ith sub streams name |
| 72 |
|
| 73 |
\sa returns always 0*/ |
| 74 |
const char *subStreamName(unsigned) final; |
| 75 |
/** returns true if a substream with name exists |
| 76 |
|
| 77 |
\sa returns always false*/ |
| 78 |
bool existsSubStream(const char *name) final; |
| 79 |
/** return a new stream for a ole zone |
| 80 |
|
| 81 |
\sa returns always 0 */ |
| 82 |
librevenge::RVNGInputStream *getSubStreamByName(const char *name) final; |
| 83 |
/** return a new stream for a ole zone |
| 84 |
|
| 85 |
\sa returns always 0 */ |
| 86 |
librevenge::RVNGInputStream *getSubStreamById(unsigned) final; |
| 87 |
|
| 88 |
private: |
| 89 |
/// the string stream data |
| 90 |
std::shared_ptr<MWAWStringStreamPrivate> m_data; |
| 91 |
MWAWStringStream(const MWAWStringStream &) = delete; // copy is not allowed |
| 92 |
MWAWStringStream &operator=(const MWAWStringStream &) = delete; // assignment is not allowed |
| 93 |
}; |
| 94 |
|
| 95 |
#endif |
| 96 |
|
| 97 |
// vim: set filetype=cpp tabstop=2 shiftwidth=2 cindent autoindent smartindent noexpandtab: |