home *** CD-ROM | disk | FTP | other *** search
/ Solo Programadores 22 / SOLO_22.iso / docs / lovelace / ustrings.ads < prev    next >
Encoding:
Text File  |  1995-11-16  |  2.3 KB  |  60 lines

  1. with Text_IO, Ada.Strings.Unbounded;
  2. use  Text_IO, Ada.Strings.Unbounded;
  3.  
  4. package Ustrings is
  5.  
  6.   -- This package provides a simpler way to work with type
  7.   -- Unbounded_String, since this type will be used very often.
  8.   -- Most users will want to ALSO with "Ada.Strings.Unbounded".
  9.   -- Ideally this would be a child package of "Ada.Strings.Unbounded".
  10.   --
  11.  
  12.   -- This package provides the following simplifications:
  13.   --  + Shortens the type name from "Unbounded_String" to "Ustring".
  14.   --  + Creates shorter function names for To_Unbounded_String, i.e.
  15.   --    To_Ustring(U) and U(S).  "U" is not a very readable name, but
  16.   --    it's such a common operation that a short name seems appropriate
  17.   --    (this function is needed every time a String constant is used).
  18.   --    It also creates S(U) as the reverse of U(S).
  19.   --  + Adds other subprograms, currently just "Swap".
  20.   --  + Other packages can use this package to provide other simplifications.
  21.  
  22.   -- Developed by David A. Wheeler; released to the public domain.
  23.  
  24.   -- This version (C) 1995 Ada Resource Association, Columbus, Ohio.
  25.   -- Permission is granted to use this program for any purpose,
  26.   -- commercial or not, as long as credit is given to David A. Wheeler
  27.   -- as the original developer.
  28.  
  29.  
  30.   subtype Ustring is Unbounded_String;
  31.  
  32.   function To_Ustring(Source : String)  return Unbounded_String
  33.                                          renames To_Unbounded_String;
  34.   function U(Source : String)           return Unbounded_String
  35.                                          renames To_Unbounded_String;
  36.   function S(Source : Unbounded_String) return String
  37.                                          renames To_String;
  38.  
  39.   -- "Swap" is important for reuse in some other packages, so we'll define it.
  40.  
  41.   procedure Swap(Left, Right : in out Unbounded_String);
  42.  
  43.  
  44.   function Empty(S : Unbounded_String) return Boolean;
  45.    -- returns True if Length(S)=0.
  46.   pragma Inline(Empty);
  47.  
  48.  
  49.   -- I/O Routines.
  50.   procedure Get_Line(File : in File_Type; Item : out Unbounded_String);
  51.   procedure Get_Line(Item : out Unbounded_String);
  52.  
  53.   procedure Put(File : in File_Type; Item : in Unbounded_String);
  54.   procedure Put(Item : in Unbounded_String);
  55.  
  56.   procedure Put_Line(File : in File_Type; Item : in Unbounded_String);
  57.   procedure Put_Line(Item : in Unbounded_String);
  58.  
  59. end Ustrings;
  60.