• 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.8 BLOBS: Using atoms to store arbitrary binary data
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
      • Foreign Language Interface
        • The Foreign Include File
          • BLOBS: Using atoms to store arbitrary binary data
            • Defining a BLOB type
              • PL_unregister_blob_type()
            • Accessing blobs
    • Packages
ntiation_error()">intPL_uninstantiation_error(term_t culprit)
Raise uninstantiation_error(culprit). This should be called if an argument that must be unbound at entry is bound to culprit. This error is typically raised for a pure output arguments such as a newly created stream handle (e.g., the third argument of open/3).
int PL_representation_error(const char *resource)
Raise representation_error(resource). See representation_error/1.
int PL_type_error(const char *expected, term_t culprit)
Raise type_error(expected, culprit). See type_error/2.
int PL_domain_error(const char *expected, term_t culprit)
Raise domain_error(expected, culprit). See domain_error/2.
int PL_existence_error(const char *type, term_t culprit)
Raise existence_error(type, culprit). See type_error/2.
int PL_permission_error(const char *operation, const char *type, term_t culprit)
Raise permission_error(operation, type, culprit). See permission_error/3.
int PL_resource_error(const char *resource)
Raise resource_error(resource). See resource_error/1.
int PL_syntax_error(const char *message, IOSTREAM *in)
Raise syntax_error(message). If arg is not NULL, add information about the current position of the input stream.

12.4.7 Foreign language wrapper support functions

In addition to the functions described in section 12.4.3.2, there is a family of functions that is used for automatic generation of wrapper functions, for example using the Prolog library library(qpforeign) that provides a Quintus/SICStus compatible foreign language interface.

The PL_cvt_i_*() family of functions is suitable for use with a _Generic selector or C++ overloading.218_Generic needs to take into account that there's no bool type in C but there is in C++. An overloaded integer() method is provided in the C++ interface.

Note that the documentation on this API is incomplete. Also note that many of these functions are equivalent to the PL_get_*_ex() functions described in section 12.4.6.

int PL_cvt_i_bool(term_t p, int *c)
Equivalent to PL_get_bool_ex(). Note that the pointer is to an int because C has no bool type. The return value is either 0 or 1.
int PL_cvt_i_char(term_t p, char *c)
int PL_cvt_i_schar(term_t p, signed char *c)
int PL_cvt_i_uchar(term_t p, unsigned char *c)
int PL_cvt_i_short(term_t p, short *s)
int PL_cvt_i_ushort(term_t p, unsigned short *s)
int PL_cvt_i_int(term_t p, int *c)
int PL_cvt_i_uint(term_t p, unsigned int *c)
int PL_cvt_i_long(term_t p, long *c)
int PL_cvt_i_ulong(term_t p, unsigned long *c)
int PL_cvt_i_llong(term_t p, long long *c)
int PL_cvt_i_ullong(term_t p, unsigned long long *c)
int PL_cvt_i_int32(term_t p, int32_t *c)
int PL_cvt_i_uint32(term_t p, uint32_t *c)
int PL_cvt_i_int64(term_t p, int64_t *c)
int PL_cvt_i_uint64(term_t p, uint64_t *c)
int PL_cvt_i_size_t(term_t p, size_t *c)
Convert a Prolog integer into a C integer of the specified size. Generate an exception and return FALSE if the conversion is impossible because the Prolog term is not an integer or the C type cannot represent the value of the Prolog integer.

12.4.8 Serializing and deserializing Prolog terms

int PL_put_term_from_chars(term_t t, int flags, size_t len, const char *s)
Parse the text from the C-string s holding len bytes and put the resulting term in t. len can be (size_t)-1, assuming a 0-terminated string. The flags argument controls the encoding and is currently one of REP_UTF8 (string is UTF8 encoded), REP_MB (string is encoded in the current locale) or 0 (string is encoded in ISO latin 1). The string may, but is not required, to be closed by a full stop (.).

If parsing produces an exception the behaviour depends on the CVT_EXCEPTION flag. If present, the exception is propagated into the environment. Otherwise, the exception is placed in t and the return value is FALSE.219The CVT_EXCEPTION was added in version 8.3.12.

12.4.9 BLOBS: Using atoms to store arbitrary binary data

SWI-Prolog atoms as well as strings can represent arbitrary binary data of arbitrary length. This facility is attractive for storing foreign data such as images in an atom. An atom is a unique handle to this data and the atom garbage collector is able to destroy atoms that are no longer referenced by the Prolog engine. This property of atoms makes them attractive as a handle to foreign resources, such as Java atoms, Microsoft's COM objects, etc., providing safe combined garbage collection.

To exploit these features safely and in an organised manner, the SWI-Prolog foreign interface allows creating‘a

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