home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / adav313.zip / gnat-3_13p-os2-bin-20010916.zip / emx / gnatlib / a-wtedit.ads < prev    next >
Text File  |  2000-07-19  |  8KB  |  208 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT RUN-TIME COMPONENTS                         --
  4. --                                                                          --
  5. --             A D A . W I D E _ T E X T _ I O . E D I T I N G              --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.3 $                              --
  10. --                                                                          --
  11. --          Copyright (C) 1992-1997 Free Software Foundation, Inc.          --
  12. --                                                                          --
  13. -- This specification is derived from the Ada Reference Manual for use with --
  14. -- GNAT. The copyright notice above, and the license provisions that follow --
  15. -- apply solely to the  contents of the part following the private keyword. --
  16. --                                                                          --
  17. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  18. -- terms of the  GNU General Public License as published  by the Free Soft- --
  19. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  20. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  21. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  22. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  23. -- for  more details.  You should have  received  a copy of the GNU General --
  24. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  25. -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
  26. -- MA 02111-1307, USA.                                                      --
  27. --                                                                          --
  28. -- As a special exception,  if other files  instantiate  generics from this --
  29. -- unit, or you link  this unit with other files  to produce an executable, --
  30. -- this  unit  does not  by itself cause  the resulting  executable  to  be --
  31. -- covered  by the  GNU  General  Public  License.  This exception does not --
  32. -- however invalidate  any other reasons why  the executable file  might be --
  33. -- covered by the  GNU Public License.                                      --
  34. --                                                                          --
  35. -- GNAT was originally developed  by the GNAT team at  New York University. --
  36. -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
  37. --                                                                          --
  38. ------------------------------------------------------------------------------
  39.  
  40. package Ada.Wide_Text_IO.Editing is
  41.  
  42.    type Picture is private;
  43.  
  44.    function Valid
  45.      (Pic_String      : in String;
  46.       Blank_When_Zero : in Boolean := False)
  47.       return            Boolean;
  48.  
  49.    function To_Picture
  50.      (Pic_String      : in String;
  51.       Blank_When_Zero : in Boolean := False)
  52.       return            Picture;
  53.  
  54.    function Pic_String      (Pic : in Picture) return String;
  55.    function Blank_When_Zero (Pic : in Picture) return Boolean;
  56.  
  57.    Max_Picture_Length : constant := 64;
  58.  
  59.    Picture_Error : exception;
  60.  
  61.    Default_Currency   : constant Wide_String    := "$";
  62.    Default_Fill       : constant Wide_Character := ' ';
  63.    Default_Separator  : constant Wide_Character := ',';
  64.    Default_Radix_Mark : constant Wide_Character := '.';
  65.  
  66.    generic
  67.       type Num is delta <> digits <>;
  68.       Default_Currency   : in Wide_String :=
  69.                                 Wide_Text_IO.Editing.Default_Currency;
  70.       Default_Fill       : in Wide_Character :=
  71.                                 Wide_Text_IO.Editing.Default_Fill;
  72.       Default_Separator  : in Wide_Character :=
  73.                                 Wide_Text_IO.Editing.Default_Separator;
  74.       Default_Radix_Mark : in Wide_Character :=
  75.                                 Wide_Text_IO.Editing.Default_Radix_Mark;
  76.  
  77.    package Decimal_Output is
  78.  
  79.       function Length
  80.         (Pic      : in Picture;
  81.          Currency : in Wide_String := Default_Currency)
  82.          return     Natural;
  83.  
  84.       function Valid
  85.         (Item     : Num;
  86.          Pic      : in Picture;
  87.          Currency : in Wide_String := Default_Currency)
  88.          return     Boolean;
  89.  
  90.       function Image
  91.         (Item       : Num;
  92.          Pic        : in Picture;
  93.          Currency   : in Wide_String    := Default_Currency;
  94.          Fill       : in Wide_Character := Default_Fill;
  95.          Separator  : in Wide_Character := Default_Separator;
  96.          Radix_Mark : in Wide_Character := Default_Radix_Mark)
  97.          return       Wide_String;
  98.  
  99.       procedure Put
  100.         (File       : in File_Type;
  101.          Item       : Num;
  102.          Pic        : in Picture;
  103.          Currency   : in Wide_String    := Default_Currency;
  104.          Fill       : in Wide_Character := Default_Fill;
  105.          Separator  : in Wide_Character := Default_Separator;
  106.          Radix_Mark : in Wide_Character := Default_Radix_Mark);
  107.  
  108.       procedure Put
  109.         (Item       : Num;
  110.          Pic        : in Picture;
  111.          Currency   : in Wide_String    := Default_Currency;
  112.          Fill       : in Wide_Character := Default_Fill;
  113.          Separator  : in Wide_Character := Default_Separator;
  114.          Radix_Mark : in Wide_Character := Default_Radix_Mark);
  115.  
  116.       procedure Put
  117.         (To         : out Wide_String;
  118.          Item       : Num;
  119.          Pic        : in Picture;
  120.          Currency   : in Wide_String    := Default_Currency;
  121.          Fill       : in Wide_Character := Default_Fill;
  122.          Separator  : in Wide_Character := Default_Separator;
  123.          Radix_Mark : in Wide_Character := Default_Radix_Mark);
  124.  
  125.    end Decimal_Output;
  126.  
  127. private
  128.    MAX_PICSIZE      : constant := 50;
  129.    MAX_MONEYSIZE    : constant := 10;
  130.    Invalid_Position : constant := -1;
  131.  
  132.    subtype Pic_Index is Natural range 0 .. MAX_PICSIZE;
  133.  
  134.    type Picture_Record (Length : Pic_Index := 0) is record
  135.       Expanded : String (1 .. Length);
  136.    end record;
  137.  
  138.    type Format_Record is record
  139.       Picture              : Picture_Record;
  140.       --  Read only
  141.  
  142.       Blank_When_Zero      : Boolean;
  143.       --  Read/write
  144.  
  145.       Original_BWZ         : Boolean;
  146.  
  147.       --  The following components get written
  148.  
  149.       Star_Fill            : Boolean := False;
  150.  
  151.       Radix_Position       : Integer := Invalid_Position;
  152.  
  153.       Sign_Position,
  154.       Second_Sign          : Integer := Invalid_Position;
  155.  
  156.       Start_Float,
  157.       End_Float            : Integer := Invalid_Position;
  158.  
  159.       Start_Currency,
  160.       End_Currency         : Integer := Invalid_Position;
  161.  
  162.       Max_Leading_Digits   : Integer := 0;
  163.  
  164.       Max_Trailing_Digits  : Integer := 0;
  165.  
  166.       Max_Currency_Digits  : Integer := 0;
  167.  
  168.       Floater              : Wide_Character := '!';
  169.       --  Initialized to illegal value
  170.  
  171.    end record;
  172.  
  173.    type Picture is record
  174.       Contents : Format_Record;
  175.    end record;
  176.  
  177.    type Number_Attributes is record
  178.       Negative     : Boolean := False;
  179.  
  180.       Has_Fraction : Boolean := False;
  181.  
  182.       Start_Of_Int,
  183.       End_Of_Int,
  184.       Start_Of_Fraction,
  185.       End_Of_Fraction : Integer := Invalid_Position;    -- invalid value
  186.    end record;
  187.  
  188.    function Parse_Number_String (Str : String) return Number_Attributes;
  189.    --  Assumed format is 'IMAGE or Fixed_IO.Put format (depends on no
  190.    --  trailing blanks...)
  191.  
  192.    procedure Precalculate (Pic : in out Format_Record);
  193.    --  Precalculates fields from the user supplied data
  194.  
  195.    function Format_Number
  196.      (Pic                 : Format_Record;
  197.       Number              : String;
  198.       Currency_Symbol     : Wide_String;
  199.       Fill_Character      : Wide_Character;
  200.       Separator_Character : Wide_Character;
  201.       Radix_Point         : Wide_Character)
  202.       return                Wide_String;
  203.    --  Formats number according to Pic
  204.  
  205.    function Expand (Picture : in String) return String;
  206.  
  207. end Ada.Wide_Text_IO.Editing;
  208.