1 // © 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 // Forward declaration for number formatting: 51 namespace number { 52 namespace impl { 53 class NumberStringBuilder; 54 } 55 } 56 57 /** 58 * FieldPositionIterator returns the field ids and their start/limit positions generated 59 * by a call to Format::format. See Format, NumberFormat, DecimalFormat. 60 * @stable ICU 4.4 61 */ 62 class U_I18N_API FieldPositionIterator : public UObject { 63 public: 64 /** 65 * Destructor. 66 * @stable ICU 4.4 67 */ 68 ~FieldPositionIterator(); 69 70 /** 71 * Constructs a new, empty iterator. 72 * @stable ICU 4.4 73 */ 74 FieldPositionIterator(void); 75 76 /** 77 * Copy constructor. If the copy failed for some reason, the new iterator will 78 * be empty. 79 * @stable ICU 4.4 80 */ 81 FieldPositionIterator(const FieldPositionIterator&); 82 83 /** 84 * Return true if another object is semantically equal to this 85 * one. 86 * <p> 87 * Return true if this FieldPositionIterator is at the same position in an 88 * equal array of run values. 89 * @stable ICU 4.4 90 */ 91 UBool operator==(const FieldPositionIterator&) const; 92 93 /** 94 * Returns the complement of the result of operator== 95 * @param rhs The FieldPositionIterator to be compared for inequality 96 * @return the complement of the result of operator== 97 * @stable ICU 4.4 98 */ 99 UBool operator!=(const FieldPositionIterator& rhs) const { return !operator==(rhs); } 100 101 /** 102 * If the current position is valid, updates the FieldPosition values, advances the iterator, 103 * and returns TRUE, otherwise returns FALSE. 104 * @stable ICU 4.4 105 */ 106 UBool next(FieldPosition& fp); 107 108 private: 109 /** 110 * Sets the data used by the iterator, and resets the position. 111 * Returns U_ILLEGAL_ARGUMENT_ERROR in status if the data is not valid 112 * (length is not a multiple of 3, or start >= limit for any run). 113 */ 114 void setData(UVector32 *adopt, UErrorCode& status); 115 116 friend class FieldPositionIteratorHandler; 117 friend class number::impl::NumberStringBuilder; 118 119 UVector32 *data; 120 int32_t pos; 121 }; 122 123 U_NAMESPACE_END 124 125 #endif /* #if !UCONFIG_NO_FORMATTING */ 126 127 #endif // FPOSITER_H 128