indexing
	description: "[
		Commonly used console input and output mechanisms. 
		This class may be used as ancestor by classes needing its facilities.
	]"
	status: "See notice at end of class"
	date: "$Date$"
	revision: "$Revision$"

class interface
	CONSOLE

create

feature -- Initialization

	make_open_stderr (fn: STRING)
			-- Create an unix standard error file.

	make_open_stdin (fn: STRING)
			-- Create an unix standard input file.
		require -- from FILE
			string_exists: fn /= void
			string_not_empty: not fn.is_empty
		ensure -- from FILE
			exists: exists
			open_read: is_open_read

	make_open_stdout (fn: STRING)
			-- Create an unix standard output file.
		require -- from FILE
			string_exists: fn /= void
			string_not_empty: not fn.is_empty
		ensure -- from FILE
			exists: exists
			open_write: is_open_write
	
feature  -- Access

	file_pointer: POINTER
			-- File pointer as required in C
			-- (from FILE)

	separator: CHARACTER
			-- ASCII code of character following last word read
			-- (from FILE)
	
feature -- Status report

	end_of_file: BOOLEAN
			-- Have we reached the end of file?
		require -- from FILE
			opened: not is_closed

	exists: BOOLEAN
			-- Does file exist?
		ensure then -- from FILE
			unchanged_mode: mode = old mode
	
feature  -- Status report

	file_readable: BOOLEAN
			-- Is there a current item that may be read?
			-- (from FILE)

	last_character: CHARACTER
			-- Last character read by read_character
			-- (from IO_MEDIUM)

	last_double: DOUBLE
			-- Last double read by read_double
			-- (from IO_MEDIUM)

	last_integer: INTEGER
			-- Last integer read by read_integer
			-- (from IO_MEDIUM)

	last_real: REAL
			-- Last real read by read_real
			-- (from IO_MEDIUM)

	last_string: STRING
			-- Last string read
			-- (from IO_MEDIUM)
	
feature  -- Element change

	append (f: like Current)
			-- Append a copy of the contents of f.
			-- (from FILE)
		require -- from SEQUENCE
			argument_not_void: s /= void
		require else -- from FILE
			target_is_closed: is_closed
			source_is_closed: f.is_closed
		ensure -- from SEQUENCE
			new_count: count >= old count
		ensure then -- from FILE
			new_count: count = old count + f.count
			files_closed: f.is_closed and is_closed
	
feature -- Removal

	dispose
			-- This is closed by the operating system at completion.
	
feature  -- Obsolete

	lastchar: CHARACTER
			-- Last character read by read_character
			-- (from IO_MEDIUM)

	lastdouble: DOUBLE
			-- Last double read by read_double
			-- (from IO_MEDIUM)

	lastint: INTEGER
			-- Last integer read by read_integer
			-- (from IO_MEDIUM)

	lastreal: REAL
			-- Last real read by read_real
			-- (from IO_MEDIUM)

	laststring: STRING
			-- Last string read
			-- (from IO_MEDIUM)
	
feature -- Input

	next_line
			-- Move to next input line on standard input.
		require -- from FILE
			is_readable: file_readable

	read_character
			-- Read a new character from standard input.
			-- Make result available in last_character.
			-- Was declared in CONSOLE as synonym of readchar.
		require -- from IO_MEDIUM
			is_readable: readable
		require else -- from FILE
			is_readable: file_readable

	read_double
			-- Read a new double from standard input.
			-- Make result available in last_double.
			-- Was declared in CONSOLE as synonym of readdouble.
		require -- from IO_MEDIUM
			is_readable: readable
		require else -- from FILE
			is_readable: file_readable

	read_integer
			-- Read a new integer from standard input.
			-- Make result available in last_integer.
			-- Was declared in CONSOLE as synonym of readint.
		require -- from IO_MEDIUM
			is_readable: readable
		require else -- from FILE
			is_readable: file_readable

	read_line
			-- Read a string until new line or end of file.
			-- Make result available in last_string.
			-- New line will be consumed but not part of last_string.
			-- Was declared in CONSOLE as synonym of readline.
		require -- from IO_MEDIUM
			is_readable: readable
		require else -- from FILE
			is_readable: file_readable
		require else
			is_readable: file_readable

	read_real
			-- Read a new real from standard input.
			-- Make result available in last_real.
			-- Was declared in CONSOLE as synonym of readreal.
		require -- from IO_MEDIUM
			is_readable: readable
		require else -- from FILE
			is_readable: file_readable

	read_stream (nb_char: INTEGER)
			-- Read a string of at most nb_char bound characters
			-- from standard input.
			-- Make result available in last_string.
			-- Was declared in CONSOLE as synonym of readstream.
		require -- from IO_MEDIUM
			is_readable: readable
		require else -- from FILE
			is_readable: file_readable

	read_word
			-- Read a new word from standard input.
			-- Make result available in last_string.
			-- Was declared in CONSOLE as synonym of readword.
		require -- from FILE
			is_readable: file_readable

	readchar
			-- Read a new character from standard input.
			-- Make result available in last_character.
			-- Was declared in CONSOLE as synonym of read_character.
		require -- from IO_MEDIUM
			is_readable: readable
		require else -- from FILE
			is_readable: file_readable

	readdouble
			-- Read a new double from standard input.
			-- Make result available in last_double.
			-- Was declared in CONSOLE as synonym of read_double.
		require -- from IO_MEDIUM
			is_readable: readable
		require else -- from FILE
			is_readable: file_readable

	readint
			-- Read a new integer from standard input.
			-- Make result available in last_integer.
			-- Was declared in CONSOLE as synonym of read_integer.
		require -- from IO_MEDIUM
			is_readable: readable
		require else -- from FILE
			is_readable: file_readable

	readline
			-- Read a string until new line or end of file.
			-- Make result available in last_string.
			-- New line will be consumed but not part of last_string.
			-- Was declared in CONSOLE as synonym of read_line.
		require -- from IO_MEDIUM
			is_readable: readable
		require else -- from FILE
			is_readable: file_readable
		require else
			is_readable: file_readable

	readreal
			-- Read a new real from standard input.
			-- Make result available in last_real.
			-- Was declared in CONSOLE as synonym of read_real.
		require -- from IO_MEDIUM
			is_readable: readable
		require else -- from FILE
			is_readable: file_readable

	readstream (nb_char: INTEGER)
			-- Read a string of at most nb_char bound characters
			-- from standard input.
			-- Make result available in last_string.
			-- Was declared in CONSOLE as synonym of read_stream.
		require -- from IO_MEDIUM
			is_readable: readable
		require else -- from FILE
			is_readable: file_readable

	readword
			-- Read a new word from standard input.
			-- Make result available in last_string.
			-- Was declared in CONSOLE as synonym of read_word.
		require -- from FILE
			is_readable: file_readable
	
feature -- Output

	new_line
			-- Write line feed at end of default output.
			-- Was declared in CONSOLE as synonym of put_new_line.
		require -- from IO_MEDIUM
			extendible: extendible

	put_boolean (b: BOOLEAN)
			-- Write b at end of default output.
			-- Was declared in CONSOLE as synonym of putbool.
		require -- from IO_MEDIUM
			extendible: extendible

	put_character (c: CHARACTER)
			-- Write c at end of default output.
			-- Was declared in CONSOLE as synonym of putchar.
		require -- from IO_MEDIUM
			extendible: extendible

	put_double (d: DOUBLE)
			-- Write d at end of default output.
			-- Was declared in CONSOLE as synonym of putdouble.
		require -- from IO_MEDIUM
			extendible: extendible

	put_integer (i: INTEGER)
			-- Write i at end of default output.
			-- Was declared in CONSOLE as synonym of putint.
		require -- from IO_MEDIUM
			extendible: extendible

	put_new_line
			-- Write line feed at end of default output.
			-- Was declared in CONSOLE as synonym of new_line.
		require -- from IO_MEDIUM
			extendible: extendible

	put_real (r: REAL)
			-- Write r at end of default output.
			-- Was declared in CONSOLE as synonym of putreal.
		require -- from IO_MEDIUM
			extendible: extendible

	put_string (s: STRING)
			-- Write s at end of default output.
			-- Was declared in CONSOLE as synonym of putstring.
		require -- from IO_MEDIUM
			extendible: extendible
			non_void: s /= void

	putbool (b: BOOLEAN)
			-- Write b at end of default output.
			-- Was declared in CONSOLE as synonym of put_boolean.
		require -- from IO_MEDIUM
			extendible: extendible

	putchar (c: CHARACTER)
			-- Write c at end of default output.
			-- Was declared in CONSOLE as synonym of put_character.
		require -- from IO_MEDIUM
			extendible: extendible

	putdouble (d: DOUBLE)
			-- Write d at end of default output.
			-- Was declared in CONSOLE as synonym of put_double.
		require -- from IO_MEDIUM
			extendible: extendible

	putint (i: INTEGER)
			-- Write i at end of default output.
			-- Was declared in CONSOLE as synonym of put_integer.
		require -- from IO_MEDIUM
			extendible: extendible

	putreal (r: REAL)
			-- Write r at end of default output.
			-- Was declared in CONSOLE as synonym of put_real.
		require -- from IO_MEDIUM
			extendible: extendible

	putstring (s: STRING)
			-- Write s at end of default output.
			-- Was declared in CONSOLE as synonym of put_string.
		require -- from IO_MEDIUM
			extendible: extendible
			non_void: s /= void
	
invariant

		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)
		-- from PLAIN_TEXT_FILE
	plain_text: is_plain_text
		-- from FILE
	valid_mode: closed_file <= mode and mode <= append_read_file
	name_exists: name /= void
	name_not_empty: not name.is_empty
		-- from FINITE
	empty_definition: is_empty = (count = 0)
	non_negative_count: count >= 0
		-- from ACTIVE
	writable_constraint: writable implies readable
	empty_constraint: is_empty implies (not readable) and (not writable)
		-- from BILINEAR
	not_both: not (after and before)
	before_constraint: before implies off
		-- from LINEAR
	after_constraint: after implies off
		-- from TRAVERSABLE
	empty_constraint: is_empty implies off

indexing
	library: "[
			EiffelBase: Library of reusable components for Eiffel.
	]"
	status: "[
			Copyright 1986-2001 Interactive Software Engineering (ISE).
			For ISE customers the original versions are an ISE product
			covered by the ISE Eiffel license and support agreements.
	]"
	license: "[
			EiffelBase may now be used by anyone as FREE SOFTWARE to
			develop any product, public-domain or commercial, without
			payment to ISE, under the terms of the ISE Free Eiffel Library
			License (IFELL) at http://eiffel.com/products/base/license.html.
	]"
	source: "[
			Interactive Software Engineering Inc.
			ISE Building
			360 Storke Road, Goleta, CA 93117 USA
			Telephone 805-685-1006, Fax 805-685-6869
			Electronic mail <info@eiffel.com>
			Customer support http://support.eiffel.com
	]"
	info: "[
			For latest info see award-winning pages: http://eiffel.com
	]"

end -- class CONSOLE