3#include <clingo/core.h>
4#include <clingo/shared.h>
20template <
typename>
inline constexpr bool always_false =
false;
22#ifndef __clang_analyzer__
23#define CLINGO_ENABLE_BITSET_ENUM(E, ...) \
24 [[nodiscard]] CLINGO_ENUM_OP(~, (E a), __VA_ARGS__)->E { \
25 return static_cast<E>(~static_cast<std::underlying_type_t<E>>(a)); \
27 [[nodiscard]] CLINGO_ENUM_OP(|, (E a, E b), __VA_ARGS__)->E { \
28 return static_cast<E>(static_cast<std::underlying_type_t<E>>(a) | static_cast<std::underlying_type_t<E>>(b)); \
30 CLINGO_ENUM_OP(|=, (E & a, E b), __VA_ARGS__)->E & { \
33 [[nodiscard]] CLINGO_ENUM_OP(&, (E a, E b), __VA_ARGS__)->E { \
34 return static_cast<E>(static_cast<std::underlying_type_t<E>>(a) & static_cast<std::underlying_type_t<E>>(b)); \
36 CLINGO_ENUM_OP(&=, (E & a, E b), __VA_ARGS__)->E & { \
39 [[nodiscard]] CLINGO_ENUM_OP(-, (E a, E b), __VA_ARGS__)->E { \
40 return static_cast<E>(static_cast<std::underlying_type_t<E>>(a) & static_cast<std::underlying_type_t<E>>(~b)); \
42 CLINGO_ENUM_OP(-=, (E & a, E b), __VA_ARGS__)->E & { \
45 [[nodiscard]] CLINGO_ENUM_OP(^, (E a, E b), __VA_ARGS__)->E { \
46 return static_cast<E>(static_cast<std::underlying_type_t<E>>(a) ^ static_cast<std::underlying_type_t<E>>(b)); \
48 CLINGO_ENUM_OP(^=, (E & a, E b), __VA_ARGS__)->E & { \
51 [[nodiscard]] [[maybe_unused]] inline __VA_ARGS__ constexpr auto intersects(E a, E b) -> bool { \
52 return static_cast<std::underlying_type_t<E>>(a & b) != 0; \
54 static_assert(std::is_enum_v<E>)
55#define CLINGO_ENUM_OP(op, arg, ...) [[maybe_unused]] inline __VA_ARGS__ constexpr auto operator op arg noexcept
57#define CLINGO_ENABLE_BITSET_ENUM(E, ...) \
58 [[nodiscard]] CLINGO_ENUM_OP(~, (E a), __VA_ARGS__)->E; \
59 [[nodiscard]] CLINGO_ENUM_OP(|, (E a, E b), __VA_ARGS__)->E; \
60 CLINGO_ENUM_OP(|=, (E & a, E b), __VA_ARGS__)->E &; \
61 [[nodiscard]] CLINGO_ENUM_OP(&, (E a, E b), __VA_ARGS__)->E; \
62 CLINGO_ENUM_OP(&=, (E & a, E b), __VA_ARGS__)->E &; \
63 [[nodiscard]] CLINGO_ENUM_OP(-, (E a, E b), __VA_ARGS__)->E; \
64 CLINGO_ENUM_OP(-=, (E & a, E b), __VA_ARGS__)->E &; \
65 [[nodiscard]] CLINGO_ENUM_OP(^, (E a, E b), __VA_ARGS__)->E; \
66 CLINGO_ENUM_OP(^=, (E & a, E b), __VA_ARGS__)->E &; \
67 [[nodiscard]] [[maybe_unused]] __VA_ARGS__ auto intersects(E a, E b) -> bool; \
68 static_assert(std::is_enum_v<E>)
69#define CLINGO_ENUM_OP(op, arg, ...) [[maybe_unused]] __VA_ARGS__ auto operator op arg noexcept
75 return Clingo::Detail::store_error(); \
80inline auto store_error() ->
bool {
83 }
catch (std::out_of_range
const &e) {
84 auto msg = std::string_view{e.what()};
86 }
catch (std::invalid_argument
const &e) {
87 auto msg = std::string_view{e.what()};
89 }
catch (std::bad_alloc
const &e) {
90 auto msg = std::string_view{e.what()};
92 }
catch (std::logic_error
const &e) {
93 auto msg = std::string_view{e.what()};
95 }
catch (std::exception
const &e) {
96 auto msg = std::string_view{e.what()};
99 auto msg = std::string_view{
"no message"};
105inline void raise_error() {
111 throw std::bad_alloc{};
114 throw std::logic_error{std::string{str.
data, str.
size}};
117 throw std::invalid_argument{std::string{str.
data, str.
size}};
120 throw std::out_of_range{std::string{str.
data, str.
size}};
123 throw std::runtime_error{std::string{str.
data, str.
size}};
131inline void handle_error(
bool res) {
138inline void handle_error_no_code(
bool res,
int code) {
142 if ((code & 65) == 65 || (code & 33) == 33) {
152template <
typename>
struct funptr_traits;
154template <
typename R,
typename... As>
struct funptr_traits<R (*)(As...)> {
155 using return_type = R;
156 using args_tuple = std::tuple<As...>;
157 template <std::
size_t N>
using arg = std::tuple_element_t<N, args_tuple>;
159 static constexpr std::size_t arity =
sizeof...(As);
160 using last = arg<arity - 1>;
163template <
auto F,
class... As>
auto call(As &&...args) {
164 using Traits = funptr_traits<
decltype(F)>;
165 auto res = std::remove_pointer_t<typename Traits::last>{};
166 if constexpr (std::is_same_v<typename Traits::return_type, void>) {
167 F(std::forward<As>(args)..., &res);
169 handle_error(F(std::forward<As>(args)..., &res));
174template <auto F>
struct Free {
175 template <
typename Ptr>
void operator()(Ptr p)
const noexcept { F(p); }
178template <
class T>
struct value_handle {
180 using pointer =
typename T::pointer;
182 value_handle() =
default;
184 value_handle(
const value_handle &other) : ptr_{other ? T::copy(other.ptr_) : nullptr} {}
186 value_handle(value_handle &&other) noexcept : ptr_{std::exchange(other.ptr_,
nullptr)} {}
188 explicit value_handle(pointer ptr,
bool copy) : ptr_{copy && ptr != nullptr ? T::copy(ptr) : ptr} {}
196 auto operator=(
const value_handle &other) -> value_handle & {
197 if (
this != &other) {
201 ptr_ = other ? T::copy(other.ptr_) : nullptr;
206 auto operator=(value_handle &&other)
noexcept -> value_handle & {
207 if (
this != &other) {
211 ptr_ = std::exchange(other.ptr_,
nullptr);
216 [[nodiscard]]
auto get() const -> pointer {
return ptr_; }
217 explicit operator bool()
const {
return ptr_ !=
nullptr; }
220 pointer ptr_ =
nullptr;
223template <auto Copy, auto Free>
struct value_handle_traits {
224 using pointer = std::remove_pointer_t<
typename funptr_traits<
decltype(Copy)>::template arg<1>>;
225 using const_pointer =
typename funptr_traits<
decltype(Copy)>::template arg<0>;
226 static auto copy(pointer p) -> pointer {
227 auto res = pointer{};
228 handle_error(Copy(p, &res));
231 static void free(const_pointer p)
noexcept { Free(p); }
234template <
class T, auto F>
using unique_handle = std::unique_ptr<T, Free<F>>;
237template <std::input_iterator It, std::sentinel_for<It> S,
class Pred>
auto transform(It begin, S end, Pred pred) {
238 auto p = std::vector<std::invoke_result_t<Pred, std::iter_reference_t<It>>>{};
239 p.reserve(std::distance(begin, end));
240 std::transform(begin, end, std::back_inserter(p), pred);
245template <std::ranges::input_range Rng,
class Pred>
auto transform(Rng &&rng, Pred pred) {
246 return transform(std::ranges::begin(rng), std::ranges::end(rng), pred);
252template <
class T>
auto hash_value(T
const &x) {
253 return std::hash<T>{}(x);
259 auto p = std::make_pair(a, b);
260 return std::hash<std::string_view>{}(std::string_view(
reinterpret_cast<char const *
>(&p),
sizeof(
decltype(p))));
264template <
class T,
class P>
class intrusive_handle {
266 intrusive_handle() =
default;
267 explicit intrusive_handle(P *ptr,
bool inc =
true) : ptr_{ptr} {
272 intrusive_handle(intrusive_handle
const &other) : intrusive_handle{other.ptr_} {}
273 intrusive_handle(intrusive_handle &&other) noexcept : ptr_{std::exchange(other.ptr_,
nullptr)} {}
274 ~intrusive_handle() noexcept { T::release(ptr_); }
275 auto operator=(intrusive_handle
const &other) -> intrusive_handle & {
276 T::acquire(other.ptr_);
281 auto operator=(intrusive_handle &&other)
noexcept -> intrusive_handle & {
283 ptr_ = std::exchange(other.ptr_,
nullptr);
286 [[nodiscard]]
auto get() const noexcept -> P * {
return ptr_; }
287 void reset(std::nullptr_t =
nullptr) noexcept {
291 void reset(P *ptr,
bool inc =
true) {
298 friend auto operator==(intrusive_handle
const &p, std::nullptr_t)
noexcept ->
bool {
return p.ptr_ ==
nullptr; }
299 friend auto operator!=(intrusive_handle
const &p, std::nullptr_t)
noexcept ->
bool {
return p.ptr_ !=
nullptr; }
300 friend auto operator==(std::nullptr_t, intrusive_handle
const &p)
noexcept ->
bool {
return p.ptr_ ==
nullptr; }
301 friend auto operator!=(std::nullptr_t, intrusive_handle
const &p)
noexcept ->
bool {
return p.ptr_ !=
nullptr; }
307template <
typename HT,
typename PT>
struct UserDataStorageTypes {
308 using HolderType = HT;
311template <
typename T>
struct UserDataStorageTraits : UserDataStorageTypes<std::unique_ptr<T>, T *> {
313 using is_holder = void;
315template <
typename T>
struct UserDataStorageTraits<std::reference_wrapper<T>> : UserDataStorageTypes<T *, T *> {
318template <
typename T>
struct UserDataStorageTraits<std::unique_ptr<T>> : UserDataStorageTypes<std::unique_ptr<T>, T *> {
319 using is_holder = void;
321template <>
struct UserDataStorageTraits<std::nullptr_t> : UserDataStorageTypes<std::nullptr_t, std::nullptr_t> {
322 using is_null = void;
332template <
typename T>
struct UserDataTraits {
333 using StorageTraits = UserDataStorageTraits<std::remove_cvref_t<T>>;
334 using PointerType =
typename StorageTraits::PtrType;
335 using ValueType = std::remove_pointer_t<PointerType>;
336 using ReferenceType = std::add_lvalue_reference_t<PointerType>;
339 static constexpr auto has_data = !
requires {
typename StorageTraits::is_null; };
342 template <
typename U>
static auto create(U &&data) -> StorageTraits::HolderType {
343 if constexpr (
requires {
typename StorageTraits::ValueType; }) {
344 return std::make_unique<typename StorageTraits::ValueType>(std::forward<U>(data));
345 }
else if constexpr (
requires {
typename StorageTraits::is_ref; }) {
352 static auto get(StorageTraits::HolderType &holder) -> PointerType {
353 if constexpr (
requires {
typename StorageTraits::is_holder; }) {
360 static auto has_value(StorageTraits::HolderType &holder) ->
bool {
return get(holder) !=
nullptr; }
362 static auto release(StorageTraits::HolderType &holder) -> StorageTraits::PtrType {
363 if constexpr (
requires {
typename StorageTraits::is_holder; }) {
364 return holder.release();
370 static auto cast(
void *ptr) -> StorageTraits::PtrType {
return static_cast<StorageTraits::PtrType
>(ptr); }
372 static void free(
void *ptr) {
373 if constexpr (
requires {
typename StorageTraits::is_holder; }) {
374 typename StorageTraits::HolderType{cast(ptr)};
379template <
typename Value,
typename Base,
bool Null>
struct IsUserData : std::is_base_of<Base, Value> {};
381template <
typename T,
typename Base,
bool Null>
382struct IsUserData<std::reference_wrapper<T>,
Base, Null> : std::is_base_of<Base, T> {};
384template <
typename T,
typename Base,
bool Null>
385struct IsUserData<std::unique_ptr<T>,
Base, Null> : std::is_base_of<Base, T> {};
387template <
typename Base,
bool Null>
388struct IsUserData<std::nullptr_t,
Base, Null> : std::conditional_t<Null, std::true_type, std::false_type> {};
395template <
typename Value,
typename Base,
bool Null = true>
396concept UserData = IsUserData<std::remove_cvref_t<Value>,
Base, Null>
::value;
398template <
typename T>
class ArrowProxy {
400 constexpr ArrowProxy(T
value) : value_(std::move(
value)) {}
401 constexpr auto operator->() -> T * {
return &value_; }
407template <
class Seq>
class RandomAccessIterator {
409 using iterator_category = std::random_access_iterator_tag;
410 using value_type =
typename Seq::value_type;
411 using size_type =
typename Seq::size_type;
412 using difference_type =
typename Seq::difference_type;
413 using pointer =
typename Seq::pointer;
414 using reference =
typename Seq::reference;
417 constexpr RandomAccessIterator() : view_{throw std::logic_error(
"invalid iterator")}, index_{0} {}
418 constexpr RandomAccessIterator(Seq container,
size_t index) noexcept : view_{std::move(container)}, index_{index} {}
419 constexpr auto operator*() const -> reference {
return view_.at(index_); }
420 constexpr auto operator->() const -> pointer {
return view_.at(index_); }
421 constexpr auto operator++() -> RandomAccessIterator & {
425 constexpr auto operator++(
int) -> RandomAccessIterator {
430 constexpr auto operator--() -> RandomAccessIterator & {
434 constexpr auto operator--(
int) -> RandomAccessIterator {
439 constexpr auto operator-(
const RandomAccessIterator &other)
const -> difference_type {
440 return static_cast<difference_type
>(index_) -
static_cast<difference_type
>(other.index_);
442 constexpr auto operator+(difference_type n)
const -> RandomAccessIterator {
443 return RandomAccessIterator(view_, index_ + n);
445 friend constexpr auto operator+(difference_type n, RandomAccessIterator it) -> RandomAccessIterator {
446 return RandomAccessIterator(it.view_, it.index_ + n);
448 constexpr auto operator-(difference_type n)
const -> RandomAccessIterator {
449 return RandomAccessIterator(view_, index_ - n);
451 constexpr auto operator+=(difference_type n) -> RandomAccessIterator & {
455 constexpr auto operator-=(difference_type n) -> RandomAccessIterator & {
459 constexpr auto operator==(
const RandomAccessIterator &other)
const ->
bool {
return index_ == other.index_; }
460 constexpr auto operator<=>(
const RandomAccessIterator &other)
const {
return index_ <=> other.index_; }
461 constexpr auto operator[](difference_type n)
const -> reference {
return view_.at(index_ + n); }
518using StringList = std::initializer_list<std::string_view const>;
574 auto log = logger ? std::make_unique<Logger>(std::move(logger)) :
nullptr;
575 auto has_log =
static_cast<bool>(log);
578 log.release(), limit),
602 [](
void *data)
noexcept { std::unique_ptr<Logger>(
static_cast<Logger *
>(data)); },
608 Detail::intrusive_handle<Library, clingo_lib_t> rep_;
631 [[nodiscard]]
auto str() const -> std::string_view {
632 auto [data, size] = Detail::call<clingo_string_builder_string>(bld_.get());
640 using Traits = Detail::value_handle_traits<clingo_string_builder_copy, clingo_string_builder_free>;
641 Detail::value_handle<Traits> bld_;
692 [[nodiscard]]
auto file() const -> std::string_view {
693 auto [data, size] = Detail::call<clingo_position_file>(pos_.get());
713 return std::string{bld.str()};
742 using Traits = Detail::value_handle_traits<clingo_position_copy, clingo_position_free>;
743 Detail::value_handle<Traits> pos_;
782 return std::string{bld.str()};
807 using Traits = Detail::value_handle_traits<clingo_location_copy, clingo_location_free>;
808 Detail::value_handle<Traits> loc_;
823inline auto version() -> std::tuple<int, int, int> {
828 return {major, minor, revision};
The main library class for managing global information and logging.
Definition core.hh:564
Library(LibraryFlags flags=LibraryFlags::none, Logger logger=nullptr, LogLevel level=LogLevel::info, size_t limit=default_message_limit)
Constructs a library object.
Definition core.hh:572
friend auto c_cast(Library const &lib) -> clingo_lib_t *
Casts the library object to its C representation.
Definition core.hh:593
Library(clingo_lib_t *rep, bool acquire)
Constructs a library object from an existing C representation.
Definition core.hh:587
Class representing a range in a file.
Definition core.hh:749
auto begin() const -> Position
Get the position marking the beginning of the location.
Definition core.hh:769
friend auto operator==(Location const &a, Location const &b) noexcept -> bool
Compare two locations for equality.
Definition core.hh:793
friend auto operator<=>(Location const &a, Location const &b) noexcept -> std::strong_ordering
Compare two locations.
Definition core.hh:802
friend auto c_cast(Location const &x) -> clingo_location_t const *
Cast the location to its C representation.
Definition core.hh:764
auto end() const -> Position
Get the position marking the end of the location.
Definition core.hh:774
Location(clingo_location_t const *loc)
Constructs a location from an existing C representation.
Definition core.hh:752
auto to_string() const -> std::string
Convert the location to a string representation.
Definition core.hh:779
auto hash() const noexcept -> size_t
Get a hash value for the location.
Definition core.hh:786
Location(Position const &begin, Position const &end)
Constructs a location from a begin and end position.
Definition core.hh:758
Class representing a position in a file.
Definition core.hh:665
Position(Library const &lib, std::string_view file, size_t line, size_t column)
Constructs a position from a file, line, and column.
Definition core.hh:680
friend auto operator==(Position const &a, Position const &b) noexcept -> bool
Compare two positions for equality.
Definition core.hh:728
friend auto c_cast(Position const &x) -> clingo_position_t const *
Cast a position to its C representation.
Definition core.hh:687
friend auto operator<=>(Position const &a, Position const &b) noexcept -> std::strong_ordering
Compare two positions.
Definition core.hh:737
Position(clingo_position_t const *pos)
Constructs a position from an existing C representation.
Definition core.hh:672
auto to_string() const -> std::string
Convert the position to a string representation.
Definition core.hh:710
auto file() const -> std::string_view
Get the file name of the position.
Definition core.hh:692
auto line() const -> size_t
Get the line number of the position.
Definition core.hh:700
auto hash() const noexcept -> size_t
Compute the hash of the position.
Definition core.hh:721
auto column() const -> size_t
Get the column number of the position.
Definition core.hh:705
A string builder for constructing strings.
Definition core.hh:617
StringBuilder()
Construct an empty string builder.
Definition core.hh:620
auto str() const -> std::string_view
Get a view of the string built by the string builder.
Definition core.hh:631
friend auto c_cast(StringBuilder &bld) -> clingo_string_builder_t *
Cast the string builder to its C representation.
Definition core.hh:626
void clear() noexcept
Clear the string builder, removing all content.
Definition core.hh:637
CLINGO_VISIBILITY_DEFAULT clingo_position_t const * clingo_location_end(clingo_location_t const *loc)
Get the end of the location.
CLINGO_VISIBILITY_DEFAULT void clingo_lib_release(clingo_lib_t *lib)
Release a library object created with clingo_lib_new().
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_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 void clingo_version(int *major, int *minor, int *revision)
Obtain the clingo version.
CLINGO_VISIBILITY_DEFAULT bool clingo_set_error(clingo_result_t code, char const *message, size_t size)
Set an error in the current thread.
struct clingo_weighted_literal clingo_weighted_literal_t
A literal with an associated weight.
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_position_to_string(clingo_position_t const *pos, clingo_string_builder_t *str)
Convert the given position into a string.
CLINGO_VISIBILITY_DEFAULT size_t clingo_position_column(clingo_position_t const *pos)
Get the column number of the position.
CLINGO_VISIBILITY_DEFAULT void clingo_string_builder_clear(clingo_string_builder_t *bld)
Clear the string in the builder.
int clingo_log_level_t
Corresponding type to clingo_log_level_e.
Definition core.h:149
struct clingo_lib clingo_lib_t
A library object storing global information.
Definition core.h:171
struct clingo_location clingo_location_t
Represents a source code location marking its beginning and end.
Definition core.h:354
CLINGO_VISIBILITY_DEFAULT void clingo_get_error(clingo_result_t *code, clingo_string_t *message)
Get the error set in the current thread.
uint32_t clingo_atom_t
Unsigned integer type used for aspif atoms.
Definition core.h:75
CLINGO_VISIBILITY_DEFAULT int clingo_location_compare(clingo_location_t const *a, clingo_location_t const *b)
Compare two locations.
struct clingo_string_builder clingo_string_builder_t
A builder for strings.
Definition core.h:252
CLINGO_VISIBILITY_DEFAULT size_t clingo_position_line(clingo_position_t const *pos)
Get the line number of the position.
#define CLINGO_VERSION_MINOR
Minor version number.
Definition core.h:64
#define CLINGO_VERSION_MAJOR
Major version number.
Definition core.h:62
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 bool clingo_location_to_string(clingo_location_t const *loc, clingo_string_builder_t *str)
Convert the given location into a string.
CLINGO_VISIBILITY_DEFAULT size_t clingo_position_hash(clingo_position_t const *pos)
Compute a hash of the position.
int32_t clingo_literal_t
Signed integer type used for aspif and solver literals.
Definition core.h:73
CLINGO_VISIBILITY_DEFAULT clingo_position_t const * clingo_location_begin(clingo_location_t const *loc)
Get the beginning of the location.
int clingo_message_t
Corresponding type to clingo_message_e.
Definition core.h:138
uint32_t clingo_id_t
Unsigned integer type used in various places.
Definition core.h:77
int clingo_result_t
Corresponding type to clingo_result_e.
Definition core.h:106
uint32_t clingo_lib_flags_t
Bitset of clingo_lib_flags_e.
Definition core.h:180
#define CLINGO_VERSION_REVISION
Revision number.
Definition core.h:66
struct clingo_position clingo_position_t
Represents a cursor position in source code.
Definition core.h:286
CLINGO_VISIBILITY_DEFAULT bool clingo_string_builder_new(clingo_string_builder_t **bld)
Create a new string builder.
CLINGO_VISIBILITY_DEFAULT bool clingo_location_equal(clingo_location_t const *a, clingo_location_t const *b)
Check if two locations are equal.
int32_t clingo_weight_t
Signed integer type for weights in sum aggregates and minimize constraints.
Definition core.h:79
CLINGO_VISIBILITY_DEFAULT size_t clingo_location_hash(clingo_location_t const *loc)
Compute a hash of the location.
CLINGO_VISIBILITY_DEFAULT void clingo_lib_acquire(clingo_lib_t *lib)
Increment the reference count of the given library.
@ clingo_message_file_included
same file included multiple times
Definition core.h:132
@ clingo_message_error
to report multiple errors; a corresponding runtime error is raised later
Definition core.h:135
@ clingo_message_info
an info message
Definition core.h:129
@ clingo_message_atom_undefined
undefined atom in program
Definition core.h:131
@ clingo_message_global_variable
global variable in tuple of aggregate element
Definition core.h:133
@ clingo_message_operation_undefined
undefined operation in program
Definition core.h:130
@ clingo_message_trace
a trace message
Definition core.h:127
@ clingo_message_debug
a debug message
Definition core.h:128
@ clingo_message_warn
a warning message
Definition core.h:134
@ clingo_log_level_warn
the warning level
Definition core.h:145
@ clingo_log_level_debug
the debug level
Definition core.h:143
@ clingo_log_level_info
the info level
Definition core.h:144
@ clingo_log_level_error
the error level (least verbose)
Definition core.h:146
@ clingo_log_level_trace
the trace level (most verbose)
Definition core.h:142
@ clingo_result_range
result out of range
Definition core.h:103
@ clingo_result_runtime
errors only detectable at runtime like invalid input
Definition core.h:99
@ clingo_result_success
successful API calls
Definition core.h:98
@ clingo_result_invalid
invalid arguments passed to function
Definition core.h:102
@ clingo_result_bad_alloc
memory could not be allocated
Definition core.h:101
@ clingo_result_logic
wrong usage of the clingo API
Definition core.h:100
@ clingo_lib_flags_shared
create symbols in a thread-safe manner
Definition core.h:176
@ clingo_lib_flags_slotted
use custom allocator for storing symbols
Definition core.h:175
@ clingo_lib_flags_fast_release
whether to enable fast release of libraries
Definition core.h:177
int clingo_external_type_t
Corresponding type to clingo_external_type_e.
Definition shared.h:32
int clingo_heuristic_type_t
Corresponding type to clingo_heuristic_type_e.
Definition shared.h:22
@ clingo_heuristic_type_false
set the level of an atom and choose a negative sign
Definition shared.h:19
@ clingo_heuristic_type_init
modify the initial VSIDS score of an atom
Definition shared.h:17
@ clingo_heuristic_type_true
set the level of an atom and choose a positive sign
Definition shared.h:18
@ clingo_heuristic_type_factor
modify VSIDS factor of an atom
Definition shared.h:16
@ clingo_heuristic_type_level
set the level of an atom
Definition shared.h:14
@ clingo_heuristic_type_sign
configure which sign to chose for an atom
Definition shared.h:15
@ clingo_external_type_free
allow an external to be assigned freely
Definition shared.h:26
@ clingo_external_type_true
assign an external to true
Definition shared.h:27
@ clingo_external_type_false
assign an external to false
Definition shared.h:28
@ clingo_external_type_release
no longer treat an atom as external
Definition shared.h:29
Base
The base of a number.
Definition number.hh:17
auto operator+(Sign a, Sign b) -> Sign
Combine two signs.
auto operator+=(Sign &a, Sign b) -> Sign &
Combine two signs.
auto operator-(Sign a) -> Sign
Negate the sign.
@ value
The configuration entry is a double value.
std::span< std::string_view const > StringSpan
A span of string views.
Definition core.hh:516
clingo_literal_t SolverLiteral
A solver literal.
Definition core.hh:492
std::initializer_list< std::string_view const > StringList
A list of string views.
Definition core.hh:518
constexpr size_t default_message_limit
The default message limit for the logger.
Definition core.hh:553
std::vector< SolverLiteral > SolverLiteralVector
A vector of solver literals.
Definition core.hh:498
LibraryFlags
Flags to create library objects.
Definition core.hh:543
std::function< void(MessageCode, std::string_view)> Logger
A callback function type for logging messages.
Definition core.hh:558
std::span< Sum const > SumSpan
A span of sums.
Definition core.hh:513
clingo_atom_t ProgramAtom
A program atom.
Definition core.hh:480
std::span< ProgramId const > ProgramIdSpan
A span of program ids.
Definition core.hh:477
std::initializer_list< SolverLiteral const > SolverLiteralList
A list of solver literals.
Definition core.hh:496
HeuristicType
Enumeration of heuristic types.
Definition core.hh:653
std::span< ProgramAtom const > ProgramAtomSpan
A span of program atoms.
Definition core.hh:482
auto version() -> std::tuple< int, int, int >
Get the version of the Clingo library as a tuple.
Definition core.hh:823
int64_t Sum
A sum representing the sum of weights.
Definition core.hh:511
MessageCode
Enumeration of message codes.
Definition core.hh:521
std::vector< ProgramLiteral > ProgramLiteralVector
A vector of program literals.
Definition core.hh:489
clingo_weight_t Weight
A weight used in sum aggregates and minimize constraints.
Definition core.hh:501
clingo_literal_t ProgramLiteral
A program literal.
Definition core.hh:485
std::span< SolverLiteral const > SolverLiteralSpan
A span of solver literals.
Definition core.hh:494
std::span< WeightedLiteral const > WeightedLiteralSpan
A span of weighted literals.
Definition core.hh:508
clingo_id_t ProgramId
A program id used for various kinds of indices.
Definition core.hh:475
std::span< ProgramLiteral const > ProgramLiteralSpan
A span of program literals.
Definition core.hh:487
ExternalType
Enumeration of control modes.
Definition core.hh:645
std::span< clingo_weight_t const > WeightSpan
A span of weights.
Definition core.hh:503
LogLevel
Enumeration of log levels.
Definition core.hh:534
@ fast_release
whether to enable fast release of libraries
@ shared
create symbols in a thread-safe manner
@ slotted
use custom allocator for storing symbols
@ sign
Configure which sign to chose for an atom.
@ factor
Modify VSIDS factor of an atom.
@ level
Set the level of an atom.
@ init
Modify the initial VSIDS score of an atom.
@ global_variable
global variable in tuple of aggregate element
@ file_included
same file included multiple times
@ atom_undefined
undefined atom in program
@ operation_undefined
undefined operation in program
@ error
to report multiple errors; a corresponding runtime error is raised later
@ release
No longer treat an atom as external.
@ true_
Assign an external to true.
@ free
Allow an external to be assigned freely.
@ false_
Assign an external to false.
#define CLINGO_ENABLE_BITSET_ENUM(E,...)
Opt-in macro for enabling bit operations for a given enum type.
Definition enum.hh:18
auto hash_combine(T... a) -> size_t
Combine the given hashes.
Definition hash.hh:239
constexpr auto transform(std::optional< T > &x, F &&f) -> Detail::transform_result< T &, F >
Implemenatation of std::optional<T>::transform.
Definition optional.hh:28
The clingo logger.
Definition core.h:152
Struct to capture strings that are not null-terminated.
Definition core.h:86
size_t size
the length of the string
Definition core.h:88
char const * data
pointer to the beginning of the string
Definition core.h:87
A literal with an associated weight.
Definition core.h:81