1999-08-16 21:50:52 +00:00
|
|
|
/*
|
1999-12-09 23:27:55 +00:00
|
|
|
**********************************************************************
|
2001-03-21 20:44:20 +00:00
|
|
|
* Copyright (C) 1999-2001, International Business Machines
|
1999-12-09 23:27:55 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
**********************************************************************
|
1999-08-16 21:50:52 +00:00
|
|
|
*/
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
#include "unicode/chariter.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2000-04-20 23:02:20 +00:00
|
|
|
CharacterIterator::CharacterIterator(int32_t length)
|
2001-03-27 02:59:37 +00:00
|
|
|
: textLength(length), pos(0), begin(0), end(length) {
|
|
|
|
if(textLength < 0) {
|
|
|
|
textLength = end = 0;
|
|
|
|
}
|
2000-04-20 23:02:20 +00:00
|
|
|
}
|
|
|
|
|
2002-03-12 01:32:42 +00:00
|
|
|
CharacterIterator::CharacterIterator(int32_t length, int32_t position)
|
2001-03-27 02:59:37 +00:00
|
|
|
: textLength(length), pos(position), begin(0), end(length) {
|
|
|
|
if(textLength < 0) {
|
|
|
|
textLength = end = 0;
|
|
|
|
}
|
|
|
|
if(pos < 0) {
|
|
|
|
pos = 0;
|
|
|
|
} else if(pos > end) {
|
|
|
|
pos = end;
|
|
|
|
}
|
2000-04-20 23:02:20 +00:00
|
|
|
}
|
|
|
|
|
2002-03-12 01:32:42 +00:00
|
|
|
CharacterIterator::CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position)
|
2001-03-27 02:59:37 +00:00
|
|
|
: textLength(length), pos(position), begin(textBegin), end(textEnd) {
|
|
|
|
if(textLength < 0) {
|
|
|
|
textLength = 0;
|
|
|
|
}
|
|
|
|
if(begin < 0) {
|
|
|
|
begin = 0;
|
|
|
|
} else if(begin > textLength) {
|
|
|
|
begin = textLength;
|
|
|
|
}
|
|
|
|
if(end < begin) {
|
|
|
|
end = begin;
|
|
|
|
} else if(end > textLength) {
|
|
|
|
end = textLength;
|
|
|
|
}
|
|
|
|
if(pos < begin) {
|
|
|
|
pos = begin;
|
|
|
|
} else if(pos > end) {
|
|
|
|
pos = end;
|
|
|
|
}
|
2000-04-20 23:02:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CharacterIterator::CharacterIterator(const CharacterIterator &that) :
|
2001-03-27 02:59:37 +00:00
|
|
|
ForwardCharacterIterator(that),
|
|
|
|
textLength(that.textLength), pos(that.pos), begin(that.begin), end(that.end)
|
|
|
|
{
|
|
|
|
}
|
2000-04-20 23:02:20 +00:00
|
|
|
|
|
|
|
CharacterIterator &
|
|
|
|
CharacterIterator::operator=(const CharacterIterator &that) {
|
2001-03-27 02:59:37 +00:00
|
|
|
ForwardCharacterIterator::operator=(that);
|
|
|
|
textLength = that.textLength;
|
|
|
|
pos = that.pos;
|
|
|
|
begin = that.begin;
|
|
|
|
end = that.end;
|
|
|
|
return *this;
|
2000-04-20 23:02:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// implementing first[32]PostInc() directly in a subclass should be faster
|
|
|
|
// but these implementations make subclassing a little easier
|
|
|
|
UChar
|
|
|
|
CharacterIterator::firstPostInc(void) {
|
2001-03-27 02:59:37 +00:00
|
|
|
setToStart();
|
|
|
|
return nextPostInc();
|
2000-04-20 23:02:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
UChar32
|
|
|
|
CharacterIterator::first32PostInc(void) {
|
2001-03-27 02:59:37 +00:00
|
|
|
setToStart();
|
|
|
|
return next32PostInc();
|
2000-04-20 23:02:20 +00:00
|
|
|
}
|
2001-10-08 23:26:58 +00:00
|
|
|
|
|
|
|
U_NAMESPACE_END
|