note description: "References to objects containing a unicode character value" library: "Free implementation of ELKS library" status: "See notice at end of class." legal: "See notice at end of class." date: "$Date: 2017-03-23 19:18:26 +0000 (Thu, 23 Mar 2017) $" revision: "$Revision: 100033 $" class CHARACTER_32_REF inherit COMPARABLE redefine is_equal, out end HASHABLE redefine is_equal, out end create default_create feature -- Access item: CHARACTER_32 -- Unicode character value code: INTEGER_32 obsolete "Use `natural_32_code' instead. [2017-05-31]" -- Associated integer value do Result := natural_32_code.as_integer_32 end hash_code: INTEGER_32 -- Hash code value do Result := natural_32_code.hash_code end natural_32_code: NATURAL_32 -- Associated natural value do Result := item.natural_32_code ensure natural_32_code_in_range: Result >= Min_value and Result <= Max_value end Min_value: NATURAL_32 = 0 Max_value: NATURAL_32 = 4294967295 -- Bounds for integer representation of CHARACTER_32 Max_unicode_value: NATURAL_32 = 1114109 -- Maximum Unicode characters. feature -- Comparison is_less alias "<" (other: like Current): BOOLEAN -- Is other greater than current character? do Result := natural_32_code < other.natural_32_code ensure then definition: Result = (natural_32_code < other.natural_32_code) end is_equal (other: like Current): BOOLEAN -- Is other attached to an object of the same type -- as current object and identical to it? do Result := other.item = item end feature -- Basic routines plus alias "+" (incr: NATURAL_32): CHARACTER_32 -- Add incr to the code of item. require valid_increment: (item.natural_32_code.to_natural_64 + incr.to_natural_64).is_valid_character_32_code do Result := (item.natural_32_code + incr).to_character_32 ensure valid_result: Result |-| item = incr.to_integer_64 end minus alias "-" (decr: NATURAL_32): CHARACTER_32 -- Subtract decr from the code of item. require valid_decrement: (item.natural_32_code.to_integer_64 - decr.to_integer_64).is_valid_character_32_code do Result := (item.natural_32_code - decr).to_character_32 ensure valid_result: item |-| Result = decr.to_integer_64 end difference alias "|-|" (other: CHARACTER_32): INTEGER_64 -- Difference between the codes of item and other. do Result := item.natural_32_code.to_integer_64 - other.natural_32_code.to_integer_64 ensure valid_non_negative_result: Result >= 0 implies ((other + Result.to_natural_32) = item) valid_negative_result: Result < 0 implies (other = (item + Result.to_natural_32)) end next: CHARACTER_32 -- Next character. require valid_character: (item.natural_32_code.to_natural_64 + 1).is_valid_character_32_code do Result := item + 1 ensure valid_result: Result |-| item = 1 end previous: CHARACTER_32 -- Previous character. require valid_character: (item.natural_32_code.to_natural_64 - 1).is_valid_character_32_code do Result := item - 1 ensure valid_result: Result |-| item = -1 end feature -- Element change set_item (c: CHARACTER_32) -- Make c the item value. do item := c end feature -- Output out: STRING_8 -- Printable representation of wide character. do create Result.make (6) Result.append_character ('U') Result.append_character ('+') Result.append_string (natural_32_code.to_hex_string) end feature {NONE} -- Initialization make_from_reference (v: CHARACTER_32_REF) -- Initialize Current with v.item. require v_not_void: v /= Void do set_item (v.item) ensure item_set: item = v.item end feature -- Conversion to_reference: CHARACTER_32_REF -- Associated reference of Current. do create Result Result.set_item (item) ensure to_reference_not_void: Result /= Void end to_character_8: CHARACTER_8 -- Convert current to CHARACTER_8. require is_character_8_compatible: is_character_8 do Result := item.to_character_8 end to_character_32: CHARACTER_32 -- Convert current to CHARACTER_32. do Result := item end as_upper: CHARACTER_32 -- Uppercase value of item. -- Returns item if not is_lower. -- Was declared in CHARACTER_32_REF as synonym of upper. do Result := Properties.to_upper (item) end upper: CHARACTER_32 -- Uppercase value of item. -- Returns item if not is_lower. -- Was declared in CHARACTER_32_REF as synonym of as_upper. do Result := Properties.to_upper (item) end as_lower: CHARACTER_32 -- Lowercase value of item. -- Returns item if not is_upper. -- Was declared in CHARACTER_32_REF as synonym of lower. do Result := Properties.to_lower (item) end lower: CHARACTER_32 -- Lowercase value of item. -- Returns item if not is_upper. -- Was declared in CHARACTER_32_REF as synonym of as_lower. do Result := Properties.to_lower (item) end feature -- Status report is_character_8: BOOLEAN -- Can current be represented on a CHARACTER_8? do Result := natural_32_code <= {CHARACTER_8}.max_value.to_natural_32 end is_alpha: BOOLEAN -- Is item alphabetic? -- Alphabetic is is_upper or is_lower. do Result := Properties.is_alpha (item) end is_upper: BOOLEAN -- Is item uppercase? do Result := Properties.is_upper (item) end is_lower: BOOLEAN -- Is item lowercase? do Result := Properties.is_lower (item) end is_digit: BOOLEAN -- Is item a decimal digit as expected for ASCII characters? -- A digit is one of 0123456789. do Result := '0'.to_character_32 <= item and item <= '9'.to_character_32 end is_unicode_digit: BOOLEAN -- Is item a decimal digit as expected for Unicode characters? do Result := Properties.is_digit (item) end is_hexa_digit: BOOLEAN -- Is item a hexadecimal digit as expected for ASCII characters? -- A digit is one of 0123456789ABCDEFabcedf. do Result := Properties.is_hexa_digit (item) end is_space: BOOLEAN -- Is item a white space? do Result := Properties.is_space (item) end is_punctuation: BOOLEAN -- Is item a punctuation? do Result := Properties.is_punctuation (item) end is_alpha_numeric: BOOLEAN -- Is item alphabetic or a digit? do Result := Properties.is_alpha (item) or Properties.is_digit (item) end is_control: BOOLEAN -- Is item a control character? do Result := Properties.is_control (item) end feature {NONE} -- Implementation Properties: CHARACTER_PROPERTY -- Property for Unicode characters. once create Result.make end note copyright: "Copyright (c) 1984-2017, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software 5949 Hollister Ave., Goleta, CA 93117 USA Telephone 805-685-1006, Fax 805-685-6869 Website http://www.eiffel.com Customer support http://support.eiffel.com ]" end -- class CHARACTER_32_REF
Generated by ISE EiffelStudio