gd_nentries(3)

NAME
gd_nentries, gd_nfields, gd_nfields_by_type gd_nmfields, gd_nmfields_by_type, gd_nmvectors, gd_nvectors — count field entries in a Dirfile

SYNOPSIS
#include <getdata.h>

unsigned int gd_nentries(DIRFILE *dirfile, const char *parent, unsigned int type, unsigned int flags);

unsigned int gd_nfields(DIRFILE *dirfile);

unsigned int gd_nfields_by_type(DIRFILE *dirfile, gd_entype_t type);

unsigned int gd_nmfields(DIRFILE *dirfile, const char *parent);

unsigned int gd_nmfields_by_type(DIRFILE *dirfile, const char *parent, gd_entype_t type);

unsigned int gd_nmvectors(DIRFILE *dirfile, const char *parent);

unsigned int gd_nvectors(DIRFILE *dirfile);

DESCRIPTION
The function queries a dirfile(5) database specified by and counts the number of metadata entries satisfying the provided criteria. If is non-NULL, metafields under the field specified by are considered; otherwise, top-level fields are considered, and metafields ignored.

The argument should be one of the following symbols indicating an explicit entry type to count:

    GD_BIT_ENTRY, GD_CARRAY_ENTRY, GD_CONST_ENTRY, GD_DIVIDE_ENTRY, GD_INDEX_ENTRY, GD_INDIR_ENTRY, GD_LINCOM_ENTRY, GD_LINTERP_ENTRY, GD_MPLEX_ENTRY, GD_MULTIPLY_ENTRY, GD_PHASE_ENTRY, GD_POLYNOM_ENTRY, GD_RAW_ENTRY, GD_RECIP_ENTRY, GD_SARRAY_ENTRY, GD_SBIT_ENTRY, GD_SINDIR_ENTRY, GD_STRING_ENTRY, GD_WINDOW_ENTRY.

(GD_INDEX_ENTRY is a special field type for the implicit INDEX field) or else one of the following special symbols: Count entries of all types. Count only aliases. This is the only way to get a count including aliases which do not point to valid field codes. Count only scalar field types (CONST, CARRAY, SARRAY, STRING). Count only numeric-valued vector field types (all field types except SINDIR and the scalar field types listed above).

The argument should be zero or more of the following flags, bitwise or'd together: Include hidden entries (see in the count: normally hidden entries are skipped; Exclude aliases from the count: normally aliases are considered the same as their target (that is: a field with n aliases, plus its canonical name, will be counted n+1 times).

This function has a subset of the functionality of the function (q.v.).

  Special Cases
The call
    gd_nfields(dirfile);

is equivalent to
    gd_nentries(dirfile, NULL, GD_ALL_ENTRIES, 0);

The call
    gd_nfields_by_type(dirfile, type);

is equivalent to
    gd_nentries(dirfile, NULL, type, 0);

The call
    gd_nmfields(dirfile, parent);

is equivalent to
    gd_nentries(dirfile, parent, GD_ALL_ENTRIES, 0);

The call
    gd_nmfields_by_type(dirfile, parent, type);

is equivalent to
    gd_nentries(dirfile, parent, type, 0);

The call
    gd_nmvectors(dirfile, parent);

is equivalent to
    gd_nentries(dirfile, parent, GD_VECTOR_ENTRIES, 0);

The call
    gd_nvectors(dirfile);

is equivalent to
    gd_nentries(dirfile, NULL, GD_VECTOR_ENTRIES, 0);

RETURN VALUE
Upon successful completion, these functions return an unsigned in indicating the number of entries in the database satisfying the supplied criteria.

On error, these functions return zero and store a negative-valued error code in the DIRFILE object which may be retrieved by a subsequent call to Possible error codes are: The supplied parent field code was not found, or referred to a metafield itself. The supplied dirfile was invalid. The parameter supplied was not one of the symbols listed above.

A descriptive error string for the error may be obtained by calling

HISTORY
The function appeared in GetData-0.3.0.

The and functions appeared in GetData-0.4.0.

In GetData-0.7.0, these functions were renamed to and

The function appeared in GetData-0.8.0.

SEE ALSO
dirfile(5),