The class PlTermv
represents an array of
term-references. This type is used to pass the arguments to a foreign
defined predicate, construct compound terms (see
PlTerm::PlTerm(const char *name)PlTermv arguments ), and to
create queries (see PlQuery
).
The only useful member function is the overloading of
,
providing (0-based) access to the elements. Range checking is performed
and raises a []
domain_error
exception.
The constructors for this class are below. Note that these can be
error-prone because there's no distinction between term_t
and
size_t
; the form of the constructor is determined by
whether the first argument is an integer (term_t
or size_t
)
or
PlTerm
.
load_file(const char *file) { return PlCall("compile", PlTermv(PlAtom(file))); }
If the vector has to contain more than 5 elements, the following construction should be used:
{ PlTermv av(10); av[0].put_term(PlTerm_atom("hello")); av[1].put_term(PlTerm_integer(666)); ... }
Important: be sure that all the arguments are of type
PlTerm
- PlTermv(i)
is not the same as
PlTermv(PlTerm_integer(i))
, and will result in a
runtime error.