Loading...
Searching...
No Matches
caniter.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
* Copyright (C) 1996-2014, International Business Machines Corporation and
* others. All Rights Reserved.
*******************************************************************************
*/
#ifndef CANITER_H
#define CANITER_H
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#if !UCONFIG_NO_NORMALIZATION
#include "unicode/uobject.h"
#include "unicode/unistr.h"
#ifndef CANITER_SKIP_ZEROES
#define CANITER_SKIP_ZEROES true
#endif
U_NAMESPACE_BEGIN
class Hashtable;
class Normalizer2;
class Normalizer2Impl;
class U_COMMON_API CanonicalIterator final : public UObject {
public:
CanonicalIterator(const UnicodeString &source, UErrorCode &status);
virtual ~CanonicalIterator();
UnicodeString getSource();
void reset();
UnicodeString next();
void setSource(const UnicodeString &newSource, UErrorCode &status);
#ifndef U_HIDE_INTERNAL_API
static void U_EXPORT2 permute(UnicodeString &source, UBool skipZeros, Hashtable *result, UErrorCode &status, int32_t depth=0);
#endif /* U_HIDE_INTERNAL_API */
static UClassID U_EXPORT2 getStaticClassID();
virtual UClassID getDynamicClassID() const override;
private:
// ===================== PRIVATES ==============================
// private default constructor
CanonicalIterator() = delete;
CanonicalIterator(const CanonicalIterator& other) = delete;
CanonicalIterator& operator=(const CanonicalIterator& other) = delete;
// fields
UnicodeString source;
UBool done;
// 2 dimensional array holds the pieces of the string with
// their different canonically equivalent representations
UnicodeString **pieces;
int32_t pieces_length;
int32_t *pieces_lengths;
// current is used in iterating to combine pieces
int32_t *current;
int32_t current_length;
// transient fields
UnicodeString buffer;
const Normalizer2 *nfd;
const Normalizer2Impl *nfcImpl;
// we have a segment, in NFD. Find all the strings that are canonically equivalent to it.
UnicodeString *getEquivalents(const UnicodeString &segment, int32_t &result_len, UErrorCode &status); //private String[] getEquivalents(String segment)
//Set getEquivalents2(String segment);
Hashtable *getEquivalents2(Hashtable *fillinResult, const char16_t *segment, int32_t segLen, UErrorCode &status);
//Hashtable *getEquivalents2(const UnicodeString &segment, int32_t segLen, UErrorCode &status);
//Set extract(int comp, String segment, int segmentPos, StringBuffer buffer);
Hashtable *extract(Hashtable *fillinResult, UChar32 comp, const char16_t *segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
//Hashtable *extract(UChar32 comp, const UnicodeString &segment, int32_t segLen, int32_t segmentPos, UErrorCode &status);
void cleanPieces();
};
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_NORMALIZATION */
#endif /* U_SHOW_CPLUSPLUS_API */
#endif
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:222
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:303
UChar32
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition umachine.h:449
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
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:509
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