C API Factsheet functions

From RL3 Wiki
Jump to: navigation, search

rl3_factsheet_create

struct RL3_Factsheet* rl3_factsheet_create(struct RL3_Engine* engine);

Create a new factsheet.

engine: a pointer to an engine structure
Returns: a pointer to a new factsheet structure

rl3_factsheet_derive

TBD!!! Clarify

struct RL3_Factsheet* rl3_factsheet_derive(struct RL3_Engine* engine, struct RL3_Factsheet* factsheet, unsigned char local);

rl3_factsheet_destroy

void rl3_factsheet_destroy(struct RL3_Engine* engine, struct RL3_Factsheet* factsheet);

Destroy a factsheet to release memory.

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

rl3_factsheet_assert_fact

void rl3_factsheet_assert_fact(struct RL3_Engine* engine, struct RL3_Factsheet* factsheet, const struct RL3_Fact* fact);

Assert a fact (either simple or based on other facts/ factsheets) to a factsheet.
To use the function, a new Fact object should be created first.

engine: a pointer to an engine structure
factsheet: a pointer to a factsheet structure
fact: a pointer to a fact structure
Returns: nothing

rl3_factsheet_assert_simple_fact

void rl3_factsheet_assert_simple_fact(struct RL3_Engine* engine, struct RL3_Factsheet* factsheet, const char* label, const char* value, double weight);

Assert a simple fact to a factsheet with omitting the creation of a Fact object.

engine: a pointer to an engine structure
factsheet: a pointer to a factsheet structure
label: a name (label) of a fact
value: fact value
weight: fact weight
Returns: nothing

rl3_factsheet_retract_fact

void rl3_factsheet_retract_fact(struct RL3_Engine* engine, struct RL3_Factsheet* factsheet, struct RL3_FactIterator* iterator);

Remove a fact from a factsheet.

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

rl3_factsheet_retract_facts

void rl3_factsheet_retract_facts(struct RL3_Engine* engine, struct RL3_Factsheet* factsheet, const char* label);

Remove multiple facts from a factsheet.

engine: a pointer to an engine structure
factsheet: a pointer to a factsheet structure
label: a pointer to the first character in the fact name (label)
Returns: nothing

rl3_factsheet_has_fact

unsigned char rl3_factsheet_has_fact(struct RL3_Engine* engine, const struct RL3_Factsheet* factsheet, const char* label);

Check whether a fact is in a factsheet.

engine: a pointer to an engine structure
factsheet: a pointer to a factsheet structure
label: a pointer to the first character in the fact name (label)
Returns: 1 if the fact label is in the factsheet, 0 if otherwise

rl3_factsheet_facts_count

unsigned int rl3_factsheet_facts_count(struct RL3_Engine* engine, const struct RL3_Factsheet* factsheet, const char* label);

Get the fact count in a factsheet by label.

engine: a pointer to an engine structure
factsheet: a pointer to a factsheet structure
label: a pointer to the first character in the fact name (label)
Returns: integer (in the non-negative integer range)

rl3_factsheet_get_fact_iterator

struct RL3_FactIterator* rl3_factsheet_get_fact_iterator(struct RL3_Engine* engine, const struct RL3_Factsheet* factsheet, const char* label);

Create an iterator to cycle through the facts with a defined label in a factsheet.

engine: a pointer to an engine structure
factsheet: a pointer to a factsheet structure
file_path: a pointer to the first character in the fact name (label)
Returns: a pointer to the FactIterator structure

rl3_factsheet_get_first_fact_iterator

struct RL3_FactIterator* rl3_factsheet_get_first_fact_iterator(struct RL3_Engine* engine, const struct RL3_Factsheet* factsheet);

Create an iterator for the first fact in a factsheet.

engine: a pointer to an engine structure
factsheet: a pointer to a factsheet structure
Returns: a pointer to the FactIterator structure

rl3_factsheet_get_factpath_iterator

struct RL3_FactPathIterator* rl3_factsheet_get_factpath_iterator(struct RL3_Engine* engine, const struct RL3_Factsheet* factsheet, const char* path);

Create an iterator that can go down the fact tree by path.

engine: a pointer to an engine structure
factsheet: a pointer to a factsheet structure
path: a path to a descendant element in a fact tree
Returns: a pointer to the FactIterator structure

rl3_factsheet_to_json

const char* rl3_factsheet_to_json(RL3_Engine* engine, RL3_Factsheet* factsheet, RL3_SharedText* root_text, unsigned char include_text);

Save Fact as JSON string.

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

rl3_factsheet_from_json

RL3_Factsheet* rl3_factsheet_from_json(RL3_Engine* engine, const char* json, RL3_SharedText* root_text);

Restore Factsheet from JSON string.

engine: a pointer to an engine structure
json: an input json string (zero terminated).
root_text: NULL if a factsheet should be considered as an independent / self-containing structure.
Returns: a pointer to a new factsheet structure.

rl3_factsheet_from_html

RL3_Factsheet* rl3_factsheet_from_html(RL3_Engine* engine, const char* html);

Create Factsheet from HTML string.

engine: a pointer to an engine structure
html: an input HTML string (zero terminated).
Returns: a pointer to a new factsheet structure.