Clingo
Loading...
Searching...
No Matches
symbol.h
1#ifndef CLINGO_SYMBOL_H
2#define CLINGO_SYMBOL_H
3
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8#include <clingo/core.h>
9
26
34
46
51typedef uint64_t clingo_symbol_t;
52
60typedef bool (*clingo_symbol_callback_t)(clingo_symbol_t const *symbols, size_t symbols_size, void *data);
61
64
68CLINGO_VISIBILITY_DEFAULT clingo_symbol_t clingo_symbol_create_infimum(void);
69
73CLINGO_VISIBILITY_DEFAULT clingo_symbol_t clingo_symbol_create_supremum(void);
74
79CLINGO_VISIBILITY_DEFAULT clingo_symbol_t clingo_symbol_create_number(int32_t number);
80
88CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_create_number_str(clingo_lib_t *lib, char const *number, size_t size,
89 clingo_symbol_t *symbol);
90
99CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_create_string(clingo_lib_t *lib, char const *string, size_t size,
100 clingo_symbol_t *symbol);
101
114CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_create_id(clingo_lib_t *lib, char const *name, size_t size,
115 bool is_positive, clingo_symbol_t *symbol);
116
125CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_create_tuple(clingo_lib_t *lib, clingo_symbol_t const *arguments,
126 size_t arguments_size, clingo_symbol_t *symbol);
127
139CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_create_function(clingo_lib_t *lib, char const *name, size_t name_size,
140 clingo_symbol_t const *arguments, size_t arguments_size,
141 bool is_positive, clingo_symbol_t *symbol);
142
155CLINGO_VISIBILITY_DEFAULT bool clingo_parse_term(clingo_lib_t *lib, char const *string, size_t size,
156 clingo_symbol_t *symbol);
157
163CLINGO_VISIBILITY_DEFAULT void clingo_symbol_acquire(clingo_symbol_t symbol);
164
170CLINGO_VISIBILITY_DEFAULT void clingo_symbol_release(clingo_symbol_t symbol);
171
173
176
186CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_number(clingo_symbol_t symbol, int32_t *number);
187
196CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_name(clingo_symbol_t symbol, clingo_string_t *name);
197
206CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_string(clingo_symbol_t symbol, clingo_string_t *string);
207
213CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_is_positive(clingo_symbol_t symbol, bool *is_positive);
214
221CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_arguments(clingo_symbol_t symbol, clingo_symbol_t const **arguments,
222 size_t *arguments_size);
223
229
235CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_to_string(clingo_symbol_t symbol, clingo_string_builder_t *builder);
236
238
241
247CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_equal(clingo_symbol_t a, clingo_symbol_t b);
248
258CLINGO_VISIBILITY_DEFAULT int clingo_symbol_compare(clingo_symbol_t a, clingo_symbol_t b);
259
264CLINGO_VISIBILITY_DEFAULT size_t clingo_symbol_hash(clingo_symbol_t symbol);
265
267
269
270#ifdef __cplusplus
271}
272#endif
273
274#endif
struct clingo_lib clingo_lib_t
A library object storing global information.
Definition core.h:176
struct clingo_string_builder clingo_string_builder_t
A builder for strings.
Definition core.h:257
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_name(clingo_symbol_t symbol, clingo_string_t *name)
Get the name of a symbol.
CLINGO_VISIBILITY_DEFAULT int clingo_symbol_compare(clingo_symbol_t a, clingo_symbol_t b)
Check if a symbol is less than another symbol.
CLINGO_VISIBILITY_DEFAULT clingo_symbol_t clingo_symbol_create_supremum(void)
Construct a symbol representing #sup.
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_create_tuple(clingo_lib_t *lib, clingo_symbol_t const *arguments, size_t arguments_size, clingo_symbol_t *symbol)
Construct a symbol representing a tuple.
bool(* clingo_symbol_callback_t)(clingo_symbol_t const *symbols, size_t symbols_size, void *data)
Callback function to inject symbols.
Definition symbol.h:60
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_to_string(clingo_symbol_t symbol, clingo_string_builder_t *builder)
Get the string representation of a symbol.
CLINGO_VISIBILITY_DEFAULT size_t clingo_symbol_hash(clingo_symbol_t symbol)
Calculate a hash code of a symbol.
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_create_string(clingo_lib_t *lib, char const *string, size_t size, clingo_symbol_t *symbol)
Construct a symbol representing a string.
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_create_id(clingo_lib_t *lib, char const *name, size_t size, bool is_positive, clingo_symbol_t *symbol)
Construct a symbol representing an id.
clingo_symbol_type_e
Enumeration of available symbol types.
Definition symbol.h:36
uint64_t clingo_symbol_t
Type to represent a symbol.
Definition symbol.h:51
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_create_function(clingo_lib_t *lib, char const *name, size_t name_size, clingo_symbol_t const *arguments, size_t arguments_size, bool is_positive, clingo_symbol_t *symbol)
Construct a symbol representing a function.
CLINGO_VISIBILITY_DEFAULT void clingo_symbol_acquire(clingo_symbol_t symbol)
Acquire ownership of the given symbol.
CLINGO_VISIBILITY_DEFAULT clingo_symbol_type_t clingo_symbol_type(clingo_symbol_t symbol)
Get the type of a symbol.
CLINGO_VISIBILITY_DEFAULT bool clingo_parse_term(clingo_lib_t *lib, char const *string, size_t size, clingo_symbol_t *symbol)
Parse a term in string form.
int clingo_symbol_type_t
Corresponding type to clingo_symbol_type.
Definition symbol.h:45
CLINGO_VISIBILITY_DEFAULT void clingo_symbol_release(clingo_symbol_t symbol)
Release ownership of the given symbol.
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_create_number_str(clingo_lib_t *lib, char const *number, size_t size, clingo_symbol_t *symbol)
Construct a symbol representing a number.
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_is_positive(clingo_symbol_t symbol, bool *is_positive)
Check whether a function or number is positive.
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_arguments(clingo_symbol_t symbol, clingo_symbol_t const **arguments, size_t *arguments_size)
Get the arguments of a symbol.
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_equal(clingo_symbol_t a, clingo_symbol_t b)
Check if two symbols are equal.
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_string(clingo_symbol_t symbol, clingo_string_t *string)
Get the string of a symbol.
CLINGO_VISIBILITY_DEFAULT clingo_symbol_t clingo_symbol_create_number(int32_t number)
Construct a symbol representing a number.
CLINGO_VISIBILITY_DEFAULT clingo_symbol_t clingo_symbol_create_infimum(void)
Construct a symbol representing #inf.
CLINGO_VISIBILITY_DEFAULT bool clingo_symbol_number(clingo_symbol_t symbol, int32_t *number)
Get the number of a symbol.
@ clingo_symbol_type_number
a numeric symbol, e.g., 1
Definition symbol.h:37
@ clingo_symbol_type_string
a string symbol, e.g., "a"
Definition symbol.h:40
@ clingo_symbol_type_function
a function symbol, e.g., c, -c, or f(1,"a")
Definition symbol.h:42
@ clingo_symbol_type_supremum
the #sup symbol
Definition symbol.h:38
@ clingo_symbol_type_tuple
a tuple symbol, e.g., (1, "a")`
Definition symbol.h:41
@ clingo_symbol_type_infimum
the #inf symbol
Definition symbol.h:39
Struct to capture strings that are not null-terminated.
Definition core.h:91