annotate modules/javafx.web/src/main/native/Source/ThirdParty/icu/source/common/unicode/caniter.h @ 10550:fee4ef5c87df

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