man-pages/man3/Scanf.Scanning.3o.html
2021-03-31 01:06:50 +01:00

402 lines
5.9 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of Scanf.Scanning</TITLE>
</HEAD><BODY>
<H1>Scanf.Scanning</H1>
Section: OCaml library (3o)<BR>Updated: 2020-01-30<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
Scanf.Scanning - no description
<A NAME="lbAC">&nbsp;</A>
<H2>Module</H2>
Module Scanf.Scanning
<A NAME="lbAD">&nbsp;</A>
<H2>Documentation</H2>
<P>
Module
<B>Scanning</B>
<BR>&nbsp;:&nbsp;
<B>sig end</B>
<P>
<P>
<P>
<P>
<P>
<P>
<P>
<I>type in_channel </I>
<P>
<P>
The notion of input channel for the
<B>Scanf</B>
module:
those channels provide all the machinery necessary to read from any source
of characters, including a
<B>in_channel</B>
value.
A Scanf.Scanning.in_channel value is also called a formatted input
channel or equivalently a scanning buffer.
The type
<B>Scanf.Scanning.scanbuf</B>
below is an alias for
<B>Scanning.in_channel</B>
.
<P>
<P>
<B>Since</B>
3.12.0
<P>
<P>
<I>type scanbuf </I>
=
<B>in_channel</B>
<P>
<P>
The type of scanning buffers. A scanning buffer is the source from which a
formatted input function gets characters. The scanning buffer holds the
current state of the scan, plus a function to get the next char from the
input, and a token buffer to store the string matched so far.
<P>
Note: a scanning action may often require to examine one character in
advance; when this 'lookahead' character does not belong to the token
read, it is stored back in the scanning buffer and becomes the next
character yet to be read.
<P>
<P>
<P>
<I>val stdin </I>
:
<B>in_channel</B>
<P>
The standard input notion for the
<B>Scanf</B>
module.
<B>Scanning.stdin</B>
is the
<B>Scanf.Scanning.in_channel</B>
formatted input channel
attached to
<B>stdin</B>
.
<P>
Note: in the interactive system, when input is read from
<B>stdin</B>
, the newline character that triggers evaluation is
part of the input; thus, the scanning specifications must properly skip
this additional newline character (for instance, simply add a
<B>'\n'</B>
as
the last character of the format string).
<P>
<P>
<B>Since</B>
3.12.0
<P>
<P>
<I>type file_name </I>
=
<B>string</B>
<P>
<P>
A convenient alias to designate a file name.
<P>
<P>
<B>Since</B>
4.00.0
<P>
<P>
<P>
<I>val open_in </I>
:
<B>file_name -&gt; in_channel</B>
<P>
<P>
<B>Scanning.open_in fname</B>
returns a
<B>Scanf.Scanning.in_channel</B>
formatted input
channel for bufferized reading in text mode from file
<B>fname</B>
.
<P>
Note:
<B>open_in</B>
returns a formatted input channel that efficiently reads
characters in large chunks; in contrast,
<B>from_channel</B>
below returns
formatted input channels that must read one character at a time, leading
to a much slower scanning rate.
<P>
<P>
<B>Since</B>
3.12.0
<P>
<P>
<P>
<I>val open_in_bin </I>
:
<B>file_name -&gt; in_channel</B>
<P>
<P>
<B>Scanning.open_in_bin fname</B>
returns a
<B>Scanf.Scanning.in_channel</B>
formatted
input channel for bufferized reading in binary mode from file
<B>fname</B>
.
<P>
<P>
<B>Since</B>
3.12.0
<P>
<P>
<P>
<I>val close_in </I>
:
<B>in_channel -&gt; unit</B>
<P>
Closes the
<B>in_channel</B>
associated with the given
<B>Scanf.Scanning.in_channel</B>
formatted input channel.
<P>
<P>
<B>Since</B>
3.12.0
<P>
<P>
<P>
<I>val from_file </I>
:
<B>file_name -&gt; in_channel</B>
<P>
An alias for
<B>Scanf.Scanning.open_in</B>
above.
<P>
<P>
<P>
<I>val from_file_bin </I>
:
<B>string -&gt; in_channel</B>
<P>
An alias for
<B>Scanf.Scanning.open_in_bin</B>
above.
<P>
<P>
<P>
<I>val from_string </I>
:
<B>string -&gt; in_channel</B>
<P>
<P>
<B>Scanning.from_string s</B>
returns a
<B>Scanf.Scanning.in_channel</B>
formatted
input channel which reads from the given string.
Reading starts from the first character in the string.
The end-of-input condition is set when the end of the string is reached.
<P>
<P>
<P>
<I>val from_function </I>
:
<B>(unit -&gt; char) -&gt; in_channel</B>
<P>
<P>
<B>Scanning.from_function f</B>
returns a
<B>Scanf.Scanning.in_channel</B>
formatted
input channel with the given function as its reading method.
<P>
When scanning needs one more character, the given function is called.
<P>
When the function has no more character to provide, it must signal an
end-of-input condition by raising the exception
<B>End_of_file</B>
.
<P>
<P>
<P>
<I>val from_channel </I>
:
<B>in_channel -&gt; in_channel</B>
<P>
<P>
<B>Scanning.from_channel ic</B>
returns a
<B>Scanf.Scanning.in_channel</B>
formatted
input channel which reads from the regular
<B>in_channel</B>
input
channel
<B>ic</B>
argument.
Reading starts at current reading position of
<B>ic</B>
.
<P>
<P>
<P>
<I>val end_of_input </I>
:
<B>in_channel -&gt; bool</B>
<P>
<P>
<B>Scanning.end_of_input ic</B>
tests the end-of-input condition of the given
<B>Scanf.Scanning.in_channel</B>
formatted input channel.
<P>
<P>
<P>
<I>val beginning_of_input </I>
:
<B>in_channel -&gt; bool</B>
<P>
<P>
<B>Scanning.beginning_of_input ic</B>
tests the beginning of input condition
of the given
<B>Scanf.Scanning.in_channel</B>
formatted input channel.
<P>
<P>
<P>
<I>val name_of_input </I>
:
<B>in_channel -&gt; string</B>
<P>
<P>
<B>Scanning.name_of_input ic</B>
returns the name of the character source
for the given
<B>Scanf.Scanning.in_channel</B>
formatted input channel.
<P>
<P>
<B>Since</B>
3.09.0
<P>
<P>
<P>
<I>val stdib </I>
:
<B>in_channel</B>
<P>
A deprecated alias for
<B>Scanf.Scanning.stdin</B>
, the scanning buffer reading from
<B>stdin</B>
.
<P>
<P>
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="1"><A HREF="#lbAB">NAME</A><DD>
<DT id="2"><A HREF="#lbAC">Module</A><DD>
<DT id="3"><A HREF="#lbAD">Documentation</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:54 GMT, March 31, 2021
</BODY>
</HTML>