xref: /aosp_15_r20/external/icu/libandroidicu/include/unicode/ufieldpositer.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others.
2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html
3*0e209d39SAndroid Build Coastguard Worker /*
4*0e209d39SAndroid Build Coastguard Worker *****************************************************************************************
5*0e209d39SAndroid Build Coastguard Worker * Copyright (C) 2015-2016, International Business Machines
6*0e209d39SAndroid Build Coastguard Worker * Corporation and others. All Rights Reserved.
7*0e209d39SAndroid Build Coastguard Worker *****************************************************************************************
8*0e209d39SAndroid Build Coastguard Worker */
9*0e209d39SAndroid Build Coastguard Worker 
10*0e209d39SAndroid Build Coastguard Worker #ifndef UFIELDPOSITER_H
11*0e209d39SAndroid Build Coastguard Worker #define UFIELDPOSITER_H
12*0e209d39SAndroid Build Coastguard Worker 
13*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h"
14*0e209d39SAndroid Build Coastguard Worker 
15*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_FORMATTING
16*0e209d39SAndroid Build Coastguard Worker 
17*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API
18*0e209d39SAndroid Build Coastguard Worker #include "unicode/localpointer.h"
19*0e209d39SAndroid Build Coastguard Worker #endif   // U_SHOW_CPLUSPLUS_API
20*0e209d39SAndroid Build Coastguard Worker 
21*0e209d39SAndroid Build Coastguard Worker /**
22*0e209d39SAndroid Build Coastguard Worker  * \file
23*0e209d39SAndroid Build Coastguard Worker  * \brief C API: UFieldPositionIterator for use with format APIs.
24*0e209d39SAndroid Build Coastguard Worker  *
25*0e209d39SAndroid Build Coastguard Worker  * Usage:
26*0e209d39SAndroid Build Coastguard Worker  * ufieldpositer_open creates an empty (unset) UFieldPositionIterator.
27*0e209d39SAndroid Build Coastguard Worker  * This can be passed to format functions such as {@link #udat_formatForFields},
28*0e209d39SAndroid Build Coastguard Worker  * which will set it to apply to the fields in a particular formatted string.
29*0e209d39SAndroid Build Coastguard Worker  * ufieldpositer_next can then be used to iterate over those fields,
30*0e209d39SAndroid Build Coastguard Worker  * providing for each field its type (using values that are specific to the
31*0e209d39SAndroid Build Coastguard Worker  * particular format type, such as date or number formats), as well as the
32*0e209d39SAndroid Build Coastguard Worker  * start and end positions of the field in the formatted string.
33*0e209d39SAndroid Build Coastguard Worker  * A given UFieldPositionIterator can be re-used for different format calls;
34*0e209d39SAndroid Build Coastguard Worker  * each such call resets it to apply to that format string.
35*0e209d39SAndroid Build Coastguard Worker  * ufieldpositer_close should be called to dispose of the UFieldPositionIterator
36*0e209d39SAndroid Build Coastguard Worker  * when it is no longer needed.
37*0e209d39SAndroid Build Coastguard Worker  *
38*0e209d39SAndroid Build Coastguard Worker  * @see FieldPositionIterator
39*0e209d39SAndroid Build Coastguard Worker  */
40*0e209d39SAndroid Build Coastguard Worker 
41*0e209d39SAndroid Build Coastguard Worker /**
42*0e209d39SAndroid Build Coastguard Worker  * Opaque UFieldPositionIterator object for use in C.
43*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 55
44*0e209d39SAndroid Build Coastguard Worker  */
45*0e209d39SAndroid Build Coastguard Worker struct UFieldPositionIterator;
46*0e209d39SAndroid Build Coastguard Worker typedef struct UFieldPositionIterator UFieldPositionIterator;  /**< C typedef for struct UFieldPositionIterator. @stable ICU 55 */
47*0e209d39SAndroid Build Coastguard Worker 
48*0e209d39SAndroid Build Coastguard Worker /**
49*0e209d39SAndroid Build Coastguard Worker  * Open a new, unset UFieldPositionIterator object.
50*0e209d39SAndroid Build Coastguard Worker  * @param status
51*0e209d39SAndroid Build Coastguard Worker  *          A pointer to a UErrorCode to receive any errors.
52*0e209d39SAndroid Build Coastguard Worker  * @return
53*0e209d39SAndroid Build Coastguard Worker  *          A pointer to an empty (unset) UFieldPositionIterator object,
54*0e209d39SAndroid Build Coastguard Worker  *          or NULL if an error occurred.
55*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 55
56*0e209d39SAndroid Build Coastguard Worker  */
57*0e209d39SAndroid Build Coastguard Worker U_CAPI UFieldPositionIterator* U_EXPORT2
58*0e209d39SAndroid Build Coastguard Worker ufieldpositer_open(UErrorCode* status);
59*0e209d39SAndroid Build Coastguard Worker 
60*0e209d39SAndroid Build Coastguard Worker /**
61*0e209d39SAndroid Build Coastguard Worker  * Close a UFieldPositionIterator object. Once closed it may no longer be used.
62*0e209d39SAndroid Build Coastguard Worker  * @param fpositer
63*0e209d39SAndroid Build Coastguard Worker  *          A pointer to the UFieldPositionIterator object to close.
64*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 55
65*0e209d39SAndroid Build Coastguard Worker  */
66*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2
67*0e209d39SAndroid Build Coastguard Worker ufieldpositer_close(UFieldPositionIterator *fpositer);
68*0e209d39SAndroid Build Coastguard Worker 
69*0e209d39SAndroid Build Coastguard Worker 
70*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API
71*0e209d39SAndroid Build Coastguard Worker 
72*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN
73*0e209d39SAndroid Build Coastguard Worker 
74*0e209d39SAndroid Build Coastguard Worker /**
75*0e209d39SAndroid Build Coastguard Worker  * \class LocalUFieldPositionIteratorPointer
76*0e209d39SAndroid Build Coastguard Worker  * "Smart pointer" class, closes a UFieldPositionIterator via ufieldpositer_close().
77*0e209d39SAndroid Build Coastguard Worker  * For most methods see the LocalPointerBase base class.
78*0e209d39SAndroid Build Coastguard Worker  *
79*0e209d39SAndroid Build Coastguard Worker  * @see LocalPointerBase
80*0e209d39SAndroid Build Coastguard Worker  * @see LocalPointer
81*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 55
82*0e209d39SAndroid Build Coastguard Worker  */
83*0e209d39SAndroid Build Coastguard Worker U_DEFINE_LOCAL_OPEN_POINTER(LocalUFieldPositionIteratorPointer, UFieldPositionIterator, ufieldpositer_close);
84*0e209d39SAndroid Build Coastguard Worker 
85*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END
86*0e209d39SAndroid Build Coastguard Worker 
87*0e209d39SAndroid Build Coastguard Worker #endif
88*0e209d39SAndroid Build Coastguard Worker 
89*0e209d39SAndroid Build Coastguard Worker /**
90*0e209d39SAndroid Build Coastguard Worker  * Get information for the next field in the formatted string to which this
91*0e209d39SAndroid Build Coastguard Worker  * UFieldPositionIterator currently applies, or return a negative value if there
92*0e209d39SAndroid Build Coastguard Worker  * are no more fields.
93*0e209d39SAndroid Build Coastguard Worker  * @param fpositer
94*0e209d39SAndroid Build Coastguard Worker  *          A pointer to the UFieldPositionIterator object containing iteration
95*0e209d39SAndroid Build Coastguard Worker  *          state for the format fields.
96*0e209d39SAndroid Build Coastguard Worker  * @param beginIndex
97*0e209d39SAndroid Build Coastguard Worker  *          A pointer to an int32_t to receive information about the start offset
98*0e209d39SAndroid Build Coastguard Worker  *          of the field in the formatted string (undefined if the function
99*0e209d39SAndroid Build Coastguard Worker  *          returns a negative value). May be NULL if this information is not needed.
100*0e209d39SAndroid Build Coastguard Worker  * @param endIndex
101*0e209d39SAndroid Build Coastguard Worker  *          A pointer to an int32_t to receive information about the end offset
102*0e209d39SAndroid Build Coastguard Worker  *          of the field in the formatted string (undefined if the function
103*0e209d39SAndroid Build Coastguard Worker  *          returns a negative value). May be NULL if this information is not needed.
104*0e209d39SAndroid Build Coastguard Worker  * @return
105*0e209d39SAndroid Build Coastguard Worker  *          The field type (non-negative value), or a negative value if there are
106*0e209d39SAndroid Build Coastguard Worker  *          no more fields for which to provide information. If negative, then any
107*0e209d39SAndroid Build Coastguard Worker  *          values pointed to by beginIndex and endIndex are undefined.
108*0e209d39SAndroid Build Coastguard Worker  *
109*0e209d39SAndroid Build Coastguard Worker  *          The values for field type depend on what type of formatter the
110*0e209d39SAndroid Build Coastguard Worker  *          UFieldPositionIterator has been set by; for a date formatter, the
111*0e209d39SAndroid Build Coastguard Worker  *          values from the UDateFormatField enum. For more information, see the
112*0e209d39SAndroid Build Coastguard Worker  *          descriptions of format functions that take a UFieldPositionIterator*
113*0e209d39SAndroid Build Coastguard Worker  *          parameter, such as {@link #udat_formatForFields}.
114*0e209d39SAndroid Build Coastguard Worker  *
115*0e209d39SAndroid Build Coastguard Worker  * @stable ICU 55
116*0e209d39SAndroid Build Coastguard Worker  */
117*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2
118*0e209d39SAndroid Build Coastguard Worker ufieldpositer_next(UFieldPositionIterator *fpositer,
119*0e209d39SAndroid Build Coastguard Worker                    int32_t *beginIndex, int32_t *endIndex);
120*0e209d39SAndroid Build Coastguard Worker 
121*0e209d39SAndroid Build Coastguard Worker #endif /* #if !UCONFIG_NO_FORMATTING */
122*0e209d39SAndroid Build Coastguard Worker 
123*0e209d39SAndroid Build Coastguard Worker #endif
124