dmi_entity_encode

Synopsis

#include <opendmi/entity.h>

bool dmi_entity_encode(dmi_encoder_t *encoder);

Description

The dmi_entity_encode function writes a structure back into the bytes it is made of, undoing what dmi_entity_decode has done.

Structures whose specification describes their layout are encoded by its fields, see dmi_fields_encode, and the rest by the encoding handler of the specification. Structures which carry no data the model holds, such as the end-of-table one, and the ones of the types no specification describes, are kept as they are in the preserve mode: their bytes are all the model the structure has.

The encoder is set up with dmi_encoder_initialize, which writes the header, and the formatted area is completed with dmi_encoder_finish.

Parameters

encoder

Encoder of the structure, see dmi_encoder_initialize.

Return value

true if the structure has been encoded, false otherwise.

Errors

DMI_ERROR_ARGUMENT_NULL

Encoder is nullptr.

DMI_ERROR_STATE_INVALID

Structure cannot be encoded: its type has no specification and the mode is the canonical one, or its specification decodes it by a handler with no encoding one.

DMI_ERROR_OUT_OF_MEMORY

Buffers of the encoder cannot grow.