1Scanf.Scanning(3) OCaml library Scanf.Scanning(3)
2
3
4
6 Scanf.Scanning - no description
7
9 Module Scanf.Scanning
10
12 Module Scanning
13 : sig end
14
15
16
17
18
19
20
21 type in_channel
22
23
24 The notion of input channel for the Scanf module: those channels pro‐
25 vide all the machinery necessary to read from any source of characters,
26 including a in_channel value. A Scanf.Scanning.in_channel value is
27 also called a formatted input channel or equivalently a scanning buf‐
28 fer. The type Scanf.Scanning.scanbuf below is an alias for Scan‐
29 ning.in_channel .
30
31
32 Since 3.12.0
33
34
35 type scanbuf = in_channel
36
37
38 The type of scanning buffers. A scanning buffer is the source from
39 which a formatted input function gets characters. The scanning buffer
40 holds the current state of the scan, plus a function to get the next
41 char from the input, and a token buffer to store the string matched so
42 far.
43
44 Note: a scanning action may often require to examine one character in
45 advance; when this 'lookahead' character does not belong to the token
46 read, it is stored back in the scanning buffer and becomes the next
47 character yet to be read.
48
49
50
51 val stdin : in_channel
52
53 The standard input notion for the Scanf module. Scanning.stdin is the
54 Scanf.Scanning.in_channel formatted input channel attached to stdin .
55
56 Note: in the interactive system, when input is read from stdin , the
57 newline character that triggers evaluation is part of the input; thus,
58 the scanning specifications must properly skip this additional newline
59 character (for instance, simply add a '\n' as the last character of the
60 format string).
61
62
63 Since 3.12.0
64
65
66 type file_name = string
67
68
69 A convenient alias to designate a file name.
70
71
72 Since 4.00.0
73
74
75
76 val open_in : file_name -> in_channel
77
78
79 Scanning.open_in fname returns a Scanf.Scanning.in_channel formatted
80 input channel for bufferized reading in text mode from file fname .
81
82 Note: open_in returns a formatted input channel that efficiently reads
83 characters in large chunks; in contrast, from_channel below returns
84 formatted input channels that must read one character at a time, lead‐
85 ing to a much slower scanning rate.
86
87
88 Since 3.12.0
89
90
91
92 val open_in_bin : file_name -> in_channel
93
94
95 Scanning.open_in_bin fname returns a Scanf.Scanning.in_channel format‐
96 ted input channel for bufferized reading in binary mode from file fname
97 .
98
99
100 Since 3.12.0
101
102
103
104 val close_in : in_channel -> unit
105
106 Closes the in_channel associated with the given Scanf.Scanning.in_chan‐
107 nel formatted input channel.
108
109
110 Since 3.12.0
111
112
113
114 val from_file : file_name -> in_channel
115
116 An alias for Scanf.Scanning.open_in above.
117
118
119
120 val from_file_bin : string -> in_channel
121
122 An alias for Scanf.Scanning.open_in_bin above.
123
124
125
126 val from_string : string -> in_channel
127
128
129 Scanning.from_string s returns a Scanf.Scanning.in_channel formatted
130 input channel which reads from the given string. Reading starts from
131 the first character in the string. The end-of-input condition is set
132 when the end of the string is reached.
133
134
135
136 val from_function : (unit -> char) -> in_channel
137
138
139 Scanning.from_function f returns a Scanf.Scanning.in_channel formatted
140 input channel with the given function as its reading method.
141
142 When scanning needs one more character, the given function is called.
143
144 When the function has no more character to provide, it must signal an
145 end-of-input condition by raising the exception End_of_file .
146
147
148
149 val from_channel : in_channel -> in_channel
150
151
152 Scanning.from_channel ic returns a Scanf.Scanning.in_channel formatted
153 input channel which reads from the regular in_channel input channel ic
154 argument. Reading starts at current reading position of ic .
155
156
157
158 val end_of_input : in_channel -> bool
159
160
161 Scanning.end_of_input ic tests the end-of-input condition of the given
162 Scanf.Scanning.in_channel formatted input channel.
163
164
165
166 val beginning_of_input : in_channel -> bool
167
168
169 Scanning.beginning_of_input ic tests the beginning of input condition
170 of the given Scanf.Scanning.in_channel formatted input channel.
171
172
173
174 val name_of_input : in_channel -> string
175
176
177 Scanning.name_of_input ic returns the name of the character source for
178 the given Scanf.Scanning.in_channel formatted input channel.
179
180
181 Since 3.09.0
182
183
184
185 val stdib : in_channel
186
187 A deprecated alias for Scanf.Scanning.stdin , the scanning buffer read‐
188 ing from stdin .
189
190
191
192
193
194OCamldoc 2020-02-27 Scanf.Scanning(3)