Tag
Hash :
0076f19f
Author :
Thomas de Grivel
Date :
2023-11-14T22:54:24
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
/* c3
* Copyright 2022,2023 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 LIBC3_FACTS_H
#define LIBC3_FACTS_H
#include "types.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, const s_fact *fact);
s_fact * facts_add_tags (s_facts *facts, const s_tag *subject,
const s_tag *predicate,
const 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);
void facts_lock_clean (s_facts *facts);
void facts_lock_init (s_facts *facts);
void facts_lock_r (s_facts *facts);
void facts_lock_unlock_r (s_facts *facts);
void facts_lock_unlock_w (s_facts *facts);
void facts_lock_w (s_facts *facts);
sw facts_open_file (s_facts *facts, const s_str *path);
s_tag * facts_ref_tag (s_facts *facts, const s_tag *tag);
bool facts_remove_fact (s_facts *facts, const s_fact *fact);
s_fact * facts_replace_fact (s_facts *facts, const s_fact *fact);
s_fact * facts_replace_tags (s_facts *facts, const s_tag *subject,
const s_tag *predicate,
const s_tag *object);
sw facts_save_file (s_facts *facts, const s8 *path);
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 s8 *path);
s_fact * facts_find_fact (s_facts *facts, const s_fact *fact);
s_fact * facts_find_fact_by_tags (s_facts *facts, const s_tag *subject,
const s_tag *predicate,
const s_tag *object);
s_tag * facts_find_tag (s_facts *facts, const s_tag *tag);
sw facts_log_add (s_log *log, const s_fact *fact);
sw facts_log_remove (s_log *log, const s_fact *fact);
#endif /* LIBC3_FACTS_H */