1Scanf.Scanning(3)                OCaml library               Scanf.Scanning(3)
2
3
4

NAME

6       Scanf.Scanning -  Scanning buffers
7

Module

9       Module   Scanf.Scanning
10

Documentation

12       Module Scanning
13        : sig end
14
15
16
17       Scanning buffers
18
19
20
21
22
23
24
25       type scanbuf
26
27
28       The  type  of  scanning  buffers.  A scanning buffer is the source from
29       which a formatted input function gets characters. The  scanning  buffer
30       holds  the  current  state of the scan, plus a function to get the next
31       char from the input, and a token buffer to store the string matched  so
32       far.
33
34       Note:  a  scan  may  often require to examine one character in advance;
35       when this ``lookahead'' character does not belong to the token read, it
36       is  stored  back  in the scanning buffer and becomes the next character
37       read.
38
39
40
41
42       val stdib : scanbuf
43
44       The scanning buffer reading from stdin .  stdib is equivalent to  Scan‐
45       ning.from_channel stdin .
46
47       Note: when input is read interactively from stdin , the newline charac‐
48       ter that triggers the evaluation is incorporated in  the  input;  thus,
49       scanning specifications must properly skip this character (simply add a
50       '\n' as the last character of the format string).
51
52
53
54
55       val from_string : string -> scanbuf
56
57
58       Scanning.from_string s returns a scanning buffer which reads  from  the
59       given  string.   Reading starts from the first character in the string.
60       The end-of-input condition is  set  when  the  end  of  the  string  is
61       reached.
62
63
64
65
66       val from_file : string -> scanbuf
67
68       Bufferized  file  reading  in text mode. The efficient and usual way to
69       scan text mode files (in effect, from_file returns  a  scanning  buffer
70       that  reads  characters in large chunks, rather than one character at a
71       time as buffers returned by from_channel do).  Scanning.from_file fname
72       returns a scanning buffer which reads from the given file fname in text
73       mode.
74
75
76
77
78       val from_file_bin : string -> scanbuf
79
80       Bufferized file reading in binary mode.
81
82
83
84
85       val from_function : (unit -> char) -> scanbuf
86
87
88       Scanning.from_function f returns a scanning buffer with the given func‐
89       tion as its reading method.
90
91       When scanning needs one more character, the given function is called.
92
93       When  the  function has no more character to provide, it must signal an
94       end-of-input condition by raising the exception End_of_file .
95
96
97
98
99       val from_channel : Pervasives.in_channel -> scanbuf
100
101
102       Scanning.from_channel ic returns a scanning buffer which reads from the
103       input channel ic , starting at the current reading position.
104
105
106
107
108       val end_of_input : scanbuf -> bool
109
110
111       Scanning.end_of_input  ib tests the end-of-input condition of the given
112       scanning buffer.
113
114
115
116
117       val beginning_of_input : scanbuf -> bool
118
119
120       Scanning.beginning_of_input ib tests the beginning of  input  condition
121       of the given scanning buffer.
122
123
124
125
126       val name_of_input : scanbuf -> string
127
128
129       Scanning.file_name_of_input ib returns the name of the character source
130       for the scanning buffer ib .
131
132
133
134
135
136
137OCamldoc                          2017-03-22                 Scanf.Scanning(3)
Impressum