sl@0: /*  
sl@0: **********************************************************************
sl@0: *   Copyright (C) 1999-2005, International Business Machines
sl@0: *   Corporation and others.  All Rights Reserved.
sl@0: **********************************************************************
sl@0: *   file name:  ustr_imp.h
sl@0: *   encoding:   US-ASCII
sl@0: *   tab size:   8 (not used)
sl@0: *   indentation:4
sl@0: *
sl@0: *   created on: 2001jan30
sl@0: *   created by: Markus W. Scherer
sl@0: */
sl@0: 
sl@0: #ifndef __USTR_IMP_H__
sl@0: #define __USTR_IMP_H__
sl@0: 
sl@0: #include "unicode/utypes.h"
sl@0: #include "unicode/uiter.h"
sl@0: #include "ucase.h"
sl@0: 
sl@0: /** Simple declaration for u_strToTitle() to avoid including unicode/ubrk.h. */
sl@0: #ifndef UBRK_TYPEDEF_UBREAK_ITERATOR
sl@0: #   define UBRK_TYPEDEF_UBREAK_ITERATOR
sl@0:     typedef void UBreakIterator;
sl@0: #endif
sl@0: 
sl@0: /**
sl@0:  * Compare two strings in code point order or code unit order.
sl@0:  * Works in strcmp style (both lengths -1),
sl@0:  * strncmp style (lengths equal and >=0, flag TRUE),
sl@0:  * and memcmp/UnicodeString style (at least one length >=0).
sl@0:  * @internal
sl@0:  */
sl@0: U_CAPI int32_t U_EXPORT2
sl@0: uprv_strCompare(const UChar *s1, int32_t length1,
sl@0:                 const UChar *s2, int32_t length2,
sl@0:                 UBool strncmpStyle, UBool codePointOrder);
sl@0: 
sl@0: /**
sl@0:  * Internal API, used by u_strcasecmp() etc.
sl@0:  * Compare strings case-insensitively,
sl@0:  * in code point order or code unit order.
sl@0:  * @internal
sl@0:  */
sl@0: U_CFUNC int32_t
sl@0: u_strcmpFold(const UChar *s1, int32_t length1,
sl@0:              const UChar *s2, int32_t length2,
sl@0:              uint32_t options,
sl@0:              UErrorCode *pErrorCode);
sl@0: 
sl@0: /**
sl@0:  * Are the Unicode properties loaded?
sl@0:  * This must be used before internal functions are called that do
sl@0:  * not perform this check.
sl@0:  * Generate a debug assertion failure if data is not loaded, to flag the fact
sl@0:  *   that u_init() wasn't called first, before trying to access character properties.
sl@0:  * @internal
sl@0:  */
sl@0: U_CFUNC UBool
sl@0: uprv_haveProperties(UErrorCode *pErrorCode);
sl@0: 
sl@0: /**
sl@0:   * Load the Unicode property data.
sl@0:   * Intended primarily for use from u_init().
sl@0:   * Has no effect if property data is already loaded.
sl@0:   * NOT thread safe.
sl@0:   * @internal
sl@0:   */
sl@0: U_CFUNC int8_t
sl@0: uprv_loadPropsData(UErrorCode *errorCode);
sl@0: 
sl@0: /**
sl@0:  * Type of a function that may be passed to the internal case mapping functions
sl@0:  * or similar for growing the destination buffer.
sl@0:  * @internal
sl@0:  */
sl@0: typedef UBool U_CALLCONV
sl@0: UGrowBuffer(void *context,      /* opaque pointer for this function */
sl@0:             UChar **pBuffer,    /* in/out destination buffer pointer */
sl@0:             int32_t *pCapacity, /* in/out buffer capacity in numbers of UChars */
sl@0:             int32_t reqCapacity,/* requested capacity */
sl@0:             int32_t length);    /* number of UChars to be copied to new buffer */
sl@0: 
sl@0: /**
sl@0:  * Default implementation of UGrowBuffer.
sl@0:  * Takes a static buffer as context, allocates a new buffer,
sl@0:  * and releases the old one if it is not the same as the one passed as context.
sl@0:  * @internal
sl@0:  */
sl@0: U_CAPI UBool /* U_CALLCONV U_EXPORT2 */
sl@0: u_growBufferFromStatic(void *context,
sl@0:                        UChar **pBuffer, int32_t *pCapacity, int32_t reqCapacity,
sl@0:                        int32_t length);
sl@0: 
sl@0: /*
sl@0:  * Internal string casing functions implementing
sl@0:  * ustring.h/ustrcase.c and UnicodeString case mapping functions.
sl@0:  */
sl@0: 
sl@0: /**
sl@0:  * @internal
sl@0:  */
sl@0: U_CFUNC int32_t
sl@0: ustr_toLower(const UCaseProps *csp,
sl@0:              UChar *dest, int32_t destCapacity,
sl@0:              const UChar *src, int32_t srcLength,
sl@0:              const char *locale,
sl@0:              UErrorCode *pErrorCode);
sl@0: 
sl@0: /**
sl@0:  * @internal
sl@0:  */
sl@0: U_CFUNC int32_t
sl@0: ustr_toUpper(const UCaseProps *csp,
sl@0:              UChar *dest, int32_t destCapacity,
sl@0:              const UChar *src, int32_t srcLength,
sl@0:              const char *locale,
sl@0:              UErrorCode *pErrorCode);
sl@0: 
sl@0: #if !UCONFIG_NO_BREAK_ITERATION
sl@0: 
sl@0: /**
sl@0:  * @internal
sl@0:  */
sl@0: U_CFUNC int32_t
sl@0: ustr_toTitle(const UCaseProps *csp,
sl@0:              UChar *dest, int32_t destCapacity,
sl@0:              const UChar *src, int32_t srcLength,
sl@0:              UBreakIterator *titleIter,
sl@0:              const char *locale,
sl@0:              UErrorCode *pErrorCode);
sl@0: 
sl@0: #endif
sl@0: 
sl@0: /**
sl@0:  * Internal case folding function.
sl@0:  * @internal
sl@0:  */
sl@0: U_CFUNC int32_t
sl@0: ustr_foldCase(const UCaseProps *csp,
sl@0:               UChar *dest, int32_t destCapacity,
sl@0:               const UChar *src, int32_t srcLength,
sl@0:               uint32_t options,
sl@0:               UErrorCode *pErrorCode);
sl@0: 
sl@0: /**
sl@0:  * NUL-terminate a UChar * string if possible.
sl@0:  * If length  < destCapacity then NUL-terminate.
sl@0:  * If length == destCapacity then do not terminate but set U_STRING_NOT_TERMINATED_WARNING.
sl@0:  * If length  > destCapacity then do not terminate but set U_BUFFER_OVERFLOW_ERROR.
sl@0:  *
sl@0:  * @param dest Destination buffer, can be NULL if destCapacity==0.
sl@0:  * @param destCapacity Number of UChars available at dest.
sl@0:  * @param length Number of UChars that were (to be) written to dest.
sl@0:  * @param pErrorCode ICU error code.
sl@0:  * @return length
sl@0:  * @internal
sl@0:  */
sl@0: U_CAPI int32_t U_EXPORT2
sl@0: u_terminateUChars(UChar *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
sl@0: 
sl@0: /**
sl@0:  * NUL-terminate a char * string if possible.
sl@0:  * Same as u_terminateUChars() but for a different string type.
sl@0:  */
sl@0: U_CAPI int32_t U_EXPORT2
sl@0: u_terminateChars(char *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
sl@0: 
sl@0: /**
sl@0:  * NUL-terminate a UChar32 * string if possible.
sl@0:  * Same as u_terminateUChars() but for a different string type.
sl@0:  */
sl@0: U_CAPI int32_t U_EXPORT2
sl@0: u_terminateUChar32s(UChar32 *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
sl@0: 
sl@0: /**
sl@0:  * NUL-terminate a wchar_t * string if possible.
sl@0:  * Same as u_terminateUChars() but for a different string type.
sl@0:  */
sl@0: U_CAPI int32_t U_EXPORT2
sl@0: u_terminateWChars(wchar_t *dest, int32_t destCapacity, int32_t length, UErrorCode *pErrorCode);
sl@0: 
sl@0: #endif