C# Class 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.

Inheritance: IDisposable
Afficher le fichier Open project: swi-to-yap/swicli Class Usage Examples

Méthodes publiques

Свойство Type Description
DiscardData bool

Méthodes publiques

Méthode Description
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.

Méthodes protégées

Méthode Description
Dispose ( bool disposing ) : void

Release all resources from the query

Private Methods

Méthode Description
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

Method Details

Dispose() public méthode

public Dispose ( ) : void
Résultat void

Dispose() protected méthode

Release all resources from the query
protected Dispose ( bool disposing ) : void
disposing bool if true all is deleted
Résultat void

EnsureQUID() public méthode

public EnsureQUID ( ) : void
Résultat void

NextSolution() public méthode

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
Résultat bool

PlCall() public static méthode

Call a goal once.
public static PlCall ( string goal ) : bool
goal string The complete goal as a string
Résultat bool

PlCall() public static méthode

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
Résultat bool

PlCall() public static méthode

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
Résultat bool

PlCallQuery() public static méthode

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
Résultat PlTerm

PlQuery() public méthode

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
Résultat System

PlQuery() public méthode

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
Résultat System

PlQuery() public méthode

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
Résultat System

PlQuery() public méthode

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
Résultat System

Query() public static méthode

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.
Résultat int

ToList() public méthode

Create a ReadOnlyCollection<T> of PlQueryVariables.

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

public ToList ( ) : ReadOnlyCollection
Résultat ReadOnlyCollection

Property Details

DiscardData public_oe property

public bool DiscardData
Résultat bool