Section Header
  
  
    + name    := ABSTRACT_STRING -> STRING;
  
  
    - comment := "Generic prototype for STRING and STRING_CONSTANT";
  
Section Inherit
  
  
    - parent_hashable:HASHABLE := 
  
  
    - parent_comparable:COMPARABLE := 
  
Section ABSTRACT_STRING, ABSTRACT_ENTRY
  
  
    + storage:NATIVE_ARRAY[CHARACTER];
  
Section Public
  
  
    + count:INTEGER;
  
  
    - lower:INTEGER := 
  
  
    - upper:INTEGER <- 
  
  
    - capacity:INTEGER <- 
  
  
  
 Access.
  
  
  
    - item index:INTEGER :CHARACTER <-
  
         Character at position `index'.
    
  
    - '@' Left 1 index:INTEGER :CHARACTER <-
  
         Character at position `index'.
    
  
  
 Switch case :
  
  
  
    - when value:ABSTRACT_STRING then block:BLOCK :ABSTRACT_STRING <-
  
  
    - when value1:ABSTRACT_STRING or value2:ABSTRACT_STRING then block:BLOCK :ABSTRACT_STRING <-
  
  
  
 Testing.
  
  
  
    - valid_index index:INTEGER :BOOLEAN <-
  
         True when `index' is valid (i.e., inside actual bounds).
  
  
  
    - is_empty : BOOLEAN <- 
  
  
    - hash_code: INTEGER <-
    
  
    - '<' other:ABSTRACT_STRING :BOOLEAN <-
  
         Is Current less than `other' ?
    
  
    - compare other:ABSTRACT_STRING :INTEGER <-
    
  
    - same_as other:ABSTRACT_STRING :BOOLEAN <-
  
         Case insensitive `=='.
    
  
    - '==' Left 40 other:ABSTRACT_STRING :BOOLEAN <-
  
         Has Current the same text as `other' ?
    
  
    - item_code i:INTEGER :INTEGER <-
  
         Code of character at position `i'.
    
  
    - index_of ch:CHARACTER since start_index:INTEGER :INTEGER <-
  
         Index of first occurrence of `c' at or after `start_index',
  
         result = count + 1, if none.
    
  
    - last_index_of ch:CHARACTER since start_index:INTEGER :INTEGER <-
  
         Index of first occurrence of `c' at or before `start_index',
  
         0 if none.
    
  
    - fast_index_of ch:CHARACTER :INTEGER <-
  
         Gives the index of the first occurrence `ch' or
  
         0 if none.
    
  
    - first_index_of c:CHARACTER :INTEGER <-  
  
         Index of first occurrence of `c' at index 1 or after index 1.
    
  
    - fast_last_index_of ch:CHARACTER :INTEGER <-
  
         Gives the index of the last occurrence `ch' or
  
         0 if none.
      
  
    - last_index_of c:CHARACTER :INTEGER <-
  
         Index of last occurrence of `c' at index upper or before index upper.
    
  
    - has ch:CHARACTER :BOOLEAN <- 
  
         True if `ch' is in the STRING.
  
  
    - has_substring other:ABSTRACT_STRING :BOOLEAN <-
  
         True if `other' is in the STRING.
  
    
  
    - occurrences c:CHARACTER :INTEGER <-
  
         Number of times character `c' appears in the string.
    
  
    -  has_suffix s:ABSTRACT_STRING :BOOLEAN <-
  
         True if suffix of `Current' is `s'.
    
  
    - has_prefix p:ABSTRACT_STRING :BOOLEAN <-
  
         True if prefix of `Current' is `p'.
    
  
 Testing and Conversion:
  
  
    - is_boolean:BOOLEAN <-
  
         does self represent a BOOLEAN?
  
         valid BOOLEANS are "TRUE" and "FALSE".
    
  
    - to_boolean:BOOLEAN <-
  
         Boolean value;
  
         "true" yields true, "false" yields false (what a surprise).
    
  
    - is_bit:BOOLEAN <-
  
         True when the contents is a sequence of bits (i.e., mixed
  
         characters `0' and characters `1').
  
  
    - is_integer:BOOLEAN <-
  
         Does self represent an INTEGER?
  
         `Result' is true if and only if the following two conditions hold:
  
        
  
         1. In the following BNF grammar, the value of self can be
  
         produced by "Integer_literal", if leading and trailing
  
         separators are ignored:
  
        
  
         Integer_literal = [Sign] Integer
  
         Sign            = "+" | "-"
  
         Integer         = Digit | Digit Integer
  
         Digit           = "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9"
  
        
  
         2. The numerical value represented by self is within the
  
         range that can be represented by an instance of type INTEGER.
    
  
    - to_integer:INTEGER <-
  
         self must look like an INTEGER.
    
  
    - is_hexadecimal :BOOLEAN <-
  
  
    - to_hexadecimal :INTEGER_64 <-
  
  
    - is_octal :BOOLEAN <-
  
  
    - to_octal:INTEGER_64 <-
  
  
    - to_binary :INTEGER_64 <-
    
  
    - is_real_16_16:BOOLEAN <-
  
         Does self represent an REAl_16_16 ?
  
         `Result' is true if and only if the following two conditions hold:
  
        
  
         1. In the following BNF grammar, the value of self can be
  
         produced by "real_literal", if leading and trailing
  
         separators are ignored:
  
        
  
         Real_literal = [Sign] Integer [Point Integer]
  
         Sign            = "+" | "-"
  
         Point           = "."
  
         Integer         = Digit | Digit Integer
  
         Digit           = "0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9"
  
        
  
         2. The numerical value represented by self is within the
  
         range that can be represented by an instance of type REAL_16_16.
    
  
    - to_real_16_16:REAL_16_16 <-
    
  
  
 Modification:
  
  
  
    - '+' other:ABSTRACT_STRING :STRING <-
  
         Create a new STRING which is the concatenation of
  
         `self' and `other'.
      
  
    - as_lower:STRING <-
  
         New object with all letters in lower case.
    
  
    - as_upper:STRING <-
  
         New object with all letters in upper case.
    
  
 Other features:
  
  
    - first:CHARACTER <-
  
         Access to the very `first' character.
  
  
    - last:CHARACTER <-
  
         Access to the very `last' character.
      
  
    - substring start_index:INTEGER to end_index:INTEGER :STRING <-
  
         New string consisting of items [`start_index'.. `end_index'].
      
  
    - substring_index (other:ABSTRACT_STRING,start_index:INTEGER) :INTEGER <-
  
         Position of the first occurrence of `other' at or after 1
  
         or 0 f none.
    
  
    - first_substring_index other:ABSTRACT_STRING :INTEGER <-
  
         Position of the first occurrence of `other' at or after 1
  
         or 0 if none.
    
  
  
 Splitting a STRING:
  
  
  
    - split:ARRAY[STRING] <-
  
         Split the string into an array of words. Uses `is_separator' of
  
         CHARACTER to find words. Gives Void or a non empty array.
    
  
    - split_in words:COLLECTION[STRING] <-
  
         Same jobs as `split' but result is appended in `words'.
    
  
    - get_new_iterator:ITERATOR[CHARACTER] <-
    
  
    - same_string other:ABSTRACT_STRING :BOOLEAN <-
  
         Do self and other have the same character sequence?
  
         Useful in proper descendants of STRING.
    
  
    - to_string:Strict STRING <-
  
         New STRING having the same character sequence as self.
  
         Useful in proper descendants of STRING.
    
  
    - string_buffer:STRING :=  
         Private, temporary once buffer.
  
  
    - split_buffer:ARRAY[STRING] := 
    
  
  
 Display.
  
  
  
    - print <- 
    
  
  
 The guru section
  
  
  
    - to_external:NATIVE_ARRAY[CHARACTER] <- 
  
         Gives C access to the internal `storage' (may be dangerous).
  
         To be compatible with C, a null character is added at the end
  
         of the internal `storage'. This extra null character is not
  
         part of the Lisaac STRING.