note description: "[ Commonly used input and output mechanisms. This class may be used as either ancestor or supplier by classes needing its facilities. ]" 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 STD_FILES create default_create feature {NONE} -- Initialization default_create -- Process instances of classes with no creation clause. -- (Default: do nothing.) -- (from ANY) do end feature -- Access default_output: detachable PLAIN_TEXT_FILE -- Default output Error: PLAIN_TEXT_FILE -- Standard error file once create {CONSOLE} Result.make_open_stderr ("stderr") ensure instance_free: class error_not_void: Result /= Void end generating_type: TYPE [detachable STD_FILES] -- 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 Input: PLAIN_TEXT_FILE -- Standard input file once create {CONSOLE} Result.make_open_stdin ("stdin") ensure instance_free: class input_not_void: Result /= Void end Output: PLAIN_TEXT_FILE -- Standard output file once create {CONSOLE} Result.make_open_stdout ("stdout") ensure instance_free: class output_not_void: Result /= Void end standard_default: PLAIN_TEXT_FILE -- Return the default_output or Output -- if default_output is Void. do Result := default_output if Result = Void then Result := Output end 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: STD_FILES): 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: STD_FILES): 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: STD_FILES): 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 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 last_character: CHARACTER_8 -- Last character read by read_character -- Was declared in STD_FILES as synonym of lastchar. do Result := Input.last_character ensure instance_free: class end last_double: REAL_64 -- Last double read by read_double. -- Was declared in STD_FILES as synonym of lastdouble and last_real_64. do Result := Input.last_double ensure instance_free: class end last_integer: INTEGER_32 -- Last integer read by read_integer -- Was declared in STD_FILES as synonym of lastint and last_integer_32. do Result := Input.last_integer ensure instance_free: class end last_integer_16: INTEGER_16 -- Last 16-bit integer read by read_integer_16 do Result := Input.last_integer_16 ensure instance_free: class end last_integer_32: INTEGER_32 -- Last integer read by read_integer -- Was declared in STD_FILES as synonym of last_integer and lastint. do Result := Input.last_integer ensure instance_free: class end last_integer_64: INTEGER_64 -- Last 8-bit integer read by read_integer_64 do Result := Input.last_integer_64 ensure instance_free: class end last_integer_8: INTEGER_8 -- Last 8-bit integer read by read_integer_8 do Result := Input.last_integer_8 ensure instance_free: class end last_natural: NATURAL_32 -- Last 32-bit natural read by read_natural_32 -- Was declared in STD_FILES as synonym of last_natural_32. do Result := Input.last_natural_32 ensure instance_free: class end last_natural_16: NATURAL_16 -- Last 16-bit natural read by read_natural_16 do Result := Input.last_natural_16 ensure instance_free: class end last_natural_32: NATURAL_32 -- Last 32-bit natural read by read_natural_32 -- Was declared in STD_FILES as synonym of last_natural. do Result := Input.last_natural_32 ensure instance_free: class end last_natural_64: NATURAL_64 -- Last 64-bit natural read by read_natural_64 do Result := Input.last_natural_64 ensure instance_free: class end last_natural_8: NATURAL_8 -- Last 8-bit natural read by read_natural_8 do Result := Input.last_natural_8 ensure instance_free: class end last_real: REAL_32 -- Last real read by read_real -- Was declared in STD_FILES as synonym of lastreal and last_real_32. do Result := Input.last_real ensure instance_free: class end last_real_32: REAL_32 -- Last real read by read_real -- Was declared in STD_FILES as synonym of last_real and lastreal. do Result := Input.last_real ensure instance_free: class end last_real_64: REAL_64 -- Last double read by read_double. -- Was declared in STD_FILES as synonym of last_double and lastdouble. do Result := Input.last_double ensure instance_free: class end last_string: STRING_8 -- Last string read by read_line, -- read_stream, or read_word -- Was declared in STD_FILES as synonym of laststring. do Result := Input.last_string ensure instance_free: class end lastchar: CHARACTER_8 -- Last character read by read_character -- Was declared in STD_FILES as synonym of last_character. do Result := Input.last_character ensure instance_free: class end lastdouble: REAL_64 -- Last double read by read_double. -- Was declared in STD_FILES as synonym of last_double and last_real_64. do Result := Input.last_double ensure instance_free: class end lastint: INTEGER_32 -- Last integer read by read_integer -- Was declared in STD_FILES as synonym of last_integer and last_integer_32. do Result := Input.last_integer ensure instance_free: class end lastreal: REAL_32 -- Last real read by read_real -- Was declared in STD_FILES as synonym of last_real and last_real_32. do Result := Input.last_real ensure instance_free: class end laststring: STRING_8 -- Last string read by read_line, -- read_stream, or read_word -- Was declared in STD_FILES as synonym of last_string. do Result := Input.last_string ensure instance_free: class 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 feature -- Element change new_line -- Write line feed at end of default output. -- Was declared in STD_FILES as synonym of put_new_line. do standard_default.put_new_line end put_boolean (b: BOOLEAN) -- Write b at end of default output. -- Was declared in STD_FILES as synonym of putbool. do if b then put_string ("True") else put_string ("False") end end put_character (c: CHARACTER_8) -- Write c at end of default output. -- Was declared in STD_FILES as synonym of putchar. do standard_default.put_character (c) end put_double (d: REAL_64) -- Write d at end of default output. -- Was declared in STD_FILES as synonym of putdouble and put_real_64. do standard_default.put_double (d) end put_integer (i: INTEGER_32) -- Write i at end of default output. -- Was declared in STD_FILES as synonym of putint and put_integer_32. do standard_default.put_integer (i) end put_integer_16 (i: INTEGER_16) -- Write i at end of default output. do standard_default.put_integer_16 (i) end put_integer_32 (i: INTEGER_32) -- Write i at end of default output. -- Was declared in STD_FILES as synonym of put_integer and putint. do standard_default.put_integer (i) end put_integer_64 (i: INTEGER_64) -- Write i at end of default output. do standard_default.put_integer_64 (i) end put_integer_8 (i: INTEGER_8) -- Write i at end of default output. do standard_default.put_integer_8 (i) end put_natural (i: NATURAL_32) -- Write i at end of default output. -- Was declared in STD_FILES as synonym of put_natural_32. do standard_default.put_natural_32 (i) end put_natural_16 (i: NATURAL_16) -- Write i at end of default output. do standard_default.put_natural_16 (i) end put_natural_32 (i: NATURAL_32) -- Write i at end of default output. -- Was declared in STD_FILES as synonym of put_natural. do standard_default.put_natural_32 (i) end put_natural_64 (i: NATURAL_64) -- Write i at end of default output. do standard_default.put_natural_64 (i) end put_natural_8 (i: NATURAL_8) -- Write i at end of default output. do standard_default.put_natural_8 (i) end put_new_line -- Write line feed at end of default output. -- Was declared in STD_FILES as synonym of new_line. do standard_default.put_new_line end put_real (r: REAL_32) -- Write r at end of default output. -- Was declared in STD_FILES as synonym of putreal and put_real_32. do standard_default.put_real (r) end put_real_32 (r: REAL_32) -- Write r at end of default output. -- Was declared in STD_FILES as synonym of put_real and putreal. do standard_default.put_real (r) end put_real_64 (d: REAL_64) -- Write d at end of default output. -- Was declared in STD_FILES as synonym of put_double and putdouble. do standard_default.put_double (d) end put_string (s: READABLE_STRING_8) -- Write s at end of default output. -- Was declared in STD_FILES as synonym of putstring. require string_not_void: s /= Void do standard_default.put_string (s) end put_string_32 (s: READABLE_STRING_32) -- Write s at end of default output. require string_not_void: s /= Void do standard_default.put_string_32 (s) end putbool (b: BOOLEAN) -- Write b at end of default output. -- Was declared in STD_FILES as synonym of put_boolean. do if b then put_string ("True") else put_string ("False") end end putchar (c: CHARACTER_8) -- Write c at end of default output. -- Was declared in STD_FILES as synonym of put_character. do standard_default.put_character (c) end putdouble (d: REAL_64) -- Write d at end of default output. -- Was declared in STD_FILES as synonym of put_double and put_real_64. do standard_default.put_double (d) end putint (i: INTEGER_32) -- Write i at end of default output. -- Was declared in STD_FILES as synonym of put_integer and put_integer_32. do standard_default.put_integer (i) end putreal (r: REAL_32) -- Write r at end of default output. -- Was declared in STD_FILES as synonym of put_real and put_real_32. do standard_default.put_real (r) end putstring (s: READABLE_STRING_8) -- Write s at end of default output. -- Was declared in STD_FILES as synonym of put_string. require string_not_void: s /= Void do standard_default.put_string (s) end set_error_default -- Use standard error as default output. do default_output := Error end set_file_default (f: PLAIN_TEXT_FILE) -- Use f as default output. require valid_argument: f /= Void file_open_write: f.is_open_write do default_output := f end set_output_default -- Use standard output as default output. do default_output := Output 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: STD_FILES) -- 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: STD_FILES) -- 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: STD_FILES -- 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: STD_FILES) -- 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: STD_FILES -- 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: STD_FILES -- 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 STD_FILES 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 STD_FILES -- 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 -- Input next_line -- Move to next input line on standard input. -- Was declared in STD_FILES as synonym of to_next_line. do Input.next_line ensure instance_free: class end read_character -- Read a new character from standard input. -- It will not return until read operation is -- terminated when enter key is pressed. -- Make result available in last_character. -- last_character will also contains platform -- specific newline character. -- Was declared in STD_FILES as synonym of readchar. do Input.read_character ensure instance_free: class end read_double -- Read a new double from standard input. -- Make result available in last_double. -- Was declared in STD_FILES as synonym of readdouble. do Input.read_double ensure instance_free: class end read_integer -- Read a new 32-bit integer from standard input. -- Make result available in last_integer. -- Was declared in STD_FILES as synonym of readint and read_integer_32. do Input.read_integer ensure instance_free: class end read_integer_16 -- Read a new 16-bit integer from standard input. -- Make result available in last_integer_16. do Input.read_integer_16 ensure instance_free: class end read_integer_32 -- Read a new 32-bit integer from standard input. -- Make result available in last_integer. -- Was declared in STD_FILES as synonym of read_integer and readint. do Input.read_integer ensure instance_free: class end read_integer_64 -- Read a new 64-bit integer from standard input. -- Make result available in last_integer_64. do Input.read_integer_64 ensure instance_free: class end read_integer_8 -- Read a new 8-bit integer from standard input. -- Make result available in last_integer_8. do Input.read_integer_8 ensure instance_free: class end read_line -- Read a line from standard input. -- Make result available in last_string. -- Was declared in STD_FILES as synonym of readline. do Input.read_line ensure instance_free: class last_string_not_void: last_string /= Void end read_natural -- Read a new 32-bit natural from standard input. -- Make result available in last_natural. -- Was declared in STD_FILES as synonym of read_natural_32. do Input.read_natural_32 ensure instance_free: class end read_natural_16 -- Read a new 16-bit natural from standard input. -- Make result available in last_natural_16. do Input.read_natural_16 ensure instance_free: class end read_natural_32 -- Read a new 32-bit natural from standard input. -- Make result available in last_natural. -- Was declared in STD_FILES as synonym of read_natural. do Input.read_natural_32 ensure instance_free: class end read_natural_64 -- Read a new 64-bit natural from standard input. -- Make result available in last_natural_64. do Input.read_natural_64 ensure instance_free: class end read_natural_8 -- Read a new 8-bit natural from standard input. -- Make result available in last_natural_8. do Input.read_natural_8 ensure instance_free: class end read_real -- Read a new real from standard input. -- Make result available in last_real. -- Was declared in STD_FILES as synonym of readreal. do Input.read_real ensure instance_free: class end read_stream (nb_char: INTEGER_32) -- Read a string of at most nb_char bound characters -- from standard input. -- Make result available in last_string. -- Was declared in STD_FILES as synonym of readstream. do Input.read_stream (nb_char) ensure instance_free: class last_string_not_void: last_string /= Void end read_word -- Read a new word from standard input. -- Make result available in last_string. -- Was declared in STD_FILES as synonym of readword. do Input.read_word ensure instance_free: class last_string_not_void: last_string /= Void end readchar -- Read a new character from standard input. -- It will not return until read operation is -- terminated when enter key is pressed. -- Make result available in last_character. -- last_character will also contains platform -- specific newline character. -- Was declared in STD_FILES as synonym of read_character. do Input.read_character ensure instance_free: class end readdouble -- Read a new double from standard input. -- Make result available in last_double. -- Was declared in STD_FILES as synonym of read_double. do Input.read_double ensure instance_free: class end readint -- Read a new 32-bit integer from standard input. -- Make result available in last_integer. -- Was declared in STD_FILES as synonym of read_integer and read_integer_32. do Input.read_integer ensure instance_free: class end readline -- Read a line from standard input. -- Make result available in last_string. -- Was declared in STD_FILES as synonym of read_line. do Input.read_line ensure instance_free: class last_string_not_void: last_string /= Void end readreal -- Read a new real from standard input. -- Make result available in last_real. -- Was declared in STD_FILES as synonym of read_real. do Input.read_real ensure instance_free: class end readstream (nb_char: INTEGER_32) -- Read a string of at most nb_char bound characters -- from standard input. -- Make result available in last_string. -- Was declared in STD_FILES as synonym of read_stream. do Input.read_stream (nb_char) ensure instance_free: class last_string_not_void: last_string /= Void end readword -- Read a new word from standard input. -- Make result available in last_string. -- Was declared in STD_FILES as synonym of read_word. do Input.read_word ensure instance_free: class last_string_not_void: last_string /= Void end to_next_line -- Move to next input line on standard input. -- Was declared in STD_FILES as synonym of next_line. do Input.next_line ensure instance_free: class 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 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 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 STD_FILES
Generated by ISE EiffelStudio