Clingo
|
Core types and functions used throughout all modules and version information. More...
Classes | |
struct | clingo_weighted_literal |
A literal with an associated weight. More... | |
struct | clingo_string |
Struct to capture strings that are not null-terminated. More... | |
struct | clingo_logger |
The clingo logger. More... | |
Typedefs | |
typedef int32_t | clingo_literal_t |
Signed integer type used for aspif and solver literals. | |
typedef uint32_t | clingo_atom_t |
Unsigned integer type used for aspif atoms. | |
typedef uint32_t | clingo_id_t |
Unsigned integer type used in various places. | |
typedef int32_t | clingo_weight_t |
Signed integer type for weights in sum aggregates and minimize constraints. | |
typedef struct clingo_weighted_literal | clingo_weighted_literal_t |
A literal with an associated weight. | |
typedef struct clingo_string | clingo_string_t |
Struct to capture strings that are not null-terminated. | |
typedef int | clingo_result_t |
Corresponding type to clingo_result_e. | |
typedef int | clingo_message_t |
Corresponding type to clingo_message_e. | |
typedef int | clingo_log_level_t |
Corresponding type to clingo_log_level_e. | |
typedef struct clingo_logger | clingo_logger_t |
The clingo logger. | |
typedef struct clingo_lib | clingo_lib_t |
A library object storing global information. | |
typedef uint32_t | clingo_lib_flags_t |
Bitset of clingo_lib_flags_e. | |
typedef struct clingo_string_builder | clingo_string_builder_t |
A builder for strings. | |
typedef struct clingo_position | clingo_position_t |
Represents a cursor position in source code. | |
typedef struct clingo_location | clingo_location_t |
Represents a source code location marking its beginning and end. | |
Functions | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_set_error (clingo_result_t code, char const *message, size_t size) |
Set an error in the current thread. | |
CLINGO_VISIBILITY_DEFAULT void | clingo_get_error (clingo_result_t *code, clingo_string_t *message) |
Get the error set in the current thread. | |
CLINGO_VISIBILITY_DEFAULT void | clingo_clear_error (void) |
Clear the current error. | |
CLINGO_VISIBILITY_DEFAULT void | clingo_version (int *major, int *minor, int *revision) |
Obtain the clingo version. | |
CLINGO_VISIBILITY_DEFAULT void | clingo_result_string (clingo_result_t code, clingo_string_t *value) |
Convert the given result code into a string. | |
CLINGO_VISIBILITY_DEFAULT void | clingo_message_string (clingo_message_t code, clingo_string_t *value) |
Convert the giving message code into a string. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_lib_new (clingo_lib_flags_t flags, clingo_log_level_t level, clingo_logger_t const *logger, void *data, size_t limit, clingo_lib_t **lib) |
Create a library object. | |
CLINGO_VISIBILITY_DEFAULT void | clingo_lib_acquire (clingo_lib_t *lib) |
Increment the reference count of the given library. | |
CLINGO_VISIBILITY_DEFAULT void | clingo_lib_release (clingo_lib_t *lib) |
Release a library object created with clingo_lib_new(). | |
CLINGO_VISIBILITY_DEFAULT void | clingo_lib_report (clingo_lib_t *lib, clingo_message_t code, char const *message, size_t size) |
Report a message via the libraries logger. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_string_builder_new (clingo_string_builder_t **bld) |
Create a new string builder. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_string_builder_copy (clingo_string_builder_t const *src, clingo_string_builder_t **dst) |
Copy the string builder. | |
CLINGO_VISIBILITY_DEFAULT void | clingo_string_builder_free (clingo_string_builder_t const *bld) |
Free the string builder. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_string_builder_string (clingo_string_builder_t const *bld, clingo_string_t *value) |
Get the (zero-terminated) string in the builder. | |
CLINGO_VISIBILITY_DEFAULT void | clingo_string_builder_clear (clingo_string_builder_t *bld) |
Clear the string in the builder. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_position_new (clingo_lib_t *lib, char const *file, size_t size, size_t line, size_t column, clingo_position_t const **pos) |
Create a new source position object. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_position_copy (clingo_position_t const *src, clingo_position_t const **dst) |
Copy the given position. | |
CLINGO_VISIBILITY_DEFAULT void | clingo_position_free (clingo_position_t const *pos) |
Free the given position. | |
CLINGO_VISIBILITY_DEFAULT void | clingo_position_file (clingo_position_t const *pos, clingo_string_t *value) |
Get the file name of the position. | |
CLINGO_VISIBILITY_DEFAULT size_t | clingo_position_line (clingo_position_t const *pos) |
Get the line number of the position. | |
CLINGO_VISIBILITY_DEFAULT size_t | clingo_position_column (clingo_position_t const *pos) |
Get the column number of the position. | |
CLINGO_VISIBILITY_DEFAULT size_t | clingo_position_hash (clingo_position_t const *pos) |
Compute a hash of the position. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_position_equal (clingo_position_t const *a, clingo_position_t const *b) |
Check if two positions are equal. | |
CLINGO_VISIBILITY_DEFAULT int | clingo_position_compare (clingo_position_t const *a, clingo_position_t const *b) |
Compare two positions. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_position_to_string (clingo_position_t const *pos, clingo_string_builder_t *str) |
Convert the given position into a string. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_location_new (clingo_position_t const *begin, clingo_position_t const *end, clingo_location_t const **loc) |
Create a new source location object. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_location_copy (clingo_location_t const *src, clingo_location_t const **dst) |
Copy the given location. | |
CLINGO_VISIBILITY_DEFAULT void | clingo_location_free (clingo_location_t const *loc) |
Free the given location. | |
CLINGO_VISIBILITY_DEFAULT clingo_position_t const * | clingo_location_begin (clingo_location_t const *loc) |
Get the beginning of the location. | |
CLINGO_VISIBILITY_DEFAULT clingo_position_t const * | clingo_location_end (clingo_location_t const *loc) |
Get the end of the location. | |
CLINGO_VISIBILITY_DEFAULT size_t | clingo_location_hash (clingo_location_t const *loc) |
Compute a hash of the location. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_location_equal (clingo_location_t const *a, clingo_location_t const *b) |
Check if two locations are equal. | |
CLINGO_VISIBILITY_DEFAULT int | clingo_location_compare (clingo_location_t const *a, clingo_location_t const *b) |
Compare two locations. | |
CLINGO_VISIBILITY_DEFAULT bool | clingo_location_to_string (clingo_location_t const *loc, clingo_string_builder_t *str) |
Convert the given location into a string. | |
Core types and functions used throughout all modules and version information.
For an example, see version.c.
typedef struct clingo_position clingo_position_t |
Represents a cursor position in source code.
enum clingo_lib_flags_e |
enum clingo_log_level_e |
enum clingo_message_e |
Enumeration of message codes.
enum clingo_result_e |
Enumeration of error codes.
CLINGO_VISIBILITY_DEFAULT void clingo_get_error | ( | clingo_result_t * | code, |
clingo_string_t * | message | ||
) |
Get the error set in the current thread.
[out] | code | the error code |
[out] | message | the error message |
CLINGO_VISIBILITY_DEFAULT void clingo_lib_acquire | ( | clingo_lib_t * | lib | ) |
Increment the reference count of the given library.
[in] | lib | the target |
CLINGO_VISIBILITY_DEFAULT bool clingo_lib_new | ( | clingo_lib_flags_t | flags, |
clingo_log_level_t | level, | ||
clingo_logger_t const * | logger, | ||
void * | data, | ||
size_t | limit, | ||
clingo_lib_t ** | lib | ||
) |
Create a library object.
A library has to be freed using clingo_lib_free().
If the logger is NULL, the default logger printing messages to stderr is used.
[in] | flags | construction flags |
[in] | level | the log level for the message logger |
[in] | logger | callback functions for warnings and info messages |
[in] | data | user data for the logger callback |
[in] | limit | the message limit |
[out] | lib | the resulting library object |
CLINGO_VISIBILITY_DEFAULT void clingo_lib_release | ( | clingo_lib_t * | lib | ) |
Release a library object created with clingo_lib_new().
If fast release has been disabled, the garbage collector is run to ensure that all symbols are freed. If there are still referenced symbols, the library is not deleted but put in a list for later cleanup. Further calls to this function trigger further cleanups (the lib parameter can be set to NULL to just run the cleanup).
The flag is mainly intended for language bindings, where cleanup of all symbols cannot be guaranteed due to unpredictable garbage collection. Objects using the library can still be freed after this call.
[in] | lib | the target |
CLINGO_VISIBILITY_DEFAULT void clingo_lib_report | ( | clingo_lib_t * | lib, |
clingo_message_t | code, | ||
char const * | message, | ||
size_t | size | ||
) |
Report a message via the libraries logger.
[in] | lib | the library |
[in] | code | associated code |
[in] | message | the message |
[in] | size | the size of the message |
CLINGO_VISIBILITY_DEFAULT clingo_position_t const * clingo_location_begin | ( | clingo_location_t const * | loc | ) |
Get the beginning of the location.
The lifetime of the position is tied to that of the location.
[in] | loc | the location |
CLINGO_VISIBILITY_DEFAULT int clingo_location_compare | ( | clingo_location_t const * | a, |
clingo_location_t const * | b | ||
) |
Compare two locations.
Only locations associated with the same library may be compared.
[in] | a | the first location |
[in] | b | the second location |
CLINGO_VISIBILITY_DEFAULT bool clingo_location_copy | ( | clingo_location_t const * | src, |
clingo_location_t const ** | dst | ||
) |
Copy the given location.
[in] | src | the location to copy |
[out] | dst | the resulting location |
CLINGO_VISIBILITY_DEFAULT clingo_position_t const * clingo_location_end | ( | clingo_location_t const * | loc | ) |
Get the end of the location.
The lifetime of the position is tied to that of the location.
[in] | loc | the location |
CLINGO_VISIBILITY_DEFAULT bool clingo_location_equal | ( | clingo_location_t const * | a, |
clingo_location_t const * | b | ||
) |
Check if two locations are equal.
Only locations associated with the same library may be compared.
[in] | a | the first location |
[in] | b | the second location |
CLINGO_VISIBILITY_DEFAULT void clingo_location_free | ( | clingo_location_t const * | loc | ) |
Free the given location.
[in] | loc | the location to free |
CLINGO_VISIBILITY_DEFAULT size_t clingo_location_hash | ( | clingo_location_t const * | loc | ) |
Compute a hash of the location.
[in] | loc | the location |
CLINGO_VISIBILITY_DEFAULT bool clingo_location_new | ( | clingo_position_t const * | begin, |
clingo_position_t const * | end, | ||
clingo_location_t const ** | loc | ||
) |
Create a new source location object.
[in] | begin | the position marking the beginning |
[in] | end | the position marking the end |
[out] | loc | the resulting location |
CLINGO_VISIBILITY_DEFAULT bool clingo_location_to_string | ( | clingo_location_t const * | loc, |
clingo_string_builder_t * | str | ||
) |
Convert the given location into a string.
[in] | loc | the location |
[in] | str | the string builder |
CLINGO_VISIBILITY_DEFAULT void clingo_message_string | ( | clingo_message_t | code, |
clingo_string_t * | value | ||
) |
Convert the giving message code into a string.
The function returns string literals that do not have to be cleaned up.
[in] | code | the message code |
[out] | value | the string |
CLINGO_VISIBILITY_DEFAULT size_t clingo_position_column | ( | clingo_position_t const * | pos | ) |
Get the column number of the position.
[in] | pos | the position |
CLINGO_VISIBILITY_DEFAULT int clingo_position_compare | ( | clingo_position_t const * | a, |
clingo_position_t const * | b | ||
) |
Compare two positions.
Only positions associated with the same library may be compared.
[in] | a | the first position |
[in] | b | the second position |
CLINGO_VISIBILITY_DEFAULT bool clingo_position_copy | ( | clingo_position_t const * | src, |
clingo_position_t const ** | dst | ||
) |
Copy the given position.
[in] | src | the position to copy |
[out] | dst | the resulting position |
CLINGO_VISIBILITY_DEFAULT bool clingo_position_equal | ( | clingo_position_t const * | a, |
clingo_position_t const * | b | ||
) |
Check if two positions are equal.
Only positions associated with the same library may be compared.
[in] | a | the first position |
[in] | b | the second position |
CLINGO_VISIBILITY_DEFAULT void clingo_position_file | ( | clingo_position_t const * | pos, |
clingo_string_t * | value | ||
) |
Get the file name of the position.
[in] | pos | the position |
[out] | value | the file name |
CLINGO_VISIBILITY_DEFAULT void clingo_position_free | ( | clingo_position_t const * | pos | ) |
Free the given position.
[in] | pos | the position to free |
CLINGO_VISIBILITY_DEFAULT size_t clingo_position_hash | ( | clingo_position_t const * | pos | ) |
Compute a hash of the position.
[in] | pos | the position |
CLINGO_VISIBILITY_DEFAULT size_t clingo_position_line | ( | clingo_position_t const * | pos | ) |
Get the line number of the position.
[in] | pos | the position |
CLINGO_VISIBILITY_DEFAULT bool clingo_position_new | ( | clingo_lib_t * | lib, |
char const * | file, | ||
size_t | size, | ||
size_t | line, | ||
size_t | column, | ||
clingo_position_t const ** | pos | ||
) |
Create a new source position object.
[in] | lib | the library storing strings |
[in] | file | the file of the position |
[in] | size | the size of the file string |
[in] | line | the line number of the position |
[in] | column | the column number of the position |
[out] | pos | the resulting position |
CLINGO_VISIBILITY_DEFAULT bool clingo_position_to_string | ( | clingo_position_t const * | pos, |
clingo_string_builder_t * | str | ||
) |
Convert the given position into a string.
[in] | pos | the position |
[in] | str | the string builder |
CLINGO_VISIBILITY_DEFAULT void clingo_result_string | ( | clingo_result_t | code, |
clingo_string_t * | value | ||
) |
Convert the given result code into a string.
The function returns string literals that do not have to be cleaned up.
[in] | code | the result code |
[out] | value | the string |
CLINGO_VISIBILITY_DEFAULT bool clingo_set_error | ( | clingo_result_t | code, |
char const * | message, | ||
size_t | size | ||
) |
Set an error in the current thread.
[in] | code | the error code |
[in] | message | the error message |
[in] | size | the size of the error message |
CLINGO_VISIBILITY_DEFAULT void clingo_string_builder_clear | ( | clingo_string_builder_t * | bld | ) |
CLINGO_VISIBILITY_DEFAULT bool clingo_string_builder_copy | ( | clingo_string_builder_t const * | src, |
clingo_string_builder_t ** | dst | ||
) |
Copy the string builder.
[in] | src | the builder to copy |
[out] | dst | the resulting builder |
CLINGO_VISIBILITY_DEFAULT void clingo_string_builder_free | ( | clingo_string_builder_t const * | bld | ) |
CLINGO_VISIBILITY_DEFAULT bool clingo_string_builder_new | ( | clingo_string_builder_t ** | bld | ) |
CLINGO_VISIBILITY_DEFAULT bool clingo_string_builder_string | ( | clingo_string_builder_t const * | bld, |
clingo_string_t * | value | ||
) |
CLINGO_VISIBILITY_DEFAULT void clingo_version | ( | int * | major, |
int * | minor, | ||
int * | revision | ||
) |
Obtain the clingo version.
[out] | major | major version number |
[out] | minor | minor version number |
[out] | revision | revision number |