C API FactIterator functions

From RL3 Wiki
Jump to: navigation, search


rl3_factiterator_destroy

void rl3_factiterator_destroy(struct RL3_Engine* engine, struct RL3_FactIterator* iterator);

Delete an iterator to release memory.

engine: a pointer to an engine structure
iterator: a pointer to an iterator structure
Returns: nothing

rl3_factiterator_is_end

unsigned char rl3_factiterator_is_end(struct RL3_Engine* engine, struct RL3_FactIterator* iterator);

Define whether an iterator has looked through all the items in a data structure.

engine: a pointer to an engine structure
iterator: a pointer to an iterator structure
Returns: 1 if there are no more items to be looked through in a data structure, 0 if otherwise

rl3_factiterator_next

unsigned char rl3_factiterator_next(struct RL3_Engine* engine, struct RL3_FactIterator* iterator);

Obtain the next element in an iteration.

engine: a pointer to an engine structure
iterator: a pointer to an iterator structure
Returns: 1 if there is a next element for a new iteration, 0 if otherwise

rl3_factiterator_get_label

const char* rl3_factiterator_get_label(struct RL3_Engine* engine, struct RL3_FactIterator* iterator);

Get a fact name (label) when iterating.

engine: a pointer to an engine structure
iterator: a pointer to an iterator structure
Returns: a pointer to the first character in the return string

rl3_factiterator_get_value

const char* rl3_factiterator_get_value(struct RL3_Engine* engine, struct RL3_FactIterator* iterator);

Get a fact value when iterating.

engine: a pointer to an engine structure
iterator: a pointer to an iterator structure
Returns: a pointer to the first character in the return string

rl3_factiterator_get_weight

double rl3_factiterator_get_weight(struct RL3_Engine* engine, struct RL3_FactIterator* iterator);

Get a fact weight when iterating.

engine: a pointer to an engine structure
iterator: a pointer to an iterator structure
Returns: double

rl3_factiterator_get_annotation_start

unsigned int rl3_factiterator_get_annotation_start(struct RL3_Engine* engine, struct RL3_FactIterator* iterator);

Get a fact start position when iterating (measured in Unicode characters, not bytes).

engine: a pointer to an engine structure
iterator: a pointer to an iterator structure
Returns: integer (in the non-negative integer range)

rl3_factiterator_get_annotation_end

unsigned int rl3_factiterator_get_annotation_end(struct RL3_Engine* engine, struct RL3_FactIterator* iterator);

Get a fact end position when iterating (measured in Unicode characters, not bytes).

engine: a pointer to an engine structure
iterator: a pointer to an iterator structure
Returns: integer (in the non-negative integer range)

rl3_factiterator_has_factsheet

unsigned char rl3_factiterator_has_factsheet(struct RL3_Engine* engine, struct RL3_FactIterator* iterator);

Define whether a fact contains a factsheet when iterating.

engine: a pointer to an engine structure
iterator: a pointer to an iterator structure
Returns: 1 if a fact contains a factsheet, 0 if otherwise.

rl3_factiterator_get_factsheet

const struct RL3_Factsheet* rl3_factiterator_get_factsheet(struct RL3_Engine* engine, struct RL3_FactIterator* iterator);

Get a factsheet from a fact when iterating.



engine: a pointer to an engine structure
iterator: a pointer to an iterator structure
Returns: a pointer to a factsheet structure; if a fact does not contain a factsheet, the function returns null.

rl3_factiterator_to_json

const char* rl3_factiterator_to_json(RL3_Engine* engine, RL3_FactIterator* iterator, RL3_SharedText* root_text, unsigned char include_text);

Save associated Fact as JSON string.

engine: a pointer to an engine structure
iterator: a pointer to iterator structure containing fact to be serializer
root_text: NULL if fact should be considered as independent / self-containing structure.
include_text 1 if text field should be included in the output; 0 otherwise.
Returns: a pointer to the first character in the return string.