iterator.hon commit get-tar-commit-id: parse comment record (3548726)
   1#ifndef ITERATOR_H
   2#define ITERATOR_H
   3
   4/*
   5 * Generic constants related to iterators.
   6 */
   7
   8/*
   9 * The attempt to advance the iterator was successful; the iterator
  10 * reflects the new current entry.
  11 */
  12#define ITER_OK 0
  13
  14/*
  15 * The iterator is exhausted and has been freed.
  16 */
  17#define ITER_DONE -1
  18
  19/*
  20 * The iterator experienced an error. The iteration has been aborted
  21 * and the iterator has been freed.
  22 */
  23#define ITER_ERROR -2
  24
  25/*
  26 * Return values for selector functions for merge iterators. The
  27 * numerical values of these constants are important and must be
  28 * compatible with ITER_DONE and ITER_ERROR.
  29 */
  30enum iterator_selection {
  31        /* End the iteration without an error: */
  32        ITER_SELECT_DONE = ITER_DONE,
  33
  34        /* Report an error and abort the iteration: */
  35        ITER_SELECT_ERROR = ITER_ERROR,
  36
  37        /*
  38         * The next group of constants are masks that are useful
  39         * mainly internally.
  40         */
  41
  42        /* The LSB selects whether iter0/iter1 is the "current" iterator: */
  43        ITER_CURRENT_SELECTION_MASK = 0x01,
  44
  45        /* iter0 is the "current" iterator this round: */
  46        ITER_CURRENT_SELECTION_0 = 0x00,
  47
  48        /* iter1 is the "current" iterator this round: */
  49        ITER_CURRENT_SELECTION_1 = 0x01,
  50
  51        /* Yield the value from the current iterator? */
  52        ITER_YIELD_CURRENT = 0x02,
  53
  54        /* Discard the value from the secondary iterator? */
  55        ITER_SKIP_SECONDARY = 0x04,
  56
  57        /*
  58         * The constants that a selector function should usually
  59         * return.
  60         */
  61
  62        /* Yield the value from iter0: */
  63        ITER_SELECT_0 = ITER_CURRENT_SELECTION_0 | ITER_YIELD_CURRENT,
  64
  65        /* Yield the value from iter0 and discard the one from iter1: */
  66        ITER_SELECT_0_SKIP_1 = ITER_SELECT_0 | ITER_SKIP_SECONDARY,
  67
  68        /* Discard the value from iter0 without yielding anything this round: */
  69        ITER_SKIP_0 = ITER_CURRENT_SELECTION_1 | ITER_SKIP_SECONDARY,
  70
  71        /* Yield the value from iter1: */
  72        ITER_SELECT_1 = ITER_CURRENT_SELECTION_1 | ITER_YIELD_CURRENT,
  73
  74        /* Yield the value from iter1 and discard the one from iter0: */
  75        ITER_SELECT_1_SKIP_0 = ITER_SELECT_1 | ITER_SKIP_SECONDARY,
  76
  77        /* Discard the value from iter1 without yielding anything this round: */
  78        ITER_SKIP_1 = ITER_CURRENT_SELECTION_0 | ITER_SKIP_SECONDARY
  79};
  80
  81#endif /* ITERATOR_H */