std1.0.0-beta-7 SafeC docs

std :: io_buf

Struct std::BufReader

#include <std/io_buf.h> source

generic<R: Reader> struct BufReader {
    &R inner;
    unsigned long pos;
    unsigned long len;
    unsigned char buf[IO_BUF_SIZE];
}

Fields

§&R innersource

the stream read from (borrowed)

§unsigned long possource

next unread byte in buf

§unsigned long lensource

bytes in buf

§unsigned char buf[IO_BUF_SIZE]source

Methods

§static struct BufReader<R> over(&R inner)source · definition
§long long read([]unsigned char out)source · definition

Reader: at most n bytes, from the buffer first. A read of at least IO_BUF_SIZE bytes with nothing buffered goes straight to the stream. The count read, 0 at the stream's end, -1 on error.

§int read_until(&String out, const &char term)source · definition

Appends bytes to 'out' up to and including the first occurrence of 'term' (a non-empty string; "\n" reads a line, "\r\n\r\n" an HTTP header block). 1 when 'term' arrived; 0 when the stream ended or failed first ('out' then holds what did arrive). Bytes after 'term' stay buffered for the next read.

§unsigned long buffered() constsource · definition

Bytes already read from the stream and not yet returned: a read of at most this many doesn't touch the stream.