test_new_iterators.adb 1.19 KB
Newer Older
1
with ASN1_Iterators.Iterable_Integer,
2
     ASN1_Iterators.Iterable_SeqOF,
3 4 5 6 7 8 9 10 11 12
     Ada.Text_IO;

use ASN1_Iterators,
    Ada.Text_IO;

procedure test_new_iterators is
    package MyInt is new ASN1_Iterators.Iterable_Integer (5, 10);
    It: MyInt.Instance;
    Iter: MyInt.Iterator := It.Iterate;
    C: MyInt.Cursor;
13 14

    -- SEQUENCE OF
15
    package MySeqOf is new ASN1_Iterators.Iterable_SeqOF (3, 5, MyInt.Custom_Iterator);
16
    ItSO : MySeqOf.Instance;
17 18
    IterSO : MySeqOf.Iterator := ItSO.Iterate;
    CSO : MySeqOf.Cursor;
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
begin
    Put_Line ("Hello");
    Put_Line ("With 'for each of':");
    for each of It loop
        Put_Line (each'img);
    end loop;
    Put_Line ("With 'for each in':");
    for each in It.Iterate loop
        Put_Line (It.Element (each)'Img);
    end loop;
    -- With manual iterators:
    Put_Line ("With manual iterators:");
    C := Iter.First;
    while MyInt.Has_Element (C) loop
        Put_Line (It.Element (C)'Img);
        C := Iter.Next (C);
    end loop;
36 37 38 39 40 41
    Put_Line ("SeqOF manual iterators:");
    CSO := IterSO.First;
    while MySeqOf.Has_Element (CSO) loop
        Put_Line ("Element"); -- ItSO.Element (CSO)'Img);
        CSO := IterSO.Next (CSO);
    end loop;
42
end;