wayland_ada_f8a9fe05/wayland_ada_scanner/src/xml_parser_utils.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
--  SPDX-License-Identifier: Apache-2.0
--
--  Copyright (c) 2018 - 2019 Joakim Strandberg <joakim@mequinox.se>
--
--  Licensed under the Apache License, Version 2.0 (the "License");
--  you may not use this file except in compliance with the License.
--  You may obtain a copy of the License at
--
--      http://www.apache.org/licenses/LICENSE-2.0
--
--  Unless required by applicable law or agreed to in writing, software
--  distributed under the License is distributed on an "AS IS" BASIS,
--  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--  See the License for the specific language governing permissions and
--  limitations under the License.

with Wayland_XML;
with Ada.Containers.Vectors;

package Xml_Parser_Utils is

   function Adaify_Name (Old_Name : String) return String;

   function Adaify_Variable_Name (Old_Name : String) return String;
   --  If the variable name is "Interface" then it will be recognized as
   --  a reserved word in Ada and it will be suffixed with "_V" resulting
   --  in "Interface_V"

   function Arg_Type_As_String (Arg_Tag : Wayland_XML.Arg_Tag) return String;

   function Number_Of_Args
     (Request_Tag : aliased Wayland_XML.Request_Tag) return Natural;

   function Is_New_Id_Argument_Present
     (Request_Tag : aliased Wayland_XML.Request_Tag) return Boolean;

   function Is_Interface_Specified
     (Request_Tag : aliased Wayland_XML.Request_Tag) return Boolean with
     Pre => Is_New_Id_Argument_Present (Request_Tag);

   Interface_Not_Found_Exception : exception;

   function Find_Specified_Interface
     (Request_Tag : aliased Wayland_XML.Request_Tag) return String with
     Pre => Is_Interface_Specified (Request_Tag);
   --  Will raise Interface_Not_Found_Exception is pre-condition is not met

   function Is_Request_Destructor
     (Request_Tag : aliased Wayland_XML.Request_Tag) return Boolean;

   function Get_Destructor
     (Interface_Tag : aliased Wayland_XML.Interface_Tag) return String;

   function Exists_Any_Event_Tag
     (Interface_Tag : aliased Wayland_XML.Interface_Tag) return Boolean;

   function Remove_Tabs (Text : String) return String;

   type Interval is record
      First : Positive;
      Last  : Natural;
   end record;

   package Interval_Vectors is new Ada.Containers.Vectors
     (Index_Type   => Positive,
      Element_Type => Interval,
      "="          => "=");

   type Intervals_Ref
     (Element : not null access constant Interval_Vectors.Vector)
   is limited null record with Implicit_Dereference => Element;

   type Interval_Identifier is tagged limited private;

   function Intervals
     (This : aliased Interval_Identifier) return Intervals_Ref with
     Global => null;

   function Make (Text : String) return Interval_Identifier with
     Global => null;

private

   type Interval_Identifier is tagged limited record
      My_Intervals : aliased Interval_Vectors.Vector;
   end record;

   function Intervals
     (This : aliased Interval_Identifier) return Intervals_Ref
   is ((Element => This.My_Intervals'Access));

end Xml_Parser_Utils;