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