/[eiffelstudio]/FreeELKS/trunk/library/kernel/std_files.e
ViewVC logotype

Contents of /FreeELKS/trunk/library/kernel/std_files.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 91424 - (show annotations)
Tue Oct 26 18:39:32 2004 UTC (15 years, 2 months ago) by manus_eiffel
File size: 5431 byte(s)
Initial revision

1 indexing
2
3 description: "[
4 Commonly used input and output mechanisms.
5 This class may be used as either ancestor or supplier
6 by classes needing its facilities.
7 ]"
8
9 status: "See notice at end of class"
10 date: "$Date$"
11 revision: "$Revision$"
12
13 class
14 STD_FILES
15
16 feature -- Access
17
18 input: PLAIN_TEXT_FILE is
19 -- Standard input file
20 once
21 create {CONSOLE} Result.make_open_stdin ("stdin")
22 end
23
24 output: PLAIN_TEXT_FILE is
25 -- Standard output file
26 once
27 create {CONSOLE} Result.make_open_stdout ("stdout")
28 end
29
30 error: PLAIN_TEXT_FILE is
31 -- Standard error file
32 once
33 create {CONSOLE} Result.make_open_stderr ("stderr")
34 end
35
36 default_output: PLAIN_TEXT_FILE
37 -- Default output
38
39 standard_default: PLAIN_TEXT_FILE is
40 -- Return the `default_output' or `output'
41 -- if `default_output' is Void.
42 --| Useful if a class inherits from STD_FILES and
43 --| and a `putint' is applied without standard setting.
44 do
45 if default_output = Void then
46 Result := output
47 else
48 Result := default_output
49 end
50 end
51
52 feature -- Status report
53
54 last_character, lastchar: CHARACTER is
55 -- Last character read by `read_character'
56 do
57 Result := input.last_character
58 end
59
60 last_integer, lastint: INTEGER is
61 -- Last integer read by `read_integer'
62 do
63 Result := input.last_integer
64 end
65
66 last_real, lastreal: REAL is
67 -- Last real read by `read_real'
68 do
69 Result := input.last_real
70 end
71
72 last_string, laststring: STRING is
73 -- Last string read by `read_line',
74 -- `read_stream', or `read_word'
75 do
76 Result := input.last_string
77 end
78
79 last_double, lastdouble: DOUBLE is
80 -- Last double read by `read_double'
81 do
82 Result := input.last_double
83 end
84
85 feature -- Element change
86
87 set_error_default is
88 -- Use standard error as default output.
89 do
90 default_output := error
91 end
92
93 set_file_default (f: PLAIN_TEXT_FILE) is
94 -- Use `f' as default output.
95 require
96 valid_argument: f /= Void
97 file_open_write: f.is_open_write
98 do
99 default_output := f
100 end
101
102 set_output_default is
103 -- Use standard output as default output.
104 do
105 default_output := output
106 end
107
108 put_character, putchar (c: CHARACTER) is
109 -- Write `c' at end of default output.
110 do
111 standard_default.put_character (c)
112 end
113
114 put_string, putstring (s: STRING) is
115 -- Write `s' at end of default output.
116 require
117 string_not_void: s /= Void
118 do
119 standard_default.put_string (s)
120 end
121
122 put_real, putreal (r: REAL) is
123 -- Write `r' at end of default output.
124 do
125 standard_default.put_real (r)
126 end
127
128 put_double, putdouble (d: DOUBLE) is
129 -- Write `d' at end of default output.
130 do
131 standard_default.put_double (d)
132 end
133
134 put_integer, putint (i: INTEGER) is
135 -- Write `i' at end of default output.
136 do
137 standard_default.put_integer (i)
138 end
139
140 put_boolean, putbool (b: BOOLEAN) is
141 -- Write `b' at end of default output.
142 do
143 if b then
144 put_string ("True")
145 else
146 put_string ("False")
147 end
148 end
149
150 put_new_line, new_line is
151 -- Write line feed at end of default output.
152 do
153 standard_default.put_new_line
154 end
155
156 feature -- Input
157
158 read_integer, readint is
159 -- Read a new integer from standard input.
160 -- Make result available in `last_integer'.
161 do
162 input.read_integer
163 end
164
165 read_real, readreal is
166 -- Read a new real from standard input.
167 -- Make result available in `last_real'.
168 do
169 input.read_real
170 end
171
172 read_double, readdouble is
173 -- Read a new double from standard input.
174 -- Make result available in `last_double'.
175 do
176 input.read_double
177 end
178
179 read_line, readline is
180 -- Read a line from standard input.
181 -- Make result available in `last_string'.
182 do
183 input.read_line
184 end
185
186 read_stream, readstream (nb_char: INTEGER) is
187 -- Read a string of at most `nb_char' bound characters
188 -- from standard input.
189 -- Make result available in `last_string'.
190 do
191 input.read_stream (nb_char)
192 end
193
194 read_word, readword is
195 -- Read a new word from standard input.
196 -- Make result available in `last_string'.
197 do
198 input.read_word
199 end
200
201 read_character, readchar is
202 -- Read a new character from standard input.
203 -- It will not return until read operation is
204 -- terminated when enter key is pressed.
205 -- Make result available in `last_character'.
206 -- `last_character' will also contains platform
207 -- specific newline character.
208 do
209 input.read_character
210 end
211
212 to_next_line, next_line is
213 -- Move to next input line on standard input.
214 do
215 input.next_line
216 end
217
218 indexing
219
220 library: "[
221 EiffelBase: Library of reusable components for Eiffel.
222 ]"
223
224 status: "[
225 Copyright 1986-2001 Interactive Software Engineering (ISE).
226 For ISE customers the original versions are an ISE product
227 covered by the ISE Eiffel license and support agreements.
228 ]"
229
230 license: "[
231 EiffelBase may now be used by anyone as FREE SOFTWARE to
232 develop any product, public-domain or commercial, without
233 payment to ISE, under the terms of the ISE Free Eiffel Library
234 License (IFELL) at http://eiffel.com/products/base/license.html.
235 ]"
236
237 source: "[
238 Interactive Software Engineering Inc.
239 ISE Building
240 360 Storke Road, Goleta, CA 93117 USA
241 Telephone 805-685-1006, Fax 805-685-6869
242 Electronic mail <info@eiffel.com>
243 Customer support http://support.eiffel.com
244 ]"
245
246 info: "[
247 For latest info see award-winning pages: http://eiffel.com
248 ]"
249
250 end -- class STD_FILES
251
252

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23