Tables_IO segregated into AAA
This commit is contained in:
@@ -4,3 +4,6 @@
|
||||
[submodule "deps/simple_logging"]
|
||||
path = deps/simple_logging
|
||||
url = https://github.com/alire-project/simple_logging.git
|
||||
[submodule "deps/aaa"]
|
||||
path = deps/aaa
|
||||
url = https://github.com/mosteo/aaa.git
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
with "aaa";
|
||||
with "semantic_versioning";
|
||||
with "simple_logging";
|
||||
|
||||
|
||||
+1
Submodule deps/aaa added at 3b263b6cb8
@@ -1,11 +1,11 @@
|
||||
with AAA.Table_IO;
|
||||
|
||||
-- with Alire.Platform;
|
||||
with Alire.Platforms;
|
||||
with Alire.Requisites.Booleans;
|
||||
|
||||
with GNAT.IO; -- To keep preelaborable
|
||||
|
||||
with Table_IO;
|
||||
|
||||
package body Alire.Releases is
|
||||
|
||||
use all type Alire.Properties.Labeled.Labels;
|
||||
@@ -352,7 +352,7 @@ package body Alire.Releases is
|
||||
if R.Origin.Is_Native then
|
||||
Put_Line ("Origin (native package):");
|
||||
declare
|
||||
Table : Table_IO.Table;
|
||||
Table : AAA.Table_IO.Table;
|
||||
begin
|
||||
for Dist in Platforms.Distributions loop
|
||||
if R.Origin.Package_Name (Dist) /= Origins.Unavailable.Image then
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
with Ada.Containers;
|
||||
with Ada.Strings.Fixed;
|
||||
|
||||
with GNAT.IO;
|
||||
|
||||
package body Table_IO is
|
||||
|
||||
use all type Ada.Containers.Count_Type;
|
||||
|
||||
------------
|
||||
-- Append --
|
||||
------------
|
||||
|
||||
procedure Append (T : in out Table; Cell : String) is
|
||||
begin
|
||||
if T.Rows.Is_Empty then
|
||||
T.New_Row;
|
||||
end if;
|
||||
|
||||
if Natural (T.Max_Widths.Length) < T.Next_Column then
|
||||
T.Max_Widths.Append (Cell'Length);
|
||||
else
|
||||
T.Max_Widths (T.Next_Column) :=
|
||||
Natural'Max (Cell'Length, T.Max_Widths (T.Next_Column));
|
||||
end if;
|
||||
|
||||
T.Rows (Natural (T.Rows.Length)).Append (Cell);
|
||||
T.Next_Column := T.Next_Column + 1;
|
||||
end Append;
|
||||
|
||||
-------------
|
||||
-- New_Row --
|
||||
-------------
|
||||
|
||||
procedure New_Row (T : in out Table) is
|
||||
begin
|
||||
T.Next_Column := 1;
|
||||
T.Rows.Append (String_Vectors.Empty_Vector);
|
||||
end New_Row;
|
||||
|
||||
----------------
|
||||
-- Put_Padded --
|
||||
----------------
|
||||
|
||||
procedure Put_Padded (T : Table;
|
||||
Col : Positive;
|
||||
Text : String;
|
||||
Align : Ada.Strings.Alignment)
|
||||
is
|
||||
Field : String (1 .. T.Max_Widths (Col));
|
||||
begin
|
||||
Ada.Strings.Fixed.Move (Text,
|
||||
Field,
|
||||
Drop => Ada.Strings.Error,
|
||||
Justify => Align);
|
||||
GNAT.IO.Put (Field);
|
||||
end Put_Padded;
|
||||
|
||||
-----------
|
||||
-- Print --
|
||||
-----------
|
||||
|
||||
procedure Print (T : Table;
|
||||
Separator : String := " ";
|
||||
Align : Alignments := (1 .. 0 => <>))
|
||||
is
|
||||
use GNAT.IO;
|
||||
begin
|
||||
for Row of T.Rows loop
|
||||
for I in 1 .. Natural (Row.Length) loop
|
||||
Put_Padded (T,
|
||||
I,
|
||||
Row (I),
|
||||
(if Align'Length >= I
|
||||
then Align (I)
|
||||
else Ada.Strings.Left));
|
||||
|
||||
if I < Natural (Row.Length) then
|
||||
Put (Separator);
|
||||
else
|
||||
New_Line;
|
||||
end if;
|
||||
end loop;
|
||||
end loop;
|
||||
end Print;
|
||||
|
||||
end Table_IO;
|
||||
@@ -1,37 +0,0 @@
|
||||
with Ada.Containers.Indefinite_Vectors;
|
||||
with Ada.Containers.Vectors;
|
||||
|
||||
with Ada.Strings;
|
||||
|
||||
package Table_IO with Preelaborate is
|
||||
|
||||
type Table is tagged private;
|
||||
|
||||
procedure Append (T : in out Table; Cell : String);
|
||||
|
||||
procedure New_Row (T : in out Table);
|
||||
|
||||
type Alignments is array (Positive range <>) of Ada.Strings.Alignment;
|
||||
|
||||
procedure Print (T : Table;
|
||||
Separator : String := " ";
|
||||
Align : Alignments := (1 .. 0 => <>));
|
||||
|
||||
private
|
||||
|
||||
package Natural_Vectors is new Ada.Containers.Vectors (Positive, Natural);
|
||||
|
||||
package String_Vectors is new Ada.Containers.Indefinite_Vectors (Positive,
|
||||
String);
|
||||
subtype Row is String_Vectors.Vector;
|
||||
use all type Row;
|
||||
|
||||
package Row_Vectors is new Ada.Containers.Vectors (Positive, Row);
|
||||
|
||||
type Table is tagged record
|
||||
Next_Column : Positive := 1;
|
||||
Rows : Row_Vectors.Vector;
|
||||
Max_Widths : Natural_Vectors.Vector;
|
||||
end record;
|
||||
|
||||
end Table_IO;
|
||||
Reference in New Issue
Block a user