indexing description: "[ Text file property store. Stores properties in name=value form, one per line. ]" project: "Project Goanna " library: "preferences" date: "$Date$" revision: "$Revision$" author: "Glenn Maughan " copyright: "Copyright (c) 2002 Glenn Maughan" license: "Eiffel Forum License v1 (see forum.txt)." class GP_TEXT_FILE_PROPERTY_STORE inherit GP_PROPERTY_STORE KL_SHARED_OPERATING_SYSTEM export {NONE} all end creation make feature {NONE} -- Initialization make (store_file_name: STRING) is -- Initialise to store in a text file named 'file_name'. require store_file_name_not_void: store_file_name /= Void do file_name := store_file_name end feature -- Basic routines read (destination: GP_PROPERTIES) is -- Read properties from store and add to 'destination' local file: KL_TEXT_INPUT_FILE next, name: STRING parts: LIST [STRING] do create file.make (file_name) file.open_read if file.is_open_read then from until file.end_of_file loop file.read_line next := clone (file.last_string) if not next.is_empty and then next.index_of ('=', 1) /= 0 then parts := next.split ('=') parts.start name := parts.item parts.forth destination.force (parts.item, name) end end file.close end end write (source: GP_PROPERTIES) is -- Write properties in 'source' to store local file: KL_TEXT_OUTPUT_FILE cursor: DS_HASH_TABLE_CURSOR [STRING, STRING] do create file.make (file_name) file.open_write if file.is_open_write then from cursor := source.new_cursor cursor.start until cursor.off loop file.put_line (cursor.key + "=" + cursor.item) cursor.forth end end file.flush file.close end feature {NONE} -- Implementation file_name: STRING -- Name of file to read and write invariant file_name_not_void: file_name /= Void end -- class GP_TEXT_FILE_PROPERTY_STORE