tibrvMsgData_Encoder

Function Type

Declaration

typedef tibrv_status (*tibrvMsgData_Encoder)(
    char**               wire_buffer,
    tibrv_u32            mem_available,
    tibrvMsgField*       field);

Purpose

Encode a local format field to wire format.

Remarks

Programs define encoders for custom datatypes. Layer 2 encoder functions translate custom datatypes into Rendezvous wire format.

Each encoder must fulfill these responsibilities:

Check that the field contains valid data of the appropriate type.
Check that the data will fit in the available space; if not, return the error status TIBRV_NO_MEMORY.

The encoder can use tibrvMsgData_ByteSize() to compute the wire size of the data.

Write the data into wire buffer of the message. Do not overwrite space that is not available.
Advance *wire_buffer to the end of the destination data (in the message). tibrvMsgData_CopyBytes() automatically advances this buffer pointer.
Check consistency, and properly address byte order and endian issues.

Note 

If your encoder implementation allocates process storage, it must call tibrvMsgData_Malloc() rather than malloc.

Parameter

Description

wire_buffer

This parameter receives the location of an address within the wire buffer of the destination message. The encoder must write the wire-format encoded data to this destination.

We strongly recommend using tibrvMsgData_CopyBytes() to transfer the data.

mem_available

This parameter receives the size of the available storage in the message’s wire buffer.

field

This parameter receives a field object, with self-describing data in local format. This source field determines the data to place into the destination wire_buffer.

Figure 196: Advancing the Wire Buffer Pointer

See Also

tibrvMsgField

tibrvMsgData_ByteSize()

tibrvMsgData_CopyBytes()