Clingo
Loading...
Searching...
No Matches
Applications on top of Clingo

Support for building applications on top of clingo. More...

Classes

struct  clingo_application
 This struct contains a set of functions to customize the clingo application. More...
 

Typedefs

typedef struct clingo_options clingo_options_t
 Object to add command-line options.
 
typedef bool(* clingo_main_function_t) (clingo_control_t *control, clingo_string_t const *files, size_t size, void *data)
 Callback to customize clingo main function.
 
typedef bool(* clingo_default_model_printer_t) (void *data)
 Callback to print a model in default format.
 
typedef bool(* clingo_model_printer_t) (clingo_model_t const *model, clingo_default_model_printer_t printer, void *printer_data, void *data)
 Callback to customize model printing.
 
typedef struct clingo_application clingo_application_t
 This struct contains a set of functions to customize the clingo application.
 
typedef bool(* clingo_option_parser_t) (char const *value, size_t size, void *data, bool *result)
 Callback to parse the value of a command-line option.
 

Functions

CLINGO_VISIBILITY_DEFAULT bool clingo_options_add (clingo_options_t *options, char const *group, size_t group_size, char const *option, size_t option_size, char const *description, size_t description_size, clingo_option_parser_t parser, void *data, bool multi, char const *argument, size_t argument_size)
 Add an option that is processed with a custom parser.
 
CLINGO_VISIBILITY_DEFAULT bool clingo_options_add_flag (clingo_options_t *options, char const *group, size_t group_size, char const *option, size_t option_size, char const *description, size_t description_size, bool *target)
 Add an option that is a simple flag.
 
CLINGO_VISIBILITY_DEFAULT bool clingo_main (clingo_lib_t *lib, clingo_string_t const *arguments, size_t size, clingo_application_t const *app, void *data, int *code)
 Run an application with the given library and arguments.
 

Detailed Description

Support for building applications on top of clingo.

Typedef Documentation

◆ clingo_default_model_printer_t

typedef bool(* clingo_default_model_printer_t) (void *data)

Callback to print a model in default format.

Parameters
[in]datauser data for the callback
Returns
wether the call was successful

◆ clingo_main_function_t

typedef bool(* clingo_main_function_t) (clingo_control_t *control, clingo_string_t const *files, size_t size, void *data)

Callback to customize clingo main function.

Parameters
[in]controlcorresponding control object
[in]filesfiles passed via command line arguments
[in]sizenumber of files
[in]datauser data for the callback
Returns
wether the call was successful

◆ clingo_model_printer_t

typedef bool(* clingo_model_printer_t) (clingo_model_t const *model, clingo_default_model_printer_t printer, void *printer_data, void *data)

Callback to customize model printing.

Parameters
[in]modelthe model
[in]printerthe default model printer
[in]printer_datauser data for the printer
[in]datauser data for the callback
Returns
wether the call was successful

◆ clingo_option_parser_t

typedef bool(* clingo_option_parser_t) (char const *value, size_t size, void *data, bool *result)

Callback to parse the value of a command-line option.

Parameters
[in]valuethe value to parse
[in]sizethe size of the value
[in]datathe user data of the callback
[in]result
Returns
wether the call was successful

Function Documentation

◆ clingo_main()

CLINGO_VISIBILITY_DEFAULT bool clingo_main ( clingo_lib_t lib,
clingo_string_t const *  arguments,
size_t  size,
clingo_application_t const *  app,
void *  data,
int *  code 
)

Run an application with the given library and arguments.

Note that the application can be set to NULL to start clingo.

Returns an exit code instead of a result code.

Parameters
[in]libthe library object
[in]argumentsthe command line arguments
[in]sizethe number of command line arguments
[in]appstruct with callbacks to override default clingo functionality
[in]datauser data for callbacks in app
[out]codethe exit code
Returns
wether the call was successful

◆ clingo_options_add()

CLINGO_VISIBILITY_DEFAULT bool clingo_options_add ( clingo_options_t options,
char const *  group,
size_t  group_size,
char const *  option,
size_t  option_size,
char const *  description,
size_t  description_size,
clingo_option_parser_t  parser,
void *  data,
bool  multi,
char const *  argument,
size_t  argument_size 
)

Add an option that is processed with a custom parser.

Note that the parser also has to take care of storing the semantic value of the option somewhere.

Parameter option specifies the name(s) of the option. For example, "-p,ping" adds the short option "-p" and its long form "--ping". It is also possible to associate an option with a help level by prepending "@l" to the option specification. Options with a level greater than zero are only shown if the argument to help is greater or equal to l.

Parameters
[in]optionsobject to register the option with
[in]groupoptions are grouped into sections as given by this string
[in]group_sizethe size of the group
[in]optionspecifies the command line option
[in]option_sizeteh size of the option
[in]descriptionthe description of the option
[in]description_sizethe size of the description
[in]parsercallback to parse the value of the option
[in]datauser data for the callback
[in]multiwhether the option can appear multiple times on the command-line
[in]argumentoptional string (NULL) to change the value name in the generated help output
[in]argument_sizethe size of the argument
Returns
wether the call was successful

◆ clingo_options_add_flag()

CLINGO_VISIBILITY_DEFAULT bool clingo_options_add_flag ( clingo_options_t options,
char const *  group,
size_t  group_size,
char const *  option,
size_t  option_size,
char const *  description,
size_t  description_size,
bool *  target 
)

Add an option that is a simple flag.

This function is similar to clingo_options_add() but simpler because it only supports flags, which do not have values. If a flag is passed via the command-line, the parameter target is set to true.

Parameters
[in]optionsobject to register the option with
[in]groupoptions are grouped into sections as given by this string
[in]group_sizethe size of the group
[in]optionspecifies the command line option
[in]option_sizeteh size of the option
[in]descriptionthe description of the option
[in]description_sizethe size of the description
[in]targetboolean set to true if the flag is given on the command-line
Returns
wether the call was successful