agpl_1.0.0_b5da3320/src/agpl-strings-pointers.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
 

with Agpl.Types.Ustrings; use Agpl.Types.Ustrings;

with Ada.Finalization;
with Ada.Unchecked_Deallocation;

package Agpl.Strings.Pointers is

   --  To have a String but allocated in heap.

   pragma Preelaborate;

   type String_Access is access all String;

   type Object is tagged private;

   function Create (This : String) return Object;
   function Create (This : Ustring) return Object;

   function Ref (This : Object) return String_Access;

   procedure Free is new Ada.Unchecked_Deallocation (String, String_Access);

private

   type Object is new Ada.Finalization.Controlled with record
      Ptr : String_Access;
   end record;

   procedure Adjust     (This : in out Object);
   procedure Finalize   (This : in out Object);

end Agpl.Strings.Pointers;