MemoryDataStream

Description

sealed class Tinman.Core.IO.Streams.MemoryDataStream

Derived from

DataStreamBase abstract
IInternalBuffer<ByteBuffer>

An implementation of the IDataStream that uses a growing memory buffer.

Public / Constructors

For

3 overloads


[OwnerReturn]
public static method For1 → (1)

bytes in : ByteBuffer

[not-null]
The bytes to read.

returns → MemoryDataStream

The created data stream.

Creates a new instance of MemoryDataStream that reads the given data.

The stream will be in read mode.


[OwnerReturn]
public static method For2 → (1)

bytes in : int8 [ ]

[not-null]
The bytes to read.

returns → MemoryDataStream

The created data stream.

Creates a new instance of MemoryDataStream that reads the given data.

The stream will be in read mode.


[OwnerReturn]
public static method For3 → (3)

bytes in : int8 [ ]

[not-null]
The bytes to read.

offset in : int32

[>=0]
Offset into bytes in to first byte to read.

count in : int32

[>=0]
Total number of bytes to read.

returns → MemoryDataStream

The created data stream.

Creates a new instance of MemoryDataStream that reads the given data.

The stream will be in read mode.

Memory​Data​Stream


public constructor MemoryDataStream → (1)

initialCapacity opt : int32 = 65536

[>=0]
The initial buffer size, in bytes.

Creates a new instance of MemoryDataStream.

The stream will be in write mode.

Wrap


[OwnerReturn]
public static method Wrap → (1)

bytes in : ByteBuffer own

[not-null]
The byte buffer to wrap.

returns → MemoryDataStream

The wrapping data stream.

Creates a new instance of MemoryDataStream that reads the given data.

The stream will be in read mode.

Public / Methods

Clear


public method Clear → (1)

initialBufferSize opt : int32 = 0

[>=0]
The initial buffer size or 0.

Clears this memory stream so that it can be used again for writing.

After returning, the stream will be in write mode.

Create​Pool


[OwnerReturn]
public static method CreatePool → (3)

name in : string

[not-empty]
Name of the object pool.

size in : int32

[>0]
The size of each memory data stream, in bytes.

count in : int32

[>0]
The maximum number of memory data streams in the pool.

returns → ObjectPool<MemoryDataStream>

The object pool.

Creates an object pool for MemoryDataStream objects of the given size.

Each MemoryDataStream object that is returned by the object pool will already have its state reset via Clear.

Flip


public method Flip → ()

Flips this memory stream so that it reads back the data that has been written to it.

When calling this method, the stream must be in write mode. After returning, the stream will be in read mode.

IOException

If this memory stream is not in write mode.

To​Buffer


[OwnerReturn]
public method ToBuffer → ()

returns → ByteBuffer

A compact byte buffer holding a copy of the current stream content.

Returns the current content of this memory stream.

When calling this method, the stream must be in write mode. The stream state is not modified by this method.

IOException

If the memory stream is not in write mode.

Write​Chunk


public method WriteChunk → (1)

count in : int32

[>=0]
The maximum number of bytes that will be written to the returned buffer.

returns → ByteBuffer

The internal buffer, correctly positioned, with at least count in remaining bytes.

Prepares the internal buffer of this memory stream for writing a chunk of bytes.

IOException

If the memory stream is not in write mode.