ICU 64.2
64.2
|
C API: String Enumeration. More...
Go to the source code of this file.
Namespaces | |
icu | |
File coll.h. | |
Typedefs | |
typedef struct UEnumeration | UEnumeration |
structure representing an enumeration object instance More... | |
Functions | |
void | uenum_close (UEnumeration *en) |
Disposes of resources in use by the iterator. More... | |
int32_t | uenum_count (UEnumeration *en, UErrorCode *status) |
Returns the number of elements that the iterator traverses. More... | |
const UChar * | uenum_unext (UEnumeration *en, int32_t *resultLength, UErrorCode *status) |
Returns the next element in the iterator's list. More... | |
const char * | uenum_next (UEnumeration *en, int32_t *resultLength, UErrorCode *status) |
Returns the next element in the iterator's list. More... | |
void | uenum_reset (UEnumeration *en, UErrorCode *status) |
Resets the iterator to the current list of service IDs. More... | |
UEnumeration * | uenum_openFromStringEnumeration (icu::StringEnumeration *adopted, UErrorCode *ec) |
Given a StringEnumeration, wrap it in a UEnumeration. More... | |
UEnumeration * | uenum_openUCharStringsEnumeration (const UChar *const strings[], int32_t count, UErrorCode *ec) |
Given an array of const UChar* strings, return a UEnumeration. More... | |
UEnumeration * | uenum_openCharStringsEnumeration (const char *const strings[], int32_t count, UErrorCode *ec) |
Given an array of const char* strings (invariant chars only), return a UEnumeration. More... | |
C API: String Enumeration.
Definition in file uenum.h.
typedef struct UEnumeration UEnumeration |
void uenum_close | ( | UEnumeration * | en | ) |
Disposes of resources in use by the iterator.
If en is NULL, does nothing. After this call, any char* or UChar* pointer returned by uenum_unext() or uenum_next() is invalid.
en | UEnumeration structure pointer |
int32_t uenum_count | ( | UEnumeration * | en, |
UErrorCode * | status | ||
) |
Returns the number of elements that the iterator traverses.
If the iterator is out-of-sync with its service, status is set to U_ENUM_OUT_OF_SYNC_ERROR. This is a convenience function. It can end up being very expensive as all the items might have to be pre-fetched (depending on the type of data being traversed). Use with caution and only when necessary.
en | UEnumeration structure pointer |
status | error code, can be U_ENUM_OUT_OF_SYNC_ERROR if the iterator is out of sync. |
const char* uenum_next | ( | UEnumeration * | en, |
int32_t * | resultLength, | ||
UErrorCode * | status | ||
) |
Returns the next element in the iterator's list.
If there are no more elements, returns NULL. If the iterator is out-of-sync with its service, status is set to U_ENUM_OUT_OF_SYNC_ERROR and NULL is returned. If the native service string is a UChar* string, it is converted to char* with the invariant converter. The result is terminated by (char)0. If the conversion fails (because a character cannot be converted) then status is set to U_INVARIANT_CONVERSION_ERROR and the return value is undefined (but non-NULL).
en | the iterator object |
resultLength | pointer to receive the length of the result (not including the terminating \0). If the pointer is NULL it is ignored. |
status | the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if the iterator is out of sync with its service. Set to U_INVARIANT_CONVERSION_ERROR if the underlying native string is UChar* and conversion to char* with the invariant converter fails. This error pertains only to current string, so iteration might be able to continue successfully. |
UEnumeration* uenum_openCharStringsEnumeration | ( | const char *const | strings[], |
int32_t | count, | ||
UErrorCode * | ec | ||
) |
Given an array of const char* strings (invariant chars only), return a UEnumeration.
String pointers from 0..count-1 must not be null. Do not free or modify either the string array or the characters it points to until this object has been destroyed with uenum_close.
strings | array of char* strings (each null terminated). All storage is owned by the caller. |
count | length of the array |
ec | error code |
UEnumeration* uenum_openFromStringEnumeration | ( | icu::StringEnumeration * | adopted, |
UErrorCode * | ec | ||
) |
Given a StringEnumeration, wrap it in a UEnumeration.
The StringEnumeration is adopted; after this call, the caller must not delete it (regardless of error status).
adopted | the C++ StringEnumeration to be wrapped in a UEnumeration. |
ec | the error code. |
UEnumeration* uenum_openUCharStringsEnumeration | ( | const UChar *const | strings[], |
int32_t | count, | ||
UErrorCode * | ec | ||
) |
Given an array of const UChar* strings, return a UEnumeration.
String pointers from 0..count-1 must not be null. Do not free or modify either the string array or the characters it points to until this object has been destroyed with uenum_close.
strings | array of const UChar* strings (each null terminated). All storage is owned by the caller. |
count | length of the array |
ec | error code |
void uenum_reset | ( | UEnumeration * | en, |
UErrorCode * | status | ||
) |
Resets the iterator to the current list of service IDs.
This re-establishes sync with the service and rewinds the iterator to start at the first element.
en | the iterator object |
status | the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if the iterator is out of sync with its service. |
const UChar* uenum_unext | ( | UEnumeration * | en, |
int32_t * | resultLength, | ||
UErrorCode * | status | ||
) |
Returns the next element in the iterator's list.
If there are no more elements, returns NULL. If the iterator is out-of-sync with its service, status is set to U_ENUM_OUT_OF_SYNC_ERROR and NULL is returned. If the native service string is a char* string, it is converted to UChar* with the invariant converter. The result is terminated by (UChar)0.
en | the iterator object |
resultLength | pointer to receive the length of the result (not including the terminating \0). If the pointer is NULL it is ignored. |
status | the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if the iterator is out of sync with its service. |