private Free ( bool discardData ) : void | ||
discardData | bool | if true all bindings of the query are destroyed |
리턴 | void |
#pragma warning disable 1573 /// <inheritdoc cref="PlCall(string, PlTermV)" /> /// <summary>As <see cref="PlCall(string, PlTermV)"/> but locating the predicate in the named module.</summary> /// <param name="module">locating the predicate in the named module.</param> public static bool PlCall(string module, string predicate, PlTermV args) { bool bRet = false; PlQuery q = new PlQuery(module, predicate, args); bRet = q.NextSolution(); q.Free(false); return(bRet); }
#pragma warning restore 1573 /// <inheritdoc cref="PlCall(string, PlTermV)" /> /// <summary>Call a goal once.</summary> /// <example> /// <code> /// Assert.IsTrue(PlQuery.PlCall("is_list([a,b,c,d])")); /// </code> /// <code> /// Assert.IsTrue(PlQuery.PlCall("consult('some_file_name')")); /// </code> /// </example> /// <param name="goal">The complete goal as a string</param> public static bool PlCall(string goal) { bool bRet; using (var q = new PlQuery("call", new PlTermV(new PlTerm(goal)))) { bRet = q.NextSolution(); q.Free(true); } return(bRet); }
#pragma warning restore 1573 /// <inheritdoc cref="PlCall(string, PlTermV)" /> /// <summary>Call a goal once.</summary> /// <example> /// <code> /// Assert.IsTrue(PlQuery.PlCall("is_list([a,b,c,d])")); /// </code> /// <code> /// Assert.IsTrue(PlQuery.PlCall("consult('some_file_name')")); /// </code> /// </example> /// <param name="goal">The complete goal as a string</param> public static bool PlCall(string goal) { // TODO: change to use PlTerm(text) or PlCompound(string) // TODO: <weiterre tests z.b. mehrere goals/> bool bRet = false; PlQuery q = new PlQuery("call", new PlTermV(PlTerm.PlCompound(goal))); bRet = q.NextSolution(); q.Free(true); return(bRet); }
#pragma warning disable 1573 /// <inheritdoc cref="PlCallQuery(System.String)" /> /// <summary>As <see cref="PlCallQuery(string)"/> but executed in the named module.</summary> /// <param name="module">The modulename in which the query is executed</param> public static PlTerm PlCallQuery(string module, string goal) { PlTerm retVal; using (var q = new PlQuery(module, goal)) { // find the variable or throw an exception PlTerm?t = null; if (q.Variables.Count == 1) { t = new PlTerm(q.Variables[0].Value.TermRef); } else { for (int i = 0; i < q._av.Size; i++) { if (!q._av[i].IsVar) { continue; } if (t == null) { t = new PlTerm(q._av[i].TermRef); } else { throw new ArgumentException("More than one Variable in " + goal); } } } if (t == null) { throw new ArgumentException("No Variable found in " + goal); } if (q.NextSolution()) { retVal = (PlTerm)t; } else { retVal = new PlTerm(); // null } q.Free(false); } return(retVal); }
//TODO: <umstellen auf PlQuery(string)/> /// <summary> /// <para>NOTE:will be changed in the near future.</para> /// 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 /// </summary> /// <param name="goal">a goal with *one* variable</param> /// <returns>the bound variable of the first solution</returns> public static PlTerm PlCallQuery(string goal) { PlTerm retVal; PlQuery q = new PlQuery(goal); { // find the variable or throw an exception PlTerm?t = null; for (int i = 0; i < q._av.Size; i++) { if (q._av[i].IsVar) { if ((object)t == null) { t = new PlTerm(q._av[i].TermRef); } else { throw new ArgumentException("More than one Variable in " + goal); } } } if ((object)t == null) { throw new ArgumentException("No Variable found in " + goal); } if (q.NextSolution()) { retVal = (PlTerm)t; } else { retVal = new PlTerm(); // null } } q.Free(false); return(retVal); }
//TODO: <umstellen auf PlQuery(string)/> /// <summary> /// <para>NOTE:will be changed in the near future.</para> /// 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 /// </summary> /// <param name="goal">a goal with *one* variable</param> /// <returns>the bound variable of the first solution</returns> public static PlTerm PlCallQuery(string goal) { PlTerm retVal; PlQuery q = new PlQuery(goal); { // find the variable or throw an exception PlTerm ? t = null; for (int i = 0; i < q._av.Size; i++) { if (q._av[i].IsVar) { if ((object)t == null) { t = new PlTerm(q._av[i].TermRef); } else throw new ArgumentException("More than one Variable in " + goal); } } if ((object)t == null) throw new ArgumentException("No Variable found in " + goal); if (q.NextSolution()) { retVal = (PlTerm)t; } else retVal = new PlTerm(); // null } q.Free(false); return retVal; }
#pragma warning restore 1573 /// <inheritdoc cref="PlCall(string, PlTermV)" /> /// <summary>Call a goal once.</summary> /// <example> /// <code> /// Assert.IsTrue(PlQuery.PlCall("is_list([a,b,c,d])")); /// </code> /// <code> /// Assert.IsTrue(PlQuery.PlCall("consult('some_file_name')")); /// </code> /// </example> /// <param name="goal">The complete goal as a string</param> public static bool PlCall(string goal) { // TODO: change to use PlTerm(text) or PlCompound(string) // TODO: <weiterre tests z.b. mehrere goals/> bool bRet = false; PlQuery q = new PlQuery("call", new PlTermV(PlTerm.PlCompound(goal))); bRet = q.NextSolution(); q.Free(true); return bRet; }
#pragma warning disable 1573 /// <inheritdoc cref="PlCall(string, PlTermV)" /> /// <summary>As <see cref="PlCall(string, PlTermV)"/> but locating the predicate in the named module.</summary> /// <param name="module">locating the predicate in the named module.</param> public static bool PlCall(string module, string predicate, PlTermV args) { bool bRet = false; PlQuery q = new PlQuery(module, predicate, args); bRet = q.NextSolution(); q.Free(false); return bRet; }