INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

description: "General concept of a searching machine."
cluster: matcher
deferred class SEARCHER
feature -- Initialization

make (p: STRING)
-- Make a searcher from search pattern `p'. 
-- Case sensitivity (which is enabled at object creation)
-- is not modified.
require
pattern_defined: p /= void

make_sensitive (p: STRING)
-- Make a case sensitive searcher from search pattern `p'.
require
pattern_defined: p /= void
ensure
case_sensitivity: sensitive

make_insensitive (p: STRING)
-- Make a case insensitive searcher from search pattern `p'.
require
pattern_defined: p /= void
ensure
case_insensitivity: insensitive
feature -- Modification

set_sensitive
-- Make searcher case-sensitive.
ensure
case_sensitivity: sensitive

set_insensitive
-- Make searcher case-insensitive.
ensure
case_insensitivity: insensitive
feature -- Status report

pattern: STRING

compiled: BOOLEAN

error_code: INTEGER

insensitive: BOOLEAN

sensitive: BOOLEAN
-- Is the searcher case insensitive?

found: BOOLEAN

start_position, end_position: INTEGER
feature -- Actions

search_forward (s: STRING; s_from, s_to: INTEGER)
-- Search for `pattern' in string `s'. Start searching at index
-- position `s_from' and search until the pattern matches (while
-- ignoring any characters behind `s_to'). If pattern matches, set
-- `found' to true and `start_position' and `end_position'
-- to the corresponding index positions (relative to the beginning
-- of the string). If the pattern doesn't match, set `found' to
-- false, but do not modify `start_position' or `end_position'.
require
s_exists: s /= void
from_in_range: s_from >= 1 and s_from <= s.count
to_in_range: s_to >= 1 and s_to <= s.count
pattern_compiled: compiled
ensure
position_set: found implies (start_position >= s_from and start_position <= s_to + 1 and end_position >= s_from - 1 and end_position <= s_to)
position_kept: (not found) implies (start_position = start_position and end_position = end_position )

search_backward (s: STRING; s_from, s_to: INTEGER)
-- Search for `pattern' in string `s'. Start searching at index
-- position `s_to' and search backward until the pattern matches
-- (ignoring any characters before `s_from'). If pattern matches,
-- set `found' to true and `start_position' and `end_position'
-- to the corresponding index positions (relative to the beginning
-- of the string). If the pattern doesn't match, set `found' to
-- false, but do not modify `start_position' or `end_position'.
require
s_exists: s /= void
from_in_range: s_from >= 1 and s_from <= s.count
to_in_range: s_to >= 1 and s_to <= s.count
pattern_compiled: compiled
ensure
position_set: found implies (start_position >= s_from and start_position <= s_to + 1 and end_position >= s_from - 1 and end_position <= s_to)
position_kept: (not found) implies (start_position = start_position and end_position = end_position )
end -- class SEARCHER

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES