]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/digitgrouping.h
2 *******************************************************************************
3 * Copyright (C) 2015, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 *******************************************************************************
9 * created by: Travis Keep
12 #ifndef __DIGITGROUPING_H__
13 #define __DIGITGROUPING_H__
15 #include "unicode/uobject.h"
16 #include "unicode/utypes.h"
20 class IntDigitCountRange
;
23 * The digit grouping policy.
25 class U_I18N_API DigitGrouping
: public UMemory
{
28 * Default is no digit grouping.
30 DigitGrouping() : fGrouping(0), fGrouping2(0), fMinGrouping(0) { }
33 * Returns TRUE if this object is equal to rhs.
35 UBool
equals(const DigitGrouping
&rhs
) const {
36 return ((fGrouping
== rhs
.fGrouping
) &&
37 (fGrouping2
== rhs
.fGrouping2
) &&
38 (fMinGrouping
== rhs
.fMinGrouping
));
42 * Returns true if a separator is needed after a particular digit.
43 * @param digitsLeftOfDecimal the total count of digits left of the
45 * @param digitPos 0 is the one's place; 1 is the 10's place; -1 is the
48 UBool
isSeparatorAt(int32_t digitsLeftOfDecimal
, int32_t digitPos
) const;
51 * Returns the total number of separators to be used to format a particular
53 * @param digitsLeftOfDecimal the total number of digits to the left of
56 int32_t getSeparatorCount(int32_t digitsLeftOfDecimal
) const;
59 * Returns true if grouping is used FALSE otherwise. When
60 * isGroupingUsed() returns FALSE; isSeparatorAt always returns FALSE
61 * and getSeparatorCount always returns 0.
63 UBool
isGroupingUsed() const { return fGrouping
> 0; }
66 * Returns TRUE if this instance would not add grouping separators
67 * when formatting value using the given constraint on digit count.
69 * @param value the value to format.
70 * @param range the minimum and maximum digits for formatting value.
73 int32_t positiveValue
, const IntDigitCountRange
&range
) const;
76 * Clears this instance so that digit grouping is not in effect.
83 * Primary grouping size. A value of 0, the default, or a negative
84 * number causes isGroupingUsed() to return FALSE.
89 * Secondary grouping size. If > 0, this size is used instead of
90 * 'fGrouping' for all but the group just to the left of the decimal
91 * point. The default value of 0, or a negative value indicates that
92 * there is no secondary grouping size.
97 * If set (that is > 0), uses no grouping separators if fewer than
98 * (fGrouping + fMinGrouping) digits appear left of the decimal place.
99 * The default value for this field is 0.
101 int32_t fMinGrouping
;
103 UBool
isGroupingEnabled(int32_t digitsLeftOfDecimal
) const;
104 int32_t getGrouping2() const;
105 int32_t getMinGrouping() const;
110 #endif // __DIGITGROUPING_H__