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

A stream that dynamically grows as it's written to. More...

#include <memwritestream.h>

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

Public Member Functions

 MemoryWriteStreamDynamic (bool disposeMemory=false, size_t capacity=0)
 
 ~MemoryWriteStreamDynamic ()
 
void reserve (size_t s)
 
size_t write (const void *dataPtr, size_t dataSize)
 Write data into the stream. More...
 
void setDisposable (bool disposeMemory)
 
void dispose ()
 
size_t pos () const
 Return the current writing position within the stream. More...
 
size_t size () const
 Return the number of bytes written to this stream in total. More...
 
size_t seek (ptrdiff_t offset, Origin whence=kOriginBegin)
 Seek offset bytes from the origin whence. More...
 
bytegetData ()
 
- 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 Member Functions

void ensureCapacity (size_t newLen)
 

Private Attributes

DisposableArray< byte_data
 
byte_ptr
 
size_t _capacity
 
size_t _size
 

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

A stream that dynamically grows as it's written to.

As long as more memory can be allocated, writing into the stream won't fail.

Definition at line 96 of file memwritestream.h.

Constructor & Destructor Documentation

◆ MemoryWriteStreamDynamic()

Common::MemoryWriteStreamDynamic::MemoryWriteStreamDynamic ( bool  disposeMemory = false,
size_t  capacity = 0 
)

Definition at line 96 of file memwritestream.cpp.

References reserve().

Here is the call graph for this function:

◆ ~MemoryWriteStreamDynamic()

Common::MemoryWriteStreamDynamic::~MemoryWriteStreamDynamic ( )

Definition at line 102 of file memwritestream.cpp.

Member Function Documentation

◆ dispose()

void Common::MemoryWriteStreamDynamic::dispose ( )

Definition at line 148 of file memwritestream.cpp.

References _capacity, _data, _ptr, _size, and Common::DisposablePtrBase< T, Deallocator >::dispose().

Here is the call graph for this function:

◆ ensureCapacity()

void Common::MemoryWriteStreamDynamic::ensureCapacity ( size_t  newLen)
private

Definition at line 122 of file memwritestream.cpp.

References _capacity, and reserve().

Referenced by write().

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

◆ getData()

byte * Common::MemoryWriteStreamDynamic::getData ( )

◆ pos()

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

Return the current writing position within the stream.

Implements Common::SeekableWriteStream.

Definition at line 156 of file memwritestream.cpp.

References _data, _ptr, and Common::DisposablePtrBase< T, Deallocator >::get().

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

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

◆ reserve()

void Common::MemoryWriteStreamDynamic::reserve ( size_t  s)

◆ seek()

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

Seek offset bytes from the origin whence.

Implements Common::SeekableWriteStream.

Definition at line 164 of file memwritestream.cpp.

References _data, _ptr, _size, Common::SeekableWriteStream::evalSeek(), Common::DisposablePtrBase< T, Deallocator >::get(), Common::kSeekError, pos(), and size().

Here is the call graph for this function:

◆ setDisposable()

void Common::MemoryWriteStreamDynamic::setDisposable ( bool  disposeMemory)

◆ size()

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

◆ write()

size_t Common::MemoryWriteStreamDynamic::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 129 of file memwritestream.cpp.

References _ptr, _size, ensureCapacity(), MAX(), and pos().

Referenced by Aurora::LanguageManager::preParseColorCodes().

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

Member Data Documentation

◆ _capacity

size_t Common::MemoryWriteStreamDynamic::_capacity
private

Definition at line 123 of file memwritestream.h.

Referenced by dispose(), ensureCapacity(), and reserve().

◆ _data

DisposableArray<byte> Common::MemoryWriteStreamDynamic::_data
private

Definition at line 119 of file memwritestream.h.

Referenced by dispose(), getData(), pos(), reserve(), seek(), and setDisposable().

◆ _ptr

byte* Common::MemoryWriteStreamDynamic::_ptr
private

Definition at line 121 of file memwritestream.h.

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

◆ _size

size_t Common::MemoryWriteStreamDynamic::_size
private

Definition at line 124 of file memwritestream.h.

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


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