Logo Search packages:      
Sourcecode: icu version File versions  Download package

const char * StringEnumeration::next ( int32_t *  resultLength,
UErrorCode status 
) [virtual, inherited]

Returns the next element as a NUL-terminated char*. If there are no more elements, returns NULL. If the resultLength pointer is not NULL, the length of the string (not counting the terminating NUL) is returned at that address. If an error status is returned, the value at resultLength is undefined.

The returned pointer is owned by this iterator and must not be deleted by the caller. The pointer is valid until the next call to next, unext, snext, reset, or the enumerator's destructor.

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. 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 (though not NULL).

Starting with ICU 2.8, the default implementation calls snext() and handles the conversion.

status the error code.
resultLength a pointer to receive the length, can be NULL.
a pointer to the string, or NULL.
ICU 2.4

Definition at line 40 of file ustrenum.cpp.

References StringEnumeration::chars, StringEnumeration::charsCapacity, StringEnumeration::ensureCharsCapacity(), UnicodeString::extract(), INT32_MAX, UnicodeString::length(), NULL, StringEnumeration::snext(), U_SUCCESS, StringEnumeration::unistr, and US_INV.

Referenced by CollationAPITest::TestGetAll(), and TimeZoneTest::TestGetAvailableIDs913().

    const UnicodeString *s=snext(status);
    if(s!=NULL) {
        ensureCharsCapacity(unistr.length()+1, status);
        if(U_SUCCESS(status)) {
            if(resultLength!=NULL) {
            unistr.extract(0, INT32_MAX, chars, charsCapacity, US_INV);
            return chars;

    return NULL;

Generated by  Doxygen 1.6.0   Back to index