de-errno
[dragonfly.git] / contrib / gperf / src / iterator.h
1 /* This may look like C code, but it is really -*- C++ -*- */
2
3 /* Provides an Iterator for keyword characters.
4
5    Copyright (C) 1989-1998 Free Software Foundation, Inc.
6    written by Douglas C. Schmidt (schmidt@ics.uci.edu)
7
8 This file is part of GNU GPERF.
9
10 GNU GPERF is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 1, or (at your option)
13 any later version.
14
15 GNU GPERF is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with GNU GPERF; see the file COPYING.  If not, write to the Free
22 Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.  */
23
24 /* Provides an Iterator that expands and decodes a control string containing digits
25    and ranges, returning an integer every time the generator function is called.
26    This is used to decode the user's key position requests.  For example:
27    "-k 1,2,5-10,$"  will return 1, 2, 5, 6, 7, 8, 9, 10, and 0 ( representing
28    the abstract ``last character of the key'' on successive calls to the
29    member function operator ().
30    No errors are handled in these routines, they are passed back to the
31    calling routines via a user-supplied Error_Value */
32
33 #ifndef iterator_h
34 #define iterator_h 1
35
36 class Iterator
37 {
38 private:
39   const char *str;              /* A pointer to the string provided by the user. */
40   int   end;                    /* Value returned after last key is processed. */
41   int   end_word;               /* A value marking the abstract ``end of word'' ( usually '$'). */
42   int   error_value;            /* Error value returned when input is syntactically erroneous. */
43   int   hi_bound;               /* Greatest possible value, inclusive. */
44   int   lo_bound;               /* Smallest possible value, inclusive. */
45
46 public:
47         Iterator (const char *s, int lo, int hi, int word_end, int bad_val, int key_end);
48   int   operator () (void);
49 };
50
51 #endif