asn1_iterators-iterable_integer.ads 1.2 KB
Newer Older
1 2 3 4 5 6 7 8 9
with Interfaces;
use Interfaces;

with ASN1_Iterators.Iterable_Type;
with ASN1_Iterators.Generic_Iterator;

generic
    Min, Max: Integer_64;
package ASN1_Iterators.Iterable_Integer is
10 11 12 13 14
    package Pkg is new ASN1_Iterators.Iterable_type (Integer_64);
    type ASN1_Integer is new Pkg.Iterable with null record;

    overriding
    procedure Initialize (It: in out ASN1_Integer) is null;
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

    overriding
    function Has_Element (It: ASN1_Integer) return Boolean is
        (It.Value <= Max);

    overriding
    function First (It: ASN1_Integer) return Integer_64 is
        (Min);

    overriding
    function Next (It: ASN1_Integer) return Integer_64 is
        (It.Value + 1);

    package Custom_Iterator is new ASN1_Iterators.Generic_Iterator
        (ASN1_Type       => Integer_64,
30
         ASN1_Iterable   => Pkg,
31 32 33 34 35 36 37 38 39
         Actual_Iterable => ASN1_Integer);

    subtype Instance is Custom_Iterator.Generic_Iterator_Type;
    -- If it is needed to iterate manually, provide Cursor and Iterator:
    subtype Cursor   is Custom_Iterator.Cursor;
    subtype Iterator is Custom_Iterator.Iterators.Forward_Iterator'Class;
    function Has_Element (Ptr: Cursor) return Boolean
        renames Custom_Iterator.Has_Element;
end;