See also section 1.13.1.
- bool PlTerm::unify_term(PlTerm)
- bool PlTerm::unify_atom(PlAtom)
- bool PlTerm::unify_atom(string)
- bool PlTerm::unify_list_codes(string)
- bool PlTerm::unify_list_chars(string)
- bool PlTerm::unify_integer(int)
- bool PlTerm::unify_float(double)
- bool PlTerm::unify_string(string)
- bool PlTerm::unify_functor(PlFunctor)
- bool PlTerm::unify_pointer(void
*)
- bool PlTerm::unify_nil()
- bool PlTerm::unify_blob(PlBlob*
blob)
- bool PlTerm::unify_blob(std::unique_ptr<PlBlob>*
blob)
- Does a call to PL_unify_blob() and, if successful, calls
std::unique_ptr<PlBlob>::release() to pass
ownership to the Prolog blob; on failure or error, deletes the pointer
(ad calls its destructor). After either success and failure,
*blob==nullptr
.
- bool PlTerm::unify_blob(void
*blob, size_t len, PL_blob_t *type)
- bool PlTerm::unify_chars(int
flags, size_t len, const char *s)
-
A family of unification methods are defined for the various Prolog
types and C++ types. Wherever string
is shown, you can use:
char*
whar_t*
std::string
std::wstring
Here is an example:
PREDICATE(hostname, 1)
{ char buf[256];
if ( gethostname(buf, sizeof buf) == 0 )
return A1.unify_atom(buf);
return false;
}
An alternative way of writing this would use the PlCheckFail()
to raise an exception if the unification fails.
PREDICATE(hostname2, 1)
{ char buf[256];
PlCheckFail(gethostname(buf, sizeof buf) == 0);
PlCheckFail(A1.unify_atom(buf));
return true;
}
Of course, in a real program, the failure of
gethostname(buf)sizeof buf should create an error term than
contains information from errno
.