asn1_iterators-iterable_seqof.adb 1.25 KB
Newer Older
1 2
with Ada.Text_IO;
use Ada.Text_IO;
3
with Ada.Iterator_Interfaces;
4 5 6 7 8

package body ASN1_Iterators.Iterable_SeqOF is

    procedure Initialize (It: in out ASN1_SequenceOf) is
    begin
9 10
        null;
        -- deprecated
11 12 13 14 15 16 17
    end;

    function Has_Element (It: ASN1_SequenceOf) return Boolean is
    begin
        return False;
    end;

18 19
    function First (It: in out ASN1_SequenceOf) return Generic_SeqOf is
        Ret : constant Generic_SeqOf := It.Value;
20
    begin
21 22 23 24 25 26 27 28 29 30
        It.Value.Length := It.Length;
        Put_Line ("Computing first of length " & It.Length'Img);
        -- Initialize the recursive structure (once)
        if It.Length > 1 and then It.Rest = Null then
            Put_Line  ("Initialize Length " & It.Length'Img);
            It.Rest               := new Instance;
            It.Rest.Item.Length   := It.Length - 1;
            It.Rest_It            :=
                new Cust_Iterator'(Custom_Iterator.Iterator (It.Rest.Iterate)
                                   with others => <>);
31
            It.Rest_It.Position        := It.Rest_It.First;
32 33
        end if;
        return Ret;
34 35 36 37 38 39 40 41
    end;

    function Next (It: ASN1_SequenceOf) return Generic_SeqOf is
        Temp : constant Generic_SeqOf := It.Value;
    begin
          return Temp;
    end;
end;