23#include <com/sun/star/io/XSeekable.hpp>
39 sal_Int64 nLen =
size();
40 return ((
nPos >= 0) && (nLen >= 0)) ? ::std::max< sal_Int64 >( nLen -
nPos, 0 ) : -1;
45 sal_Int64 nStrmPos =
tell();
47 if(
mbSeekable && (0 <= nAnchorPos) && (nAnchorPos != nStrmPos) && (nBlockSize > 1) )
50 sal_Int64 nSkipSize = (nAnchorPos < nStrmPos) ?
51 (nBlockSize - ((nStrmPos - nAnchorPos - 1) % nBlockSize) - 1) :
52 ((nAnchorPos - nStrmPos) % nBlockSize);
53 seek( nStrmPos + nSkipSize );
133 mnPos = getLimitedValue< sal_Int32, sal_Int64 >(
nPos, 0,
mpData->getLength() );
Base class for binary stream classes.
virtual sal_Int64 size() const =0
Implementations return the size of the stream, if possible.
void alignToBlock(sal_Int32 nBlockSize, sal_Int64 nAnchorPos)
Seeks the stream forward to a position that is a multiple of the passed block size,...
const bool mbSeekable
True = implementation supports seeking.
sal_Int64 getRemaining() const
Returns the size of the remaining data available in the stream, if stream supports size() and tell(),...
virtual ~BinaryStreamBase()
virtual sal_Int64 tell() const =0
Implementations return the current stream position, if possible.
virtual void seek(sal_Int64 nPos)=0
Implementations seek the stream to the passed position, if the stream is seekable.
bool mbEof
End of stream flag.
BinaryXSeekableStream(const css::uno::Reference< css::io::XSeekable > &rxSeekable)
virtual ~BinaryXSeekableStream() override
virtual void close() override
Releases the reference to the UNO XSeekable interface.
virtual sal_Int64 tell() const override
Returns the current stream position, if wrapped stream is seekable, otherwise -1.
css::uno::Reference< css::io::XSeekable > mxSeekable
Stream seeking interface.
virtual sal_Int64 size() const override
Returns the size of the stream, if wrapped stream is seekable, otherwise -1.
virtual void seek(sal_Int64 nPos) override
Seeks the stream to the passed position, if wrapped stream is seekable.
sal_Int32 mnPos
Current position in the sequence.
virtual void close() override
Releases the reference to the data sequence.
virtual void seek(sal_Int64 nPos) override
Seeks the stream to the passed position.
SequenceSeekableStream(const StreamDataSequence &rData)
virtual sal_Int64 size() const override
Returns the size of the wrapped data sequence.
virtual sal_Int64 tell() const override
Returns the current stream position.
const StreamDataSequence * mpData
Wrapped data sequence.
#define TOOLS_WARN_EXCEPTION(area, stream)
css::uno::Sequence< sal_Int8 > StreamDataSequence
Reference< XSeekable > mxSeekable