LibreOffice Module oox (master) 1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
oox::RelativeInputStream Class Referencefinal

Wraps a BinaryInputStream and provides access to a specific part of the stream data. More...

#include <binaryinputstream.hxx>

Inheritance diagram for oox::RelativeInputStream:
[legend]
Collaboration diagram for oox::RelativeInputStream:
[legend]

Public Member Functions

 RelativeInputStream (BinaryInputStream &rInStrm, sal_Int64 nSize)
 Constructs the wrapper object for the passed stream. More...
 
virtual sal_Int64 size () const override
 Returns the size of the data block in the wrapped stream offered by this wrapper. More...
 
virtual sal_Int64 tell () const override
 Returns the current relative stream position. More...
 
virtual void seek (sal_Int64 nPos) override
 Seeks the stream to the passed relative position, if the wrapped stream is seekable. More...
 
virtual void close () override
 Closes the input stream but not the wrapped stream. More...
 
virtual sal_Int32 readData (StreamDataSequence &orData, sal_Int32 nBytes, size_t nAtomSize=1) override
 Reads nBytes bytes to the passed sequence. More...
 
virtual sal_Int32 readMemory (void *opMem, sal_Int32 nBytes, size_t nAtomSize=1) override
 Reads nBytes bytes to the (existing) buffer opMem. More...
 
virtual void skip (sal_Int32 nBytes, size_t nAtomSize=1) override
 Seeks the stream forward by the passed number of bytes. More...
 
- Public Member Functions inherited from oox::BinaryInputStream
virtual sal_Int32 readData (StreamDataSequence &orData, sal_Int32 nBytes, size_t nAtomSize=1)=0
 Derived classes implement reading nBytes bytes to the passed sequence. More...
 
virtual sal_Int32 readMemory (void *opMem, sal_Int32 nBytes, size_t nAtomSize=1)=0
 Derived classes implement reading nBytes bytes to the (preallocated!) memory buffer opMem. More...
 
virtual void skip (sal_Int32 nBytes, size_t nAtomSize=1)=0
 Derived classes implement seeking the stream forward by the passed number of bytes. More...
 
template<typename Type >
Type readValue ()
 Reads a value from the stream and converts it to platform byte order. More...
 
sal_Int8 readInt8 ()
 
sal_uInt8 readuInt8 ()
 
sal_Int16 readInt16 ()
 
sal_uInt16 readuInt16 ()
 
sal_Int32 readInt32 ()
 
sal_uInt32 readuInt32 ()
 
sal_Int64 readInt64 ()
 
float readFloat ()
 
double readDouble ()
 
unsigned char readuChar ()
 
template<typename Type >
sal_Int32 readArray (Type *opnArray, sal_Int32 nElemCount)
 Reads a (preallocated!) C array of values from the stream. More...
 
template<typename Type >
sal_Int32 readArray (::std::vector< Type > &orVector, sal_Int32 nElemCount)
 Reads a vector of values from the stream. More...
 
OUString readNulUnicodeArray ()
 Reads a NUL-terminated Unicode character array and returns the string. More...
 
OString readCharArray (sal_Int32 nChars)
 Reads a byte character array and returns the string. More...
 
OUString readCharArrayUC (sal_Int32 nChars, rtl_TextEncoding eTextEnc)
 Reads a byte character array and returns a Unicode string. More...
 
OUString readUnicodeArray (sal_Int32 nChars)
 Reads a Unicode character array and returns the string. More...
 
OUString readCompressedUnicodeArray (sal_Int32 nChars, bool bCompressed)
 Reads a Unicode character array (may be compressed) and returns the string. More...
 
void copyToStream (BinaryOutputStream &rOutStrm)
 Copies bytes from the current position to the passed output stream. More...
 
- Public Member Functions inherited from oox::BinaryStreamBase
virtual ~BinaryStreamBase ()
 
virtual sal_Int64 size () const =0
 Implementations return the size of the stream, if possible. More...
 
virtual sal_Int64 tell () const =0
 Implementations return the current stream position, if possible. More...
 
virtual void seek (sal_Int64 nPos)=0
 Implementations seek the stream to the passed position, if the stream is seekable. More...
 
virtual void close ()=0
 Implementations close the stream. More...
 
bool isSeekable () const
 Returns true, if the implementation supports the seek() operation. More...
 
bool isEof () const
 Returns true, if the stream position is invalid (EOF). More...
 
sal_Int64 getRemaining () const
 Returns the size of the remaining data available in the stream, if stream supports size() and tell(), otherwise -1. More...
 
void seekToStart ()
 Seeks the stream to the beginning, if stream is seekable. More...
 
void alignToBlock (sal_Int32 nBlockSize, sal_Int64 nAnchorPos)
 Seeks the stream forward to a position that is a multiple of the passed block size, if stream is seekable. More...
 

Private Member Functions

sal_Int32 getMaxBytes (sal_Int32 nBytes) const
 Returns the number of bytes available in the sequence for the passed byte count. More...
 

Private Attributes

BinaryInputStreammpInStrm
 
sal_Int64 mnStartPos
 
sal_Int64 mnRelPos
 
sal_Int64 mnSize
 

Additional Inherited Members

- Protected Member Functions inherited from oox::BinaryInputStream
 BinaryInputStream ()
 This dummy default c'tor will never call the c'tor of the virtual base class BinaryStreamBase as this class cannot be instantiated directly. More...
 
- Protected Member Functions inherited from oox::BinaryStreamBase
 BinaryStreamBase (bool bSeekable)
 
- Protected Attributes inherited from oox::BinaryStreamBase
bool mbEof
 End of stream flag. More...
 

Detailed Description

Wraps a BinaryInputStream and provides access to a specific part of the stream data.

Provides access to the stream data block starting at the current position of the stream, and with a specific length. If the wrapped stream is seekable, this wrapper will treat the position of the wrapped stream at construction time as position "0" (therefore the class name).

The passed input stream MUST live at least as long as this stream wrapper. The stream MUST NOT be changed from outside as long as this stream wrapper is used to read from it.

Definition at line 327 of file binaryinputstream.hxx.

Constructor & Destructor Documentation

◆ RelativeInputStream()

oox::RelativeInputStream::RelativeInputStream ( BinaryInputStream rInStrm,
sal_Int64  nSize 
)
explicit

Constructs the wrapper object for the passed stream.

Parameters
nSizeIf specified, restricts the amount of data that can be read from the passed input stream.

Definition at line 246 of file binaryinputstream.cxx.

References oox::BinaryStreamBase::getRemaining(), oox::BinaryStreamBase::isEof(), oox::BinaryStreamBase::mbEof, and mnSize.

Member Function Documentation

◆ close()

void oox::RelativeInputStream::close ( )
overridevirtual

Closes the input stream but not the wrapped stream.

Implements oox::BinaryStreamBase.

Definition at line 277 of file binaryinputstream.cxx.

References oox::BinaryStreamBase::mbEof, and mpInStrm.

◆ getMaxBytes()

sal_Int32 oox::RelativeInputStream::getMaxBytes ( sal_Int32  nBytes) const
inlineprivate

Returns the number of bytes available in the sequence for the passed byte count.

Definition at line 370 of file binaryinputstream.hxx.

References mnRelPos, and mnSize.

Referenced by readData(), readMemory(), and skip().

◆ readData()

sal_Int32 oox::RelativeInputStream::readData ( StreamDataSequence orData,
sal_Int32  nBytes,
size_t  nAtomSize = 1 
)
overridevirtual

Reads nBytes bytes to the passed sequence.

Does not read out of the data block whose size has been specified on construction.

Returns
Number of bytes really read.

Implements oox::BinaryInputStream.

Definition at line 283 of file binaryinputstream.cxx.

References getMaxBytes(), oox::BinaryStreamBase::isEof(), oox::BinaryStreamBase::mbEof, mnRelPos, mpInStrm, and oox::BinaryInputStream::readData().

◆ readMemory()

sal_Int32 oox::RelativeInputStream::readMemory ( void *  opMem,
sal_Int32  nBytes,
size_t  nAtomSize = 1 
)
overridevirtual

Reads nBytes bytes to the (existing) buffer opMem.

Does not read out of the data block whose size has been specified on construction.

Returns
Number of bytes really read.

Implements oox::BinaryInputStream.

Definition at line 296 of file binaryinputstream.cxx.

References getMaxBytes(), oox::BinaryStreamBase::isEof(), oox::BinaryStreamBase::mbEof, mnRelPos, mpInStrm, and oox::BinaryInputStream::readMemory().

◆ seek()

void oox::RelativeInputStream::seek ( sal_Int64  nPos)
overridevirtual

Seeks the stream to the passed relative position, if the wrapped stream is seekable.

Implements oox::BinaryStreamBase.

Definition at line 267 of file binaryinputstream.cxx.

References oox::BinaryStreamBase::isEof(), oox::BinaryStreamBase::isSeekable(), oox::BinaryStreamBase::mbEof, mnRelPos, mnSize, mnStartPos, mpInStrm, nPos, and oox::BinaryStreamBase::seek().

◆ size()

sal_Int64 oox::RelativeInputStream::size ( ) const
overridevirtual

Returns the size of the data block in the wrapped stream offered by this wrapper.

Implements oox::BinaryStreamBase.

Definition at line 257 of file binaryinputstream.cxx.

References mnSize, and mpInStrm.

◆ skip()

void oox::RelativeInputStream::skip ( sal_Int32  nBytes,
size_t  nAtomSize = 1 
)
overridevirtual

Seeks the stream forward by the passed number of bytes.

This works for non-seekable streams too. Does not seek out of the data block.

Implements oox::BinaryInputStream.

Definition at line 309 of file binaryinputstream.cxx.

References getMaxBytes(), oox::BinaryStreamBase::mbEof, mnRelPos, mpInStrm, and oox::BinaryInputStream::skip().

◆ tell()

sal_Int64 oox::RelativeInputStream::tell ( ) const
overridevirtual

Returns the current relative stream position.

Implements oox::BinaryStreamBase.

Definition at line 262 of file binaryinputstream.cxx.

References mnRelPos, and mpInStrm.

Member Data Documentation

◆ mnRelPos

sal_Int64 oox::RelativeInputStream::mnRelPos
private

Definition at line 376 of file binaryinputstream.hxx.

Referenced by getMaxBytes(), readData(), readMemory(), seek(), skip(), and tell().

◆ mnSize

sal_Int64 oox::RelativeInputStream::mnSize
private

Definition at line 377 of file binaryinputstream.hxx.

Referenced by getMaxBytes(), RelativeInputStream(), seek(), and size().

◆ mnStartPos

sal_Int64 oox::RelativeInputStream::mnStartPos
private

Definition at line 375 of file binaryinputstream.hxx.

Referenced by seek().

◆ mpInStrm

BinaryInputStream* oox::RelativeInputStream::mpInStrm
private

Definition at line 374 of file binaryinputstream.hxx.

Referenced by close(), readData(), readMemory(), seek(), size(), skip(), and tell().


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