table of contents
gd_nentries(3) | GETDATA | 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 dirfileSYNOPSIS¶
#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 gd_nentries() function queries a dirfile(5) database specified by dirfile and returns a count of metadata entries satisfying the supplied criteria. If parent is non-NULL, metafields under the field specified by parent are considered; otherwise, top-level fields are considered, and metafields ignored.The type 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_LINCOM_ENTRY, GD_LINTERP_ENTRY, GD_MPLEX_ENTRY, GD_MULTIPLY_ENTRY, GD_PHASE_ENTRY, GD_POLYNOM_ENTRY, GD_RAW_ENTRY, GD_RECIP_ENTRY, GD_SBIT_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:
- GD_ALL_ENTRIES (= 0)
- Count entries of all types.
- GD_ALIAS_ENTRIES
- Count only aliases. This is the only way to get a count including aliases which do not point to valid field codes.
- GD_SCALAR_ENTRIES
- Count only scalar field types (CONST, CARRAY, STRING).
- GD_VECTOR_ENTRIES
- Count only vector field types (all field types except the scalar field types listed above).
The flags argument should be zero or more of the following flags, bitwise or'd together:
- GD_ENTRIES_HIDDEN
- Include hidden entries (see gd_hidden(3)) in the count: normally hidden entries are skipped;
- GD_ENTRIES_NOALIAS
- 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).
Special Cases¶
The callis equivalent to
The call
is equivalent to
The call
is equivalent to
The call
is equivalent to
The call
is equivalent to
The call
is equivalent to
RETURN VALUE¶
Upon successful completion, these functions return the number of entries in the database satisfying the supplied criteria. On error, they return zero and sets the dirfile error to a non-zero error value. Possible error values are:- GD_E_BAD_CODE
- The supplied parent field code was not found, or referred to a metafield itself.
- GD_E_BAD_DIRFILE
- The supplied dirfile was invalid.
- GD_E_BAD_ENTRY
- The type parameter supplied was not one of the symbols listed above.
The dirfile error may be retrieved by calling gd_error(3). A descriptive error string for the last error encountered can be obtained from a call to gd_error_string(3).
SEE ALSO¶
dirfile(5), gd_open(3), gd_entry_list(3), gd_error(3), gd_error_string(3), gd_hidden(3)28 June 2012 | Version 0.8.0 |