![]() |
Section 8.1.1.7: |
![]() |
This abstract class defines a state component which is a set of all instantiations of objects of any class sub-typing from this class in addition to the vdm model types used wherever this class name is used. Note that SAME has to be an instantiated class, not an abstract one.
types SAME = object_type ; $TEXT = set of object_type state multi : $TEXT inv multi_types == forall obj in set multi_types & sub_type($TEXT,obj)
NOTE | See the important note about vdm state in the notes on vdm-sl usage in this specification. |
This abstract class models the concept of a claass which can convert a text string into a value of the class. It provides the two features defined below.
This feature is required for any sub-type of this abstract class. It provides a mechanism for creating a value of the class from a character string cursor.
build | ( |
cursor : STR_CURSOR | |
) : SAME |
build(self : SAME, cursor : STR_CURSOR) res : [SAME]
pre not STR_CURSOR.is_done(cursor)
If the indicated text string does not have a valid representation of an object of the sub-typing class then nil should be returned and the cursor argument not be altered.
post ((cursor = cursor~) and (res = nil)) or res <> nil
This returns a new object which has been converted from the given textual representation using the repertoire and encoding of the text string (see class STR) to which the cursor belongs provided that the string is a valid textual representation of the class defining this feature, otherwise the cursor has not been moved and void is returned.
NOTE | The return of void is the Sather equivalent of the vdm-sl value 'nil'. Although the situation giving rise to the nil is defined as corresponding to the inability to carry out the conversion, this is different from the vdm-sl concept of error which is more closely related to the Sather exception concept. |
This creation routine takes a string of text and returns a value in the class (or nil!).
create(self : SAME, instr : STR) res : [SAME]
pre STR.size(instr) > 0
If the indicated text string does not have a valid representation of an object of the sub-typing class then nil shall be returned.
post str(res) = instr or res = nil
This returns a new object which has been converted from the given text string. If the argument is not a valid text representation of a value of the class void is returned.
NOTE | The return of void is the Sather equivalent of the vdm-sl value 'nil'. Although the situation giving rise to the nil is defined as corresponding to the inability to carry out the conversion, this is different from the vdm-sl concept of error which is more closely related to the Sather exception concept. |
![]() |
Language Index | ![]() |
Library Index | ![]() |
Basic Index |
Comments or enquiries should be made to
Keith
Hopper. Page last modified: Wednesday, 30 May 2001. |
![]() |