Module Scanf.Scanning
type in_channelThe notion of input channel for the
Scanfmodule: those channels provide all the machinery necessary to read from any source of characters, including aStdlib.in_channelvalue. A Scanf.Scanning.in_channel value is also called a formatted input channel or equivalently a scanning buffer. The typeScanning.scanbufbelow is an alias forScanning.in_channel.- since
- 3.12.0
type scanbuf= in_channelThe 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.
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.
val stdin : in_channelThe standard input notion for the
Scanfmodule.Scanning.stdinis theScanning.in_channelformatted input channel attached toStdlib.stdin.Note: in the interactive system, when input is read from
Stdlib.stdin, 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'\n'as the last character of the format string).- since
- 3.12.0
val open_in : file_name -> in_channelScanning.open_in fnamereturns aScanning.in_channelformatted input channel for bufferized reading in text mode from filefname.Note:
open_inreturns a formatted input channel that efficiently reads characters in large chunks; in contrast,from_channelbelow returns formatted input channels that must read one character at a time, leading to a much slower scanning rate.- since
- 3.12.0
val open_in_bin : file_name -> in_channelScanning.open_in_bin fnamereturns aScanning.in_channelformatted input channel for bufferized reading in binary mode from filefname.- since
- 3.12.0
val close_in : in_channel -> unitCloses the
Stdlib.in_channelassociated with the givenScanning.in_channelformatted input channel.- since
- 3.12.0
val from_file : file_name -> in_channelAn alias for
Scanning.open_inabove.
val from_file_bin : string -> in_channelAn alias for
Scanning.open_in_binabove.
val from_string : string -> in_channelScanning.from_string sreturns aScanning.in_channelformatted 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.
val from_function : (unit -> char) -> in_channelScanning.from_function freturns aScanning.in_channelformatted input channel with the given function as its reading method.When scanning needs one more character, the given function is called.
When the function has no more character to provide, it must signal an end-of-input condition by raising the exception
End_of_file.
val from_channel : Stdlib.in_channel -> in_channelScanning.from_channel icreturns aScanning.in_channelformatted input channel which reads from the regularStdlib.in_channelinput channelicargument. Reading starts at current reading position ofic.
val end_of_input : in_channel -> boolScanning.end_of_input ictests the end-of-input condition of the givenScanning.in_channelformatted input channel.
val beginning_of_input : in_channel -> boolScanning.beginning_of_input ictests the beginning of input condition of the givenScanning.in_channelformatted input channel.
val name_of_input : in_channel -> stringScanning.name_of_input icreturns the name of the character source for the givenScanning.in_channelformatted input channel.- since
- 3.09.0
val stdib : in_channelA deprecated alias for
Scanning.stdin, the scanning buffer reading fromStdlib.stdin.