class STRING
Summary
Class invariant
Overview
creation features
exported features
Creation / Modification:
Testing:
Testing and Conversion:
Modification:
Printing:
Agents based features:
Other features:
Splitting a STRING:
Other features:
Interfacing with C string:
Other features here for ELKS compatibility:
  • infix "<=" (other: STRING): BOOLEAN
    Is Current less than or equal other?
  • infix ">" (other: STRING): BOOLEAN
    Is Current strictly greater than other?
  • infix ">=" (other: STRING): BOOLEAN
    Is Current greater than or equal than other?
  • in_range (lower: STRING, upper: STRING): BOOLEAN
    Return True if Current is in range [lower..upper]
    See also min, max, compare.
  • min (other: STRING): STRING
    Minimum of Current and other.
  • max (other: STRING): STRING
    Maximum of Current and other.
Indexing:
count: INTEGER_32
writable attribute
String length which is also the maximum valid index.
capacity: INTEGER_32
writable attribute
Capacity of the storage area.
lower: INTEGER_32
constant attribute
Minimum index; actually, this is always 1 (this feature is here to mimic the one of the COLLECTION hierarchy).
upper: INTEGER_32
effective function
Maximum index; actually the same value as count (this feature is here to mimic the one of the COLLECTION hierarchy).
make (needed_capacity: INTEGER_32)
effective procedure
Initialize the string to have at least needed_capacity characters of storage.
with_capacity (needed_capacity: INTEGER_32)
effective procedure
Initialize the string to have at least needed_capacity characters of storage.
make_empty
effective procedure
Create an empty string.
make_filled (c: CHARACTER, n: INTEGER_32)
effective procedure
Initialize string with n copies of c.
is_empty: BOOLEAN
effective function
Has string length 0?
item (i: INTEGER_32): CHARACTER
effective function
Character at position i.
infix "@" (i: INTEGER_32): CHARACTER
frozen
effective function
The infix notation which is actually just a synonym for item.
hash_code: INTEGER_32
effective function
The hash-code value of Current.
infix "<" (other: STRING): BOOLEAN
effective function
Is Current less than other?
compare (other: STRING): INTEGER_32
effective function
If current object equal to other, 0 if smaller, -1; if greater, 1.
three_way_comparison (other: STRING): INTEGER_32
effective function
If current object equal to other, 0 if smaller, -1; if greater, 1.
is_equal (other: STRING): BOOLEAN
effective function
Do both strings have the same character sequence?
same_as (other: STRING): BOOLEAN
effective function
Case insensitive is_equal.
item_code (i: INTEGER_32): INTEGER_32
effective function
Code of character at position i.
index_of (c: CHARACTER, start_index: INTEGER_32): INTEGER_32
effective function
Index of first occurrence of c at or after start_index, 0 if none.
reverse_index_of (c: CHARACTER, start_index: INTEGER_32): INTEGER_32
effective function
Index of first occurrence of c at or before start_index, 0 if none.
first_index_of (c: CHARACTER): INTEGER_32
effective function
Index of first occurrence of c, 0 if none.
last_index_of (c: CHARACTER): INTEGER_32
effective function
Index of last occurrence of c, 0 if none.
has (c: CHARACTER): BOOLEAN
effective function
True if c is in the STRING.
has_substring (other: STRING): BOOLEAN
effective function
True if Current contains other.
occurrences (c: CHARACTER): INTEGER_32
effective function
Number of times character c appears in the string.
has_suffix (s: STRING): BOOLEAN
effective function
True if suffix of Current is s.
has_prefix (p: STRING): BOOLEAN
effective function
True if prefix of Current is p.
is_ascii: BOOLEAN
effective function
Is Current only made of (7 bit) ASCII characters?
is_boolean: BOOLEAN
effective function
Does Current represent a BOOLEAN?
to_boolean: BOOLEAN
effective function
Boolean value "True" yields True, "False" yields False (what a surprise).
is_integer: BOOLEAN
effective function
Does 'Current' represent an INTEGER?
to_integer: INTEGER_32
effective function
Current must look like an INTEGER.
is_integer_64: BOOLEAN
effective function
Does 'Current' represent an INTEGER_64?
to_integer_64: INTEGER_64
effective function
Current must look like an INTEGER_64.
is_real: BOOLEAN
effective function
Can contents be read as a REAL ? Fails for numbers where the base or "10 ^ exponent" are not in the range Minimum_real ...
to_real: REAL_64
effective function
Conversion to the corresponding REAL value.
is_number: BOOLEAN
effective function
Can contents be read as a NUMBER?
to_number: NUMBER
effective function
Current must looks like an INTEGER.
is_bit: BOOLEAN
effective function
True when the contents is a sequence of bits (i.e., mixed characters 0 and characters 1).
to_hexadecimal
effective procedure
Convert Current bit sequence into the corresponding hexadecimal notation.
binary_to_integer: INTEGER_32
effective function
Assume there is enougth space in the INTEGER to store the corresponding decimal value.
resize (new_count: INTEGER_32)
effective procedure
Resize Current.
clear_count
effective procedure
Discard all characters so that is_empty is True after that call.
wipe_out
effective procedure
Discard all characters so that is_empty is True after that call.
clear_count_and_capacity
effective procedure
Discard all characters (is_empty is True after that call).
copy (other: STRING)
effective procedure
Copy other onto Current.
fill_with (c: CHARACTER)
effective procedure
Replace every character with c.
replace_all (old_character: CHARACTER, new_character: CHARACTER)
effective procedure
Replace all occurrences of the element old_character by new_character.
append (s: STRING)
effective procedure
Append a copy of 's' to Current.
append_string (s: STRING)
effective procedure
Append a copy of 's' to Current.
append_substring (s: STRING, start_index: INTEGER_32, end_index: INTEGER_32)
effective procedure
Append the substring from s from start_index to end_index to Current.
prepend (other: STRING)
effective procedure
Prepend other to Current.
insert_string (s: STRING, i: INTEGER_32)
effective procedure
Insert s at index i, shifting characters from index i to count rightwards.
replace_substring (s: STRING, start_index: INTEGER_32, end_index: INTEGER_32)
effective procedure
Replace the substring from start_index to end_index, inclusive, with s.
infix "+" (other: STRING): STRING
effective function
Create a new STRING which is the concatenation of Current and other.
put (c: CHARACTER, i: INTEGER_32)
effective procedure
Put c at index i.
swap (i1: INTEGER_32, i2: INTEGER_32)
effective procedure
Swap two characters.
insert_character (c: CHARACTER, i: INTEGER_32)
effective procedure
Inserts c at index i, shifting characters from position 'i' to count rightwards.
shrink (min_index: INTEGER_32, max_index: INTEGER_32)
effective procedure
Keep only the slice [min_index .. max_index] or nothing when the slice is empty.
remove (i: INTEGER_32)
effective procedure
Remove character at position i.
add_first (c: CHARACTER)
effective procedure
Add c at first position.
precede (c: CHARACTER)
effective procedure
Add c at first position.
add_last (c: CHARACTER)
effective procedure
Append c to string.
append_character (c: CHARACTER)
effective procedure
Append c to string.
extend (c: CHARACTER)
effective procedure
Append c to string.
to_lower
effective procedure
Convert all characters to lower case.
to_upper
effective procedure
Convert all characters to upper case.
as_lower: STRING
effective function
New object with all letters in lower case.
as_upper: STRING
effective function
New object with all letters in upper case.
keep_head (n: INTEGER_32)
effective procedure
Remove all characters except for the first n.
keep_tail (n: INTEGER_32)
effective procedure
Remove all characters except for the last n.
remove_first
effective procedure
Remove the first item.
remove_the_first
effective procedure
remove_head (n: INTEGER_32)
effective procedure
Remove n first characters.
remove_last
effective procedure
Remove the last item.
remove_the_last
effective procedure
remove_tail (n: INTEGER_32)
effective procedure
Remove n last characters.
remove_substring (start_index: INTEGER_32, end_index: INTEGER_32)
effective procedure
Remove all characters from strt_index to end_index inclusive.
remove_between (start_index: INTEGER_32, end_index: INTEGER_32)
effective procedure
Remove all characters from strt_index to end_index inclusive.
remove_suffix (s: STRING)
effective procedure
Remove the suffix s of current string.
remove_prefix (s: STRING)
effective procedure
Remove the prefix s of current string.
left_adjust
effective procedure
Remove leading blanks.
right_adjust
effective procedure
Remove trailing blanks.
out_in_tagged_out_memory
effective procedure
Append terse printable represention of current object in tagged_out_memory.
fill_tagged_out_memory
effective procedure
Append a viewable information in tagged_out_memory in order to affect the behavior of out, tagged_out, etc.
do_all (action: ROUTINE[TUPLE 1[CHARACTER]])
effective procedure
Apply action to every item of Current.
effective function
Do all items satisfy test?
effective function
Does at least one item satisfy test?
first: CHARACTER
effective function
Access to the very first character.
last: CHARACTER
effective function
Access to the very last character.
substring (start_index: INTEGER_32, end_index: INTEGER_32): STRING
effective function
New string consisting of items [start_index.. end_index].
extend_multiple (c: CHARACTER, n: INTEGER_32)
effective procedure
Extend Current with n times character c.
precede_multiple (c: CHARACTER, n: INTEGER_32)
effective procedure
Prepend n times character c to Current.
extend_to_count (c: CHARACTER, needed_count: INTEGER_32)
effective procedure
Extend Current with c until needed_count is reached.
precede_to_count (c: CHARACTER, needed_count: INTEGER_32)
effective procedure
Prepend c to Current until needed_count is reached.
reverse
effective procedure
Reverse the string.
remove_all_occurrences (ch: CHARACTER)
effective procedure
Remove all occurrences of ch.
substring_index (other: STRING, start_index: INTEGER_32): INTEGER_32
effective function
Position of first occurrence of other at or after start 0 if none.
first_substring_index (other: STRING): INTEGER_32
effective function
Position of first occurrence of other at or after 1, 0 if none.
split: ARRAY[STRING]
effective function
Split the string into an array of words.
split_in (words: COLLECTION[STRING])
effective procedure
Same jobs as split but result is appended in words.
extend_unless (ch: CHARACTER)
effective procedure
Extend Current (using extend) with ch unless ch is already the last character.
get_new_iterator: ITERATOR[CHARACTER]
effective function
to_external: POINTER
effective function
Gives C access to the internal storage (may be dangerous).
from_external (p: POINTER)
effective procedure
Internal storage is set using p (may be dangerous because the external C string p is not duplicated).
from_external_copy (p: POINTER)
effective procedure
Internal storage is set using a copy of p.
from_external_sized (p: POINTER, size: INTEGER_32)
effective procedure
Internal storage is set using p (may be dangerous because the external C string p is not duplicated).
from_external_sized_copy (p: POINTER, size: INTEGER_32)
effective procedure
Internal storage is set using a copy of p.
make_from_string (model: STRING)
effective procedure
(Here for ELKS compatibility.)
same_string (other: STRING): BOOLEAN
effective function
(Here for ELKS compatibility.)
string: STRING
effective function
(Here for ELKS compatibility.)
infix "<=" (other: STRING): BOOLEAN
effective function
Is Current less than or equal other?
infix ">" (other: STRING): BOOLEAN
effective function
Is Current strictly greater than other?
infix ">=" (other: STRING): BOOLEAN
effective function
Is Current greater than or equal than other?
in_range (lower: STRING, upper: STRING): BOOLEAN
effective function
Return True if Current is in range [lower..upper]
See also min, max, compare.
min (other: STRING): STRING
effective function
Minimum of Current and other.
max (other: STRING): STRING
effective function
Maximum of Current and other.
valid_index (i: INTEGER_32): BOOLEAN
effective function
True when i is valid (i.e., inside actual bounds).