• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • CPACK
    • Home
    • List packs
    • Submit pack
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

12.4.3 Analysing Terms via the Foreign Interface
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Foreign Language Interface
        • The Foreign Include File
          • Analysing Terms via the Foreign Interface
            • Testing the type of a term
            • Reading data from a term
            • Exchanging text using length and string
              • PL_get_atom_nchars()
              • PL_get_list_nchars()
              • PL_get_nchars()
              • PL_put_atom_nchars()
              • PL_put_string_nchars()
              • PL_put_list_ncodes()
              • PL_put_list_nchars()
              • PL_unify_atom_nchars()
              • PL_unify_string_nchars()
              • PL_unify_list_ncodes()
              • PL_unify_list_nchars()
              • PL_new_atom_nchars()
              • PL_atom_nchars()
            • Wide-character versions
            • Reading a list
            • Processing option lists and dicts
            • An example: defining write/1 in C
    • Packages
>intPL_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.3.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, size_t len, const char *s)
See PL_put_atom_chars().
int PL_put_string_nchars(term_t t, size_t len, const char *s)
See PL_put_string_chars().

ClioPatria (version V3.1.1-42-gd6a756b-DIRTY)