dmi_decoder_initialize

Synopsis

#include <opendmi/decoder.h>

bool dmi_decoder_initialize(dmi_decoder_t *decoder, dmi_entity_t *entity);

Description

A decoder reads the data of one structure into the values the model holds: dmi_reader_t gives it the bytes, and the structure being decoded says what they refer to, e.g. which string a number stands for. Neither knows of the other, which is what the decoder brings together.

The dmi_decoder_initialize function sets the decoder up over entity. The reader is set up over the body of the structure, positioned right after the header, and reads the copy with additional information applied whenever there is one.

The decoder holds no memory of its own, so there is nothing to destroy: the data belongs to the buffer of the structure.

Parameters

decoder

Decoder to initialize.

entity

Structure to decode.

Return value

true on success, false otherwise.

Errors

DMI_ERROR_ARGUMENT_NULL

Decoder or entity is nullptr.