+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
********************************************************************
*
-* Copyright (C) 1997-2005, International Business Machines
+* Copyright (C) 1997-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
********************************************************************
* \brief C++ API: Character Iterator
*/
+#if U_SHOW_CPLUSPLUS_API
U_NAMESPACE_BEGIN
/**
* Abstract class that defines an API for forward-only iteration
* }
*
* void function1(ForwardCharacterIterator &it) {
- * UChar c;
+ * char16_t c;
* while((c=it.nextPostInc())!=ForwardCharacterIterator::DONE) {
* // use c
* }
* @return the current code unit.
* @stable ICU 2.0
*/
- virtual UChar nextPostInc(void) = 0;
+ virtual char16_t nextPostInc(void) = 0;
/**
* Gets the current code point for returning and advances to the next code point
* showing a way to convert simple for() loops:
* \code
* void forward2(CharacterIterator &it) {
- * UChar c;
+ * char16_t c;
* for(c=it.firstPostInc(); c!=CharacterIterator::DONE; c=it.nextPostInc()) {
* // use c
* }
* Backward iteration with a more traditional for() loop:
* \code
* void backward2(CharacterIterator &it) {
- * UChar c;
+ * char16_t c;
* for(c=it.last(); c!=CharacterIterator::DONE; c=it.previous()) {
* // use c
* }
* // get the position
* int32_t pos=it.getIndex();
* // get the previous code unit
- * UChar u=it.previous();
+ * char16_t u=it.previous();
* // move back one more code unit
* it.move(-1, CharacterIterator::kCurrent);
* // set the position back to where it was
* Function processing characters, in this example simple output
* <pre>
* \code
- * void processChar( UChar c )
+ * void processChar( char16_t c )
* {
* cout << " " << c;
* }
* \code
* void traverseForward(CharacterIterator& iter)
* {
- * for(UChar c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
+ * for(char16_t c = iter.first(); c != CharacterIterator.DONE; c = iter.next()) {
* processChar(c);
* }
* }
* \code
* void traverseBackward(CharacterIterator& iter)
* {
- * for(UChar c = iter.last(); c != CharacterIterator.DONE; c = iter.previous()) {
+ * for(char16_t c = iter.last(); c != CharacterIterator.DONE; c = iter.previous()) {
* processChar(c);
* }
* }
* \code
* void traverseOut(CharacterIterator& iter, int32_t pos)
* {
- * UChar c;
+ * char16_t c;
* for (c = iter.setIndex(pos);
* c != CharacterIterator.DONE && (Unicode::isLetter(c) || Unicode::isDigit(c));
* c = iter.next()) {}
*/
enum EOrigin { kStart, kCurrent, kEnd };
+ /**
+ * Destructor.
+ * @stable ICU 2.0
+ */
+ virtual ~CharacterIterator();
+
/**
* Returns a pointer to a new CharacterIterator of the same
* concrete class as this one, and referring to the same
* @return the first code unit in its iteration range.
* @stable ICU 2.0
*/
- virtual UChar first(void) = 0;
+ virtual char16_t first(void) = 0;
/**
* Sets the iterator to refer to the first code unit in its
* @return the first code unit in its iteration range.
* @stable ICU 2.0
*/
- virtual UChar firstPostInc(void);
+ virtual char16_t firstPostInc(void);
/**
* Sets the iterator to refer to the first code point in its
* @return the last code unit.
* @stable ICU 2.0
*/
- virtual UChar last(void) = 0;
+ virtual char16_t last(void) = 0;
/**
* Sets the iterator to refer to the last code point in its
* @return the "position"-th code unit.
* @stable ICU 2.0
*/
- virtual UChar setIndex(int32_t position) = 0;
+ virtual char16_t setIndex(int32_t position) = 0;
/**
* Sets the iterator to refer to the beginning of the code point
* @return the current code unit.
* @stable ICU 2.0
*/
- virtual UChar current(void) const = 0;
+ virtual char16_t current(void) const = 0;
/**
* Returns the code point the iterator currently refers to.
* @return the next code unit.
* @stable ICU 2.0
*/
- virtual UChar next(void) = 0;
+ virtual char16_t next(void) = 0;
/**
* Advances to the next code point in the iteration range
* @return the previous code unit.
* @stable ICU 2.0
*/
- virtual UChar previous(void) = 0;
+ virtual char16_t previous(void) = 0;
/**
* Advances to the previous code point in the iteration range
* Returns the numeric index in the underlying text-storage
* object of the character the iterator currently refers to
* (i.e., the character returned by current()).
- * @return the numberic index in the text-storage object of
+ * @return the numeric index in the text-storage object of
* the character the iterator currently refers to
* @stable ICU 2.0
*/
* @return the new position
* @stable ICU 2.0
*/
+#ifdef move32
+ // One of the system headers right now is sometimes defining a conflicting macro we don't use
+#undef move32
+#endif
virtual int32_t move32(int32_t delta, EOrigin origin) = 0;
/**
}
U_NAMESPACE_END
+#endif // U_SHOW_CPLUSPLUS_API
#endif