17777dab0Sopenharmony_ci// © 2016 and later: Unicode, Inc. and others.
27777dab0Sopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html
37777dab0Sopenharmony_ci/*
47777dab0Sopenharmony_ci*******************************************************************************
57777dab0Sopenharmony_ci*
67777dab0Sopenharmony_ci*   Copyright (C) 2002-2013, International Business Machines
77777dab0Sopenharmony_ci*   Corporation and others.  All Rights Reserved.
87777dab0Sopenharmony_ci*
97777dab0Sopenharmony_ci*******************************************************************************
107777dab0Sopenharmony_ci*   file name:  uenum.h
117777dab0Sopenharmony_ci*   encoding:   UTF-8
127777dab0Sopenharmony_ci*   tab size:   8 (not used)
137777dab0Sopenharmony_ci*   indentation:2
147777dab0Sopenharmony_ci*
157777dab0Sopenharmony_ci*   created on: 2002jul08
167777dab0Sopenharmony_ci*   created by: Vladimir Weinstein
177777dab0Sopenharmony_ci*/
187777dab0Sopenharmony_ci
197777dab0Sopenharmony_ci#ifndef __UENUM_H
207777dab0Sopenharmony_ci#define __UENUM_H
217777dab0Sopenharmony_ci
227777dab0Sopenharmony_ci#include "unicode/utypes.h"
237777dab0Sopenharmony_ci
247777dab0Sopenharmony_ci#if U_SHOW_CPLUSPLUS_API
257777dab0Sopenharmony_ci#include "unicode/localpointer.h"
267777dab0Sopenharmony_ci
277777dab0Sopenharmony_ciU_NAMESPACE_BEGIN
287777dab0Sopenharmony_ciclass StringEnumeration;
297777dab0Sopenharmony_ciU_NAMESPACE_END
307777dab0Sopenharmony_ci#endif   // U_SHOW_CPLUSPLUS_API
317777dab0Sopenharmony_ci
327777dab0Sopenharmony_ci/**
337777dab0Sopenharmony_ci * \file
347777dab0Sopenharmony_ci * \brief C API: String Enumeration
357777dab0Sopenharmony_ci */
367777dab0Sopenharmony_ci
377777dab0Sopenharmony_ci/**
387777dab0Sopenharmony_ci * An enumeration object.
397777dab0Sopenharmony_ci * For usage in C programs.
407777dab0Sopenharmony_ci * @stable ICU 2.2
417777dab0Sopenharmony_ci */
427777dab0Sopenharmony_cistruct UEnumeration;
437777dab0Sopenharmony_ci/** structure representing an enumeration object instance @stable ICU 2.2 */
447777dab0Sopenharmony_citypedef struct UEnumeration UEnumeration;
457777dab0Sopenharmony_ci
467777dab0Sopenharmony_ci/**
477777dab0Sopenharmony_ci * Disposes of resources in use by the iterator.  If en is NULL,
487777dab0Sopenharmony_ci * does nothing.  After this call, any char* or UChar* pointer
497777dab0Sopenharmony_ci * returned by uenum_unext() or uenum_next() is invalid.
507777dab0Sopenharmony_ci * @param en UEnumeration structure pointer
517777dab0Sopenharmony_ci * @stable ICU 2.2
527777dab0Sopenharmony_ci */
537777dab0Sopenharmony_ciU_CAPI void U_EXPORT2
547777dab0Sopenharmony_ciuenum_close(UEnumeration* en);
557777dab0Sopenharmony_ci
567777dab0Sopenharmony_ci
577777dab0Sopenharmony_ci/**
587777dab0Sopenharmony_ci * Returns the number of elements that the iterator traverses.  If
597777dab0Sopenharmony_ci * the iterator is out-of-sync with its service, status is set to
607777dab0Sopenharmony_ci * U_ENUM_OUT_OF_SYNC_ERROR.
617777dab0Sopenharmony_ci * This is a convenience function. It can end up being very
627777dab0Sopenharmony_ci * expensive as all the items might have to be pre-fetched (depending
637777dab0Sopenharmony_ci * on the type of data being traversed). Use with caution and only
647777dab0Sopenharmony_ci * when necessary.
657777dab0Sopenharmony_ci * @param en UEnumeration structure pointer
667777dab0Sopenharmony_ci * @param status error code, can be U_ENUM_OUT_OF_SYNC_ERROR if the
677777dab0Sopenharmony_ci *               iterator is out of sync.
687777dab0Sopenharmony_ci * @return number of elements in the iterator
697777dab0Sopenharmony_ci * @stable ICU 2.2
707777dab0Sopenharmony_ci */
717777dab0Sopenharmony_ciU_CAPI int32_t U_EXPORT2
727777dab0Sopenharmony_ciuenum_count(UEnumeration* en, UErrorCode* status);
737777dab0Sopenharmony_ci
747777dab0Sopenharmony_ci/**
757777dab0Sopenharmony_ci * Returns the next element in the iterator's list.  If there are
767777dab0Sopenharmony_ci * no more elements, returns NULL.  If the iterator is out-of-sync
777777dab0Sopenharmony_ci * with its service, status is set to U_ENUM_OUT_OF_SYNC_ERROR and
787777dab0Sopenharmony_ci * NULL is returned.  If the native service string is a char* string,
797777dab0Sopenharmony_ci * it is converted to UChar* with the invariant converter.
807777dab0Sopenharmony_ci * The result is terminated by (UChar)0.
817777dab0Sopenharmony_ci * @param en the iterator object
827777dab0Sopenharmony_ci * @param resultLength pointer to receive the length of the result
837777dab0Sopenharmony_ci *                     (not including the terminating \\0).
847777dab0Sopenharmony_ci *                     If the pointer is NULL it is ignored.
857777dab0Sopenharmony_ci * @param status the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if
867777dab0Sopenharmony_ci *               the iterator is out of sync with its service.
877777dab0Sopenharmony_ci * @return a pointer to the string.  The string will be
887777dab0Sopenharmony_ci *         zero-terminated.  The return pointer is owned by this iterator
897777dab0Sopenharmony_ci *         and must not be deleted by the caller.  The pointer is valid
907777dab0Sopenharmony_ci *         until the next call to any uenum_... method, including
917777dab0Sopenharmony_ci *         uenum_next() or uenum_unext().  When all strings have been
927777dab0Sopenharmony_ci *         traversed, returns NULL.
937777dab0Sopenharmony_ci * @stable ICU 2.2
947777dab0Sopenharmony_ci */
957777dab0Sopenharmony_ciU_CAPI const UChar* U_EXPORT2
967777dab0Sopenharmony_ciuenum_unext(UEnumeration* en,
977777dab0Sopenharmony_ci            int32_t* resultLength,
987777dab0Sopenharmony_ci            UErrorCode* status);
997777dab0Sopenharmony_ci
1007777dab0Sopenharmony_ci/**
1017777dab0Sopenharmony_ci * Returns the next element in the iterator's list.  If there are
1027777dab0Sopenharmony_ci * no more elements, returns NULL.  If the iterator is out-of-sync
1037777dab0Sopenharmony_ci * with its service, status is set to U_ENUM_OUT_OF_SYNC_ERROR and
1047777dab0Sopenharmony_ci * NULL is returned.  If the native service string is a UChar*
1057777dab0Sopenharmony_ci * string, it is converted to char* with the invariant converter.
1067777dab0Sopenharmony_ci * The result is terminated by (char)0.  If the conversion fails
1077777dab0Sopenharmony_ci * (because a character cannot be converted) then status is set to
1087777dab0Sopenharmony_ci * U_INVARIANT_CONVERSION_ERROR and the return value is undefined
1097777dab0Sopenharmony_ci * (but non-NULL).
1107777dab0Sopenharmony_ci * @param en the iterator object
1117777dab0Sopenharmony_ci * @param resultLength pointer to receive the length of the result
1127777dab0Sopenharmony_ci *                     (not including the terminating \\0).
1137777dab0Sopenharmony_ci *                     If the pointer is NULL it is ignored.
1147777dab0Sopenharmony_ci * @param status the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if
1157777dab0Sopenharmony_ci *               the iterator is out of sync with its service.  Set to
1167777dab0Sopenharmony_ci *               U_INVARIANT_CONVERSION_ERROR if the underlying native string is
1177777dab0Sopenharmony_ci *               UChar* and conversion to char* with the invariant converter
1187777dab0Sopenharmony_ci *               fails. This error pertains only to current string, so iteration
1197777dab0Sopenharmony_ci *               might be able to continue successfully.
1207777dab0Sopenharmony_ci * @return a pointer to the string.  The string will be
1217777dab0Sopenharmony_ci *         zero-terminated.  The return pointer is owned by this iterator
1227777dab0Sopenharmony_ci *         and must not be deleted by the caller.  The pointer is valid
1237777dab0Sopenharmony_ci *         until the next call to any uenum_... method, including
1247777dab0Sopenharmony_ci *         uenum_next() or uenum_unext().  When all strings have been
1257777dab0Sopenharmony_ci *         traversed, returns NULL.
1267777dab0Sopenharmony_ci * @stable ICU 2.2
1277777dab0Sopenharmony_ci */
1287777dab0Sopenharmony_ciU_CAPI const char* U_EXPORT2
1297777dab0Sopenharmony_ciuenum_next(UEnumeration* en,
1307777dab0Sopenharmony_ci           int32_t* resultLength,
1317777dab0Sopenharmony_ci           UErrorCode* status);
1327777dab0Sopenharmony_ci
1337777dab0Sopenharmony_ci/**
1347777dab0Sopenharmony_ci * Resets the iterator to the current list of service IDs.  This
1357777dab0Sopenharmony_ci * re-establishes sync with the service and rewinds the iterator
1367777dab0Sopenharmony_ci * to start at the first element.
1377777dab0Sopenharmony_ci * @param en the iterator object
1387777dab0Sopenharmony_ci * @param status the error code, set to U_ENUM_OUT_OF_SYNC_ERROR if
1397777dab0Sopenharmony_ci *               the iterator is out of sync with its service.
1407777dab0Sopenharmony_ci * @stable ICU 2.2
1417777dab0Sopenharmony_ci */
1427777dab0Sopenharmony_ciU_CAPI void U_EXPORT2
1437777dab0Sopenharmony_ciuenum_reset(UEnumeration* en, UErrorCode* status);
1447777dab0Sopenharmony_ci#endif
145