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 Pervasives.in_channel value. A Scanf.Scanning.in_channel
27 value is also called a formatted input channel or equivalently a scan‐
28 ning buffer. The type Scanf.Scanning.scanbuf below is an alias for
29 Scanning.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 Perva‐
55 sives.stdin .
56
57 Note: in the interactive system, when input is read from Perva‐
58 sives.stdin , the newline character that triggers evaluation is part of
59 the input; thus, the scanning specifications must properly skip this
60 additional newline character (for instance, simply add a '\n' as the
61 last character of the format string).
62
63
64 Since 3.12.0
65
66
67 type file_name = string
68
69
70 A convenient alias to designate a file name.
71
72
73 Since 4.00.0
74
75
76
77 val open_in : file_name -> in_channel
78
79
80 Scanning.open_in fname returns a Scanf.Scanning.in_channel formatted
81 input channel for bufferized reading in text mode from file fname .
82
83 Note: open_in returns a formatted input channel that efficiently reads
84 characters in large chunks; in contrast, from_channel below returns
85 formatted input channels that must read one character at a time, lead‐
86 ing to a much slower scanning rate.
87
88
89 Since 3.12.0
90
91
92
93 val open_in_bin : file_name -> in_channel
94
95
96 Scanning.open_in_bin fname returns a Scanf.Scanning.in_channel format‐
97 ted input channel for bufferized reading in binary mode from file fname
98 .
99
100
101 Since 3.12.0
102
103
104
105 val close_in : in_channel -> unit
106
107 Closes the Pervasives.in_channel associated with the given Scanf.Scan‐
108 ning.in_channel formatted input channel.
109
110
111 Since 3.12.0
112
113
114
115 val from_file : file_name -> in_channel
116
117 An alias for Scanf.Scanning.open_in above.
118
119
120
121 val from_file_bin : string -> in_channel
122
123 An alias for Scanf.Scanning.open_in_bin above.
124
125
126
127 val from_string : string -> in_channel
128
129
130 Scanning.from_string s returns a Scanf.Scanning.in_channel formatted
131 input channel which reads from the given string. Reading starts from
132 the first character in the string. The end-of-input condition is set
133 when the end of the string is reached.
134
135
136
137 val from_function : (unit -> char) -> in_channel
138
139
140 Scanning.from_function f returns a Scanf.Scanning.in_channel formatted
141 input channel with the given function as its reading method.
142
143 When scanning needs one more character, the given function is called.
144
145 When the function has no more character to provide, it must signal an
146 end-of-input condition by raising the exception End_of_file .
147
148
149
150 val from_channel : Pervasives.in_channel -> in_channel
151
152
153 Scanning.from_channel ic returns a Scanf.Scanning.in_channel formatted
154 input channel which reads from the regular Pervasives.in_channel input
155 channel ic argument. Reading starts at current reading position of ic
156 .
157
158
159
160 val end_of_input : in_channel -> bool
161
162
163 Scanning.end_of_input ic tests the end-of-input condition of the given
164 Scanf.Scanning.in_channel formatted input channel.
165
166
167
168 val beginning_of_input : in_channel -> bool
169
170
171 Scanning.beginning_of_input ic tests the beginning of input condition
172 of the given Scanf.Scanning.in_channel formatted input channel.
173
174
175
176 val name_of_input : in_channel -> string
177
178
179 Scanning.name_of_input ic returns the name of the character source for
180 the given Scanf.Scanning.in_channel formatted input channel.
181
182
183 Since 3.09.0
184
185
186
187 val stdib : in_channel
188
189 A deprecated alias for Scanf.Scanning.stdin , the scanning buffer read‐
190 ing from Pervasives.stdin .
191
192
193
194
195
196OCamldoc 2019-02-02 Scanf.Scanning(3)