1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- S Y S T E M . D I M . I N T E G E R _ I O --
9 -- Copyright (C) 2011-2012, Free Software Foundation, Inc. --
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. --
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. --
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/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 -- This package provides output routines for integer dimensioned types. All
33 -- Put routines are modelled after those in package Ada.Text_IO.Integer_IO
34 -- with the addition of an extra default parameter.
36 -- All the examples in this package are based on the MKS system of units:
38 -- type Mks_Type is new Integer
40 -- Dimension_System => ((Meter, 'm'),
48 -- Parameter Symbol may be used in the following manner:
50 -- Case 1. A value is supplied for Symbol
52 -- The string appears as a suffix of Item
54 -- Obj : Mks_Type := 2;
55 -- Put (Obj, Symbols => " dimensionless");
57 -- The corresponding output is: 2 dimensionless
59 -- Case 2. No value is supplied for Symbol and Item is dimensionless
61 -- Item appears without a suffix
63 -- Obj : Mks_Type := 2;
66 -- The corresponding output is: 2
68 -- Case 3. No value is supplied for Symbol and Item has a dimension
70 -- If the type of Item is a dimensioned subtype whose symbolic name is not
71 -- empty, then the symbolic name appears as a suffix.
73 -- subtype Length is Mks_Type
82 -- The corresponding output is: 2 m
84 -- Otherwise, a new string is created and appears as a suffix of Item.
85 -- This string results in the successive concatanations between each
86 -- dimension symbolic name raised by its corresponding dimension power from
87 -- the dimensions of Item.
89 -- subtype Random is Mks_Type
99 -- The corresponding output is: 5 m**3.cd**2
101 with Ada.Text_IO; use Ada.Text_IO;
104 type Num_Dim_Integer is range <>;
106 package System.Dim.Integer_IO is
108 Default_Width : Field := Num_Dim_Integer'Width;
109 Default_Base : Number_Base := 10;
113 Item : Num_Dim_Integer;
114 Width : Field := Default_Width;
115 Base : Number_Base := Default_Base;
116 Symbols : String := "");
119 (Item : Num_Dim_Integer;
120 Width : Field := Default_Width;
121 Base : Number_Base := Default_Base;
122 Symbols : String := "");
126 Item : Num_Dim_Integer;
127 Base : Number_Base := Default_Base;
128 Symbols : String := "");
132 end System.Dim.Integer_IO;