Configuration of search and enumeration algorithms.
More...
|
CLINGO_VISIBILITY_DEFAULT bool | clingo_config_add (clingo_config_t *config, clingo_id_t parent, char const *name, size_t name_size, char const *description, size_t description_size, clingo_config_entry_t const *entry, void *data) |
| Add a custom configuration entry under a parent key.
|
|
CLINGO_VISIBILITY_DEFAULT bool | clingo_config_root (clingo_config_t const *config, clingo_id_t *key) |
| Get the root key of the configuration.
|
|
CLINGO_VISIBILITY_DEFAULT bool | clingo_config_type (clingo_config_t const *config, clingo_id_t key, clingo_config_type_bitset_t *type) |
| Get the type of a key.
|
|
CLINGO_VISIBILITY_DEFAULT bool | clingo_config_description (clingo_config_t const *config, clingo_id_t key, clingo_string_t *description) |
| Get the description of an entry.
|
|
CLINGO_VISIBILITY_DEFAULT bool | clingo_control_config (clingo_control_t *control, clingo_config_t **config) |
| Get the configuration object.
|
|
|
CLINGO_VISIBILITY_DEFAULT bool | clingo_config_map_size (clingo_config_t const *config, clingo_id_t key, size_t *size) |
| Get the number of subkeys of a map entry.
|
|
CLINGO_VISIBILITY_DEFAULT bool | clingo_config_map_subkey_name (clingo_config_t const *config, clingo_id_t key, size_t offset, clingo_string_t *name) |
| Get the name associated with the offset-th subkey.
|
|
CLINGO_VISIBILITY_DEFAULT bool | clingo_config_map_at (clingo_config_t const *config, clingo_id_t key, char const *name, size_t size, clingo_id_t *subkey, bool *has_subkey) |
| Lookup a subkey under the given name.
|
|
Configuration of search and enumeration algorithms.
Entries in a configuration are organized hierarchically. Subentries are either accessed by name for map entries or by offset for array entries. Value entries have a string value that can be inspected or modified.
For an example, see config.c.
◆ clingo_config_entry_t
Callback interface for custom configuration entries.
This struct allows users to define custom configuration entries by providing function pointers for querying and manipulating the entry. The data
pointer is passed to each callback and can be used to store user-defined state.
On each configuration path, there can be at most one array entry. If present, the array index is passed to all entries following an array entry in the path. It is up to the entry implementation to interpret an absent index (i.e., when index
is NULL).
All callbacks are optional; if a callback is NULL, the corresponding operation is not supported for this entry.
◆ clingo_config_type_e
Enumeration for entries of the configuration.
Enumerator |
---|
clingo_config_type_value | the entry is a (string) value
|
clingo_config_type_array | the entry is an array
|
clingo_config_type_map | the entry is a map
|
◆ clingo_config_add()
CLINGO_VISIBILITY_DEFAULT bool clingo_config_add |
( |
clingo_config_t * |
config, |
|
|
clingo_id_t |
parent, |
|
|
char const * |
name, |
|
|
size_t |
name_size, |
|
|
char const * |
description, |
|
|
size_t |
description_size, |
|
|
clingo_config_entry_t const * |
entry, |
|
|
void * |
data |
|
) |
| |
Add a custom configuration entry under a parent key.
The entry is defined by the provided callbacks and user data. The API takes ownership of the data
pointer and will call the free
callback (if non-NULL) when the entry is removed or the configuration is destroyed.
- Parameters
-
[in] | config | the configuration object |
[in] | parent | the parent key under which to add the entry |
[in] | name | the name of the new entry (not null-terminated) |
[in] | name_size | the length of the name string |
[in] | description | the description of the entry (not null-terminated) |
[in] | description_size | the length of the description string |
[in] | entry | pointer to the entry callbacks struct |
[in] | data | user data pointer for the entry callbacks |
- Returns
- true on success, false on error
◆ clingo_config_array_at()
Get the subkey at the given offset of an array entry.
- Note
- Some array entries, like fore example the solver configuration, can be accessed past there actual size to add subentries.
- Precondition
- The type of the entry must be clingo_config_type_array.
- Parameters
-
[in] | config | the target configuration |
[in] | key | the key |
[in] | offset | the offset in the array |
[out] | subkey | the resulting subkey |
- Returns
- whether the call was successful
◆ clingo_config_array_size()
Get the size of an array entry.
- Precondition
- The type of the entry must be clingo_config_type_array.
- Parameters
-
[in] | config | the target configuration |
[in] | key | the key |
[out] | size | the resulting size |
- Returns
- whether the call was successful
◆ clingo_config_description()
Get the description of an entry.
- Parameters
-
[in] | config | the target configuration |
[in] | key | the key |
[out] | description | the description |
- Returns
- whether the call was successful
◆ clingo_config_map_at()
Lookup a subkey under the given name.
- Precondition
- The type of the entry must be clingo_config_type_map.
- Note
- Multiple levels can be looked up by concatenating keys with a period.
- Parameters
-
[in] | config | the target configuration |
[in] | key | the key |
[in] | name | the name to look up the subkey |
[in] | size | the size of the name |
[out] | subkey | the resulting subkey |
[out] | has_subkey | whether the map has the subkey |
- Returns
- whether the call was successful
◆ clingo_config_map_size()
Get the number of subkeys of a map entry.
- Precondition
- The type of the entry must be clingo_config_type_map.
- Parameters
-
[in] | config | the target configuration |
[in] | key | the key |
[out] | size | the resulting number |
- Returns
- whether the call was successful
◆ clingo_config_map_subkey_name()
Get the name associated with the offset-th subkey.
- Precondition
- The type of the entry must be clingo_config_type_map.
- Parameters
-
[in] | config | the target configuration |
[in] | key | the key |
[in] | offset | the offset of the name |
[out] | name | the resulting name |
- Returns
- whether the call was successful
◆ clingo_config_root()
Get the root key of the configuration.
- Parameters
-
[in] | config | the target configuration |
[out] | key | the root key |
- Returns
- whether the call was successful
◆ clingo_config_to_string()
Get the string representation of the given theory element.
- Parameters
-
[in] | config | the target configuration |
[in] | key | the key |
[in] | builder | the builder |
- Returns
- whether the call was successful
◆ clingo_config_type()
Get the type of a key.
- Note
- The type is bitset, an entry can have multiple (but at least one) type.
- Parameters
-
[in] | config | the target configuration |
[in] | key | the key |
[out] | type | the resulting type |
- Returns
- whether the call was successful
◆ clingo_config_value_get()
Get the string value of the given entry.
- Precondition
- The type of the entry must be clingo_config_type_value.
- Parameters
-
[in] | config | the target configuration |
[in] | key | the key |
[out] | value | the resulting string value |
[out] | has_value | whether the config entry has a value |
- Returns
- whether the call was successful
◆ clingo_config_value_set()
CLINGO_VISIBILITY_DEFAULT bool clingo_config_value_set |
( |
clingo_config_t * |
config, |
|
|
clingo_id_t |
key, |
|
|
char const * |
value, |
|
|
size_t |
size |
|
) |
| |
Set the value of an entry.
- Precondition
- The type of the entry must be clingo_config_type_value.
- Parameters
-
[in] | config | the target configuration |
[in] | key | the key |
[in] | value | the value to set |
[in] | size | the size of the value |
- Returns
- whether the call was successful
◆ clingo_control_config()
CLINGO_VISIBILITY_DEFAULT bool clingo_control_config |
( |
clingo_control_t * |
control, |
|
|
clingo_config_t ** |
config |
|
) |
| |
Get the configuration object.
- Parameters
-
[in] | control | the target |
[out] | config | the configuration |
- Returns
- whether the call was successful