+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
******************************************************************************
-* Copyright (C) 1998-2004, International Business Machines Corporation and *
-* others. All Rights Reserved. *
+* Copyright (C) 1998-2012, International Business Machines Corporation and
+* others. All Rights Reserved.
******************************************************************************
*/
+#include "utypeinfo.h" // for 'typeid' to work
+
#include "unicode/uchriter.h"
#include "unicode/ustring.h"
-#include "uhash.h"
+#include "unicode/utf16.h"
+#include "ustr_imp.h"
U_NAMESPACE_BEGIN
// never default construct!
}
-UCharCharacterIterator::UCharCharacterIterator(const UChar* textPtr,
+UCharCharacterIterator::UCharCharacterIterator(ConstChar16Ptr textPtr,
int32_t length)
: CharacterIterator(textPtr != 0 ? (length>=0 ? length : u_strlen(textPtr)) : 0),
text(textPtr)
{
}
-UCharCharacterIterator::UCharCharacterIterator(const UChar* textPtr,
+UCharCharacterIterator::UCharCharacterIterator(ConstChar16Ptr textPtr,
int32_t length,
int32_t position)
: CharacterIterator(textPtr != 0 ? (length>=0 ? length : u_strlen(textPtr)) : 0, position),
{
}
-UCharCharacterIterator::UCharCharacterIterator(const UChar* textPtr,
+UCharCharacterIterator::UCharCharacterIterator(ConstChar16Ptr textPtr,
int32_t length,
int32_t textBegin,
int32_t textEnd,
if (this == &that) {
return TRUE;
}
-
- if (getDynamicClassID() != that.getDynamicClassID()) {
+ if (typeid(*this) != typeid(that)) {
return FALSE;
}
int32_t
UCharCharacterIterator::hashCode() const {
- return uhash_hashUCharsN(text, textLength) ^ pos ^ begin ^ end;
+ return ustr_hashUCharsN(text, textLength) ^ pos ^ begin ^ end;
}
CharacterIterator*
if(pos < end) {
int32_t i = pos;
UChar32 c;
- UTF_NEXT_CHAR(text, i, end, c);
+ U16_NEXT(text, i, end, c);
return c;
} else {
return DONE;
pos = begin;
if(pos < end) {
UChar32 c;
- UTF_NEXT_CHAR(text, pos, end, c);
+ U16_NEXT(text, pos, end, c);
return c;
} else {
return DONE;
pos = end;
if(pos > begin) {
UChar32 c;
- UTF_PREV_CHAR(text, begin, pos, c);
+ U16_PREV(text, begin, pos, c);
return c;
} else {
return DONE;
position = end;
}
if(position < end) {
- UTF_SET_CHAR_START(text, begin, position);
+ U16_SET_CP_START(text, begin, position);
int32_t i = this->pos = position;
UChar32 c;
- UTF_NEXT_CHAR(text, i, end, c);
+ U16_NEXT(text, i, end, c);
return c;
} else {
this->pos = position;
UCharCharacterIterator::current32() const {
if (pos >= begin && pos < end) {
UChar32 c;
- UTF_GET_CHAR(text, begin, pos, end, c);
+ U16_GET(text, begin, pos, end, c);
return c;
} else {
return DONE;
UChar32
UCharCharacterIterator::next32() {
if (pos < end) {
- UTF_FWD_1(text, pos, end);
+ U16_FWD_1(text, pos, end);
if(pos < end) {
int32_t i = pos;
UChar32 c;
- UTF_NEXT_CHAR(text, i, end, c);
+ U16_NEXT(text, i, end, c);
return c;
}
}
UCharCharacterIterator::next32PostInc() {
if (pos < end) {
UChar32 c;
- UTF_NEXT_CHAR(text, pos, end, c);
+ U16_NEXT(text, pos, end, c);
return c;
} else {
return DONE;
UCharCharacterIterator::previous32() {
if (pos > begin) {
UChar32 c;
- UTF_PREV_CHAR(text, begin, pos, c);
+ U16_PREV(text, begin, pos, c);
return c;
} else {
return DONE;
case kStart:
pos = begin;
if(delta > 0) {
- UTF_FWD_N(text, pos, end, delta);
+ U16_FWD_N(text, pos, end, delta);
}
break;
case kCurrent:
if(delta > 0) {
- UTF_FWD_N(text, pos, end, delta);
+ U16_FWD_N(text, pos, end, delta);
} else {
- UTF_BACK_N(text, begin, pos, -delta);
+ U16_BACK_N(text, begin, pos, -delta);
}
break;
case kEnd:
pos = end;
if(delta < 0) {
- UTF_BACK_N(text, begin, pos, -delta);
+ U16_BACK_N(text, begin, pos, -delta);
}
break;
default:
return pos;
}
-void UCharCharacterIterator::setText(const UChar* newText,
+void UCharCharacterIterator::setText(ConstChar16Ptr newText,
int32_t newTextLength) {
text = newText;
if(newText == 0 || newTextLength < 0) {