xoreos  0.0.5
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Common::SeekableWriteStream Class Referenceabstract

#include <writestream.h>

Inheritance diagram for Common::SeekableWriteStream:
Inheritance graph
[legend]
Collaboration diagram for Common::SeekableWriteStream:
Collaboration graph
[legend]

Public Types

enum  Origin { kOriginBegin = 0, kOriginCurrent = 1, kOriginEnd = 2, kOriginMAX }
 The position a seeking offset takes as a base. More...
 

Public Member Functions

 SeekableWriteStream ()
 
 ~SeekableWriteStream ()
 
virtual size_t pos () const =0
 Obtains the current value of the stream position indicator of the stream. More...
 
virtual size_t size () const =0
 Obtains the total size of the stream, measured in bytes. More...
 
virtual size_t seek (ptrdiff_t offset, Origin whence=kOriginBegin)=0
 Sets the stream position indicator for the stream. More...
 
virtual size_t skip (ptrdiff_t offset)
 Skip the specified number of bytes, adding that offset to the current position in the stream. More...
 
- Public Member Functions inherited from Common::WriteStream
 WriteStream ()
 
virtual ~WriteStream ()
 
virtual size_t write (const void *dataPtr, size_t dataSize)=0
 Write data into the stream. More...
 
virtual void flush ()
 Commit any buffered data to the underlying channel or storage medium; unbuffered streams can use the default implementation. More...
 
void writeByte (byte value)
 
void writeSByte (int8 value)
 
void writeUint16LE (uint16 value)
 
void writeUint32LE (uint32 value)
 
void writeUint64LE (uint64 value)
 
void writeUint16BE (uint16 value)
 
void writeUint32BE (uint32 value)
 
void writeUint64BE (uint64 value)
 
void writeBytes (byte value, size_t n)
 Write n bytes of value to the stream. More...
 
FORCEINLINE void writeZeros (size_t n)
 Write n zeros to the stream. More...
 
FORCEINLINE void writeSint16LE (int16 value)
 
FORCEINLINE void writeSint32LE (int32 value)
 
FORCEINLINE void writeSint64LE (int64 value)
 
FORCEINLINE void writeSint16BE (int16 value)
 
FORCEINLINE void writeSint32BE (int32 value)
 
FORCEINLINE void writeSint64BE (int64 value)
 
FORCEINLINE void writeIEEEFloatLE (float value)
 
FORCEINLINE void writeIEEEFloatBE (float value)
 
FORCEINLINE void writeIEEEDoubleLE (double value)
 
FORCEINLINE void writeIEEEDoubleBE (double value)
 
size_t writeStream (ReadStream &stream, size_t n)
 Copy n bytes of the given stream into the stream. More...
 
size_t writeStream (ReadStream &stream)
 Copy the complete contents of the given stream. More...
 
void writeString (const UString &str)
 Write the given string to the stream, encoded as UTF-8. More...
 

Static Public Member Functions

static size_t evalSeek (ptrdiff_t offset, Origin whence, size_t pos, size_t begin, size_t size)
 Evaluate the seek offset relative to whence into a position from the beginning. More...
 

Detailed Description

Definition at line 215 of file writestream.h.

Member Enumeration Documentation

◆ Origin

The position a seeking offset takes as a base.

Enumerator
kOriginBegin 

Seek from the begin of the stream.

kOriginCurrent 

Seek from the current position of the stream.

kOriginEnd 

Seek from the end of the stream.

kOriginMAX 

For range checks.

Definition at line 218 of file writestream.h.

Constructor & Destructor Documentation

◆ SeekableWriteStream()

Common::SeekableWriteStream::SeekableWriteStream ( )

Definition at line 99 of file writestream.cpp.

◆ ~SeekableWriteStream()

Common::SeekableWriteStream::~SeekableWriteStream ( )

Definition at line 103 of file writestream.cpp.

Member Function Documentation

◆ evalSeek()

size_t Common::SeekableWriteStream::evalSeek ( ptrdiff_t  offset,
SeekableWriteStream::Origin  whence,
size_t  pos,
size_t  begin,
size_t  size 
)
static

Evaluate the seek offset relative to whence into a position from the beginning.

Definition at line 107 of file writestream.cpp.

References kOriginBegin, kOriginCurrent, kOriginEnd, pos(), size(), and XOREOS_FALLTHROUGH.

Referenced by Common::WriteFile::seek(), Common::MemoryWriteStream::seek(), and Common::MemoryWriteStreamDynamic::seek().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pos()

virtual size_t Common::SeekableWriteStream::pos ( ) const
pure virtual

Obtains the current value of the stream position indicator of the stream.

Returns
the current position indicator, or kPositionInvalid if an error occurred.

Implemented in Common::MemoryWriteStreamDynamic, Common::MemoryWriteStream, and Common::WriteFile.

Referenced by Aurora::TheWitcherSaveWriter::add(), evalSeek(), and Aurora::TheWitcherSaveWriter::finish().

Here is the caller graph for this function:

◆ seek()

virtual size_t Common::SeekableWriteStream::seek ( ptrdiff_t  offset,
Origin  whence = kOriginBegin 
)
pure virtual

Sets the stream position indicator for the stream.

The new position, measured in bytes, is obtained by adding offset bytes to the position specified by whence. If whence is set to kOriginBegin, kOriginCurrent, or kOriginEnd, the offset is relative to the start of the file, the current position indicator, or end-of-file, respectively.

On error, or when trying to seek outside the stream, a kSeekError exception is thrown.

Parameters
offsetthe relative offset in bytes.
whencethe seek reference: kOriginBegin, kOriginCurrent or kOriginEnd.
Returns
the previous position of the stream, before seeking.

Implemented in Common::MemoryWriteStreamDynamic, Common::MemoryWriteStream, and Common::WriteFile.

Referenced by Aurora::ERFWriter::add(), and skip().

Here is the caller graph for this function:

◆ size()

virtual size_t Common::SeekableWriteStream::size ( ) const
pure virtual

Obtains the total size of the stream, measured in bytes.

If this value is unknown or can not be computed, kSizeInvalid is returned.

Returns
the size of the stream, or kSizeInvalid if an error occurred.

Implemented in Common::MemoryWriteStreamDynamic, Common::MemoryWriteStream, and Common::WriteFile.

Referenced by evalSeek().

Here is the caller graph for this function:

◆ skip()

virtual size_t Common::SeekableWriteStream::skip ( ptrdiff_t  offset)
inlinevirtual

Skip the specified number of bytes, adding that offset to the current position in the stream.

On error, or when trying to skip outside the stream, a kSeekError exception is thrown.

Parameters
offsetthe number of bytes to skip.
Returns
the previous position of the stream, before skipping.

Definition at line 265 of file writestream.h.

References kOriginCurrent, and seek().

Here is the call graph for this function:

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