Clingo
Loading...
Searching...
No Matches
Symbol Handling

Working with (evaluated) ground terms and related functions. More...

Classes

class  Clingo::Symbol
 Class modeling a symbol in Clingo. More...
 

Typedefs

using Clingo::SymbolSpan = std::span< Symbol const >
 A span of symbols, which is a view on a contiguous sequence of symbols.
 
using Clingo::SymbolList = std::initializer_list< Symbol const >
 A list of symbols.
 
using Clingo::SymbolVector = std::vector< Symbol >
 A vector of symbols.
 

Enumerations

enum class  Clingo::SymbolType : clingo_symbol_type_t {
  SymbolType::infimum = clingo_symbol_type_infimum , SymbolType::number = clingo_symbol_type_number , SymbolType::string = clingo_symbol_type_string , SymbolType::tuple = clingo_symbol_type_tuple ,
  SymbolType::function = clingo_symbol_type_function , SymbolType::supremum = clingo_symbol_type_supremum
}
 Enumeration of symbol types. More...
 

Functions

auto Clingo::cpp_cast (clingo_symbol_t const *sym) -> Symbol const *
 Cast a C symbol to its C++ representation.
 
auto Clingo::Number (int num) -> Symbol
 Construct a numeric symbol from an integer.
 
auto Clingo::Number (Library const &lib, std::string_view str) -> Symbol
 Construct a numeric symbol from a string.
 
auto Clingo::Supremum () -> Symbol
 Construct a supremum symbol.
 
auto Clingo::Infimum () -> Symbol
 Construct an infimum symbol.
 
auto Clingo::String (Library const &lib, std::string_view str) -> Symbol
 Construct a string symbol from a string.
 
auto Clingo::Function (Library const &lib, std::string_view str, SymbolSpan arguments={}, bool is_positive=true) -> Symbol
 Construct a function symbol from a name and arguments.
 
auto Clingo::Function (Library const &lib, std::string_view str, SymbolList arguments, bool is_positive=true) -> Symbol
 Construct a function symbol from a name and arguments.
 
auto Clingo::Tuple (Library const &lib, SymbolSpan arguments={}) -> Symbol
 Construct a tuple symbol from a list of arguments.
 
auto Clingo::Tuple (Library const &lib, SymbolList arguments) -> Symbol
 Construct a tuple symbol from a list of arguments.
 
auto Clingo::parse_term (Library const &lib, std::string_view str) -> Symbol
 Parse the given string and evaluate it to a symbol.
 

Detailed Description

Working with (evaluated) ground terms and related functions.

Note
Functions to create symbols are only thread-safe if library flags have been requested accordingly.

Enumeration Type Documentation

◆ SymbolType

Enumeration of symbol types.

Enumerator
infimum 

The symbol is a sentinel for the minimum value.

number 

The symbol is a number.

string 

The symbol is a string.

tuple 

The symbol is a tuple.

function 

The symbol is a function.

supremum 

The symbol is a sentinel for the maximum value.

Function Documentation

◆ cpp_cast()

auto Clingo::cpp_cast ( clingo_symbol_t const sym) -> Symbol const *
inline

Cast a C symbol to its C++ representation.

Intended to cast continous ranges of symbols, e.g., from a vector or span.

For internal use.

Parameters
symthe symbol to cast
Returns
the C++ representation of the symbol

◆ Function() [1/2]

auto Clingo::Function ( Library const lib,
std::string_view  str,
SymbolList  arguments,
bool  is_positive = true 
) -> Symbol
inline

Construct a function symbol from a name and arguments.

The positivity of the function is used to model classical negation of symbolic atoms. However, it can also be used in term contexts.

Parameters
libthe library for storing symbols
strthe name of the function
argumentsthe arguments of the function
is_positivewhether the function is positive

◆ Function() [2/2]

auto Clingo::Function ( Library const lib,
std::string_view  str,
SymbolSpan  arguments = {},
bool  is_positive = true 
) -> Symbol
inline

Construct a function symbol from a name and arguments.

The positivity of the function is used to model classical negation of symbolic atoms. However, it can also be used in term contexts.

Parameters
libthe library for storing symbols
strthe name of the function
argumentsthe arguments of the function
is_positivewhether the function is positive

◆ Infimum()

auto Clingo::Infimum ( ) -> Symbol
inline

Construct an infimum symbol.

The infimum symbol is a sentinel for the minimum value.

Returns
an infimum symbol

◆ Number() [1/2]

auto Clingo::Number ( int  num) -> Symbol
inline

Construct a numeric symbol from an integer.

Parameters
numthe integer to convert
Returns
a symbol representing the number

◆ Number() [2/2]

auto Clingo::Number ( Library const lib,
std::string_view  str 
) -> Symbol
inline

Construct a numeric symbol from a string.

Parameters
libthe library for storing symbols
strthe string to convert
Returns
a symbol representing the number

◆ parse_term()

auto Clingo::parse_term ( Library const lib,
std::string_view  str 
) -> Symbol
inline

Parse the given string and evaluate it to a symbol.

Parameters
libthe library for storing symbols
strthe string to parse

◆ String()

auto Clingo::String ( Library const lib,
std::string_view  str 
) -> Symbol
inline

Construct a string symbol from a string.

Parameters
libthe library for storing symbols
strthe string to convert
Returns
a symbol representing the string

◆ Supremum()

auto Clingo::Supremum ( ) -> Symbol
inline

Construct a supremum symbol.

The supremum symbol is a sentinel for the maximum value.

Returns
a supremum symbol

◆ Tuple() [1/2]

auto Clingo::Tuple ( Library const lib,
SymbolList  arguments 
) -> Symbol
inline

Construct a tuple symbol from a list of arguments.

Parameters
libthe library for storing symbols
argumentsthe arguments of the tuple
Returns
a symbol representing the tuple

◆ Tuple() [2/2]

auto Clingo::Tuple ( Library const lib,
SymbolSpan  arguments = {} 
) -> Symbol
inline

Construct a tuple symbol from a list of arguments.

Parameters
libthe library for storing symbols
argumentsthe arguments of the tuple
Returns
a symbol representing the tuple