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 . Note that a Scanning.in_channel is not concur‐
30 rency-safe: concurrent use may produce arbitrary values or exceptions.
31
32
33 Since 3.12.0
34
35
36 type scanbuf = in_channel
37
38
39 The type of scanning buffers. A scanning buffer is the source from
40 which a formatted input function gets characters. The scanning buffer
41 holds the current state of the scan, plus a function to get the next
42 char from the input, and a token buffer to store the string matched so
43 far.
44
45 Note: a scanning action may often require to examine one character in
46 advance; when this 'lookahead' character does not belong to the token
47 read, it is stored back in the scanning buffer and becomes the next
48 character yet to be read.
49
50
51
52 val stdin : in_channel
53
54 The standard input notion for the Scanf module. Scanning.stdin is the
55 Scanf.Scanning.in_channel formatted input channel attached to stdin .
56
57 Note: in the interactive system, when input is read from stdin , the
58 newline character that triggers evaluation is part of the input; thus,
59 the scanning specifications must properly skip this additional newline
60 character (for instance, simply add a '\n' as the last character of the
61 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 in_channel associated with the given Scanf.Scanning.in_chan‐
108 nel 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 : 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 in_channel input channel ic
155 argument. Reading starts at current reading position of ic .
156
157
158
159 val end_of_input : in_channel -> bool
160
161
162 Scanning.end_of_input ic tests the end-of-input condition of the given
163 Scanf.Scanning.in_channel formatted input channel.
164
165
166
167 val beginning_of_input : in_channel -> bool
168
169
170 Scanning.beginning_of_input ic tests the beginning of input condition
171 of the given Scanf.Scanning.in_channel formatted input channel.
172
173
174
175 val name_of_input : in_channel -> string
176
177
178 Scanning.name_of_input ic returns the name of the character source for
179 the given Scanf.Scanning.in_channel formatted input channel.
180
181
182 Since 3.09.0
183
184
185
186
187
188OCamldoc 2023-07-20 Scanf.Scanning(3)