C# Класс SbsSW.SwiPlCs.PlQuery

This class allows queries to prolog.

A query can be created by a string or by constructing compound terms see Constructors for details.

All resources an terms created by a query are reclaimed by Dispose(). It is recommended to build a query in a scope.

There are four possible opportunities to query Prolog

Query typeDescription A static callTo ask prolog for a proof. Return only true or false. A PlCallQuery(string)To get the first result of a goal Construct a PlQuery object by a string.The most convenient way. Construct a PlQuery object by compound terms.The most flexible and fast (runtime) way.

For examples see PlQuery(string) and PlQuery(string, PlTermV)

The query will be opened by NextSolution() and will be closed if NextSolution() return false.

Наследование: IDisposable
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
DiscardData bool

Открытые методы

Метод Описание
Dispose ( ) : void
EnsureQUID ( ) : void
NextSolution ( ) : bool

Provide the next solution to the query. Prolog exceptions are mapped to C# exceptions.

If the query is closed it will be opened. If the last solution was generated the query will be closed.

If an exception is thrown while parsing (open) the query the _qid is set to zero.

PlCall ( string goal ) : bool

Call a goal once.

PlCall ( string predicate, PlTermV args ) : bool

Create a PlQuery from the arguments, generates the first solution by NextSolution() and destroys the query.

PlCall ( string module, string predicate, PlTermV args ) : bool

As PlCall(string, PlTermV) but locating the predicate in the named module.

PlCallQuery ( string goal ) : PlTerm

NOTE:will be changed in the near future.

return the solution of a query which is called once by call Throw an ArgumentException if there is no or more than one variable in the goal

PlQuery ( string goal ) : System

With this constructor a query is created from a string.

Uppercase parameters are interpreted a variables but can't be nested in sub terms. If you need a variable in a nested term use PlQuery(string, PlTermV). See the examples for details.

Muddy Waters sang:"I'am build for comfort, I ain't build for speed"

PlQuery ( string name, PlTermV termV ) : System

Create a query where name defines the name of the predicate and av the argument vector. The arity is deduced from av. The predicate is located in the Prolog module user.

PlQuery ( string module, string goal ) : System

locating the predicate in the named module.

PlQuery ( string module, string name, PlTermV termV ) : System

locating the predicate in the named module.

Query ( PlQuerySwitch queryType ) : int

Obtain status information on the Prolog system. The actual argument type depends on the information required. The parameter queryType describes what information is wanted.

Returning pointers and integers as a long is bad style. The signature of this function should be changed.

PlQuerySwitch

ToList ( ) : ReadOnlyCollection

Create a ReadOnlyCollection<T> of PlQueryVariables.

If calling ToList() all solutions of the query are generated and stored in the Collection.

Защищенные методы

Метод Описание
Dispose ( bool disposing ) : void

Release all resources from the query

Приватные методы

Метод Описание
CheckForException ( ) : void
EraseRecords ( ) : void
Free ( bool discardData ) : void

Discards the query, but does not delete any of the data created by the query if discardData is false. It just invalidate qid, allowing for a new PlQuery object in this context.

see

PlQuery ( ) : System
Sread ( IntPtr handle, System buffer, long buffersize ) : long

Описание методов

Dispose() публичный Метод

public Dispose ( ) : void
Результат void

Dispose() защищенный Метод

Release all resources from the query
protected Dispose ( bool disposing ) : void
disposing bool if true all is deleted
Результат void

EnsureQUID() публичный Метод

public EnsureQUID ( ) : void
Результат void

NextSolution() публичный Метод

Provide the next solution to the query. Prolog exceptions are mapped to C# exceptions.

If the query is closed it will be opened. If the last solution was generated the query will be closed.

If an exception is thrown while parsing (open) the query the _qid is set to zero.

Is thrown if SWI-Prolog Manual PL_next_solution() returns false
public NextSolution ( ) : bool
Результат bool

PlCall() публичный статический Метод

Call a goal once.
public static PlCall ( string goal ) : bool
goal string The complete goal as a string
Результат bool

PlCall() публичный статический Метод

Create a PlQuery from the arguments, generates the first solution by NextSolution() and destroys the query.

public static PlCall ( string predicate, PlTermV args ) : bool
predicate string defines the name of the predicate
args PlTermV Is a of arguments for the predicate
Результат bool

PlCall() публичный статический Метод

As PlCall(string, PlTermV) but locating the predicate in the named module.
public static PlCall ( string module, string predicate, PlTermV args ) : bool
module string locating the predicate in the named module.
predicate string
args PlTermV
Результат bool

PlCallQuery() публичный статический Метод

NOTE:will be changed in the near future.

return the solution of a query which is called once by call Throw an ArgumentException if there is no or more than one variable in the goal
public static PlCallQuery ( string goal ) : PlTerm
goal string a goal with *one* variable
Результат PlTerm

PlQuery() публичный Метод

With this constructor a query is created from a string.

Uppercase parameters are interpreted a variables but can't be nested in sub terms. If you need a variable in a nested term use PlQuery(string, PlTermV). See the examples for details.

Muddy Waters sang:"I'am build for comfort, I ain't build for speed"
public PlQuery ( string goal ) : System
goal string A string for a prolog query
Результат System

PlQuery() публичный Метод

Create a query where name defines the name of the predicate and av the argument vector. The arity is deduced from av. The predicate is located in the Prolog module user.
public PlQuery ( string name, PlTermV termV ) : System
name string the name of the predicate
termV PlTermV the argument vector containing the parameters
Результат System

PlQuery() публичный Метод

locating the predicate in the named module.
public PlQuery ( string module, string goal ) : System
module string locating the predicate in the named module.
goal string
Результат System

PlQuery() публичный Метод

locating the predicate in the named module.
public PlQuery ( string module, string name, PlTermV termV ) : System
module string locating the predicate in the named module.
name string
termV PlTermV
Результат System

Query() публичный статический Метод

Obtain status information on the Prolog system. The actual argument type depends on the information required. The parameter queryType describes what information is wanted.

Returning pointers and integers as a long is bad style. The signature of this function should be changed.

PlQuerySwitch
public static Query ( PlQuerySwitch queryType ) : int
queryType PlQuerySwitch A PlQuerySwitch.
Результат int

ToList() публичный Метод

Create a ReadOnlyCollection<T> of PlQueryVariables.

If calling ToList() all solutions of the query are generated and stored in the Collection.

public ToList ( ) : ReadOnlyCollection
Результат ReadOnlyCollection

Описание свойств

DiscardData публичное свойство

public bool DiscardData
Результат bool