Iterators
-
struct CowlIterator
Iterator API.
A CowlIterator is a wrapper around a function that gets called for every element matched by a query submitted to a CowlOntology. By providing a generic context pointer, you can plug any data structure (loggers, collections, etc.) which allows for arbitrarily complex programmatic queries.
The iterator function returns a
boolean
that can be used to control iteration: by returningtrue
iteration proceeds to the next element, while returningfalse
causes it to stop. This is useful if, for example, you want to find the first element matching certain criteria.Public Members
-
void *ctx
The iterator context, can be anything.
-
CowlIterator cowl_iterator_vec(UVec_CowlObjectPtr *vec)
Initializes an iterator that stores objects in the specified vector.
Note
When using this iterator, iterator functions return false on error, e.g. when memory cannot be allocated.
Note
If vec is NULL, a new vector is allocated and assigned to the iterator context. You are responsible for deallocating it and releasing its elements.
- Parameters
vec – Vector.
- Returns
Initialized iterator.
-
CowlIterator cowl_iterator_set(UHash_CowlObjectTable *set)
Initializes an iterator that stores objects in the specified set.
Note
When using this iterator, iterator functions return false on error, e.g. when memory cannot be allocated.
Note
If set is NULL, a new set is allocated and assigned to the iterator context. You are responsible for deallocating it and releasing its elements.
- Parameters
set – Set.
- Returns
Initialized iterator.
-
CowlIterator cowl_iterator_count(ulib_uint *count)
Initializes an iterator that counts the objects it iterates on.
Note
If count is NULL, a new unsigned integer is allocated and assigned to the iterator context. You are responsible for deallocating it.
- Parameters
count – Object count.
- Returns
Initialized iterator.
-
void *ctx
Iterator flags
-
typedef uint8_t CowlPrimitiveFlags
These flags are used to control iteration over primitives.
-
COWL_PF_NONE
Iterate over no primitives.
-
COWL_PF_ALL
Iterate over all primitives.
-
COWL_PF_CLASS
Iterate over classes.
-
COWL_PF_OBJ_PROP
Iterate over object properties.
-
COWL_PF_DATA_PROP
Iterate over data properties.
-
COWL_PF_ANNOT_PROP
Iterate over annotation properties.
-
COWL_PF_NAMED_IND
Iterate over named individuals.
-
COWL_PF_ANON_IND
Iterate over anonymous individuals.
-
COWL_PF_DATATYPE
Iterate over datatypes.
-
COWL_PF_ENTITY
Iterate over entities.