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