X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/f3c0d7a59d99c2a94c6b8822291f0e42be3773c9..0f5d89e82340278ed3d7d50029f37cab2c41a57e:/icuSources/common/unicode/casemap.h diff --git a/icuSources/common/unicode/casemap.h b/icuSources/common/unicode/casemap.h index f3fc734d..5e693087 100644 --- a/icuSources/common/unicode/casemap.h +++ b/icuSources/common/unicode/casemap.h @@ -8,6 +8,7 @@ #define __CASEMAP_H__ #include "unicode/utypes.h" +#include "unicode/stringpiece.h" #include "unicode/uobject.h" /** @@ -18,15 +19,14 @@ #if U_SHOW_CPLUSPLUS_API U_NAMESPACE_BEGIN -#ifndef U_HIDE_DRAFT_API - class BreakIterator; +class ByteSink; class Edits; /** * Low-level C++ case mapping functions. * - * @draft ICU 59 + * @stable ICU 59 */ class U_COMMON_API CaseMap U_FINAL : public UMemory { public: @@ -37,7 +37,7 @@ public: * The source string and the destination buffer must not overlap. * * @param locale The locale ID. ("" = root locale, NULL = default locale.) - * @param options Options bit set, usually 0. See UCASEMAP_OMIT_UNCHANGED_TEXT. + * @param options Options bit set, usually 0. See U_OMIT_UNCHANGED_TEXT and U_EDITS_NO_RESET. * @param src The original string. * @param srcLength The length of the original string. If -1, then src must be NUL-terminated. * @param dest A buffer for the result string. The result will be NUL-terminated if @@ -49,7 +49,8 @@ public: * @param edits Records edits for index mapping, working with styled text, * and getting only changes (if any). * The Edits contents is undefined if any error occurs. - * This function calls edits->reset() first. edits can be NULL. + * This function calls edits->reset() first unless + * options includes U_EDITS_NO_RESET. edits can be NULL. * @param errorCode Reference to an in/out error code value * which must not indicate a failure before the function call. * @return The length of the result string, if successful. @@ -57,7 +58,7 @@ public: * the full length is returned and a U_BUFFER_OVERFLOW_ERROR is set. * * @see u_strToLower - * @draft ICU 59 + * @stable ICU 59 */ static int32_t toLower( const char *locale, uint32_t options, @@ -72,7 +73,7 @@ public: * The source string and the destination buffer must not overlap. * * @param locale The locale ID. ("" = root locale, NULL = default locale.) - * @param options Options bit set, usually 0. See UCASEMAP_OMIT_UNCHANGED_TEXT. + * @param options Options bit set, usually 0. See U_OMIT_UNCHANGED_TEXT and U_EDITS_NO_RESET. * @param src The original string. * @param srcLength The length of the original string. If -1, then src must be NUL-terminated. * @param dest A buffer for the result string. The result will be NUL-terminated if @@ -84,7 +85,8 @@ public: * @param edits Records edits for index mapping, working with styled text, * and getting only changes (if any). * The Edits contents is undefined if any error occurs. - * This function calls edits->reset() first. edits can be NULL. + * This function calls edits->reset() first unless + * options includes U_EDITS_NO_RESET. edits can be NULL. * @param errorCode Reference to an in/out error code value * which must not indicate a failure before the function call. * @return The length of the result string, if successful. @@ -92,7 +94,7 @@ public: * the full length is returned and a U_BUFFER_OVERFLOW_ERROR is set. * * @see u_strToUpper - * @draft ICU 59 + * @stable ICU 59 */ static int32_t toUpper( const char *locale, uint32_t options, @@ -113,8 +115,10 @@ public: * all others. (This can be modified with options bits.) * * @param locale The locale ID. ("" = root locale, NULL = default locale.) - * @param options Options bit set, usually 0. See UCASEMAP_OMIT_UNCHANGED_TEXT, - * U_TITLECASE_NO_LOWERCASE, U_TITLECASE_NO_BREAK_ADJUSTMENT. + * @param options Options bit set, usually 0. See U_OMIT_UNCHANGED_TEXT, U_EDITS_NO_RESET, + * U_TITLECASE_NO_LOWERCASE, + * U_TITLECASE_NO_BREAK_ADJUSTMENT, U_TITLECASE_ADJUST_TO_CASED, + * U_TITLECASE_WHOLE_STRING, U_TITLECASE_SENTENCES. * @param iter A break iterator to find the first characters of words that are to be titlecased. * It is set to the source string (setText()) * and used one or more times for iteration (first() and next()). @@ -131,7 +135,8 @@ public: * @param edits Records edits for index mapping, working with styled text, * and getting only changes (if any). * The Edits contents is undefined if any error occurs. - * This function calls edits->reset() first. edits can be NULL. + * This function calls edits->reset() first unless + * options includes U_EDITS_NO_RESET. edits can be NULL. * @param errorCode Reference to an in/out error code value * which must not indicate a failure before the function call. * @return The length of the result string, if successful. @@ -140,7 +145,7 @@ public: * * @see u_strToTitle * @see ucasemap_toTitle - * @draft ICU 59 + * @stable ICU 59 */ static int32_t toTitle( const char *locale, uint32_t options, BreakIterator *iter, @@ -160,7 +165,7 @@ public: * The result may be longer or shorter than the original. * The source string and the destination buffer must not overlap. * - * @param options Options bit set, usually 0. See UCASEMAP_OMIT_UNCHANGED_TEXT, + * @param options Options bit set, usually 0. See U_OMIT_UNCHANGED_TEXT, U_EDITS_NO_RESET, * U_FOLD_CASE_DEFAULT, U_FOLD_CASE_EXCLUDE_SPECIAL_I. * @param src The original string. * @param srcLength The length of the original string. If -1, then src must be NUL-terminated. @@ -173,7 +178,8 @@ public: * @param edits Records edits for index mapping, working with styled text, * and getting only changes (if any). * The Edits contents is undefined if any error occurs. - * This function calls edits->reset() first. edits can be NULL. + * This function calls edits->reset() first unless + * options includes U_EDITS_NO_RESET. edits can be NULL. * @param errorCode Reference to an in/out error code value * which must not indicate a failure before the function call. * @return The length of the result string, if successful. @@ -181,7 +187,7 @@ public: * the full length is returned and a U_BUFFER_OVERFLOW_ERROR is set. * * @see u_strFoldCase - * @draft ICU 59 + * @stable ICU 59 */ static int32_t fold( uint32_t options, @@ -189,6 +195,131 @@ public: char16_t *dest, int32_t destCapacity, Edits *edits, UErrorCode &errorCode); +#ifndef U_HIDE_DRAFT_API + /** + * Lowercases a UTF-8 string and optionally records edits. + * Casing is locale-dependent and context-sensitive. + * The result may be longer or shorter than the original. + * + * @param locale The locale ID. ("" = root locale, NULL = default locale.) + * @param options Options bit set, usually 0. See U_OMIT_UNCHANGED_TEXT and U_EDITS_NO_RESET. + * @param src The original string. + * @param sink A ByteSink to which the result string is written. + * sink.Flush() is called at the end. + * @param edits Records edits for index mapping, working with styled text, + * and getting only changes (if any). + * The Edits contents is undefined if any error occurs. + * This function calls edits->reset() first unless + * options includes U_EDITS_NO_RESET. edits can be NULL. + * @param errorCode Reference to an in/out error code value + * which must not indicate a failure before the function call. + * + * @see ucasemap_utf8ToLower + * @draft ICU 60 + */ + static void utf8ToLower( + const char *locale, uint32_t options, + StringPiece src, ByteSink &sink, Edits *edits, + UErrorCode &errorCode); + + /** + * Uppercases a UTF-8 string and optionally records edits. + * Casing is locale-dependent and context-sensitive. + * The result may be longer or shorter than the original. + * + * @param locale The locale ID. ("" = root locale, NULL = default locale.) + * @param options Options bit set, usually 0. See U_OMIT_UNCHANGED_TEXT and U_EDITS_NO_RESET. + * @param src The original string. + * @param sink A ByteSink to which the result string is written. + * sink.Flush() is called at the end. + * @param edits Records edits for index mapping, working with styled text, + * and getting only changes (if any). + * The Edits contents is undefined if any error occurs. + * This function calls edits->reset() first unless + * options includes U_EDITS_NO_RESET. edits can be NULL. + * @param errorCode Reference to an in/out error code value + * which must not indicate a failure before the function call. + * + * @see ucasemap_utf8ToUpper + * @draft ICU 60 + */ + static void utf8ToUpper( + const char *locale, uint32_t options, + StringPiece src, ByteSink &sink, Edits *edits, + UErrorCode &errorCode); + +#if !UCONFIG_NO_BREAK_ITERATION + + /** + * Titlecases a UTF-8 string and optionally records edits. + * Casing is locale-dependent and context-sensitive. + * The result may be longer or shorter than the original. + * + * Titlecasing uses a break iterator to find the first characters of words + * that are to be titlecased. It titlecases those characters and lowercases + * all others. (This can be modified with options bits.) + * + * @param locale The locale ID. ("" = root locale, NULL = default locale.) + * @param options Options bit set, usually 0. See U_OMIT_UNCHANGED_TEXT, U_EDITS_NO_RESET, + * U_TITLECASE_NO_LOWERCASE, + * U_TITLECASE_NO_BREAK_ADJUSTMENT, U_TITLECASE_ADJUST_TO_CASED, + * U_TITLECASE_WHOLE_STRING, U_TITLECASE_SENTENCES. + * @param iter A break iterator to find the first characters of words that are to be titlecased. + * It is set to the source string (setUText()) + * and used one or more times for iteration (first() and next()). + * If NULL, then a word break iterator for the locale is used + * (or something equivalent). + * @param src The original string. + * @param sink A ByteSink to which the result string is written. + * sink.Flush() is called at the end. + * @param edits Records edits for index mapping, working with styled text, + * and getting only changes (if any). + * The Edits contents is undefined if any error occurs. + * This function calls edits->reset() first unless + * options includes U_EDITS_NO_RESET. edits can be NULL. + * @param errorCode Reference to an in/out error code value + * which must not indicate a failure before the function call. + * + * @see ucasemap_utf8ToTitle + * @draft ICU 60 + */ + static void utf8ToTitle( + const char *locale, uint32_t options, BreakIterator *iter, + StringPiece src, ByteSink &sink, Edits *edits, + UErrorCode &errorCode); + +#endif // UCONFIG_NO_BREAK_ITERATION + + /** + * Case-folds a UTF-8 string and optionally records edits. + * + * Case folding is locale-independent and not context-sensitive, + * but there is an option for whether to include or exclude mappings for dotted I + * and dotless i that are marked with 'T' in CaseFolding.txt. + * + * The result may be longer or shorter than the original. + * + * @param options Options bit set, usually 0. See U_OMIT_UNCHANGED_TEXT and U_EDITS_NO_RESET. + * @param src The original string. + * @param sink A ByteSink to which the result string is written. + * sink.Flush() is called at the end. + * @param edits Records edits for index mapping, working with styled text, + * and getting only changes (if any). + * The Edits contents is undefined if any error occurs. + * This function calls edits->reset() first unless + * options includes U_EDITS_NO_RESET. edits can be NULL. + * @param errorCode Reference to an in/out error code value + * which must not indicate a failure before the function call. + * + * @see ucasemap_utf8FoldCase + * @draft ICU 60 + */ + static void utf8Fold( + uint32_t options, + StringPiece src, ByteSink &sink, Edits *edits, + UErrorCode &errorCode); +#endif // U_HIDE_DRAFT_API + /** * Lowercases a UTF-8 string and optionally records edits. * Casing is locale-dependent and context-sensitive. @@ -196,7 +327,7 @@ public: * The source string and the destination buffer must not overlap. * * @param locale The locale ID. ("" = root locale, NULL = default locale.) - * @param options Options bit set, usually 0. See UCASEMAP_OMIT_UNCHANGED_TEXT. + * @param options Options bit set, usually 0. See U_OMIT_UNCHANGED_TEXT and U_EDITS_NO_RESET. * @param src The original string. * @param srcLength The length of the original string. If -1, then src must be NUL-terminated. * @param dest A buffer for the result string. The result will be NUL-terminated if @@ -208,7 +339,8 @@ public: * @param edits Records edits for index mapping, working with styled text, * and getting only changes (if any). * The Edits contents is undefined if any error occurs. - * This function calls edits->reset() first. edits can be NULL. + * This function calls edits->reset() first unless + * options includes U_EDITS_NO_RESET. edits can be NULL. * @param errorCode Reference to an in/out error code value * which must not indicate a failure before the function call. * @return The length of the result string, if successful. @@ -216,9 +348,9 @@ public: * the full length is returned and a U_BUFFER_OVERFLOW_ERROR is set. * * @see ucasemap_utf8ToLower - * @draft ICU 59 + * @stable ICU 59 */ - static int32_t utf8ToLower( + static int32_t utf8ToLower( const char *locale, uint32_t options, const char *src, int32_t srcLength, char *dest, int32_t destCapacity, Edits *edits, @@ -231,7 +363,7 @@ public: * The source string and the destination buffer must not overlap. * * @param locale The locale ID. ("" = root locale, NULL = default locale.) - * @param options Options bit set, usually 0. See UCASEMAP_OMIT_UNCHANGED_TEXT. + * @param options Options bit set, usually 0. See U_OMIT_UNCHANGED_TEXT and U_EDITS_NO_RESET. * @param src The original string. * @param srcLength The length of the original string. If -1, then src must be NUL-terminated. * @param dest A buffer for the result string. The result will be NUL-terminated if @@ -243,7 +375,8 @@ public: * @param edits Records edits for index mapping, working with styled text, * and getting only changes (if any). * The Edits contents is undefined if any error occurs. - * This function calls edits->reset() first. edits can be NULL. + * This function calls edits->reset() first unless + * options includes U_EDITS_NO_RESET. edits can be NULL. * @param errorCode Reference to an in/out error code value * which must not indicate a failure before the function call. * @return The length of the result string, if successful. @@ -251,7 +384,7 @@ public: * the full length is returned and a U_BUFFER_OVERFLOW_ERROR is set. * * @see ucasemap_utf8ToUpper - * @draft ICU 59 + * @stable ICU 59 */ static int32_t utf8ToUpper( const char *locale, uint32_t options, @@ -272,10 +405,12 @@ public: * all others. (This can be modified with options bits.) * * @param locale The locale ID. ("" = root locale, NULL = default locale.) - * @param options Options bit set, usually 0. See UCASEMAP_OMIT_UNCHANGED_TEXT, - * U_TITLECASE_NO_LOWERCASE, U_TITLECASE_NO_BREAK_ADJUSTMENT. + * @param options Options bit set, usually 0. See U_OMIT_UNCHANGED_TEXT, U_EDITS_NO_RESET, + * U_TITLECASE_NO_LOWERCASE, + * U_TITLECASE_NO_BREAK_ADJUSTMENT, U_TITLECASE_ADJUST_TO_CASED, + * U_TITLECASE_WHOLE_STRING, U_TITLECASE_SENTENCES. * @param iter A break iterator to find the first characters of words that are to be titlecased. - * It is set to the source string (setText()) + * It is set to the source string (setUText()) * and used one or more times for iteration (first() and next()). * If NULL, then a word break iterator for the locale is used * (or something equivalent). @@ -290,7 +425,8 @@ public: * @param edits Records edits for index mapping, working with styled text, * and getting only changes (if any). * The Edits contents is undefined if any error occurs. - * This function calls edits->reset() first. edits can be NULL. + * This function calls edits->reset() first unless + * options includes U_EDITS_NO_RESET. edits can be NULL. * @param errorCode Reference to an in/out error code value * which must not indicate a failure before the function call. * @return The length of the result string, if successful. @@ -298,7 +434,7 @@ public: * the full length is returned and a U_BUFFER_OVERFLOW_ERROR is set. * * @see ucasemap_utf8ToTitle - * @draft ICU 59 + * @stable ICU 59 */ static int32_t utf8ToTitle( const char *locale, uint32_t options, BreakIterator *iter, @@ -318,7 +454,7 @@ public: * The result may be longer or shorter than the original. * The source string and the destination buffer must not overlap. * - * @param options Options bit set, usually 0. See UCASEMAP_OMIT_UNCHANGED_TEXT, + * @param options Options bit set, usually 0. See U_OMIT_UNCHANGED_TEXT, U_EDITS_NO_RESET, * U_FOLD_CASE_DEFAULT, U_FOLD_CASE_EXCLUDE_SPECIAL_I. * @param src The original string. * @param srcLength The length of the original string. If -1, then src must be NUL-terminated. @@ -331,7 +467,8 @@ public: * @param edits Records edits for index mapping, working with styled text, * and getting only changes (if any). * The Edits contents is undefined if any error occurs. - * This function calls edits->reset() first. edits can be NULL. + * This function calls edits->reset() first unless + * options includes U_EDITS_NO_RESET. edits can be NULL. * @param errorCode Reference to an in/out error code value * which must not indicate a failure before the function call. * @return The length of the result string, if successful. @@ -339,7 +476,7 @@ public: * the full length is returned and a U_BUFFER_OVERFLOW_ERROR is set. * * @see ucasemap_utf8FoldCase - * @draft ICU 59 + * @stable ICU 59 */ static int32_t utf8Fold( uint32_t options, @@ -353,8 +490,6 @@ private: CaseMap &operator=(const CaseMap &other) = delete; }; -#endif // U_HIDE_DRAFT_API - U_NAMESPACE_END #endif // U_SHOW_CPLUSPLUS_API