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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175 | ------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Cheddar is a GNU GPL real-time scheduling analysis tool.
-- This program provides services to automatically check schedulability and
-- other performance criteria of real-time architecture models.
--
-- Copyright (C) 2002-2023, Frank Singhoff, Alain Plantec, Jerome Legrand,
-- Hai Nam Tran, Stephane Rubini
--
-- The Cheddar project was started in 2002 by
-- Frank Singhoff, Lab-STICC UMR 6285, Université de Bretagne Occidentale
--
-- Cheddar has been published in the "Agence de Protection des Programmes/France" in 2008.
-- Since 2008, Ellidiss technologies also contributes to the development of
-- Cheddar and provides industrial support.
--
-- The full list of contributors and sponsors can be found in README.md
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
--
-- Contact : cheddar@listes.univ-brest.fr
--
------------------------------------------------------------------------------
-- Last update :
-- $Rev: 4589 $
-- $Date: 2023-09-29 16:02:19 +0200 (ven., 29 sept. 2023) $
-- $Author: singhoff $
------------------------------------------------------------------------------
------------------------------------------------------------------------------
with Ada.Strings.Maps.Constants;
with Text_IO; use Text_IO;
package body unbounded_strings is
function unbounded_ht (number : in Natural := 1) return Unbounded_String is
result : Unbounded_String := empty_string;
begin
for i in 1 .. number loop
result := result & unbounded_lf;
end loop;
return result;
end unbounded_ht;
function xml_string (s : in unbounded_string_ptr) return Unbounded_String is
begin
return xml_string (s.all);
end xml_string;
function to_upper (s : String) return Unbounded_String is
begin
return to_upper (To_Unbounded_String (s));
end to_upper;
function to_lower (s : String) return Unbounded_String is
begin
return to_lower (To_Unbounded_String (s));
end to_lower;
function to_upper (s : Unbounded_String) return Unbounded_String is
begin
return Translate (s, Ada.Strings.Maps.Constants.Upper_Case_Map);
end to_upper;
function to_lower (s : Unbounded_String) return Unbounded_String is
begin
return Translate (s, Ada.Strings.Maps.Constants.Lower_Case_Map);
end to_lower;
procedure to_double
(from : in Unbounded_String;
to : out Double;
ok : out Boolean)
is
begin
to := Double'value (To_String (from));
ok := True;
exception
when Constraint_Error =>
to := 0.0;
ok := False;
end to_double;
procedure initialize (st : out Unbounded_String) is
begin
st := empty_string;
end initialize;
procedure put (s : unbounded_string_ptr) is
begin
Put (To_String (s.all));
end put;
function suppress_space (s : in String) return Unbounded_String is
result : Unbounded_String;
begin
for i in 1 .. s'length loop
if s (i) /= ' ' then
Append (result, s (i));
end if;
end loop;
return result;
end suppress_space;
function suppress_space (s : in Unbounded_String) return Unbounded_String is
begin
return suppress_space (To_String (s));
end suppress_space;
function has_space (s : in String) return Boolean is
begin
for i in 1 .. s'length loop
if s (i) /= ' ' then
return True;
end if;
end loop;
return False;
end has_space;
function has_space (s : in Unbounded_String) return Boolean is
begin
return has_space (To_String (s));
end has_space;
function element_in_list
(e : in Unbounded_String;
l : in unbounded_string_list) return Boolean
is
current : unbounded_string_ptr;
is_found : Boolean := False;
local_iterator : unbounded_string_iterator;
begin
reset_head_iterator (l, local_iterator);
current_element (l, current, local_iterator);
while not is_tail_element (l, local_iterator) loop
if current.all = e then
is_found := True;
exit;
end if;
next_element (l, local_iterator);
end loop;
if current.all = e then
is_found := True;
end if;
return is_found;
end element_in_list;
function convert (a : in Unbounded_String) return Unbounded_String is
begin
return a;
end convert;
function substring
(Str : in Unbounded_String;
From : in Natural;
To : in Natural) return Unbounded_String
is
begin
return To_Unbounded_String (To_String (Str) (From .. To));
end substring;
end unbounded_strings;
|