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
Exibir arquivo Open project: swi-to-yap/swicli Class Usage Examples

Public Properties

Property Type Description
DiscardData bool

Public Methods

Method 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.

Protected Methods

Method Description
Dispose ( bool disposing ) : void

Release all resources from the query

Private Methods

Method 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 method

public Dispose ( ) : void
return void

Dispose() protected method

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

EnsureQUID() public method

public EnsureQUID ( ) : void
return void

NextSolution() public method

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
return bool

PlCall() public static method

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

PlCall() public static method

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
return bool

PlCall() public static method

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
return bool

PlCallQuery() public static method

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
return PlTerm

PlQuery() public method

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
return System

PlQuery() public method

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
return System

PlQuery() public method

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
return System

PlQuery() public method

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
return System

Query() public static method

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.
return int

ToList() public method

Create a ReadOnlyCollection<T> of PlQueryVariables.

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

public ToList ( ) : ReadOnlyCollection
return ReadOnlyCollection

Property Details

DiscardData public_oe property

public bool DiscardData
return bool