![]() |
Section 8.17.3.2:
|
![]() |
types SAME = FSTR ; FSTR = seq of CHAR
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{CHAR,STR,FSTR} :-
The following features are required to be implemented for this class in accordance with the specifications given in $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{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 $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 $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.fstr(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.fstr(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.
![]() |
Language Index | ![]() |
Library Index | ![]() |
Text Index |
Comments
or enquiries should be made toKeith Hopper. Page last modified: Monday, 26 March 2001. |
![]() |