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

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

Issue 1621943002: ICU 56 step 4: Apply post-56 fixes for measure/date format (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@56goog
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/plurrule_impl.h ('k') | source/i18n/quantityformatter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 ****************************************************************************** 2 ******************************************************************************
3 * Copyright (C) 2014, International Business Machines 3 * Copyright (C) 2014-2015, International Business Machines
4 * Corporation and others. All Rights Reserved. 4 * Corporation and others. All Rights Reserved.
5 ****************************************************************************** 5 ******************************************************************************
6 * quantityformatter.h 6 * quantityformatter.h
7 */ 7 */
8 8
9 #ifndef __QUANTITY_FORMATTER_H__ 9 #ifndef __QUANTITY_FORMATTER_H__
10 #define __QUANTITY_FORMATTER_H__ 10 #define __QUANTITY_FORMATTER_H__
11 11
12 #include "unicode/utypes.h" 12 #include "unicode/utypes.h"
13 #include "unicode/uobject.h" 13 #include "unicode/uobject.h"
14 14
15 #if !UCONFIG_NO_FORMATTING 15 #if !UCONFIG_NO_FORMATTING
16 16
17 #include "standardplural.h"
18
17 U_NAMESPACE_BEGIN 19 U_NAMESPACE_BEGIN
18 20
19 class SimplePatternFormatter; 21 class SimplePatternFormatter;
20 class UnicodeString; 22 class UnicodeString;
21 class PluralRules; 23 class PluralRules;
22 class NumberFormat; 24 class NumberFormat;
23 class Formattable; 25 class Formattable;
24 class FieldPosition; 26 class FieldPosition;
25 27
26 /** 28 /**
(...skipping 30 matching lines...) Expand all
57 * Destructor. 59 * Destructor.
58 */ 60 */
59 ~QuantityFormatter(); 61 ~QuantityFormatter();
60 62
61 /** 63 /**
62 * Removes all variants from this object including the "other" variant. 64 * Removes all variants from this object including the "other" variant.
63 */ 65 */
64 void reset(); 66 void reset();
65 67
66 /** 68 /**
67 * Adds a plural variant. 69 * Adds a plural variant if there is none yet for the plural form.
68 * 70 *
69 * @param variant "zero", "one", "two", "few", "many", "other" 71 * @param variant "zero", "one", "two", "few", "many", "other"
70 * @param rawPattern the pattern for the variant e.g "{0} meters" 72 * @param rawPattern the pattern for the variant e.g "{0} meters"
71 * @param status any error returned here. 73 * @param status any error returned here.
72 * @return TRUE on success; FALSE if status was set to a non zero error. 74 * @return TRUE on success; FALSE if status was set to a non zero error.
73 */ 75 */
74 UBool add( 76 UBool addIfAbsent(const char *variant, const UnicodeString &rawPattern, UErr orCode &status);
75 const char *variant,
76 const UnicodeString &rawPattern,
77 UErrorCode &status);
78 77
79 /** 78 /**
80 * returns TRUE if this object has at least the "other" variant. 79 * returns TRUE if this object has at least the "other" variant.
81 */ 80 */
82 UBool isValid() const; 81 UBool isValid() const;
83 82
84 /** 83 /**
85 * Gets the pattern formatter that would be used for a particular variant. 84 * Gets the pattern formatter that would be used for a particular variant.
86 * If isValid() returns TRUE, this method is guaranteed to return a 85 * If isValid() returns TRUE, this method is guaranteed to return a
87 * non-NULL value. 86 * non-NULL value.
88 */ 87 */
89 const SimplePatternFormatter *getByVariant(const char *variant) const; 88 const SimplePatternFormatter *getByVariant(const char *variant) const;
90 89
91 /** 90 /**
92 * Formats a quantity with this object appending the result to appendTo. 91 * Formats a number with this object appending the result to appendTo.
93 * At least the "other" variant must be added to this object for this 92 * At least the "other" variant must be added to this object for this
94 * method to work. 93 * method to work.
95 * 94 *
96 * @param quantity the single quantity. 95 * @param number the single number.
97 * @param fmt formats the quantity 96 * @param fmt formats the number
98 * @param rules computes the plural variant to use. 97 * @param rules computes the plural variant to use.
99 * @param appendTo result appended here. 98 * @param appendTo result appended here.
100 * @param status any error returned here. 99 * @param status any error returned here.
101 * @return appendTo 100 * @return appendTo
102 */ 101 */
103 UnicodeString &format( 102 UnicodeString &format(
104 const Formattable &quantity, 103 const Formattable &number,
105 const NumberFormat &fmt, 104 const NumberFormat &fmt,
106 const PluralRules &rules, 105 const PluralRules &rules,
107 UnicodeString &appendTo, 106 UnicodeString &appendTo,
108 FieldPosition &pos, 107 FieldPosition &pos,
109 UErrorCode &status) const; 108 UErrorCode &status) const;
110 109
110 /**
111 * Selects the standard plural form for the number/formatter/rules.
112 */
113 static StandardPlural::Form selectPlural(
114 const Formattable &number,
115 const NumberFormat &fmt,
116 const PluralRules &rules,
117 UnicodeString &formattedNumber,
118 FieldPosition &pos,
119 UErrorCode &status);
120
121 /**
122 * Formats the pattern with the value and adjusts the FieldPosition.
123 */
124 static UnicodeString &format(
125 const SimplePatternFormatter &pattern,
126 const UnicodeString &value,
127 UnicodeString &appendTo,
128 FieldPosition &pos,
129 UErrorCode &status);
130
111 private: 131 private:
112 SimplePatternFormatter *formatters[6]; 132 SimplePatternFormatter *formatters[StandardPlural::COUNT];
113 }; 133 };
114 134
115 U_NAMESPACE_END 135 U_NAMESPACE_END
116 136
117 #endif 137 #endif
118 138
119 #endif 139 #endif
OLDNEW
« no previous file with comments | « source/i18n/plurrule_impl.h ('k') | source/i18n/quantityformatter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698