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* Copyright (C) 2015-2016, International Business Machines
67777dab0Sopenharmony_ci* Corporation and others. All Rights Reserved.
77777dab0Sopenharmony_ci*****************************************************************************************
87777dab0Sopenharmony_ci*/
97777dab0Sopenharmony_ci
107777dab0Sopenharmony_ci#ifndef UFIELDPOSITER_H
117777dab0Sopenharmony_ci#define UFIELDPOSITER_H
127777dab0Sopenharmony_ci
137777dab0Sopenharmony_ci#include "unicode/utypes.h"
147777dab0Sopenharmony_ci
157777dab0Sopenharmony_ci#if !UCONFIG_NO_FORMATTING
167777dab0Sopenharmony_ci
177777dab0Sopenharmony_ci#if U_SHOW_CPLUSPLUS_API
187777dab0Sopenharmony_ci#include "unicode/localpointer.h"
197777dab0Sopenharmony_ci#endif   // U_SHOW_CPLUSPLUS_API
207777dab0Sopenharmony_ci
217777dab0Sopenharmony_ci/**
227777dab0Sopenharmony_ci * \file
237777dab0Sopenharmony_ci * \brief C API: UFieldPositionIterator for use with format APIs.
247777dab0Sopenharmony_ci *
257777dab0Sopenharmony_ci * Usage:
267777dab0Sopenharmony_ci * ufieldpositer_open creates an empty (unset) UFieldPositionIterator.
277777dab0Sopenharmony_ci * This can be passed to format functions such as {@link #udat_formatForFields},
287777dab0Sopenharmony_ci * which will set it to apply to the fields in a particular formatted string.
297777dab0Sopenharmony_ci * ufieldpositer_next can then be used to iterate over those fields,
307777dab0Sopenharmony_ci * providing for each field its type (using values that are specific to the
317777dab0Sopenharmony_ci * particular format type, such as date or number formats), as well as the
327777dab0Sopenharmony_ci * start and end positions of the field in the formatted string.
337777dab0Sopenharmony_ci * A given UFieldPositionIterator can be re-used for different format calls;
347777dab0Sopenharmony_ci * each such call resets it to apply to that format string.
357777dab0Sopenharmony_ci * ufieldpositer_close should be called to dispose of the UFieldPositionIterator
367777dab0Sopenharmony_ci * when it is no longer needed.
377777dab0Sopenharmony_ci *
387777dab0Sopenharmony_ci * @see FieldPositionIterator
397777dab0Sopenharmony_ci */
407777dab0Sopenharmony_ci
417777dab0Sopenharmony_ci/**
427777dab0Sopenharmony_ci * Opaque UFieldPositionIterator object for use in C.
437777dab0Sopenharmony_ci * @stable ICU 55
447777dab0Sopenharmony_ci */
457777dab0Sopenharmony_cistruct UFieldPositionIterator;
467777dab0Sopenharmony_citypedef struct UFieldPositionIterator UFieldPositionIterator;  /**< C typedef for struct UFieldPositionIterator. @stable ICU 55 */
477777dab0Sopenharmony_ci
487777dab0Sopenharmony_ci/**
497777dab0Sopenharmony_ci * Open a new, unset UFieldPositionIterator object.
507777dab0Sopenharmony_ci * @param status
517777dab0Sopenharmony_ci *          A pointer to a UErrorCode to receive any errors.
527777dab0Sopenharmony_ci * @return
537777dab0Sopenharmony_ci *          A pointer to an empty (unset) UFieldPositionIterator object,
547777dab0Sopenharmony_ci *          or NULL if an error occurred.
557777dab0Sopenharmony_ci * @stable ICU 55
567777dab0Sopenharmony_ci */
577777dab0Sopenharmony_ciU_CAPI UFieldPositionIterator* U_EXPORT2
587777dab0Sopenharmony_ciufieldpositer_open(UErrorCode* status);
597777dab0Sopenharmony_ci
607777dab0Sopenharmony_ci/**
617777dab0Sopenharmony_ci * Close a UFieldPositionIterator object. Once closed it may no longer be used.
627777dab0Sopenharmony_ci * @param fpositer
637777dab0Sopenharmony_ci *          A pointer to the UFieldPositionIterator object to close.
647777dab0Sopenharmony_ci * @stable ICU 55
657777dab0Sopenharmony_ci */
667777dab0Sopenharmony_ciU_CAPI void U_EXPORT2
677777dab0Sopenharmony_ciufieldpositer_close(UFieldPositionIterator *fpositer);
687777dab0Sopenharmony_ci
697777dab0Sopenharmony_ci
707777dab0Sopenharmony_ci#if U_SHOW_CPLUSPLUS_API
717777dab0Sopenharmony_ci
727777dab0Sopenharmony_ciU_NAMESPACE_BEGIN
737777dab0Sopenharmony_ci
747777dab0Sopenharmony_ci/**
757777dab0Sopenharmony_ci * \class LocalUFieldPositionIteratorPointer
767777dab0Sopenharmony_ci * "Smart pointer" class, closes a UFieldPositionIterator via ufieldpositer_close().
777777dab0Sopenharmony_ci * For most methods see the LocalPointerBase base class.
787777dab0Sopenharmony_ci *
797777dab0Sopenharmony_ci * @see LocalPointerBase
807777dab0Sopenharmony_ci * @see LocalPointer
817777dab0Sopenharmony_ci * @stable ICU 55
827777dab0Sopenharmony_ci */
837777dab0Sopenharmony_ciU_DEFINE_LOCAL_OPEN_POINTER(LocalUFieldPositionIteratorPointer, UFieldPositionIterator, ufieldpositer_close);
847777dab0Sopenharmony_ci
857777dab0Sopenharmony_ciU_NAMESPACE_END
867777dab0Sopenharmony_ci
877777dab0Sopenharmony_ci#endif
887777dab0Sopenharmony_ci
897777dab0Sopenharmony_ci/**
907777dab0Sopenharmony_ci * Get information for the next field in the formatted string to which this
917777dab0Sopenharmony_ci * UFieldPositionIterator currently applies, or return a negative value if there
927777dab0Sopenharmony_ci * are no more fields.
937777dab0Sopenharmony_ci * @param fpositer
947777dab0Sopenharmony_ci *          A pointer to the UFieldPositionIterator object containing iteration
957777dab0Sopenharmony_ci *          state for the format fields.
967777dab0Sopenharmony_ci * @param beginIndex
977777dab0Sopenharmony_ci *          A pointer to an int32_t to receive information about the start offset
987777dab0Sopenharmony_ci *          of the field in the formatted string (undefined if the function
997777dab0Sopenharmony_ci *          returns a negative value). May be NULL if this information is not needed.
1007777dab0Sopenharmony_ci * @param endIndex
1017777dab0Sopenharmony_ci *          A pointer to an int32_t to receive information about the end offset
1027777dab0Sopenharmony_ci *          of the field in the formatted string (undefined if the function
1037777dab0Sopenharmony_ci *          returns a negative value). May be NULL if this information is not needed.
1047777dab0Sopenharmony_ci * @return
1057777dab0Sopenharmony_ci *          The field type (non-negative value), or a negative value if there are
1067777dab0Sopenharmony_ci *          no more fields for which to provide information. If negative, then any
1077777dab0Sopenharmony_ci *          values pointed to by beginIndex and endIndex are undefined.
1087777dab0Sopenharmony_ci *
1097777dab0Sopenharmony_ci *          The values for field type depend on what type of formatter the
1107777dab0Sopenharmony_ci *          UFieldPositionIterator has been set by; for a date formatter, the
1117777dab0Sopenharmony_ci *          values from the UDateFormatField enum. For more information, see the
1127777dab0Sopenharmony_ci *          descriptions of format functions that take a UFieldPositionIterator*
1137777dab0Sopenharmony_ci *          parameter, such as {@link #udat_formatForFields}.
1147777dab0Sopenharmony_ci *
1157777dab0Sopenharmony_ci * @stable ICU 55
1167777dab0Sopenharmony_ci */
1177777dab0Sopenharmony_ciU_CAPI int32_t U_EXPORT2
1187777dab0Sopenharmony_ciufieldpositer_next(UFieldPositionIterator *fpositer,
1197777dab0Sopenharmony_ci                   int32_t *beginIndex, int32_t *endIndex);
1207777dab0Sopenharmony_ci
1217777dab0Sopenharmony_ci#endif /* #if !UCONFIG_NO_FORMATTING */
1227777dab0Sopenharmony_ci
1237777dab0Sopenharmony_ci#endif
124