]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/unicode/normlzr.h
ICU-59117.0.1.tar.gz
[apple/icu.git] / icuSources / common / unicode / normlzr.h
index 475f830aa3cf300cb60aec3b185dd7cd32b1c7dc..eceb6e6b9d9933f9018d50caf794cb0526e32cbe 100644 (file)
@@ -1,7 +1,9 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
  ********************************************************************
  * COPYRIGHT:
- * Copyright (c) 1996-2010, International Business Machines Corporation and
+ * Copyright (c) 1996-2015, International Business Machines Corporation and
  * others. All Rights Reserved.
  ********************************************************************
  */
 #include "unicode/unorm.h"
 #include "unicode/uobject.h"
 
+#if U_SHOW_CPLUSPLUS_API
 U_NAMESPACE_BEGIN
 /**
- * The Normalizer class supports the standard normalization forms described in
- * <a href="http://www.unicode.org/unicode/reports/tr15/" target="unicode">
- * Unicode Standard Annex #15: Unicode Normalization Forms</a>.
+ * Old Unicode normalization API.
  *
- * Note: This API has been replaced by the Normalizer2 class and is only available
+ * This API has been replaced by the Normalizer2 class and is only available
  * for backward compatibility. This class simply delegates to the Normalizer2 class.
  * There is one exception: The new API does not provide a replacement for Normalizer::compare().
  *
+ * The Normalizer class supports the standard normalization forms described in
+ * <a href="http://www.unicode.org/unicode/reports/tr15/" target="unicode">
+ * Unicode Standard Annex #15: Unicode Normalization Forms</a>.
+ *
  * The Normalizer class consists of two parts:
  * - static functions that normalize strings or test if strings are normalized
  * - a Normalizer object is an iterator that takes any kind of text and
@@ -129,10 +134,11 @@ U_NAMESPACE_BEGIN
  */
 class U_COMMON_API Normalizer : public UObject {
 public:
+#ifndef U_HIDE_DEPRECATED_API
   /**
    * If DONE is returned from an iteration function that returns a code point,
    * then there are no more normalization results available.
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   enum {
       DONE=0xffff
@@ -148,7 +154,7 @@ public:
    *              will start at the beginning of the string.
    *
    * @param mode  The normalization mode.
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   Normalizer(const UnicodeString& str, UNormalizationMode mode);
 
@@ -161,9 +167,9 @@ public:
    *
    * @param length Length of the string, or -1 if NUL-terminated.
    * @param mode  The normalization mode.
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
-  Normalizer(const UChar* str, int32_t length, UNormalizationMode mode);
+  Normalizer(ConstChar16Ptr str, int32_t length, UNormalizationMode mode);
 
   /**
    * Creates a new <code>Normalizer</code> object for iterating over the
@@ -173,20 +179,21 @@ public:
    *              will start at the beginning of the string.
    *
    * @param mode  The normalization mode.
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   Normalizer(const CharacterIterator& iter, UNormalizationMode mode);
+#endif  /* U_HIDE_DEPRECATED_API */
 
   /**
    * Copy constructor.
    * @param copy The object to be copied.
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   Normalizer(const Normalizer& copy);
 
   /**
    * Destructor
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   virtual ~Normalizer();
 
@@ -195,6 +202,7 @@ public:
   // Static utility methods
   //-------------------------------------------------------------------------
 
+#ifndef U_HIDE_DEPRECATED_API
   /**
    * Normalizes a <code>UnicodeString</code> according to the specified normalization mode.
    * This is a wrapper for unorm_normalize(), using UnicodeString's.
@@ -207,7 +215,7 @@ public:
    * @param options   the optional features to be enabled (0 for no options)
    * @param result    The normalized string (on output).
    * @param status    The error code.
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   static void U_EXPORT2 normalize(const UnicodeString& source,
                         UNormalizationMode mode, int32_t options,
@@ -229,7 +237,7 @@ public:
    * @param options   the optional features to be enabled (0 for no options)
    * @param result    The composed string (on output).
    * @param status    The error code.
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   static void U_EXPORT2 compose(const UnicodeString& source,
                       UBool compat, int32_t options,
@@ -251,7 +259,7 @@ public:
    * @param options   the optional features to be enabled (0 for no options)
    * @param result    The decomposed string (on output).
    * @param status    The error code.
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   static void U_EXPORT2 decompose(const UnicodeString& source,
                         UBool compat, int32_t options,
@@ -276,7 +284,7 @@ public:
    * @return UNORM_YES, UNORM_NO or UNORM_MAYBE
    *
    * @see isNormalized
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   static inline UNormalizationCheckResult
   quickCheck(const UnicodeString &source, UNormalizationMode mode, UErrorCode &status);
@@ -292,7 +300,7 @@ public:
    * @return UNORM_YES, UNORM_NO or UNORM_MAYBE
    *
    * @see isNormalized
-   * @stable ICU 2.6
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   static UNormalizationCheckResult
   quickCheck(const UnicodeString &source, UNormalizationMode mode, int32_t options, UErrorCode &status);
@@ -315,7 +323,7 @@ public:
    *         "mode" normalization form.
    *
    * @see quickCheck
-   * @stable ICU 2.2
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   static inline UBool
   isNormalized(const UnicodeString &src, UNormalizationMode mode, UErrorCode &errorCode);
@@ -333,7 +341,7 @@ public:
    *         "mode" normalization form.
    *
    * @see quickCheck
-   * @stable ICU 2.6
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   static UBool
   isNormalized(const UnicodeString &src, UNormalizationMode mode, int32_t options, UErrorCode &errorCode);
@@ -365,13 +373,14 @@ public:
    * @see unorm_next
    * @see unorm_previous
    *
-   * @stable ICU 2.1
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   static UnicodeString &
-  U_EXPORT2 concatenate(UnicodeString &left, UnicodeString &right,
+  U_EXPORT2 concatenate(const UnicodeString &left, const UnicodeString &right,
               UnicodeString &result,
               UNormalizationMode mode, int32_t options,
               UErrorCode &errorCode);
+#endif  /* U_HIDE_DEPRECATED_API */
 
   /**
    * Compare two strings for canonical equivalence.
@@ -442,6 +451,7 @@ public:
           uint32_t options,
           UErrorCode &errorCode);
 
+#ifndef U_HIDE_DEPRECATED_API
   //-------------------------------------------------------------------------
   // Iteration API
   //-------------------------------------------------------------------------
@@ -452,7 +462,7 @@ public:
    * The getIndex() is not changed.
    *
    * @return the current normalized code point
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   UChar32              current(void);
 
@@ -462,7 +472,7 @@ public:
    * (Post-increment semantics.)
    *
    * @return the first normalized code point
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   UChar32              first(void);
 
@@ -472,7 +482,7 @@ public:
    * (Pre-decrement semantics.)
    *
    * @return the last normalized code point
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   UChar32              last(void);
 
@@ -488,7 +498,7 @@ public:
    * The C API unorm_next() is more efficient and does not have this ambiguity.
    *
    * @return the next normalized code point
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   UChar32              next(void);
 
@@ -504,7 +514,7 @@ public:
    * The C API unorm_previous() is more efficient and does not have this ambiguity.
    *
    * @return the previous normalized code point
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   UChar32              previous(void);
 
@@ -515,14 +525,14 @@ public:
    * specified here.
    *
    * @param index the desired index in the input text.
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   void                 setIndexOnly(int32_t index);
 
   /**
    * Reset the index to the beginning of the text.
    * This is equivalent to setIndexOnly(startIndex)).
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   void                reset(void);
 
@@ -538,7 +548,7 @@ public:
    * was returned from with previous().
    *
    * @return the current index in the input text
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   int32_t            getIndex(void) const;
 
@@ -548,7 +558,7 @@ public:
    * over which this <code>Normalizer</code> is iterating.
    *
    * @return the smallest index in the input text where the Normalizer operates
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   int32_t            startIndex(void) const;
 
@@ -560,7 +570,7 @@ public:
    * before this index.
    *
    * @return the first index in the input text where the Normalizer does not operate
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   int32_t            endIndex(void) const;
 
@@ -570,7 +580,7 @@ public:
    *
    * @param that a Normalizer object to compare this one to
    * @return comparison result
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   UBool        operator==(const Normalizer& that) const;
 
@@ -580,7 +590,7 @@ public:
    *
    * @param that a Normalizer object to compare this one to
    * @return comparison result
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   inline UBool        operator!=(const Normalizer& that) const;
 
@@ -588,7 +598,7 @@ public:
    * Returns a pointer to a new Normalizer that is a clone of this one.
    * The caller is responsible for deleting the new clone.
    * @return a pointer to a new Normalizer
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   Normalizer*        clone(void) const;
 
@@ -596,7 +606,7 @@ public:
    * Generates a hash code for this iterator.
    *
    * @return the hash code
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   int32_t                hashCode(void) const;
 
@@ -617,7 +627,7 @@ public:
    * <p>
    * @param newMode the new mode for this <code>Normalizer</code>.
    * @see #getUMode
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   void setMode(UNormalizationMode newMode);
 
@@ -629,7 +639,7 @@ public:
    *
    * @return the mode for this <code>Normalizer</code>
    * @see #setMode
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   UNormalizationMode getUMode(void) const;
 
@@ -647,7 +657,7 @@ public:
    *                  turn the option(s) on and <code>FALSE</code> to turn it/them off.
    *
    * @see #getOption
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   void setOption(int32_t option,
          UBool value);
@@ -660,7 +670,7 @@ public:
    * @param option the option(s) that are to be checked
    * @return TRUE if any of the option(s) are set
    * @see #setOption
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   UBool getOption(int32_t option) const;
 
@@ -670,7 +680,7 @@ public:
    *
    * @param newText a string that replaces the current input text
    * @param status a UErrorCode
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   void setText(const UnicodeString& newText,
            UErrorCode &status);
@@ -681,7 +691,7 @@ public:
    *
    * @param newText a CharacterIterator object that replaces the current input text
    * @param status a UErrorCode
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   void setText(const CharacterIterator& newText,
            UErrorCode &status);
@@ -693,30 +703,31 @@ public:
    * @param newText a string that replaces the current input text
    * @param length the length of the string, or -1 if NUL-terminated
    * @param status a UErrorCode
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
-  void setText(const UChar* newText,
+  void setText(ConstChar16Ptr newText,
                     int32_t length,
             UErrorCode &status);
   /**
    * Copies the input text into the UnicodeString argument.
    *
    * @param result Receives a copy of the text under iteration.
-   * @stable ICU 2.0
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   void            getText(UnicodeString&  result);
 
   /**
    * ICU "poor man's RTTI", returns a UClassID for this class.
    * @returns a UClassID for this class.
-   * @stable ICU 2.2
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   static UClassID U_EXPORT2 getStaticClassID();
+#endif  /* U_HIDE_DEPRECATED_API */
 
   /**
    * ICU "poor man's RTTI", returns a UClassID for the actual class.
    * @return a UClassID for the actual class.
-   * @stable ICU 2.2
+   * @deprecated ICU 56 Use Normalizer2 instead.
    */
   virtual UClassID getDynamicClassID() const;
 
@@ -742,7 +753,7 @@ private:
 
   FilteredNormalizer2*fFilteredNorm2;  // owned if not NULL
   const Normalizer2  *fNorm2;  // not owned; may be equal to fFilteredNorm2
-  UNormalizationMode  fUMode;
+  UNormalizationMode  fUMode;  // deprecated
   int32_t             fOptions;
 
   // The input text and our position in it
@@ -761,6 +772,7 @@ private:
 // Inline implementations
 //-------------------------------------------------------------------------
 
+#ifndef U_HIDE_DEPRECATED_API
 inline UBool
 Normalizer::operator!= (const Normalizer& other) const
 { return ! operator==(other); }
@@ -778,19 +790,21 @@ Normalizer::isNormalized(const UnicodeString& source,
                          UErrorCode &status) {
     return isNormalized(source, mode, 0, status);
 }
+#endif  /* U_HIDE_DEPRECATED_API */
 
 inline int32_t
 Normalizer::compare(const UnicodeString &s1, const UnicodeString &s2,
                     uint32_t options,
                     UErrorCode &errorCode) {
   // all argument checking is done in unorm_compare
-  return unorm_compare(s1.getBuffer(), s1.length(),
-                       s2.getBuffer(), s2.length(),
+  return unorm_compare(toUCharPtr(s1.getBuffer()), s1.length(),
+                       toUCharPtr(s2.getBuffer()), s2.length(),
                        options,
                        &errorCode);
 }
 
 U_NAMESPACE_END
+#endif // U_SHOW_CPLUSPLUS_API
 
 #endif /* #if !UCONFIG_NO_NORMALIZATION */