.. index:: single: reader
.. _reader/0:

.. rst-class:: right

**object**

``reader``
==========

Predicates for reading text file and text stream contents to lists of terms, characters, or character codes and for reading binary file and binary stream contents to lists of bytes.

| **Availability:** 
|    ``logtalk_load(reader(loader))``

| **Author:** Paulo Moura
| **Version:** 2:2:0
| **Date:** 2023-11-14

| **Compilation flags:**
|    ``static, context_switching_calls``


| **Dependencies:**
|   (none)


| **Remarks:**
|    (none)

| **Inherited public predicates:**
|    (none)

.. contents::
   :local:
   :backlinks: top

Public predicates
-----------------

.. index:: file_to_codes/2
.. _reader/0::file_to_codes/2:

``file_to_codes/2``
^^^^^^^^^^^^^^^^^^^

Reads a text file into a list of character codes.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``file_to_codes(File,Codes)``
| **Mode and number of proofs:**
|    ``file_to_codes(+atom,-list(character_code))`` - ``one``


------------

.. index:: file_to_codes/3
.. _reader/0::file_to_codes/3:

``file_to_codes/3``
^^^^^^^^^^^^^^^^^^^

Reads a text file into a list of character codes. The list is terminated by the given tail.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``file_to_codes(File,Codes,Tail)``
| **Mode and number of proofs:**
|    ``file_to_codes(+atom,-list(character_code),@term)`` - ``one``


------------

.. index:: file_to_chars/2
.. _reader/0::file_to_chars/2:

``file_to_chars/2``
^^^^^^^^^^^^^^^^^^^

Reads a text file into a list of characters.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``file_to_chars(File,Chars)``
| **Mode and number of proofs:**
|    ``file_to_chars(+atom,-list(character))`` - ``one``


------------

.. index:: file_to_chars/3
.. _reader/0::file_to_chars/3:

``file_to_chars/3``
^^^^^^^^^^^^^^^^^^^

Reads a text file into a list of characters. The list is terminated by the given tail.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``file_to_chars(File,Chars,Tail)``
| **Mode and number of proofs:**
|    ``file_to_chars(+atom,-list(character),@term)`` - ``one``


------------

.. index:: file_to_terms/2
.. _reader/0::file_to_terms/2:

``file_to_terms/2``
^^^^^^^^^^^^^^^^^^^

Reads a text file into a list of terms.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``file_to_terms(File,Terms)``
| **Mode and number of proofs:**
|    ``file_to_terms(+atom,-list(term))`` - ``one``


------------

.. index:: file_to_terms/3
.. _reader/0::file_to_terms/3:

``file_to_terms/3``
^^^^^^^^^^^^^^^^^^^

Reads a text file into a list of terms. The list is terminated by the given tail.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``file_to_terms(File,Terms,Tail)``
| **Mode and number of proofs:**
|    ``file_to_terms(+atom,-list(term),@term)`` - ``one``


------------

.. index:: file_to_bytes/2
.. _reader/0::file_to_bytes/2:

``file_to_bytes/2``
^^^^^^^^^^^^^^^^^^^

Reads a binary file into a list of bytes.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``file_to_bytes(File,Bytes)``
| **Mode and number of proofs:**
|    ``file_to_bytes(+atom,-list(byte))`` - ``one``


------------

.. index:: file_to_bytes/3
.. _reader/0::file_to_bytes/3:

``file_to_bytes/3``
^^^^^^^^^^^^^^^^^^^

Reads a binary file into a list of bytes. The list is terminated by the given tail.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``file_to_bytes(File,Bytes,Tail)``
| **Mode and number of proofs:**
|    ``file_to_bytes(+atom,-list(byte),@term)`` - ``one``


------------

.. index:: stream_to_codes/2
.. _reader/0::stream_to_codes/2:

``stream_to_codes/2``
^^^^^^^^^^^^^^^^^^^^^

Reads a text stream into a list of character codes. Does not close the stream.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``stream_to_codes(Stream,Codes)``
| **Mode and number of proofs:**
|    ``stream_to_codes(+stream_or_alias,-list(character_code))`` - ``one``


------------

.. index:: stream_to_codes/3
.. _reader/0::stream_to_codes/3:

``stream_to_codes/3``
^^^^^^^^^^^^^^^^^^^^^

Reads a text stream into a list of character codes. Does not close the stream. The list is terminated by the given tail.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``stream_to_codes(Stream,Codes,Tail)``
| **Mode and number of proofs:**
|    ``stream_to_codes(+stream_or_alias,-list(character_code),@term)`` - ``one``


------------

.. index:: stream_to_chars/2
.. _reader/0::stream_to_chars/2:

``stream_to_chars/2``
^^^^^^^^^^^^^^^^^^^^^

Reads a text stream into a list of characters. Does not close the stream.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``stream_to_chars(Stream,Chars)``
| **Mode and number of proofs:**
|    ``stream_to_chars(+stream_or_alias,-list(char))`` - ``one``


------------

.. index:: stream_to_chars/3
.. _reader/0::stream_to_chars/3:

``stream_to_chars/3``
^^^^^^^^^^^^^^^^^^^^^

Reads a text stream into a list of characters. Does not close the stream. The list is terminated by the given tail.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``stream_to_chars(Stream,Chars,Tail)``
| **Mode and number of proofs:**
|    ``stream_to_chars(+stream_or_alias,-list(char),@term)`` - ``one``


------------

.. index:: stream_to_terms/2
.. _reader/0::stream_to_terms/2:

``stream_to_terms/2``
^^^^^^^^^^^^^^^^^^^^^

Reads a text stream into a list of terms. Does not close the stream.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``stream_to_terms(Stream,Terms)``
| **Mode and number of proofs:**
|    ``stream_to_terms(+stream_or_alias,-list(term))`` - ``one``


------------

.. index:: stream_to_terms/3
.. _reader/0::stream_to_terms/3:

``stream_to_terms/3``
^^^^^^^^^^^^^^^^^^^^^

Reads a text stream into a list of terms. Does not close the stream. The list is terminated by the given tail.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``stream_to_terms(Stream,Terms,Tail)``
| **Mode and number of proofs:**
|    ``stream_to_terms(+stream_or_alias,-list(term),@term)`` - ``one``


------------

.. index:: stream_to_bytes/2
.. _reader/0::stream_to_bytes/2:

``stream_to_bytes/2``
^^^^^^^^^^^^^^^^^^^^^

Reads a binary stream into a list of bytes. Does not close the stream.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``stream_to_bytes(Stream,Bytes)``
| **Mode and number of proofs:**
|    ``stream_to_bytes(+stream_or_alias,-list(byte))`` - ``one``


------------

.. index:: stream_to_bytes/3
.. _reader/0::stream_to_bytes/3:

``stream_to_bytes/3``
^^^^^^^^^^^^^^^^^^^^^

Reads a binary stream into a list of bytes. Does not close the stream. The list is terminated by the given tail.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``stream_to_bytes(Stream,Bytes,Tail)``
| **Mode and number of proofs:**
|    ``stream_to_bytes(+stream_or_alias,-list(byte),@term)`` - ``one``


------------

.. index:: line_to_chars/2
.. _reader/0::line_to_chars/2:

``line_to_chars/2``
^^^^^^^^^^^^^^^^^^^

Reads a line from a text stream into a list of characters. Discards the end-of-line characters. Unifies ``Chars`` with ``end_of_file`` at the end of the file.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``line_to_chars(Stream,Chars)``
| **Mode and number of proofs:**
|    ``line_to_chars(+stream_or_alias,-types([atom,list(character)]))`` - ``one``


------------

.. index:: line_to_chars/3
.. _reader/0::line_to_chars/3:

``line_to_chars/3``
^^^^^^^^^^^^^^^^^^^

Reads a line from a text stream into a list of characters. Keeps the end-of-line marker normalized to the line feed control character. The list is terminated by the given tail, which is unified with the empty list at the end of the file.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``line_to_chars(Stream,Chars,Tail)``
| **Mode and number of proofs:**
|    ``line_to_chars(+stream_or_alias,-list(character),?term)`` - ``one``


------------

.. index:: line_to_codes/2
.. _reader/0::line_to_codes/2:

``line_to_codes/2``
^^^^^^^^^^^^^^^^^^^

Reads a line from a text stream into a list of character codes. Discards the end-of-line character codes. Unifies ``Codes`` with ``end_of_file`` at the end of the file.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``line_to_codes(Stream,Codes)``
| **Mode and number of proofs:**
|    ``line_to_codes(+stream_or_alias,-types([atom,list(character_code)]))`` - ``one``


------------

.. index:: line_to_codes/3
.. _reader/0::line_to_codes/3:

``line_to_codes/3``
^^^^^^^^^^^^^^^^^^^

Reads a line from a text stream into a list of character codes. Keeps the end-of-line marker normalized to the line feed control character code. The list is terminated by the given tail, which is unified with the empty list at the end of the file.

| **Compilation flags:**
|    ``static``

| **Template:**
|    ``line_to_codes(Stream,Codes,Tail)``
| **Mode and number of proofs:**
|    ``line_to_codes(+stream_or_alias,-list(character_code),?term)`` - ``one``


------------

Protected predicates
--------------------

(none)

Private predicates
------------------

(none)

Operators
---------

(none)

