ICU 73.2  73.2
caniter.h
Go to the documentation of this file.
00001 // © 2016 and later: Unicode, Inc. and others.
00002 // License & terms of use: http://www.unicode.org/copyright.html
00003 /*
00004  *******************************************************************************
00005  * Copyright (C) 1996-2014, International Business Machines Corporation and
00006  * others. All Rights Reserved.
00007  *******************************************************************************
00008  */
00009 
00010 #ifndef CANITER_H
00011 #define CANITER_H
00012 
00013 #include "unicode/utypes.h"
00014 
00015 #if U_SHOW_CPLUSPLUS_API
00016 
00017 #if !UCONFIG_NO_NORMALIZATION
00018 
00019 #include "unicode/uobject.h"
00020 #include "unicode/unistr.h"
00021 
00031 #ifndef CANITER_SKIP_ZEROES
00032 #define CANITER_SKIP_ZEROES true
00033 #endif
00034 
00035 U_NAMESPACE_BEGIN
00036 
00037 class Hashtable;
00038 class Normalizer2;
00039 class Normalizer2Impl;
00040 
00076 class U_COMMON_API CanonicalIterator final : public UObject {
00077 public:
00084     CanonicalIterator(const UnicodeString &source, UErrorCode &status);
00085 
00090     virtual ~CanonicalIterator();
00091 
00097     UnicodeString getSource();
00098 
00103     void reset();
00104 
00112     UnicodeString next();
00113 
00121     void setSource(const UnicodeString &newSource, UErrorCode &status);
00122 
00123 #ifndef U_HIDE_INTERNAL_API
00124 
00133     static void U_EXPORT2 permute(UnicodeString &source, UBool skipZeros, Hashtable *result, UErrorCode &status);
00134 #endif  /* U_HIDE_INTERNAL_API */
00135 
00141     static UClassID U_EXPORT2 getStaticClassID();
00142 
00148     virtual UClassID getDynamicClassID() const override;
00149 
00150 private:
00151     // ===================== PRIVATES ==============================
00152     // private default constructor
00153     CanonicalIterator() = delete;
00154 
00155 
00160     CanonicalIterator(const CanonicalIterator& other) = delete;
00161 
00166     CanonicalIterator& operator=(const CanonicalIterator& other) = delete;
00167 
00168     // fields
00169     UnicodeString source;
00170     UBool done;
00171 
00172     // 2 dimensional array holds the pieces of the string with
00173     // their different canonically equivalent representations
00174     UnicodeString **pieces;
00175     int32_t pieces_length;
00176     int32_t *pieces_lengths;
00177 
00178     // current is used in iterating to combine pieces
00179     int32_t *current;
00180     int32_t current_length;
00181 
00182     // transient fields
00183     UnicodeString buffer;
00184 
00185     const Normalizer2 &nfd;
00186     const Normalizer2Impl &nfcImpl;
00187 
00188     // we have a segment, in NFD. Find all the strings that are canonically equivalent to it.
00189     UnicodeString *getEquivalents(const UnicodeString &segment, int32_t &result_len, UErrorCode &status); //private String[] getEquivalents(String segment)
00190 
00191     //Set getEquivalents2(String segment);
00192     Hashtable *getEquivalents2(Hashtable *fillinResult, const char16_t *segment, int32_t segLen, UErrorCode &status);
00193     //Hashtable *getEquivalents2(const UnicodeString &segment, int32_t segLen, UErrorCode &status);
00194 
00200     //Set extract(int comp, String segment, int segmentPos, StringBuffer buffer);
00201     Hashtable *extract(Hashtable *fillinResult, UChar32 comp, const char16_t *segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
00202     //Hashtable *extract(UChar32 comp, const UnicodeString &segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
00203 
00204     void cleanPieces();
00205 
00206 };
00207 
00208 U_NAMESPACE_END
00209 
00210 #endif /* #if !UCONFIG_NO_NORMALIZATION */
00211 
00212 #endif /* U_SHOW_CPLUSPLUS_API */
00213 
00214 #endif