1Scanf.Scanning(3) OCaml library Scanf.Scanning(3)
2
3
4
6 Scanf.Scanning - Scanning buffers.
7
9 Module Scanf.Scanning
10
12 Module Scanning
13 : sig end
14
15
16 Scanning buffers.
17
18
19
20
21
22
23 type scanbuf
24
25
26 The type of scanning buffers. A scanning buffer is the argument passed
27 to the scanning functions used by the scanf family of functions. The
28 scanning buffer holds the current state of the scan, plus a function to
29 get the next char from the input, and a token buffer to store the
30 string matched so far.
31
32
33
34
35 val stdib : scanbuf
36
37 The scanning buffer reading from stdin . stdib is equivalent to Scan‐
38 ning.from_channel stdin .
39
40
41
42
43 val from_string : string -> scanbuf
44
45
46 Scanning.from_string s returns a scanning buffer which reads from the
47 given string. Reading starts from the first character in the string.
48 The end-of-input condition is set when the end of the string is
49 reached.
50
51
52
53
54 val from_file : string -> scanbuf
55
56 Bufferized file reading in text mode. The efficient and usual way to
57 scan text mode files (in effect, from_file returns a buffer that reads
58 characters in large chunks, rather than one character at a time as buf‐
59 fers returned by from_channel do). Scanning.from_file fname returns a
60 scanning buffer which reads from the given file fname in text mode.
61
62
63
64
65 val from_file_bin : string -> scanbuf
66
67 Bufferized file reading in binary mode.
68
69
70
71
72 val from_function : (unit -> char) -> scanbuf
73
74
75 Scanning.from_function f returns a scanning buffer with the given func‐
76 tion as its reading method. When scanning needs one more character,
77 the given function is called. When the function has no more character
78 to provide, it must signal an end-of-input condition by raising the
79 exception End_of_file .
80
81
82
83
84 val from_channel : Pervasives.in_channel -> scanbuf
85
86
87 Scanning.from_channel ic returns a scanning buffer which reads one
88 character at a time from the input channel ic , starting at the current
89 reading position.
90
91
92
93
94 val end_of_input : scanbuf -> bool
95
96
97 Scanning.end_of_input ib tests the end-of-input condition of the given
98 buffer.
99
100
101
102
103 val beginning_of_input : scanbuf -> bool
104
105
106 Scanning.beginning_of_input ib tests the beginning of input condition
107 of the given buffer.
108
109
110
111
112 val name_of_input : scanbuf -> string
113
114
115 Scanning.file_name_of_input ib returns the name of the character source
116 for the input buffer ib .
117
118
119
120
121
122
123OCamldoc 2007-05-24 Scanf.Scanning(3)