2002-07-09 06:15:34 +00:00
|
|
|
/*
|
|
|
|
*******************************************************************************
|
|
|
|
*
|
2009-03-12 17:56:24 +00:00
|
|
|
* Copyright (C) 2002-2009, International Business Machines
|
2002-07-09 06:15:34 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
|
|
|
*******************************************************************************
|
|
|
|
* file name: uenum.h
|
|
|
|
* encoding: US-ASCII
|
|
|
|
* tab size: 8 (not used)
|
|
|
|
* indentation:2
|
|
|
|
*
|
|
|
|
* created on: 2002jul08
|
|
|
|
* created by: Vladimir Weinstein
|
|
|
|
*/
|
|
|
|
|
2002-12-12 00:27:50 +00:00
|
|
|
#ifndef __UENUM_H
|
|
|
|
#define __UENUM_H
|
|
|
|
|
2002-07-08 23:04:59 +00:00
|
|
|
#include "unicode/utypes.h"
|
2009-11-14 00:36:06 +00:00
|
|
|
#include "unicode/localpointer.h"
|
2002-07-08 23:04:59 +00:00
|
|
|
|
2009-12-17 07:13:28 +00:00
|
|
|
#if U_SHOW_CPLUSPLUS_API
|
2009-03-12 17:56:24 +00:00
|
|
|
#include "unicode/strenum.h"
|
|
|
|
#endif
|
|
|
|
|
2005-06-22 22:39:36 +00:00
|
|
|
/**
|
|
|
|
* \file
|
|
|
|
* \brief C API: String Enumeration
|
|
|
|
*/
|
|
|
|
|
2002-12-12 00:27:50 +00:00
|
|
|
/**
|
|
|
|
* An enumeration object.
|
|
|
|
* For usage in C programs.
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-07-08 23:04:59 +00:00
|
|
|
*/
|
|
|
|
struct UEnumeration;
|
2003-11-18 02:37:24 +00:00
|
|
|
/** structure representing an enumeration object instance @stable ICU 2.2 */
|
2002-07-08 23:04:59 +00:00
|
|
|
typedef struct UEnumeration UEnumeration;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
* @param en UEnumeration structure pointer
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-07-08 23:04:59 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2002-07-09 06:15:34 +00:00
|
|
|
uenum_close(UEnumeration* en);
|
2002-07-08 23:04:59 +00:00
|
|
|
|
2009-12-17 07:13:28 +00:00
|
|
|
#if U_SHOW_CPLUSPLUS_API
|
2009-11-14 00:36:06 +00:00
|
|
|
|
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \class LocalUEnumerationPointer
|
|
|
|
* "Smart pointer" class, closes a UEnumeration via uenum_close().
|
|
|
|
* For most methods see the LocalPointerBase base class.
|
|
|
|
*
|
|
|
|
* @see LocalPointerBase
|
|
|
|
* @see LocalPointer
|
|
|
|
* @draft ICU 4.4
|
|
|
|
*/
|
|
|
|
U_DEFINE_LOCAL_OPEN_POINTER(LocalUEnumerationPointer, UEnumeration, uenum_close);
|
|
|
|
|
|
|
|
U_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2002-07-08 23:04:59 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
* @param en UEnumeration structure pointer
|
|
|
|
* @param status error code, can be U_ENUM_OUT_OF_SYNC_ERROR if the
|
|
|
|
* iterator is out of sync.
|
|
|
|
* @return number of elements in the iterator
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-07-08 23:04:59 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE int32_t U_EXPORT2
|
2002-07-09 06:15:34 +00:00
|
|
|
uenum_count(UEnumeration* en, UErrorCode* status);
|
2002-07-08 23:04:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
* @param en the iterator object
|
2002-08-02 23:01:10 +00:00
|
|
|
* @param resultLength pointer to receive the length of the result
|
2004-06-15 20:52:22 +00:00
|
|
|
* (not including the terminating \\0).
|
2002-08-02 23:01:10 +00:00
|
|
|
* If the pointer is NULL it is ignored.
|
2002-07-08 23:04:59 +00:00
|
|
|
* @param status the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if
|
|
|
|
* the iterator is out of sync with its service.
|
|
|
|
* @return a pointer to the string. The string will be
|
|
|
|
* zero-terminated. The return pointer is owned by this iterator
|
|
|
|
* and must not be deleted by the caller. The pointer is valid
|
|
|
|
* until the next call to any uenum_... method, including
|
|
|
|
* uenum_next() or uenum_unext(). When all strings have been
|
|
|
|
* traversed, returns NULL.
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-07-08 23:04:59 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE const UChar* U_EXPORT2
|
2002-07-09 06:15:34 +00:00
|
|
|
uenum_unext(UEnumeration* en,
|
|
|
|
int32_t* resultLength,
|
|
|
|
UErrorCode* status);
|
2002-07-08 23:04:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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).
|
|
|
|
* @param en the iterator object
|
2002-08-02 23:01:10 +00:00
|
|
|
* @param resultLength pointer to receive the length of the result
|
2004-06-15 20:52:22 +00:00
|
|
|
* (not including the terminating \\0).
|
2002-08-02 23:01:10 +00:00
|
|
|
* If the pointer is NULL it is ignored.
|
2002-07-08 23:04:59 +00:00
|
|
|
* @param 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.
|
|
|
|
* @return a pointer to the string. The string will be
|
|
|
|
* zero-terminated. The return pointer is owned by this iterator
|
|
|
|
* and must not be deleted by the caller. The pointer is valid
|
|
|
|
* until the next call to any uenum_... method, including
|
|
|
|
* uenum_next() or uenum_unext(). When all strings have been
|
|
|
|
* traversed, returns NULL.
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-07-08 23:04:59 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE const char* U_EXPORT2
|
2002-07-09 06:15:34 +00:00
|
|
|
uenum_next(UEnumeration* en,
|
|
|
|
int32_t* resultLength,
|
|
|
|
UErrorCode* status);
|
2002-07-08 23:04:59 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
* @param en the iterator object
|
|
|
|
* @param status the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if
|
|
|
|
* the iterator is out of sync with its service.
|
2003-11-18 02:37:24 +00:00
|
|
|
* @stable ICU 2.2
|
2002-07-08 23:04:59 +00:00
|
|
|
*/
|
2004-03-26 19:42:04 +00:00
|
|
|
U_STABLE void U_EXPORT2
|
2002-07-09 06:15:34 +00:00
|
|
|
uenum_reset(UEnumeration* en, UErrorCode* status);
|
2002-07-08 23:04:59 +00:00
|
|
|
|
2009-12-17 07:13:28 +00:00
|
|
|
#if U_SHOW_CPLUSPLUS_API
|
2009-03-12 17:56:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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).
|
|
|
|
* @param adopted the C++ StringEnumeration to be wrapped in a UEnumeration.
|
|
|
|
* @param ec the error code.
|
|
|
|
* @return a UEnumeration wrapping the adopted StringEnumeration.
|
|
|
|
* @draft ICU 4.2
|
|
|
|
*/
|
|
|
|
U_CAPI UEnumeration* U_EXPORT2
|
2009-03-18 20:23:40 +00:00
|
|
|
uenum_openFromStringEnumeration(U_NAMESPACE_QUALIFIER StringEnumeration* adopted, UErrorCode* ec);
|
2009-03-12 17:56:24 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2002-07-08 23:04:59 +00:00
|
|
|
#endif
|