annotate modules/javafx.web/src/main/native/Source/ThirdParty/icu/source/common/unicode/caniter.h @ 11038:20a8447c71c6

8207159: Update ICU to version 62.1 Reviewed-by: mbilla, kcr, ghb
author arajkumar
date Fri, 24 Aug 2018 15:06:40 +0530
parents fee4ef5c87df
children
rev   line source
arajkumar@11038 1 // © 2016 and later: Unicode, Inc. and others.
arajkumar@11038 2 // License & terms of use: http://www.unicode.org/copyright.html
ghb@10550 3 /*
ghb@10550 4 *******************************************************************************
arajkumar@11038 5 * Copyright (C) 1996-2014, International Business Machines Corporation and
ghb@10550 6 * others. All Rights Reserved.
ghb@10550 7 *******************************************************************************
ghb@10550 8 */
ghb@10550 9
ghb@10550 10 #ifndef CANITER_H
ghb@10550 11 #define CANITER_H
ghb@10550 12
ghb@10550 13 #include "unicode/utypes.h"
ghb@10550 14
ghb@10550 15 #if !UCONFIG_NO_NORMALIZATION
ghb@10550 16
ghb@10550 17 #include "unicode/uobject.h"
ghb@10550 18 #include "unicode/unistr.h"
ghb@10550 19
ghb@10550 20 /**
ghb@10550 21 * \file
ghb@10550 22 * \brief C++ API: Canonical Iterator
ghb@10550 23 */
ghb@10550 24
ghb@10550 25 /** Should permutation skip characters with combining class zero
ghb@10550 26 * Should be either TRUE or FALSE. This is a compile time option
ghb@10550 27 * @stable ICU 2.4
ghb@10550 28 */
ghb@10550 29 #ifndef CANITER_SKIP_ZEROES
ghb@10550 30 #define CANITER_SKIP_ZEROES TRUE
ghb@10550 31 #endif
ghb@10550 32
ghb@10550 33 U_NAMESPACE_BEGIN
ghb@10550 34
ghb@10550 35 class Hashtable;
ghb@10550 36 class Normalizer2;
ghb@10550 37 class Normalizer2Impl;
ghb@10550 38
ghb@10550 39 /**
ghb@10550 40 * This class allows one to iterate through all the strings that are canonically equivalent to a given
ghb@10550 41 * string. For example, here are some sample results:
ghb@10550 42 Results for: {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}
ghb@10550 43 1: \\u0041\\u030A\\u0064\\u0307\\u0327
ghb@10550 44 = {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}
ghb@10550 45 2: \\u0041\\u030A\\u0064\\u0327\\u0307
ghb@10550 46 = {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D}{COMBINING CEDILLA}{COMBINING DOT ABOVE}
ghb@10550 47 3: \\u0041\\u030A\\u1E0B\\u0327
ghb@10550 48 = {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D WITH DOT ABOVE}{COMBINING CEDILLA}
ghb@10550 49 4: \\u0041\\u030A\\u1E11\\u0307
ghb@10550 50 = {LATIN CAPITAL LETTER A}{COMBINING RING ABOVE}{LATIN SMALL LETTER D WITH CEDILLA}{COMBINING DOT ABOVE}
ghb@10550 51 5: \\u00C5\\u0064\\u0307\\u0327
ghb@10550 52 = {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}
ghb@10550 53 6: \\u00C5\\u0064\\u0327\\u0307
ghb@10550 54 = {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D}{COMBINING CEDILLA}{COMBINING DOT ABOVE}
ghb@10550 55 7: \\u00C5\\u1E0B\\u0327
ghb@10550 56 = {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D WITH DOT ABOVE}{COMBINING CEDILLA}
ghb@10550 57 8: \\u00C5\\u1E11\\u0307
ghb@10550 58 = {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D WITH CEDILLA}{COMBINING DOT ABOVE}
ghb@10550 59 9: \\u212B\\u0064\\u0307\\u0327
ghb@10550 60 = {ANGSTROM SIGN}{LATIN SMALL LETTER D}{COMBINING DOT ABOVE}{COMBINING CEDILLA}
ghb@10550 61 10: \\u212B\\u0064\\u0327\\u0307
ghb@10550 62 = {ANGSTROM SIGN}{LATIN SMALL LETTER D}{COMBINING CEDILLA}{COMBINING DOT ABOVE}
ghb@10550 63 11: \\u212B\\u1E0B\\u0327
ghb@10550 64 = {ANGSTROM SIGN}{LATIN SMALL LETTER D WITH DOT ABOVE}{COMBINING CEDILLA}
ghb@10550 65 12: \\u212B\\u1E11\\u0307
ghb@10550 66 = {ANGSTROM SIGN}{LATIN SMALL LETTER D WITH CEDILLA}{COMBINING DOT ABOVE}
ghb@10550 67 *<br>Note: the code is intended for use with small strings, and is not suitable for larger ones,
ghb@10550 68 * since it has not been optimized for that situation.
ghb@10550 69 * Note, CanonicalIterator is not intended to be subclassed.
ghb@10550 70 * @author M. Davis
ghb@10550 71 * @author C++ port by V. Weinstein
ghb@10550 72 * @stable ICU 2.4
ghb@10550 73 */
arajkumar@11038 74 class U_COMMON_API CanonicalIterator U_FINAL : public UObject {
ghb@10550 75 public:
ghb@10550 76 /**
ghb@10550 77 * Construct a CanonicalIterator object
ghb@10550 78 * @param source string to get results for
ghb@10550 79 * @param status Fill-in parameter which receives the status of this operation.
ghb@10550 80 * @stable ICU 2.4
ghb@10550 81 */
ghb@10550 82 CanonicalIterator(const UnicodeString &source, UErrorCode &status);
ghb@10550 83
ghb@10550 84 /** Destructor
ghb@10550 85 * Cleans pieces
ghb@10550 86 * @stable ICU 2.4
ghb@10550 87 */
ghb@10550 88 virtual ~CanonicalIterator();
ghb@10550 89
ghb@10550 90 /**
ghb@10550 91 * Gets the NFD form of the current source we are iterating over.
ghb@10550 92 * @return gets the source: NOTE: it is the NFD form of source
ghb@10550 93 * @stable ICU 2.4
ghb@10550 94 */
ghb@10550 95 UnicodeString getSource();
ghb@10550 96
ghb@10550 97 /**
ghb@10550 98 * Resets the iterator so that one can start again from the beginning.
ghb@10550 99 * @stable ICU 2.4
ghb@10550 100 */
ghb@10550 101 void reset();
ghb@10550 102
ghb@10550 103 /**
ghb@10550 104 * Get the next canonically equivalent string.
ghb@10550 105 * <br><b>Warning: The strings are not guaranteed to be in any particular order.</b>
ghb@10550 106 * @return the next string that is canonically equivalent. A bogus string is returned when
ghb@10550 107 * the iteration is done.
ghb@10550 108 * @stable ICU 2.4
ghb@10550 109 */
ghb@10550 110 UnicodeString next();
ghb@10550 111
ghb@10550 112 /**
ghb@10550 113 * Set a new source for this iterator. Allows object reuse.
ghb@10550 114 * @param newSource the source string to iterate against. This allows the same iterator to be used
ghb@10550 115 * while changing the source string, saving object creation.
ghb@10550 116 * @param status Fill-in parameter which receives the status of this operation.
ghb@10550 117 * @stable ICU 2.4
ghb@10550 118 */
ghb@10550 119 void setSource(const UnicodeString &newSource, UErrorCode &status);
ghb@10550 120
ghb@10550 121 #ifndef U_HIDE_INTERNAL_API
ghb@10550 122 /**
ghb@10550 123 * Dumb recursive implementation of permutation.
ghb@10550 124 * TODO: optimize
ghb@10550 125 * @param source the string to find permutations for
ghb@10550 126 * @param skipZeros determine if skip zeros
ghb@10550 127 * @param result the results in a set.
ghb@10550 128 * @param status Fill-in parameter which receives the status of this operation.
ghb@10550 129 * @internal
ghb@10550 130 */
ghb@10550 131 static void U_EXPORT2 permute(UnicodeString &source, UBool skipZeros, Hashtable *result, UErrorCode &status);
ghb@10550 132 #endif /* U_HIDE_INTERNAL_API */
ghb@10550 133
ghb@10550 134 /**
ghb@10550 135 * ICU "poor man's RTTI", returns a UClassID for this class.
ghb@10550 136 *
ghb@10550 137 * @stable ICU 2.2
ghb@10550 138 */
ghb@10550 139 static UClassID U_EXPORT2 getStaticClassID();
ghb@10550 140
ghb@10550 141 /**
ghb@10550 142 * ICU "poor man's RTTI", returns a UClassID for the actual class.
ghb@10550 143 *
ghb@10550 144 * @stable ICU 2.2
ghb@10550 145 */
ghb@10550 146 virtual UClassID getDynamicClassID() const;
ghb@10550 147
ghb@10550 148 private:
ghb@10550 149 // ===================== PRIVATES ==============================
ghb@10550 150 // private default constructor
ghb@10550 151 CanonicalIterator();
ghb@10550 152
ghb@10550 153
ghb@10550 154 /**
ghb@10550 155 * Copy constructor. Private for now.
arajkumar@11038 156 * @internal (private)
ghb@10550 157 */
ghb@10550 158 CanonicalIterator(const CanonicalIterator& other);
ghb@10550 159
ghb@10550 160 /**
ghb@10550 161 * Assignment operator. Private for now.
arajkumar@11038 162 * @internal (private)
ghb@10550 163 */
ghb@10550 164 CanonicalIterator& operator=(const CanonicalIterator& other);
ghb@10550 165
ghb@10550 166 // fields
ghb@10550 167 UnicodeString source;
ghb@10550 168 UBool done;
ghb@10550 169
ghb@10550 170 // 2 dimensional array holds the pieces of the string with
ghb@10550 171 // their different canonically equivalent representations
ghb@10550 172 UnicodeString **pieces;
ghb@10550 173 int32_t pieces_length;
ghb@10550 174 int32_t *pieces_lengths;
ghb@10550 175
ghb@10550 176 // current is used in iterating to combine pieces
ghb@10550 177 int32_t *current;
ghb@10550 178 int32_t current_length;
ghb@10550 179
ghb@10550 180 // transient fields
ghb@10550 181 UnicodeString buffer;
ghb@10550 182
ghb@10550 183 const Normalizer2 &nfd;
ghb@10550 184 const Normalizer2Impl &nfcImpl;
ghb@10550 185
ghb@10550 186 // we have a segment, in NFD. Find all the strings that are canonically equivalent to it.
ghb@10550 187 UnicodeString *getEquivalents(const UnicodeString &segment, int32_t &result_len, UErrorCode &status); //private String[] getEquivalents(String segment)
ghb@10550 188
ghb@10550 189 //Set getEquivalents2(String segment);
arajkumar@11038 190 Hashtable *getEquivalents2(Hashtable *fillinResult, const char16_t *segment, int32_t segLen, UErrorCode &status);
ghb@10550 191 //Hashtable *getEquivalents2(const UnicodeString &segment, int32_t segLen, UErrorCode &status);
ghb@10550 192
ghb@10550 193 /**
ghb@10550 194 * See if the decomposition of cp2 is at segment starting at segmentPos
ghb@10550 195 * (with canonical rearrangment!)
ghb@10550 196 * If so, take the remainder, and return the equivalents
ghb@10550 197 */
ghb@10550 198 //Set extract(int comp, String segment, int segmentPos, StringBuffer buffer);
arajkumar@11038 199 Hashtable *extract(Hashtable *fillinResult, UChar32 comp, const char16_t *segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
ghb@10550 200 //Hashtable *extract(UChar32 comp, const UnicodeString &segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
ghb@10550 201
ghb@10550 202 void cleanPieces();
ghb@10550 203
ghb@10550 204 };
ghb@10550 205
ghb@10550 206 U_NAMESPACE_END
ghb@10550 207
ghb@10550 208 #endif /* #if !UCONFIG_NO_NORMALIZATION */
ghb@10550 209
ghb@10550 210 #endif