ICU 76.1: common/unicode/caniter.h Source File

ICU 76.1 76.1

caniter.h
Go to the documentation of this file.
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
3/*
4 *******************************************************************************
5 * Copyright (C) 1996-2014, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 *******************************************************************************
8 */
9
10#ifndef CANITER_H
11#define CANITER_H
12
13#include "unicode/utypes.h"
14
15#if U_SHOW_CPLUSPLUS_API
16
17#if !UCONFIG_NO_NORMALIZATION
18
19#include "unicode/uobject.h"
20#include "unicode/unistr.h"
21
31#ifndef CANITER_SKIP_ZEROES
32#define CANITER_SKIP_ZEROES true
33#endif
34
35U_NAMESPACE_BEGIN
36
37class Hashtable;
38class Normalizer2;
39class Normalizer2Impl;
40
76 class U_COMMON_API CanonicalIterator final : public UObject {
77public:
84 CanonicalIterator(const UnicodeString &source, UErrorCode &status);
85
90 virtual ~CanonicalIterator();
91
97 UnicodeString getSource();
98
103 void reset();
104
112 UnicodeString next();
113
121 void setSource(const UnicodeString &newSource, UErrorCode &status);
122
123#ifndef U_HIDE_INTERNAL_API
134 static void U_EXPORT2 permute(UnicodeString &source, UBool skipZeros, Hashtable *result, UErrorCode &status, int32_t depth=0);
135#endif /* U_HIDE_INTERNAL_API */
136
142 static UClassID U_EXPORT2 getStaticClassID();
143
149 virtual UClassID getDynamicClassID() const override;
150
151private:
152 // ===================== PRIVATES ==============================
153 // private default constructor
154 CanonicalIterator() = delete;
155
156
161 CanonicalIterator(const CanonicalIterator& other) = delete;
162
167 CanonicalIterator& operator=(const CanonicalIterator& other) = delete;
168
169 // fields
170 UnicodeString source;
171 UBool done;
172
173 // 2 dimensional array holds the pieces of the string with
174 // their different canonically equivalent representations
175 UnicodeString **pieces;
176 int32_t pieces_length;
177 int32_t *pieces_lengths;
178
179 // current is used in iterating to combine pieces
180 int32_t *current;
181 int32_t current_length;
182
183 // transient fields
184 UnicodeString buffer;
185
186 const Normalizer2 *nfd;
187 const Normalizer2Impl *nfcImpl;
188
189 // we have a segment, in NFD. Find all the strings that are canonically equivalent to it.
190 UnicodeString *getEquivalents(const UnicodeString &segment, int32_t &result_len, UErrorCode &status); //private String[] getEquivalents(String segment)
191
192 //Set getEquivalents2(String segment);
193 Hashtable *getEquivalents2(Hashtable *fillinResult, const char16_t *segment, int32_t segLen, UErrorCode &status);
194 //Hashtable *getEquivalents2(const UnicodeString &segment, int32_t segLen, UErrorCode &status);
195
201 //Set extract(int comp, String segment, int segmentPos, StringBuffer buffer);
202 Hashtable *extract(Hashtable *fillinResult, UChar32 comp, const char16_t *segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
203 //Hashtable *extract(UChar32 comp, const UnicodeString &segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
204
205 void cleanPieces();
206
207};
208
209U_NAMESPACE_END
210
211#endif /* #if !UCONFIG_NO_NORMALIZATION */
212
213#endif /* U_SHOW_CPLUSPLUS_API */
214
215#endif
icu::CanonicalIterator
This class allows one to iterate through all the strings that are canonically equivalent to a given s...
Definition caniter.h:76
icu::CanonicalIterator::reset
void reset()
Resets the iterator so that one can start again from the beginning.
icu::CanonicalIterator::next
UnicodeString next()
Get the next canonically equivalent string.
icu::CanonicalIterator::permute
static void permute(UnicodeString &source, UBool skipZeros, Hashtable *result, UErrorCode &status, int32_t depth=0)
Dumb recursive implementation of permutation.
icu::CanonicalIterator::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::CanonicalIterator::setSource
void setSource(const UnicodeString &newSource, UErrorCode &status)
Set a new source for this iterator.
icu::CanonicalIterator::getDynamicClassID
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::CanonicalIterator::CanonicalIterator
CanonicalIterator(const UnicodeString &source, UErrorCode &status)
Construct a CanonicalIterator object.
icu::CanonicalIterator::getSource
UnicodeString getSource()
Gets the NFD form of the current source we are iterating over.
icu::CanonicalIterator::~CanonicalIterator
virtual ~CanonicalIterator()
Destructor Cleans pieces.
icu::Normalizer2
Unicode normalization functionality for standard Unicode normalization or for using custom mapping ta...
Definition normalizer2.h:85
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition uobject.h:223
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:296
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition umachine.h:427
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:247
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.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:430
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