ICU 56.1  56.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
caniter.h
Go to the documentation of this file.
1 /*
2  *******************************************************************************
3  * Copyright (C) 1996-2014, International Business Machines Corporation and
4  * others. All Rights Reserved.
5  *******************************************************************************
6  */
7 
8 #ifndef CANITER_H
9 #define CANITER_H
10 
11 #include "unicode/utypes.h"
12 
13 #if !UCONFIG_NO_NORMALIZATION
14 
15 #include "unicode/uobject.h"
16 #include "unicode/unistr.h"
17 
27 #ifndef CANITER_SKIP_ZEROES
28 #define CANITER_SKIP_ZEROES TRUE
29 #endif
30 
32 
33 class Hashtable;
34 class Normalizer2;
35 class Normalizer2Impl;
36 
72 class U_COMMON_API CanonicalIterator U_FINAL : public UObject {
73 public:
80  CanonicalIterator(const UnicodeString &source, UErrorCode &status);
81 
86  virtual ~CanonicalIterator();
87 
93  UnicodeString getSource();
94 
99  void reset();
100 
108  UnicodeString next();
109 
117  void setSource(const UnicodeString &newSource, UErrorCode &status);
118 
119 #ifndef U_HIDE_INTERNAL_API
120 
129  static void U_EXPORT2 permute(UnicodeString &source, UBool skipZeros, Hashtable *result, UErrorCode &status);
130 #endif /* U_HIDE_INTERNAL_API */
131 
137  static UClassID U_EXPORT2 getStaticClassID();
138 
144  virtual UClassID getDynamicClassID() const;
145 
146 private:
147  // ===================== PRIVATES ==============================
148  // private default constructor
150 
151 
156  CanonicalIterator(const CanonicalIterator& other);
157 
162  CanonicalIterator& operator=(const CanonicalIterator& other);
163 
164  // fields
165  UnicodeString source;
166  UBool done;
167 
168  // 2 dimensional array holds the pieces of the string with
169  // their different canonically equivalent representations
170  UnicodeString **pieces;
171  int32_t pieces_length;
172  int32_t *pieces_lengths;
173 
174  // current is used in iterating to combine pieces
175  int32_t *current;
176  int32_t current_length;
177 
178  // transient fields
179  UnicodeString buffer;
180 
181  const Normalizer2 &nfd;
182  const Normalizer2Impl &nfcImpl;
183 
184  // we have a segment, in NFD. Find all the strings that are canonically equivalent to it.
185  UnicodeString *getEquivalents(const UnicodeString &segment, int32_t &result_len, UErrorCode &status); //private String[] getEquivalents(String segment)
186 
187  //Set getEquivalents2(String segment);
188  Hashtable *getEquivalents2(Hashtable *fillinResult, const UChar *segment, int32_t segLen, UErrorCode &status);
189  //Hashtable *getEquivalents2(const UnicodeString &segment, int32_t segLen, UErrorCode &status);
190 
196  //Set extract(int comp, String segment, int segmentPos, StringBuffer buffer);
197  Hashtable *extract(Hashtable *fillinResult, UChar32 comp, const UChar *segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
198  //Hashtable *extract(UChar32 comp, const UnicodeString &segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
199 
200  void cleanPieces();
201 
202 };
203 
205 
206 #endif /* #if !UCONFIG_NO_NORMALIZATION */
207 
208 #endif