summaryrefslogtreecommitdiffstats
path: root/intl/icu/source/i18n/smallintformatter.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/smallintformatter.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/smallintformatter.h')
-rw-r--r--intl/icu/source/i18n/smallintformatter.h90
1 files changed, 90 insertions, 0 deletions
diff --git a/intl/icu/source/i18n/smallintformatter.h b/intl/icu/source/i18n/smallintformatter.h
new file mode 100644
index 000000000..abf2b4b98
--- /dev/null
+++ b/intl/icu/source/i18n/smallintformatter.h
@@ -0,0 +1,90 @@
+// 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.
+*******************************************************************************
+* smallintformatter.h
+*
+* created on: 2015jan06
+* created by: Travis Keep
+*/
+
+#ifndef __SMALLINTFORMATTER_H__
+#define __SMALLINTFORMATTER_H__
+
+#include "unicode/uobject.h"
+#include "unicode/utypes.h"
+
+U_NAMESPACE_BEGIN
+
+class UnicodeString;
+
+/**
+ * A representation an acceptable range of digit counts for integers.
+ */
+class U_I18N_API IntDigitCountRange : public UMemory {
+public:
+ /**
+ * No constraints: 0 up to INT32_MAX
+ */
+ IntDigitCountRange() : fMin(0), fMax(INT32_MAX) { }
+ IntDigitCountRange(int32_t min, int32_t max);
+ int32_t pin(int32_t digitCount) const;
+ int32_t getMax() const { return fMax; }
+ int32_t getMin() const { return fMin; }
+private:
+ int32_t fMin;
+ int32_t fMax;
+};
+
+
+/**
+ * A formatter for small, positive integers.
+ */
+class U_I18N_API SmallIntFormatter : public UMemory {
+public:
+ /**
+ * Estimates the actual digit count needed to format positiveValue
+ * using the given range of digit counts.
+ * Returns a value that is at least the actual digit count needed.
+ *
+ * @param positiveValue the value to format
+ * @param range the acceptable range of digit counts.
+ */
+ static int32_t estimateDigitCount(
+ int32_t positiveValue, const IntDigitCountRange &range);
+
+ /**
+ * Returns TRUE if this class can format positiveValue using
+ * the given range of digit counts.
+ *
+ * @param positiveValue the value to format
+ * @param range the acceptable range of digit counts.
+ */
+ static UBool canFormat(
+ int32_t positiveValue, const IntDigitCountRange &range);
+
+ /**
+ * Formats positiveValue using the given range of digit counts.
+ * Always uses standard digits '0' through '9'. Formatted value is
+ * left padded with '0' as necessary to achieve minimum digit count.
+ * Does not produce any grouping separators or trailing decimal point.
+ * Calling format to format a value with a particular digit count range
+ * when canFormat indicates that the same value and digit count range
+ * cannot be formatted results in undefined behavior.
+ *
+ * @param positiveValue the value to format
+ * @param range the acceptable range of digit counts.
+ */
+ static UnicodeString &format(
+ int32_t positiveValue,
+ const IntDigitCountRange &range,
+ UnicodeString &appendTo);
+
+};
+
+U_NAMESPACE_END
+
+#endif // __SMALLINTFORMATTER_H__