- Documentation
- Reference manual
- Packages
loat, integer or rational number, its value is
assigned over f. Note that if t is an integer or
rational conversion may fail because the number cannot be represented as
a float.
int PL_get_functor(term_t
+t, functor_t *f) If t is compound or an atom, the Prolog representation of the
name-arity pair will be assigned over f. See also
PL_get_name_arity()
and PL_is_functor().
int PL_get_name_arity(term_t
+t, atom_t *name, size_t *arity) If t is compound or an atom, the functor name will be
assigned over name and the arity over arity
(either or both may be NULL). See also PL_get_functor()
and PL_is_functor().
int PL_get_compound_name_arity(term_t
+t, atom_t *name, size_t *arity) If t is compound term, the functor name will be assigned over
name and the arity over arity. This is the same as
PL_get_name_arity(),
but this function fails if t is an atom.
int PL_get_module(term_t
+t, module_t *module) If t is an atom, the system will look up or create the
corresponding module and assign an opaque pointer to it over module.
int PL_get_arg(size_t
index, term_t +t, term_t -a) If t is compound and index is between 1 and arity
(inclusive), assign a with a term reference to the argument.
int _PL_get_arg(size_t
index, term_t +t, term_t -a) Same as PL_get_arg(),
but no checking is performed, neither whether t is actually a
term nor whether index is a valid argument index.
int PL_get_dict_key(atom_t
key, term_t +dict, term_t -value) If dict is a dict, get the associated value in value.
Fails silently if key does not appear in dict or
if if dict is not a dict.
12.4.4.3 Exchanging text using length and string
All internal text representation in SWI-Prolog is represented using
char *
plus length and allow for 0-bytes in them.
The foreign library supports this by implementing a *_nchars() function
for each applicable *_chars() function. Below we briefly present the
signatures of these functions. For full documentation consult the
*_chars() function.
- int PL_get_atom_nchars(term_t t, size_t *len, char **s)
- See PL_get_atom_chars().
- int PL_get_list_nchars(term_t t, size_t *len, char **s)
- See PL_get_list_chars().
- int PL_get_nchars(term_t t, size_t *len, char **s, unsigned int flags)
- See PL_get_chars().
The len pointer may be
NULL
. - int PL_put_atom_nchars(term_t t, s