![]() |
Section 8.17.3.6:
|
![]() |
types SAME = FRUNES ; FRUNES = seq of RUNE
This class implements the concept of a fast (mutable) text string - in this particular case a string of characters each having a single encoding.
The following features are required to be implemented for this class in accordance with the specifications given in $FTEXT_STRING{RUNE,STR,FSTR} :-
The following features are required to be implemented for this class in accordance with the specifications given in the abstract class $FTEXT_STRING :-
The following features are required to be implemented for this class in accordance with the specifications given in $FSTRINGS :-
The following features are required to be implemented for this class in accordance with the specifications given in $BINARY :-
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 specifications given in $FLISTS :-
The following features are required to be implemented for this class in accordance with the specification given in $LISTS{RUNE} from which this class inherits :-
The following features are required to be implemented for this class in accordance with the specification given in $ARR{RUNE} 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{RUNE} from which this class inherits :-
The following features are required to be implemented for this class in accordance with the specification given in $CONTAINER{RUNE} from which this class inherits :-
The following features are required to be implemented for this class in accordance with the specification given in $FILTERS{RUNE} from which this class inherits :-
The following feature is required to be implemented for this class in accordance with the specification given in $ELT{RUNE} 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 $ELT{RUNE} 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 $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 feature returns the string formed by appending the contents of the named file to the current contents of self. Any file problem results in an exception being raised.
append_file | ( |
name : STR | |
) : SAME |
append_file(self : SAME, name : STR) res : [SAME]
Since this feature is defined (below) to raise an exception if there is a problem in accessing the named file, the pre-condition may be vacuously true.
post let fpath : FILE_PATH = FILE_PATH::create(name) in ((fpath = nil) and (res = nil)) or (let fyle = TEXT_FILE.open_for_read(name) in let contents : SAME = TEXT_FILE.frunes(fyle) in res = self ^ contents)
This exception mechanism uses the raise statement (feature) of Sather.
errs FILE_ERROR : (fyle = nil) or TEXT_FILE.error(fyle) -> raise fyle
This routine opens the file which has the given name. If this is successful then the contents of the file are appended to self which is returned after closing the file.
NOTE | If there is a file reading error then an exception is raised! |
This feature returns the string formed by appending the indicated sub-string of the contents of the named file to the current contents of self. Any file problem results in an exception being raised.
append_file_range | ( |
name : STR, | |
start_position : CARD, | |
count : CARD | |
) : SAME |
append_file_range(self : SAME, name : STR, start_position : CARD, count : CARD) res : [SAME]
Since this feature is defined (below) to raise an exception if there is a problem in accessing the named file, the pre-condition may be vacuously true.
post let fpath : FILE_PATH = FILE_PATH::create(name) in ((fpath = nil) and (res = nil)) or (let fyle = TEXT_FILE.open_for_read(name) in let contents : SAME = TEXT_FILE.frunes(fyle) in res = self ^ contents(start_position, ..., (start_position + count)))
This exception mechanism uses the raise statement (feature) of Sather.
errs FILE_ERROR : (fyle = nil) or (TEXT_FILE.error(fyle) -> raise fyle
This routine opens the file which has the given name. If this is successful then the indicated substring of the file contents are appended to self which is returned after closing the file.
NOTE | If there is a file reading error then an exception is raised! |
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.
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 : STR) yld : STR
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.
This feature is the only case in which an implied knowledge of storage is needed. It is the equivalent of aset, but, since the element to be set may have more encodings than the element it replaces it is necessary to return what could well be a new string capable of holding the existing contents minus the replaced element plus the replacing element.
vset(self : SAME, index : CARD, elem : RUNE) res : SAME
pre index < len self
post len self = len res and let head : seq of RUNE, item : RUNE, tail : seq of RUNE be st len head = index and head ^ [item] ^ tail = self in res = head ^ [elem] ^ tail
This feature is the indexing facility for the case where the number of codes in elem is different from the number currently at that index position in the string. A new rune string has to be produced if the resulting length is different from that currently allocated.
This feature creates an immutable rune string - a counterpart to the str feature in FSTR.
runes(self : SAME) res : RUNES
Since the self argument is not optional, this pre-condition is vacously true.
post let buff : seq of RUNE be st buff = self in (res = buff)
This feature creates and returns an immutable rune string.
![]() |
Language Index | ![]() |
Library Index | ![]() |
Text Index |
Comments
or enquiries should be made toKeith Hopper. Page last modified: Thursday, 5 April 2001. |
![]() |