note description: "[ Encoding of arbitrary objects graphs between different version of programs containing types that might have changed and for which the retrieving system may know how to fix the mismatches. ]" legal: "See notice at end of class." status: "See notice at end of class." date: "$Date: 2020-05-19 14:29:33 +0000 (Tue, 19 May 2020) $" revision: "$Revision: 104259 $" class SED_RECOVERABLE_SERIALIZER inherit SED_BASIC_SERIALIZER redefine write_header end create make feature {NONE} -- Implementation write_header (a_list: ARRAYED_LIST [separate ANY]; a_type_table: HASH_TABLE [INTEGER_32, INTEGER_32]) -- Write header of storable. local l_attr_dtype_table: like attributes_dynamic_types l_dtype: INTEGER_32 l_ser: like serializer l_reflector: like reflector l_is_independent_serializer: BOOLEAN do l_ser := serializer l_reflector := reflector write_settings l_is_independent_serializer := not is_store_settings_enabled l_attr_dtype_table := attributes_dynamic_types (a_type_table) from l_ser.write_compressed_natural_32 (a_type_table.count.to_natural_32); a_type_table.start until a_type_table.after loop l_dtype := a_type_table.item_for_iteration; l_ser.write_compressed_natural_32 (l_dtype.to_natural_32); l_ser.write_string_8 (l_reflector.type_name_8_of_type (l_dtype)); a_type_table.forth if not l_is_independent_serializer and then version >= {SED_VERSIONS}.version_6_6 then if attached l_reflector.storable_version_of_type (l_dtype) as l_version and then not l_version.is_empty then l_ser.write_boolean (True); l_ser.write_string_8 (l_version) else l_ser.write_boolean (False) end end end from l_ser.write_compressed_natural_32 (l_attr_dtype_table.count.to_natural_32); l_attr_dtype_table.start until l_attr_dtype_table.after loop l_dtype := l_attr_dtype_table.item_for_iteration; l_ser.write_compressed_natural_32 (l_dtype.to_natural_32); l_ser.write_string_8 (l_reflector.type_name_8_of_type (l_dtype)); l_attr_dtype_table.forth end from l_ser.write_compressed_natural_32 (a_type_table.count.to_natural_32); a_type_table.start until a_type_table.after loop l_dtype := a_type_table.item_for_iteration; l_ser.write_compressed_natural_32 (l_dtype.to_natural_32) write_attributes (l_dtype); a_type_table.forth end write_object_table (a_list) end attributes_dynamic_types (a_type_table: HASH_TABLE [INTEGER_32, INTEGER_32]): HASH_TABLE [INTEGER_32, INTEGER_32] -- Table of dynamic types of attributes appearing in a_type_table. -- If encountering an expanded type inside one of the type of a_type_table, -- we add it to a_type_table. require a_type_table_not_void: a_type_table /= Void local l_reflector: like reflector i, nb: INTEGER_32 l_dtype, l_obj_dtype: INTEGER_32 do l_reflector := reflector from a_type_table.start create Result.make (500) until a_type_table.after loop from i := 1 l_obj_dtype := a_type_table.item_for_iteration nb := l_reflector.field_count_of_type (l_obj_dtype) nb := nb + 1 until i = nb loop if not l_reflector.is_field_transient_of_type (i, l_obj_dtype) then l_dtype := l_reflector.field_static_type_of_type (i, l_obj_dtype) if not a_type_table.has (l_dtype) then if l_reflector.is_field_expanded_of_type (i, l_obj_dtype) then a_type_table.put (l_dtype, l_dtype) else Result.put (l_dtype, l_dtype) end end end i := i + 1 end; a_type_table.forth end ensure attributes_dynamic_types_not_void: Result /= Void end write_attributes (a_dtype: INTEGER_32) -- Write attribute description for type whose dynamic type id is a_dtype. require a_dtype_non_negative: a_dtype >= 0 local l_reflector: like reflector l_ser: like serializer i, nb: INTEGER_32 do l_reflector := reflector l_ser := serializer from i := 1; l_ser.write_compressed_natural_32 (l_reflector.persistent_field_count_of_type (a_dtype).to_natural_32) nb := l_reflector.field_count_of_type (a_dtype) + 1 until i = nb loop if not l_reflector.is_field_transient_of_type (i, a_dtype) then l_ser.write_compressed_natural_32 (l_reflector.field_static_type_of_type (i, a_dtype).to_natural_32); l_ser.write_string_8 (l_reflector.field_name_8_of_type (i, a_dtype)) end i := i + 1 end end note library: "EiffelBase: Library of reusable components for Eiffel." 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 SED_RECOVERABLE_SERIALIZER
Generated by ISE EiffelStudio