xoreos
0.0.5
|
A stream that dynamically grows as it's written to. More...
#include <memwritestream.h>
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... | |
byte * | getData () |
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... | |
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.
Common::MemoryWriteStreamDynamic::MemoryWriteStreamDynamic | ( | bool | disposeMemory = false , |
size_t | capacity = 0 |
||
) |
Definition at line 96 of file memwritestream.cpp.
References reserve().
Common::MemoryWriteStreamDynamic::~MemoryWriteStreamDynamic | ( | ) |
Definition at line 102 of file memwritestream.cpp.
void Common::MemoryWriteStreamDynamic::dispose | ( | ) |
Definition at line 148 of file memwritestream.cpp.
References _capacity, _data, _ptr, _size, and Common::DisposablePtrBase< T, Deallocator >::dispose().
|
private |
Definition at line 122 of file memwritestream.cpp.
References _capacity, and reserve().
Referenced by write().
byte * Common::MemoryWriteStreamDynamic::getData | ( | ) |
Definition at line 177 of file memwritestream.cpp.
References _data, and Common::DisposablePtrBase< T, Deallocator >::get().
Referenced by Aurora::Small::decompress(), Sound::WwRIFFVorbisStream::generateHeaderComment(), Sound::WwRIFFVorbisStream::generateHeaderIdentification(), Sound::WwRIFFVorbisStream::generateHeaderSetup(), Aurora::PEFile::getResource(), Aurora::NSBTXFile::getResource(), and Aurora::LanguageManager::preParseColorCodes().
|
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().
void Common::MemoryWriteStreamDynamic::reserve | ( | size_t | s | ) |
Definition at line 105 of file memwritestream.cpp.
References _capacity, _data, _ptr, _size, Common::DisposablePtrBase< T, Deallocator >::dispose(), Common::DisposablePtrBase< T, Deallocator >::get(), pos(), and Common::DisposablePtrBase< T, Deallocator >::reset().
Referenced by ensureCapacity(), MemoryWriteStreamDynamic(), and Aurora::LanguageManager::preParseColorCodes().
|
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().
void Common::MemoryWriteStreamDynamic::setDisposable | ( | bool | disposeMemory | ) |
Definition at line 144 of file memwritestream.cpp.
References _data, and Common::DisposablePtrBase< T, Deallocator >::setDisposable().
Referenced by Aurora::Small::decompress(), Sound::WwRIFFVorbisStream::generateHeaderComment(), Sound::WwRIFFVorbisStream::generateHeaderIdentification(), Sound::WwRIFFVorbisStream::generateHeaderSetup(), Aurora::PEFile::getResource(), and Aurora::NSBTXFile::getResource().
|
virtual |
Return the number of bytes written to this stream in total.
Implements Common::SeekableWriteStream.
Definition at line 160 of file memwritestream.cpp.
References _size.
Referenced by Aurora::Small::decompress(), Sound::WwRIFFVorbisStream::generateHeaderComment(), Sound::WwRIFFVorbisStream::generateHeaderIdentification(), Sound::WwRIFFVorbisStream::generateHeaderSetup(), Aurora::PEFile::getResource(), Aurora::NSBTXFile::getResource(), Aurora::LanguageManager::preParseColorCodes(), and seek().
|
virtual |
Write data into the stream.
Subclasses must implement this method; all other write methods are implemented using it.
dataPtr | pointer to the data to be written. |
dataSize | number of bytes to be written. |
Implements Common::WriteStream.
Definition at line 129 of file memwritestream.cpp.
References _ptr, _size, ensureCapacity(), MAX(), and pos().
Referenced by Aurora::LanguageManager::preParseColorCodes().
|
private |
Definition at line 123 of file memwritestream.h.
Referenced by dispose(), ensureCapacity(), and reserve().
|
private |
Definition at line 119 of file memwritestream.h.
Referenced by dispose(), getData(), pos(), reserve(), seek(), and setDisposable().
|
private |
|
private |