Imported Upstream version 58.1
[platform/upstream/icu.git] / source / i18n / unicode / fpositer.h
1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 ********************************************************************************
5 *   Copyright (C) 2010-2012, International Business Machines
6 *   Corporation and others.  All Rights Reserved.
7 ********************************************************************************
8 *
9 * File attiter.h
10 *
11 * Modification History:
12 *
13 *   Date        Name        Description
14 *   12/15/2009  dougfelt    Created
15 ********************************************************************************
16 */
17
18 #ifndef FPOSITER_H
19 #define FPOSITER_H
20
21 #include "unicode/utypes.h"
22 #include "unicode/uobject.h"
23
24 /**
25  * \file
26  * \brief C++ API: FieldPosition Iterator.
27  */
28
29 #if UCONFIG_NO_FORMATTING
30
31 U_NAMESPACE_BEGIN
32
33 /*
34  * Allow the declaration of APIs with pointers to FieldPositionIterator
35  * even when formatting is removed from the build.
36  */
37 class FieldPositionIterator;
38
39 U_NAMESPACE_END
40
41 #else
42
43 #include "unicode/fieldpos.h"
44 #include "unicode/umisc.h"
45
46 U_NAMESPACE_BEGIN
47
48 class UVector32;
49
50 /**
51  * FieldPositionIterator returns the field ids and their start/limit positions generated
52  * by a call to Format::format.  See Format, NumberFormat, DecimalFormat.
53  * @stable ICU 4.4
54  */
55 class U_I18N_API FieldPositionIterator : public UObject {
56 public:
57     /**
58      * Destructor.
59      * @stable ICU 4.4
60      */
61     ~FieldPositionIterator();
62
63     /**
64      * Constructs a new, empty iterator.
65      * @stable ICU 4.4
66      */
67     FieldPositionIterator(void);
68
69     /**
70      * Copy constructor.  If the copy failed for some reason, the new iterator will
71      * be empty.
72      * @stable ICU 4.4
73      */
74     FieldPositionIterator(const FieldPositionIterator&);
75
76     /**
77      * Return true if another object is semantically equal to this
78      * one.
79      * <p>
80      * Return true if this FieldPositionIterator is at the same position in an
81      * equal array of run values.
82      * @stable ICU 4.4
83      */
84     UBool operator==(const FieldPositionIterator&) const;
85
86     /**
87      * Returns the complement of the result of operator==
88      * @param rhs The FieldPositionIterator to be compared for inequality
89      * @return the complement of the result of operator==
90      * @stable ICU 4.4
91      */
92     UBool operator!=(const FieldPositionIterator& rhs) const { return !operator==(rhs); }
93
94     /**
95      * If the current position is valid, updates the FieldPosition values, advances the iterator,
96      * and returns TRUE, otherwise returns FALSE.
97      * @stable ICU 4.4
98      */
99     UBool next(FieldPosition& fp);
100
101 private:
102     friend class FieldPositionIteratorHandler;
103
104     /**
105      * Sets the data used by the iterator, and resets the position.
106      * Returns U_ILLEGAL_ARGUMENT_ERROR in status if the data is not valid 
107      * (length is not a multiple of 3, or start >= limit for any run).
108      */
109     void setData(UVector32 *adopt, UErrorCode& status);
110
111     UVector32 *data;
112     int32_t pos;
113 };
114
115 U_NAMESPACE_END
116
117 #endif /* #if !UCONFIG_NO_FORMATTING */
118
119 #endif // FPOSITER_H