inline SvStream& operator<<( SvStream& rStr, SvStrPtr f );
// SvLockBytes
struct SvLockBytesStat
{
std::size_t nSize;
SvLockBytesStat() : nSize(0) {}
};
/** This is only extended by UcbLockBytes in ucb/ and appears to exist toallowUCBtododelayedfeedingofdataintoaSvStreami.e.akindofapipe mechanismtoallowasynchronousfetchingofdata.
*/ class UNLESS_MERGELIBS(TOOLS_DLLPUBLIC) SvLockBytes: public SvRefBase
{ bool m_bSync;
// buffer management
std::unique_ptr<sal_uInt8[]>
m_pRWBuf; ///< Points to read/write buffer
sal_uInt8* m_pBufPos; ///< m_pRWBuf + m_nBufActualPos
sal_uInt16 m_nBufSize; ///< Allocated size of buffer
sal_uInt16 m_nBufActualLen; ///< Length of used segment of buffer ///< = m_nBufSize, if EOF did not occur
sal_uInt16 m_nBufActualPos; ///< current position in buffer (0..m_nBufSize-1)
sal_uInt16 m_nBufFree; ///< number of free slots in buffer to IO of type eIOMode bool m_isIoRead; bool m_isIoWrite;
template <typename N>
SvStream& WriteNumberAsString( N n ) { return WriteOString(OString::number(n)); }
std::size_t ReadBytes( void* pData, std::size_t nSize );
std::size_t WriteBytes( constvoid* pData, std::size_t nSize );
sal_uInt64 Seek( sal_uInt64 nPos );
sal_uInt64 SeekRel( sal_Int64 nPos );
sal_uInt64 Tell() const { return m_nBufFilePos + m_nBufActualPos; } virtual sal_uInt64 TellEnd(); // length between current (Tell()) pos and end of stream
sal_uInt64 remainingSize(); /// If we have data in our internal buffers, write them out void FlushBuffer(); /// Call FlushBuffer() and then call flush on the underlying OS stream void Flush(); // next Tell() <= nSize bool SetStreamSize( sal_uInt64 nSize );
/// Switch to no endian swapping and write 0xfeff void StartWritingUnicodeText();
/** If eReadBomCharSet==RTL_TEXTENCODING_DONTKNOW: read 16bit, if 0xfeff do nothing(UTF-16),if0xfffeswitchendianswapping(UTF-16),if0xefbb or0xbbefreadanotherbyteandcheckforUTF-8.IfnoUTF-*BOMwas detectedputallreadbytesback.Thismeansthatif2byteswereread itwasanUTF-16BOM,if3byteswerereaditwasanUTF-8BOM.There isnoUTF-7,UTF-32orUTF-EBCDICBOMdetection!
IfeReadBomCharSet!=RTL_TEXTENCODING_DONTKNOW:onlyreadaBOMofthat
encoding and switch endian swapping if UTF-16 and 0xfffe. */ void StartReadingUnicodeText( rtl_TextEncoding eReadBomCharSet );
/** Read a line of Unicode.
@paramnMaxCodepointsToRead Maximumofcodepoints(UCS-2orUTF-16pairs,notbytes)to read,iflineislongeritwillbetruncated.
*/
SAL_DLLPRIVATE bool ReadUniStringLine(OUString& rStr, sal_Int32 nMaxCodepointsToRead); /** Read a 32bit length prefixed sequence of utf-16 if eSrcCharSet==RTL_TEXTENCODING_UNICODE,otherwisereada16bitlength
prefixed sequence of bytes and convert from eSrcCharSet */
OUString ReadUniOrByteString(rtl_TextEncoding eSrcCharSet); /** Write a 32bit length prefixed sequence of utf-16 if eSrcCharSet==RTL_TEXTENCODING_UNICODE,otherwiseconverttoeSrcCharSet
and write a 16bit length prefixed sequence of bytes */
SvStream& WriteUniOrByteString( std::u16string_view rStr, rtl_TextEncoding eDestCharSet );
/** Read a line of Unicode if eSrcCharSet==RTL_TEXTENCODING_UNICODE, otherwisereadalineofBytecodeandconvertfromeSrcCharSet
TOOLS_DLLPUBLIC SvStream& endl( SvStream& rStr ); /// same as endl() but Unicode
TOOLS_DLLPUBLIC SvStream& endlu( SvStream& rStr ); /// call endlu() if m_eStreamCharSet==RTL_TEXTECODING_UNICODE otherwise endl()
TOOLS_DLLPUBLIC SvStream& endlub( SvStream& rStr );
/// Attempt to read nUnits 8bit units to an OString, returned OString's /// length is number of units successfully read
TOOLS_DLLPUBLIC OString read_uInt8s_ToOString(SvStream& rStrm,
std::size_t nUnits);
/// Attempt to read nUnits 8bit units to an OUString inline OUString read_uInt8s_ToOUString(SvStream& rStrm,
std::size_t nUnits, rtl_TextEncoding eEnc)
{ return OStringToOUString(read_uInt8s_ToOString(rStrm, nUnits), eEnc);
}
/// Attempt to read nUnits 16bit units to an OUString, returned /// OUString's length is number of units successfully read
TOOLS_DLLPUBLIC OUString read_uInt16s_ToOUString(SvStream& rStrm,
std::size_t nUnits);
/// Attempt to read a pascal-style length (of type prefix) prefixed sequence of /// 16bit units to an OUString, returned OString's length is number of /// units successfully read. inline OUString read_uInt16_lenPrefixed_uInt16s_ToOUString(SvStream& rStrm)
{
sal_uInt16 nUnits = 0;
rStrm.ReadUInt16( nUnits ); return read_uInt16s_ToOUString(rStrm, nUnits);
}
/// Attempt to write a pascal-style length (of type prefix) prefixed sequence /// of 16bit units from an OUString, returned value is number of bytes written /// (including byte-count of prefix)
std::size_t write_uInt32_lenPrefixed_uInt16s_FromOUString(SvStream& rStrm,
std::u16string_view rStr);
/// Attempt to write a pascal-style length (of type prefix) prefixed sequence /// of 16bit units from an OUString, returned value is number of bytes written /// (including byte-count of prefix)
UNLESS_MERGELIBS(TOOLS_DLLPUBLIC) std::size_t write_uInt16_lenPrefixed_uInt16s_FromOUString(SvStream& rStrm,
std::u16string_view rStr);
/// Attempt to read 8bit units to an OString until a zero terminator is /// encountered, returned OString's length is number of units *definitely* /// successfully read, check SvStream::good() to see if null terminator was /// successfully read
TOOLS_DLLPUBLIC OString read_zeroTerminated_uInt8s_ToOString(SvStream& rStrm);
/// Attempt to read 8bit units assuming source encoding eEnc to an OUString /// until a zero terminator is encountered. Check SvStream::good() to see if /// null terminator was successfully read
TOOLS_DLLPUBLIC OUString read_zeroTerminated_uInt8s_ToOUString(SvStream& rStrm, rtl_TextEncoding eEnc);
/// Attempt to read a pascal-style length (of type prefix) prefixed sequence of /// 8bit units to an OString, returned OString's length is number of units /// successfully read. inline OString read_uInt32_lenPrefixed_uInt8s_ToOString(SvStream& rStrm)
{
sal_uInt32 nUnits = 0;
rStrm.ReadUInt32(nUnits); return read_uInt8s_ToOString(rStrm, nUnits);
} inline OString read_uInt16_lenPrefixed_uInt8s_ToOString(SvStream& rStrm)
{
sal_uInt16 nUnits = 0;
rStrm.ReadUInt16(nUnits); return read_uInt8s_ToOString(rStrm, nUnits);
}
/// Attempt to write a pascal-style length (of type prefix) prefixed /// sequence of units from a string-type, returned value is number of bytes /// written (including byte-count of prefix)
TOOLS_DLLPUBLIC std::size_t write_uInt16_lenPrefixed_uInt8s_FromOString(SvStream& rStrm,
std::string_view rStr);
/// Attempt to write a pascal-style length (of type prefix) prefixed sequence /// of 8bit units from an OUString, returned value is number of bytes written /// (including byte-count of prefix) inline std::size_t write_uInt16_lenPrefixed_uInt8s_FromOUString(SvStream& rStrm,
std::u16string_view rStr,
rtl_TextEncoding eEnc)
{ return write_uInt16_lenPrefixed_uInt8s_FromOString(rStrm, OUStringToOString(rStr, eEnc));
}
namespace tools
{ /// Is rUrl a file:// URL with no contents?
TOOLS_DLLPUBLIC bool isEmptyFileUrl(const OUString& rUrl);
}
// FileStream
class TOOLS_DLLPUBLIC SvFileStream final : public SvStream
{ private: void* mxFileHandle = nullptr; // on windows, it is a HANDLE, otherwise, it is a oslFileHandle #ifdefined(_WIN32)
sal_uInt16 nLockCounter; #endif
OUString aFilename; bool bIsOpen;
/// AllocateMemory must update pBuf accordingly /// - pBuf: Address of new block void AllocateMemory( std::size_t nSize );
/// 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 bool ReAllocateMemory( tools::Long nDiff );
/// Is called when this stream allocated the buffer or the buffer is /// resized. FreeMemory may need to NULLify handles in derived classes. void FreeMemory();
// return the buffer currently in use, and allocate a new buffer internally void* SwitchBuffer(); // the buffer is not owned by this class void SetBuffer( void* pBuf, std::size_t nSize, std::size_t nEOF );
void ObjectOwnsMemory( bool bOwn ) { bOwnsData = bOwn; } /// Makes the stream read-only after it was (possibly) initially writable, /// without having to copy the data or change buffers. /// @since LibreOffice 7.5 void MakeReadOnly(); void SetResizeOffset( std::size_t nNewResize ) { nResize = nNewResize; } virtual sal_uInt64 TellEnd() override final { FlushBuffer(); return nEndOfData; }
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.