dmi_reader_initialize

Synopsis

#include <opendmi/reader.h>

bool dmi_reader_initialize(
        dmi_reader_t       *reader,
        const dmi_buffer_t *buffer,
        size_t              offset,
        size_t              length);

Description

The dmi_reader_initialize function sets the reader up over length bytes at offset within buffer. The cursor is positioned at the beginning of the range, and the reader reads nothing outside it.

A reader reads bytes out of a range of a dmi_buffer_t, which holds them, the way dmi_writer_t writes them into one. What the bytes stand for is of no concern to the reader: the range it is given is a structure body, an entry point or whatever else the caller reads. Reading the values of a structure is what dmi_decoder_t does over a reader, see dmi_decoder_initialize.

The reader holds no memory of its own, so there is nothing to destroy: the data belongs to the buffer and outlives the readers of it.

Parameters

reader

Reader to initialize.

buffer

Buffer holding the data to read.

offset

Offset the range begins at within the buffer.

length

Number of the bytes of the range.

Return value

true on success, false if reader or buffer is nullptr, or if the buffer holds fewer bytes than the range.

Errors

None.