summaryrefslogtreecommitdiffstats
path: root/intl/icu/source/i18n/digitinterval.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /intl/icu/source/i18n/digitinterval.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'intl/icu/source/i18n/digitinterval.h')
-rw-r--r--intl/icu/source/i18n/digitinterval.h159
1 files changed, 159 insertions, 0 deletions
diff --git a/intl/icu/source/i18n/digitinterval.h b/intl/icu/source/i18n/digitinterval.h
new file mode 100644
index 000000000..8e1c83f77
--- /dev/null
+++ b/intl/icu/source/i18n/digitinterval.h
@@ -0,0 +1,159 @@
+// Copyright (C) 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
+/*
+*******************************************************************************
+* Copyright (C) 2015, International Business Machines
+* Corporation and others. All Rights Reserved.
+*******************************************************************************
+* digitinterval.h
+*
+* created on: 2015jan6
+* created by: Travis Keep
+*/
+
+#ifndef __DIGITINTERVAL_H__
+#define __DIGITINTERVAL_H__
+
+#include "unicode/uobject.h"
+#include "unicode/utypes.h"
+
+U_NAMESPACE_BEGIN
+
+/**
+ * An interval of digits.
+ * DigitIntervals are for fixed point formatting. A DigitInterval specifies
+ * zero or more integer digits and zero or more fractional digits. This class
+ * specifies particular digits in a number by their power of 10. For example,
+ * the digit position just to the left of the decimal is 0, and the digit
+ * position just left of that is 1. The digit position just to the right of
+ * the decimal is -1. The digit position just to the right of that is -2.
+ */
+class U_I18N_API DigitInterval : public UMemory {
+public:
+
+ /**
+ * Spans all integer and fraction digits
+ */
+ DigitInterval()
+ : fLargestExclusive(INT32_MAX), fSmallestInclusive(INT32_MIN) { }
+
+
+ /**
+ * Makes this instance span all digits.
+ */
+ void clear() {
+ fLargestExclusive = INT32_MAX;
+ fSmallestInclusive = INT32_MIN;
+ }
+
+ /**
+ * Returns TRUE if this interval contains this digit position.
+ */
+ UBool contains(int32_t digitPosition) const;
+
+ /**
+ * Returns true if this object is the same as rhs.
+ */
+ UBool equals(const DigitInterval &rhs) const {
+ return ((fLargestExclusive == rhs.fLargestExclusive) &&
+ (fSmallestInclusive == rhs.fSmallestInclusive));
+ }
+
+ /**
+ * Expand this interval so that it contains all of rhs.
+ */
+ void expandToContain(const DigitInterval &rhs);
+
+ /**
+ * Shrink this interval so that it contains no more than rhs.
+ */
+ void shrinkToFitWithin(const DigitInterval &rhs);
+
+ /**
+ * Expand this interval as necessary to contain digit with given exponent
+ * After this method returns, this interval is guaranteed to contain
+ * digitExponent.
+ */
+ void expandToContainDigit(int32_t digitExponent);
+
+ /**
+ * Changes the number of digits to the left of the decimal point that
+ * this interval spans. If count is negative, it means span all digits
+ * to the left of the decimal point.
+ */
+ void setIntDigitCount(int32_t count);
+
+ /**
+ * Changes the number of digits to the right of the decimal point that
+ * this interval spans. If count is negative, it means span all digits
+ * to the right of the decimal point.
+ */
+ void setFracDigitCount(int32_t count);
+
+ /**
+ * Sets the least significant inclusive value to smallest. If smallest >= 0
+ * then least significant inclusive value becomes 0.
+ */
+ void setLeastSignificantInclusive(int32_t smallest) {
+ fSmallestInclusive = smallest < 0 ? smallest : 0;
+ }
+
+ /**
+ * Sets the most significant exclusive value to largest.
+ * If largest <= 0 then most significant exclusive value becomes 0.
+ */
+ void setMostSignificantExclusive(int32_t largest) {
+ fLargestExclusive = largest > 0 ? largest : 0;
+ }
+
+ /**
+ * If returns 8, the most significant digit in interval is the 10^7 digit.
+ * Returns INT32_MAX if this interval spans all digits to left of
+ * decimal point.
+ */
+ int32_t getMostSignificantExclusive() const {
+ return fLargestExclusive;
+ }
+
+ /**
+ * Returns number of digits to the left of the decimal that this
+ * interval includes. This is a synonym for getMostSignificantExclusive().
+ */
+ int32_t getIntDigitCount() const {
+ return fLargestExclusive;
+ }
+
+ /**
+ * Returns number of digits to the right of the decimal that this
+ * interval includes.
+ */
+ int32_t getFracDigitCount() const {
+ return fSmallestInclusive == INT32_MIN ? INT32_MAX : -fSmallestInclusive;
+ }
+
+ /**
+ * Returns the total number of digits that this interval spans.
+ * Caution: If this interval spans all digits to the left or right of
+ * decimal point instead of some fixed number, then what length()
+ * returns is undefined.
+ */
+ int32_t length() const {
+ return fLargestExclusive - fSmallestInclusive;
+ }
+
+ /**
+ * If returns -3, the least significant digit in interval is the 10^-3
+ * digit. Returns INT32_MIN if this interval spans all digits to right of
+ * decimal point.
+ */
+ int32_t getLeastSignificantInclusive() const {
+ return fSmallestInclusive;
+ }
+private:
+ int32_t fLargestExclusive;
+ int32_t fSmallestInclusive;
+};
+
+U_NAMESPACE_END
+
+#endif // __DIGITINTERVAL_H__