Hash :
b3bc87e4
Author :
Thomas de Grivel
Date :
2024-12-04T16:20:49
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
/* kc3
* Copyright 2022,2023,2024 kmx.io <contact@kmx.io>
*
* Permission is hereby granted to use this software granted the above
* copyright notice and this permission paragraph are included in all
* copies and substantial portions of this software.
*
* THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
* PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
#ifndef LIBKC3_FACTS_H
#define LIBKC3_FACTS_H
#include "types.h"
#include "config.h"
#define FACTS_EXT ".facts"
#define facts_count(f) ((f)->facts.count)
/* Stack allocation compatible functions */
void facts_clean (s_facts *facts);
s_facts * facts_init (s_facts *facts);
/* Constructors */
s_facts * facts_new (void);
/* Destructor */
void facts_delete (s_facts *facts);
/* Modifiers */
s_fact * facts_add_fact (s_facts *facts, s_fact *fact);
s_fact * facts_add_tags (s_facts *facts, s_tag *subject,
s_tag *predicate, s_tag *object);
void facts_close (s_facts *facts);
sw facts_load (s_facts *facts, s_buf *buf,
const s_str *path);
sw facts_load_file (s_facts *facts, const s_str *path);
sw facts_open_file (s_facts *facts, const s_str *path);
s_tag * facts_ref_tag (s_facts *facts, s_tag *tag);
bool * facts_remove_fact (s_facts *facts, const s_fact *fact,
bool *dest);
bool * facts_remove_fact_tags (s_facts *facts,
s_tag *subject,
s_tag *predicate,
s_tag *object,
bool *dest);
s_facts * facts_remove_all (s_facts *facts);
s_fact * facts_replace_fact (s_facts *facts, s_fact *fact);
s_fact * facts_replace_tags (s_facts *facts, s_tag *subject,
s_tag *predicate, s_tag *object);
sw facts_save_file (s_facts *facts, const char *path);
s_facts_transaction *
facts_transaction_clean (s_facts_transaction *transaction);
s_facts * facts_transaction_rollback
(s_facts *facts, const s_facts_transaction *transaction);
void facts_transaction_start
(s_facts *facts, s_facts_transaction *transaction);
bool facts_unref_tag (s_facts *facts, const s_tag *tag);
/* Observers */
sw facts_dump (s_facts *facts, s_buf *buf);
sw facts_dump_file (s_facts *facts, const char *path);
s_fact ** facts_find_fact (s_facts *facts, const s_fact *fact,
s_fact **dest);
s_fact ** facts_find_fact_by_tags (s_facts *facts,
s_tag *subject,
s_tag *predicate,
s_tag *object,
s_fact **dest);
s_tag ** facts_find_tag (s_facts *facts, const s_tag *tag,
s_tag **dest);
sw facts_log_add (s_log *log, const s_fact *fact);
sw facts_log_remove (s_log *log, const s_fact *fact);
#endif /* LIBKC3_FACTS_H */