asn1_iterators-generic_iterator.adb 997 Bytes
Newer Older
1 2
package body ASN1_Iterators.Generic_Iterator is

3 4 5 6 7
--   procedure Initialize (Self: in out Generic_Iterator_Type) is
--   begin
--       Self.Item.Initialize;
--       Self.Item.Value := ASN1_Iterable.First(ASN1_Iterable.Iterable'Class(Self.Item));
--   end;
8 9

    function First (Item : Iterator) return Cursor is
10
        C: constant Cursor := Item.Position;
11
    begin
12
        C.Item.Value := ASN1_Iterable.First(ASN1_Iterable.Iterable'Class(Item.Position.all.Item));
13 14 15 16
        return C;
    end;

    function Next  (Item : Iterator;
17
                    Position  : Cursor)
18
    return Cursor is
19
        C: constant Cursor := Item.Position;
20
    begin
21
        C.Item.Value := ASN1_Iterable.Next(ASN1_Iterable.Iterable'Class(Position.all.Item));
22 23 24 25 26 27 28
        return C;
    end;

    function Iterate (self : Generic_Iterator_Type)
    return Iterators.Forward_Iterator'Class is
    begin
         return I: Iterator do
29
             I.Position := self'Unrestricted_Access;
30 31 32 33
         end return;
    end;

end;