1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others. 2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html 3*0e209d39SAndroid Build Coastguard Worker /* 4*0e209d39SAndroid Build Coastguard Worker ******************************************************************************* 5*0e209d39SAndroid Build Coastguard Worker * 6*0e209d39SAndroid Build Coastguard Worker * Copyright (C) 2002-2013, International Business Machines 7*0e209d39SAndroid Build Coastguard Worker * Corporation and others. All Rights Reserved. 8*0e209d39SAndroid Build Coastguard Worker * 9*0e209d39SAndroid Build Coastguard Worker ******************************************************************************* 10*0e209d39SAndroid Build Coastguard Worker * file name: uenum.h 11*0e209d39SAndroid Build Coastguard Worker * encoding: UTF-8 12*0e209d39SAndroid Build Coastguard Worker * tab size: 8 (not used) 13*0e209d39SAndroid Build Coastguard Worker * indentation:2 14*0e209d39SAndroid Build Coastguard Worker * 15*0e209d39SAndroid Build Coastguard Worker * created on: 2002jul08 16*0e209d39SAndroid Build Coastguard Worker * created by: Vladimir Weinstein 17*0e209d39SAndroid Build Coastguard Worker */ 18*0e209d39SAndroid Build Coastguard Worker 19*0e209d39SAndroid Build Coastguard Worker #ifndef __UENUM_H 20*0e209d39SAndroid Build Coastguard Worker #define __UENUM_H 21*0e209d39SAndroid Build Coastguard Worker 22*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 23*0e209d39SAndroid Build Coastguard Worker 24*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 25*0e209d39SAndroid Build Coastguard Worker #include "unicode/localpointer.h" 26*0e209d39SAndroid Build Coastguard Worker 27*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN 28*0e209d39SAndroid Build Coastguard Worker class StringEnumeration; 29*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 30*0e209d39SAndroid Build Coastguard Worker #endif // U_SHOW_CPLUSPLUS_API 31*0e209d39SAndroid Build Coastguard Worker 32*0e209d39SAndroid Build Coastguard Worker /** 33*0e209d39SAndroid Build Coastguard Worker * @addtogroup icu4c ICU4C 34*0e209d39SAndroid Build Coastguard Worker * @{ 35*0e209d39SAndroid Build Coastguard Worker * \file 36*0e209d39SAndroid Build Coastguard Worker * \brief C API: String Enumeration 37*0e209d39SAndroid Build Coastguard Worker */ 38*0e209d39SAndroid Build Coastguard Worker 39*0e209d39SAndroid Build Coastguard Worker /** 40*0e209d39SAndroid Build Coastguard Worker * An enumeration object. 41*0e209d39SAndroid Build Coastguard Worker * For usage in C programs. 42*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.2 43*0e209d39SAndroid Build Coastguard Worker */ 44*0e209d39SAndroid Build Coastguard Worker struct UEnumeration; 45*0e209d39SAndroid Build Coastguard Worker /** structure representing an enumeration object instance \xrefitem stable "Stable" "Stable List" ICU 2.2 */ 46*0e209d39SAndroid Build Coastguard Worker typedef struct UEnumeration UEnumeration; 47*0e209d39SAndroid Build Coastguard Worker 48*0e209d39SAndroid Build Coastguard Worker /** 49*0e209d39SAndroid Build Coastguard Worker * Disposes of resources in use by the iterator. If en is NULL, 50*0e209d39SAndroid Build Coastguard Worker * does nothing. After this call, any char* or UChar* pointer 51*0e209d39SAndroid Build Coastguard Worker * returned by uenum_unext() or uenum_next() is invalid. 52*0e209d39SAndroid Build Coastguard Worker * @param en UEnumeration structure pointer 53*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.2 54*0e209d39SAndroid Build Coastguard Worker */ 55*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 56*0e209d39SAndroid Build Coastguard Worker uenum_close(UEnumeration* en) __INTRODUCED_IN(31); 57*0e209d39SAndroid Build Coastguard Worker 58*0e209d39SAndroid Build Coastguard Worker 59*0e209d39SAndroid Build Coastguard Worker 60*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 61*0e209d39SAndroid Build Coastguard Worker 62*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN 63*0e209d39SAndroid Build Coastguard Worker 64*0e209d39SAndroid Build Coastguard Worker /** 65*0e209d39SAndroid Build Coastguard Worker * \class LocalUEnumerationPointer 66*0e209d39SAndroid Build Coastguard Worker * "Smart pointer" class, closes a UEnumeration via uenum_close(). 67*0e209d39SAndroid Build Coastguard Worker * For most methods see the LocalPointerBase base class. 68*0e209d39SAndroid Build Coastguard Worker * 69*0e209d39SAndroid Build Coastguard Worker * @see LocalPointerBase 70*0e209d39SAndroid Build Coastguard Worker * @see LocalPointer 71*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 4.4 72*0e209d39SAndroid Build Coastguard Worker */ 73*0e209d39SAndroid Build Coastguard Worker U_DEFINE_LOCAL_OPEN_POINTER(LocalUEnumerationPointer, UEnumeration, uenum_close); 74*0e209d39SAndroid Build Coastguard Worker 75*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 76*0e209d39SAndroid Build Coastguard Worker 77*0e209d39SAndroid Build Coastguard Worker #endif 78*0e209d39SAndroid Build Coastguard Worker 79*0e209d39SAndroid Build Coastguard Worker /** 80*0e209d39SAndroid Build Coastguard Worker * Returns the number of elements that the iterator traverses. If 81*0e209d39SAndroid Build Coastguard Worker * the iterator is out-of-sync with its service, status is set to 82*0e209d39SAndroid Build Coastguard Worker * U_ENUM_OUT_OF_SYNC_ERROR. 83*0e209d39SAndroid Build Coastguard Worker * This is a convenience function. It can end up being very 84*0e209d39SAndroid Build Coastguard Worker * expensive as all the items might have to be pre-fetched (depending 85*0e209d39SAndroid Build Coastguard Worker * on the type of data being traversed). Use with caution and only 86*0e209d39SAndroid Build Coastguard Worker * when necessary. 87*0e209d39SAndroid Build Coastguard Worker * @param en UEnumeration structure pointer 88*0e209d39SAndroid Build Coastguard Worker * @param status error code, can be U_ENUM_OUT_OF_SYNC_ERROR if the 89*0e209d39SAndroid Build Coastguard Worker * iterator is out of sync. 90*0e209d39SAndroid Build Coastguard Worker * @return number of elements in the iterator 91*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.2 92*0e209d39SAndroid Build Coastguard Worker */ 93*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 94*0e209d39SAndroid Build Coastguard Worker uenum_count(UEnumeration* en, UErrorCode* status) __INTRODUCED_IN(31); 95*0e209d39SAndroid Build Coastguard Worker 96*0e209d39SAndroid Build Coastguard Worker 97*0e209d39SAndroid Build Coastguard Worker 98*0e209d39SAndroid Build Coastguard Worker /** 99*0e209d39SAndroid Build Coastguard Worker * Returns the next element in the iterator's list. If there are 100*0e209d39SAndroid Build Coastguard Worker * no more elements, returns NULL. If the iterator is out-of-sync 101*0e209d39SAndroid Build Coastguard Worker * with its service, status is set to U_ENUM_OUT_OF_SYNC_ERROR and 102*0e209d39SAndroid Build Coastguard Worker * NULL is returned. If the native service string is a char* string, 103*0e209d39SAndroid Build Coastguard Worker * it is converted to UChar* with the invariant converter. 104*0e209d39SAndroid Build Coastguard Worker * The result is terminated by (UChar)0. 105*0e209d39SAndroid Build Coastguard Worker * @param en the iterator object 106*0e209d39SAndroid Build Coastguard Worker * @param resultLength pointer to receive the length of the result 107*0e209d39SAndroid Build Coastguard Worker * (not including the terminating \\0). 108*0e209d39SAndroid Build Coastguard Worker * If the pointer is NULL it is ignored. 109*0e209d39SAndroid Build Coastguard Worker * @param status the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if 110*0e209d39SAndroid Build Coastguard Worker * the iterator is out of sync with its service. 111*0e209d39SAndroid Build Coastguard Worker * @return a pointer to the string. The string will be 112*0e209d39SAndroid Build Coastguard Worker * zero-terminated. The return pointer is owned by this iterator 113*0e209d39SAndroid Build Coastguard Worker * and must not be deleted by the caller. The pointer is valid 114*0e209d39SAndroid Build Coastguard Worker * until the next call to any uenum_... method, including 115*0e209d39SAndroid Build Coastguard Worker * uenum_next() or uenum_unext(). When all strings have been 116*0e209d39SAndroid Build Coastguard Worker * traversed, returns NULL. 117*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.2 118*0e209d39SAndroid Build Coastguard Worker */ 119*0e209d39SAndroid Build Coastguard Worker U_CAPI const UChar* U_EXPORT2 120*0e209d39SAndroid Build Coastguard Worker uenum_unext(UEnumeration* en, 121*0e209d39SAndroid Build Coastguard Worker int32_t* resultLength, 122*0e209d39SAndroid Build Coastguard Worker UErrorCode* status) __INTRODUCED_IN(31); 123*0e209d39SAndroid Build Coastguard Worker 124*0e209d39SAndroid Build Coastguard Worker 125*0e209d39SAndroid Build Coastguard Worker 126*0e209d39SAndroid Build Coastguard Worker /** 127*0e209d39SAndroid Build Coastguard Worker * Returns the next element in the iterator's list. If there are 128*0e209d39SAndroid Build Coastguard Worker * no more elements, returns NULL. If the iterator is out-of-sync 129*0e209d39SAndroid Build Coastguard Worker * with its service, status is set to U_ENUM_OUT_OF_SYNC_ERROR and 130*0e209d39SAndroid Build Coastguard Worker * NULL is returned. If the native service string is a UChar* 131*0e209d39SAndroid Build Coastguard Worker * string, it is converted to char* with the invariant converter. 132*0e209d39SAndroid Build Coastguard Worker * The result is terminated by (char)0. If the conversion fails 133*0e209d39SAndroid Build Coastguard Worker * (because a character cannot be converted) then status is set to 134*0e209d39SAndroid Build Coastguard Worker * U_INVARIANT_CONVERSION_ERROR and the return value is undefined 135*0e209d39SAndroid Build Coastguard Worker * (but non-NULL). 136*0e209d39SAndroid Build Coastguard Worker * @param en the iterator object 137*0e209d39SAndroid Build Coastguard Worker * @param resultLength pointer to receive the length of the result 138*0e209d39SAndroid Build Coastguard Worker * (not including the terminating \\0). 139*0e209d39SAndroid Build Coastguard Worker * If the pointer is NULL it is ignored. 140*0e209d39SAndroid Build Coastguard Worker * @param status the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if 141*0e209d39SAndroid Build Coastguard Worker * the iterator is out of sync with its service. Set to 142*0e209d39SAndroid Build Coastguard Worker * U_INVARIANT_CONVERSION_ERROR if the underlying native string is 143*0e209d39SAndroid Build Coastguard Worker * UChar* and conversion to char* with the invariant converter 144*0e209d39SAndroid Build Coastguard Worker * fails. This error pertains only to current string, so iteration 145*0e209d39SAndroid Build Coastguard Worker * might be able to continue successfully. 146*0e209d39SAndroid Build Coastguard Worker * @return a pointer to the string. The string will be 147*0e209d39SAndroid Build Coastguard Worker * zero-terminated. The return pointer is owned by this iterator 148*0e209d39SAndroid Build Coastguard Worker * and must not be deleted by the caller. The pointer is valid 149*0e209d39SAndroid Build Coastguard Worker * until the next call to any uenum_... method, including 150*0e209d39SAndroid Build Coastguard Worker * uenum_next() or uenum_unext(). When all strings have been 151*0e209d39SAndroid Build Coastguard Worker * traversed, returns NULL. 152*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.2 153*0e209d39SAndroid Build Coastguard Worker */ 154*0e209d39SAndroid Build Coastguard Worker U_CAPI const char* U_EXPORT2 155*0e209d39SAndroid Build Coastguard Worker uenum_next(UEnumeration* en, 156*0e209d39SAndroid Build Coastguard Worker int32_t* resultLength, 157*0e209d39SAndroid Build Coastguard Worker UErrorCode* status) __INTRODUCED_IN(31); 158*0e209d39SAndroid Build Coastguard Worker 159*0e209d39SAndroid Build Coastguard Worker 160*0e209d39SAndroid Build Coastguard Worker 161*0e209d39SAndroid Build Coastguard Worker /** 162*0e209d39SAndroid Build Coastguard Worker * Resets the iterator to the current list of service IDs. This 163*0e209d39SAndroid Build Coastguard Worker * re-establishes sync with the service and rewinds the iterator 164*0e209d39SAndroid Build Coastguard Worker * to start at the first element. 165*0e209d39SAndroid Build Coastguard Worker * @param en the iterator object 166*0e209d39SAndroid Build Coastguard Worker * @param status the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if 167*0e209d39SAndroid Build Coastguard Worker * the iterator is out of sync with its service. 168*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.2 169*0e209d39SAndroid Build Coastguard Worker */ 170*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 171*0e209d39SAndroid Build Coastguard Worker uenum_reset(UEnumeration* en, UErrorCode* status) __INTRODUCED_IN(31); 172*0e209d39SAndroid Build Coastguard Worker 173*0e209d39SAndroid Build Coastguard Worker 174*0e209d39SAndroid Build Coastguard Worker 175*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 176*0e209d39SAndroid Build Coastguard Worker 177*0e209d39SAndroid Build Coastguard Worker 178*0e209d39SAndroid Build Coastguard Worker 179*0e209d39SAndroid Build Coastguard Worker #endif 180*0e209d39SAndroid Build Coastguard Worker 181*0e209d39SAndroid Build Coastguard Worker /** 182*0e209d39SAndroid Build Coastguard Worker * Given an array of const UChar* strings, return a UEnumeration. String pointers from 0..count-1 must not be null. 183*0e209d39SAndroid Build Coastguard Worker * Do not free or modify either the string array or the characters it points to until this object has been destroyed with uenum_close. 184*0e209d39SAndroid Build Coastguard Worker * \snippet test/cintltst/uenumtst.c uenum_openUCharStringsEnumeration 185*0e209d39SAndroid Build Coastguard Worker * @param strings array of const UChar* strings (each null terminated). All storage is owned by the caller. 186*0e209d39SAndroid Build Coastguard Worker * @param count length of the array 187*0e209d39SAndroid Build Coastguard Worker * @param ec error code 188*0e209d39SAndroid Build Coastguard Worker * @return the new UEnumeration object. Caller is responsible for calling uenum_close to free memory. 189*0e209d39SAndroid Build Coastguard Worker * @see uenum_close 190*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 50 191*0e209d39SAndroid Build Coastguard Worker */ 192*0e209d39SAndroid Build Coastguard Worker U_CAPI UEnumeration* U_EXPORT2 193*0e209d39SAndroid Build Coastguard Worker uenum_openUCharStringsEnumeration(const UChar* const strings[], int32_t count, 194*0e209d39SAndroid Build Coastguard Worker UErrorCode* ec) __INTRODUCED_IN(31); 195*0e209d39SAndroid Build Coastguard Worker 196*0e209d39SAndroid Build Coastguard Worker 197*0e209d39SAndroid Build Coastguard Worker 198*0e209d39SAndroid Build Coastguard Worker /** 199*0e209d39SAndroid Build Coastguard Worker * Given an array of const char* strings (invariant chars only), return a UEnumeration. String pointers from 0..count-1 must not be null. 200*0e209d39SAndroid Build Coastguard Worker * Do not free or modify either the string array or the characters it points to until this object has been destroyed with uenum_close. 201*0e209d39SAndroid Build Coastguard Worker * \snippet test/cintltst/uenumtst.c uenum_openCharStringsEnumeration 202*0e209d39SAndroid Build Coastguard Worker * @param strings array of char* strings (each null terminated). All storage is owned by the caller. 203*0e209d39SAndroid Build Coastguard Worker * @param count length of the array 204*0e209d39SAndroid Build Coastguard Worker * @param ec error code 205*0e209d39SAndroid Build Coastguard Worker * @return the new UEnumeration object. Caller is responsible for calling uenum_close to free memory 206*0e209d39SAndroid Build Coastguard Worker * @see uenum_close 207*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 50 208*0e209d39SAndroid Build Coastguard Worker */ 209*0e209d39SAndroid Build Coastguard Worker U_CAPI UEnumeration* U_EXPORT2 210*0e209d39SAndroid Build Coastguard Worker uenum_openCharStringsEnumeration(const char* const strings[], int32_t count, 211*0e209d39SAndroid Build Coastguard Worker UErrorCode* ec) __INTRODUCED_IN(31); 212*0e209d39SAndroid Build Coastguard Worker 213*0e209d39SAndroid Build Coastguard Worker 214*0e209d39SAndroid Build Coastguard Worker 215*0e209d39SAndroid Build Coastguard Worker #endif 216*0e209d39SAndroid Build Coastguard Worker 217*0e209d39SAndroid Build Coastguard Worker /** @} */ // addtogroup 218