LibreOffice Module tools (master) 1
Classes | Namespaces | Macros | Typedefs | Enumerations | Functions
stream.hxx File Reference
#include <config_options.h>
#include <tools/toolsdllapi.h>
#include <tools/lineend.hxx>
#include <tools/long.hxx>
#include <tools/ref.hxx>
#include <comphelper/errcode.hxx>
#include <rtl/string.hxx>
#include <rtl/strbuf.hxx>
#include <o3tl/typed_flags_set.hxx>
#include <memory>
#include <string_view>
Include dependency graph for stream.hxx:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  o3tl::typed_flags< StreamMode >
 
struct  o3tl::typed_flags< SvStreamCompressFlags >
 
struct  SvLockBytesStat
 
class  SvLockBytes
 
class  SvStream
 
class  SvFileStream
 
class  SvMemoryStream
 

Namespaces

namespace  o3tl
 
namespace  tools
 Note: this class is a true marvel of engineering: because the author could not decide whether it's better to have a closed or half-open interval, they just implemented both in the same class!
 

Macros

#define STREAM_SEEK_TO_BEGIN   0L
 
#define STREAM_SEEK_TO_END   SAL_MAX_UINT64
 

Typedefs

typedef SvStream &(* SvStrPtr) (SvStream &)
 
typedef tools::SvRef< SvLockBytesSvLockBytesRef
 

Enumerations

enum class  StreamMode {
  NONE = 0x0000 ,
  READ = 0x0001 ,
  WRITE = 0x0002 ,
  NOCREATE = 0x0004 ,
  TRUNC = 0x0008 ,
  COPY_ON_SYMLINK = 0x0010 ,
  TEMPORARY = 0x0020 ,
  DELETE_ON_CLOSE = 0x0040 ,
  SHARE_DENYNONE = 0x0100 ,
  SHARE_DENYREAD = 0x0200 ,
  SHARE_DENYWRITE = 0x0400 ,
  SHARE_DENYALL = 0x0800 ,
  READWRITE = READ | WRITE ,
  STD_READ = READ | SHARE_DENYNONE | NOCREATE ,
  STD_WRITE = WRITE | SHARE_DENYALL ,
  STD_READWRITE = READWRITE | SHARE_DENYALL
}
 
enum class  SvStreamEndian {
  BIG ,
  LITTLE
}
 
enum class  SvStreamCompressFlags {
  NONE = 0x0000 ,
  ZBITMAP = 0x0001 ,
  NATIVE = 0x0010
}
 

Functions

rtl_TextEncoding GetStoreCharSet (rtl_TextEncoding eEncoding)
 
SvStreamoperator<< (SvStream &rStr, SvStrPtr f)
 
TOOLS_DLLPUBLIC SvStreamendl (SvStream &rStr)
 
TOOLS_DLLPUBLIC SvStreamendlu (SvStream &rStr)
 same as endl() but Unicode More...
 
TOOLS_DLLPUBLIC SvStreamendlub (SvStream &rStr)
 call endlu() if m_eStreamCharSet==RTL_TEXTECODING_UNICODE otherwise endl() More...
 
TOOLS_DLLPUBLIC OString read_uInt8s_ToOString (SvStream &rStrm, std::size_t nUnits)
 Attempt to read nUnits 8bit units to an OString, returned OString's length is number of units successfully read. More...
 
OUString read_uInt8s_ToOUString (SvStream &rStrm, std::size_t nUnits, rtl_TextEncoding eEnc)
 Attempt to read nUnits 8bit units to an OUString. More...
 
TOOLS_DLLPUBLIC OUString read_uInt16s_ToOUString (SvStream &rStrm, std::size_t nUnits)
 Attempt to read nUnits 16bit units to an OUString, returned OUString's length is number of units successfully read. More...
 
OUString read_uInt16_lenPrefixed_uInt16s_ToOUString (SvStream &rStrm)
 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. More...
 
OUString read_uInt32_lenPrefixed_uInt16s_ToOUString (SvStream &rStrm)
 
TOOLS_DLLPUBLIC std::size_t write_uInt16s_FromOUString (SvStream &rStrm, std::u16string_view rStr, std::size_t nUnits)
 Attempt to write a prefixed sequence of nUnits 16bit units from an OUString, returned value is number of bytes written. More...
 
std::size_t write_uInt16s_FromOUString (SvStream &rStrm, std::u16string_view rStr)
 
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) More...
 
UNLESS_MERGELIBS(TOOLS_DLLPUBLIC) std TOOLS_DLLPUBLIC OString read_zeroTerminated_uInt8s_ToOString (SvStream &rStrm)
 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) More...
 
TOOLS_DLLPUBLIC OUString read_zeroTerminated_uInt8s_ToOUString (SvStream &rStrm, rtl_TextEncoding eEnc)
 Attempt to read 8bit units assuming source encoding eEnc to an OUString until a zero terminator is encountered. More...
 
OString read_uInt32_lenPrefixed_uInt8s_ToOString (SvStream &rStrm)
 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. More...
 
OString read_uInt16_lenPrefixed_uInt8s_ToOString (SvStream &rStrm)
 
OString read_uInt8_lenPrefixed_uInt8s_ToOString (SvStream &rStrm)
 
OUString read_uInt16_lenPrefixed_uInt8s_ToOUString (SvStream &rStrm, rtl_TextEncoding eEnc)
 
OUString read_uInt8_lenPrefixed_uInt8s_ToOUString (SvStream &rStrm, rtl_TextEncoding eEnc)
 
std::size_t write_uInt8s_FromOString (SvStream &rStrm, std::string_view rStr, std::size_t nUnits)
 Attempt to write a prefixed sequence of nUnits 8bit units from an OString, returned value is number of bytes written. More...
 
std::size_t write_uInt8s_FromOString (SvStream &rStrm, std::string_view rStr)
 
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 units from a string-type, returned value is number of bytes written (including byte-count of prefix) More...
 
std::size_t write_uInt16_lenPrefixed_uInt8s_FromOUString (SvStream &rStrm, std::u16string_view rStr, rtl_TextEncoding eEnc)
 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) More...
 
TOOLS_DLLPUBLIC bool checkSeek (SvStream &rSt, sal_uInt64 nOffset)
 
bool tools::isEmptyFileUrl (const OUString &rUrl)
 Is rUrl a file:// URL with no contents? More...
 

Macro Definition Documentation

◆ STREAM_SEEK_TO_BEGIN

#define STREAM_SEEK_TO_BEGIN   0L

Definition at line 72 of file stream.hxx.

◆ STREAM_SEEK_TO_END

#define STREAM_SEEK_TO_END   SAL_MAX_UINT64

Definition at line 73 of file stream.hxx.

Typedef Documentation

◆ SvLockBytesRef

Definition at line 137 of file stream.hxx.

◆ SvStrPtr

typedef SvStream &(* SvStrPtr) (SvStream &)

Definition at line 89 of file stream.hxx.

Enumeration Type Documentation

◆ StreamMode

enum class StreamMode
strong
Enumerator
NONE 
READ 

allow read accesses

WRITE 

allow write accesses

NOCREATE 

1 == Don't create file

TRUNC 

Truncate existing file to zero length.

COPY_ON_SYMLINK 

copy-on-write for symlinks (Unix-only)

TEMPORARY 

temporary file attribute (Windows-only)

DELETE_ON_CLOSE 

only for temporary files (Windows-only)

SHARE_DENYNONE 
SHARE_DENYREAD 
SHARE_DENYWRITE 
SHARE_DENYALL 
READWRITE 
STD_READ 
STD_WRITE 
STD_READWRITE 

Definition at line 46 of file stream.hxx.

◆ SvStreamCompressFlags

enum class SvStreamCompressFlags
strong
Enumerator
NONE 
ZBITMAP 
NATIVE 

Definition at line 77 of file stream.hxx.

◆ SvStreamEndian

enum class SvStreamEndian
strong
Enumerator
BIG 
LITTLE 

Definition at line 75 of file stream.hxx.

Function Documentation

◆ checkSeek()

TOOLS_DLLPUBLIC bool checkSeek ( SvStream rSt,
sal_uInt64  nOffset 
)

Definition at line 1292 of file stream.cxx.

References SvStream::Seek(), and SvStream::TellEnd().

◆ endl()

TOOLS_DLLPUBLIC SvStream & endl ( SvStream rStr)

Definition at line 1465 of file stream.cxx.

References SvStream::GetLineDelimiter(), LINEEND_CR, LINEEND_LF, and SvStream::WriteChar().

Referenced by endlub(), and SvStream::WriteLine().

◆ endlu()

TOOLS_DLLPUBLIC SvStream & endlu ( SvStream rStr)

same as endl() but Unicode

Definition at line 1477 of file stream.cxx.

References SvStream::GetLineDelimiter(), LINEEND_CR, LINEEND_LF, rStrm, and SvStream::WriteUnicode().

Referenced by endlub().

◆ endlub()

TOOLS_DLLPUBLIC SvStream & endlub ( SvStream rStr)

call endlu() if m_eStreamCharSet==RTL_TEXTECODING_UNICODE otherwise endl()

Definition at line 1493 of file stream.cxx.

References endl(), endlu(), SvStream::GetStreamCharSet(), and rStrm.

◆ GetStoreCharSet()

rtl_TextEncoding GetStoreCharSet ( rtl_TextEncoding  eEncoding)
inline

Definition at line 35 of file stream.hxx.

◆ operator<<()

SvStream & operator<< ( SvStream rStr,
SvStrPtr  f 
)
inline

Definition at line 432 of file stream.hxx.

◆ read_uInt16_lenPrefixed_uInt16s_ToOUString()

OUString read_uInt16_lenPrefixed_uInt16s_ToOUString ( SvStream rStrm)
inline

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.

Definition at line 464 of file stream.hxx.

References read_uInt16s_ToOUString(), SvStream::ReadUInt16(), and rStrm.

◆ read_uInt16_lenPrefixed_uInt8s_ToOString()

OString read_uInt16_lenPrefixed_uInt8s_ToOString ( SvStream rStrm)
inline

◆ read_uInt16_lenPrefixed_uInt8s_ToOUString()

OUString read_uInt16_lenPrefixed_uInt8s_ToOUString ( SvStream rStrm,
rtl_TextEncoding  eEnc 
)
inline

Definition at line 535 of file stream.hxx.

References read_uInt16_lenPrefixed_uInt8s_ToOString(), and rStrm.

Referenced by SvStream::ReadUniOrByteString().

◆ read_uInt16s_ToOUString()

TOOLS_DLLPUBLIC OUString read_uInt16s_ToOUString ( SvStream rStrm,
std::size_t  nUnits 
)

Attempt to read nUnits 16bit units to an OUString, returned OUString's length is number of units successfully read.

Definition at line 1823 of file stream.cxx.

References i, SvStream::IsEndianSwap(), SvStream::ReadBytes(), SvStream::remainingSize(), rStrm, SAL_MAX_INT32, and SAL_WARN_IF.

Referenced by read_uInt16_lenPrefixed_uInt16s_ToOUString(), and read_uInt32_lenPrefixed_uInt16s_ToOUString().

◆ read_uInt32_lenPrefixed_uInt16s_ToOUString()

OUString read_uInt32_lenPrefixed_uInt16s_ToOUString ( SvStream rStrm)
inline

Definition at line 471 of file stream.hxx.

References read_uInt16s_ToOUString(), SvStream::ReadUInt32(), and rStrm.

Referenced by SvStream::ReadUniOrByteString().

◆ read_uInt32_lenPrefixed_uInt8s_ToOString()

OString read_uInt32_lenPrefixed_uInt8s_ToOString ( SvStream rStrm)
inline

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.

Definition at line 515 of file stream.hxx.

References read_uInt8s_ToOString(), SvStream::ReadUInt32(), and rStrm.

◆ read_uInt8_lenPrefixed_uInt8s_ToOString()

OString read_uInt8_lenPrefixed_uInt8s_ToOString ( SvStream rStrm)
inline

◆ read_uInt8_lenPrefixed_uInt8s_ToOUString()

OUString read_uInt8_lenPrefixed_uInt8s_ToOUString ( SvStream rStrm,
rtl_TextEncoding  eEnc 
)
inline

Definition at line 541 of file stream.hxx.

References read_uInt8_lenPrefixed_uInt8s_ToOString(), and rStrm.

◆ read_uInt8s_ToOString()

TOOLS_DLLPUBLIC OString read_uInt8s_ToOString ( SvStream rStrm,
std::size_t  nUnits 
)

Attempt to read nUnits 8bit units to an OString, returned OString's length is number of units successfully read.

Definition at line 1791 of file stream.cxx.

References SvStream::ReadBytes(), SvStream::remainingSize(), rStrm, SAL_MAX_INT32, and SAL_WARN_IF.

Referenced by read_uInt16_lenPrefixed_uInt8s_ToOString(), read_uInt32_lenPrefixed_uInt8s_ToOString(), read_uInt8_lenPrefixed_uInt8s_ToOString(), and read_uInt8s_ToOUString().

◆ read_uInt8s_ToOUString()

OUString read_uInt8s_ToOUString ( SvStream rStrm,
std::size_t  nUnits,
rtl_TextEncoding  eEnc 
)
inline

Attempt to read nUnits 8bit units to an OUString.

Definition at line 450 of file stream.hxx.

References read_uInt8s_ToOString(), and rStrm.

◆ read_zeroTerminated_uInt8s_ToOString()

UNLESS_MERGELIBS(TOOLS_DLLPUBLIC) std TOOLS_DLLPUBLIC OString read_zeroTerminated_uInt8s_ToOString ( SvStream rStrm)

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)

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

Definition at line 608 of file stream.cxx.

References SvStream::GetError(), SvStream::ReadBytes(), SvStream::Seek(), and SvStream::Tell().

Referenced by read_zeroTerminated_uInt8s_ToOUString().

◆ read_zeroTerminated_uInt8s_ToOUString()

TOOLS_DLLPUBLIC OUString read_zeroTerminated_uInt8s_ToOUString ( SvStream rStrm,
rtl_TextEncoding  eEnc 
)

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

Definition at line 644 of file stream.cxx.

References read_zeroTerminated_uInt8s_ToOString().

◆ write_uInt16_lenPrefixed_uInt8s_FromOString()

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 units from a string-type, returned value is number of bytes written (including byte-count of prefix)

Definition at line 1984 of file stream.cxx.

References SvStream::good(), rStrm, SAL_WARN_IF, write_uInt8s_FromOString(), and SvStream::WriteUInt16().

Referenced by write_uInt16_lenPrefixed_uInt8s_FromOUString().

◆ write_uInt16_lenPrefixed_uInt8s_FromOUString()

std::size_t write_uInt16_lenPrefixed_uInt8s_FromOUString ( SvStream rStrm,
std::u16string_view  rStr,
rtl_TextEncoding  eEnc 
)
inline

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)

Definition at line 569 of file stream.hxx.

References OUStringToOString(), rStrm, and write_uInt16_lenPrefixed_uInt8s_FromOString().

Referenced by SvStream::WriteUniOrByteString().

◆ write_uInt16s_FromOUString() [1/2]

std::size_t write_uInt16s_FromOUString ( SvStream rStrm,
std::u16string_view  rStr 
)
inline

Definition at line 483 of file stream.hxx.

References rStrm, and write_uInt16s_FromOUString().

◆ write_uInt16s_FromOUString() [2/2]

TOOLS_DLLPUBLIC std::size_t write_uInt16s_FromOUString ( SvStream rStrm,
std::u16string_view  rStr,
std::size_t  nUnits 
)

Attempt to write a prefixed sequence of nUnits 16bit units from an OUString, returned value is number of bytes written.

Definition at line 652 of file stream.cxx.

References aBuf, DBG_ASSERT, SvStream::IsEndianSwap(), p, rStrm, SwapNumber(), and SvStream::WriteBytes().

Referenced by write_uInt16_lenPrefixed_uInt16s_FromOUString(), write_uInt16s_FromOUString(), write_uInt32_lenPrefixed_uInt16s_FromOUString(), and SvStream::WriteUnicodeOrByteText().

◆ write_uInt32_lenPrefixed_uInt16s_FromOUString()

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)

Definition at line 1950 of file stream.cxx.

References SvStream::good(), rStrm, SAL_WARN_IF, write_uInt16s_FromOUString(), and SvStream::WriteUInt32().

Referenced by SvStream::WriteUniOrByteString().

◆ write_uInt8s_FromOString() [1/2]

std::size_t write_uInt8s_FromOString ( SvStream rStrm,
std::string_view  rStr 
)
inline

Definition at line 555 of file stream.hxx.

References rStrm, and write_uInt8s_FromOString().

◆ write_uInt8s_FromOString() [2/2]

std::size_t write_uInt8s_FromOString ( SvStream rStrm,
std::string_view  rStr,
std::size_t  nUnits 
)
inline

Attempt to write a prefixed sequence of nUnits 8bit units from an OString, returned value is number of bytes written.

Definition at line 549 of file stream.hxx.

References rStrm, and SvStream::WriteBytes().

Referenced by write_uInt16_lenPrefixed_uInt8s_FromOString(), write_uInt8s_FromOString(), and SvStream::WriteUnicodeOrByteText().