MemoryStream

Implements a stream of contiguous, GC-free, heap-memory.

In theory its size can go up to 2^31 bytes (X86) or 2^63 bytes (X86_64). This value is obviously limited by the amount of DRAM and the fragmentation.

MemoryStream is also enhanced by implementing the interfaces StreamPersist and FilePersist8. They allow to save the content either to another stream or to a file and to load the content either from another Stream or from a file.

Constructors

this
this()
this
this(A a)

Constructs a MemoryStream and write the input argument.

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Members

Functions

chars
const(char[]) chars()

Returns the stream content as a read-only char array.

clear
void clear()

see the Stream interface.

loadFromFile
void loadFromFile(const(char)[] aFilename)

see the FilePersist8 interface.

loadFromStream
void loadFromStream(Stream stream)

see the StreamPersist interface.

memory
Ptr memory()

Access to the memory chunk.

position
long position()
void position(long value)
void position(int value)

see the Stream interface.

read
size_t read(Ptr buffer, size_t count)

see the Stream interface.

saveToFile
void saveToFile(const(char)[] aFilename)

see the FilePersist8 interface.

saveToStream
void saveToStream(Stream stream)

see the StreamPersist interface.

seek
long seek(long offset, SeekMode mode)
int seek(int offset, SeekMode mode)

see the Stream interface.

setMemory
Ptr setMemory(Ptr ptr, size_t newSize, bool freeCurrent = true)

Replaces the current memory.

size
long size()
void size(long value)
void size(int value)

see the Stream interface.

ubytes
const(ubyte)[] ubytes()

Returns the stream content as a read-only ubyte array.

write
size_t write(const Ptr buffer, size_t count)

see the Stream interface.

Inherited Members

From Stream

read
size_t read(Ptr buffer, size_t count)

Reads from the Stream.

readVariable
T readVariable()

Reads a typed variable.

write
size_t write(const Ptr buffer, size_t count)

Writes the content of a buffer.

writeVariable
size_t writeVariable(T value)

Writes a typed value.

seek
long seek(long offset, SeekMode mode)
int seek(int offset, SeekMode mode)

Sets the stream position.

size
long size()
void size(long value)
void size(int value)

Sets or gets the stream size.

position
long position()
void position(long value)
void position(int value)

Sets or gets the stream position.

clear
void clear()

Resets the stream size to 0.

opOpAssign
void opOpAssign(Stream rhs)

Support for the concatenation operator.

From StreamPersist

saveToStream
void saveToStream(Stream stream)

Saves something in aStream

loadFromStream
void loadFromStream(Stream stream)

Loads something from aStream. aStream initial position is preserved.

From FilePersist8

saveToFile
void saveToFile(const(char)[] aFilename)

Saves something to aFilename.

loadFromFile
void loadFromFile(const(char)[] aFilename)

Loads something to aFilename.

Meta