MWAWInputStream Class Reference documentation

Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
MWAWInputStream Class Reference

Internal class used to read the file stream Internal class used to read the file stream, this class adds some usefull functions to the basic librevenge::RVNGInputStream: More...

`#include <MWAWInputStream.hxx>`

## Public Member Functions
| MWAWInputStream (std::shared_ptr< librevenge::RVNGInputStream > input, bool inverted)
| creates a stream with given endian More...
| MWAWInputStream (librevenge::RVNGInputStream *input, bool inverted, bool checkCompression=false)
| creates a stream with given endian from an existing input More...
| ~MWAWInputStream ()
| destructor More...
std::shared_ptr< librevenge::RVNGInputStream > | input ()
| returns the basic librevenge::RVNGInputStream More...
bool | readInverted () const
| returns the endian mode (see constructor) More...
void | setReadInverted (bool newVal)
| sets the endian mode More...
int | seek (long offset, librevenge::RVNG_SEEK_TYPE seekType)
| seeks to a offset position, from actual, beginning or ending position More...
long | tell ()
| returns actual offset position More...
long | size () const
| returns the stream size More...
bool | checkPosition (long pos) const
| checks if a position is or not a valid file position More...
bool | isEnd ()
| returns true if we are at the end of the section/file More...
void | pushLimit (long newLimit)
| defines a new section in the file (from actualPos to newLimit) next call of seek, tell, atEos, ... will be restrained to this section More...
void | popLimit ()
| pops a section defined by pushLimit More...
void | recomputeStreamSize ()
unsigned long | readULong (int num)
| returns a uint8, uint16, uint32 readed from actualPos More...
long | readLong (int num)
| return a int8, int16, int32 readed from actualPos More...
bool | readDouble8 (double &res, bool &isNotANumber)
| try to read a double of size 8: 1.5 bytes exponent, 6.5 bytes mantisse More...
bool | readDoubleReverted8 (double &res, bool &isNotANumber)
| try to read a double of size 8: 6.5 bytes mantisse, 1.5 bytes exponent More...
bool | readDouble10 (double &res, bool &isNotANumber)
| try to read a double of size 10: 2 bytes exponent, 8 bytes mantisse More...
const uint8_t * | read (size_t numBytes, unsigned long &numBytesRead)
| ! reads numbytes data, WITHOUT using any endian or section consideration More...
bool | readDataBlock (long size, librevenge::RVNGBinaryData &data)
| reads a librevenge::RVNGBinaryData with a given size in the actual section/file More...
bool | readEndDataBlock (librevenge::RVNGBinaryData &data)
| reads a librevenge::RVNGBinaryData from actPos to the end of the section/file More...
bool | isStructured ()
| return true if the stream is ole More...
unsigned | subStreamCount ()
| returns the number of substream More...
std::string | subStreamName (unsigned id)
| returns the name of the i^th substream More...
std::shared_ptr< MWAWInputStream > | getSubStreamByName (std::string const &name)
| return a new stream for a ole zone More...
std::shared_ptr< MWAWInputStream > | getSubStreamById (unsigned id)
| return a new stream for a ole zone More...
bool | getFinderInfo (std::string &type, std::string &creator) const
| returns the finder info type and creator (if known) More...
bool | hasDataFork () const
| returns true if the data fork block exists More...
bool | hasResourceFork () const
| returns true if the resource fork block exists More...
std::shared_ptr< MWAWInputStream > | getResourceForkStream ()
| returns the resource fork if find More...

## Static Public Member Functions
static std::shared_ptr< MWAWInputStream > | get (librevenge::RVNGBinaryData const &data, bool inverted)
| returns a new input stream corresponding to a librevenge::RVNGBinaryData More...
static unsigned long | readULong (librevenge::RVNGInputStream *stream, int num, unsigned long a, bool inverseRead)
| internal function used to read num byte, More...

## Protected Member Functions
void | updateStreamSize ()
| update the stream size ( must be called in the constructor ) More...
bool | unBinHex ()
| unbinhex the data in the file is a BinHex 4.0 file of a mac file More...
bool | unzipStream ()
| unzip the data in the file is a zip file of a mac file More...
bool | unMacMIME ()
| check if some stream are in MacMIME format, if so de MacMIME More...
bool | unMacMIME (MWAWInputStream *input, std::shared_ptr< librevenge::RVNGInputStream > &dataInput, std::shared_ptr< librevenge::RVNGInputStream > &rsrcInput) const
| de MacMIME an input stream More...
bool | unsplitInternalMergeStream ()
| check if a stream is an internal merge stream More...

## Static Protected Member Functions
static uint8_t | readU8 (librevenge::RVNGInputStream *stream)
| internal function used to read a byte More...

## Protected Attributes
std::shared_ptr< librevenge::RVNGInputStream > | m_stream
| the initial input More...
long | m_streamSize
| the stream size More...
long | m_readLimit
| actual section limit (-1 if no limit) More...
std::vector< long > | m_prevLimits
| list of previous limits More...
std::string | m_fInfoType
| finder info type More...
std::string | m_fInfoCreator
| finder info type More...
std::shared_ptr< MWAWInputStream > | m_resourceFork
| the resource fork More...
bool | m_inverseRead
| big or normal endian More...

## Private Member Functions
| MWAWInputStream (MWAWInputStream const &orig)=delete
MWAWInputStream & | operator= (MWAWInputStream const &orig)=delete

## Detailed Description

Internal class used to read the file stream Internal class used to read the file stream, this class adds some usefull functions to the basic librevenge::RVNGInputStream:

- read number (int8, int16, int32) in low or end endian
- selection of a section of a stream
- read block of data
- interface with modified librevenge::RVNGOLEStream

## Constructor & Destructor Documentation

## ◆ MWAWInputStream() [1/3]

MWAWInputStream::MWAWInputStream | ( | std::shared_ptr< librevenge::RVNGInputStream > | input,
|  | bool | inverted
| ) |  |

creates a stream with given endian

Parameters

  input | the given input
  inverted | must be set to true for pc doc and ole part and to false for mac doc

Referenced by get(), getSubStreamById(), getSubStreamByName(), unBinHex(), unMacMIME(), unsplitInternalMergeStream(), and unzipStream().

## ◆ MWAWInputStream() [2/3]

MWAWInputStream::MWAWInputStream | ( | librevenge::RVNGInputStream * | input,
|  | bool | inverted,
|  | bool | checkCompression = `false`
| ) |  |

creates a stream with given endian from an existing input

Note: this functions does not delete input

## ◆ ~MWAWInputStream()

MWAWInputStream::~MWAWInputStream | ( |  | ) |

destructor

## ◆ MWAWInputStream() [3/3]

MWAWInputStream::MWAWInputStream | ( | MWAWInputStream const & | orig | ) |
| privatedelete

## Member Function Documentation

## ◆ checkPosition()

bool MWAWInputStream::checkPosition | ( | long | pos | ) | const
| inline

checks if a position is or not a valid file position

Referenced by ApplePictParserInternal::ColorTable::read(), libmwaw_applepict1::Region::read(), and libmwaw_applepict1::OpCode::readText().

## ◆ get()

std::shared_ptr< MWAWInputStream > MWAWInputStream::get | ( | librevenge::RVNGBinaryData const & | data,
|  | bool | inverted
| ) |  |
| static

returns a new input stream corresponding to a librevenge::RVNGBinaryData

Referenced by HanMacWrdJText::computeNumPages(), libmwaw_applepict1::PictParser::convertToPict2(), MacDocParser::createZones(), HanMacWrdKParser::decodeZone(), LightWayTxtGraph::findJPEGSize(), MWAWOLEParser::parse(), WriteNowText::send(), NisusWrtGraph::sendPageGraphics(), LightWayTxtGraph::sendPICT(), TeachTxtParser::sendPicture(), EDocParser::sendPicture(), NisusWrtGraph::sendPicture(), DocMkrParser::sendPicture(), MacDocParser::sendPicture(), MacWrtProParser::sendPicture(), HanMacWrdJText::sendText(), and FullWrtStruct::Entry::update().

## ◆ getFinderInfo()

bool MWAWInputStream::getFinderInfo | ( | std::string & | type,
|  | std::string & | creator
| ) |  | const
| inline

returns the finder info type and creator (if known)

## ◆ getResourceForkStream()

std::shared_ptr<MWAWInputStream> MWAWInputStream::getResourceForkStream | ( |  | ) |
| inline

returns the resource fork if find

Referenced by unBinHex().

## ◆ getSubStreamById()

std::shared_ptr< MWAWInputStream > MWAWInputStream::getSubStreamById | ( | unsigned | id | ) |

return a new stream for a ole zone

## ◆ getSubStreamByName()

std::shared_ptr< MWAWInputStream > MWAWInputStream::getSubStreamByName | ( | std::string const & | name | ) |

return a new stream for a ole zone

## ◆ hasDataFork()

bool MWAWInputStream::hasDataFork | ( |  | ) | const
| inline

returns true if the data fork block exists

Referenced by isEnd(), read(), readDataBlock(), readEndDataBlock(), seek(), tell(), unBinHex(), and unMacMIME().

## ◆ hasResourceFork()

bool MWAWInputStream::hasResourceFork | ( |  | ) | const
| inline

returns true if the resource fork block exists

## ◆ input()

std::shared_ptr<librevenge::RVNGInputStream> MWAWInputStream::input | ( |  | ) |
| inline

returns the basic librevenge::RVNGInputStream

## ◆ isEnd()

bool MWAWInputStream::isEnd | ( |  | ) |

returns true if we are at the end of the section/file

Referenced by ApplePictParserInternal::Pixmap::computeHeight(), libmwaw_applepict1::Bitmap::read(), ApplePictParserInternal::Bitmap::readBitmapData(), libmwaw_applepict1::Bitmap::readBitmapData(), WriteNowText::readParagraph(), WriteNowText::readTable(), WriteNowText::readTokenV2(), readULong(), unBinHex(), and unMacMIME().

## ◆ isStructured()

bool MWAWInputStream::isStructured | ( |  | ) |

return true if the stream is ole

Referenced by unsplitInternalMergeStream(), and unzipStream().

## ◆ operator=()

MWAWInputStream& MWAWInputStream::operator= | ( | MWAWInputStream const & | orig | ) |
| privatedelete

## ◆ popLimit()

void MWAWInputStream::popLimit | ( |  | ) |
| inline

pops a section defined by pushLimit

## ◆ pushLimit()

void MWAWInputStream::pushLimit | ( | long | newLimit | ) |
| inline

defines a new section in the file (from actualPos to newLimit) next call of seek, tell, atEos, ... will be restrained to this section

## ◆ read()

const uint8_t * MWAWInputStream::read | ( | size_t | numBytes,
|  | unsigned long & | numBytesRead
| ) |  |

! reads numbytes data, WITHOUT using any endian or section consideration

Returns
  a pointer to the read elements

Referenced by ApplePictParserInternal::Bitmap::readBitmapData(), libmwaw_applepict1::Bitmap::readBitmapData(), ApplePictParserInternal::Pixmap::readPixmapData(), MacDraft5StyleManagerInternal::Pixmap::readPixmapData(), unBinHex(), and unMacMIME().

## ◆ readDataBlock()

bool MWAWInputStream::readDataBlock | ( | long | size,
|  | librevenge::RVNGBinaryData & | data
| ) |  |

reads a librevenge::RVNGBinaryData with a given size in the actual section/file

Referenced by readEndDataBlock().

## ◆ readDouble10()

bool MWAWInputStream::readDouble10 | ( | double & | res,
|  | bool & | isNotANumber
| ) |  |

try to read a double of size 10: 2 bytes exponent, 8 bytes mantisse

## ◆ readDouble8()

bool MWAWInputStream::readDouble8 | ( | double & | res,
|  | bool & | isNotANumber
| ) |  |

try to read a double of size 8: 1.5 bytes exponent, 6.5 bytes mantisse

## ◆ readDoubleReverted8()

bool MWAWInputStream::readDoubleReverted8 | ( | double & | res,
|  | bool & | isNotANumber
| ) |  |

try to read a double of size 8: 6.5 bytes mantisse, 1.5 bytes exponent

## ◆ readEndDataBlock()

bool MWAWInputStream::readEndDataBlock | ( | librevenge::RVNGBinaryData & | data | ) |

reads a librevenge::RVNGBinaryData from actPos to the end of the section/file

## ◆ readInverted()

bool MWAWInputStream::readInverted | ( |  | ) | const
| inline

returns the endian mode (see constructor)

## ◆ readLong()

long MWAWInputStream::readLong | ( | int | num | ) |

return a int8, int16, int32 readed from actualPos

Referenced by ApplePictParserInternal::ColorTable::read(), libmwaw_applepict1::Region::read(), libmwaw_applepict1::Bitmap::read(), WriteNowText::readFont(), libmwaw_applepict1::OpCode::readInt(), WriteNowText::readParagraph(), WriteNowText::readTable(), WriteNowText::readToken(), WriteNowText::readTokenV2(), and unBinHex().

## ◆ readU8()

uint8_t MWAWInputStream::readU8 | ( | librevenge::RVNGInputStream * | stream | ) |
| staticprotected

internal function used to read a byte

Referenced by readULong(), and unBinHex().

## ◆ readULong() [1/2]

unsigned long MWAWInputStream::readULong | ( | int | num | ) |
| inline

returns a uint8, uint16, uint32 readed from actualPos

Referenced by ApplePictParserInternal::Pixmap::computeHeight(), libmwaw_applepict1::OpCode::getSize(), ApplePictParserInternal::ColorTable::read(), libmwaw_applepict1::Region::read(), libmwaw_applepict1::Bitmap::read(), ApplePictParserInternal::Bitmap::readBitmapData(), libmwaw_applepict1::Bitmap::readBitmapData(), libmwaw_applepict1::OpCode::readColor(), RagTime5StructManager::readCompressedLong(), RagTime5StructManager::readDataIdList(), readDouble10(), readDouble8(), readDoubleReverted8(), WriteNowText::readFont(), libmwaw_applepict1::OpCode::readInt(), readLong(), ClarisWksGraph::readOLE(), WriteNowText::readParagraph(), libmwaw_applepict1::OpCode::readPattern(), ApplePictParserInternal::Pixmap::readPixmapData(), WriteNowText::readTable(), libmwaw_applepict1::OpCode::readText(), WriteNowText::readToken(), readULong(), unBinHex(), and unMacMIME().

## ◆ readULong() [2/2]

unsigned long MWAWInputStream::readULong | ( | librevenge::RVNGInputStream * | stream,
|  | int | num,
|  | unsigned long | a,
|  | bool | inverseRead
| ) |  |
| static

internal function used to read num byte,

- where a is the previous read data

## ◆ recomputeStreamSize()

void MWAWInputStream::recomputeStreamSize | ( |  | ) |

internal: recomputes the stream size, must be called after you modify the data of the main input

For instance, if this input stream is created from a MWAWStringStream and you decide to add some data in the original MWAWStringStream...

## ◆ seek()

int MWAWInputStream::seek | ( | long | offset,
|  | librevenge::RVNG_SEEK_TYPE | seekType
| ) |  |

seeks to a offset position, from actual, beginning or ending position

Returns
  0 if ok

See also
  pushLimit popLimit

Referenced by ApplePictParserInternal::Pixmap::computeHeight(), libmwaw_applepict1::OpCode::computeSize(), getSubStreamById(), getSubStreamByName(), MWAWInputStream(), ApplePictParserInternal::ColorTable::read(), libmwaw_applepict1::OpCode::readData(), readDouble10(), WriteNowText::readFont(), WriteNowText::readParagraph(), WriteNowText::readTable(), WriteNowText::readToken(), WriteNowText::readTokenV2(), unBinHex(), unMacMIME(), and unzipStream().

## ◆ setReadInverted()

void MWAWInputStream::setReadInverted | ( | bool | newVal | ) |
| inline

sets the endian mode

## ◆ size()

long MWAWInputStream::size | ( |  | ) | const
| inline

returns the stream size

Referenced by ApplePictParserInternal::Pixmap::computeHeight(), isEnd(), readDataBlock(), readEndDataBlock(), seek(), unBinHex(), and unMacMIME().

## ◆ subStreamCount()

unsigned MWAWInputStream::subStreamCount | ( |  | ) |

returns the number of substream

## ◆ subStreamName()

std::string MWAWInputStream::subStreamName | ( | unsigned | id | ) |

returns the name of the i^th substream

## ◆ tell()

long MWAWInputStream::tell | ( |  | ) |

returns actual offset position

Referenced by ApplePictParserInternal::Pixmap::computeHeight(), libmwaw_applepict1::OpCode::computeSize(), libmwaw_applepict1::OpCode::getSize(), getSubStreamById(), getSubStreamByName(), ApplePictParserInternal::ColorTable::read(), libmwaw_applepict1::Region::read(), libmwaw_applepict1::OpCode::readColor(), libmwaw_applepict1::OpCode::readData(), readDataBlock(), readDouble10(), readDouble8(), readDoubleReverted8(), readEndDataBlock(), WriteNowText::readFont(), libmwaw_applepict1::OpCode::readInt(), WriteNowText::readParagraph(), libmwaw_applepict1::OpCode::readPattern(), WriteNowText::readTable(), libmwaw_applepict1::OpCode::readText(), WriteNowText::readToken(), WriteNowText::readTokenV2(), seek(), unMacMIME(), and updateStreamSize().

## ◆ unBinHex()

bool MWAWInputStream::unBinHex | ( |  | ) |
| protected

unbinhex the data in the file is a BinHex 4.0 file of a mac file

Referenced by MWAWInputStream().

## ◆ unMacMIME() [1/2]

bool MWAWInputStream::unMacMIME | ( |  | ) |
| protected

check if some stream are in MacMIME format, if so de MacMIME

Referenced by MWAWInputStream().

## ◆ unMacMIME() [2/2]

bool MWAWInputStream::unMacMIME | ( | MWAWInputStream * | input,
|  | std::shared_ptr< librevenge::RVNGInputStream > & | dataInput,
|  | std::shared_ptr< librevenge::RVNGInputStream > & | rsrcInput
| ) |  | const
| protected

de MacMIME an input stream

## ◆ unsplitInternalMergeStream()

bool MWAWInputStream::unsplitInternalMergeStream | ( |  | ) |
| protected

check if a stream is an internal merge stream

Referenced by MWAWInputStream().

## ◆ unzipStream()

bool MWAWInputStream::unzipStream | ( |  | ) |
| protected

unzip the data in the file is a zip file of a mac file

Referenced by MWAWInputStream().

## ◆ updateStreamSize()

void MWAWInputStream::updateStreamSize | ( |  | ) |
| protected

update the stream size ( must be called in the constructor )

Referenced by MWAWInputStream(), and recomputeStreamSize().

## Member Data Documentation

## ◆ m_fInfoCreator

std::string MWAWInputStream::m_fInfoCreator
| mutableprotected

finder info type

Referenced by getFinderInfo(), unBinHex(), unMacMIME(), and unsplitInternalMergeStream().

## ◆ m_fInfoType

std::string MWAWInputStream::m_fInfoType
| mutableprotected

finder info type

Referenced by getFinderInfo(), unBinHex(), unMacMIME(), and unsplitInternalMergeStream().

## ◆ m_inverseRead

bool MWAWInputStream::m_inverseRead
| protected

big or normal endian

Referenced by getSubStreamById(), getSubStreamByName(), readInverted(), readULong(), setReadInverted(), and unsplitInternalMergeStream().

## ◆ m_prevLimits

std::vector<long> MWAWInputStream::m_prevLimits
| protected

list of previous limits

Referenced by popLimit(), and pushLimit().

## ◆ m_readLimit

long MWAWInputStream::m_readLimit
| protected

actual section limit (-1 if no limit)

Referenced by checkPosition(), isEnd(), popLimit(), pushLimit(), readDataBlock(), readDouble10(), readDouble8(), readDoubleReverted8(), readEndDataBlock(), and seek().

## ◆ m_resourceFork

std::shared_ptr<MWAWInputStream> MWAWInputStream::m_resourceFork
| protected

the resource fork

Referenced by getResourceForkStream(), hasResourceFork(), MWAWInputStream(), unBinHex(), unMacMIME(), unsplitInternalMergeStream(), and unzipStream().

## ◆ m_stream

std::shared_ptr<librevenge::RVNGInputStream> MWAWInputStream::m_stream
| protected

the initial input

Referenced by getSubStreamById(), getSubStreamByName(), hasDataFork(), input(), isEnd(), isStructured(), MWAWInputStream(), read(), readDataBlock(), readDouble10(), readDouble8(), readDoubleReverted8(), readULong(), seek(), subStreamCount(), subStreamName(), tell(), unBinHex(), unMacMIME(), unsplitInternalMergeStream(), unzipStream(), and updateStreamSize().

## ◆ m_streamSize

long MWAWInputStream::m_streamSize
| protected

the stream size

Referenced by checkPosition(), pushLimit(), readDouble10(), readDouble8(), readDoubleReverted8(), recomputeStreamSize(), seek(), size(), and updateStreamSize().

The documentation for this class was generated from the following files:

- MWAWInputStream.hxx
- MWAWInputStream.cxx