INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

title: "Access to text files"
project: "Visual Eiffel Library"
revision: "$Revision: 1.1 $"
copyright: "Copyright (C) 1996-2005 Object Tools Group"
license: "http://visual-eiffel.com/license"
cluster: pool
class TEXTFILE
creation

make_create_read_write,
make_open_read,
make_open_read_write
feature -- Creation

make_create_read_write (txt_name: STRING)
-- Create text file with 'txt_name' as file name
require
string_exists: txt_name /= void
string_not_empty: not txt_name.is_empty
ensure
is_open: is_open

make_open_read (txt_name: STRING)
-- Open text file with 'txt_name' as file name in read mode
require
string_exists: txt_name /= void
string_not_empty: not txt_name.is_empty
ensure
is_open: is_open

make_open_read_write (txt_name: STRING)
-- Open text file with 'txt_name' as file name for both reading and
-- writing
require
string_exists: txt_name /= void
string_not_empty: not txt_name.is_empty
ensure
is_open: is_open
feature -- Measument

count: INTEGER
-- Total number of strings in the file
require
file_is_open: is_open
feature -- Status report

is_open: BOOLEAN
-- Is file open?
feature -- Status setting

close
-- Close file
require
file_is_open: is_open
open_for_writing: is_dirty implies txtfile.is_open_write
ensure
is_closed: not is_open

abort
-- Discard all changes made to original file
require
file_is_open: is_open
ensure
is_closed: not is_open
feature -- Access

item (index: INTEGER): STRING
-- Item at position `index'
require
file_is_open: is_open
good_index: 1 <= index and then index <= count

put (s: STRING; index: INTEGER)
-- Put `s' at position `index'
require
file_is_open: is_open
good_index: 1 <= index and then index <= count
valid_string_0: s = void or else s.index_of ('%U', 1) = 0
valid_string_n: s = void or else s.index_of ('%N', 1) = 0
valid_string_r: s = void or else s.index_of ('%R', 1) = 0

insert (s: STRING; index: INTEGER)
-- Insert `element' after position `index'
require
file_is_open: is_open
good_index: 0 <= index and then index <= count
valid_string_0: s = void or else s.index_of ('%U', 1) = 0
valid_string_n: s = void or else s.index_of ('%N', 1) = 0
valid_string_r: s = void or else s.index_of ('%R', 1) = 0

remove (index: INTEGER)
-- Remove element at position `index'
-- Elements after `index' will move one position left
-- (i.e., towards lower indices)
require
file_is_open: is_open
good_index: 1 <= index and then index <= count
end -- class TEXTFILE

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES