BufferedInput.slice

Access buffer content.

  1. void[] slice()
  2. void[] slice(size_t size, bool eat)
    class BufferedInput
    final
    void[]
    slice
    (,
    bool eat = true
    )

Parameters

size size_t

Number of bytes to access.

eat bool

Whether to consume the content or not.

Return Value

Type: void[]

The corresponding buffer slice when successful, or null if there's not enough data available (Eof; Eob).

Remarks: Read a slice of data from the buffer, loading from the conduit as necessary. The specified number of bytes is sliced from the buffer, and marked as having been read when the 'eat' parameter is set true. When 'eat' is set false, the read position is not adjusted.

Note that the slice cannot be larger than the size of the buffer ~ use method fill(void[]) instead where you simply want the content copied, or use conduit.read() to extract directly from an attached conduit. Also note that if you need to retain the slice, then it should be .dup'd before the buffer is compressed or repopulated.

Examples

// create a buffer with some content
auto buffer = new Buffer ("hello world");

// consume everything unread
auto slice = buffer.slice (buffer.readable);

Meta