work in progress | character

Class CHARACTER_REF

Visual Eiffel 3.2 beta


indexing
   title       : "Reference class for CHARACTER.";
   cluster     : "%VE_Lib%\Kernel";
   project     : "Eiffel Kernel Library";
   copyright   : "Object Tools, 1996-1998";
   original    : 26,Apr,96;
   version     : 1.0;
   last_change :

      25,Jul,96, Alexis  , "inheritance clause was changed to follow       ",
                           "required ancestry links                        ",

      15,May,98, Alexandr, "some feature implementations were changed to   ",
                           "allow non-predefined classes to inherit from   ",
                           "this class                                     ";

   key         : ELKS;
   done_at     : "Object Tools (info@object-tools.com)";
   extrnl_name : "char_ref.e"
-----------------------------------------------------------------------------
class CHARACTER_REF
-----------------------------------------------------------------------------
inherit
-------------------------------------------------------------------- HASHABLE
   HASHABLE
      redefine
         out
   end
------------------------------------------------------------------ COMPARABLE
   COMPARABLE
      redefine
         out
   end
-----------------------------------------------------------------------------
feature -- Access
------------------------------------------------------------------------ item
   item : CHARACTER;
      -- Character value
------------------------------------------------------------------------ code
   code : INTEGER is
      -- Associated integer value
   do
      Result := item.code
   end; -- code
------------------------------------------------------------------- hash_code
   hash_code : INTEGER is
      -- Hash code value
      -- (From HASHABLE)
   do
      Result := item.code;
   end; -- hash_code
-----------------------------------------------------------------------------
feature -- Comparison
------------------------------------------------------------------- infix "<"
   infix "<" (other : like Current) : BOOLEAN is
      -- Is current character less than 'other' ?
      -- (From COMPARABLE)
   do
      Result := item < other.item
   end; -- infix "<"
-----------------------------------------------------------------------------
feature -- Element change
-------------------------------------------------------------------- set_item
   set_item (c : CHARACTER) is
      -- Make 'c' the associated character value
   do
      item := c;
   ensure
      item_set : item = c
   end; -- set_item
-----------------------------------------------------------------------------
feature -- Eiffel/S 1.3 compatibility
------------------------------------------------------------------ to_integer
   to_integer : INTEGER is
   obsolete "Eiffel/S 1.3 compatibility"
   do
      Result := item.code
   end; -- to_integer
---------------------------------------------------------------- from_integer
   from_integer (i : INTEGER) is
   do
      item.from_integer( i )
   end; -- from_integer
-------------------------------------------------------------------- to_lower
   to_lower : CHARACTER is
   do
      Result := item
      inspect
         Result
      when 'A' .. 'Z' then
         Result.from_integer (code - ('A').code + ('a').code)
      else
      end; -- inspect
   end; -- to_lower
-------------------------------------------------------------------- to_upper
   to_upper : CHARACTER is
   do
      Result := item
      inspect
         Result
      when 'a' .. 'z' then
         Result.from_integer (code - ('a').code + ('A').code)
      else
      end; -- inspect
   end; -- to_upper
-----------------------------------------------------------------------------
feature -- Output
------------------------------------------------------------------------- out
   out : STRING is
      -- Printable representation of character
      -- (From GENERAL)
   do
      if item <  ' '  and then
         item /= '%T' and then -- Tab
         item /= '%F' and then -- FF
         item /= '%R' and then -- CR
         item /= '%N'          -- LF
      then
         Result := ".";
      else
         !!Result.make (1);
         Result.put (item, 1);
      end; -- if
   end; -- out
-----------------------------------------------------------------------------
end -- class CHARACTER_REF