# Section 8.17.3.4:
RUNE

###### class RUNE < $CHAR{SAME}

#### Formal Types

types
SAME = RUNE ;
RUNE = seq1 of CHAR_CODE

This class implements the notion of a logical character which has the semantics associated with such a token in the cultural environment concerned. It is required to satisfy Level 3 conformance to ISO/IEC 10646-1:2000 as defined therein.

#### External specifications

The following feature is required to be implemented for this class in accordance with the specification given in $IS_EQ of which $CHAR{RUNE} is a sub-type :-

- is_eq(other : SAME) : BOOL

The following feature is required to be implemented for this class in accordance with the specification given in $IS_LT{RUNE} of which $CHAR{RUNE} is a sub-type :-

- is_lt(other : SAME) : BOOL

The following features are required to be implemented for this class in accordance with the specifications given by inheritance in $STR of which $CHAR{RUNE} is a sub-type :-

- str(lib : LIBCHARS) : STR
- str : STR

The following feature is required to be implemented for this class in accordance with the specification given in $HASH of which $CHAR{RUNE} is a sub-type :-

- hash : CARD

The following features are required to be implemented for this class in accordance with the specifications given in $BINARY of which $CHAR{RUNE} is a sub-type :-

- create(storage : BINSTR) : SAME
- build(cursor : BIN_CURSOR) : SAME
- read(cursor : BIN_CURSOR) : SAME
- binstr : BINSTR
- write(fyle : BIN_FILE)

The following features are required to be implemented for this class in accordance with the specifications given in $INSTR of which $CHAR{RUNE} is a sub-type :-

- build(cursor : RUNES_CURSOR) : SAME
- build(cursor : RUNES_CURSOR, lib : LIBCHARS) : SAME

The following features are required to be implemented for this class in accordance with the specifications given in $ANCHORED_FMT of which $CHAR{RUNE} is a sub-type :-

- fmt(descr : ANCHORED_DESCR) : SAME
- fmt(descr : ANCHORED_DESCR, lib : LIBCHARS) : SAME

The following features are required to be implemented for this class in accordance with the specifications given in $CHAR{RUNE} :-

- create(ch_code : CHAR_CODE) : SAME
- create(ch_code : CHAR_CODE, lib : LIBCHARS) : SAME
- char : CHAR
- code(lib : LIBCHARS) : CHAR_CODE
- code : CHAR_CODE
- rune(lib : LIBCHARS) : SAME
- rune : SAME
- is_alpha(lib : LIBCHARS) : BOOL
- is_alpha : BOOL
- is_upper(lib : LIBCHARS) : BOOL
- is_upper : BOOL
- is_lower(lib : LIBCHARS) : BOOL
- is_lower : BOOL
- is_octal_digit(lib : LIBCHARS) : BOOL
- is_octal_digit : BOOL
- is_digit(lib : LIBCHARS) : BOOL
- is_digit : BOOL
- is_hex_digit(lib : LIBCHARS) : BOOL
- is_hex_digit : BOOL
- is_numeric(lib : LIBCHARS) : BOOL
- is_numeric : BOOL
- is_alphanum(lib : LIBCHARS) : BOOL
- is_alphanum : BOOL
- is_space(lib : LIBCHARS) : BOOL
- is_space : BOOL
- is_print(lib : LIBCHARS) : BOOL
- is_print : BOOL
- is_punct(lib : LIBCHARS) : BOOL
- is_punct : BOOL
- is_control(lib : LIBCHARS) : BOOL
- is_control : BOOL
- num_codes : CARD
- upper(lib : LIBCHARS) : SAME
- upper : SAME
- lower(lib : LIBCHARS) : SAME
- lower : SAME
- octal_digit_value(lib : LIBCHARS) : CARD
- octal_digit_value : CARD
- digit_value(lib : LIBCHARS) : CARD
- digit_value : CARD
- hex_digit_value(lib : LIBCHARS) : CARD
- hex_digit_value : CARD
- code!(lib : LIBCHARS) : CHAR_CODE
- code! : CHAR_CODE

#### Reader Routine

This class has a single reader routine -

- lib : LIBCHARS - this routine returns the cultural descriptor associated with self.

#### valid

This predicate is provided in order that the validity of the 'number' as a bit-pattern for a code may be ascertained - in respect to the given encoding and repertoire.

valid | (
| num : CARD,
| lib : LIBCHARS
| ) : BOOL

##### Formal Signature

valid(num : CARD, lib : LIBCHARS) res : BOOL

##### Pre-condition

pre true

##### Post-condition

Note that where the code is to occupy eight bits only then all values are valid, but that for sixteen bit codes all values except the one with all bits set is valid - and for thirty-two bit codes only 31 bits are used and then the value with 31 bits set is not valid.

post res =
cases LIBCHARS.my_size(lib) :
1 -> num <= OCTET.Octet_Max,
2 -> num < HEXTET.Hextet_Max,
4 -> num <= QUADBITS.Quad_Max div 2
end

This routine returns true if and only if the value of num may be interpreted as a character bit-pattern valid in the given encoding and repertoire, otherwise false.

#### valid

This predicate is provided in order that the validity of the 'number' as a bit-pattern for a code may be ascertained - in respect to the default encoding and repertoire.

valid | (
| num : CARD
| ) : BOOL

##### Formal Signature

valid(num : CARD) res : BOOL

##### Pre-condition

pre true

##### Post-condition

Note that where the code is to occupy eight bits only then all values are valid, but that for sixteen bit codes all values except the one with all bits set is valid - and for thirty-two bit codes only 31 bits are used and then the value with 31 bits set is not valid.

post res =
cases LIBCHARS.my_size(LIBCHARS.default()) :
1 -> num <= OCTET.Octet_Max,
2 -> num < HEXTET.Hextet_Max,
4 -> num <= QUADBITS.Quad_Max div 2
end

This routine returns true if and only if the value of num may be interpreted as a character bit-pattern valid in the default execution environment encoding and repertoire, otherwise false.

#### convert

This routine attempts to convert self into the encoding specified by the argument if this is possible, otherwise void is returned.

convert | (
| lib : LIBCHARS
| ) : SAME

##### Formal Signature

convert(self : SAME, lib : LIBCHARS) res : [SAME]

##### Pre-condition

pre true

##### Post-condition

post convert(res,lib(self)) = self
or res = nil

This routine converts self into the encoding specified by lib - if this is possible, otherwise returning void.

#### copy

Since this 'kind' of character is not an immutable class, this copy routine is provided to aid in providing immutable semantics if desired.

copy | : SAME

##### Formal Signature

copy(self : SAME) res : SAME

##### Pre-condition

pre true

##### Post-condition

post res = self

This routine returns an exact copy of self.

#### size

This routine has the same semantics as num_codes - returning the number of codes in self.

size | : CARD

##### Formal Signature

size(self : SAME) res : CARD

##### Pre-condition

pre true

##### Post-condition

post res = len self

This routine returns the number of codes in self.

#### plus

This routine is provided for building a rune from a number of individual codes which must all be combining codes except the first.

plus | (
| code : CHAR_CODE
| ) : SAME

##### Formal Signature

plus(self : SAME, code : CHAR_CODE) res : SAME

##### Pre-condition

pre CHAR_CODE.lib = lib(self)
and CHAR_CODE.is_combining(code)

##### Post-condition

post res = self ^ code

This routine appends code to self returning the new rune formed.

| Language Index |  | Library Index |  | Text Index

Comments or enquiries should be made to Keith Hopper. Page last modified: Thursday, 23 November 2000. |