1------------------------------------------------------------------------------ 2-- -- 3-- GNAT RUN-TIME COMPONENTS -- 4-- -- 5-- ADA.STRINGS.TEXT_BUFFERS.UNBOUNDED -- 6-- -- 7-- S p e c -- 8-- -- 9-- This specification is derived from the Ada Reference Manual for use with -- 10-- GNAT. In accordance with the copyright of that document, you can freely -- 11-- copy and modify this specification, provided that if you redistribute a -- 12-- modified version, any changes that you have made are clearly indicated. -- 13-- -- 14------------------------------------------------------------------------------ 15 16with Ada.Finalization; 17package Ada.Strings.Text_Buffers.Unbounded with 18 Preelaborate 19 -- , Nonblocking 20 -- , Global => null 21is 22 23 type Buffer_Type is new Root_Buffer_Type with private; 24 25 function Get (Buffer : in out Buffer_Type) return String with 26 Post'Class => Get'Result'First = 1 and then Current_Indent (Buffer) = 0; 27 28 function Wide_Get (Buffer : in out Buffer_Type) return Wide_String with 29 Post'Class => Wide_Get'Result'First = 1 30 and then Current_Indent (Buffer) = 0; 31 32 function Wide_Wide_Get 33 (Buffer : in out Buffer_Type) return Wide_Wide_String with 34 Post'Class => Wide_Wide_Get'Result'First = 1 35 and then Current_Indent (Buffer) = 0; 36 37 function Get_UTF_8 38 (Buffer : in out Buffer_Type) return UTF_Encoding.UTF_8_String with 39 Post'Class => Get_UTF_8'Result'First = 1 40 and then Current_Indent (Buffer) = 0; 41 42 function Wide_Get_UTF_16 43 (Buffer : in out Buffer_Type) return UTF_Encoding.UTF_16_Wide_String with 44 Post'Class => Wide_Get_UTF_16'Result'First = 1 45 and then Current_Indent (Buffer) = 0; 46 47private 48 49 procedure Put_UTF_8_Implementation 50 (Buffer : in out Root_Buffer_Type'Class; 51 Item : UTF_Encoding.UTF_8_String) 52 with Pre => Buffer in Buffer_Type'Class; 53 54 package Mapping is new Output_Mapping (Put_UTF_8_Implementation); 55 56 type Chunk; 57 type Chunk_Access is access all Chunk; 58 type Chunk (Length : Positive) is record 59 Next : Chunk_Access := null; 60 Chars : UTF_Encoding.UTF_8_String (1 .. Length); 61 end record; 62 63 type Managed_Chunk_List is new Ada.Finalization.Limited_Controlled with 64 record 65 First_Chunk : aliased Chunk (64); 66 -- First chunk in list is not created by an allocator; it is 67 -- large enough to suffice for many common images. 68 69 Current_Chunk : Chunk_Access; 70 -- Chunk we are currrently writing to. 71 -- Initialized to Managed_Chunk_List.First'Access. 72 end record; 73 74 overriding procedure Initialize (List : in out Managed_Chunk_List); 75 -- List.Current_Chunk := List.First_Chunk'Unchecked_Access; 76 77 overriding procedure Finalize (List : in out Managed_Chunk_List); 78 -- Free any allocated chunks. 79 80 type Buffer_Type is new Mapping.Buffer_Type with record 81 List : Managed_Chunk_List; 82 83 Last_Used : Natural := 0; 84 -- Index of last used char in List.Current_Chunk.all; 0 if none used. 85 end record; 86 87end Ada.Strings.Text_Buffers.Unbounded; 88