ICU 4.4.2 4.4.2
|
00001 /* 00002 ******************************************************************************* 00003 * 00004 * Copyright (C) 2009-2010, International Business Machines 00005 * Corporation and others. All Rights Reserved. 00006 * 00007 ******************************************************************************* 00008 * file name: normalizer2.h 00009 * encoding: US-ASCII 00010 * tab size: 8 (not used) 00011 * indentation:4 00012 * 00013 * created on: 2009nov22 00014 * created by: Markus W. Scherer 00015 */ 00016 00017 #ifndef __NORMALIZER2_H__ 00018 #define __NORMALIZER2_H__ 00019 00025 #include "unicode/utypes.h" 00026 00027 #if !UCONFIG_NO_NORMALIZATION 00028 00029 #include "unicode/uniset.h" 00030 #include "unicode/unistr.h" 00031 #include "unicode/unorm2.h" 00032 00033 U_NAMESPACE_BEGIN 00034 00077 class U_COMMON_API Normalizer2 : public UObject { 00078 public: 00100 static const Normalizer2 * 00101 getInstance(const char *packageName, 00102 const char *name, 00103 UNormalization2Mode mode, 00104 UErrorCode &errorCode); 00105 00116 UnicodeString 00117 normalize(const UnicodeString &src, UErrorCode &errorCode) const { 00118 UnicodeString result; 00119 normalize(src, result, errorCode); 00120 return result; 00121 } 00135 virtual UnicodeString & 00136 normalize(const UnicodeString &src, 00137 UnicodeString &dest, 00138 UErrorCode &errorCode) const = 0; 00153 virtual UnicodeString & 00154 normalizeSecondAndAppend(UnicodeString &first, 00155 const UnicodeString &second, 00156 UErrorCode &errorCode) const = 0; 00171 virtual UnicodeString & 00172 append(UnicodeString &first, 00173 const UnicodeString &second, 00174 UErrorCode &errorCode) const = 0; 00175 00190 virtual UBool 00191 isNormalized(const UnicodeString &s, UErrorCode &errorCode) const = 0; 00192 00208 virtual UNormalizationCheckResult 00209 quickCheck(const UnicodeString &s, UErrorCode &errorCode) const = 0; 00210 00233 virtual int32_t 00234 spanQuickCheckYes(const UnicodeString &s, UErrorCode &errorCode) const = 0; 00235 00249 virtual UBool hasBoundaryBefore(UChar32 c) const = 0; 00250 00265 virtual UBool hasBoundaryAfter(UChar32 c) const = 0; 00266 00280 virtual UBool isInert(UChar32 c) const = 0; 00281 00287 static UClassID U_EXPORT2 getStaticClassID(); 00288 00294 virtual UClassID getDynamicClassID() const = 0; 00295 }; 00296 00308 class U_COMMON_API FilteredNormalizer2 : public Normalizer2 { 00309 public: 00320 FilteredNormalizer2(const Normalizer2 &n2, const UnicodeSet &filterSet) : 00321 norm2(n2), set(filterSet) {} 00322 00336 virtual UnicodeString & 00337 normalize(const UnicodeString &src, 00338 UnicodeString &dest, 00339 UErrorCode &errorCode) const; 00354 virtual UnicodeString & 00355 normalizeSecondAndAppend(UnicodeString &first, 00356 const UnicodeString &second, 00357 UErrorCode &errorCode) const; 00372 virtual UnicodeString & 00373 append(UnicodeString &first, 00374 const UnicodeString &second, 00375 UErrorCode &errorCode) const; 00376 00388 virtual UBool 00389 isNormalized(const UnicodeString &s, UErrorCode &errorCode) const; 00401 virtual UNormalizationCheckResult 00402 quickCheck(const UnicodeString &s, UErrorCode &errorCode) const; 00414 virtual int32_t 00415 spanQuickCheckYes(const UnicodeString &s, UErrorCode &errorCode) const; 00416 00425 virtual UBool hasBoundaryBefore(UChar32 c) const; 00426 00435 virtual UBool hasBoundaryAfter(UChar32 c) const; 00436 00444 virtual UBool isInert(UChar32 c) const; 00445 00451 static UClassID U_EXPORT2 getStaticClassID(); 00452 00458 virtual UClassID getDynamicClassID() const; 00459 private: 00460 UnicodeString & 00461 normalize(const UnicodeString &src, 00462 UnicodeString &dest, 00463 USetSpanCondition spanCondition, 00464 UErrorCode &errorCode) const; 00465 00466 UnicodeString & 00467 normalizeSecondAndAppend(UnicodeString &first, 00468 const UnicodeString &second, 00469 UBool doNormalize, 00470 UErrorCode &errorCode) const; 00471 00472 const Normalizer2 &norm2; 00473 const UnicodeSet &set; 00474 }; 00475 00476 U_NAMESPACE_END 00477 00478 #endif // !UCONFIG_NO_NORMALIZATION 00479 #endif // __NORMALIZER2_H__