note description: "[ Objects that may be stored and retrieved along with all their dependents. This class may be used as ancestor 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: 2018-04-28 20:49:45 +0000 (Sat, 28 Apr 2018) $" revision: "$Revision: 101698 $" class STORABLE 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 Check_instruction: INTEGER_32 = 7 -- Exception code for violated check -- (from EXCEP_CONST) Class_invariant: INTEGER_32 = 6 -- Exception code for violated class invariant -- (from EXCEP_CONST) Com_exception: INTEGER_32 = 28 -- Exception code for a COM error. -- (from EXCEP_CONST) Create_on_deferred: INTEGER_32 = 17 -- Create on deferred -- (from EXCEP_CONST) Developer_exception: INTEGER_32 = 24 -- Exception code for developer exception -- (from EXCEP_CONST) Dollar_applied_to_melted_feature: INTEGER_32 = 26 -- $ applied to melted feature -- (from EXCEP_CONST) Eiffel_runtime_fatal_error: INTEGER_32 = 25 -- Eiffel run-time fatal error -- (from EXCEP_CONST) Eiffel_runtime_panic: INTEGER_32 = 13 -- Eiffel run-time panic -- (from EXCEP_CONST) Exception_in_signal_handler: INTEGER_32 = 20 -- Exception in signal handler -- (from EXCEP_CONST) Exception_manager: EXCEPTION_MANAGER -- Exception manager -- (from EXCEPTION_MANAGER_FACTORY) once create {ISE_EXCEPTION_MANAGER} Result ensure -- from EXCEPTION_MANAGER_FACTORY instance_free: class exception_manager_not_void: Result /= Void end External_exception: INTEGER_32 = 18 -- Exception code for operating system error -- which does not set the errno variable -- (Unix-specific) -- (from EXCEP_CONST) Floating_point_exception: INTEGER_32 = 5 -- Exception code for floating point exception -- (from EXCEP_CONST) generating_type: TYPE [detachable STORABLE] -- 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 Incorrect_inspect_value: INTEGER_32 = 9 -- Exception code for inspect value which is not one -- of the inspect constants, if there is no Else_part -- (from EXCEP_CONST) Io_exception: INTEGER_32 = 21 -- Exception code for I/O error -- (from EXCEP_CONST) Loop_invariant: INTEGER_32 = 11 -- Exception code for violated loop invariant -- (from EXCEP_CONST) Loop_variant: INTEGER_32 = 10 -- Exception code for non-decreased loop variant -- (from EXCEP_CONST) No_more_memory: INTEGER_32 = 2 -- Exception code for failed memory allocation -- (from EXCEP_CONST) Number_of_codes: INTEGER_32 = 31 -- How many codes are there to represent exceptions? -- (from EXCEP_CONST) Old_exception: INTEGER_32 = 30 -- Old exception code. -- (from EXCEP_CONST) Operating_system_exception: INTEGER_32 = 22 -- Exception code for operating system error -- which sets the errno variable -- (Unix-specific) -- (from EXCEP_CONST) Out_of_memory: INTEGER_32 = 15 -- Out of memory (cannot be ignored) -- (from EXCEP_CONST) Postcondition: INTEGER_32 = 4 -- Exception code for violated postcondition -- (from EXCEP_CONST) Precondition: INTEGER_32 = 3 -- Exception code for violated precondition -- (from EXCEP_CONST) Rescue_exception: INTEGER_32 = 14 -- Exception code for exception in rescue clause -- (from EXCEP_CONST) Resumption_failed: INTEGER_32 = 16 -- Resumption failed (retry did not succeed) -- (from EXCEP_CONST) retrieve_by_name (file_name: READABLE_STRING_GENERAL): detachable ANY -- Retrieve object structure, from external -- representation previously stored in a file -- called file_name. -- To access resulting object under correct type, -- use assignment attempt. -- Will raise an exception (code Retrieve_exception) -- if file content is not a stored Eiffel structure. -- Will return Void if the file does not exist or -- is not readable. require file_name_exists: file_name /= Void file_name_meaningful: not file_name.is_empty local file: RAW_FILE do create file.make_with_name (file_name) if file.exists and then file.is_readable then file.open_read Result := file.retrieved; file.close end ensure instance_free: class end Retrieve_exception: INTEGER_32 = 23 -- Exception code for retrieval error -- may be raised by retrieved in IO_MEDIUM. -- (from EXCEP_CONST) retrieved (medium: IO_MEDIUM): detachable ANY -- Retrieved object structure, from external -- representation previously stored in medium. -- To access resulting object under correct type, -- use assignment attempt. -- Will raise an exception (code Retrieve_exception) -- if medium content is not a stored Eiffel structure. require medium_not_void: medium /= Void medium_exists: medium.exists medium_is_open_read: medium.is_open_read medium_supports_storable: medium.support_storable do Result := medium.retrieved ensure instance_free: class end Routine_failure: INTEGER_32 = 8 -- Exception code for failed routine -- (from EXCEP_CONST) Runtime_check_exception: INTEGER_32 = 29 -- Exception code for runtime check being violated. -- (from EXCEP_CONST) Runtime_io_exception: INTEGER_32 = 27 -- Exception code for I/O error raised by runtime functions -- such as store/retrieve, file access... -- (from EXCEP_CONST) Serialization_exception: INTEGER_32 = 31 -- Serialization exception code. -- (from EXCEP_CONST) Signal_exception: INTEGER_32 = 12 -- Exception code for operating system signal -- (from EXCEP_CONST) valid_code (c: INTEGER_32): BOOLEAN -- Is c a valid code to represent some kind of exceptions? -- (from EXCEP_CONST) do Result := c >= 1 and c <= Number_of_codes end Void_assigned_to_expanded: INTEGER_32 = 19 -- Exception code for assignment of void value -- to expanded entity -- (from EXCEP_CONST) Void_call_target: INTEGER_32 = 1 -- Exception code for feature applied to void reference -- (from EXCEP_CONST) 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: STORABLE): 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: STORABLE): 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: STORABLE): 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 assertion_violation: BOOLEAN -- Is last exception originally due to a violated -- assertion or non-decreasing variant? -- (from EXCEPTIONS) do Result := attached Exception_manager.last_exception as l_exception and then attached {ASSERTION_VIOLATION} l_exception.original ensure -- from EXCEPTIONS instance_free: class end class_name: detachable STRING_8 -- Name of the class that includes the recipient -- of original form of last exception -- (from EXCEPTIONS) do if attached Exception_manager.last_exception as l_exception then Result := l_exception.type_name end ensure -- from EXCEPTIONS instance_free: class end 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 developer_exception_name: detachable STRING_8 -- Name of last developer-raised exception -- (from EXCEPTIONS) require -- from EXCEPTIONS applicable: is_developer_exception do if attached Exception_manager.last_exception as e and then attached e.original.description as d then Result := {UTF_CONVERTER}.escaped_utf_32_string_to_utf_8_string_8 (d) end ensure -- from EXCEPTIONS instance_free: class end exception: INTEGER_32 -- Code of last exception that occurred -- (from EXCEPTIONS) do if attached Exception_manager.last_exception as l_exception then Result := l_exception.code end ensure -- from EXCEPTIONS instance_free: class end exception_trace: detachable STRING_8 -- String representation of the exception trace -- (from EXCEPTIONS) do if attached Exception_manager.last_exception as e and then attached e.original.trace as t then Result := {UTF_CONVERTER}.escaped_utf_32_string_to_utf_8_string_8 (t) end ensure -- from EXCEPTIONS instance_free: class end is_developer_exception: BOOLEAN -- Is the last exception originally due to -- a developer exception? -- (from EXCEPTIONS) do Result := attached Exception_manager.last_exception as l_exception and then attached {DEVELOPER_EXCEPTION} l_exception.original ensure -- from EXCEPTIONS instance_free: class end is_developer_exception_of_name (name: detachable STRING_8): BOOLEAN -- Is the last exception originally due to a developer -- exception of name name? -- (from EXCEPTIONS) do if is_developer_exception then Result := developer_exception_name ~ name end ensure -- from EXCEPTIONS instance_free: class end is_signal: BOOLEAN -- Is last exception originally due to an external -- event (operating system signal)? -- (from EXCEPTIONS) do Result := attached Exception_manager.last_exception as l_exception and then attached {OPERATING_SYSTEM_SIGNAL_FAILURE} l_exception.original ensure -- from EXCEPTIONS instance_free: class end is_system_exception: BOOLEAN -- Is last exception originally due to an -- external event (operating system error)? -- (from EXCEPTIONS) do if attached Exception_manager.last_exception as l_exception and attached Exception_manager.exception_from_code (External_exception) as l_external then Result := l_exception.original.conforms_to (l_external) or else attached {OPERATING_SYSTEM_FAILURE} l_exception.original end ensure -- from EXCEPTIONS instance_free: class end meaning (except: INTEGER_32): detachable STRING_8 -- A message in English describing what except is -- (from EXCEPTIONS) do if attached Exception_manager.exception_from_code (except) as e then Result := {UTF_CONVERTER}.string_32_to_utf_8_string_8 (e.Tag) end ensure -- from EXCEPTIONS instance_free: class end original_class_name: detachable STRING_8 -- Name of the class that includes the recipient -- of original form of last exception -- (from EXCEPTIONS) do if attached Exception_manager.last_exception as l_exception then Result := l_exception.cause.original.type_name end ensure -- from EXCEPTIONS instance_free: class end original_exception: INTEGER_32 -- Original code of last exception that triggered -- current exception -- (from EXCEPTIONS) do if attached Exception_manager.last_exception as l_exception then Result := l_exception.cause.original.code end ensure -- from EXCEPTIONS instance_free: class end original_recipient_name: detachable STRING_8 -- Name of the routine whose execution was -- interrupted by original form of last exception -- (from EXCEPTIONS) do if attached Exception_manager.last_exception as l_exception then Result := l_exception.cause.original.recipient_name end ensure -- from EXCEPTIONS instance_free: class end original_tag_name: detachable STRING_8 -- Assertion tag for original form of last -- assertion violation. -- (from EXCEPTIONS) do if attached Exception_manager.last_exception as e and then attached e.cause.original.description as d then Result := {UTF_CONVERTER}.escaped_utf_32_string_to_utf_8_string_8 (d) end ensure -- from EXCEPTIONS instance_free: class end recipient_name: detachable STRING_8 -- Name of the routine whose execution was -- interrupted by last exception -- (from EXCEPTIONS) do if attached Exception_manager.last_exception as l_exception then Result := l_exception.recipient_name end ensure -- from EXCEPTIONS 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 tag_name: detachable STRING_8 -- Tag of last violated assertion clause -- (from EXCEPTIONS) do if attached Exception_manager.last_exception as e and then attached e.description as d then Result := {UTF_CONVERTER}.escaped_utf_32_string_to_utf_8_string_8 (d) end ensure -- from EXCEPTIONS instance_free: class end feature -- Status setting catch (code: INTEGER_32) -- Make sure that any exception of code code will be -- caught. This is the default. -- (from EXCEPTIONS) do if attached Exception_manager.type_of_code (code) as l_type then Exception_manager.catch (l_type) end ensure -- from EXCEPTIONS instance_free: class end die (code: INTEGER_32) -- Terminate execution with exit status code, -- without triggering an exception. -- (from EXCEPTIONS) external "C use %"eif_except.h%"" alias "esdie" ensure -- from EXCEPTIONS False instance_free: class end ignore (code: INTEGER_32) -- Make sure that any exception of code code will be -- ignored. This is not the default. -- (from EXCEPTIONS) do if attached Exception_manager.type_of_code (code) as l_type then Exception_manager.ignore (l_type) end ensure -- from EXCEPTIONS instance_free: class end message_on_failure -- Print an exception history table -- in case of failure. -- This is the default. -- (from EXCEPTIONS) do c_trace_exception (True) ensure -- from EXCEPTIONS instance_free: class end new_die (code: INTEGER_32) obsolete "Use `die'. [2017-05-31]" -- (from EXCEPTIONS) external "C use %"eif_except.h%"" alias "esdie" ensure -- from EXCEPTIONS False instance_free: class end no_message_on_failure -- Do not print an exception history table -- in case of failure. -- (from EXCEPTIONS) do c_trace_exception (False) ensure -- from EXCEPTIONS instance_free: class end raise (name: detachable READABLE_STRING_GENERAL) -- Raise a developer exception of name name. -- (from EXCEPTIONS) local l_exception: DEVELOPER_EXCEPTION do create l_exception; l_exception.set_description (name); l_exception.raise ensure -- from EXCEPTIONS instance_free: class end raise_retrieval_exception (name: detachable READABLE_STRING_GENERAL) -- Raise a retrieval exception of name name. -- (from EXCEPTIONS) do if attached Exception_manager.exception_from_code (Serialization_exception) as l_exception then l_exception.set_description (name); l_exception.raise end ensure -- from EXCEPTIONS instance_free: class end feature -- Element change basic_store (medium: IO_MEDIUM) -- Produce on medium an external representation of the -- entire object structure reachable from current object. -- Retrievable within current system only. require medium_not_void: medium /= Void medium_exists: medium.exists medium_is_open_write: medium.is_open_write medium_supports_storable: medium.support_storable do medium.basic_store (Current) end general_store (medium: IO_MEDIUM) obsolete "Use `independent_store'. [2017-05-31]" -- Produce on medium an external representation of the -- entire object structure reachable from current object. -- Retrievable from other systems for same platform -- (machine architecture). require medium_not_void: medium /= Void medium_exists: medium.exists medium_is_open_write: medium.is_open_write medium_supports_storable: medium.support_storable do medium.independent_store (Current) end independent_store (medium: IO_MEDIUM) -- Produce on medium an external representation of the -- entire object structure reachable from current object. -- Retrievable from other systems for the same or other -- platform (machine architecture). require medium_not_void: medium /= Void medium_exists: medium.exists medium_is_open_write: medium.is_open_write medium_supports_storable: medium.support_storable do medium.independent_store (Current) end store_by_name (file_name: READABLE_STRING_GENERAL) -- Produce on file called file_name an external -- representation of the entire object structure -- reachable from current object. -- Retrievable from other systems for same platform -- (machine architecture). require file_name_not_void: file_name /= Void file_name_meaningful: not file_name.is_empty local file: RAW_FILE l_io_exception: IO_FAILURE do create file.make_with_name (file_name) if (file.exists and then file.is_writable) or else file.is_creatable then file.open_write; file.independent_store (Current); file.close else create l_io_exception; l_io_exception.set_description ("write permission failure"); l_io_exception.raise 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: STORABLE) -- 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: STORABLE) -- 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: STORABLE -- 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: STORABLE) -- 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: STORABLE -- 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: STORABLE -- 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 STORABLE 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 STORABLE -- 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 {NONE} -- Implementation c_trace_exception (b: BOOLEAN) -- (from EXCEPTIONS) external "C use %"eif_except.h%"" alias "eetrace" 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 feature -- Setting set_discard_pointers (v: BOOLEAN) -- If v it will discard POINTER values and replace them by -- the default_pointer pointer. Otherwise it keeps the original value. external "C signature (EIF_BOOLEAN) use %"eif_retrieve.h%"" alias "eif_set_discard_pointer_values" end set_new_independent_format (v: BOOLEAN) obsolete "It is now the new format. Use former version of EiffelStudio to store in the old format. [2017-05-31]" -- If v it will use ISE Eiffel 5.0 storable format for -- storing. do end set_new_recoverable_format (v: BOOLEAN) obsolete "It is now the new format. Use former version of EiffelStudio to store in the old format. [2017-05-31]" -- If v it will use ISE Eiffel 5.3 storable format for -- storing with ability to recover when there is a type mismatch. do end invariant -- from ANY reflexive_equality: standard_is_equal (Current) reflexive_conformance: conforms_to (Current) note copyright: "Copyright (c) 1984-2018, 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 STORABLE
Generated by ISE EiffelStudio