xoreos  0.0.5
Public Member Functions | Private Attributes | List of all members
Common::MemoryWriteStream Class Reference

Simple memory based 'stream', which implements the SeekableWriteStream interface for a plain memory block. More...

#include <memwritestream.h>

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

Public Member Functions

 MemoryWriteStream (byte *buf, size_t len)
 
 ~MemoryWriteStream ()
 
template<size_t N>
 MemoryWriteStream (byte(&array)[N])
 Template constructor to create a MemoryWriteStream around an array buffer. More...
 
size_t write (const void *dataPtr, size_t dataSize)
 Write data into the stream. More...
 
size_t pos () const
 Return the current writing position within the memory block. More...
 
size_t size () const
 Return the total size of the memory block. More...
 
size_t seek (ptrdiff_t offset, Origin whence=kOriginBegin)
 Seek offset bytes from the origin whence. More...
 
- Public Member Functions inherited from Common::SeekableWriteStream
 SeekableWriteStream ()
 
 ~SeekableWriteStream ()
 
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 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...
 

Private Attributes

byte_ptr
 
const size_t _bufSize
 
size_t _pos
 

Additional Inherited Members

- Public Types inherited from Common::SeekableWriteStream
enum  Origin { kOriginBegin = 0, kOriginCurrent = 1, kOriginEnd = 2, kOriginMAX }
 The position a seeking offset takes as a base. More...
 
- Static Public Member Functions inherited from Common::SeekableWriteStream
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

Simple memory based 'stream', which implements the SeekableWriteStream interface for a plain memory block.

Writing past the size of the memory block will fail with an exception.

Definition at line 66 of file memwritestream.h.

Constructor & Destructor Documentation

◆ MemoryWriteStream() [1/2]

Common::MemoryWriteStream::MemoryWriteStream ( byte buf,
size_t  len 
)
inline

Definition at line 68 of file memwritestream.h.

◆ ~MemoryWriteStream()

Common::MemoryWriteStream::~MemoryWriteStream ( )
inline

Definition at line 69 of file memwritestream.h.

◆ MemoryWriteStream() [2/2]

template<size_t N>
Common::MemoryWriteStream::MemoryWriteStream ( byte(&)  array[N])
inline

Template constructor to create a MemoryWriteStream around an array buffer.

Definition at line 73 of file memwritestream.h.

Member Function Documentation

◆ pos()

size_t Common::MemoryWriteStream::pos ( ) const
virtual

Return the current writing position within the memory block.

Implements Common::SeekableWriteStream.

Definition at line 73 of file memwritestream.cpp.

References _pos.

◆ seek()

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

Seek offset bytes from the origin whence.

Implements Common::SeekableWriteStream.

Definition at line 81 of file memwritestream.cpp.

References _bufSize, _pos, _ptr, Common::SeekableWriteStream::evalSeek(), Common::kSeekError, and size().

Here is the call graph for this function:

◆ size()

size_t Common::MemoryWriteStream::size ( ) const
virtual

Return the total size of the memory block.

Implements Common::SeekableWriteStream.

Definition at line 77 of file memwritestream.cpp.

References _bufSize.

Referenced by seek().

Here is the caller graph for this function:

◆ write()

size_t Common::MemoryWriteStream::write ( const void *  dataPtr,
size_t  dataSize 
)
virtual

Write data into the stream.

Subclasses must implement this method; all other write methods are implemented using it.

Parameters
dataPtrpointer to the data to be written.
dataSizenumber of bytes to be written.
Returns
the number of bytes which were actually written.

Implements Common::WriteStream.

Definition at line 58 of file memwritestream.cpp.

References _bufSize, _pos, and _ptr.

Member Data Documentation

◆ _bufSize

const size_t Common::MemoryWriteStream::_bufSize
private

Definition at line 88 of file memwritestream.h.

Referenced by seek(), size(), and write().

◆ _pos

size_t Common::MemoryWriteStream::_pos
private

Definition at line 89 of file memwritestream.h.

Referenced by pos(), seek(), and write().

◆ _ptr

byte* Common::MemoryWriteStream::_ptr
private

Definition at line 86 of file memwritestream.h.

Referenced by seek(), and write().


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