Loading...
Searching...
No Matches
usetiter.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) 2002-2014, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
*/
#ifndef USETITER_H
#define USETITER_H
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#include "unicode/uobject.h"
#include "unicode/unistr.h"
U_NAMESPACE_BEGIN
class UnicodeSet;
class UnicodeString;
class U_COMMON_API UnicodeSetIterator final : public UObject {
enum { IS_STRING = -1 };
UChar32 codepoint;
UChar32 codepointEnd;
const UnicodeString* string;
public:
UnicodeSetIterator(const UnicodeSet& set);
UnicodeSetIterator();
virtual ~UnicodeSetIterator();
inline UBool isString() const;
inline UChar32 getCodepoint() const;
inline UChar32 getCodepointEnd() const;
const UnicodeString& getString();
inline UnicodeSetIterator &skipToStrings() {
// Finish code point/range iteration.
range = endRange;
endElement = -1;
nextElement = 0;
return *this;
}
UBool next();
UBool nextRange();
void reset(const UnicodeSet& set);
void reset();
static UClassID U_EXPORT2 getStaticClassID();
virtual UClassID getDynamicClassID() const override;
// ======================= PRIVATES ===========================
private:
// endElement and nextElements are really UChar32's, but we keep
// them as signed int32_t's so we can do comparisons with
// endElement set to -1. Leave them as int32_t's.
const UnicodeSet* set;
int32_t endRange;
int32_t range;
int32_t endElement;
int32_t nextElement;
int32_t nextString;
int32_t stringCount;
UnicodeString *cpString;
UnicodeSetIterator(const UnicodeSetIterator&) = delete;
UnicodeSetIterator& operator=(const UnicodeSetIterator&) = delete;
void loadRange(int32_t range);
};
inline UBool UnicodeSetIterator::isString() const {
return codepoint < 0;
}
inline UChar32 UnicodeSetIterator::getCodepoint() const {
return codepoint;
}
inline UChar32 UnicodeSetIterator::getCodepointEnd() const {
return codepointEnd;
}
U_NAMESPACE_END
#endif /* U_SHOW_CPLUSPLUS_API */
#endif
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition uobject.h:222
icu::UnicodeSetIterator::next
UBool next()
Advances the iteration position to the next element in the set, which can be either a single code poi...
icu::UnicodeSetIterator::UnicodeSetIterator
UnicodeSetIterator(const UnicodeSet &set)
Create an iterator over the given set.
icu::UnicodeSetIterator::getCodepoint
UChar32 getCodepoint() const
Returns the current code point, if isString() returned false.
Definition usetiter.h:310
icu::UnicodeSetIterator::getCodepointEnd
UChar32 getCodepointEnd() const
Returns the end of the current code point range, if isString() returned false and nextRange() was cal...
Definition usetiter.h:314
icu::UnicodeSetIterator::skipToStrings
UnicodeSetIterator & skipToStrings()
Skips over the remaining code points/ranges, if any.
Definition usetiter.h:176
icu::UnicodeSetIterator::reset
void reset()
Resets this iterator to the start of the set.
icu::UnicodeSetIterator::nextRange
UBool nextRange()
Returns the next element in the set, either a code point range or a string.
icu::UnicodeSetIterator::reset
void reset(const UnicodeSet &set)
Sets this iterator to visit the elements of the given set and resets it to the start of that set.
icu::UnicodeSetIterator::getDynamicClassID
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::UnicodeSetIterator::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::UnicodeSetIterator::~UnicodeSetIterator
virtual ~UnicodeSetIterator()
Destructor.
icu::UnicodeSetIterator::isString
UBool isString() const
Returns true if the current element is a string.
Definition usetiter.h:306
icu::UnicodeSetIterator::UnicodeSetIterator
UnicodeSetIterator()
Create an iterator over nothing.
icu::UnicodeSetIterator::getString
const UnicodeString & getString()
Returns the current string, if isString() returned true.
icu::UnicodeSet
A mutable set of Unicode characters and multicharacter strings.
Definition uniset.h:285
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:303
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