Line data Source code
1 : // © 2016 and later: Unicode, Inc. and others.
2 : // License & terms of use: http://www.unicode.org/copyright.html
3 : /*
4 : **********************************************************************
5 : * Copyright (C) 1999-2011, International Business Machines
6 : * Corporation and others. All Rights Reserved.
7 : **********************************************************************
8 : */
9 :
10 : #include "unicode/chariter.h"
11 :
12 : U_NAMESPACE_BEGIN
13 :
14 0 : ForwardCharacterIterator::~ForwardCharacterIterator() {}
15 0 : ForwardCharacterIterator::ForwardCharacterIterator()
16 0 : : UObject()
17 0 : {}
18 0 : ForwardCharacterIterator::ForwardCharacterIterator(const ForwardCharacterIterator &other)
19 0 : : UObject(other)
20 0 : {}
21 :
22 :
23 0 : CharacterIterator::CharacterIterator()
24 0 : : textLength(0), pos(0), begin(0), end(0) {
25 0 : }
26 :
27 0 : CharacterIterator::CharacterIterator(int32_t length)
28 0 : : textLength(length), pos(0), begin(0), end(length) {
29 0 : if(textLength < 0) {
30 0 : textLength = end = 0;
31 : }
32 0 : }
33 :
34 0 : CharacterIterator::CharacterIterator(int32_t length, int32_t position)
35 0 : : textLength(length), pos(position), begin(0), end(length) {
36 0 : if(textLength < 0) {
37 0 : textLength = end = 0;
38 : }
39 0 : if(pos < 0) {
40 0 : pos = 0;
41 0 : } else if(pos > end) {
42 0 : pos = end;
43 : }
44 0 : }
45 :
46 0 : CharacterIterator::CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position)
47 0 : : textLength(length), pos(position), begin(textBegin), end(textEnd) {
48 0 : if(textLength < 0) {
49 0 : textLength = 0;
50 : }
51 0 : if(begin < 0) {
52 0 : begin = 0;
53 0 : } else if(begin > textLength) {
54 0 : begin = textLength;
55 : }
56 0 : if(end < begin) {
57 0 : end = begin;
58 0 : } else if(end > textLength) {
59 0 : end = textLength;
60 : }
61 0 : if(pos < begin) {
62 0 : pos = begin;
63 0 : } else if(pos > end) {
64 0 : pos = end;
65 : }
66 0 : }
67 :
68 0 : CharacterIterator::~CharacterIterator() {}
69 :
70 0 : CharacterIterator::CharacterIterator(const CharacterIterator &that) :
71 : ForwardCharacterIterator(that),
72 0 : textLength(that.textLength), pos(that.pos), begin(that.begin), end(that.end)
73 : {
74 0 : }
75 :
76 : CharacterIterator &
77 0 : CharacterIterator::operator=(const CharacterIterator &that) {
78 0 : ForwardCharacterIterator::operator=(that);
79 0 : textLength = that.textLength;
80 0 : pos = that.pos;
81 0 : begin = that.begin;
82 0 : end = that.end;
83 0 : return *this;
84 : }
85 :
86 : // implementing first[32]PostInc() directly in a subclass should be faster
87 : // but these implementations make subclassing a little easier
88 : UChar
89 0 : CharacterIterator::firstPostInc(void) {
90 0 : setToStart();
91 0 : return nextPostInc();
92 : }
93 :
94 : UChar32
95 0 : CharacterIterator::first32PostInc(void) {
96 0 : setToStart();
97 0 : return next32PostInc();
98 : }
99 :
100 : U_NAMESPACE_END
|