fontservices/textshaperplugin/IcuSource/common/ustr_imp.h
changeset 0 1fb32624e06b
equal deleted inserted replaced
-1:000000000000 0:1fb32624e06b
       
     1 /*  
       
     2 **********************************************************************
       
     3 *   Copyright (C) 1999-2005, International Business Machines
       
     4 *   Corporation and others.  All Rights Reserved.
       
     5 **********************************************************************
       
     6 *   file name:  ustr_imp.h
       
     7 *   encoding:   US-ASCII
       
     8 *   tab size:   8 (not used)
       
     9 *   indentation:4
       
    10 *
       
    11 *   created on: 2001jan30
       
    12 *   created by: Markus W. Scherer
       
    13 */
       
    14 
       
    15 #ifndef __USTR_IMP_H__
       
    16 #define __USTR_IMP_H__
       
    17 
       
    18 #include "unicode/utypes.h"
       
    19 #include "unicode/uiter.h"
       
    20 #include "ucase.h"
       
    21 
       
    22 /** Simple declaration for u_strToTitle() to avoid including unicode/ubrk.h. */
       
    23 #ifndef UBRK_TYPEDEF_UBREAK_ITERATOR
       
    24 #   define UBRK_TYPEDEF_UBREAK_ITERATOR
       
    25     typedef void UBreakIterator;
       
    26 #endif
       
    27 
       
    28 /**
       
    29  * Compare two strings in code point order or code unit order.
       
    30  * Works in strcmp style (both lengths -1),
       
    31  * strncmp style (lengths equal and >=0, flag TRUE),
       
    32  * and memcmp/UnicodeString style (at least one length >=0).
       
    33  * @internal
       
    34  */
       
    35 U_CAPI int32_t U_EXPORT2
       
    36 uprv_strCompare(const UChar *s1, int32_t length1,
       
    37                 const UChar *s2, int32_t length2,
       
    38                 UBool strncmpStyle, UBool codePointOrder);
       
    39 
       
    40 /**
       
    41  * Internal API, used by u_strcasecmp() etc.
       
    42  * Compare strings case-insensitively,
       
    43  * in code point order or code unit order.
       
    44  * @internal
       
    45  */
       
    46 U_CFUNC int32_t
       
    47 u_strcmpFold(const UChar *s1, int32_t length1,
       
    48              const UChar *s2, int32_t length2,
       
    49              uint32_t options,
       
    50              UErrorCode *pErrorCode);
       
    51 
       
    52 /**
       
    53  * Are the Unicode properties loaded?
       
    54  * This must be used before internal functions are called that do
       
    55  * not perform this check.
       
    56  * Generate a debug assertion failure if data is not loaded, to flag the fact
       
    57  *   that u_init() wasn't called first, before trying to access character properties.
       
    58  * @internal
       
    59  */
       
    60 U_CFUNC UBool
       
    61 uprv_haveProperties(UErrorCode *pErrorCode);
       
    62 
       
    63 /**
       
    64   * Load the Unicode property data.
       
    65   * Intended primarily for use from u_init().
       
    66   * Has no effect if property data is already loaded.
       
    67   * NOT thread safe.
       
    68   * @internal
       
    69   */
       
    70 U_CFUNC int8_t
       
    71 uprv_loadPropsData(UErrorCode *errorCode);
       
    72 
       
    73 /**
       
    74  * Type of a function that may be passed to the internal case mapping functions
       
    75  * or similar for growing the destination buffer.
       
    76  * @internal
       
    77  */
       
    78 typedef UBool U_CALLCONV
       
    79 UGrowBuffer(void *context,      /* opaque pointer for this function */
       
    80             UChar **pBuffer,    /* in/out destination buffer pointer */
       
    81             int32_t *pCapacity, /* in/out buffer capacity in numbers of UChars */
       
    82             int32_t reqCapacity,/* requested capacity */
       
    83             int32_t length);    /* number of UChars to be copied to new buffer */
       
    84 
       
    85 /**
       
    86  * Default implementation of UGrowBuffer.
       
    87  * Takes a static buffer as context, allocates a new buffer,
       
    88  * and releases the old one if it is not the same as the one passed as context.
       
    89  * @internal
       
    90  */
       
    91 U_CAPI UBool /* U_CALLCONV U_EXPORT2 */
       
    92 u_growBufferFromStatic(void *context,
       
    93                        UChar **pBuffer, int32_t *pCapacity, int32_t reqCapacity,
       
    94                        int32_t length);
       
    95 
       
    96 /*
       
    97  * Internal string casing functions implementing
       
    98  * ustring.h/ustrcase.c and UnicodeString case mapping functions.
       
    99  */
       
   100 
       
   101 /**
       
   102  * @internal
       
   103  */
       
   104 U_CFUNC int32_t
       
   105 ustr_toLower(const UCaseProps *csp,
       
   106              UChar *dest, int32_t destCapacity,
       
   107              const UChar *src, int32_t srcLength,
       
   108              const char *locale,
       
   109              UErrorCode *pErrorCode);
       
   110 
       
   111 /**
       
   112  * @internal
       
   113  */
       
   114 U_CFUNC int32_t
       
   115 ustr_toUpper(const UCaseProps *csp,
       
   116              UChar *dest, int32_t destCapacity,
       
   117              const UChar *src, int32_t srcLength,
       
   118              const char *locale,
       
   119              UErrorCode *pErrorCode);
       
   120 
       
   121 #if !UCONFIG_NO_BREAK_ITERATION
       
   122 
       
   123 /**
       
   124  * @internal
       
   125  */
       
   126 U_CFUNC int32_t
       
   127 ustr_toTitle(const UCaseProps *csp,
       
   128              UChar *dest, int32_t destCapacity,
       
   129              const UChar *src, int32_t srcLength,
       
   130              UBreakIterator *titleIter,
       
   131              const char *locale,
       
   132              UErrorCode *pErrorCode);
       
   133 
       
   134 #endif
       
   135 
       
   136 /**
       
   137  * Internal case folding function.
       
   138  * @internal
       
   139  */
       
   140 U_CFUNC int32_t
       
   141 ustr_foldCase(const UCaseProps *csp,
       
   142               UChar *dest, int32_t destCapacity,
       
   143               const UChar *src, int32_t srcLength,
       
   144               uint32_t options,
       
   145               UErrorCode *pErrorCode);
       
   146 
       
   147 /**
       
   148  * NUL-terminate a UChar * string if possible.
       
   149  * If length  < destCapacity then NUL-terminate.
       
   150  * If length == destCapacity then do not terminate but set U_STRING_NOT_TERMINATED_WARNING.
       
   151  * If length  > destCapacity then do not terminate but set U_BUFFER_OVERFLOW_ERROR.
       
   152  *
       
   153  * @param dest Destination buffer, can be NULL if destCapacity==0.
       
   154  * @param destCapacity Number of UChars available at dest.
       
   155  * @param length Number of UChars that were (to be) written to dest.
       
   156  * @param pErrorCode ICU error code.
       
   157  * @return length
       
   158  * @internal
       
   159  */
       
   160 U_CAPI int32_t U_EXPORT2
       
   161 u_terminateUChars(UChar *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
       
   162 
       
   163 /**
       
   164  * NUL-terminate a char * string if possible.
       
   165  * Same as u_terminateUChars() but for a different string type.
       
   166  */
       
   167 U_CAPI int32_t U_EXPORT2
       
   168 u_terminateChars(char *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
       
   169 
       
   170 /**
       
   171  * NUL-terminate a UChar32 * string if possible.
       
   172  * Same as u_terminateUChars() but for a different string type.
       
   173  */
       
   174 U_CAPI int32_t U_EXPORT2
       
   175 u_terminateUChar32s(UChar32 *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
       
   176 
       
   177 /**
       
   178  * NUL-terminate a wchar_t * string if possible.
       
   179  * Same as u_terminateUChars() but for a different string type.
       
   180  */
       
   181 U_CAPI int32_t U_EXPORT2
       
   182 u_terminateWChars(wchar_t *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
       
   183 
       
   184 #endif