home *** CD-ROM | disk | FTP | other *** search
/ BURKS 2 / BURKS_AUG97.ISO / BURKS / LANGUAGE / ADA / LOVELACE / ustrings.ads < prev    next >
Text File  |  1996-03-03  |  3KB  |  69 lines

  1. --
  2. -- Copyright (C) 1996 Ada Resource Association (ARA), Columbus, Ohio.
  3. -- Author: David A. Wheeler
  4. --
  5.  
  6. with Text_IO, Ada.Strings.Unbounded;
  7. use  Text_IO, Ada.Strings.Unbounded;
  8.  
  9. package Ustrings is
  10.  
  11.   -- This package provides a simpler way to work with type
  12.   -- Unbounded_String, since this type will be used very often.
  13.   -- Most users will want to ALSO with "Ada.Strings.Unbounded".
  14.   -- Ideally this would be a child package of "Ada.Strings.Unbounded".
  15.   --
  16.  
  17.   -- This package provides the following simplifications:
  18.   --  + Shortens the type name from "Unbounded_String" to "Ustring".
  19.   --  + Creates shorter function names for To_Unbounded_String, i.e.
  20.   --    To_Ustring(U) and U(S).  "U" is not a very readable name, but
  21.   --    it's such a common operation that a short name seems appropriate
  22.   --    (this function is needed every time a String constant is used).
  23.   --    It also creates S(U) as the reverse of U(S).
  24.   --  + Adds other subprograms, currently just "Swap".
  25.   --  + Other packages can use this package to provide other simplifications.
  26.  
  27.   subtype Ustring is Unbounded_String;
  28.  
  29.   function To_Ustring(Source : String)  return Unbounded_String
  30.                                          renames To_Unbounded_String;
  31.   function U(Source : String)           return Unbounded_String
  32.                                          renames To_Unbounded_String;
  33.   function S(Source : Unbounded_String) return String
  34.                                          renames To_String;
  35.  
  36.   -- "Swap" is important for reuse in some other packages, so we'll define it.
  37.  
  38.   procedure Swap(Left, Right : in out Unbounded_String);
  39.  
  40.  
  41.   function Empty(S : Unbounded_String) return Boolean;
  42.    -- returns True if Length(S)=0.
  43.   pragma Inline(Empty);
  44.  
  45.  
  46.   -- I/O Routines.
  47.   procedure Get_Line(File : in File_Type; Item : out Unbounded_String);
  48.   procedure Get_Line(Item : out Unbounded_String);
  49.  
  50.   procedure Put(File : in File_Type; Item : in Unbounded_String);
  51.   procedure Put(Item : in Unbounded_String);
  52.  
  53.   procedure Put_Line(File : in File_Type; Item : in Unbounded_String);
  54.   procedure Put_Line(Item : in Unbounded_String);
  55.  
  56. end Ustrings;
  57.  
  58. --
  59. -- Permission to use, copy, modify, and distribute this software and its
  60. -- documentation for any purpose and without fee is hereby granted,
  61. -- provided that the above copyright and authorship notice appear in all
  62. -- copies and that both that copyright notice and this permission notice
  63. -- appear in supporting documentation.
  64. -- 
  65. -- The ARA makes no representations about the suitability of this software
  66. -- for any purpose.  It is provided "as is" without express
  67. -- or implied warranty.
  68. -- 
  69.