Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: source/i18n/smallintformatter.h

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/i18n/significantdigitinterval.h ('k') | source/i18n/smallintformatter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 *******************************************************************************
3 * Copyright (C) 2015, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 *******************************************************************************
6 * smallintformatter.h
7 *
8 * created on: 2015jan06
9 * created by: Travis Keep
10 */
11
12 #ifndef __SMALLINTFORMATTER_H__
13 #define __SMALLINTFORMATTER_H__
14
15 #include "unicode/uobject.h"
16 #include "unicode/utypes.h"
17
18 U_NAMESPACE_BEGIN
19
20 class UnicodeString;
21
22 /**
23 * A representation an acceptable range of digit counts for integers.
24 */
25 class U_I18N_API IntDigitCountRange : public UMemory {
26 public:
27 /**
28 * No constraints: 0 up to INT32_MAX
29 */
30 IntDigitCountRange() : fMin(0), fMax(INT32_MAX) { }
31 IntDigitCountRange(int32_t min, int32_t max);
32 int32_t pin(int32_t digitCount) const;
33 int32_t getMax() const { return fMax; }
34 int32_t getMin() const { return fMin; }
35 private:
36 int32_t fMin;
37 int32_t fMax;
38 };
39
40
41 /**
42 * A formatter for small, positive integers.
43 */
44 class U_I18N_API SmallIntFormatter : public UMemory {
45 public:
46 /**
47 * Estimates the actual digit count needed to format positiveValue
48 * using the given range of digit counts.
49 * Returns a value that is at least the actual digit count needed.
50 *
51 * @param positiveValue the value to format
52 * @param range the acceptable range of digit counts.
53 */
54 static int32_t estimateDigitCount(
55 int32_t positiveValue, const IntDigitCountRange &range);
56
57 /**
58 * Returns TRUE if this class can format positiveValue using
59 * the given range of digit counts.
60 *
61 * @param positiveValue the value to format
62 * @param range the acceptable range of digit counts.
63 */
64 static UBool canFormat(
65 int32_t positiveValue, const IntDigitCountRange &range);
66
67 /**
68 * Formats positiveValue using the given range of digit counts.
69 * Always uses standard digits '0' through '9'. Formatted value is
70 * left padded with '0' as necessary to achieve minimum digit count.
71 * Does not produce any grouping separators or trailing decimal point.
72 * Calling format to format a value with a particular digit count range
73 * when canFormat indicates that the same value and digit count range
74 * cannot be formatted results in undefined behavior.
75 *
76 * @param positiveValue the value to format
77 * @param range the acceptable range of digit counts.
78 */
79 static UnicodeString &format(
80 int32_t positiveValue,
81 const IntDigitCountRange &range,
82 UnicodeString &appendTo);
83
84 };
85
86 U_NAMESPACE_END
87
88 #endif // __SMALLINTFORMATTER_H__
OLDNEW
« no previous file with comments | « source/i18n/significantdigitinterval.h ('k') | source/i18n/smallintformatter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698