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

Contents of /FreeELKS/trunk/library/kernel/plain_text_file.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: 4082 byte(s)
Initial revision

1 indexing
2
3 description:
4 "Files viewed as persistent sequences of ASCII characters"
5
6 status: "See notice at end of class"
7 date: "$Date$"
8 revision: "$Revision$"
9
10 class PLAIN_TEXT_FILE
11
12 inherit
13 FILE
14 rename
15 index as position
16 redefine
17 is_plain_text
18 end
19
20 create
21
22 make, make_open_read, make_open_write, make_open_append,
23 make_open_read_write, make_create_read_write,
24 make_open_read_append
25
26 feature -- Status report
27
28 is_plain_text: BOOLEAN is
29 -- Is file reserved for text (character sequences)? (Yes)
30 do
31 Result := True
32 end
33
34 support_storable: BOOLEAN is False
35 -- Can medium be used to store an Eiffel structure?
36
37 feature -- Output
38
39 put_integer, putint (i: INTEGER) is
40 -- Write ASCII value of `i' at current position.
41 do
42 file_pi (file_pointer, i)
43 end
44
45 put_boolean, putbool (b: BOOLEAN) is
46 -- Write ASCII value of `b' at current position.
47 local
48 ext_bool_str: ANY
49 do
50 if b then
51 ext_bool_str := true_string.to_c
52 file_ps (file_pointer, $ext_bool_str, true_string.count)
53 else
54 ext_bool_str := false_string.to_c
55 file_ps (file_pointer, $ext_bool_str, false_string.count)
56 end
57 end
58
59 put_real, putreal (r: REAL) is
60 -- Write ASCII value of `r' at current position.
61 do
62 file_pr (file_pointer, r)
63 end
64
65 put_double, putdouble (d: DOUBLE) is
66 -- Write ASCII value `d' at current position.
67 do
68 file_pd (file_pointer, d)
69 end
70
71 feature -- Input
72
73 read_integer, readint is
74 -- Read the ASCII representation of a new integer
75 -- from file. Make result available in `last_integer'.
76 do
77 last_integer := file_gi (file_pointer)
78 end
79
80 read_real, readreal is
81 -- Read the ASCII representation of a new real
82 -- from file. Make result available in `last_real'.
83 do
84 last_real := file_gr (file_pointer)
85 end
86
87 read_double, readdouble is
88 -- Read the ASCII representation of a new double
89 -- from file. Make result available in `last_double'.
90 do
91 last_double := file_gd (file_pointer)
92 end
93
94 feature {NONE} -- Implementation
95
96 read_to_string (a_string: STRING; pos, nb: INTEGER): INTEGER is
97 -- Fill `a_string', starting at position `pos' with at
98 -- most `nb' characters read from current file.
99 -- Return the number of characters actually read.
100 do
101 Result := file_gss (file_pointer, a_string.area.item_address (pos - 1), nb)
102 end
103
104 file_gi (file: POINTER): INTEGER is
105 -- Get an integer from `file'
106 external
107 "C (FILE *): EIF_INTEGER | %"eif_file.h%""
108 end
109
110 file_gr (file: POINTER): REAL is
111 -- Read a real from `file'
112 external
113 "C (FILE *): EIF_REAL | %"eif_file.h%""
114 end
115
116 file_gd (file: POINTER): DOUBLE is
117 -- Read a double from `file'
118 external
119 "C (FILE *): EIF_DOUBLE | %"eif_file.h%""
120 end
121
122 file_pi (file: POINTER; n: INTEGER) is
123 -- Put `n' to end of `file'.
124 external
125 "C (FILE *, EIF_INTEGER) | %"eif_file.h%""
126 end
127
128 file_pr (file: POINTER; r: REAL) is
129 -- Put `r' to end of `file'.
130 external
131 "C (FILE *, EIF_REAL) | %"eif_file.h%""
132 end
133
134 file_pd (file: POINTER; d: DOUBLE) is
135 -- Put `d' to end of `file'.
136 external
137 "C (FILE *, EIF_DOUBLE) | %"eif_file.h%""
138 end
139
140 invariant
141
142 plain_text: is_plain_text
143
144 indexing
145
146 library: "[
147 EiffelBase: Library of reusable components for Eiffel.
148 ]"
149
150 status: "[
151 Copyright 1986-2001 Interactive Software Engineering (ISE).
152 For ISE customers the original versions are an ISE product
153 covered by the ISE Eiffel license and support agreements.
154 ]"
155
156 license: "[
157 EiffelBase may now be used by anyone as FREE SOFTWARE to
158 develop any product, public-domain or commercial, without
159 payment to ISE, under the terms of the ISE Free Eiffel Library
160 License (IFELL) at http://eiffel.com/products/base/license.html.
161 ]"
162
163 source: "[
164 Interactive Software Engineering Inc.
165 ISE Building
166 360 Storke Road, Goleta, CA 93117 USA
167 Telephone 805-685-1006, Fax 805-685-6869
168 Electronic mail <info@eiffel.com>
169 Customer support http://support.eiffel.com
170 ]"
171
172 info: "[
173 For latest info see award-winning pages: http://eiffel.com
174 ]"
175
176 end -- class PLAIN_TEXT_FILE
177
178
179

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23