text stringlengths 0 234 |
|---|
begin |
return AUnit.Format ("Chunk tests for String_Pool"); |
end Name; |
procedure Test_One_String (T : in out Test_Cases.Test_Case'Class) is |
Test_Data : constant String := "123456"; |
C : constant Reference := TC (T).P.From_String (Test_Data); |
begin |
Ada.Text_IO.Put_Line ("Test one string, chunk content:"); |
Ada.Text_IO.Put_Line (TC (T).P.Current_Chunk_As_String); |
Assert (C = Test_Data, "Data mismatch!"); |
declare |
C2 : constant Reference := C; |
begin |
Ada.Text_IO.Put_Line ("Range after copy: (" & C2.Data.all'First'Img & |
" .." & C2.Data.all'Last'Img & ')'); |
Function Definition: procedure Free is new Ada.Unchecked_Deallocation |
Function Body: (String, Buffer_Type); |
subtype Line_End is Character with Static_Predicate => |
Line_End in Line_Feed | Carriage_Return | End_Of_Input; |
procedure Init (Object : in out Instance; Input : Source.Pointer; |
Initial_Buffer_Size : Positive := |
Default_Initial_Buffer_Size) is |
begin |
Object.Internal.Input := Input; |
Object.Buffer := new String (1 .. Initial_Buffer_Size); |
Object.Internal.Sentinel := Initial_Buffer_Size + 1; |
Refill_Buffer (Object); |
end Init; |
procedure Init (Object : in out Instance; Input : String) is |
begin |
Object.Internal.Input := null; |
Object.Buffer := new String (1 .. Input'Length + 1); |
Object.Internal.Sentinel := Input'Length + 2; |
Object.Buffer.all := Input & End_Of_Input; |
end Init; |
function Next (Object : in out Instance) return Character is |
begin |
return C : constant Character := Object.Buffer (Object.Pos) do |
Object.Pos := Object.Pos + 1; |
end return; |
end Next; |
procedure Refill_Buffer (L : in out Instance) is |
Bytes_To_Copy : constant Natural := L.Buffer'Last + 1 - L.Internal.Sentinel; |
Fill_At : Positive := Bytes_To_Copy + 1; |
Bytes_Read : Positive; |
function Search_Sentinel return Boolean with Inline is |
Peek : Positive := L.Buffer'Last; |
begin |
while not (L.Buffer (Peek) in Line_End) loop |
if Peek = Fill_At then |
return False; |
else |
Peek := Peek - 1; |
end if; |
end loop; |
L.Internal.Sentinel := Peek + 1; |
return True; |
end Search_Sentinel; |
begin |
if Bytes_To_Copy > 0 then |
L.Buffer (1 .. Bytes_To_Copy) := |
L.Buffer (L.Internal.Sentinel .. L.Buffer'Last); |
end if; |
loop |
L.Internal.Input.Read_Data |
(L.Buffer (Fill_At .. L.Buffer'Last), Bytes_Read); |
if Bytes_Read < L.Buffer'Last - Fill_At then |
L.Internal.Sentinel := Fill_At + Bytes_Read + 1; |
L.Buffer (L.Internal.Sentinel - 1) := End_Of_Input; |
exit; |
else |
exit when Search_Sentinel; |
Fill_At := L.Buffer'Last + 1; |
declare |
New_Buffer : constant Buffer_Type := |
new String (1 .. 2 * L.Buffer'Last); |
begin |
New_Buffer.all (L.Buffer'Range) := L.Buffer.all; |
Free (L.Buffer); |
L.Buffer := New_Buffer; |
Function Definition: function Convert is new Ada.Unchecked_Conversion |
Function Body: (System.Address, Header_Access); |
use System.Storage_Elements; |
begin |
return Convert (S.all'Address - Storage_Offset (Header_Size)); |
end Header_Of; |
function Value (Object : Reference) return Accessor is |
(Accessor'(Data => Object.Data, Hold => Object)); |
function Length (Object : Reference) return Natural is |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.