Debian Codegraph @

deps/clic/src/clic-config-info.adb

raw
1 with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
2
3 with GNAT.Regpat;
4
5 package body CLIC.Config.Info is
6
7 ----------
8 -- List --
9 ----------
10
11 function List (This : CLIC.Config.Instance;
12 Filter : String := ".*";
13 Show_Origin : Boolean := False)
14 return AAA.Strings.Vector
15 is
16 Result : AAA.Strings.Vector;
17 begin
18
19 for Key of List_Keys (This, Filter) loop
20 declare
21 Val : constant Config_Value := This.Config_Map (+Key);
22 Line : Unbounded_String;
23 begin
24 if Show_Origin then
25 Line := Val.Origin & ": ";
26 end if;
27
28 Append (Line, Key & "=");
29 Append (Line, Image (Val.Value));
30 Result.Append (To_String (Line));
31 end;
32 end loop;
33
34 return Result;
35 end List;
36
37 ---------------
38 -- List_Keys --
39 ---------------
40
41 function List_Keys (This : CLIC.Config.Instance;
42 Filter : String := ".*")
43 return AAA.Strings.Vector
44 is
45 use GNAT.Regpat;
46
47 Re : constant Pattern_Matcher := Compile (Filter);
48
49 Result : AAA.Strings.Vector;
50 begin
51 for C in This.Config_Map.Iterate loop
52 declare
53 Key : constant String := To_String (Config_Maps.Key (C));
54 begin
55 if Match (Re, Key) then
56 Result.Append (Key);
57 end if;
58 end;
59 end loop;
60 return Result;
61 end List_Keys;
62
63 end CLIC.Config.Info;