1------------------------------------------------------------------------------
2--                                                                          --
3--                         GNAT RUN-TIME COMPONENTS                         --
4--                                                                          --
5--                      S Y S T E M . I M G _ U T I L                       --
6--                                                                          --
7--                                 S p e c                                  --
8--                                                                          --
9--            Copyright (C) 2020-2021, Free Software Foundation, Inc.       --
10--                                                                          --
11-- GNAT is free software;  you can  redistribute it  and/or modify it under --
12-- terms of the  GNU General Public License as published  by the Free Soft- --
13-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
14-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
17--                                                                          --
18-- As a special exception under Section 7 of GPL version 3, you are granted --
19-- additional permissions described in the GCC Runtime Library Exception,   --
20-- version 3.1, as published by the Free Software Foundation.               --
21--                                                                          --
22-- You should have received a copy of the GNU General Public License and    --
23-- a copy of the GCC Runtime Library Exception along with this program;     --
24-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25-- <http://www.gnu.org/licenses/>.                                          --
26--                                                                          --
27-- GNAT was originally developed  by the GNAT team at  New York University. --
28-- Extensive contributions were provided by Ada Core Technologies Inc.      --
29--                                                                          --
30------------------------------------------------------------------------------
31
32--  This package provides some common utilities used by the s-imgxxx files
33
34package System.Img_Util is
35   pragma Pure;
36
37   Max_Real_Image_Length : constant := 5200;
38   --  If Exp is set to zero and Aft is set to Text_IO.Field'Last (i.e., 255)
39   --  then Long_Long_Float'Last generates an image whose length is slightly
40   --  less than 5200.
41
42   procedure Set_Decimal_Digits
43     (Digs  : in out String;
44      NDigs : Natural;
45      S     : out String;
46      P     : in out Natural;
47      Scale : Integer;
48      Fore  : Natural;
49      Aft   : Natural;
50      Exp   : Natural);
51   --  Sets the image of Digs (1 .. NDigs), which is a string of decimal digits
52   --  preceded by either a minus sign or a space, i.e. the integer image of
53   --  the value in units of delta if this is for a decimal fixed point type
54   --  with the given Scale, or the integer image of the value converted to an
55   --  implicit decimal fixed point type with the given Scale if this is for an
56   --  ordinary fixed point type, starting at S (P + 1), updating P to point to
57   --  the last character stored. The caller promises that the buffer is large
58   --  enough and therefore no check is made for it. Constraint_Error will not
59   --  necessarily be raised if the requirement is violated since it is valid
60   --  to compile this unit with checks off. The Fore, Aft and Exp values can
61   --  be set to any valid values for the case of use by Text_IO.Decimal_IO or
62   --  Text_IO.Fixed_IO. Note that there is no leading space stored. The call
63   --  may destroy the value in Digs, which is why Digs is in-out (this happens
64   --  if rounding is required).
65
66   type Floating_Invalid_Value is (Minus_Infinity, Infinity, Not_A_Number);
67
68   procedure Set_Floating_Invalid_Value
69     (V    : Floating_Invalid_Value;
70      S    : out String;
71      P    : in out Natural;
72      Fore : Natural;
73      Aft  : Natural;
74      Exp  : Natural);
75   --  Sets the image of a floating-point invalid value, starting at S (P + 1),
76   --  updating P to point to the last character stored. The caller promises
77   --  that the buffer is large enough and therefore no check is made for it.
78   --  Constraint_Error will not necessarily be raised if the requirement is
79   --  violated since it is valid to compile this unit with checks off.
80
81end System.Img_Util;
82