3#include <clingo/core.hh>
5#include <clingo/config.h>
54 return static_cast<ConfigType>(Detail::call<clingo_config_type>(cfg_, key_));
97 return std::string_view{
value.data,
value.size};
101 throw std::logic_error{
"not a value"};
114 auto [data, size] = Detail::call<clingo_config_description>(cfg_, key_);
127 return std::string{
bld.str()};
172 throw std::logic_error{
"not a value"};
201 using pointer = Detail::ArrowProxy<value_type>;
203 using iterator = Detail::RandomAccessIterator<ConstConfigArray>;
218 [[
nodiscard]]
auto size()
const ->
size_t {
return Detail::call<clingo_config_array_size>(cfg_, key_); }
231 return Detail::call<clingo_config_array_at>(cfg_, key_, index);
242 throw std::logic_error{
"not an array"};
261 using pointer = Detail::ArrowProxy<value_type>;
263 using iterator = Detail::RandomAccessIterator<ConfigArray>;
288 throw std::logic_error{
"not an array"};
311 using pointer = Detail::ArrowProxy<value_type>;
313 using iterator = Detail::RandomAccessIterator<ConstConfigMap>;
324 [[
nodiscard]]
auto size()
const ->
size_t {
return Detail::call<clingo_config_map_size>(cfg_, key_); }
331 auto [name,
subkey] = at_(index);
349 return Detail::call<clingo_config_map_has_subkey>(cfg_, key_, name.data(), name.size());
366 return Detail::call<clingo_config_map_at>(cfg_, key_, name.data(), name.size());
369 [[
nodiscard]]
auto at_(
size_t index)
const -> std::pair<std::string_view, clingo_id_t> {
370 auto [data,
size] = Detail::call<clingo_config_map_subkey_name>(cfg_, key_, index);
371 auto str = std::string_view{data,
size};
372 return {str, at_(str)};
383 throw std::logic_error{
"not a map"};
406 using pointer = Detail::ArrowProxy<value_type>;
408 using iterator = Detail::RandomAccessIterator<ConfigMap>;
415 auto [name,
subkey] = at_(index);
438 throw std::logic_error{
"not a map"};
Class modeling a mutable array of configuration entries.
Definition config.hh:250
auto begin() const -> iterator
Get an iterator to the beginning of the array.
Definition config.hh:273
ConfigArray(clingo_config_t *stats, ProgramId key)
Construct from the underlying C API type and a key.
Definition config.hh:266
auto operator[](size_t index) const -> Config
Get the configuration entry at the given index in the array.
Definition config.hh:271
auto end() const -> iterator
Get an iterator to the beginning of the array.
Definition config.hh:275
Detail::ArrowProxy< value_type > pointer
The pointer type.
Definition config.hh:261
auto at(size_t index) const -> Config
Get the configuration entry at the given index in the array.
Definition config.hh:269
Detail::RandomAccessIterator< ConfigArray > iterator
The iterator type.
Definition config.hh:263
std::size_t size_type
The size type.
Definition config.hh:255
std::ptrdiff_t difference_type
The difference type.
Definition config.hh:257
Config value_type
The value type.
Definition config.hh:253
Class modeling a mutable map of configuration entries.
Definition config.hh:391
auto at(size_t index) const -> value_type
Get the name configuration entry pair at the given index in the map.
Definition config.hh:414
Detail::RandomAccessIterator< ConfigMap > iterator
The iterator type.
Definition config.hh:408
std::pair< key_type, mapped_type > value_type
The value type.
Definition config.hh:398
auto begin() const -> iterator
Get an iterator to the beginning of the map.
Definition config.hh:423
std::string_view key_type
The key type.
Definition config.hh:394
value_type reference
The reference type.
Definition config.hh:404
std::ptrdiff_t difference_type
The difference type.
Definition config.hh:402
auto get(std::string_view name) const -> Config
Get the configuration entry with the given name in the map.
Definition config.hh:419
auto end() const -> iterator
Get an iterator to the end of the map.
Definition config.hh:425
auto operator[](std::string_view name) const -> Config
Get the configuration entry with the given name in the map.
Definition config.hh:421
Detail::ArrowProxy< value_type > pointer
The pointer type.
Definition config.hh:406
std::size_t size_type
The size type.
Definition config.hh:400
ConfigMap(clingo_config_t *stats, ProgramId key)
Construct from the underlying C API type and a key.
Definition config.hh:411
Class modeling a mutable configuration entry.
Definition config.hh:138
auto value() const -> std::optional< std::string_view >
Get the value of the configuration entry.
Definition config.hh:91
friend auto c_cast(Config const &stats) -> clingo_config_t *
Cast the configuration to the underlying C API type.
Definition config.hh:150
void value(std::string_view value) const
Set the value of the configuration entry.
Definition config.hh:168
auto operator=(std::string_view value) const -> Config
Set the value of the configuration entry.
Definition config.hh:177
Config(clingo_config_t *stats, ProgramId key)
Construct from the underlying C API type and a key.
Definition config.hh:144
Class modeling an immutable array of configuration entries.
Definition config.hh:190
std::size_t size_type
The size type.
Definition config.hh:195
ConstConfigArray(clingo_config_t const *stats, ProgramId key)
Construct from the underlying C API type and a key.
Definition config.hh:209
auto operator[](size_t index) const -> ConstConfig
Get the configuration entry at the given index in the array.
Definition config.hh:214
Detail::ArrowProxy< value_type > pointer
The pointer type.
Definition config.hh:201
auto end() const -> iterator
Get an iterator to the end of the array.
Definition config.hh:226
auto size() const -> size_t
Get the size of the array.
Definition config.hh:218
ConstConfig value_type
The value type.
Definition config.hh:193
auto at(size_t index) const -> ConstConfig
Get the configuration entry at the given index in the array.
Definition config.hh:212
auto begin() const -> iterator
Get an iterator to the beginning of the array.
Definition config.hh:222
Detail::RandomAccessIterator< ConstConfigArray > iterator
The iterator type.
Definition config.hh:203
std::ptrdiff_t difference_type
The difference type.
Definition config.hh:197
Class modeling an immutable map of configuration entries.
Definition config.hh:296
std::pair< key_type, mapped_type > value_type
The value type.
Definition config.hh:303
ConstConfigMap(clingo_config_t const *stats, ProgramId key)
Construct from the underlying C API type and a key.
Definition config.hh:319
std::size_t size_type
The size type.
Definition config.hh:305
auto end() const -> iterator
Get an iterator to the end of the map.
Definition config.hh:360
auto begin() const -> iterator
Get an iterator to the beginning of the map.
Definition config.hh:355
value_type reference
The reference type.
Definition config.hh:309
auto contains(std::string_view name) const -> bool
Check if the map contains a configuration entry with the given name.
Definition config.hh:348
std::string_view key_type
The key type.
Definition config.hh:299
auto operator[](std::string_view name) const -> ConstConfig
Get the configuration entry with the given name in the map.
Definition config.hh:342
Detail::ArrowProxy< value_type > pointer
The pointer type.
Definition config.hh:311
auto at(size_t index) const -> value_type
Get the name configuration entry pair at the given index in the map.
Definition config.hh:330
auto size() const -> size_t
Get the size of the map.
Definition config.hh:324
std::ptrdiff_t difference_type
The difference type.
Definition config.hh:307
Detail::RandomAccessIterator< ConstConfigMap > iterator
The iterator type.
Definition config.hh:313
auto get(std::string_view name) const -> ConstConfig
Get the configuration entry with the given name in the map.
Definition config.hh:339
Class modeling an immutable configuration entry.
Definition config.hh:36
friend auto c_cast(ConstConfig const &stats) -> clingo_config_t const *
Cast the configuration to the underlying C API type.
Definition config.hh:48
auto description() const -> std::string_view
Get the description of the configuration entry.
Definition config.hh:113
auto value() const -> std::optional< std::string_view >
Get the value of the configuration entry.
Definition config.hh:91
auto type() const -> ConfigType
Get the type of the configuration entry.
Definition config.hh:53
auto to_string() const -> std::string
Get a string representation of the configuration entry.
Definition config.hh:124
auto operator*() const -> std::optional< std::string_view >
Get the value of the configuration entry.
Definition config.hh:105
ConstConfig(clingo_config_t const *stats, ProgramId key)
Construct from the underlying C API type and a key.
Definition config.hh:42
A string builder for constructing strings.
Definition core.hh:524
struct clingo_config clingo_config_t
Handle for to the solver configuration.
Definition config.h:46
CLINGO_VISIBILITY_DEFAULT bool clingo_config_value_get(clingo_config_t const *config, clingo_id_t key, clingo_string_t *value, bool *has_value)
Get the string value of the given entry.
unsigned clingo_config_type_bitset_t
Bitset for values of type clingo_config_type_e.
Definition config.h:43
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.
CLINGO_VISIBILITY_DEFAULT bool clingo_config_to_string(clingo_config_t const *config, clingo_id_t key, clingo_string_builder_t *builder)
Get the string representation of the given theory element.
@ clingo_config_type_array
the entry is an array
Definition config.h:39
@ clingo_config_type_map
the entry is a map
Definition config.h:40
@ clingo_config_type_value
the entry is a (string) value
Definition config.h:38
uint32_t clingo_id_t
Unsigned integer type used in various places.
Definition core.h:82
@ tuple
Theory tuples "(t1,...,tn)".
ConfigType
Enumeration of configuration types.
Definition config.hh:19
auto array() const -> ConstConfigArray
Access the configuration entry as an array.
Definition config.hh:238
auto get(std::string_view name) const -> Config
Get the configuration entry with the given name in the map.
Definition config.hh:441
auto array() const -> ConfigArray
Access the configuration entry as an array.
Definition config.hh:284
auto map() const -> ConstConfigMap
Access the configuration entry as a map.
Definition config.hh:379
auto at(size_t index) const -> Config
Get the configuration entry at the given index in the array.
Definition config.hh:291
auto get(std::string_view name) const -> ConstConfig
Get the configuration entry with the given name in the map.
Definition config.hh:386
auto at(size_t index) const -> ConstConfig
Get the configuration entry at the given index in the array.
Definition config.hh:245
auto map() const -> ConfigMap
Access the configuration entry as a map.
Definition config.hh:434
@ map
The configuration entry is a map of configurations.
@ value
The configuration entry is a double value.
@ array
The configuration entry is a array of configurations.
clingo_id_t ProgramId
A program id used for various kinds of indices.
Definition core.hh:382
#define CLINGO_ENABLE_BITSET_ENUM(E,...)
Opt-in macro for enabling bit operations for a given enum type.
Definition enum.hh:18
Struct to capture strings that are not null-terminated.
Definition core.h:91