22#include <com/sun/star/io/XOutputStream.hpp>
23#include <com/sun/star/io/XSeekable.hpp>
24#include <osl/diagnose.h>
34const sal_Int32 OUTPUTSTREAM_BUFFERSIZE = 0x8000;
41 maBuffer( OUTPUTSTREAM_BUFFERSIZE ),
43 mbAutoClose( bAutoClose && rxOutStrm.is() )
64 OSL_FAIL(
"BinaryXOutputStream::close - closing output stream failed" );
79 OSL_FAIL(
"BinaryXOutputStream::writeData - stream read error" );
88 sal_Int32 nBufferSize = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, (OUTPUTSTREAM_BUFFERSIZE / nAtomSize) * nAtomSize );
92 sal_Int32 nWriteSize = getLimitedValue< sal_Int32, sal_Int32 >( nBytes, 0, nBufferSize );
94 memcpy(
maBuffer.getArray(), pnMem,
static_cast< size_t >( nWriteSize ) );
105 sBuf = sBuf.replace(
'\0',
'?' );
106 writeMemory(
static_cast< const void*
>( sBuf.getStr() ), sBuf.getLength() );
112 OUString sBuf = rString.replace(
'\0',
'?' );
116 memcpy( notConst, sBuf.getStr(),
sizeof(
sal_Unicode)*sBuf.getLength() );
119 writeArray( sBuf.getStr(), sBuf.getLength() );
141 if(
mpData && rData.hasElements() )
142 writeMemory( rData.getConstArray(), rData.getLength(), nAtomSize );
147 if(
mpData && (nBytes > 0) )
151 memcpy(
mpData->getArray() +
mnPos, pMem,
static_cast< size_t >( nBytes ) );
170 mnPos = getLimitedValue< sal_Int32, sal_Int64 >(
nPos, 0,
mpData->getLength() );
void writeCharArrayUC(std::u16string_view rString, rtl_TextEncoding eTextEnc)
virtual void writeMemory(const void *pMem, sal_Int32 nBytes, size_t nAtomSize=1)=0
Derived classes implement writing the contents of the (preallocated!) memory buffer pMem.
void writeCompressedUnicodeArray(const OUString &rString, bool bCompressed)
void writeArray(Type *opnArray, sal_Int32 nElemCount)
void writeUnicodeArray(const OUString &rString)
Base class for binary stream classes.
bool mbEof
End of stream flag.
BinaryXOutputStream(const css::uno::Reference< css::io::XOutputStream > &rxOutStrm, bool bAutoClose)
Constructs the wrapper object for the passed output stream.
virtual void writeData(const StreamDataSequence &rData, size_t nAtomSize=1) override
Writes the passed data sequence.
StreamDataSequence maBuffer
Data buffer used in writeMemory() function.
css::uno::Reference< css::io::XOutputStream > mxOutStrm
Reference to the output stream.
virtual ~BinaryXOutputStream() override
void close() override
Flushes and closes the output stream.
virtual void writeMemory(const void *pMem, sal_Int32 nBytes, size_t nAtomSize=1) override
Write nBytes bytes from the (preallocated!) buffer pMem.
bool mbAutoClose
True = automatically close stream on destruction.
Base class for binary input and output streams wrapping a UNO stream, seekable via the com....
virtual void close() override
Releases the reference to the UNO XSeekable interface.
virtual sal_Int64 tell() const override
Returns the current stream position.
StreamDataSequence * mpData
Wrapped data sequence.
virtual void close() override
Releases the reference to the data sequence.
SequenceOutputStream(StreamDataSequence &rData)
Constructs the wrapper object for the passed data sequence.
virtual sal_Int64 size() const override
Returns the size of the wrapped data sequence.
virtual void seek(sal_Int64 nPos) override
Seeks the stream to the passed position.
sal_Int32 mnPos
Current position in the sequence.
virtual void writeData(const StreamDataSequence &rData, size_t nAtomSize=1) override
Writes the passed data sequence.
virtual void writeMemory(const void *pMem, sal_Int32 nBytes, size_t nAtomSize=1) override
Write nBytes bytes from the (preallocated!) buffer pMem.
css::uno::Sequence< sal_Int8 > StreamDataSequence
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
Reference< XOutputStream > mxOutStrm