• 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.9 Foreign access to Prolog IO streams
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Foreign Language Interface
        • Foreign access to Prolog IO streams
          • Get IO stream handles
          • Creating an IO stream
          • Interacting with foreign streams
          • Foreign stream error handling
          • Foreign stream encoding
          • Foreign stream line endings
          • Foreign stream position information
          • Support functions for blob save/load
            • PL_qlf_put_int64()
            • PL_qlf_put_int32()
            • PL_qlf_put_uint32()
            • PL_qlf_put_double()
            • PL_qlf_put_atom()
            • PL_qlf_get_int64()
            • PL_qlf_get_int32()
            • PL_qlf_get_uint32()
            • PL_qlf_get_double()
            • PL_qlf_get_atom()
    • Packages

12.9.8 Support functions for blob save/load

The functions in this sections are intended to support blobs to define save() and load() functions so they can be part of a saved state or .qlf file. The matching pair of functions is guaranteed to give the same result, regardless of byte ordering (big or little endian). The user must not make any assumptions on the exact data format used for storing the data. The atom read/write functions can only be used from the blob callback functions.

For saving an uninterpreted array of bytes, it is suggested that the length is output as a size_t value using PL_qlf_put_uint32() followed by the bytes using Sfwrite(); and for loading, the length is read using PL_qlf_get_uint32(), a buffer is allocated, and the bytes are read using Sfread().

int PL_qlf_put_int64(int64_t i, IOSTREAM *s)
int PL_qlf_put_int32(int32_t i, IOSTREAM *s)
int PL_qlf_put_uint32(uint32 i, IOSTREAM *s)
Write integers of several sizes. Signed integers are written in zigzag encoding. For unsigned integers we only write the non-zero bytes. The result is compact and the same for big or little endian.
int PL_qlf_put_double(double f, IOSTREAM *s)
Write double as 8 byte big endian.
int PL_qlf_put_atom(atom_t a, IOSTREAM *s)
Write an atom. The atom may be a blob. Note that this function may only be used from a blob save() function. Calling from another context results in a fatal error.
int PL_qlf_get_int64(IOSTREAM *s, int64_t *ip)
int PL_qlf_get_int32(IOSTREAM *s, int32_t *ip)
int PL_qlf_get_uint32(IOSTREAM *s, uint32_t *ip)
int PL_qlf_get_double(IOSTREAM *s, double *fp)
Counterparts of corresponding PL_qlf_put_*() functions.
int PL_qlf_get_atom(IOSTREAM *s, atom_t *ap)
Counterpart of PL_qlf_put_atom(). Again, this may only be used in the context of a blob load() function.

ClioPatria (version V3.1.1-51-ga0b30a5)