Array

Array manipulation typically involves appending, as in the following example:

// create a small buffer
auto buf = new Array (256);

auto foo = "to write some D";

// append some text directly to it
buf.append ("now is the time for all good men ").append(foo);

Alternatively, one might use a formatter to append content:

auto output = new TextOutput (new Array(256));
output.format ("now is the time for {} good men {}", 3, foo);

A slice() method returns all valid content within the array.

Constructors

this
this(size_t capacity, size_t growing)

Construct a buffer.

this
this(void[] data)

Construct a buffer.

this
this(void[] data, size_t readable)

Construct a buffer.

Members

Functions

append
Array append(const(void)[] src)

Append content.

assign
Array assign(void[] data)

Reset the buffer content.

assign
Array assign(void[] data, size_t readable)

Reset the buffer content

assign
void[] assign()

Access buffer content.

bufferSize
size_t bufferSize()

Return a preferred size for buffering conduit I/O.

capacity
size_t capacity()

Access buffer capacity.

clear
Array clear()

Clear array content.

detach
void detach()

Release external resources.

flush
Array flush()

Emit/purge buffered content.

next
bool next(size_t delegate(const(void)[]) scan)

Iterator support.

opSlice
void[] opSlice(size_t start, size_t end)

Return a void[] read of the buffer from start to end, where end is exclusive.

position
size_t position()

Access buffer read position.

read
size_t read(void[] dst)

Transfer content into the provided dst.

reader
size_t reader(size_t delegate(const(void)[]) dg)

Read directly from this buffer.

seek
long seek(long offset, Anchor anchor)

Seek within the constraints of assigned content.

slice
void[] slice()

Retrieve all readable content.

slice
void[] slice(size_t size, bool eat)

Access buffer content.

toString
immutable(char)[] toString()

Return the name of this conduit.

write
size_t write(const(void)[] src)

Emulate OutputStream.write().

writer
size_t writer(size_t delegate(void[]) dg)

Write into this buffer.

Properties

limit
size_t limit [@property getter]

Access buffer limit.

readable
size_t readable [@property getter]

Available content.

writable
size_t writable [@property getter]

Available space.

Inherited Members

From Conduit

scheduler
Fiber.Scheduler scheduler;
Undocumented in source.
~this
~this()

Clean up when collected. See method detach().

toString
string toString()

Return the name of this conduit.

bufferSize
size_t bufferSize()

Return a preferred size for buffering conduit I/O.

read
size_t read(void[] dst)

Read from conduit into a target array. The provided dst will be populated with content from the conduit.

write
size_t write(const(void)[] src)

Write to conduit from a source array. The provided src content will be written to the conduit.

detach
void detach()

Disconnect this conduit. Note that this may be invoked both explicitly by the user, and implicitly by the GC. Be sure to manage multiple detachment requests correctly: set a flag, or sentinel value as necessary.

timeout
uint timeout [@property setter]

Set the active timeout period for IO calls (in milliseconds.)

timeout
uint timeout [@property getter]

Get the active timeout period for IO calls (in milliseconds.)

isAlive
bool isAlive [@property getter]

Is the conduit alive? Default behaviour returns true.

conduit
IConduit conduit [@property getter]

Return the host. This is part of the Stream interface.

flush
IOStream flush()

Emit buffered output or reset buffered input.

close
void close()

Close this conduit.

error
void error(const(char[]) msg)

Throw an IOException, with the provided message.

input
InputStream input [@property getter]

Return the input stream.

output
OutputStream output [@property getter]

Return the output stream.

put
Conduit put(void[] src)

Emit fixed-length content from 'src' into this conduit, throwing an IOException upon Eof.

get
Conduit get(void[] dst)

Consume fixed-length content into 'dst' from this conduit, throwing an IOException upon Eof.

rewind
Conduit rewind()

Rewind to beginning of file.

copy
OutputStream copy(InputStream src, size_t max)

Transfer the content of another conduit to this one. Returns the dst OutputStream, or throws IOException on failure.

seek
long seek(long offset, Anchor anchor)

Seek on this stream. Source conduits that don't support seeking will throw an IOException.

text
char[] text(size_t max)

Load text from a stream, and return them all in an array.

load
void[] load(size_t max)

Load the bits from a stream, and return them all in an array. The dst array can be provided as an option, which will be expanded as necessary to consume the input.

load
void[] load(InputStream src, size_t max)

Load the bits from a stream, and return them all in an array. The dst array can be provided as an option, which will be expanded as necessary to consume input.

put
void put(void[] src, OutputStream output)

Emit fixed-length content from 'src' into 'output', throwing an IOException upon Eof.

get
void get(void[] dst, InputStream input)

Consume fixed-length content into 'dst' from 'input', throwing an IOException upon Eof.

transfer
size_t transfer(InputStream src, OutputStream dst, size_t max)

Low-level data transfer, where max represents the maximum number of bytes to transfer.

Meta