BufferedInput

Buffers the flow of data from a upstream input. A downstream neighbour can locate and use this buffer instead of creating another instance of their own.

(Note that upstream is closer to the source, and downstream is further away.)

Constructors

this
this(InputStream stream)

Construct a buffer.

this
this(InputStream stream, size_t capacity)

Construct a buffer.

Members

Aliases

clear
alias clear = flush
Undocumented in source.
input
alias input = InputFilter.input
Undocumented in source.

Functions

capacity
size_t capacity()

Access buffer capacity.

drain
size_t drain(OutputStream dst)

Drain buffer content to the specific conduit.

fill
size_t fill(void[] dst, bool exact)

Fill the provided buffer. Returns the number of bytes actually read, which will be less that dst.length when Eof has been reached and Eof thereafter.

flush
BufferedInput flush()

Clear buffer content.

load
void[] load(size_t max)

Load the bits from a stream, up to an indicated length, and return them all in an array. The function may consume more than the indicated size where additional data is available during a block read operation, but will not wait for more than specified. An Eof terminates the operation.

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

Iterator support.

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

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

populate
size_t populate()

Place more data from the source stream into this buffer, and return the number of bytes added. This does not compress the current buffer content, so consider doing that explicitly.

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.

reserve
size_t reserve(size_t space)

Reserve the specified space within the buffer, compressing existing content as necessary to make room.

seek
long seek(long offset, Anchor start)

Move the current read location.

skip
bool skip(ptrdiff_t size)

Move the current read location.

slice
void[] slice()

Retrieve the valid content.

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

Access buffer content.

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

Write into this buffer.

Properties

compress
BufferedInput compress [@property getter]

Compress buffer space.

input
InputStream input [@property setter]

Set the input stream.

limit
size_t limit [@property getter]

Access buffer limit.

position
size_t position [@property getter]

Access buffer read position.

readable
size_t readable [@property getter]

Available content.

Static functions

convert
inout(T)[] convert(inout(void)[] x)

Cast to a target type without invoking the wrath of the runtime checks for misalignment. Instead, we truncate the array length.

create
InputBuffer create(InputStream stream)

Attempt to share an upstream Buffer, and create an instance where there's not one available.

Inherited Members

From InputFilter

source
InputStream source;
Undocumented in source.
conduit
IConduit conduit [@property getter]

Return the hosting conduit.

read
size_t read(void[] dst)

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

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.

flush
IOStream flush()

Clear any buffered content.

seek
long seek(long offset, Anchor anchor)

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

input
InputStream input [@property getter]

Return the upstream host of this filter.

close
void close()

Close the input.

Meta