![]() |
Section 8.3.1.1:
|
![]() |
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 ; $CODE_MAPPER = set of object_type ; object_type = map token to token state references : $CODE_MAPPER inv ref_types == forall obj | obj in set ref_types & sub_type($CODE_MAPPER,obj)
NOTE | See the important note about vdm state in the notes on vdm-sl usage in this specification. |
This abstract class models concept of a one-to-one bijective map (table) between encodings which are not Unicode and Unicode encoding itself. This implies that only those encodings for which there is a forward mapping to Unicode have reverse mappings from Unicode.
Note that for formal modelling purposes the codes are treated merely as tokens.
This feature creates a new empty map for conversion between the given code kind and Unicode.
create | ( |
kind : CODE_KINDS | |
) : SAME |
create(kind : CODE_KINDS) res : SAME
Since this is a creation operation and the argument is no optional, this pre-condition is vacuously true.
post kind(res) = kind
This feature creates an empty mapper object for the code kind indicated.
This feature creates a new empty map for conversion between the given code kind and Unicode.
create | ( |
kind : CODE_KINDS | |
path : FILE_PATH | |
) : SAME |
create2(kind : CODE_KINDS, fpath : FILE_PATH) res : [SAME]
Since this is a creation operation and both the arguments are not optional, this pre-condition is vacuously true.
Since this is an abstraction, ther can be no more precise post-condition than that given since in general the size of the map is not determinable until a program executes.
post (kind(res) = kind and card dom res > 0) or res = nil
This feature creates a new mapper from the contents of the indicated file. If there is a problem in accessing the file or the file is not a valid map file then the routine returns void.
This feature returns the kind of encoding for which this map serves.
kind(self : SAME) res : CODE_KINDS
Since the self argument is not optional, then this pre-condition is vacuously true.
post create(res) = self
This feature returns the kind of code for which this map may be used.
This feature returns the character code resulting from applying the reverse of this map to the argument code.
from_unicode(ch_code : CHAR_CODE) res : CHAR_CODE
pre kind(self) = CULTURE.kind(LIBCHARS.culture(CHAR_CODE.lib(ch_code)))
post self(res) = ch_code or res = CHAR_CODE.nil
This feature convert the single code given as a Unicode code into the encoding used in this mapping table if such a value exists, otherwise returning CHAR_CODE::nil.
This feature returns the character code (encoded in Unicode) resulting from applying this map to the argument code.
to_unicode(ch_code : CHAR_CODE) res : CHAR_CODE
pre kind(self) = CULTURE.kind(LIBCHARS.culture(CHAR_CODE.lib(ch_code)))
post res = self(ch_code) or res = CHAR_CODE.nil
This feature convert the single code given into the corresponding Unicode encoding using this mapping table.
![]() |
Language Index | ![]() |
Library Index | ![]() |
Codes Index |
Comments
or enquiries should be made toKeith Hopper. Page last modified: Thursday, 26 April 2001. |
![]() |