LibreOffice Module tools (master) 1
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
SvMemoryStream Class Reference

#include <stream.hxx>

Inheritance diagram for SvMemoryStream:
[legend]
Collaboration diagram for SvMemoryStream:
[legend]

Public Member Functions

 SvMemoryStream (void *pBuf, std::size_t nSize, StreamMode eMode)
 
 SvMemoryStream (std::size_t nInitSize=512, std::size_t nResize=64)
 
virtual ~SvMemoryStream () override
 
virtual void ResetError () override
 
sal_uInt64 GetSize ()
 
std::size_t GetEndOfData () const
 
const void * GetData ()
 
void * SwitchBuffer ()
 
void SetBuffer (void *pBuf, std::size_t nSize, std::size_t nEOF)
 
void ObjectOwnsMemory (bool bOwn)
 
void MakeReadOnly ()
 Makes the stream read-only after it was (possibly) initially writable, without having to copy the data or change buffers. More...
 
void SetResizeOffset (std::size_t nNewResize)
 
virtual sal_uInt64 TellEnd () override
 
- Public Member Functions inherited from SvStream
 SvStream ()
 
 SvStream (SvLockBytes *pLockBytes)
 
virtual ~SvStream ()
 
SvLockBytesGetLockBytes () const
 
ErrCode GetError () const
 
ErrCode const & GetErrorCode () const
 
void SetError (ErrCode nErrorCode)
 
virtual void ResetError ()
 
void SetEndian (SvStreamEndian SvStreamEndian)
 
SvStreamEndian GetEndian () const
 
bool IsEndianSwap () const
 returns status of endian swap flag More...
 
void SetCompressMode (SvStreamCompressFlags nNewMode)
 
SvStreamCompressFlags GetCompressMode () const
 
void SetCryptMaskKey (const OString &rCryptMaskKey)
 
void SetStreamCharSet (rtl_TextEncoding eCharSet)
 
rtl_TextEncoding GetStreamCharSet () const
 
void SetLineDelimiter (LineEnd eLineEnd)
 
LineEnd GetLineDelimiter () const
 
SvStreamReadUInt16 (sal_uInt16 &rUInt16)
 
SvStreamReadUInt32 (sal_uInt32 &rUInt32)
 
SvStreamReadUInt64 (sal_uInt64 &rUInt64)
 
SvStreamReadInt16 (sal_Int16 &rInt16)
 
SvStreamReadInt32 (sal_Int32 &rInt32)
 
SvStreamReadInt64 (sal_Int64 &rInt64)
 
SvStreamReadSChar (signed char &rChar)
 
SvStreamReadChar (char &rChar)
 
SvStreamReadUChar (unsigned char &rChar)
 
SvStreamReadUtf16 (sal_Unicode &rUtf16)
 
SvStreamReadCharAsBool (bool &rBool)
 
SvStreamReadFloat (float &rFloat)
 
SvStreamReadDouble (double &rDouble)
 
SvStreamReadStream (SvStream &rStream)
 
SvStreamWriteUInt16 (sal_uInt16 nUInt16)
 
SvStreamWriteUInt32 (sal_uInt32 nUInt32)
 
SvStreamWriteUInt64 (sal_uInt64 nuInt64)
 
SvStreamWriteInt16 (sal_Int16 nInt16)
 
SvStreamWriteInt32 (sal_Int32 nInt32)
 
SvStreamWriteInt64 (sal_Int64 nInt64)
 
SvStreamWriteUInt8 (sal_uInt8 nuInt8)
 
SvStreamWriteUnicode (sal_Unicode)
 
SvStreamWriteOString (std::string_view rStr)
 
SvStreamWriteStream (SvStream &rStream)
 
sal_uInt64 WriteStream (SvStream &rStream, sal_uInt64 nSize)
 
SvStreamWriteBool (bool b)
 
SvStreamWriteSChar (signed char nChar)
 
SvStreamWriteChar (char nChar)
 
SvStreamWriteUChar (unsigned char nChar)
 
SvStreamWriteFloat (float nFloat)
 
SvStreamWriteDouble (const double &rDouble)
 
template<typename N >
SvStreamWriteNumberAsString (N n)
 
std::size_t ReadBytes (void *pData, std::size_t nSize)
 
std::size_t WriteBytes (const void *pData, std::size_t nSize)
 
sal_uInt64 Seek (sal_uInt64 nPos)
 
sal_uInt64 SeekRel (sal_Int64 nPos)
 
sal_uInt64 Tell () const
 
virtual sal_uInt64 TellEnd ()
 
sal_uInt64 remainingSize ()
 
void FlushBuffer ()
 If we have data in our internal buffers, write them out. More...
 
void Flush ()
 Call FlushBuffer() and then call flush on the underlying OS stream. More...
 
bool SetStreamSize (sal_uInt64 nSize)
 
bool ReadLine (OStringBuffer &rStr, sal_Int32 nMaxBytesToRead=0xFFFE)
 Read a line of bytes. More...
 
bool ReadLine (OString &rStr, sal_Int32 nMaxBytesToRead=0xFFFE)
 
bool WriteLine (std::string_view rStr)
 
bool ReadByteStringLine (OUString &rStr, rtl_TextEncoding eSrcCharSet, sal_Int32 nMaxBytesToRead=0xFFFE)
 Read a line of bytes. More...
 
bool WriteByteStringLine (std::u16string_view rStr, rtl_TextEncoding eDestCharSet)
 
void StartWritingUnicodeText ()
 Switch to no endian swapping and write 0xfeff. More...
 
void StartReadingUnicodeText (rtl_TextEncoding eReadBomCharSet)
 If eReadBomCharSet==RTL_TEXTENCODING_DONTKNOW: read 16bit, if 0xfeff do nothing (UTF-16), if 0xfffe switch endian swapping (UTF-16), if 0xefbb or 0xbbef read another byte and check for UTF-8. More...
 
SAL_DLLPRIVATE bool ReadUniStringLine (OUString &rStr, sal_Int32 nMaxCodepointsToRead)
 Read a line of Unicode. More...
 
OUString ReadUniOrByteString (rtl_TextEncoding eSrcCharSet)
 Read a 32bit length prefixed sequence of utf-16 if eSrcCharSet==RTL_TEXTENCODING_UNICODE, otherwise read a 16bit length prefixed sequence of bytes and convert from eSrcCharSet. More...
 
SvStreamWriteUniOrByteString (std::u16string_view rStr, rtl_TextEncoding eDestCharSet)
 Write a 32bit length prefixed sequence of utf-16 if eSrcCharSet==RTL_TEXTENCODING_UNICODE, otherwise convert to eSrcCharSet and write a 16bit length prefixed sequence of bytes. More...
 
bool ReadUniOrByteStringLine (OUString &rStr, rtl_TextEncoding eSrcCharSet, sal_Int32 nMaxCodepointsToRead=0xFFFE)
 Read a line of Unicode if eSrcCharSet==RTL_TEXTENCODING_UNICODE, otherwise read a line of Bytecode and convert from eSrcCharSet. More...
 
bool WriteUnicodeOrByteText (std::u16string_view rStr, rtl_TextEncoding eDestCharSet)
 Write a sequence of Unicode characters if eDestCharSet==RTL_TEXTENCODING_UNICODE, otherwise write a sequence of Bytecodes converted to eDestCharSet. More...
 
bool WriteUnicodeOrByteText (std::u16string_view rStr)
 
bool WriteUniOrByteChar (sal_Unicode ch, rtl_TextEncoding eDestCharSet)
 Write a Unicode character if eDestCharSet==RTL_TEXTENCODING_UNICODE, otherwise write as Bytecode converted to eDestCharSet. More...
 
bool WriteUniOrByteChar (sal_Unicode ch)
 
void SetBufferSize (sal_uInt16 m_nBufSize)
 
sal_uInt16 GetBufferSize () const
 
void RefreshBuffer ()
 
bool IsWritable () const
 
StreamMode GetStreamMode () const
 
sal_Int32 GetVersion () const
 
void SetVersion (sal_Int32 n)
 
bool eof () const
 end of input seen during previous i/o operation More...
 
bool bad () const
 stream is broken More...
 
bool good () const
 Get state. More...
 

Protected Member Functions

virtual std::size_t GetData (void *pData, std::size_t nSize) override
 
virtual std::size_t PutData (const void *pData, std::size_t nSize) override
 
virtual sal_uInt64 SeekPos (sal_uInt64 nPos) override
 
virtual void SetSize (sal_uInt64 nSize) override
 
virtual void FlushData () override
 
void AllocateMemory (std::size_t nSize)
 AllocateMemory must update pBuf accordingly. More...
 
bool ReAllocateMemory (tools::Long nDiff)
 ReAllocateMemory must update the following variables: More...
 
void FreeMemory ()
 Is called when this stream allocated the buffer or the buffer is resized. More...
 
- Protected Member Functions inherited from SvStream
virtual std::size_t GetData (void *pData, std::size_t nSize)
 
virtual std::size_t PutData (const void *pData, std::size_t nSize)
 
virtual sal_uInt64 SeekPos (sal_uInt64 nPos)
 
virtual void FlushData ()
 
virtual void SetSize (sal_uInt64 nSize)
 
SAL_DLLPRIVATE void ClearError ()
 
SAL_DLLPRIVATE void ClearBuffer ()
 
SAL_DLLPRIVATE std::size_t CryptAndWriteBuffer (const void *pStart, std::size_t nLen)
 Encrypt and write. More...
 
SAL_DLLPRIVATE void EncryptBuffer (void *pStart, std::size_t nLen) const
 

Protected Attributes

std::size_t nSize
 
std::size_t nResize
 
std::size_t nPos
 
std::size_t nEndOfData
 
sal_uInt8pBuf
 
bool bOwnsData
 
- Protected Attributes inherited from SvStream
sal_uInt64 m_nBufFilePos
 File position of pBuf[0]. More...
 
StreamMode m_eStreamMode
 
bool m_isWritable
 

Private Member Functions

 SvMemoryStream (const SvMemoryStream &)=delete
 
SvMemoryStreamoperator= (const SvMemoryStream &)=delete
 

Detailed Description

Definition at line 625 of file stream.hxx.

Constructor & Destructor Documentation

◆ SvMemoryStream() [1/3]

SvMemoryStream::SvMemoryStream ( const SvMemoryStream )
privatedelete

◆ SvMemoryStream() [2/3]

SvMemoryStream::SvMemoryStream ( void *  pBuf,
std::size_t  nSize,
StreamMode  eMode 
)

◆ SvMemoryStream() [3/3]

SvMemoryStream::SvMemoryStream ( std::size_t  nInitSize = 512,
std::size_t  nResize = 64 
)

◆ ~SvMemoryStream()

SvMemoryStream::~SvMemoryStream ( )
overridevirtual

Definition at line 1533 of file stream.cxx.

References bOwnsData, SvStream::FlushBuffer(), FreeMemory(), and pBuf.

Member Function Documentation

◆ AllocateMemory()

void SvMemoryStream::AllocateMemory ( std::size_t  nSize)
protected

AllocateMemory must update pBuf accordingly.

  • pBuf: Address of new block

Definition at line 1680 of file stream.cxx.

References pBuf.

Referenced by SvMemoryStream(), and SwitchBuffer().

◆ FlushData()

void SvMemoryStream::FlushData ( )
overrideprotectedvirtual

Reimplemented from SvStream.

Definition at line 1671 of file stream.cxx.

◆ FreeMemory()

void SvMemoryStream::FreeMemory ( )
protected

Is called when this stream allocated the buffer or the buffer is resized.

FreeMemory may need to NULLify handles in derived classes.

Definition at line 1736 of file stream.cxx.

References bOwnsData, and pBuf.

Referenced by ReAllocateMemory(), SetBuffer(), and ~SvMemoryStream().

◆ GetData() [1/2]

const void * SvMemoryStream::GetData ( )
inline

Definition at line 669 of file stream.hxx.

◆ GetData() [2/2]

std::size_t SvMemoryStream::GetData ( void *  pData,
std::size_t  nSize 
)
overrideprotectedvirtual

Reimplemented from SvStream.

Definition at line 1565 of file stream.cxx.

References nCount, nEndOfData, nPos, pBuf, and pData.

◆ GetEndOfData()

std::size_t SvMemoryStream::GetEndOfData ( ) const
inline

Definition at line 668 of file stream.hxx.

◆ GetSize()

sal_uInt64 SvMemoryStream::GetSize ( )
inline

Definition at line 667 of file stream.hxx.

◆ MakeReadOnly()

void SvMemoryStream::MakeReadOnly ( )

Makes the stream read-only after it was (possibly) initially writable, without having to copy the data or change buffers.

Available since: \n LibreOffice 7.5

Definition at line 1781 of file stream.cxx.

References SvStream::FlushBuffer(), SvStream::m_isWritable, nResize, and SvStream::SetBufferSize().

◆ ObjectOwnsMemory()

void SvMemoryStream::ObjectOwnsMemory ( bool  bOwn)
inline

Definition at line 676 of file stream.hxx.

◆ operator=()

SvMemoryStream & SvMemoryStream::operator= ( const SvMemoryStream )
privatedelete

◆ PutData()

std::size_t SvMemoryStream::PutData ( const void *  pData,
std::size_t  nSize 
)
overrideprotectedvirtual

◆ ReAllocateMemory()

bool SvMemoryStream::ReAllocateMemory ( tools::Long  nDiff)
protected

ReAllocateMemory must update the following variables:

  • pBuf: Address of new block
  • nEndOfData: Set to nNewSize-1 , if outside of block Set to 0 , if new block size is 0 bytes
  • nSize: New block size
  • nPos: Set to 0 if position outside of block

Definition at line 1686 of file stream.cxx.

References bOwnsData, FreeMemory(), SvStream::m_isWritable, nEndOfData, nPos, nSize, and pBuf.

Referenced by PutData(), SeekPos(), and SetSize().

◆ ResetError()

void SvMemoryStream::ResetError ( )
overridevirtual

Reimplemented from SvStream.

Definition at line 1675 of file stream.cxx.

References SvStream::ClearError().

Referenced by SetBuffer(), and SwitchBuffer().

◆ SeekPos()

sal_uInt64 SvMemoryStream::SeekPos ( sal_uInt64  nPos)
overrideprotectedvirtual

Reimplemented from SvStream.

Definition at line 1633 of file stream.cxx.

References nEndOfData, nPos, nResize, nSize, ReAllocateMemory(), SAL_MAX_UINT32, and STREAM_SEEK_TO_END.

◆ SetBuffer()

void SvMemoryStream::SetBuffer ( void *  pBuf,
std::size_t  nSize,
std::size_t  nEOF 
)

◆ SetResizeOffset()

void SvMemoryStream::SetResizeOffset ( std::size_t  nNewResize)
inline

Definition at line 681 of file stream.hxx.

◆ SetSize()

void SvMemoryStream::SetSize ( sal_uInt64  nSize)
overrideprotectedvirtual

Reimplemented from SvStream.

Definition at line 1769 of file stream.cxx.

References SvStream::m_isWritable, nSize, ReAllocateMemory(), SvStream::SetError(), and SVSTREAM_INVALID_HANDLE.

◆ SwitchBuffer()

void * SvMemoryStream::SwitchBuffer ( )

◆ TellEnd()

virtual sal_uInt64 SvMemoryStream::TellEnd ( )
inlineoverridevirtual

Reimplemented from SvStream.

Definition at line 682 of file stream.hxx.

Member Data Documentation

◆ bOwnsData

bool SvMemoryStream::bOwnsData
protected

◆ nEndOfData

std::size_t SvMemoryStream::nEndOfData
protected

◆ nPos

std::size_t SvMemoryStream::nPos
protected

◆ nResize

std::size_t SvMemoryStream::nResize
protected

Definition at line 632 of file stream.hxx.

Referenced by MakeReadOnly(), PutData(), SeekPos(), SetBuffer(), SvMemoryStream(), and SwitchBuffer().

◆ nSize

std::size_t SvMemoryStream::nSize
protected

◆ pBuf

sal_uInt8* SvMemoryStream::pBuf
protected

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