![]() |
Section 8.17.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 ; $CHAR_TP = set of Object_Type Object_Type = seq1 of CHAR_CODE ; state multi : $CHAR_TP inv multi_types == forall obj in set multi_types & sub_type($CHAR_TP,obj)
NOTES | 1. See the important note about vdm state in the notes on vdm-sl usage in this specification. |
2. The vdm type Object_Type is defined solely in order to be able to specify the iterators at the end of this class definition. It is otherwise not used. |
This abstraction models the semantic notion of a character, ascribing to it all of those features which are not dependent upon any particular form of representation. One additional feature is, however, modelled - that a character is represented by one or more encodings - the class CHAR_CODE.
A character is created by this routine from the given code - which may be considered as some bit-pattern. The character, however, has all of the semantics associated with characters in human communication.
create(ch_code : CHAR_CODE) res : SAME
pre not UNICODE.is_combining(UNICODE.create(CHAR_CODE.card(code)))
post code(res,CHAR_CODE.lib(ch_code)) = ch_code
This routine creates a character from a single character code - which must not be a combining code as specified in ISO/IEC 10646-1:2000.
A character is created by this routine from the given control function name (as a code) - which may be considered as some bit-pattern. The resultant pseudo-character, however, has semantics associated with that control function in a rendering engine dependent manner. The given repertoire and encoding is needed to convert the bit-pattern of a control code into an appropriate pattern for the culture concerned. These differ principally in the number of bits needed.
create | ( |
function : CONTROL_CODES, | |
lib : LIBCHARS | |
) : SAME |
create2(function : CONTROL_CODES, lib : LIBCHARS) res : SAME
Since this is a creation routine with a larger range than the domain of control codes, the pre-condition is vacuously true.
post CONTROL_CODES.create(CHAR_CODE.card(code(res,CHAR_CODE.lib(code)))) = function
This routine creates a 'character' from the given control function name and repertoire and encoding. The result is a pseudo-character which may be interpreted in some rendering engine specific manner.
This feature returns the character equivalent of the NUL function name.
null(self : SAME) res : CHAR
pre num_codes(self) = 1
post CONTROL_CODES.create(CHAR_CODE.card(code(res))) = CONTROL_CODES.NUL
This routine returns the single coding character in which the bit-pattern is the same as that of the control code (function) called NUL.
Providing that self consists of only a single encoding this routine returns the corresponding single code character.
char(self : SAME) res : CHAR
pre num_codes(self) = 1
post create(code(res)) = self
This routine returns the single coding character corresponding to self.
This is the first of two features which convert self into a character code - providing that it consists of only one encoding.
code(self : SAME, lib : LIBCHARS) res : CHAR_CODE
pre num_codes(self) = 1
post create(res) = self
This routine returns the encoding corresponding to the single element of self, using the given encoding and repertoire.
This version of the conversion feature for turning self into a character code makes use of the default execution environment encoding and repertoire.
code2(self : SAME) res : CHAR_CODE
pre num_codes(self) = 1
post create(res) = self
This routine returns the encoding corresponding to the single element of self, using the default execution environment encoding and repertoire.
This is the first of two features which convert self into a rune (which may have multiple encodings).
rune(self : SAME, lib : LIBCHARS) res : RUNE
Since the range of the result is at least as large as the domain of self, the pre-condition is vacuously true.
post self = create(code(res))
This routine returns the encoding corresponding to the single element of self, using the given encoding and repertoire.
This version of the conversion feature for turning self into a rune makes use of the default execution environment encoding and repertoire.
rune2(self : SAME) res : RUNE
Since the range of the result is at least as large as the domain of self, the pre-condition is vacuously true.
post create(res) = self
This routine returns the rune corresponding to the single element of self, using the default execution environment encoding and repertoire.
This feature returns true if and only if self is a letter as defined in the given encoding and repertoire.
is_alpha(self : SAME, lib : LIBCHARS) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This predicate returns true if and only if self is a member of the value domain of letters as specified for the given encoding and repertoire.
This version of the predicate returns true if self is a letter in the default execution environment.
is_alpha2(self : SAME) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This routine returns true if and only if the values of self is a member of the domain of letters as defined in the default execution environment.
This feature returns true if and only if self is an upper case letter as defined in the given encoding and repertoire.
is_upper(self : SAME, lib : LIBCHARS) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This predicate returns true if and only if self is a member of the value domain of upper case letters as specified for the given encoding and repertoire.
This version of the predicate returns true if self is an upper case letter in the default execution environment.
is_upper2(self : SAME) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This routine returns true if and only if the value of self is a member of the domain of upper case letters as defined in the default execution environment.
This feature returns true if and only if self is an upper case letter and has a corresponding lower case letter as defined in the given encoding and repertoire.
is_downmapped | ( |
lib : LIBCHARS | |
) : BOOL |
is_downmapped(self : SAME, lib : LIBCHARS) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
post let loc_map : map CHAR_MAPPINGS to CHAR_MAP be st loc_map = CHAR_TYPES.mappings(CULTURE.char_data(LIBCHARS.culture(lib))) in let chmap : CHAR_MAP = loc_map(CHAR_MAPPINGS.Lower) in res = is_lower(self) and CHAR_MAP.is_mapped(chmap)
This predicate returns true if and only if self is a member of the value domain of upper case letters as specified for the given encoding and repertoire and has a defined lower case mapping.
This version of the predicate returns true if self is an upper case letter and has a corresponding lower case letter in the default execution environment.
is_downmapped2(self : SAME) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
post res = is_downmapped(self,LIBCHARS.default)
This routine returns true if and only if the value of self is an upper case letter as defined in the default execution environment and there is a corresponding lower case letter.
This feature returns true if and only if self is a lower case letter as defined in the given encoding and repertoire.
is_lower(self : SAME, lib : LIBCHARS) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This predicate returns true if and only if self is a member of the value domain of lower case letters as specified for the given encoding and repertoire.
This version of the predicate returns true if self is a lower case letter in the default execution environment.
is_lower2(self : SAME) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This routine returns true if and only if the value of self is a member of the domain of lower case letters as defined in the default execution environment.
This feature returns true if and only if self is a lower case letter and has a corresponding upper case letter as defined in the given encoding and repertoire.
is_upmapped | ( |
lib : LIBCHARS | |
) : BOOL |
is_upmapped(self : SAME, lib : LIBCHARS) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
post let loc_map : map CHAR_MAPPINGS to CHAR_MAP be st loc_map = CHAR_TYPES.mappings(CULTURE.char_data(LIBCHARS.culture(lib))) in let chmap : CHAR_MAP = loc_map(CHAR_MAPPINGS.Upper) in res = is_lower(self) and CHAR_MAP.is_mapped(chmap)
This predicate returns true if and only if self is a member of the value domain of lower case letters as specified for the given encoding and repertoire and has a defined upper case mapping.
This version of the predicate returns true if self is a lower case letter and has a corresponding upper case letter in the default execution environment.
is_upmapped2(self : SAME) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
post res = is_upmapped(self,LIBCHARS.default)
This routine returns true if and only if the values of self is a lower case letter as defined in the default execution environment and there is a corresponding upper case letter.
This feature returns true if and only if self is an octal digit as defined in the given encoding and repertoire.
is_octal_digit | ( |
lib : LIBCHARS | |
) : BOOL |
is_octal_digit(self : SAME, lib : LIBCHARS) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This predicate returns true if and only if self is a member of the value domain of octal digit characters as specified for the given encoding and repertoire.
This version of the predicate returns true if self is an octal digit in the default execution environment.
is_octal_digit2(self : SAME) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This routine returns true if and only if the value of self is a member of the domain of octal digit characters as defined in the default execution environment.
This feature returns true if and only if self is a decimal digit as defined in the given encoding and repertoire.
is_digit(self : SAME, lib : LIBCHARS) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This predicate returns true if and only if self is a member of the value domain of decimal digit characters as specified for the given encoding and repertoire.
This version of the predicate returns true if self is a decimal digit in the default execution environment.
is_digit2(self : SAME) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This routine returns true if and only if the value of self is a member of the domain of decimal digit characters as defined in the default execution environment.
This feature returns true if and only if self is a hexadecimal digit as defined in the given encoding and repertoire.
is_hex_digit | ( |
lib : LIBCHARS | |
) : BOOL |
is_hex_digit(self : SAME, lib : LIBCHARS) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This predicate returns true if and only if self is a member of the value domain of hexadecimal digit characters as specified for the given encoding and repertoire.
This version of the predicate returns true if self is a hexadecimal digit in the default execution environment.
is_hex_digit2(self : SAME) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This routine returns true if and only if the value of self is a member of the domain of hexadecimal digit characters as defined in the default execution environment.
This feature returns true if and only if self is a number character as defined in the given encoding and repertoire. Note, particularly, that while this domain will usually include decimal digits that it is not restricted to characters which may be converted directly to numbers and used in arithmetic operations.
is_numeric | ( |
lib : LIBCHARS | |
) : BOOL |
is_numeric(self : SAME, lib : LIBCHARS) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This predicate returns true if and only if self is a member of the value domain of number characters as specified for the given encoding and repertoire.
This version of the predicate returns true if self is a number character in the default execution environment. Note, particularly that characters which belong to this group will almost certainly include, but by no means be restricted to those which may take part in arithmetic operations.
is_numeric2(self : SAME) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This routine returns true if and only if the value of self is a member of the domain of number characters as defined in the default execution environment.
This feature returns true if and only if self is an alpha-numeric character as defined in the given encoding and repertoire. Note, particularly, that while this domain will usually include characters of the classes alpha and digits, it may not be assumed that such characters are the only members of this class domain.
is_alphanum | ( |
lib : LIBCHARS | |
) : BOOL |
is_alphanum(self : SAME, lib : LIBCHARS) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This predicate returns true if and only if self is a member of the value domain of alpha-numeric characters as specified for the given encoding and repertoire.
This version of the predicate returns true if self is an alpha-numeric character in the default execution environment. Note, particularly that characters which belong to this group will almost certainly include, but by no means be restricted to, characters belonging to the classes alpha and digit.
is_alphanum2(self : SAME) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This routine returns true if and only if the value of self is a member of the domain of alpha-numeric characters as defined in the default execution environment.
This feature returns true if and only if self is a white space character as defined in the given encoding and repertoire. Note, particularly, that this class may include control function name codes.
is_space(self : SAME, lib : LIBCHARS) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This predicate returns true if and only if self is a member of the value domain of space characters (characters which, when rendered, occupy space in the image but have no visible glyph) as specified for the given encoding and repertoire.
This version of the predicate returns true if self is a white space character which has no visible mark in the default execution environment. Note, particularly that characters which belong to this group may include control function name codes.
is_space2(self : SAME) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This routine returns true if and only if the value of self is a member of the domain of space characters (characters which occupy space when rendered but do not have a visible glyph) as defined in the default execution environment.
This feature returns true if and only if self is a character which, when rendered is visible as defined in the given encoding and repertoire.
is_print(self : SAME, lib : LIBCHARS) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This predicate returns true if and only if self is a member of the value domain of characters which, when rendered, have a visible image as specified for the given encoding and repertoire.
This version of the predicate returns true if self is a character which has a visible mark when rendered in the default execution environment.
is_print2(self : SAME) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This routine returns true if and only if the value of self is a member of the domain of characters which, when rendered, have a visible glyph as defined in the default execution environment.
This feature returns true if and only if self is a character which is defined as a punctuation mark in the given encoding and repertoire. Note that, while this will not includes characters detected as being letter, numbers and whitespace using the predicates above, it will not necessarily include all other visible characters.
is_punct(self : SAME, lib : LIBCHARS) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This predicate returns true if and only if self is a member of the domain of characters which are defined as punctuation marks for the given encoding and repertoire.
This version of the predicate returns true if self is a character which is defined as a punctuation mark in the default execution environment. Note that while this will not include letters, numbers and spcae as detected using the above predicates, there may be other visible characters which are not in this domain.
is_punct2(self : SAME) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This routine returns true if and only if the value of self is a member of the domain of characters which are defined as punctuation marks in the default execution environment.
This routine returns true if self is the code name of a control function in the given encoding and repertoire. Note that all internationally standardised encodings have the identical code names as defined by ISO 636. (see also the library class CONTROL_CODES).
is_control | ( |
lib : LIBCHARS | |
) : BOOL |
is_control(self : SAME, lib : LIBCHARS) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This predicate returns true if and only if self is a member of the domain of characters which are defined as punctuation marks for the given encoding and repertoire.
This version of the predicate returns true if self is the code name of a control function in the default encoding and repertoire. Note that all internationally standardised encodings have the identical code names as defined by ISO 636.
is_control2(self : SAME) res : BOOL
Since this feature is a predicate, the pre-condition is vacuously true.
Since this feature is a predicate, the post-condition also is vacuously true.
This routine returns true if and only if the value of self is the code name of a control function in the default execution environment.
This routine returns the count of encodings in self. As given in ISO/IEC 10646, this will not exceed six.
num_codes(self : SAME) res : CARD
Since the range of the result is greater than the range of components, the pre-condition is vacuously true.
post res > 0 and res <= 6
This routine returns the count of the number of encodings in self.
This routine returns the upper case character corresponding to self if this exists, otherwise self. Note that there is not necessarily an upper case letter corresponding to every lower case letter (for example in the ISO 8859-1 encoding the letter "ß" is lower case but has no single character upper case equivalent).
upper(self : SAME, lib : LIBCHARS) res : SAME
Since this feature is a predicate, the pre-condition is vacuously true.
post lower(res,lib) = self) or res = self
This routine returns the upper case character corresponding to self if it exists, otherwise self.
This routine returns the upper case character corresponding to the given lower case letter if this exists, otherwise self.
upper | : SAME |
upper2(self : SAME) res : SAME
Since the domain of self and of other are identical, the pre-condition is vacuously true.
post lower(res) = self) or res = self
This routine returns the upper case character corresponding to self in the default encoding and repertoire, provided that self is a lower case letter - otherwise self is returned.
This routine returns the lower case character corresponding to self if this exists, otherwise self. Note that there is not necessarily a lower case letter corresponding to every upper case letter.
lower(self : SAME, lib : LIBCHARS) res : SAME
Since this feature is a predicate, the pre-condition is vacuously true.
post upper(res,lib) = self) or res = self
This routine returns the lower case character corresponding to self if it exists, otherwise self.
This routine returns the lower case character corresponding to the given upper case letter if this exists, otherwise self.
lower | : SAME |
lower2(self : SAME) res : SAME
Since the domain of self and of other are identical, the pre-condition is vacuously true.
post upper(res) = self) or res = self
This routine returns the lower case character corresponding to self in the default encoding and repertoire, provided that self is an upper case letter and the equivalent character is mapped - otherwise self is returned.
This routine returns the numeric value represented by self as an octal digit in the given repertoire and encoding.
octal_digit_value | ( |
lib : LIBCHARS | |
) : SAME |
octal_digit_value(self : SAME, lib : LIBCHARS) res : CARD
Since the operation is defined over all possible argument values then this pre-condition is vacuously true.
post (is_octal_digit(self,lib) and create(CHAR_CODE.create(res,lib),lib) = self) or res = CARD.nil
This routine returns the numeric value corresponding to self, provided that it is an octal digit, otherwise CARD::maxval.
This routine returns the numeric value represented by self, if self is an octal digit.
octal_digit_value2(self : SAME) res : CARD
Since the operation is defined over all possible argument values then this pre-condition is vacuously true.
post (is_octal_digit(self) and create(CHAR_CODE.create(res)) = self) or res = CARD.nil
This routine returns the numeric value which is represented by the octal digit character self if this exists, otherwise CARD::maxval.
This routine returns the numeric value represented by self as a decimal digit in the given repertoire and encoding.
digit_value | ( |
lib : LIBCHARS | |
) : SAME |
digit_value(self : SAME, lib : LIBCHARS) res : CARD
Since the operation is defined over all possible argument values then this pre-condition is vacuously true.
post (is_digit(self,lib) and create(CHAR_CODE.create(res,lib),lib) = self) or res = CARD.nil
This routine returns the numeric value corresponding to self, provided that it is a decimal digit, otherwise CARD::maxval.
This routine returns the numeric value represented by self, if self is a decimal digit.
digit_value2(self : SAME) res : CARD
Since the operation is defined over all possible argument values then this pre-condition is vacuously true.
post (is_digit(self) and create(CHAR_CODE.create(res)) = self) or res = CARD.nil
This routine returns the decimal numeric value of the digit which is represented by the character self if this exists, otherwise CARD::nil..
This routine returns the numeric value represented by self as a hexa-decimal digit in the given repertoire and encoding.
hex_digit_value | ( |
lib : LIBCHARS | |
) : SAME |
hex_digit_value(self : SAME, lib : LIBCHARS) res : CARD
Since the operation is defined over all possible argument values then this pre-condition is vacuously true.
post (is_hex_digit(self,lib) and create(CHAR_CODE.create(res,lib),lib) = self) or res = CARD.nil
This routine returns the numeric value corresponding to self, provided that it is a hexa-decimal digit, otherwise CARD::nil.
This routine returns the numeric value represented by self, if self is a hexa-decimal digit.
hex_digit_value2(self : SAME) res : CARD
Since the operation is defined over all possible argument values then this pre-condition is vacuously true.
post (is_hex_digit(self) and create(CHAR_CODE.create(res)) = self) or res = CARD.nil
This routine returns the hexa-decimal numeric value of the digit which is represented by the character self if this exists, otherwise CARD::nil.
This iter yields successive encodings of self in the given encoding and repertoire.
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.
code_iter(self : SAME, lib : LIBCHARS) res : CHAR_CODE
Since neither of the arguments is optional, then this 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 = self(1) and history = [res]) or (res = self(len history) and history = history~ ^ res)
For quit actions see the specificatiion of the quit statement.
errs QUIT : len history = len self -> quit
This iter yields successive encodings of self in the given encoding and repertoire.
This iter yields successive encodings of self in the default execution environment encoding and repertoire.
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.
code2_iter(self : SAME) res : CHAR_CODE
Since neither of the arguments is optional, then this 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 = self(1) and history = [res]) or (res = self(len history) and history = history~ ^ res)
For quit actions see the specificatiion of the quit statement.
errs QUIT : len history = len self -> quit
This iter yields successive encodings of self in the default execution environment encoding and repertoire.
![]() |
Language Index | ![]() |
Library Index | ![]() |
Text Index |
Comments
or enquiries should be made toKeith Hopper. Page last modified: Friday, 4 May 2001. |
![]() |