File "charsio"

This Prolog text provides temporary input/output redirection. The predicate with_text_to/2 re-directs the output for the given goal and retrieves the stream content for each success. The predicate with_text_from/2 redirects the input for the given goal. Both predicates work with atoms for their return result respective actual argument.

As a convenience the predicate term_atom/[2,3] allows writing a Prolog term into a new atom. The binary predicate will use writeq/1, the ternary predicate will use write_term/2 and if quoting isn’t desired, one needs to opt-out. This module also provides a couple of simple utilities to deal with the generation of XML texts.

The following compat predicates are provided:

with_text_to(A, G):
The predicate succeeds whenever G succeeds and unifies A with its text output.
with_text_from(A, G):
The predicate succeeds whenever G succeeds and provides A as its text input.
open_input_atom_stream(A, S):
The built-in succeeds in S with a new input stream for the atom A.
open_output_atom_stream(S):
The built-in succeeds in S with a new output stream.
close_output_atom_stream(S, A):
The built-in succeeds in A with the content of the output stream S.
xml_escape(T, E):
The predicate succeeds when E unifies with the text escape of T.
percent_encode(T, E):
The predicate succeeds when E unifies with the percent encode of T.
term_atom(T, A):
term_atom(T, A, O):
The build-in succeeds in writing the term T into a new atom A. The ternary predicate accepts write options O.
enum_atoms(S, A):
enum_atoms(S, A, O):
The predicate succeeds in A with the subsequent atoms from the stream S. The ternary predicate allows specifying atom options.

Comments