File: dbf\array_handler.ads

    1 --::::::::::
    2 --arrahand.ads
    3 --::::::::::
    4 -- Developed by (C) Wasiliy W. Molostoff 1994, 1995.
    5 --                  Moscow, Russia,
    6 --                  Voice:   7 (095) 398-23-38
    7 --                  e-mail:  edv@edv.msk.ru
    8 -- This is free software; you can  freely  redistribute  it  and/or
    9 -- modify  it  without any restrictions.  Please report any errors.
   10 -- All corrections will be made as soon as possible.
   11 generic
   12 
   13    type elem_type  is private;
   14    type elem_array is array (positive range <>) of elem_type;
   15    default_width: positive;
   16    toolname: string := "array-handler";
   17    extra_check: boolean := true;
   18 
   19 package array_handler is
   20 
   21    type object (width: natural := default_width) is private;
   22 
   23       generic
   24           type operand is limited private;
   25           type result  is limited private;
   26           with function op (left:  in elem_array;
   27                             right: in operand) return result;
   28       function translating_poly_in  (left:  in object;
   29                          right: in operand;
   30                          from:  in positive := 1;
   31                          to:    in positive := positive'last) return result;
   32 
   33       generic
   34           type result is limited private;
   35           with function value (right: elem_array) return result is <>;
   36       function translating_mono_in   (right: in object;
   37                           from: in positive := 1;
   38                           to:   in positive := positive'last) return result;
   39       generic
   40           type operand is limited private;
   41           with procedure op (left:  in out elem_array; right: in operand);
   42       procedure transforming_poly_in_out (left:  in out object;
   43                              right: in operand;
   44                              from:  in positive := 1;
   45                              to:    in positive := positive'last);
   46 
   47       generic
   48           with procedure op (right: in out elem_array);
   49       procedure transforming_mono_in_out (right: in out object;
   50                              from:  in positive := 1;
   51                              to:    in positive := positive'last);
   52 
   53       generic
   54           with procedure op (data: in elem_array);
   55       procedure transfering_mono_in (item:   in object;
   56                            from: in positive := 1;
   57                            to:   in positive := positive'last);
   58 
   59       generic
   60           with procedure op (data: out elem_array);
   61       procedure transfering_mono_out (item:  in out object;
   62                            from: in positive := 1;
   63                            to:   in positive := positive'last);
   64 
   65       generic
   66           with procedure op (item: out elem_array; new_length: out natural);
   67       procedure transfering_mono_out_changes (item: in out object);
   68 
   69       generic
   70           type control is limited private;
   71           with procedure op (file: in control;
   72                              data: in elem_array);
   73       procedure transfering_poly_in (file:   in control;
   74                          item:   in object;
   75                            from: in positive := 1;
   76                            to:   in positive := positive'last);
   77 
   78       generic
   79           type control is limited private;
   80           with procedure op (file: in control;
   81                              data: in out elem_array);
   82       procedure transfering_poly_in_out (file: in control;
   83                              item: in out object;
   84                              from: in positive := 1;
   85                                to: in positive := positive'last);
   86 
   87       generic
   88           type control is limited private;
   89           with procedure op (file: in control;
   90                              data: out elem_array);
   91       procedure transfering_poly_out ( file: in control;
   92                            item: in out object;
   93                            from: in positive := 1;
   94                            to:   in positive := positive'last);
   95 
   96       generic
   97           type control is limited private;
   98           with procedure op (file: in control;
   99                              item: out elem_array; new_length: out natural);
  100       procedure transfering_poly_out_changes (file: in control;
  101                                   item: in out object);
  102 
  103    function length (item: object) return natural;
  104    pragma inline (length);
  105    function value  (item: object; position: positive) return elem_type;
  106    pragma inline (value);
  107    function value  (item: object; first, last: natural) return elem_array;
  108    pragma inline (value);
  109    function value  (item: object) return elem_array;
  110    pragma inline (value);
  111    function empty  (item: object) return boolean;
  112    pragma inline (empty);
  113 
  114    function value (item: elem_array) return object;
  115    pragma inline (value);
  116    function value (item: elem_type)  return object;
  117    pragma inline (value);
  118 
  119    function "&"  (left: object; right: object) return object;
  120    function "&"  (left: object; right: elem_array) return object;
  121    function "&"  (left: elem_array; right: object) return object;
  122    function "&"  (left: object; right: elem_type ) return object;
  123    function "&"  (left: elem_type ; right: object) return object;
  124 
  125    procedure set   (item: in out object; value: in object);
  126    procedure set   (item: in out object; value: in elem_array);
  127    procedure set   (item: in out object; value: in elem_type);
  128    procedure set   (item: in out object;
  129                    value: in elem_type;
  130                    times: in positive);
  131 
  132    procedure clear (item: in out object; from: in positive := 1);
  133    pragma inline (clear);
  134 
  135    procedure set_length (item: in out object; len: in natural);
  136    pragma inline (set_length);
  137 
  138    procedure append (tail: in object; to: in out object);
  139    procedure append (tail: in elem_array; to: in out object);
  140    procedure append (tail: in elem_type ; to: in out object);
  141    procedure append (tail: in object; to: in out object;
  142                      len:  in natural;
  143                      pos:  in positive := 1);
  144 
  145    procedure amend (item: in out object; by: in object; position: in positive);
  146    procedure amend (item: in out object; by: in elem_array; position: in positive);
  147    procedure amend (item: in out object; by: in elem_type ; position: in positive);
  148 
  149    function locate (frag:   object;
  150                   within:   object;
  151                     from:   positive := 1;
  152                     to:     positive := positive'last) return natural;
  153    function locate (frag:   elem_array;
  154                   within:   object;
  155                     from:   positive := 1;
  156                     to:     positive := positive'last) return natural;
  157    function locate (frag:   elem_type;
  158                     within: object;
  159                     from:   positive := 1;
  160                     to:     positive := positive'last) return natural;
  161 
  162    procedure delete   (item: in out object; from, to: positive);
  163    procedure expand   (item: in out object; from, to: positive);
  164    procedure exchange (item_a, item_b: in out object);
  165 
  166    procedure insert (item:    in out object;
  167                      frag:    in     elem_type;
  168                      from:    in     positive;
  169                      replace: in     natural  := 0);
  170 
  171    procedure insert (item:    in out object;
  172                      frag:    in     elem_array;
  173                      from:    in     positive;
  174                      replace: in     natural := 0);
  175 
  176    procedure insert (item:    in out object;
  177                      frag:    in     object;
  178                      from:    in     positive;
  179                      replace: in     natural := 0);
  180 
  181    function prefix (a, b: object) return natural;
  182    function suffix (a, b: object) return natural;
  183 
  184    private
  185 
  186       type object (width: natural := default_width)
  187       is record
  188          len    : natural := 0;
  189          data   : elem_array (1..width);
  190       end record;
  191 
  192 end array_handler;
  193