4 * Copyright (C) 1989 Free Software Foundation, Inc.
5 * written by Douglas C. Schmidt (d.schmidt@vanderbilt.edu)
7 * This file is part of GNU GPERF.
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 #include "ace/OS_NS_ctype.h"
27 /// Constructor for Iterator.
28 Iterator::Iterator (char *s
,
37 error_value (bad_val
),
43 /// Provide an Iterator, returning the ``next'' value from the list of
44 /// valid values given in the constructor.
46 Iterator::operator() ()
48 // Variables to record the Iterator's status when handling ranges,
52 static int curr_value
;
53 static int upper_bound
;
57 if (++curr_value
>= upper_bound
)
66 default: return error_value
;
67 case ',': str
++; break;
68 case '$': str
++; return end_word
;
69 case '0': case '1': case '2': case '3': case '4':
70 case '5': case '6': case '7': case '8': case '9':
71 for (curr_value
= 0; ACE_OS::ace_isdigit (*str
); str
++)
73 curr_value
= curr_value
* 10 + *str
- '0';
78 for (size
= 1, upper_bound
= 0;
79 ACE_OS::ace_isdigit (*++str
);
80 upper_bound
= upper_bound
* 10 + *str
- '0')
85 if (upper_bound
<= curr_value
|| upper_bound
> hi_bound
)
91 return curr_value
>= lo_bound
&& curr_value
<= hi_bound