Loading...
Searching...
No Matches
chariter.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
********************************************************************
*
* Copyright (C) 1997-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
********************************************************************
*/
#ifndef CHARITER_H
#define CHARITER_H
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#include "unicode/uobject.h"
#include "unicode/unistr.h"
U_NAMESPACE_BEGIN
class U_COMMON_API ForwardCharacterIterator : public UObject {
public:
enum { DONE = 0xffff };
virtual ~ForwardCharacterIterator();
virtual bool operator==(const ForwardCharacterIterator& that) const = 0;
inline bool operator!=(const ForwardCharacterIterator& that) const;
virtual int32_t hashCode() const = 0;
virtual UClassID getDynamicClassID() const override = 0;
virtual char16_t nextPostInc() = 0;
virtual UChar32 next32PostInc() = 0;
virtual UBool hasNext() = 0;
protected:
ForwardCharacterIterator();
ForwardCharacterIterator(const ForwardCharacterIterator &other);
ForwardCharacterIterator &operator=(const ForwardCharacterIterator&) { return *this; }
};
class U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
public:
enum EOrigin { kStart, kCurrent, kEnd };
virtual ~CharacterIterator();
virtual CharacterIterator* clone() const = 0;
virtual char16_t first() = 0;
virtual char16_t firstPostInc();
virtual UChar32 first32() = 0;
virtual UChar32 first32PostInc();
inline int32_t setToStart();
virtual char16_t last() = 0;
virtual UChar32 last32() = 0;
inline int32_t setToEnd();
virtual char16_t setIndex(int32_t position) = 0;
virtual UChar32 setIndex32(int32_t position) = 0;
virtual char16_t current() const = 0;
virtual UChar32 current32() const = 0;
virtual char16_t next() = 0;
virtual UChar32 next32() = 0;
virtual char16_t previous() = 0;
virtual UChar32 previous32() = 0;
virtual UBool hasPrevious() = 0;
inline int32_t startIndex() const;
inline int32_t endIndex() const;
inline int32_t getIndex() const;
inline int32_t getLength() const;
virtual int32_t move(int32_t delta, EOrigin origin) = 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;
virtual void getText(UnicodeString& result) = 0;
protected:
CharacterIterator();
CharacterIterator(int32_t length);
CharacterIterator(int32_t length, int32_t position);
CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position);
CharacterIterator(const CharacterIterator &that);
CharacterIterator &operator=(const CharacterIterator &that);
int32_t textLength;
int32_t pos;
int32_t begin;
int32_t end;
};
inline bool
ForwardCharacterIterator::operator!=(const ForwardCharacterIterator& that) const {
return !operator==(that);
}
inline int32_t
CharacterIterator::setToStart() {
return move(0, kStart);
}
inline int32_t
CharacterIterator::setToEnd() {
return move(0, kEnd);
}
inline int32_t
CharacterIterator::startIndex() const {
return begin;
}
inline int32_t
CharacterIterator::endIndex() const {
return end;
}
inline int32_t
CharacterIterator::getIndex() const {
return pos;
}
inline int32_t
CharacterIterator::getLength() const {
return textLength;
}
U_NAMESPACE_END
#endif /* U_SHOW_CPLUSPLUS_API */
#endif
icu::CharacterIterator::firstPostInc
virtual char16_t firstPostInc()
Sets the iterator to refer to the first code unit in its iteration range, returns that code unit,...
icu::CharacterIterator::EOrigin
EOrigin
Origin enumeration for the move() and move32() functions.
Definition chariter.h:367
icu::CharacterIterator::textLength
int32_t textLength
Base class text length field.
Definition chariter.h:674
icu::CharacterIterator::previous32
virtual UChar32 previous32()=0
Advances to the previous code point in the iteration range (toward startIndex()), and returns that co...
icu::CharacterIterator::CharacterIterator
CharacterIterator(int32_t length, int32_t position)
Constructor, just setting the length and position fields in this base class.
icu::CharacterIterator::last
virtual char16_t last()=0
Sets the iterator to refer to the last code unit in its iteration range, and returns that code unit.
icu::CharacterIterator::getText
virtual void getText(UnicodeString &result)=0
Copies the text under iteration into the UnicodeString referred to by "result".
icu::CharacterIterator::move
virtual int32_t move(int32_t delta, EOrigin origin)=0
Moves the current position relative to the start or end of the iteration range, or relative to the cu...
icu::CharacterIterator::first32
virtual UChar32 first32()=0
Sets the iterator to refer to the first code point in its iteration range, and returns that code unit...
icu::CharacterIterator::next
virtual char16_t next()=0
Advances to the next code unit in the iteration range (toward endIndex()), and returns that code unit...
icu::CharacterIterator::operator=
CharacterIterator & operator=(const CharacterIterator &that)
Assignment operator.
icu::CharacterIterator::last32
virtual UChar32 last32()=0
Sets the iterator to refer to the last code point in its iteration range, and returns that code unit.
icu::CharacterIterator::~CharacterIterator
virtual ~CharacterIterator()
Destructor.
icu::CharacterIterator::current
virtual char16_t current() const =0
Returns the code unit the iterator currently refers to.
icu::CharacterIterator::endIndex
int32_t endIndex() const
Returns the numeric index in the underlying text-storage object of the position immediately BEYOND th...
Definition chariter.h:716
icu::CharacterIterator::setIndex32
virtual UChar32 setIndex32(int32_t position)=0
Sets the iterator to refer to the beginning of the code point that contains the "position"-th code un...
icu::CharacterIterator::begin
int32_t begin
Base class field for the start of the iteration range.
Definition chariter.h:686
icu::CharacterIterator::CharacterIterator
CharacterIterator(int32_t length)
Constructor, just setting the length field in this base class.
icu::CharacterIterator::pos
int32_t pos
Base class field for the current position.
Definition chariter.h:680
icu::CharacterIterator::next32
virtual UChar32 next32()=0
Advances to the next code point in the iteration range (toward endIndex()), and returns that code poi...
icu::CharacterIterator::end
int32_t end
Base class field for the end of the iteration range.
Definition chariter.h:692
icu::CharacterIterator::move32
virtual int32_t move32(int32_t delta, EOrigin origin)=0
Moves the current position relative to the start or end of the iteration range, or relative to the cu...
icu::CharacterIterator::getIndex
int32_t getIndex() const
Returns the numeric index in the underlying text-storage object of the character the iterator current...
Definition chariter.h:721
icu::CharacterIterator::first32PostInc
virtual UChar32 first32PostInc()
Sets the iterator to refer to the first code point in its iteration range, returns that code point,...
icu::CharacterIterator::CharacterIterator
CharacterIterator(const CharacterIterator &that)
Copy constructor.
icu::CharacterIterator::current32
virtual UChar32 current32() const =0
Returns the code point the iterator currently refers to.
icu::CharacterIterator::setToEnd
int32_t setToEnd()
Sets the iterator to the end of its iteration range, just behind the last code unit or code point.
Definition chariter.h:706
icu::CharacterIterator::setToStart
int32_t setToStart()
Sets the iterator to refer to the first code unit or code point in its iteration range.
Definition chariter.h:701
icu::CharacterIterator::hasPrevious
virtual UBool hasPrevious()=0
Returns false if there are no more code units or code points before the current position in the itera...
icu::CharacterIterator::clone
virtual CharacterIterator * clone() const =0
Returns a pointer to a new CharacterIterator of the same concrete class as this one,...
icu::CharacterIterator::previous
virtual char16_t previous()=0
Advances to the previous code unit in the iteration range (toward startIndex()), and returns that cod...
icu::CharacterIterator::first
virtual char16_t first()=0
Sets the iterator to refer to the first code unit in its iteration range, and returns that code unit.
icu::CharacterIterator::setIndex
virtual char16_t setIndex(int32_t position)=0
Sets the iterator to refer to the "position"-th code unit in the text-storage object the iterator ref...
icu::CharacterIterator::CharacterIterator
CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position)
Constructor, just setting the length, start, end, and position fields in this base class.
icu::CharacterIterator::CharacterIterator
CharacterIterator()
Empty constructor.
icu::CharacterIterator::startIndex
int32_t startIndex() const
Returns the numeric index in the underlying text-storage object of the character returned by first().
Definition chariter.h:711
icu::CharacterIterator::getLength
int32_t getLength() const
Returns the length of the entire text in the underlying text-storage object.
Definition chariter.h:726
icu::ForwardCharacterIterator::getDynamicClassID
virtual UClassID getDynamicClassID() const override=0
Returns a UClassID for this ForwardCharacterIterator ("poor man'sRTTI").
icu::ForwardCharacterIterator::~ForwardCharacterIterator
virtual ~ForwardCharacterIterator()
Destructor.
icu::ForwardCharacterIterator::next32PostInc
virtual UChar32 next32PostInc()=0
Gets the current code point for returning and advances to the next code point in the iteration range ...
icu::ForwardCharacterIterator::operator!=
bool operator!=(const ForwardCharacterIterator &that) const
Returns true when the iterators refer to different text-storage objects, or to different characters i...
Definition chariter.h:696
icu::ForwardCharacterIterator::hashCode
virtual int32_t hashCode() const =0
Generates a hash code for this iterator.
icu::ForwardCharacterIterator::ForwardCharacterIterator
ForwardCharacterIterator(const ForwardCharacterIterator &other)
Copy constructor to be overridden in the implementing class.
icu::ForwardCharacterIterator::operator==
virtual bool operator==(const ForwardCharacterIterator &that) const =0
Returns true when both iterators refer to the same character in the same character-storage object.
icu::ForwardCharacterIterator::operator=
ForwardCharacterIterator & operator=(const ForwardCharacterIterator &)
Assignment operator to be overridden in the implementing class.
Definition chariter.h:189
icu::ForwardCharacterIterator::ForwardCharacterIterator
ForwardCharacterIterator()
Default constructor to be overridden in the implementing class.
icu::ForwardCharacterIterator::hasNext
virtual UBool hasNext()=0
Returns false if there are no more code units or code points at or after the current position in the ...
icu::ForwardCharacterIterator::nextPostInc
virtual char16_t nextPostInc()=0
Gets the current code unit for returning and advances to the next code unit in the iteration range (t...
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition uobject.h:222
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:303
icu::operator!=
bool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition stringpiece.h:346
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition umachine.h:449
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
unistr.h
C++ API: Unicode String.
uobject.h
C++ API: Common ICU base class UObject.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
U_COMMON_API
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition utypes.h:315