C API FactIterator functions
FactIterator manages FactIterator objects created in FactSheets with the help of rl3_factsheet_get_fact_iterator and rl3_factsheet_get_factpath_iterator functions. |
Contents
- 1 rl3_factiterator_destroy
- 2 rl3_factiterator_is_end
- 3 rl3_factiterator_next
- 4 rl3_factiterator_get_label
- 5 rl3_factiterator_get_value
- 6 rl3_factiterator_get_weight
- 7 rl3_factiterator_get_annotation_start
- 8 rl3_factiterator_get_annotation_end
- 9 rl3_factiterator_has_factsheet
- 10 rl3_factiterator_get_factsheet
- 11 rl3_factiterator_to_json
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.
The get_factsheet() function should not be confused with a similar function for the FactSheet structure.
The difference is in the return type in case a fact contains no factsheet:
|
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. |