asn1_iterators-generic_basic.ads 1.45 KB
Newer Older
1 2 3 4 5 6
with Ada.Iterator_Interfaces;
with Ada.Finalization;
use Ada.Finalization;
with ASN1_Iterators.SimpleTypes;

generic
Maxime Perrotin's avatar
Maxime Perrotin committed
7
   with package P is new SimpleTypes (<>);
8
package ASN1_Iterators.Generic_Basic is
Maxime Perrotin's avatar
Maxime Perrotin committed
9 10
   --  Provides an iterator for a basic type
   subtype Sort is P.Sort;
11

Maxime Perrotin's avatar
Maxime Perrotin committed
12 13 14 15 16 17 18 19
   type Basic_ASN1_Iterator is new Controlled
   with record
      Value    : P.SimpleType;
      Is_Valid : Boolean := True;
   end record
       with Default_Iterator  => Iterate,
            Iterator_Element  => P.Sort,
            Constant_Indexing => Elem_Value;
20

Maxime Perrotin's avatar
Maxime Perrotin committed
21
   procedure Initialize (self: in out Basic_ASN1_Iterator);
22

Maxime Perrotin's avatar
Maxime Perrotin committed
23
   type Cursor is access all Basic_ASN1_Iterator;
24

25
   function Has_Element (Position : Cursor) return Boolean;
26

Maxime Perrotin's avatar
Maxime Perrotin committed
27 28
   package Iterators is
       new Ada.Iterator_Interfaces (Cursor, Has_Element);
29

Maxime Perrotin's avatar
Maxime Perrotin committed
30
   type Iterator is new Iterators.Forward_Iterator with record
31
       Position : Cursor;
Maxime Perrotin's avatar
Maxime Perrotin committed
32
   end record;
33

34
   function Get_Cursor (Item : Iterator) return Cursor is (Item.Position);
35

Maxime Perrotin's avatar
Maxime Perrotin committed
36 37
   overriding function First (Item : Iterator)     return Cursor;
   overriding function Next  (Item : Iterator;
38
                              Position  : Cursor) return Cursor;
39

Maxime Perrotin's avatar
Maxime Perrotin committed
40
   subtype Forward_Iterator is Iterators.Forward_Iterator'Class;
41

Maxime Perrotin's avatar
Maxime Perrotin committed
42
   function Iterate (Self : Basic_ASN1_Iterator) return Forward_Iterator;
43

Maxime Perrotin's avatar
Maxime Perrotin committed
44
   function Elem_Value (Self : Basic_ASN1_Iterator;
45 46
                        Position  : Cursor)
      return P.Sort is (Position.Value.Element_Value);
Maxime Perrotin's avatar
Maxime Perrotin committed
47
end ASN1_Iterators.Generic_Basic;