asn1_iterators-iterable_seqof.adb 2.65 KB
Newer Older
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
with Ada.Text_IO;
use Ada.Text_IO;

package body ASN1_Iterators.Iterable_SeqOF is

    procedure Initialize (It: in out ASN1_SequenceOf) is
--        Rest_Init : Instance;
    begin
         Put_Line ("Initialize Iterable_SeqOF length " & It.Length'Img);
--       It.Value.Length := It.Length;
--       if It.Length > 1 then
--           Rest_Init.Item.Length := It.Length - 1;
--           It.Rest               := new Instance'(Rest_Init);
--           It.Rest_It            := new Cust_Iterator'(Cust_Iterator(It.Rest.Iterate));
--           It.Rest_It.Ptr        := It.Rest_It.First;
--       end if;
    end;

    function Has_Element (It: ASN1_SequenceOf) return Boolean is
--      (P.Has_Element(P.Ptr(Ptr.FirstIt)));
    begin
        return False;
    end;

    function First (It: ASN1_SequenceOf) return Generic_SeqOf is
--        Ptr_elem : P.Iterator_Ptr := P.Ptr(Item.Ptr.FirstIt);
        Temp : constant Generic_SeqOf := It.Value;
    begin
      -- Initialize the iterator (Compute first value)
--     Item.Ptr.FirstIt := P.Iterator(Item.Ptr.FirstVal.Iterate);
--     Ptr_elem := P.First(Item.Ptr.FirstIt);
--     Item.Ptr.Value.Data(1) := P.Elem_Value(Item.Ptr.FirstVal,
--                                            Ptr_elem);
--     if Item.Ptr.Length > 1 then
--         Item.Ptr.Value.Data(2 .. Item.Ptr.Length) :=
--             Item.Ptr.Rest_It.Ptr.Value.Data(1..Item.Ptr.Rest_It.Ptr.Length);
--     end if;
--     return Item.Ptr;
        return Temp;
    end;

    function Next (It: ASN1_SequenceOf) return Generic_SeqOf is
        --Ptr_elem : P.Iterator_Ptr := P.Ptr(Ptr.FirstIt);
        Temp : constant Generic_SeqOf := It.Value;
    begin
--     if Ptr.Length > 1 then
--         Ptr.Rest_It.Ptr := Ptr.Rest_It.Next (Ptr.Rest_It.Ptr);
--         if Has_Element_SeqOf (Ptr.Rest_It.Ptr) then
--             Ptr.Value.Data (2..Ptr.Length) :=
--                   Ptr.Rest_It.Ptr.Value.Data (1..Ptr.Rest_It.Ptr.Value.Length);
--         else
--             Ptr.Rest_It.Ptr := Ptr.Rest_It.First;
--             -- Exhausted "rest": iterate on the first item
--             Ptr_elem := P.Next(Ptr.FirstIt, Ptr_elem);
--             if P.Has_Element (Ptr_elem) then
--                 Ptr.Value.Data(1) := P.Elem_Value(Ptr.FirstVal, Ptr_elem);
--                 Ptr.Value.Data(2..Ptr.Length) := Ptr.Rest_It.Ptr.Value.Data (1..Ptr.Rest_It.Ptr.Length);
--             end if;
--         end if;
--    else
--        -- Size is 0 or 1
--        Ptr_elem := P.Next(Ptr.FirstIt, Ptr_elem);
--        if P.Has_Element (Ptr_elem) then
--            Ptr.Value.Data(1) := P.Elem_Value(Ptr.FirstVal, Ptr_elem);
--        end if;
--     end if;
--    return Ptr;
          return Temp;
    end;
end;