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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112 | -----------------------------------------------------------------------
-- gen-utils -- Utilities for model generator
-- Copyright (C) 2010, 2011, 2012, 2021 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- 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 Ada.Strings.Unbounded;
with Ada.Containers.Ordered_Sets;
with DOM.Core;
with Util.Strings.Vectors;
with Util.Beans.Objects;
package Gen.Utils is
-- Generic procedure to iterate over the DOM nodes children of <b>node</b>
-- and having the entity name <b>name</b>.
generic
type T (<>) is limited private;
with procedure Process (Closure : in out T;
Node : DOM.Core.Node);
procedure Iterate_Nodes (Closure : in out T;
Node : in DOM.Core.Node;
Name : in String;
Recurse : in Boolean := True);
-- Get the first DOM child from the given entity tag
function Get_Child (Node : in DOM.Core.Node;
Name : in String) return DOM.Core.Node;
-- Get the content of the node
function Get_Data_Content (Node : in DOM.Core.Node) return String;
-- Get the content of the node identified by <b>Name</b> under the given DOM node.
function Get_Data_Content (Node : in DOM.Core.Node;
Name : in String) return String;
-- Get a boolean attribute
function Get_Attribute (Node : in DOM.Core.Node;
Name : in String;
Default : in Boolean := False) return Boolean;
-- Get a string attribute
function Get_Attribute (Node : in DOM.Core.Node;
Name : in String;
Default : in String := "") return String;
-- Get the Ada package name from a qualified type
function Get_Package_Name (Name : in String) return String;
-- Get the Ada type name from a full qualified type
function Get_Type_Name (Name : in String) return String;
-- Get a query name from the XML query file name
function Get_Query_Name (Path : in String) return String;
use Ada.Strings.Unbounded;
package String_Set is
new Ada.Containers.Ordered_Sets (Element_Type => UString,
"<" => Ada.Strings.Unbounded."<",
"=" => Ada.Strings.Unbounded."=");
package String_List renames Util.Strings.Vectors;
-- Returns True if the Name is a valid project or module name.
-- The name must be a valid Ada identifier.
function Is_Valid_Name (Name : in String) return Boolean;
-- Returns True if the path referred to by <b>Path</b> is an absolute path.
function Is_Absolute_Path (Path : in String) return Boolean;
-- Returns the path if this is an absolute path, otherwise build and return an absolute path.
function Absolute_Path (Path : in String) return String;
-- Returns True if the file name must be ignored (.svn, CVS, .git, are ignored).
function Is_File_Ignored (Name : in String) return Boolean;
-- Get a string attribute
function Get_Attribute (Node : in DOM.Core.Node;
Name : in String;
Default : in String := "")
return UString;
-- Get the value identified by the name from the attribute.
-- Normalize the result string.
-- If the name cannot be found, the method should return the Null object.
function Get_Normalized_Type (Node : in DOM.Core.Node;
Name : in String) return String;
-- Get the attribute identified by <b>Name</b> on the DOM node
-- and return it as an EL object.
function Get_Attribute (Node : in DOM.Core.Node;
Name : in String) return Util.Beans.Objects.Object;
-- Get the comment associated with a node
function Get_Comment (Node : in DOM.Core.Node) return String;
-- Returns a qualified name from a package name and a name.
function Qualify_Name (Pkg_Name : in UString;
Name : in UString) return UString;
end Gen.Utils;
|