Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / icu / source / common / ustr_imp.h
index 01c7901..ee54d33 100644 (file)
@@ -1,6 +1,6 @@
 /*  
 **********************************************************************
-*   Copyright (C) 1999-2010, International Business Machines
+*   Copyright (C) 1999-2011, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 **********************************************************************
 *   file name:  ustr_imp.h
@@ -19,7 +19,7 @@
 #include "unicode/uiter.h"
 #include "ucase.h"
 
-/** Simple declaration for u_strToTitle() to avoid including unicode/ubrk.h. */
+/** Simple declaration to avoid including unicode/ubrk.h. */
 #ifndef UBRK_TYPEDEF_UBREAK_ITERATOR
 #   define UBRK_TYPEDEF_UBREAK_ITERATOR
     typedef struct UBreakIterator UBreakIterator;
@@ -30,7 +30,6 @@
 /**
  * Option bit for unorm_compare:
  * Perform case-insensitive comparison.
- * @draft ICU 2.2
  */
 #define U_COMPARE_IGNORE_CASE       0x10000
 #endif
@@ -38,7 +37,6 @@
 /**
  * Internal option for unorm_cmpEquivFold() for strncmp style.
  * If set, checks for both string length and terminating NUL.
- * @internal
  */
 #define _STRNCMP_STYLE 0x1000
 
@@ -47,7 +45,6 @@
  * Works in strcmp style (both lengths -1),
  * strncmp style (lengths equal and >=0, flag TRUE),
  * and memcmp/UnicodeString style (at least one length >=0).
- * @internal
  */
 U_CFUNC int32_t U_EXPORT2
 uprv_strCompare(const UChar *s1, int32_t length1,
@@ -58,7 +55,6 @@ uprv_strCompare(const UChar *s1, int32_t length1,
  * Internal API, used by u_strcasecmp() etc.
  * Compare strings case-insensitively,
  * in code point order or code unit order.
- * @internal
  */
 U_CFUNC int32_t
 u_strcmpFold(const UChar *s1, int32_t length1,
@@ -71,7 +67,6 @@ u_strcmpFold(const UChar *s1, int32_t length1,
  * This must be used before internal functions are called that do
  * not perform this check.
  * Generate a debug assertion failure if data is not loaded.
- * @internal
  */
 U_CFUNC UBool
 uprv_haveProperties(UErrorCode *pErrorCode);
@@ -81,7 +76,6 @@ uprv_haveProperties(UErrorCode *pErrorCode);
   * Intended primarily for use from u_init().
   * Has no effect if property data is already loaded.
   * NOT thread safe.
-  * @internal
   */
 /*U_CFUNC int8_t
 uprv_loadPropsData(UErrorCode *errorCode);*/
@@ -91,9 +85,6 @@ uprv_loadPropsData(UErrorCode *errorCode);*/
  * ustring.h/ustrcase.c and UnicodeString case mapping functions.
  */
 
-/**
- * @internal
- */
 struct UCaseMap {
     const UCaseProps *csp;
 #if !UCONFIG_NO_BREAK_ITERATION
@@ -108,61 +99,114 @@ struct UCaseMap {
 typedef struct UCaseMap UCaseMap;
 #endif
 
+#if UCONFIG_NO_BREAK_ITERATION
+#   define UCASEMAP_INITIALIZER { NULL, { 0 }, 0, 0 }
+#else
+#   define UCASEMAP_INITIALIZER { NULL, NULL, { 0 }, 0, 0 }
+#endif
+
+U_CFUNC void
+ustrcase_setTempCaseMapLocale(UCaseMap *csm, const char *locale);
+
+#ifndef U_STRING_CASE_MAPPER_DEFINED
+#define U_STRING_CASE_MAPPER_DEFINED
+
 /**
- * @internal
+ * String case mapping function type, used by ustrcase_map().
+ * All error checking must be done.
+ * The UCaseMap must be fully initialized, with locale and/or iter set as needed.
+ * src and dest must not overlap.
  */
-enum {
-    TO_LOWER,
-    TO_UPPER,
-    TO_TITLE,
-    FOLD_CASE
-};
+typedef int32_t U_CALLCONV
+UStringCaseMapper(const UCaseMap *csm,
+                  UChar *dest, int32_t destCapacity,
+                  const UChar *src, int32_t srcLength,
+                  UErrorCode *pErrorCode);
+
+#endif
+
+/** Implements UStringCaseMapper. */
+U_CFUNC int32_t U_CALLCONV
+ustrcase_internalToLower(const UCaseMap *csm,
+                         UChar *dest, int32_t destCapacity,
+                         const UChar *src, int32_t srcLength,
+                         UErrorCode *pErrorCode);
+
+/** Implements UStringCaseMapper. */
+U_CFUNC int32_t U_CALLCONV
+ustrcase_internalToUpper(const UCaseMap *csm,
+                         UChar *dest, int32_t destCapacity,
+                         const UChar *src, int32_t srcLength,
+                         UErrorCode *pErrorCode);
+
+#if !UCONFIG_NO_BREAK_ITERATION
+
+/** Implements UStringCaseMapper. */
+U_CFUNC int32_t U_CALLCONV
+ustrcase_internalToTitle(const UCaseMap *csm,
+                         UChar *dest, int32_t destCapacity,
+                         const UChar *src, int32_t srcLength,
+                         UErrorCode *pErrorCode);
+
+#endif
+
+/** Implements UStringCaseMapper. */
+U_CFUNC int32_t U_CALLCONV
+ustrcase_internalFold(const UCaseMap *csm,
+                      UChar *dest, int32_t destCapacity,
+                      const UChar *src, int32_t srcLength,
+                      UErrorCode *pErrorCode);
 
 /**
- * @internal
+ * Implements argument checking and buffer handling
+ * for string case mapping as a common function.
  */
 U_CFUNC int32_t
-ustr_toLower(const UCaseProps *csp,
+ustrcase_map(const UCaseMap *csm,
              UChar *dest, int32_t destCapacity,
              const UChar *src, int32_t srcLength,
-             const char *locale,
+             UStringCaseMapper *stringCaseMapper,
              UErrorCode *pErrorCode);
 
 /**
- * @internal
+ * UTF-8 string case mapping function type, used by ucasemap_mapUTF8().
+ * UTF-8 version of UStringCaseMapper.
+ * All error checking must be done.
+ * The UCaseMap must be fully initialized, with locale and/or iter set as needed.
+ * src and dest must not overlap.
  */
-U_CFUNC int32_t
-ustr_toUpper(const UCaseProps *csp,
-             UChar *dest, int32_t destCapacity,
-             const UChar *src, int32_t srcLength,
-             const char *locale,
-             UErrorCode *pErrorCode);
+typedef int32_t U_CALLCONV
+UTF8CaseMapper(const UCaseMap *csm,
+               uint8_t *dest, int32_t destCapacity,
+               const uint8_t *src, int32_t srcLength,
+               UErrorCode *pErrorCode);
 
-#if !UCONFIG_NO_BREAK_ITERATION
+/** Implements UTF8CaseMapper. */
+U_CFUNC int32_t U_CALLCONV
+ucasemap_internalUTF8ToTitle(const UCaseMap *csm,
+         uint8_t *dest, int32_t destCapacity,
+         const uint8_t *src, int32_t srcLength,
+         UErrorCode *pErrorCode);
 
 /**
- * @internal
+ * Implements argument checking and buffer handling
+ * for UTF-8 string case mapping as a common function.
  */
 U_CFUNC int32_t
-ustr_toTitle(const UCaseProps *csp,
-             UChar *dest, int32_t destCapacity,
-             const UChar *src, int32_t srcLength,
-             UBreakIterator *titleIter,
-             const char *locale, uint32_t options,
-             UErrorCode *pErrorCode);
+ucasemap_mapUTF8(const UCaseMap *csm,
+                 uint8_t *dest, int32_t destCapacity,
+                 const uint8_t *src, int32_t srcLength,
+                 UTF8CaseMapper *stringCaseMapper,
+                 UErrorCode *pErrorCode);
 
-#endif
+U_CAPI int32_t U_EXPORT2 
+ustr_hashUCharsN(const UChar *str, int32_t length);
 
-/**
- * Internal case folding function.
- * @internal
- */
-U_CFUNC int32_t
-ustr_foldCase(const UCaseProps *csp,
-              UChar *dest, int32_t destCapacity,
-              const UChar *src, int32_t srcLength,
-              uint32_t options,
-              UErrorCode *pErrorCode);
+U_CAPI int32_t U_EXPORT2 
+ustr_hashCharsN(const char *str, int32_t length);
+
+U_CAPI int32_t U_EXPORT2
+ustr_hashICharsN(const char *str, int32_t length);
 
 /**
  * NUL-terminate a UChar * string if possible.
@@ -175,7 +219,6 @@ ustr_foldCase(const UCaseProps *csp,
  * @param length Number of UChars that were (to be) written to dest.
  * @param pErrorCode ICU error code.
  * @return length
- * @internal
  */
 U_CAPI int32_t U_EXPORT2
 u_terminateUChars(UChar *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);