Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

kernel.unicode

Class UC_CHARACTER


Direct ancestors

COMPARABLE, HASHABLE, KL_SHARED_PLATFORM, UC_IMPORTED_UNICODE_ROUTINES, KL_IMPORTED_INTEGER_ROUTINES, KL_IMPORTED_STRING_ROUTINES

Creation

Features

Invariants

indexing

description

Unicode characters

library

Gobo Eiffel Kernel Library

copyright

Copyright (c) 2001, Eric Bezault and others

license

Eiffel Forum License v2 (see forum.txt)

date

$Date: 2005/07/13 17:05:11 $

revision

$Revision: 1.9 $

class

UC_CHARACTER

inherit

COMPARABLE
PART_COMPARABLE
HASHABLE
KL_SHARED_PLATFORM
UC_IMPORTED_UNICODE_ROUTINES
KL_IMPORTED_INTEGER_ROUTINES
KL_IMPORTED_STRING_ROUTINES

create

make_from_character (c: CHARACTER)

-- Create a new unicode character from Latin-1 character c.

ensure
code_set: code = c.code
make_from_code (a_code: INTEGER)

-- Create a new unicode character with code a_code.

require
valid_code: unicode.valid_code (a_code)
ensure
code_set: code = a_code

feature -- Access

integer_: KL_INTEGER_ROUTINES

-- Routines that ought to be in class INTEGER

-- (From KL_IMPORTED_INTEGER_ROUTINES)

ensure
integer_routines_not_void: Result /= Void
platform: KL_PLATFORM

-- Platform-dependent properties

-- (From KL_SHARED_PLATFORM)

ensure
platform_not_void: Result /= Void
string_: KL_STRING_ROUTINES

-- Routines that ought to be in class STRING

-- (From KL_IMPORTED_STRING_ROUTINES)

ensure
string_routines_not_void: Result /= Void
code: INTEGER

-- Code of unicode character

hash_code: INTEGER

-- Hash code value

-- (From HASHABLE)

ensure
good_hash_value: Result >= 0
unicode: UC_UNICODE_ROUTINES

-- Unicode routines

-- (From UC_IMPORTED_UNICODE_ROUTINES)

ensure
unicode_not_void: Result /= Void

feature -- Comparison

infix "<" (other: like Current): BOOLEAN

-- Is current object less than other?

-- (From PART_COMPARABLE)

require
other_exists: other /= Void
ensure then
asymmetric: Result implies not (other < Current)
infix "<=" (other: like Current): BOOLEAN

-- Is current object less than or equal to other?

-- (From PART_COMPARABLE)

require
other_exists: other /= Void
ensure then
definition: Result = ((Current < other) or is_equal (other))
infix ">" (other: like Current): BOOLEAN

-- Is current object greater than other?

-- (From PART_COMPARABLE)

require
other_exists: other /= Void
ensure then
definition: Result = (other < Current)
infix ">=" (other: like Current): BOOLEAN

-- Is current object greater than or equal to other?

-- (From PART_COMPARABLE)

require
other_exists: other /= Void
ensure then
definition: Result = (other <= Current)
is_equal (other: like Current): BOOLEAN

-- Is other attached to an object of the same type
-- as current object and identical to it?

-- (From ANY)

require
other_not_void: other /= Void
ensure
symmetric: Result implies other.is_equal (Current)
consistent: standard_is_equal (other) implies Result
max (other: like Current): like Current

-- The greater of current object and other

-- (From COMPARABLE)

require
other_exists: other /= Void
ensure
current_if_not_smaller: Current >= other implies Result = Current
other_if_smaller: Current < other implies Result = other
min (other: like Current): like Current

-- The smaller of current object and other

-- (From COMPARABLE)

require
other_exists: other /= Void
ensure
current_if_not_greater: Current <= other implies Result = Current
other_if_greater: Current > other implies Result = other
three_way_comparison (other: like Current): INTEGER

-- If current object equal to other, 0;
-- if smaller, -1; if greater, 1

-- (From COMPARABLE)

require
other_exists: other /= Void
ensure
equal_zero: (Result = 0) = is_equal (other)
smaller_negative: (Result = -1) = (Current < other)
greater_positive: (Result = 1) = (Current > other)

feature -- Status report

is_ascii: BOOLEAN

-- Is current character an ASCII character?

ensure
definition: Result = unicode.valid_ascii_code (code)
is_hashable: BOOLEAN

-- May current object be hashed?
-- (True if it is not its type's default.)

-- (From HASHABLE)

ensure
ok_if_not_default: Result implies (Current /= default)

feature -- Conversion

as_lower: like Current

-- Lowercase value of current character
-- (Create a new object at each call.)

ensure
to_lower_not_void: Result /= Void
as_upper: like Current

-- Uppercase value of current character
-- (Create a new object at each call.)

ensure
to_upper_not_void: Result /= Void
to_character: CHARACTER

-- Character with code code

require
valid_code: code <= Platform.Maximum_character_code
ensure
code_set: Result.code = code
to_lower: like Current

-- Lowercase value of current character
-- (Create a new object at each call.)

ensure
to_lower_not_void: Result /= Void
to_upper: like Current

-- Uppercase value of current character
-- (Create a new object at each call.)

ensure
to_upper_not_void: Result /= Void

feature -- Output

out: STRING

-- New STRING containing terse printable representation
-- of current character; Non-ascii characters are represented
-- with the %/code/ convention.

-- (From ANY)

feature -- Obsolete

platform_: KL_PLATFORM

-- Platform-dependent properties

-- (From KL_SHARED_PLATFORM)

obsolete

[040101] Use Platform instead.

ensure
platform_not_void: Result /= Void

invariant

valid_code: unicode.valid_code (code)

-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

-- From COMPARABLE
irreflexive_comparison: not (Current < Current)

end