- Main Page
- Modules
- Files
- Related Pages
- Examples

# Iterating on keys names

## Defines
#define | GRIB_KEYS_ITERATOR_ALL_KEYS 0
#define | GRIB_KEYS_ITERATOR_SKIP_READ_ONLY (1<<0)
#define | GRIB_KEYS_ITERATOR_SKIP_OPTIONAL (1<<1)
#define | GRIB_KEYS_ITERATOR_SKIP_EDITION_SPECIFIC (1<<2)
#define | GRIB_KEYS_ITERATOR_SKIP_CODED (1<<3)
#define | GRIB_KEYS_ITERATOR_SKIP_COMPUTED (1<<4)
#define | GRIB_KEYS_ITERATOR_SKIP_DUPLICATES (1<<5)
#define | GRIB_KEYS_ITERATOR_SKIP_FUNCTION (1<<6)
## Typedefs
typedef struct grib_keys_iterator | grib_keys_iterator
## Functions
grib_keys_iterator * | grib_keys_iterator_new (grib_handle *h, unsigned long filter_flags, char *name_space)
int | grib_keys_iterator_next (grib_keys_iterator *kiter)
const char * | grib_keys_iterator_get_name (grib_keys_iterator *kiter)
int | grib_keys_iterator_delete (grib_keys_iterator *kiter)
int | grib_keys_iterator_rewind (grib_keys_iterator *kiter)

## Detailed Description

The keys iterator is designed to get the key names defined in a message. Key names on which the iteration is carried out can be filtered through their attributes or by the namespace they belong to.

## Define Documentation

#define GRIB_KEYS_ITERATOR_ALL_KEYS 0

Iteration is carried out on all the keys available in the message

See also:
  grib_keys_iterator_new

Examples:
  keys_iterator.c.

#define GRIB_KEYS_ITERATOR_SKIP_CODED (1<<3)

coded keys are skipped by keys iterator.

See also:
  grib_keys_iterator_new

#define GRIB_KEYS_ITERATOR_SKIP_COMPUTED (1<<4)

computed keys are skipped by keys iterator.

See also:
  grib_keys_iterator_new

#define GRIB_KEYS_ITERATOR_SKIP_DUPLICATES (1<<5)

duplicates of a key are skipped by keys iterator.

See also:
  grib_keys_iterator_new

#define GRIB_KEYS_ITERATOR_SKIP_EDITION_SPECIFIC (1<<2)

edition specific keys are skipped by keys iterator.

See also:
  grib_keys_iterator_new

#define GRIB_KEYS_ITERATOR_SKIP_FUNCTION (1<<6)

function keys are skipped by keys iterator.

See also:
  grib_keys_iterator_new

#define GRIB_KEYS_ITERATOR_SKIP_OPTIONAL (1<<1)

optional keys are skipped by keys iterator.

See also:
  grib_keys_iterator_new

#define GRIB_KEYS_ITERATOR_SKIP_READ_ONLY (1<<0)

read only keys are skipped by keys iterator.

See also:
  grib_keys_iterator_new

## Typedef Documentation

typedef struct grib_keys_iterator grib_keys_iterator

Grib keys iterator. Iterator over keys.

Examples:
  keys_iterator.c, and keys_iterator_fortran.F.

## Function Documentation

int grib_keys_iterator_delete | ( | grib_keys_iterator * | kiter | ) |

Delete the iterator.

Parameters:

  | kiter | : valid grib_keys_iterator

Returns:
  0 if OK, integer value on error

Examples:
  keys_iterator.c, keys_iterator.f90, and keys_iterator_fortran.F.

const char* grib_keys_iterator_get_name | ( | grib_keys_iterator * | kiter | ) |

get the key name from the iterator

Parameters:

  | kiter | : valid grib_keys_iterator

Returns:
  key name

Examples:
  keys_iterator.c, keys_iterator.f90, and keys_iterator_fortran.F.

grib_keys_iterator* grib_keys_iterator_new | ( | grib_handle * | h,
|  | unsigned long | filter_flags,
|  | char * | name_space |
| ) |  |  |

Create a new iterator from a valid and initialized handle.

Parameters:

  | h | : the handle whose keys you want to iterate
  | filter_flags | : flags to filter out some of the keys through their attributes
  | name_space | : if not null the iteration is carried out only on keys belongin to the namespace passed. (NULL for all the keys)

Returns:
  keys iterator ready to iterate through keys according to filter_flags and namespace

Examples:
  keys_iterator.c, and keys_iterator.f90.

int grib_keys_iterator_next | ( | grib_keys_iterator * | kiter | ) |

Step to the next iterator.

Parameters:

  | kiter | : valid grib_keys_iterator

Returns:
  1 if next iterator exitsts, 0 if no more elements to iterate on

Examples:
  keys_iterator.c, keys_iterator.f90, and keys_iterator_fortran.F.

int grib_keys_iterator_rewind | ( | grib_keys_iterator * | kiter | ) |

Rewind the iterator.

Parameters:

  | kiter | : valid grib_keys_iterator

Returns:
  0 if OK, integer value on error