cdds_index - field index within DDS type

SYNOPSIS

#include "cdds.h"

int cdds_index(bin_tag, field_tag, prime);

BIN_TAG bin_tag
FIELD_TAG field_tag
int prime

DESCRIPTION

This function returns the index of a field within a DDS binary. The index is an array subscript relative to a DDS prime type. This allows the field value to be accessed within a buffer.

INPUT

bin_tag is a binary tag, previously obtained from cdds_open. It specifies a particular binary stream.

field_tag is a tag that identifies a field within bin_tag obtained from cdds_member.

Prime is a tag that identifies a DDS prime type. It must be compatible with the field's prime type. (For a simple byte offset to a field, use cdds_offset.) The field offset must be compatible with the type's precision; a fractional index would be useless. An error is issued, if these assumptions are violated.

Symbolic names for DDS prime types are provided in cdds.h. They correspond to "C" types on the host computer. This allows the prime argument to be host independent. Possible values include:

Host Dependent values
prime                   Host Type
-----                   ---------
DDS_VOID                zero precision
DDS_PTR                 pointer
DDS_CHAR                character
DDS_SCHAR               signed character
DDS_UCHAR               unsigned character
DDS_SHORT               signed integer
DDS_INT                 integer
DDS_LONG                long
DDS_LLONG               long long
DDS_USHORT              unsigned short
DDS_UINT                unsigned integer
DDS_ULONG               unsigned long
DDS_ULLONG              unsigned long long
DDS_FLOAT               floating point
DDS_DOUBLE              double float
DDS_LDOUBLE             long double
DDS_CPX                 complex: struct{float real, imag;}
DDS_DBLCPX              double complex
DDS_LDBLCPX             long double complex
        
Host Independent values
prime                     Data Type
-----                     ---------
DDS_ASCII1                ascii characters
DDS_EBCDIC1               ebcdic characters
DDS_INTEGER1              signed integer*1
DDS_INTEGER2              signed integer*2
DDS_INTEGER4              signed integer*4
DDS_INTEGER8              signed integer*8
DDS_UNSIGNED1             unsigned integer*1
DDS_UNSIGNED2             unsigned integer*2
DDS_UNSIGNED4             unsigned integer*4
DDS_UNSIGNED8             unsigned integer*8
DDS_FLOAT4                IEEE float
DDS_FLOAT4IBM             IBM float
DDS_FLOAT8                IEEE double
DDS_FLOAT8IBM             IBM double
DDS_FLOAT16               IEEE long double
DDS_COMPLEX8              IEEE complex
DDS_COMPLEX8IBM           IBM complex
DDS_COMPLEX16             IEEE double complex
DDS_COMPLEX16IBM          IBM double complex
DDS_COMPLEX32             IEEE long double complex
        

OUTPUT

The return value is the index of field_tag within bin_tag, or -1 if an error occurred.

EXAMPLES

          
            BIN_TAG bin;
            FIELD_TAG field;
            int i_RecNum, RecNum;
            short *buf_short;
            ...
            /* index to RecNum field (short int) */
            field = cdds_member(bin, 0, "RecNum");
            i_RecNum = cdds_index(bin, field, DDS_SHORT);
            ...
            RecNum = buf_short[i_RecNum];
          

SEE ALSO

      cdds_offset Field offset within DDS type
    

AUTHOR

R. L. Selzler, EPTG (Oct 1995)