The field management API gives programmatic access to configured fields. A field can be referenced in a number of ways, these functions provide ways to access and map between them.
A field contains:
- index. This is a zero based index for all the fields
- field name. This is a text string
- field number. This is an integer between -65535 and 65535
- flags. Flags associated with this field
The index is useful for storing or keeping track of fields in an application. It is also the fastest lookup method to access the other attributes and allows you to loop through all the fields if required.
#define DS_FIELDS_NOT_DEFINED |
Value returned by field API functions when a field is not defined.
int ds_fields_add |
( |
int |
num, |
|
|
const char * |
name, |
|
|
int |
flags, |
|
|
int |
dp, |
|
|
const char * |
fmt |
|
) |
| |
Add a new field to the field list.
- Parameters
-
num | Field number to add |
name | Name of the field to add |
flags | Field flags |
dp | Decimal place precision |
fmt | Format string of the field value |
- Return values
-
DS_FIELDS_NOT_DEFINED | - if the field couldn't be added |
- Returns
- The index of this field
int ds_fields_getdp |
( |
int |
index | ) |
|
Return the decimal precision of this index.
- Parameters
-
- Returns
- The field's decimal precision
int ds_fields_getflags |
( |
int |
index | ) |
|
Return the field flags of this index.
- Parameters
-
- Returns
- The field's flags
int ds_fields_indexbyname |
( |
const char * |
name | ) |
|
Return the index of this field.
- Parameters
-
- Returns
- Field index
- Return values
-
DS_FIELDS_NOT_DEFINED | - if the field is not recognised |
int ds_fields_indexbynum |
( |
int |
num | ) |
|
Return the index of this field.
- Parameters
-
- Returns
- Field index
- Return values
-
DS_FIELDS_NOT_DEFINED | - if the field is not recognised |
Return the number of fields that have been defined.
- Returns
- The number of fields that have been defined
char* ds_fields_namebyindex |
( |
int |
index | ) |
|
Return the field name of this index.
- Parameters
-
- Returns
- Field name
char* ds_fields_namebynum |
( |
int |
num | ) |
|
Return the field name of this field number.
- Parameters
-
- Return values
-
Field | name |
NULL | if not known |
int ds_fields_numbyindex |
( |
int |
index | ) |
|
Return the field number of this index.
- Parameters
-
- Returns
- Field number
- Return values
-
DS_FIELDS_NOT_DEFINED | - invalid index supplied |
int ds_fields_numbyname |
( |
const char * |
name | ) |
|
Return the field number of this field.
- Parameters
-
- Returns
- Field number
- Return values
-
DS_FIELDS_NOT_DEFINED | - if the field is not recognised |