1.4 The class PlTerm
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • A C++ interface to SWI-Prolog
        • A C++ interface to SWI-Prolog (Version 1)
          • The class PlTerm
            • Constructors
            • Casting PlTerm to native C-types
            • Unification
            • Comparison
            • Analysing compound terms
            • Miscellaneous
            • The class PlString
            • The class PlCodeList
            • The class PlCharList
            • The class PlCompound
            • The class PlTail

1.4.2 Casting PlTerm to native C-types

PlTerm can be cast 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 the PlTerm is a Prolog integer or float that can be converted without loss to a long. throws a type_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*).