Panda3D
Loading...
Searching...
No Matches
rangeIterator.cxx
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file rangeIterator.cxx
10 * @author drose
11 * @date 2003-09-07
12 */
13
14#include "rangeIterator.h"
15
16/**
17 * Constructs an iterator to walk through the codes on the descriptor. It is
18 * important not to modify the RangeDescription object during the lifetime of
19 * the iterator.
20 */
23 _desc(desc)
24{
25 _it = _desc._range_list.begin();
26 if (_it == _desc._range_list.end()) {
27 _code = -1;
28 } else {
29 _code = (*_it)._from_code;
30 _codes_generated.insert(_code);
31 }
32}
33
34/**
35 * Advances the iterator to the next code. Returns true if there is a next
36 * code, or false if there are no mode codes.
37 */
39next() {
40 do {
41 if (_it == _desc._range_list.end()) {
42 return false;
43 }
44
45 if (_code < (*_it)._to_code) {
46 _code++;
47
48 } else {
49 _it++;
50 if (_it == _desc._range_list.end()) {
51 _code = -1;
52 return false;
53 }
54
55 _code = (*_it)._from_code;
56 }
57
58 // If this code has already been generated, repeat and skip to the next
59 // one.
60 } while (!_codes_generated.insert(_code).second);
61
62 return true;
63}
This describes a sparse range of Unicode character codes for conversion that may be specified on the ...
bool next()
Advances the iterator to the next code.
RangeIterator(const RangeDescription &desc)
Constructs an iterator to walk through the codes on the descriptor.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.