1------------------------------------------------------------------------------
2--                                                                          --
3--                            Matreshka Project                             --
4--                                                                          --
5--                          Ada Modeling Framework                          --
6--                                                                          --
7--                        Runtime Library Component                         --
8--                                                                          --
9------------------------------------------------------------------------------
10--                                                                          --
11-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com>                --
12-- All rights reserved.                                                     --
13--                                                                          --
14-- Redistribution and use in source and binary forms, with or without       --
15-- modification, are permitted provided that the following conditions       --
16-- are met:                                                                 --
17--                                                                          --
18--  * Redistributions of source code must retain the above copyright        --
19--    notice, this list of conditions and the following disclaimer.         --
20--                                                                          --
21--  * Redistributions in binary form must reproduce the above copyright     --
22--    notice, this list of conditions and the following disclaimer in the   --
23--    documentation and/or other materials provided with the distribution.  --
24--                                                                          --
25--  * Neither the name of the Vadim Godunko, IE nor the names of its        --
26--    contributors may be used to endorse or promote products derived from  --
27--    this software without specific prior written permission.              --
28--                                                                          --
29-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS      --
30-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT        --
31-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    --
32-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     --
33-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   --
34-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
35-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR   --
36-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF   --
37-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     --
38-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS       --
39-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.             --
40--                                                                          --
41------------------------------------------------------------------------------
42--  $Revision: 2937 $ $Date: 2012-05-01 21:07:27 +0400 (Tue, 01 May 2012) $
43------------------------------------------------------------------------------
44with AMF.Elements;
45with AMF.Internals.Element_Collections;
46with AMF.Internals.Helpers;
47with AMF.Internals.Tables.UML_Attributes;
48with AMF.Visitors.UML_Iterators;
49with AMF.Visitors.UML_Visitors;
50with League.Strings.Internals;
51with Matreshka.Internals.Strings;
52
53package body AMF.Internals.UML_Literal_Strings is
54
55   -------------------
56   -- Enter_Element --
57   -------------------
58
59   overriding procedure Enter_Element
60    (Self    : not null access constant UML_Literal_String_Proxy;
61     Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
62     Control : in out AMF.Visitors.Traverse_Control) is
63   begin
64      if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
65         AMF.Visitors.UML_Visitors.UML_Visitor'Class
66          (Visitor).Enter_Literal_String
67            (AMF.UML.Literal_Strings.UML_Literal_String_Access (Self),
68           Control);
69      end if;
70   end Enter_Element;
71
72   -------------------
73   -- Leave_Element --
74   -------------------
75
76   overriding procedure Leave_Element
77    (Self    : not null access constant UML_Literal_String_Proxy;
78     Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
79     Control : in out AMF.Visitors.Traverse_Control) is
80   begin
81      if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
82         AMF.Visitors.UML_Visitors.UML_Visitor'Class
83          (Visitor).Leave_Literal_String
84            (AMF.UML.Literal_Strings.UML_Literal_String_Access (Self),
85           Control);
86      end if;
87   end Leave_Element;
88
89   -------------------
90   -- Visit_Element --
91   -------------------
92
93   overriding procedure Visit_Element
94    (Self     : not null access constant UML_Literal_String_Proxy;
95     Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
96     Visitor  : in out AMF.Visitors.Abstract_Visitor'Class;
97     Control  : in out AMF.Visitors.Traverse_Control) is
98   begin
99      if Iterator in AMF.Visitors.UML_Iterators.UML_Iterator'Class then
100         AMF.Visitors.UML_Iterators.UML_Iterator'Class
101          (Iterator).Visit_Literal_String
102            (Visitor,
103             AMF.UML.Literal_Strings.UML_Literal_String_Access (Self),
104             Control);
105      end if;
106   end Visit_Element;
107
108   ---------------
109   -- Get_Value --
110   ---------------
111
112   overriding function Get_Value
113    (Self : not null access constant UML_Literal_String_Proxy)
114       return AMF.Optional_String is
115   begin
116      declare
117         use type Matreshka.Internals.Strings.Shared_String_Access;
118
119         Aux : constant Matreshka.Internals.Strings.Shared_String_Access
120           := AMF.Internals.Tables.UML_Attributes.Internal_Get_Value (Self.Element);
121
122      begin
123         if Aux = null then
124            return (Is_Empty => True);
125
126         else
127            return (False, League.Strings.Internals.Create (Aux));
128         end if;
129      end;
130   end Get_Value;
131
132   ---------------
133   -- Set_Value --
134   ---------------
135
136   overriding procedure Set_Value
137    (Self : not null access UML_Literal_String_Proxy;
138     To   : AMF.Optional_String) is
139   begin
140      if To.Is_Empty then
141         AMF.Internals.Tables.UML_Attributes.Internal_Set_Value
142          (Self.Element, null);
143
144      else
145         AMF.Internals.Tables.UML_Attributes.Internal_Set_Value
146          (Self.Element,
147           League.Strings.Internals.Internal (To.Value));
148      end if;
149   end Set_Value;
150
151   --------------
152   -- Get_Type --
153   --------------
154
155   overriding function Get_Type
156    (Self : not null access constant UML_Literal_String_Proxy)
157       return AMF.UML.Types.UML_Type_Access is
158   begin
159      return
160        AMF.UML.Types.UML_Type_Access
161         (AMF.Internals.Helpers.To_Element
162           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Type
163             (Self.Element)));
164   end Get_Type;
165
166   --------------
167   -- Set_Type --
168   --------------
169
170   overriding procedure Set_Type
171    (Self : not null access UML_Literal_String_Proxy;
172     To   : AMF.UML.Types.UML_Type_Access) is
173   begin
174      AMF.Internals.Tables.UML_Attributes.Internal_Set_Type
175       (Self.Element,
176        AMF.Internals.Helpers.To_Element
177         (AMF.Elements.Element_Access (To)));
178   end Set_Type;
179
180   ---------------------------
181   -- Get_Client_Dependency --
182   ---------------------------
183
184   overriding function Get_Client_Dependency
185    (Self : not null access constant UML_Literal_String_Proxy)
186       return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is
187   begin
188      return
189        AMF.UML.Dependencies.Collections.Wrap
190         (AMF.Internals.Element_Collections.Wrap
191           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency
192             (Self.Element)));
193   end Get_Client_Dependency;
194
195   -------------------------
196   -- Get_Name_Expression --
197   -------------------------
198
199   overriding function Get_Name_Expression
200    (Self : not null access constant UML_Literal_String_Proxy)
201       return AMF.UML.String_Expressions.UML_String_Expression_Access is
202   begin
203      return
204        AMF.UML.String_Expressions.UML_String_Expression_Access
205         (AMF.Internals.Helpers.To_Element
206           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression
207             (Self.Element)));
208   end Get_Name_Expression;
209
210   -------------------------
211   -- Set_Name_Expression --
212   -------------------------
213
214   overriding procedure Set_Name_Expression
215    (Self : not null access UML_Literal_String_Proxy;
216     To   : AMF.UML.String_Expressions.UML_String_Expression_Access) is
217   begin
218      AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression
219       (Self.Element,
220        AMF.Internals.Helpers.To_Element
221         (AMF.Elements.Element_Access (To)));
222   end Set_Name_Expression;
223
224   -------------------
225   -- Get_Namespace --
226   -------------------
227
228   overriding function Get_Namespace
229    (Self : not null access constant UML_Literal_String_Proxy)
230       return AMF.UML.Namespaces.UML_Namespace_Access is
231   begin
232      return
233        AMF.UML.Namespaces.UML_Namespace_Access
234         (AMF.Internals.Helpers.To_Element
235           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace
236             (Self.Element)));
237   end Get_Namespace;
238
239   ------------------------
240   -- Get_Qualified_Name --
241   ------------------------
242
243   overriding function Get_Qualified_Name
244    (Self : not null access constant UML_Literal_String_Proxy)
245       return AMF.Optional_String is
246   begin
247      declare
248         use type Matreshka.Internals.Strings.Shared_String_Access;
249
250         Aux : constant Matreshka.Internals.Strings.Shared_String_Access
251           := AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element);
252
253      begin
254         if Aux = null then
255            return (Is_Empty => True);
256
257         else
258            return (False, League.Strings.Internals.Create (Aux));
259         end if;
260      end;
261   end Get_Qualified_Name;
262
263   -----------------------------------
264   -- Get_Owning_Template_Parameter --
265   -----------------------------------
266
267   overriding function Get_Owning_Template_Parameter
268    (Self : not null access constant UML_Literal_String_Proxy)
269       return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
270   begin
271      return
272        AMF.UML.Template_Parameters.UML_Template_Parameter_Access
273         (AMF.Internals.Helpers.To_Element
274           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Owning_Template_Parameter
275             (Self.Element)));
276   end Get_Owning_Template_Parameter;
277
278   -----------------------------------
279   -- Set_Owning_Template_Parameter --
280   -----------------------------------
281
282   overriding procedure Set_Owning_Template_Parameter
283    (Self : not null access UML_Literal_String_Proxy;
284     To   : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
285   begin
286      AMF.Internals.Tables.UML_Attributes.Internal_Set_Owning_Template_Parameter
287       (Self.Element,
288        AMF.Internals.Helpers.To_Element
289         (AMF.Elements.Element_Access (To)));
290   end Set_Owning_Template_Parameter;
291
292   ----------------------------
293   -- Get_Template_Parameter --
294   ----------------------------
295
296   overriding function Get_Template_Parameter
297    (Self : not null access constant UML_Literal_String_Proxy)
298       return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
299   begin
300      return
301        AMF.UML.Template_Parameters.UML_Template_Parameter_Access
302         (AMF.Internals.Helpers.To_Element
303           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Template_Parameter
304             (Self.Element)));
305   end Get_Template_Parameter;
306
307   ----------------------------
308   -- Set_Template_Parameter --
309   ----------------------------
310
311   overriding procedure Set_Template_Parameter
312    (Self : not null access UML_Literal_String_Proxy;
313     To   : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
314   begin
315      AMF.Internals.Tables.UML_Attributes.Internal_Set_Template_Parameter
316       (Self.Element,
317        AMF.Internals.Helpers.To_Element
318         (AMF.Elements.Element_Access (To)));
319   end Set_Template_Parameter;
320
321   -------------------
322   -- Is_Computable --
323   -------------------
324
325   overriding function Is_Computable
326    (Self : not null access constant UML_Literal_String_Proxy)
327       return Boolean is
328   begin
329      --  Generated stub: replace with real body!
330      pragma Compile_Time_Warning (Standard.True, "Is_Computable unimplemented");
331      raise Program_Error with "Unimplemented procedure UML_Literal_String_Proxy.Is_Computable";
332      return Is_Computable (Self);
333   end Is_Computable;
334
335   ------------------
336   -- String_Value --
337   ------------------
338
339   overriding function String_Value
340    (Self : not null access constant UML_Literal_String_Proxy)
341       return League.Strings.Universal_String is
342   begin
343      --  Generated stub: replace with real body!
344      pragma Compile_Time_Warning (Standard.True, "String_Value unimplemented");
345      raise Program_Error with "Unimplemented procedure UML_Literal_String_Proxy.String_Value";
346      return String_Value (Self);
347   end String_Value;
348
349   ------------------------
350   -- Is_Compatible_With --
351   ------------------------
352
353   overriding function Is_Compatible_With
354    (Self : not null access constant UML_Literal_String_Proxy;
355     P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
356       return Boolean is
357   begin
358      --  Generated stub: replace with real body!
359      pragma Compile_Time_Warning (Standard.True, "Is_Compatible_With unimplemented");
360      raise Program_Error with "Unimplemented procedure UML_Literal_String_Proxy.Is_Compatible_With";
361      return Is_Compatible_With (Self, P);
362   end Is_Compatible_With;
363
364   ------------------
365   -- String_Value --
366   ------------------
367
368   overriding function String_Value
369    (Self : not null access constant UML_Literal_String_Proxy)
370       return AMF.Optional_String is
371   begin
372      --  Generated stub: replace with real body!
373      pragma Compile_Time_Warning (Standard.True, "String_Value unimplemented");
374      raise Program_Error with "Unimplemented procedure UML_Literal_String_Proxy.String_Value";
375      return String_Value (Self);
376   end String_Value;
377
378   -------------------------
379   -- All_Owning_Packages --
380   -------------------------
381
382   overriding function All_Owning_Packages
383    (Self : not null access constant UML_Literal_String_Proxy)
384       return AMF.UML.Packages.Collections.Set_Of_UML_Package is
385   begin
386      --  Generated stub: replace with real body!
387      pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented");
388      raise Program_Error with "Unimplemented procedure UML_Literal_String_Proxy.All_Owning_Packages";
389      return All_Owning_Packages (Self);
390   end All_Owning_Packages;
391
392   -----------------------------
393   -- Is_Distinguishable_From --
394   -----------------------------
395
396   overriding function Is_Distinguishable_From
397    (Self : not null access constant UML_Literal_String_Proxy;
398     N : AMF.UML.Named_Elements.UML_Named_Element_Access;
399     Ns : AMF.UML.Namespaces.UML_Namespace_Access)
400       return Boolean is
401   begin
402      --  Generated stub: replace with real body!
403      pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
404      raise Program_Error with "Unimplemented procedure UML_Literal_String_Proxy.Is_Distinguishable_From";
405      return Is_Distinguishable_From (Self, N, Ns);
406   end Is_Distinguishable_From;
407
408   ---------------
409   -- Namespace --
410   ---------------
411
412   overriding function Namespace
413    (Self : not null access constant UML_Literal_String_Proxy)
414       return AMF.UML.Namespaces.UML_Namespace_Access is
415   begin
416      --  Generated stub: replace with real body!
417      pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented");
418      raise Program_Error with "Unimplemented procedure UML_Literal_String_Proxy.Namespace";
419      return Namespace (Self);
420   end Namespace;
421
422   ---------------------------
423   -- Is_Template_Parameter --
424   ---------------------------
425
426   overriding function Is_Template_Parameter
427    (Self : not null access constant UML_Literal_String_Proxy)
428       return Boolean is
429   begin
430      --  Generated stub: replace with real body!
431      pragma Compile_Time_Warning (Standard.True, "Is_Template_Parameter unimplemented");
432      raise Program_Error with "Unimplemented procedure UML_Literal_String_Proxy.Is_Template_Parameter";
433      return Is_Template_Parameter (Self);
434   end Is_Template_Parameter;
435
436end AMF.Internals.UML_Literal_Strings;
437