asn1_iterators-generic_iterator.adb 967 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 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

    function First (Item : Iterator) return Cursor is
        C: constant Cursor := Item.Ptr;
    begin
        C.Item.Value := ASN1_Iterable.First(ASN1_Iterable.Iterable'Class(Item.Ptr.all.Item));
        return C;
    end;

    function Next  (Item : Iterator;
                    Ptr  : Cursor)
    return Cursor is
        C: constant Cursor := Item.Ptr;
    begin
        C.Item.Value := ASN1_Iterable.Next(ASN1_Iterable.Iterable'Class(Ptr.all.Item));
        return C;
    end;

    function Iterate (self : Generic_Iterator_Type)
    return Iterators.Forward_Iterator'Class is
    begin
         return I: Iterator do
             I.Ptr := self'Unrestricted_Access;
         end return;
    end;

end;