- Documentation
- Reference manual
- Packages
- A C++ interface to SWI-Prolog
- A C++ interface to SWI-Prolog (Version 2)
- Overview of accessing and changing values (version 2)
- Converting PlTerm to native C and C++ types (version 2)
- Unification (version 2)
- Comparison (version 2)
- Analysing compound terms (version 2)
- Miscellaneous (version 2)
- The class PlTerm_string (version 2)
- The class PlCodeList (version 2)
- The class PlCharList (version 2)
- The class PlCompound (version 2)
- The class PlTail (version 2)
- The class PlTermv (version 2)
- The class PlAtom - Supporting Prolog constants (version 2)
- Classes for the recorded database: PlRecord and PlRecordExternalCopy
- Overview of accessing and changing values (version 2)
- A C++ interface to SWI-Prolog (Version 2)
- A C++ interface to SWI-Prolog
2.10.1 Converting PlTerm to native C and C++ types (version 2)
These are deprecated and replaced by the various as_*()
methods.
PlTerm
can be converted to the following types:
- PlTerm ::operator term_t(void)
- This cast is used for integration with the C-interface primitives.
- PlTerm ::operator long(void)
- Yields a
long
if thePlTerm
is a Prolog integer or float that can be converted without loss to a long. Throws atype_error
exception otherwise. - PlTerm ::operator int(void)
- Same as for
long
, but might represent fewer bits. - PlTerm ::operator double(void)
- Yields the value as a C double if
PlTerm
represents a Prolog integer or float. - PlTerm ::operator wchar_t *(void)
- PlTerm ::operator char *(void)
- Converts the Prolog argument using PL_get_chars() using the flags
CVT_ALL|CVT_WRITE|BUF_RING
, which implies Prolog atoms and strings are converted to the represented text. All other data is handed to write/1. If the text is static in Prolog, a direct pointer to the string is returned. Otherwise the text is saved in a ring of 16 buffers and must be copied to avoid overwriting. - PlTerm ::operator void *(void)
- Extracts pointer value from a term. The term should have been created by PlTerm::PlTerm(void*).
In addition, the Prolog type (`PL_VARIABLE`,‘PL_ATOM`, ...‘PL_DICT`) can be determined using the type() method. There are also boolean methods that check the type:
- int PlTerm::type()
- See PL_term_type()
- bool PlTerm::is_variable()
- See PL_is_variable()
- bool PlTerm::is_ground()
- See PL_is_ground()
- bool PlTerm::is_atom(S)
- ee PL_is_atom()
- bool PlTerm::is_integer(S)
- ee PL_is_integer()
- bool PlTerm::is_string(S)
- ee PL_is_string()
- bool PlTerm::is_atom_or_string(I)
- s true if either PlTerm::is_atom() or PlTerm::is_string() is true.
- bool PlTerm::is_float(S)
- ee PL_is_float()
- bool PlTerm::is_rational(S)
- ee PL_is_rational()
- bool PlTerm::is_compound(S)
- ee PL_is_compound()
- bool PlTerm::is_callable(S)
- ee PL_is_callable()
- bool PlTerm::is_list(S)
- ee PL_is_list()
- bool PlTerm::is_dict(S)
- ee PL_is_dict()
- bool PlTerm::is_pair(S)
- ee PL_is_pair()
- bool PlTerm::is_atomic(S)
- ee PL_is_atomic()
- bool PlTerm::is_number(S)
- ee PL_is_number()
- bool PlTerm::is_acyclic(S)
- ee PL_is_acyclic()
- bool PlTerm::is_functor(PlFunctor)
- See PL_is_functor()