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.1 Constructors

PlTerm :: PlTerm()
Creates a new initialised term (holding a Prolog variable).
PlTerm :: PlTerm(term_t t)
Converts between the C-interface and the C++ interface by turning the term-reference into an instance of PlTerm. Note that, being a lightweight class, this is a no-op at the machine-level!
PlTerm :: PlTerm(const char *text)
Creates a term-references holding a Prolog atom representing text.
PlTerm :: PlTerm(const wchar_t *text)
Creates a term-references holding a Prolog atom representing text.
PlTerm :: PlTerm(const PlAtom &atom)
Creates a term-references holding a Prolog atom from an atom-handle.
PlTerm :: PlTerm(long n)
Creates a term-references holding a Prolog integer representing n.
PlTerm :: PlTerm(double f)
Creates a term-references holding a Prolog float representing f.
PlTerm :: PlTerm(void *ptr)
Creates a term-references holding a Prolog pointer. A pointer is represented in Prolog as a mangled integer. The mangling is designed to make most pointers fit into a tagged-integer. Any valid pointer can be represented. This mechanism can be used to represent pointers to C++ objects in Prolog. Please note that‘myclass' should define conversion to and from void *.
PREDICATE(make_my_object, 1)
{ myclass *myobj = new myclass();

  return A1 = (void *)myobj;
}

PREDICATE(free_my_object, 1)
{ myclass *myobj = (void *)A1;

  delete(myobj);
  return TRUE;
}