INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

title: "Miscellaneous operations under strings"
project: "Visual Eiffel"
revision: "$Revision: 1.1 $"
copyright: "Copyright (C) 1996-2005 Object Tools Group"
license: "http://visual-eiffel.com/license"
cluster: dale
class STRING_OPERATIONS
inherit

DALE_SERVER
end
feature -- Commands:

rotate (s: STRING; axis: CHARACTER): STRING
-- rotate the string around 'axis'
-- example: s="ABC@DEFG", axis='@', result="DEFG@ABC".
require
valid_string: s /= void and then s.occurrences (axis) = 1
ensure
same_length: Result.count = s.count

enfold (prefx, s, suffx: STRING)
-- enfold the specified string by the prefix 'prefx' and
-- the suffix 'suffx'
require
not_void: s /= void and prefx /= void and suffx /= void
ensure
well_done: s.count = prefx.count + s.count + suffx.count

lpad0 (s: STRING; len: INTEGER)
-- pad the string to the specified length by zeroes from the left
require
valid_string: s /= void
valid_arguments: 0 <= len
ensure
valid_new_length: s.count = len

i2s_lpad0 (n, len: INTEGER): STRING
-- returns a string representation of 'n' padded
-- by zeroes from the left
require
not_negative: 0 <= n
ensure
valid_result: Result /= void and then Result.count = len

in_quotes (s: STRING)
-- enfold the specified string by quotes
require
not_void: s /= void
ensure
well_done: s.count = s.count + 2
feature -- Queries for catalog classes:

sptr (s: STRING): POINTER
-- returns address of string's store or Null pointer if it is Void

slen (s: STRING): INTEGER
-- returns length of specified string or 0 if it's Void
feature -- Transforming queries:

trim (s: STRING): STRING
-- trims string from both sides and returns the result
require
valid_string: s /= void
ensure
same_or_shorter: Result /= void and then Result.count <= s.count

rtrim (s: STRING): STRING
-- trims string from the right side and returns the result
require
valid_string: s /= void
ensure
same_or_shorter: Result /= void and then Result.count <= s.count

substring (s: STRING; lower, upper: INTEGER): STRING
-- same as STRING's but creates empty string when
-- 'upper' < 'lower' and corrects these indices when they
-- run out from string's bounds
require
valid_string: s /= void
ensure
same_or_shorter: Result /= void and then Result.count <= s.count

without_symbols (s, symbols: STRING): STRING
-- returns the original string without specified symbols
require
valid_string: s /= void
valid_symbols: symbols /= void and then not symbols.is_empty
ensure
same_or_shorter: Result /= void and then Result.count <= s.count

without_blanks (s: STRING): STRING
-- returns the original string without blanks
require
valid_string: s /= void
ensure
same_or_shorter: Result /= void and then Result.count <= s.count

without_quoted_literals (s: STRING): STRING
-- returns the string without quoted literals
require
valid_string: s /= void
ensure
same_or_shorter: Result /= void and then Result.count <= s.count
feature -- Searching queries:

has_blanks (s: STRING): BOOLEAN
-- is there at least one blank?
require
not_void: s /= void

count_digits (s: STRING): INTEGER
-- count digits in the specified string
require
not_void: s /= void
feature -- Character categories:

is_one_of (s: STRING; a: ARRAY [STRING]): BOOLEAN
-- returns True if 's' is one of strings in 'a'
-- note case-sensitivity of this method
require
valid_string: s /= void
valid_array: a /= void and then a.lower = 1

is_letter (c: CHARACTER): BOOLEAN
-- 'a'-'z' or 'A'-'Z'

is_digit (c: CHARACTER): BOOLEAN
-- '0'-'9'

is_alpha (c: CHARACTER): BOOLEAN
-- 'a'-'z' or 'A'-'Z' or '0'-'9' or '_'

is_idaux (c: CHARACTER): BOOLEAN
-- '$', '#', '@', '^'
end -- class STRING_OPERATIONS

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES