indexing
	description: "Implementation of the STORABLE mechanism with streams."

class interface
	STREAM

create 

	make_stream
			-- Create stream object with a default_size of 100 bytes

feature -- Initialization

	make_stream
			-- Create stream object with a default_size of 100 bytes
	
feature -- Access

	buffer: POINTER
			-- C buffer correspond to the Eiffel STREAM.

	buffer_size: INTEGER
			-- Buffer's size.

	create_c_buffer
			-- Create the C memory corresponding to the C
			-- buffer.

	name: STRING

	retrieved: ANY
			-- Retrieved object structure
			-- To access resulting object under correct type,
			-- use assignment attempt.
			-- Will raise an exception (code Retrieve_exception)
			-- if content is not a stored Eiffel structure.
		require -- from IO_MEDIUM
			exists: exists;
			is_open_read: is_open_read;
			support_storable: support_storable
		ensure -- from IO_MEDIUM
			result_exists: Result /= void
	
feature -- Status report

	exists: BOOLEAN
			-- Does stream exist?

	extendible: BOOLEAN
			-- May new items be added?

	handle: INTEGER
			-- Handle to medium
		require -- from IO_MEDIUM
			valid_handle: handle_available

	handle_available: BOOLEAN
			-- Is the handle available after class has been
			-- created?

	is_closed: BOOLEAN
			-- Is the I/O medium open

	is_executable: BOOLEAN
			-- Is stream executable?
		require -- from IO_MEDIUM
			handle_exists: exists

	is_open_read: BOOLEAN
			-- Is stream opened for input

	is_open_write: BOOLEAN
			-- Is this stream opened for output

	is_plain_text: BOOLEAN
			-- Is file reserved for text (character sequences)?
			-- (from IO_MEDIUM)

	is_readable: BOOLEAN
			-- Is stream a readable?
		require -- from IO_MEDIUM
			handle_exists: exists

	is_writable: BOOLEAN
			-- Is stream writable?
		require -- from IO_MEDIUM
			handle_exists: exists

	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)

	readable: BOOLEAN
			-- Is there a current item that may be read?
		require -- from IO_MEDIUM
			handle_exists: exists

	Support_storable: BOOLEAN is false
			-- Can medium be used to store an Eiffel structure?
	
feature -- Status setting

	close
			-- Close medium.
		require -- from IO_MEDIUM
			medium_is_open: not is_closed
	
feature -- Element change

	basic_store (object: ANY)
			-- Produce an external representation of the
			-- entire object structure reachable from object.
			-- Retrievable within current system only.
		require -- from IO_MEDIUM
			object_not_void: object /= void;
			exists: exists;
			is_open_write: is_open_write;
			support_storable: support_storable

	general_store (object: ANY)
			-- Produce an external representation of the
			-- entire object structure reachable from object.
			-- Retrievable from other systems for same platform
			-- (machine architecture).
		require -- from IO_MEDIUM
			object_not_void: object /= void;
			exists: exists;
			is_open_write: is_open_write;
			support_storable: support_storable

	independent_store (object: ANY)
			-- Produce an external representation of the
			-- entire object structure reachable from object.
			-- Retrievable from other systems for the same or other
			-- platform (machine architecture).
		require -- from IO_MEDIUM
			object_not_void: object /= void;
			exists: exists;
			is_open_write: is_open_write;
			support_storable: support_storable
	
feature -- Removal

	dispose
			-- Ensure this medium is closed when garbage collected.
			-- (from IO_MEDIUM)
	
feature -- Output

	new_line
			-- Write a new line character to medium
			-- Was declared in STREAM as synonym of put_new_line and new_line.
		require -- from IO_MEDIUM
			extendible: extendible
		require else
			stream_exists: exists

	put_boolean (b: BOOLEAN)
			-- Write b to medium.
			-- Was declared in STREAM as synonym of put_boolean and putbool.
		require -- from IO_MEDIUM
			extendible: extendible

	put_character (c: CHARACTER)
			-- Write c to medium.
			-- Was declared in STREAM as synonym of put_character and putchar.
		require -- from IO_MEDIUM
			extendible: extendible

	put_double (d: DOUBLE)
			-- Write d to medium.
			-- Was declared in STREAM as synonym of put_double and putdouble.
		require -- from IO_MEDIUM
			extendible: extendible

	put_integer (i: INTEGER)
			-- Write i to medium.
			-- Was declared in STREAM as synonym of put_integer and putint.
		require -- from IO_MEDIUM
			extendible: extendible

	put_new_line
			-- Write a new line character to medium
			-- Was declared in STREAM as synonym of put_new_line and new_line.
		require -- from IO_MEDIUM
			extendible: extendible
		require else
			stream_exists: exists

	put_real (r: REAL)
			-- Write r to medium.
			-- Was declared in STREAM as synonym of put_real and putreal.
		require -- from IO_MEDIUM
			extendible: extendible

	put_string (s: STRING)
			-- Write s to medium.
			-- Was declared in STREAM as synonym of put_string and putstring.
		require -- from IO_MEDIUM
			extendible: extendible;
			non_void: s /= void

	putbool (b: BOOLEAN)
			-- Write b to medium.
			-- Was declared in STREAM as synonym of put_boolean and putbool.
		require -- from IO_MEDIUM
			extendible: extendible

	putchar (c: CHARACTER)
			-- Write c to medium.
			-- Was declared in STREAM as synonym of put_character and putchar.
		require -- from IO_MEDIUM
			extendible: extendible

	putdouble (d: DOUBLE)
			-- Write d to medium.
			-- Was declared in STREAM as synonym of put_double and putdouble.
		require -- from IO_MEDIUM
			extendible: extendible

	putint (i: INTEGER)
			-- Write i to medium.
			-- Was declared in STREAM as synonym of put_integer and putint.
		require -- from IO_MEDIUM
			extendible: extendible

	putreal (r: REAL)
			-- Write r to medium.
			-- Was declared in STREAM as synonym of put_real and putreal.
		require -- from IO_MEDIUM
			extendible: extendible

	putstring (s: STRING)
			-- Write s to medium.
			-- Was declared in STREAM as synonym of put_string and putstring.
		require -- from IO_MEDIUM
			extendible: extendible;
			non_void: s /= void
	
feature -- Input

	read_character
			-- Read a new character.
			-- Make result available in last_character.
			-- Was declared in STREAM as synonym of read_character and readchar.
		require -- from IO_MEDIUM
			is_readable: readable

	read_double
			-- Read a new double.
			-- Make result available in last_double.
			-- Was declared in STREAM as synonym of read_double and readdouble.
		require -- from IO_MEDIUM
			is_readable: readable

	read_integer
			-- Read a new integer.
			-- Make result available in last_integer.
			-- Was declared in STREAM as synonym of read_integer and readint.
		require -- from IO_MEDIUM
			is_readable: readable

	read_line
			-- Read characters until a new line or
			-- end of medium.
			-- Make result available in last_string.
			-- Was declared in STREAM as synonym of read_line and readline.
		require -- from IO_MEDIUM
			is_readable: readable

	read_real
			-- Read a new real.
			-- Make result available in last_real.
			-- Was declared in STREAM as synonym of read_real and readreal.
		require -- from IO_MEDIUM
			is_readable: readable

	read_stream (nb_char: INTEGER)
			-- Read a string of at most nb_char bound characters
			-- or until end of medium is encountered.
			-- Make result available in last_string.
			-- Was declared in STREAM as synonym of read_stream and readstream.
		require -- from IO_MEDIUM
			is_readable: readable

	readchar
			-- Read a new character.
			-- Make result available in last_character.
			-- Was declared in STREAM as synonym of read_character and readchar.
		require -- from IO_MEDIUM
			is_readable: readable

	readdouble
			-- Read a new double.
			-- Make result available in last_double.
			-- Was declared in STREAM as synonym of read_double and readdouble.
		require -- from IO_MEDIUM
			is_readable: readable

	readint
			-- Read a new integer.
			-- Make result available in last_integer.
			-- Was declared in STREAM as synonym of read_integer and readint.
		require -- from IO_MEDIUM
			is_readable: readable

	readline
			-- Read characters until a new line or
			-- end of medium.
			-- Make result available in last_string.
			-- Was declared in STREAM as synonym of read_line and readline.
		require -- from IO_MEDIUM
			is_readable: readable

	readreal
			-- Read a new real.
			-- Make result available in last_real.
			-- Was declared in STREAM as synonym of read_real and readreal.
		require -- from IO_MEDIUM
			is_readable: readable

	readstream (nb_char: INTEGER)
			-- Read a string of at most nb_char bound characters
			-- or until end of medium is encountered.
			-- Make result available in last_string.
			-- Was declared in STREAM as synonym of read_stream and readstream.
		require -- from IO_MEDIUM
			is_readable: readable
	
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)
	
invariant

	valid_mode: closed_stream <= mode and mode <= output_stream;
	name_exists: name /= void;
	name_not_empty: not name.empty;

end -- class STREAM