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