note
	description: "Implementation of the STORABLE mechanism with streams."
	library: "Free implementation of ELKS library"
	status: "See notice at end of class."
	legal: "See notice at end of class."
	date: "$Date: 2020-05-19 14:29:33 +0000 (Tue, 19 May 2020) $"
	revision: "$Revision: 104259 $"

class 
	STREAM

create 
	make,
	make_with_size

feature -- Initialization

	make
			-- Create stream object with a default_size of 100 bytes
		do
			make_with_size (200)
		end

	make_with_size (n: INTEGER_32)
			-- Create stream object with a default_size of n bytes
		do
			buffer_size := n
			create_c_buffer
			create last_string.make_empty
		end
	
feature {NONE} -- Initialization

	default_create
			-- Process instances of classes with no creation clause.
			-- (Default: do nothing.)
			-- (from ANY)
		do
		end
	
feature -- Access

	buffer: POINTER
		obsolete "Use `item' instead to directly access stored/retrieved data. [2017-05-31]"
			-- C buffer correspond to the Eiffel STREAM
		do
			Result := internal_buffer_access
		end

	buffer_size: INTEGER_32
			-- Buffer's size.

	create_c_buffer
			-- Create the C memory corresponding to the C buffer.
		do
			internal_buffer_access := c_malloc (buffer_size)
		end

	generating_type: TYPE [detachable STREAM]
			-- Type of current object
			-- (type of which it is a direct instance)
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			generating_type_not_void: Result /= Void
		end

	generator: STRING_8
			-- Name of current object's generating class
			-- (base class of the type of which it is a direct instance)
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			generator_not_void: Result /= Void
			generator_not_empty: not Result.is_empty
		end

	item: POINTER
			-- Direct access to stored/retrieved data
		do
			Result := c_buffer (internal_buffer_access)
		end

	object_stored_size: INTEGER_32
			-- 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
			is_readable: readable
			support_storable: Support_storable
		require else
				True
		local
			size: INTEGER_32
		do
			(create {MISMATCH_CORRECTOR}).Mismatch_information.do_nothing
			Result := c_retrieved (internal_buffer_access, buffer_size, 0, $size.to_pointer)
			object_stored_size := size
		end
	
feature -- Comparison

	frozen deep_equal (a: detachable ANY; b: like arg #1): BOOLEAN
			-- Are a and b either both void
			-- or attached to isomorphic object structures?
			-- (from ANY)
		do
			if a = Void then
				Result := b = Void
			else
				Result := b /= Void and then a.is_deep_equal (b)
			end
		ensure -- from ANY
			instance_free: class
			shallow_implies_deep: standard_equal (a, b) implies Result
			both_or_none_void: (a = Void) implies (Result = (b = Void))
			same_type: (Result and (a /= Void)) implies (b /= Void and then a.same_type (b))
			symmetric: Result implies deep_equal (b, a)
		end

	frozen equal (a: detachable ANY; b: like arg #1): BOOLEAN
			-- Are a and b either both void or attached
			-- to objects considered equal?
			-- (from ANY)
		do
			if a = Void then
				Result := b = Void
			else
				Result := b /= Void and then a.is_equal (b)
			end
		ensure -- from ANY
			instance_free: class
			definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.is_equal (b))
		end

	frozen is_deep_equal alias "≡≡≡" (other: STREAM): BOOLEAN
			-- Are Current and other attached to isomorphic object structures?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		external
			"built_in"
		ensure -- from ANY
			shallow_implies_deep: standard_is_equal (other) implies Result
			same_type: Result implies same_type (other)
			symmetric: Result implies other.is_deep_equal (Current)
		end

	is_equal (other: STREAM): BOOLEAN
			-- Is other attached to an object considered
			-- equal to current object?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		external
			"built_in"
		ensure -- from ANY
			symmetric: Result implies other ~ Current
			consistent: standard_is_equal (other) implies Result
		end

	frozen standard_equal (a: detachable ANY; b: like arg #1): BOOLEAN
			-- Are a and b either both void or attached to
			-- field-by-field identical objects of the same type?
			-- Always uses default object comparison criterion.
			-- (from ANY)
		do
			if a = Void then
				Result := b = Void
			else
				Result := b /= Void and then a.standard_is_equal (b)
			end
		ensure -- from ANY
			instance_free: class
			definition: Result = (a = Void and b = Void) or else ((a /= Void and b /= Void) and then a.standard_is_equal (b))
		end

	frozen standard_is_equal alias "" (other: STREAM): BOOLEAN
			-- Is other attached to an object of the same type
			-- as current object, and field-by-field identical to it?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		external
			"built_in"
		ensure -- from ANY
			same_type: Result implies same_type (other)
			symmetric: Result implies other.standard_is_equal (Current)
		end
	
feature -- Status report

	bytes_read: INTEGER_32
			-- Last number of bytes read by read_to_managed_pointer.
			-- (from IO_MEDIUM)

	conforms_to (other: ANY): BOOLEAN
			-- Does type of current object conform to type
			-- of other (as per Eiffel: The Language, chapter 13)?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		external
			"built_in"
		end

	Exists: BOOLEAN = True
			-- Stream exists in any cases.

	extendible: BOOLEAN
			-- May new items be added?
		do
			Result := True
		end

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

	is_executable: BOOLEAN
			-- Is stream executable?
		require -- from IO_MEDIUM
			handle_exists: Exists
		do
			Result := False
		end

	Is_open_read: BOOLEAN = True
			-- Stream opens for input.

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

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

	Is_readable: BOOLEAN = True
			-- Is medium readable?

	Is_writable: BOOLEAN = True
			-- Stream is writable.

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

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

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

	last_integer_16: INTEGER_16
			-- Last 16-bit integer read by read_integer_16
			-- (from IO_MEDIUM)

	last_integer_32: INTEGER_32
			-- Synonymy of last_integer
			-- (from IO_MEDIUM)
		do
			Result := last_integer
		end

	last_integer_64: INTEGER_64
			-- Last 64-bit integer read by read_integer_64
			-- (from IO_MEDIUM)

	last_integer_8: INTEGER_8
			-- Last 8-bit integer read by read_integer_8
			-- (from IO_MEDIUM)

	last_natural: NATURAL_32
			-- Last 32-bit natural read by read_natural
			-- (from IO_MEDIUM)

	last_natural_16: NATURAL_16
			-- Last 16-bit natural read by read_natural_16
			-- (from IO_MEDIUM)

	last_natural_32: NATURAL_32
			-- Synonymy of last_natural
			-- (from IO_MEDIUM)
		do
			Result := last_natural
		end

	last_natural_64: NATURAL_64
			-- Last 64-bit natural read by read_natural_64
			-- (from IO_MEDIUM)

	last_natural_8: NATURAL_8
			-- Last 8-bit natural read by read_natural_8
			-- (from IO_MEDIUM)

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

	last_real_32: REAL_32
			-- Last 32-bit real read by read_real_32.
			-- Synonym of last_real.
			-- (from IO_MEDIUM)
		do
			Result := last_real
		end

	last_real_64: REAL_64
			-- Last 64-bit real read by read_real_64.
			-- Synonym of last_double.
			-- (from IO_MEDIUM)
		do
			Result := last_double
		end

	last_string: STRING_8
			-- Last string read
			-- (from IO_MEDIUM)

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

	same_type (other: ANY): BOOLEAN
			-- Is type of current object identical to type of other?
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		external
			"built_in"
		ensure -- from ANY
			definition: Result = (conforms_to (other) and other.conforms_to (Current))
		end

	Support_storable: BOOLEAN = True
			-- Can medium be used to store an Eiffel structure?
	
feature {NONE} -- Status report

	is_in_final_collect: BOOLEAN
			-- Is GC currently performing final collection
			-- after execution of current program?
			-- Safe to use in dispose.
			-- (from DISPOSABLE)
		external
			"C inline use %"eif_memory.h%""
		alias
			"return eif_is_in_final_collect;"
		end
	
feature -- Status setting

	close
			-- Close medium.
		require -- from IO_MEDIUM
			medium_is_open: not is_closed
		do
			is_closed := True
			c_free (internal_buffer_access)
			internal_buffer_access := default_pointer
		end
	
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
			extendible: extendible
			support_storable: Support_storable
		local
			size: INTEGER_32
		do
			buffer_size := c_stream_basic_store (internal_buffer_access, buffer_size, $object.to_pointer, $size.to_pointer)
			object_stored_size := size
		end

	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
			extendible: extendible
			support_storable: Support_storable
		local
			size: INTEGER_32
		do
			buffer_size := c_stream_general_store (internal_buffer_access, buffer_size, $object.to_pointer, $size.to_pointer)
			object_stored_size := size
		end

	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
			extendible: extendible
			support_storable: Support_storable
		local
			size: INTEGER_32
		do
			buffer_size := c_stream_independent_store (internal_buffer_access, buffer_size, $object.to_pointer, $size.to_pointer)
			object_stored_size := size
		end

	set_additional_size (new_size: INTEGER_32)
			-- Set new_size to BUFFER_SIZE, internal value used to
			-- increment buffer_size during storable operations.
		external
			"C use %"eif_store.h%""
		alias
			"set_buffer_size"
		end
	
feature -- Removal

	dispose
			-- Ensure this medium is closed when garbage collected.
			-- (from IO_MEDIUM)
		do
			if not is_closed then
				close
			end
		end
	
feature -- Duplication

	frozen clone (other: detachable ANY): like other
		obsolete "Use `twin' instead. [2017-05-31]"
			-- Void if other is void; otherwise new object
			-- equal to other
			--
			-- For non-void other, clone calls copy;
			-- to change copying/cloning semantics, redefine copy.
			-- (from ANY)
		do
			if other /= Void then
				Result := other.twin
			end
		ensure -- from ANY
			instance_free: class
			equal: Result ~ other
		end

	copy (other: STREAM)
			-- Update current object using fields of object attached
			-- to other, so as to yield equal objects.
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
			type_identity: same_type (other)
		external
			"built_in"
		ensure -- from ANY
			is_equal: Current ~ other
		end

	frozen deep_clone (other: detachable ANY): like other
		obsolete "Use `deep_twin' instead. [2017-05-31]"
			-- Void if other is void: otherwise, new object structure
			-- recursively duplicated from the one attached to other
			-- (from ANY)
		do
			if other /= Void then
				Result := other.deep_twin
			end
		ensure -- from ANY
			instance_free: class
			deep_equal: deep_equal (other, Result)
		end

	frozen deep_copy (other: STREAM)
			-- Effect equivalent to that of:
			--		copy (other . deep_twin)
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
		do
			copy (other.deep_twin)
		ensure -- from ANY
			deep_equal: deep_equal (Current, other)
		end

	frozen deep_twin: STREAM
			-- New object structure recursively duplicated from Current.
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			deep_twin_not_void: Result /= Void
			deep_equal: deep_equal (Current, Result)
		end

	frozen standard_clone (other: detachable ANY): like other
		obsolete "Use `standard_twin' instead. [2017-05-31]"
			-- Void if other is void; otherwise new object
			-- field-by-field identical to other.
			-- Always uses default copying semantics.
			-- (from ANY)
		do
			if other /= Void then
				Result := other.standard_twin
			end
		ensure -- from ANY
			instance_free: class
			equal: standard_equal (Result, other)
		end

	frozen standard_copy (other: STREAM)
			-- Copy every field of other onto corresponding field
			-- of current object.
			-- (from ANY)
		require -- from ANY
			other_not_void: other /= Void
			type_identity: same_type (other)
		external
			"built_in"
		ensure -- from ANY
			is_standard_equal: standard_is_equal (other)
		end

	frozen standard_twin: STREAM
			-- New object field-by-field identical to other.
			-- Always uses default copying semantics.
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			standard_twin_not_void: Result /= Void
			equal: standard_equal (Result, Current)
		end

	frozen twin: STREAM
			-- New object equal to Current
			-- twin calls copy; to change copying/twinning semantics, redefine copy.
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			twin_not_void: Result /= Void
			is_equal: Result ~ Current
		end
	
feature -- Basic operations

	frozen as_attached: attached STREAM
		obsolete "Remove calls to this feature. [2017-05-31]"
			-- Attached version of Current.
			-- (Can be used during transitional period to convert
			-- non-void-safe classes to void-safe ones.)
			-- (from ANY)
		do
			Result := Current
		end

	frozen default: detachable STREAM
			-- Default value of object's type
			-- (from ANY)
		do
		end

	frozen default_pointer: POINTER
			-- Default value of type POINTER
			-- (Avoid the need to write p.default for
			-- some p of type POINTER.)
			-- (from ANY)
		do
		ensure -- from ANY
			instance_free: class
		end

	default_rescue
			-- Process exception for routines with no Rescue clause.
			-- (Default: do nothing.)
			-- (from ANY)
		do
		end

	frozen do_nothing
			-- Execute a null action.
			-- (from ANY)
		do
		ensure -- from ANY
			instance_free: class
		end
	
feature -- Obsolete

	lastchar: CHARACTER_8
			-- Last character read by read_character
			-- (from IO_MEDIUM)
		do
			Result := last_character
		end

	lastdouble: REAL_64
			-- Last double read by read_double
			-- (from IO_MEDIUM)
		do
			Result := last_double
		end

	lastint: INTEGER_32
			-- Last integer read by read_integer
			-- (from IO_MEDIUM)
		do
			Result := last_integer
		end

	lastreal: REAL_32
			-- Last real read by read_real
			-- (from IO_MEDIUM)
		do
			Result := last_real
		end

	laststring: like last_string
			-- Last string read
			-- (from IO_MEDIUM)
		do
			Result := last_string
		end
	
feature {NONE} -- Implementation

	c_buffer (a_buf: POINTER): POINTER
			-- Dereferenced pointer of a_buf
		require
			a_buf_not_null: a_buf /= default_pointer
		external
			"C inline"
		alias
			"return (*(EIF_POINTER *) $a_buf);"
		end

	c_free (buf: POINTER)
		external
			"C signature (EIF_POINTER *) use %"eif_store.h%""
		alias
			"stream_free"
		end

	c_malloc (size: INTEGER_32): POINTER
		external
			"C use %"eif_store.h%""
		alias
			"stream_malloc"
		end

	c_retrieved (stream_buffer: POINTER; stream_buffer_size: INTEGER_32; stream_buffer_position: INTEGER_32; c_real_size: POINTER): ANY
			-- Object structured retrieved from stream of pointer
			-- stream_ptr
		external
			"C signature (EIF_POINTER *, EIF_INTEGER, EIF_INTEGER, EIF_INTEGER *): EIF_REFERENCE use %"eif_retrieve.h%""
		alias
			"stream_eretrieve"
		end

	c_stream_basic_store (stream_buffer: POINTER; stream_buffer_size: INTEGER_32; object: POINTER; c_real_size: POINTER): INTEGER_32
			-- Store object structure reachable form current object
			-- Return new size of internal_buffer_access.
		external
			"C signature (EIF_POINTER *, EIF_INTEGER, EIF_REFERENCE, EIF_INTEGER *): EIF_INTEGER use %"eif_store.h%""
		alias
			"stream_estore"
		end

	c_stream_general_store (stream_buffer: POINTER; stream_buffer_size: INTEGER_32; object: POINTER; c_real_size: POINTER): INTEGER_32
			-- Store object structure reachable form current object
			-- Return new size of internal_buffer_access.
		external
			"C signature (EIF_POINTER *, EIF_INTEGER, EIF_REFERENCE, EIF_INTEGER *): EIF_INTEGER use %"eif_store.h%""
		alias
			"stream_eestore"
		end

	c_stream_independent_store (stream_buffer: POINTER; stream_buffer_size: INTEGER_32; object: POINTER; c_real_size: POINTER): INTEGER_32
			-- Store object structure reachable form current object
			-- Return new size of internal_buffer_access.
		external
			"C signature (EIF_POINTER *, EIF_INTEGER, EIF_REFERENCE, EIF_INTEGER *): EIF_INTEGER use %"eif_store.h%""
		alias
			"stream_sstore"
		end

	internal_buffer_access: POINTER
			-- Access to C buffer pointed by item.
	
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
		do
		end

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

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

	read_integer_16
			-- Read a new integer.
			-- Make result available in last_integer_16.
		require -- from IO_MEDIUM
			is_readable: readable
		do
		end

	read_integer_32
			-- 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
		do
		end

	read_integer_64
			-- Read a new integer.
			-- Make result available in last_integer_64.
		require -- from IO_MEDIUM
			is_readable: readable
		do
		end

	read_integer_8
			-- Read a new integer.
			-- Make result available in last_integer_8.
		require -- from IO_MEDIUM
			is_readable: readable
		do
		end

	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
		do
		ensure -- from IO_MEDIUM
			last_string_not_void: last_string /= Void
		end

	read_line_thread_aware
			-- Read characters until a new line or
			-- end of medium.
			-- Make result available in last_string.
			-- Functionally identical to read_line but
			-- won't prevent garbage collection from occurring
			-- while blocked waiting for data, though data must
			-- be copied an extra time.			
			-- (from IO_MEDIUM)
		require -- from IO_MEDIUM
			is_readable: readable
		do
			read_line
		ensure -- from IO_MEDIUM
			last_string_not_void: last_string /= Void
		end

	read_natural
			-- Read a new natural.
			-- Make result available in last_natural.
			-- Was declared in STREAM as synonym of read_natural_32.
		require -- from IO_MEDIUM
			is_readable: readable
		do
		end

	read_natural_16
			-- Read a new natural.
			-- Make result available in last_natural_16.
		require -- from IO_MEDIUM
			is_readable: readable
		do
		end

	read_natural_32
			-- Read a new natural.
			-- Make result available in last_natural.
			-- Was declared in STREAM as synonym of read_natural.
		require -- from IO_MEDIUM
			is_readable: readable
		do
		end

	read_natural_64
			-- Read a new natural.
			-- Make result available in last_natural_64.
		require -- from IO_MEDIUM
			is_readable: readable
		do
		end

	read_natural_8
			-- Read a new natural.
			-- Make result available in last_natural_8.
		require -- from IO_MEDIUM
			is_readable: readable
		do
		end

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

	read_real_32
			-- 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
		do
		end

	read_real_64
			-- 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
		do
		end

	read_stream (nb_char: INTEGER_32)
			-- 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
		do
		ensure -- from IO_MEDIUM
			last_string_not_void: last_string /= Void
		end

	read_stream_thread_aware (nb_char: INTEGER_32)
			-- Read a string of at most nb_char bound characters
			-- or until end of medium is encountered.
			-- Make result available in last_string.
			-- Functionally identical to read_stream but
			-- won't prevent garbage collection from occurring
			-- while blocked waiting for data, though data must
			-- be copied an extra time.			
			-- (from IO_MEDIUM)
		require -- from IO_MEDIUM
			is_readable: readable
		do
			read_stream (nb_char)
		ensure -- from IO_MEDIUM
			last_string_not_void: last_string /= Void
		end

	read_to_managed_pointer (p: MANAGED_POINTER; start_pos, nb_bytes: INTEGER_32)
			-- Read at most nb_bytes bound bytes and make result
			-- available in p at position start_pos.
		require -- from IO_MEDIUM
			p_not_void: p /= Void
			p_large_enough: p.count >= nb_bytes + start_pos
			nb_bytes_non_negative: nb_bytes >= 0
			is_readable: readable
		do
		ensure -- from IO_MEDIUM
			bytes_read_non_negative: bytes_read >= 0
			bytes_read_not_too_big: bytes_read <= nb_bytes
		end

	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
		do
		end

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

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

	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
		do
		ensure -- from IO_MEDIUM
			last_string_not_void: last_string /= Void
		end

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

	readstream (nb_char: INTEGER_32)
			-- 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
		do
		ensure -- from IO_MEDIUM
			last_string_not_void: last_string /= Void
		end
	
feature -- Not exported

	handle: INTEGER_32
			-- Handle to medium
		require -- from IO_MEDIUM
			valid_handle: handle_available
		do
		end

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

	name: detachable STRING_8
			-- Not meaningful
		do
		end
	
feature -- Output

	Io: STD_FILES
			-- Handle to standard file setup
			-- (from ANY)
		once
			create Result;
			Result.set_output_default
		ensure -- from ANY
			instance_free: class
			io_not_void: Result /= Void
		end

	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
		do
			put_character ('%N')
		end

	out: STRING_8
			-- New string containing terse printable representation
			-- of current object
			-- (from ANY)
		do
			Result := tagged_out
		ensure -- from ANY
			out_not_void: Result /= Void
		end

	print (o: detachable ANY)
			-- Write terse external representation of o
			-- on standard output.
			-- (from ANY)
		local
			s: READABLE_STRING_8
		do
			if attached o then
				s := o.out
				if attached {READABLE_STRING_32} s as s32 then
					Io.put_string_32 (s32)
				elseif attached {READABLE_STRING_8} s as s8 then
					Io.put_string (s8)
				else
					Io.put_string_32 (s.as_string_32)
				end
			end
		ensure -- from ANY
			instance_free: class
		end

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

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

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

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

	put_integer_16 (i: INTEGER_16)
			-- Write i to medium.
		require -- from IO_MEDIUM
			extendible: extendible
		do
		end

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

	put_integer_64 (i: INTEGER_64)
			-- Write i to medium.
		require -- from IO_MEDIUM
			extendible: extendible
		do
		end

	put_integer_8 (i: INTEGER_8)
			-- Write i to medium.
		require -- from IO_MEDIUM
			extendible: extendible
		do
		end

	put_managed_pointer (p: MANAGED_POINTER; start_pos, nb_bytes: INTEGER_32)
			-- Put data of length nb_bytes pointed by start_pos index in p at
			-- current position.
		require -- from IO_MEDIUM
			p_not_void: p /= Void
			p_large_enough: p.count >= nb_bytes + start_pos
			nb_bytes_non_negative: nb_bytes >= 0
			extendible: extendible
		do
		end

	put_natural (i: NATURAL_32)
			-- Write i to medium.
			-- Was declared in STREAM as synonym of put_natural_32.
		require -- from IO_MEDIUM
			extendible: extendible
		do
		end

	put_natural_16 (i: NATURAL_16)
			-- Write i to medium.
		require -- from IO_MEDIUM
			extendible: extendible
		do
		end

	put_natural_32 (i: NATURAL_32)
			-- Write i to medium.
			-- Was declared in STREAM as synonym of put_natural.
		require -- from IO_MEDIUM
			extendible: extendible
		do
		end

	put_natural_64 (i: NATURAL_64)
			-- Write i to medium.
		require -- from IO_MEDIUM
			extendible: extendible
		do
		end

	put_natural_8 (i: NATURAL_8)
			-- Write i to medium.
		require -- from IO_MEDIUM
			extendible: extendible
		do
		end

	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
		do
			put_character ('%N')
		end

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

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

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

	put_string (s: READABLE_STRING_8)
			-- Write s to medium.
			-- Was declared in STREAM as synonym of putstring.
		require -- from IO_MEDIUM
			extendible: extendible
			non_void: s /= Void
		do
		end

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

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

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

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

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

	putstring (s: READABLE_STRING_8)
			-- Write s to medium.
			-- Was declared in STREAM as synonym of put_string.
		require -- from IO_MEDIUM
			extendible: extendible
			non_void: s /= Void
		do
		end

	frozen tagged_out: STRING_8
			-- New string containing terse printable representation
			-- of current object
			-- (from ANY)
		external
			"built_in"
		ensure -- from ANY
			tagged_out_not_void: Result /= Void
		end
	
feature -- Platform

	Operating_environment: OPERATING_ENVIRONMENT
			-- Objects available from the operating system
			-- (from ANY)
		once
			create Result
		ensure -- from ANY
			instance_free: class
			operating_environment_not_void: Result /= Void
		end
	
feature {NONE} -- Retrieval

	frozen internal_correct_mismatch
			-- Called from runtime to perform a proper dynamic dispatch on correct_mismatch
			-- from MISMATCH_CORRECTOR.
			-- (from ANY)
		local
			l_msg: STRING_32
			l_exc: EXCEPTIONS
		do
			if attached {MISMATCH_CORRECTOR} Current as l_corrector then
				l_corrector.correct_mismatch
			else
				create l_msg.make_from_string ("Mismatch: ".as_string_32)
				create l_exc;
				l_msg.append (generating_type.name_32);
				l_exc.raise_retrieval_exception (l_msg)
			end
		end
	
invariant
		-- from ANY
	reflexive_equality: standard_is_equal (Current)
	reflexive_conformance: conforms_to (Current)

note
	copyright: "Copyright (c) 1984-2020, Eiffel Software and others"
	license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
	source: "[
		Eiffel Software
		5949 Hollister Ave., Goleta, CA 93117 USA
		Telephone 805-685-1006, Fax 805-685-6869
		Website http://www.eiffel.com
		Customer support http://support.eiffel.com
	]"

end -- class STREAM

Generated by ISE EiffelStudio