OLD | NEW |
(Empty) | |
| 1 /* |
| 2 ******************************************************************************* |
| 3 * Copyright (C) 2015, International Business Machines |
| 4 * Corporation and others. All Rights Reserved. |
| 5 ******************************************************************************* |
| 6 * significantdigitinterval.h |
| 7 * |
| 8 * created on: 2015jan6 |
| 9 * created by: Travis Keep |
| 10 */ |
| 11 |
| 12 #ifndef __SIGNIFICANTDIGITINTERVAL_H__ |
| 13 #define __SIGNIFICANTDIGITINTERVAL_H__ |
| 14 |
| 15 #include "unicode/uobject.h" |
| 16 #include "unicode/utypes.h" |
| 17 |
| 18 U_NAMESPACE_BEGIN |
| 19 |
| 20 /** |
| 21 * An interval of allowed significant digit counts. |
| 22 */ |
| 23 class U_I18N_API SignificantDigitInterval : public UMemory { |
| 24 public: |
| 25 |
| 26 /** |
| 27 * No limits on significant digits. |
| 28 */ |
| 29 SignificantDigitInterval() |
| 30 : fMax(INT32_MAX), fMin(0) { } |
| 31 |
| 32 /** |
| 33 * Make this instance have no limit on significant digits. |
| 34 */ |
| 35 void clear() { |
| 36 fMin = 0; |
| 37 fMax = INT32_MAX; |
| 38 } |
| 39 |
| 40 /** |
| 41 * Returns TRUE if this object is equal to rhs. |
| 42 */ |
| 43 UBool equals(const SignificantDigitInterval &rhs) const { |
| 44 return ((fMax == rhs.fMax) && (fMin == rhs.fMin)); |
| 45 } |
| 46 |
| 47 /** |
| 48 * Sets maximum significant digits. 0 or negative means no maximum. |
| 49 */ |
| 50 void setMax(int32_t count) { |
| 51 fMax = count <= 0 ? INT32_MAX : count; |
| 52 } |
| 53 |
| 54 /** |
| 55 * Get maximum significant digits. INT32_MAX means no maximum. |
| 56 */ |
| 57 int32_t getMax() const { |
| 58 return fMax; |
| 59 } |
| 60 |
| 61 /** |
| 62 * Sets minimum significant digits. 0 or negative means no minimum. |
| 63 */ |
| 64 void setMin(int32_t count) { |
| 65 fMin = count <= 0 ? 0 : count; |
| 66 } |
| 67 |
| 68 /** |
| 69 * Get maximum significant digits. 0 means no minimum. |
| 70 */ |
| 71 int32_t getMin() const { |
| 72 return fMin; |
| 73 } |
| 74 |
| 75 /** |
| 76 * Returns TRUE if this instance represents no constraints on significant |
| 77 * digits. |
| 78 */ |
| 79 UBool isNoConstraints() const { |
| 80 return fMin == 0 && fMax == INT32_MAX; |
| 81 } |
| 82 |
| 83 private: |
| 84 int32_t fMax; |
| 85 int32_t fMin; |
| 86 }; |
| 87 |
| 88 U_NAMESPACE_END |
| 89 |
| 90 #endif // __SIGNIFICANTDIGITINTERVAL_H__ |
OLD | NEW |