![]() |
Section 8.3.2.4:
|
![]() |
types SAME = CHAR_CODE ; CHAR_CODE = token ;
This class implements the concept of a character encoding which is applicable to a given culture.
The following feature is required to be implemented for this class in accordance with the specification given in $IS_EQ :-
The following feature is required to be implemented for this class in accordance with the specification given in $IS_LT{CHAR_CODE} :-
The following feature is required to be implemented for this class in accordance with the specification given in $IS_NILof which $NIL is a sub-type :-
The following feature is required to be implemented for this class in accordance with the specification given in $NIL :-
The following features are required to be implemented for this class in accordance with the specifications given by inheritance in $STR of which $TEXT} is a sub-type :-
The following feature is required to be implemented for this class in accordance with the specification given in $HASH :-
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 specifications given in $INSTR of which $TEXT is a sub-type :-
This class has the following three reader routines -
This version of a building feature takes the appropriate number of octets from the binary cursor buffer (defined in the lib argument) and returns the corresponding character code. It is provided for use in situations where the binary representation of a number of character codes in the same encoding is needed. The encoding can then be used once (separately) for the whole sequence.
raw_build | ( |
cursor : BIN_CURSOR | |
lib : LIBCHARS | |
) : SAME |
raw_build(cursor : BIN_CURSOR, plib : LIBCHARS) res : SAME
pre not BIN_CURSOR.is_done(cursor)
post let loc_res : seq of OCTET be st loc_res = res in let loc_buff = BIN_CURSOR.buffer(cursor), loc_idx = BIN_CURSOR.index(cursor) in LIBCHARS.my_size(plib) = len loc_res and loc_res = loc_buff((loc_idx - len loc_res), ..., loc_idx)
This routine creates a character code object from the binary string indicated by the cursor, in the given repertoire and encoding (which is not contained in the binary string)!
This predicate returns true if and only if the given numeric argument is a valid bit-pattern for a character encoding in the given culture.
is_valid(val : CARD, plib : LIBCHARS) res : SAME
Since this operation is a predicate then this pre-condition is vacuously true.
Note that this post-condition performs an abstract character code creation in order to determine if the result is in the domain of the character repertoire. Such an operation could not be performed in general with executable code. It is used solely for specification purposes.
post let loc_ch = create2(val,lib) in res = (loc_ch in set dom CULTURE.rep_map(LIBCHARS.culture(plib)))
This predicate returns true if and only if the bit-pattern of the numeric argument forms a valid character code in the given cultural repertoire.
This feature creates a character code from the given binary string. There should be no cultural indicator(s) in the binary string which is expected to ba a 'raw' bit-patterns containing exactly the number of octets specified by the lib argument.
create(str : BINSTR, plib : LIBCHARS) res : SAME
pre len str = LIBCHARS.my_size(plib)
post let loc_res : seq of OCTET be st loc_res = res in loc_res = str and lib(res) = plib
This feature creates a code object from the given binary string which contains no culture-defining component(s).
This feature creates a character code from the given numeric value, used as a bit-pattern.
create2(val : CARD, plib : LIBCHARS) res : SAME
pre is_valid(val, plib)
post let loc_res : seq of OCTET be st loc_res = res in loc_res = CARD.binstr(val)(1, ..., LIBCHARS.my_size(plib)) and lib(res) = plib
This feature creates a new character code which has the bit-pattern representation which is the same as the value given.
This feature creates a character code from the given character which is assumed to be a correct value for the encoding and repertoire specified by the lib argument. This assumption cannot in general be proved!
create3(ch : CHAR, plib : LIBCHARS) res : SAME
Since neither argument is optional then this pre-condition is vacuously true.
post let loc_res : seq of OCTET be st loc_res = res in loc_res = CHAR.binstr(ch)(1, ..., LIBCHARS.my_size(plib)) and lib(res) = plib
This feature creates a new character code which has the bit-pattern representation which is the same as the value given.
This predicate returns true only if self is a combvining code as defined in ISO/IEC 10646-1:2000 (see also Unicode version 3.1)
is_combining(self : SAME) res : BOOL
Since this feature is a predicate and the argument is not optional then this pre-condition is vacuously true.
post res = (self in set dom UNICODE.Combining)
This predicate returns true if and only if self is a combining encoding in the Unicode domain.
This feature corresponds to the 'raw' building routine, the result having no cultural coding, etc information.
raw_binstr(self : SAME) res : BINSTR
Since the argument is not optional then this pre-condition is vacuously true.
post build(res,lib) = self
This feature returns the binary string representation of self which contains no encoding or re[ertoire information.
This feature produces the cardinal number represented by the encoding of this character.
card(self : SAME) res : CARD
Since the argument is not optional then this pre-condition is vacuously true.
post create(res,lib) = self
This feature returns the cardinal number which is represented by the encoding of this character code.
This feature produces the character corresponding to self as a charcater code. Doing this results in dissociating the cultural data from the character.
char(self : SAME) res : CHAR
Since the argument is not optional then this pre-condition is vacuously true.
The use of this routine results in the loss of associated cultural information.
post create(res,lib) = self
This feature returns the character, the encoding of which is represented by self.
This feature produces the singly coded rune corresponding to self as a charcater code.
rune(self : SAME) res : RUNE
Since the argument is not optional then this pre-condition is vacuously true.
post create(res,lib) = self
This feature returns the rune, the single encoding of which is represented by self.
This successor routine is provided to enable simple sequential character encoding operations to be carried out. Note that the successor of the bit-pattern with the highest number of bits set (as defined in the Unicode standard) is that with no bits set as the semantics attributed are those of the closed field class FIELD.
next | : SAME |
next(self : SAME) res : SAME
Since the argument is not optional then this pre-condition is vacuously true.
The use of this routine results in the loss of associated cultural information.
post let loc_max = UNICODE.card(UNICODE.Invalid) - 1 in ((card(self) = loc_max) and (card(res) = 0)) or card(res) = card(self) + 1
This routine returns a new character code the corresponding cardinal number for which is offset by the given argument count.
offset(self : SAME, cnt : INT) res : SAME
pre let loc_max = UNICODE.card(UNICODE.Invalid) - 1 in let loc_res = cases : (card(self) + cnt > loc_max) -> card(self) - loc_max + cnt, (card(self) + cnt < 0) -> card(self) + loc_max + cnt, others -> card(self) + cnt end in UNICODE.create(loc_res) in set dom UNICODE.Code_Groups
post let loc_max = UNICODE.card(UNICODE.Invalid) - 1 in ((card(self) + cnt > loc_max) and (card(res) = card(self) + cnt - loc_max)) or ((card(self) + cnt < 0) and (card(res) = card(self) + loc_max + cnt)) or card(res) = card(self) + cnt
This routine returns the ccharaccter code which is count positions before/after self provided that such a code exists.
This iter yields in sequence the individual octets which make up self - from the most significant group of eight downwards.
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.
octet_iter(self : SAME) res : OCTET
pre len history mod 8 = 0
This post-condition makes use of the history concept from vdm++ (see the vdm dialect notes).
post let loc_res : seq of BIT be st (res = loc_res and len loc_res = 8) in let loc_size = LIBCHARS.my_size(lib(self)) in ((history~ = [] and (history = loc_res)) or (history = history ^ loc_res)) and loc_res = self((loc_size - len history), ..., (loc_size - len history~))
For quit actions see the specification of the quit statement.
errs QUIT : len history~ = len self -> quit
This iter yields in turn the sequence of octets making up self, starting with the most significant group of eight bits.
This iter yields in sequence cnt individual octets which make up self - finishing with the least significant group of eight.
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.
octet_iter2(self : SAME, cnt : CARD) res : OCTET
pre len history mod 8 = 0 and (cnt <= LIBCHARS.my_size(lib(self)))
This post-condition makes use of the history concept from vdm++ (see the vdm dialect notes).
post let loc_res : seq of BIT be st (loc_res = res and len loc_res = 8) in ((history~ = [] and (history = loc_res)) or (history = history ^ loc_res)) and loc_res = self((cnt - len history), ..., (loc_size - len history~))
For quit actions see the specification of the quit statement.
errs QUIT : len history~ = len self -> quit
This iter yields in turn a sequence of cnt octets making up self, ending with the least significant group of eight bits.
![]() |
Language Index | ![]() |
Library Index | ![]() |
Codes Index |
Comments
or enquiries should be made toKeith Hopper. Page last modified: Monday, 23 April 2001. |
![]() |