indexing
	description: "Implementation of the STORABLE mechanism with streams."
	date: "$Date$"
	revision: "$Revision$"

class interface
	STREAM

create

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

	make_with_size (n: INTEGER)
			-- Create stream object with a default_size of n bytes

feature -- Initialization

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

	make_with_size (n: INTEGER)
			-- Create stream object with a default_size of n 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.

	object_stored_size: INTEGER
			-- Size of last stored object.

	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 is True
			-- Stream exists in any cases.

	extendible: BOOLEAN
			-- May new items be added?

	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 True
			-- Stream opens for input.

	Is_open_write: BOOLEAN is True
			-- Stream opens for output.

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

	Is_readable: BOOLEAN is True

	Is_writable: BOOLEAN is True
			-- Stream is writable.

	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 True
			-- 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

	set_additional_size (new_size: INTEGER)
			-- Set new_size to BUFFER_SIZE, internal value used to
			-- increment buffer_size during storable operations.

feature -- Removal

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

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

	read_character
			-- Read a new character.
			-- Make result available in last_character.
			-- Was declared in STREAM as synonym of 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 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 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 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 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 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.
		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.
		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.
		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.
		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.
		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.
		require -- from IO_MEDIUM
			is_readable: readable

feature -- Output

	new_line
			-- Write a new line character to medium
			-- Was declared in STREAM as synonym of put_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 putbool.
		require -- from IO_MEDIUM
			extendible: extendible

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

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

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

	put_new_line
			-- Write a new line character to medium
			-- Was declared in STREAM as synonym of 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 putreal.
		require -- from IO_MEDIUM
			extendible: extendible

	put_string (s: STRING)
			-- Write s to medium.
			-- Was declared in STREAM as synonym of 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.
		require -- from IO_MEDIUM
			extendible: extendible

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

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

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

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

	putstring (s: STRING)
			-- Write s to medium.
			-- Was declared in STREAM 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)

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 STREAM