![]() |
Section 8.17.3.10:
|
![]() |
types SAME = QUAD_STR ; QUAD_STR = seq of CHAR
This class provides a string implementation in which each character has a single encoding and all encodings are represented as 32-bit bit-patterns. Objects of this type have immutable semantics.
The following features are required to be implemented for this class in accordance with the specifications given in $TEXT_STRING{CHAR,FSTR,QUAD_STR} from which this class inherits :-
The following features are required to be implemented for this class in accordance with the specifications given in $TEXT_STRING{CHAR} from which this class inherits :-
The following features are required to be implemented for this class in accordance with the specifications given in $BINARY from which this class inherits :-
The following features are required to be implemented for this class in accordance with the specifications given in $SEARCH from which this class inherits :-
The following feature is required to be implemented for this class in accordance with the specification given in $EXTERNAL_REF from which this class inherits :-
The following features are required to be implemented for this class in accordance with the specifications given in $ANCHORED_FMT from which this class inherits :-
The following features are required to be implemented for this class in accordance with the specification given in $STRING{CHAR} from which this class inherits :-
The following features are required to be implemented for this class in accordance with the specification given in $STRINGS from which this class inherits :-
The following features are required to be implemented for this class in accordance with the specification given in $LISTS{CHAR} from which this class inherits :-
The following features are required to be implemented for this class in accordance with the specification given in $ARR{CHAR} from which this class inherits :-
The following features are required to be implemented for this class in accordance with the specification given in $RO_ARR{CHAR} from which this class inherits :-
The following features are required to be implemented for this class in accordance with the specification given in $CONTAINER{CHAR} from which this class inherits :-
The following features are required to be implemented for this class in accordance with the specification given in $FILTERS{CHAR} from which this class inherits :-
The following feature is required to be implemented for this class in accordance with the specification given in $ELT{CHAR} from which this class inherits :-
The following features are required to be implemented for this class in accordance with the specification given in $ELT from which this class inherits :-
The following feature is required to be implemented for this class in accordance with the specification given in $HASH from which this class inherits :-
The following feature is required to be implemented for this class in accordance with the specification given in $COPY from which this class inherits :-
The following features are required to be implemented for this class in accordance with the specification given in $STR from which this class inherits :-
The following feature is required to be implemented for this class in accordance with the specification given in $IS_EQ from which this class inherits :-
This creation routine returns a string of the given size for the cultural context defined by the second argument.
create5(size : CARD, lib : LIBCHARS) res : SAME
Since the second argument is not optional and because it is possible to create an empty string then the pre-condition of this routine is merely true.
post size(res) = size and index_lib(res) = lib
This routine creates a string of the requested size and in the culture specified by the second lib argument.
This creation routine returns an empty string for the given cultural context.
create6(lib : LIBCHARS) res : SAME
Since the argument is not optional the pre-condition of this routine is merely true.
post size(res) = 0 and index_lib(res) = lib
This routine creates an empty string which is in the given culture, encoding and repertoire.
This creation routine returns a single element string containing the charecter given which is to be treated as though it is in the given repertoire and encoding.
create7(ch : CHAR, lib : LIBCHARS) res : SAME
Since neither argument is optional, the pre-condition of this routine is merely true.
post size(res) = 1 and res(1) = ch and index_lib(res) = lib
This routine returns the single element string in the given encoding and repertoire.
Although this feature actually creates a new immutable string, this is really a conversion operation since the two strings have identical content and cultural context.
from_fstr(fast_str : FSTR) res : SAME
Since the argument is not optional (although it may be the empty string) this pre-condition is vacuously true.
post FSTR.index_lib(fast_str) = index_lib(res) and len res = len fast_str and forall idx | idx in set inds fast_str & fast_str(idx) = res(idx)
This routine converts the argument (mutable) string into the immutable form. The contents of both are the identical sequence of characters.
This feature is provided for symmetry with the RUNES class (qv). It returns the character at the indicated index.
char(self : SAME, index : CARD) res : CHAR
pre index < len self
post res = self(index)
This routine returns the value of the character at the given index. It is a synonym for aget.
This feature provides a means by which the cultural context of a string may be converted to the one described by the given argument.
convert(self : SAME, lib : LIBCHARS) res : [SAME]
Since the arguments are not optional then the pre-condition is vacuously true.
post (res = nil) or let to_map : CODE_MAPPER = CODE_CONVERTER.map(CULTURE.kind(LIBCHARS.cult(index_lib)), from_map : CODE_MAPPER = CODE_CONVERTER.map(CULTURE.kind(LIBCHARS.cult(lib)) in forall ch | ch in set dom self & let ucode = CODE_MAPPER.to_unicode(to_map,CHAR_CODE.create(ch,index_lib)) in CODE_MAPPER.from_unicode(from_map,ucode) <> nil
This routine returns a new string in the given encoding and repertoire with the identical character contents to self. If any character of self has no corresponding code in the target culture then void is returned.
This iter is provided to enable splitting of strings which are composed of sequences of strings with the insertion of some separator. The sub-strings yielded are successive strings without separating characters. If there are two adjacent separating characters then the empty string is returned.
Note that the formal name of the iter has been changed to replace the exclamation mark iter symbol to a name acceptable to vdm tools.
split_iter(self : SAME, ch : CHAR) res : SAME
The pre-condition to all calls is vacuously true except for the history which must be the empty sequence at the initial call (only).
This post-condition makes use of the history concept from vdm++ (see the vdm dialect notes).
post let rest = [self(len history~), ..., self(len self)] in let res ^ tail = rest be st forall idx | idx in set inds res & res(idx) <> ch) and (((history~ = []) and (history = [ch] ^ res)) or ((len history > 0) and (history = history~ ^ [ch] ^ res)))
For quit actions see the specification of the quit statement.
errs QUIT : len history = len self + 1 -> quit
This iter yields successive substrings of self which are separated by the single given character. each occurrence of the separating character in self is omitted from the strings returned. Successive strings are taken from the remainder of self after the separating character at the end of the previous yield (if any) has been passed over.
This feature is provided as a complement to the one above, yielding the argument only on the first iteration, successive iterations yielding self followed by the argument. It is provided for ease in creating string lists of some kind.
separate! | ( |
str : SAME | |
: SAME |
Note that the formal name of the iter has been changed to replace the exclamation mark iter symbol to a name acceptable to vdm tools.
separate_iter(self : SAME, str : SAME) yld : SAME
Since the arguments are not optional the pre-condition is vacuously true.
This post-condition makes use of the history concept from vdm++ (see the vdm dialect notes).
post (((history~ = []) and (res = str)) or (res = self ^ str)) and (history = self)
NOTE | This is an infinite iterator and the enclosing loop must be left by some other iter! |
On the first iteration this feature yields the string argument. On successive iterations it yields self followed by the argument.
![]() |
Language Index | ![]() |
Library Index | ![]() |
Text Index |
Comments
or enquiries should be made toKeith Hopper. Page last modified: Monday, 26 March 2001. |
![]() |