General Information about PEXlib Encode and Decode Output Commands


For a list of Encode and Decode functions and related topics, see Output Command Encode and Decode.

Encode and decode output commands are provided for applications that need to generate protocol-formatted output commands for use in archives or client-side data storage. Likewise, your application may need to decode the protocol-formatted output commands returned from functions like PEXFetchElements. The functions described in this chapter provide for these operations.

For complete information on protocol format, see the PEX Protocol Specification.

For the definition of the PEXOCData data structure, please refer to the PEXlib.h file that accompanies your PEX implementation. The data structure is too large to reproduce here in its entirety.

Handling Exception OC's Defined After 5.1

For a list of Encode and Decode functions and related topics, see Output Command Encode and Decode.

Using the PEXOCData structure with the encode and decode functions is straightforward for all the output commands defined in PEX 5.1 and PEX 5.2 except for SetLocalTransformWithHints. Except for this single OC, you simply use an array of PEXOCData, one element for each OC, and fill in or read the OC data in each PEXOCData element, using one of the structs in the PEXOCData union, selected by the OC type.

Here is an abbreviated version of the PEXOCData data structure:

typedef struct {
  unsigned short oc_type;
  union {
    struct {
      unsigned long count;
      PEXName *names;
    } AddToNameSet;
    ...
    < additional structs for 5.1 and 5.2 OC's >
    ...
    struct {
PEXSetLocalTransformWithHintsOCData *ocptr; } SetLocalTransformWithHints; ...
< other structs for 5.2 OC's > } data; } PEXOCData; typedef struct { ... } PEXSetLocalTransformWithHintsOCData;

The SetLocalTransformWithHints OC is the only 5.2 OC larger in size than the largest 5.1 OC, and would cause the size of the PEXOCData structure to increase in size if a new structure was simply added to the PEXOCData structure. This would break binary compatibility between applications compiled with PEXlib 5.1 header files, but linked (dynamically) with PEXlib 5.2 library implementations.

The solution specified for this OC is to use a pointer in the SetLocalTransformWithHints structure to point to another disjoint area of storage that contains the OC data for this OC. This storage area is mapped with the PEXSetLocalTransformWithHintsOCData structure.

Here is a diagram of the data storage layout for an array of PEXOCData structures that contains a SetLocalTransformWithHints output command: