EiffelBase class
(HTML page generated by ISE Eiffel 4.2)
Eiffel Class
indexing
description: "Files viewed as persistent sequences of ASCII characters";
status: "See notice at end of class";
date: "$Date: 2007-03-30 11:10:11 -0800 (Fri, 30 Mar 2007) $";
revision: "$Revision: 95354 $"
class PLAIN_TEXT_FILE
inherit
FILE
rename
index as position
redefine
is_plain_text
end
creation
make,
make_open_read,
make_open_write,
make_open_append,
make_open_read_write,
make_create_read_write,
make_open_read_append
feature -- Status report
is_plain_text: BOOLEAN is
-- Is file reserved for text (character sequences)? (Yes)
do
Result := true
end;
Support_storable: BOOLEAN is false;
-- Can medium be used to store an Eiffel structure?
feature -- Output
put_integer (i: INTEGER) is
-- Write ASCII value of i at current position.
-- Was declared in PLAIN_TEXT_FILE as synonym of put_integer and putint.
do
file_pi (file_pointer, i)
end;
putint (i: INTEGER) is
-- Write ASCII value of i at current position.
-- Was declared in PLAIN_TEXT_FILE as synonym of put_integer and putint.
do
file_pi (file_pointer, i)
end;
put_boolean (b: BOOLEAN) is
-- Write ASCII value of b at current position.
-- Was declared in PLAIN_TEXT_FILE as synonym of put_boolean and putbool.
local
ext_bool_str: ANY
do
if b then
ext_bool_str := true_string.to_c;
file_ps (file_pointer, $ext_bool_str, true_string.count)
else
ext_bool_str := false_string.to_c;
file_ps (file_pointer, $ext_bool_str, false_string.count)
end
end;
putbool (b: BOOLEAN) is
-- Write ASCII value of b at current position.
-- Was declared in PLAIN_TEXT_FILE as synonym of put_boolean and putbool.
local
ext_bool_str: ANY
do
if b then
ext_bool_str := true_string.to_c;
file_ps (file_pointer, $ext_bool_str, true_string.count)
else
ext_bool_str := false_string.to_c;
file_ps (file_pointer, $ext_bool_str, false_string.count)
end
end;
put_real (r: REAL) is
-- Write ASCII value of r at current position.
-- Was declared in PLAIN_TEXT_FILE as synonym of put_real and putreal.
do
file_pr (file_pointer, r)
end;
putreal (r: REAL) is
-- Write ASCII value of r at current position.
-- Was declared in PLAIN_TEXT_FILE as synonym of put_real and putreal.
do
file_pr (file_pointer, r)
end;
put_double (d: DOUBLE) is
-- Write ASCII value d at current position.
-- Was declared in PLAIN_TEXT_FILE as synonym of put_double and putdouble.
do
file_pd (file_pointer, d)
end;
putdouble (d: DOUBLE) is
-- Write ASCII value d at current position.
-- Was declared in PLAIN_TEXT_FILE as synonym of put_double and putdouble.
do
file_pd (file_pointer, d)
end;
feature -- Input
read_integer is
-- Read the ASCII representation of a new integer
-- from file. Make result available in last_integer.
-- Was declared in PLAIN_TEXT_FILE as synonym of read_integer and readint.
do
last_integer := file_gi (file_pointer)
end;
readint is
-- Read the ASCII representation of a new integer
-- from file. Make result available in last_integer.
-- Was declared in PLAIN_TEXT_FILE as synonym of read_integer and readint.
do
last_integer := file_gi (file_pointer)
end;
read_real is
-- Read the ASCII representation of a new real
-- from file. Make result available in last_real.
-- Was declared in PLAIN_TEXT_FILE as synonym of read_real and readreal.
do
last_real := file_gr (file_pointer)
end;
readreal is
-- Read the ASCII representation of a new real
-- from file. Make result available in last_real.
-- Was declared in PLAIN_TEXT_FILE as synonym of read_real and readreal.
do
last_real := file_gr (file_pointer)
end;
read_double is
-- Read the ASCII representation of a new double
-- from file. Make result available in last_double.
-- Was declared in PLAIN_TEXT_FILE as synonym of read_double and readdouble.
do
last_double := file_gd (file_pointer)
end;
readdouble is
-- Read the ASCII representation of a new double
-- from file. Make result available in last_double.
-- Was declared in PLAIN_TEXT_FILE as synonym of read_double and readdouble.
do
last_double := file_gd (file_pointer)
end;
feature {NONE} -- Implementation
file_gi (file: POINTER): INTEGER is
-- Get an integer from file
external
"C (FILE *): EIF_INTEGER | %"eif_file.h%""
end;
file_gr (file: POINTER): REAL is
-- Read a real from file
external
"C (FILE *): EIF_REAL | %"eif_file.h%""
end;
file_gd (file: POINTER): DOUBLE is
-- Read a double from file
external
"C (FILE *): EIF_DOUBLE | %"eif_file.h%""
end;
file_pi (file: POINTER; n: INTEGER) is
-- Put n to end of file.
external
"C (FILE *, EIF_INTEGER) | %"eif_file.h%""
end;
file_pr (file: POINTER; r: REAL) is
-- Put r to end of file.
external
"C (FILE *, EIF_REAL) | %"eif_file.h%""
end;
file_pd (file: POINTER; d: DOUBLE) is
-- Put d to end of file.
external
"C (FILE *, EIF_DOUBLE) | %"eif_file.h%""
end;
invariant
plain_text: is_plain_text;
end -- class PLAIN_TEXT_FILE
|