vss_24.0.0_b4d0be7c/source/xml/templates/implementation/vss-xml-implementation-template_namespaces.ads

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
--
--  Copyright (C) 2022-2023, AdaCore
--
--  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--

with Ada.Containers.Hashed_Maps;
with Ada.Finalization;

with VSS.Strings.Hash;
with VSS.String_Vectors;
with VSS.XML.Templates.Proxies;

package VSS.XML.Implementation.Template_Namespaces is

   package Name_Item_Maps is
     new Ada.Containers.Hashed_Maps
       (VSS.Strings.Virtual_String,
        VSS.XML.Templates.Proxies.Proxy_Access,
        VSS.Strings.Hash,
        VSS.Strings."=",
        VSS.XML.Templates.Proxies."=");

   type Namespace is tagged;

   type Namespace_Access is access all Namespace'Class;

   type Namespace is
     limited new Ada.Finalization.Limited_Controlled
       and VSS.XML.Templates.Proxies.Abstract_Proxy with
   record
      Enclosing : Namespace_Access;
      Items     : Name_Item_Maps.Map;
   end record;

   procedure Resolve
     (Self  : Namespace'Class;
      Path  : VSS.String_Vectors.Virtual_String_Vector;
      Proxy : out VSS.XML.Templates.Proxies.Proxy_Access;
      Owned : out Boolean);
   --  Resolve given path to the proxy.
   --
   --  @param Self   Root namespace
   --  @param Path   Path to resolve
   --  @param Proxy  Proxy found at given path, if any; null overwise
   --  @param Owned
   --    Whether proxy is owned by the namespace. Returned proxy must be
   --    deallocated by the caller when proxy is not owned by the namespace.

   procedure Bind
     (Self : in out Namespace'Class;
      Path : VSS.String_Vectors.Virtual_String_Vector;
      Item : not null VSS.XML.Templates.Proxies.Proxy_Access)
     with Pre => not Path.Is_Empty;

   procedure Bind
     (Self : in out Namespace'Class;
      Name : VSS.Strings.Virtual_String;
      Item : not null VSS.XML.Templates.Proxies.Proxy_Access)
     with Pre => not Name.Is_Empty;

   overriding procedure Finalize (Self : in out Namespace);

end VSS.XML.Implementation.Template_Namespaces;