pango 3.2.7-x64-mingw32 → 3.2.8-x64-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +10 -7
  3. data/lib/2.2/pango.so +0 -0
  4. data/lib/2.3/pango.so +0 -0
  5. data/lib/2.4/pango.so +0 -0
  6. data/lib/2.5/pango.so +0 -0
  7. data/pango.gemspec +2 -0
  8. data/vendor/local/bin/derb.exe +0 -0
  9. data/vendor/local/bin/escapesrc.exe +0 -0
  10. data/vendor/local/bin/fribidi.exe +0 -0
  11. data/vendor/local/bin/genbrk.exe +0 -0
  12. data/vendor/local/bin/genccode.exe +0 -0
  13. data/vendor/local/bin/gencfu.exe +0 -0
  14. data/vendor/local/bin/gencmn.exe +0 -0
  15. data/vendor/local/bin/gencnval.exe +0 -0
  16. data/vendor/local/bin/gendict.exe +0 -0
  17. data/vendor/local/bin/gennorm2.exe +0 -0
  18. data/vendor/local/bin/genrb.exe +0 -0
  19. data/vendor/local/bin/gensprep.exe +0 -0
  20. data/vendor/local/bin/hb-ot-shape-closure.exe +0 -0
  21. data/vendor/local/bin/hb-shape.exe +0 -0
  22. data/vendor/local/bin/hb-subset.exe +0 -0
  23. data/vendor/local/bin/hb-view.exe +0 -0
  24. data/vendor/local/bin/icu-config +6 -6
  25. data/vendor/local/bin/icuinfo.exe +0 -0
  26. data/vendor/local/bin/icupkg.exe +0 -0
  27. data/vendor/local/bin/libfribidi-0.dll +0 -0
  28. data/vendor/local/bin/libgraphene-1.0-0.dll +0 -0
  29. data/vendor/local/bin/libharfbuzz-0.dll +0 -0
  30. data/vendor/local/bin/libharfbuzz-subset-0.dll +0 -0
  31. data/vendor/local/bin/libpango-1.0-0.dll +0 -0
  32. data/vendor/local/bin/libpangocairo-1.0-0.dll +0 -0
  33. data/vendor/local/bin/libpangoft2-1.0-0.dll +0 -0
  34. data/vendor/local/bin/libpangowin32-1.0-0.dll +0 -0
  35. data/vendor/local/bin/makeconv.exe +0 -0
  36. data/vendor/local/{libexec/installed-tests/graphene-1.0/quad.exe → bin/pango-list.exe} +0 -0
  37. data/vendor/local/bin/pango-view.exe +0 -0
  38. data/vendor/local/bin/pkgdata.exe +0 -0
  39. data/vendor/local/bin/uconv.exe +0 -0
  40. data/vendor/local/include/fribidi/fribidi-config.h +2 -2
  41. data/vendor/local/include/graphene-1.0/graphene-macros.h +1 -1
  42. data/vendor/local/include/graphene-1.0/graphene-matrix.h +1 -1
  43. data/vendor/local/include/graphene-1.0/graphene-vec2.h +1 -1
  44. data/vendor/local/include/graphene-1.0/graphene-vec3.h +1 -1
  45. data/vendor/local/include/graphene-1.0/graphene-vec4.h +1 -1
  46. data/vendor/local/include/graphene-1.0/graphene-version.h +2 -2
  47. data/vendor/local/include/harfbuzz/hb-ot-layout.h +13 -0
  48. data/vendor/local/include/harfbuzz/hb-set.h +4 -0
  49. data/vendor/local/include/harfbuzz/hb-subset-plan.hh +1 -1
  50. data/vendor/local/include/harfbuzz/hb-subset-private.hh +1 -0
  51. data/vendor/local/include/harfbuzz/hb-subset.h +3 -0
  52. data/vendor/local/include/harfbuzz/hb-version.h +2 -2
  53. data/vendor/local/include/pango-1.0/pango/pango-features.h +2 -2
  54. data/vendor/local/include/unicode/brkiter.h +1 -1
  55. data/vendor/local/include/unicode/bytestriebuilder.h +1 -1
  56. data/vendor/local/include/unicode/caniter.h +2 -2
  57. data/vendor/local/include/unicode/compactdecimalformat.h +17 -250
  58. data/vendor/local/include/unicode/currunit.h +3 -2
  59. data/vendor/local/include/unicode/dcfmtsym.h +8 -1
  60. data/vendor/local/include/unicode/decimfmt.h +301 -439
  61. data/vendor/local/include/unicode/docmain.h +1 -1
  62. data/vendor/local/include/unicode/edits.h +129 -21
  63. data/vendor/local/include/unicode/fmtable.h +14 -21
  64. data/vendor/local/include/unicode/fpositer.h +0 -8
  65. data/vendor/local/include/unicode/measunit.h +0 -8
  66. data/vendor/local/include/unicode/nounit.h +6 -6
  67. data/vendor/local/include/unicode/numberformatter.h +1005 -553
  68. data/vendor/local/include/unicode/numfmt.h +10 -10
  69. data/vendor/local/include/unicode/platform.h +0 -14
  70. data/vendor/local/include/unicode/plurrule.h +0 -21
  71. data/vendor/local/include/unicode/rbbi.h +9 -15
  72. data/vendor/local/include/unicode/rbnf.h +2 -2
  73. data/vendor/local/include/unicode/scientificnumberformatter.h +0 -5
  74. data/vendor/local/include/unicode/smpdtfmt.h +33 -6
  75. data/vendor/local/include/unicode/timezone.h +2 -0
  76. data/vendor/local/include/unicode/uchar.h +42 -3
  77. data/vendor/local/include/unicode/unistr.h +3 -3
  78. data/vendor/local/include/unicode/unum.h +26 -5
  79. data/vendor/local/include/unicode/unumberformatter.h +717 -0
  80. data/vendor/local/include/unicode/urename.h +13 -0
  81. data/vendor/local/include/unicode/uscript.h +16 -1
  82. data/vendor/local/include/unicode/uspoof.h +24 -1
  83. data/vendor/local/include/unicode/utypes.h +4 -1
  84. data/vendor/local/include/unicode/uvernum.h +5 -5
  85. data/vendor/local/lib/cmake/harfbuzz/harfbuzz-config.cmake +1 -1
  86. data/vendor/local/lib/graphene-1.0/include/graphene-config.h +3 -1
  87. data/vendor/local/lib/icu/{61.1 → 62.1}/Makefile.inc +6 -6
  88. data/vendor/local/lib/icu/{61.1 → 62.1}/pkgdata.inc +3 -3
  89. data/vendor/local/lib/icu/Makefile.inc +6 -6
  90. data/vendor/local/lib/icu/pkgdata.inc +3 -3
  91. data/vendor/local/lib/icudt.dll +0 -0
  92. data/vendor/local/lib/{icudt61.dll → icudt62.dll} +0 -0
  93. data/vendor/local/lib/icuin.dll +0 -0
  94. data/vendor/local/lib/icuin62.dll +0 -0
  95. data/vendor/local/lib/icuio.dll +0 -0
  96. data/vendor/local/lib/{icuio61.dll → icuio62.dll} +0 -0
  97. data/vendor/local/lib/icutest.dll +0 -0
  98. data/vendor/local/lib/{icutest61.dll → icutest62.dll} +0 -0
  99. data/vendor/local/lib/icutu.dll +0 -0
  100. data/vendor/local/lib/{icutu61.dll → icutu62.dll} +0 -0
  101. data/vendor/local/lib/icuuc.dll +0 -0
  102. data/vendor/local/lib/{icuuc61.dll → icuuc62.dll} +0 -0
  103. data/vendor/local/lib/libfribidi.dll.a +0 -0
  104. data/vendor/local/lib/libgraphene-1.0.dll.a +0 -0
  105. data/vendor/local/lib/libharfbuzz-icu.a +0 -0
  106. data/vendor/local/lib/libharfbuzz-icu.la +2 -2
  107. data/vendor/local/lib/libharfbuzz-subset.dll.a +0 -0
  108. data/vendor/local/lib/libharfbuzz-subset.la +2 -2
  109. data/vendor/local/lib/libharfbuzz.dll.a +0 -0
  110. data/vendor/local/lib/libharfbuzz.la +2 -2
  111. data/vendor/local/lib/libicudt.dll.a +0 -0
  112. data/vendor/local/lib/libicuin.dll.a +0 -0
  113. data/vendor/local/lib/libicuio.dll.a +0 -0
  114. data/vendor/local/lib/libicutest.dll.a +0 -0
  115. data/vendor/local/lib/libicutu.dll.a +0 -0
  116. data/vendor/local/lib/libicuuc.dll.a +0 -0
  117. data/vendor/local/lib/libpango-1.0.dll.a +0 -0
  118. data/vendor/local/lib/libpango-1.0.la +2 -2
  119. data/vendor/local/lib/libpangocairo-1.0.dll.a +0 -0
  120. data/vendor/local/lib/libpangocairo-1.0.la +2 -2
  121. data/vendor/local/lib/libpangoft2-1.0.dll.a +0 -0
  122. data/vendor/local/lib/libpangoft2-1.0.la +2 -2
  123. data/vendor/local/lib/libpangowin32-1.0.dll.a +0 -0
  124. data/vendor/local/lib/libpangowin32-1.0.la +2 -2
  125. data/vendor/local/lib/pkgconfig/fribidi.pc +1 -1
  126. data/vendor/local/lib/pkgconfig/graphene-1.0.pc +7 -11
  127. data/vendor/local/lib/pkgconfig/graphene-gobject-1.0.pc +6 -12
  128. data/vendor/local/lib/pkgconfig/harfbuzz-icu.pc +1 -1
  129. data/vendor/local/lib/pkgconfig/harfbuzz-subset.pc +1 -1
  130. data/vendor/local/lib/pkgconfig/harfbuzz.pc +1 -1
  131. data/vendor/local/lib/pkgconfig/icu-i18n.pc +6 -6
  132. data/vendor/local/lib/pkgconfig/icu-io.pc +6 -6
  133. data/vendor/local/lib/pkgconfig/icu-uc.pc +6 -6
  134. data/vendor/local/lib/pkgconfig/pango.pc +3 -2
  135. data/vendor/local/lib/pkgconfig/pangocairo.pc +1 -1
  136. data/vendor/local/lib/pkgconfig/pangoft2.pc +1 -1
  137. data/vendor/local/lib/pkgconfig/pangowin32.pc +2 -2
  138. data/vendor/local/share/gir-1.0/Graphene-1.0.gir +1 -1
  139. data/vendor/local/share/gtk-doc/html/harfbuzz/api-index-full.html +80 -0
  140. data/vendor/local/share/gtk-doc/html/harfbuzz/harfbuzz-hb-blob.html +34 -0
  141. data/vendor/local/share/gtk-doc/html/harfbuzz/harfbuzz-hb-face.html +13 -0
  142. data/vendor/local/share/gtk-doc/html/harfbuzz/harfbuzz-hb-ot-layout.html +20 -0
  143. data/vendor/local/share/gtk-doc/html/harfbuzz/harfbuzz-hb-set.html +83 -28
  144. data/vendor/local/share/gtk-doc/html/harfbuzz/harfbuzz.devhelp2 +5 -1
  145. data/vendor/local/share/gtk-doc/html/harfbuzz/object-tree.html +1 -0
  146. data/vendor/local/share/gtk-doc/html/harfbuzz/pt02.html +1 -1
  147. data/vendor/local/share/gtk-doc/html/pango/PangoEngineLang.html +2 -2
  148. data/vendor/local/share/gtk-doc/html/pango/PangoEngineShape.html +2 -2
  149. data/vendor/local/share/gtk-doc/html/pango/PangoFcDecoder.html +2 -2
  150. data/vendor/local/share/gtk-doc/html/pango/PangoFcFont.html +2 -2
  151. data/vendor/local/share/gtk-doc/html/pango/PangoFcFontMap.html +2 -2
  152. data/vendor/local/share/gtk-doc/html/pango/PangoMarkupFormat.html +2 -2
  153. data/vendor/local/share/gtk-doc/html/pango/PangoRenderer.html +2 -2
  154. data/vendor/local/share/gtk-doc/html/pango/annotation-glossary.html +2 -2
  155. data/vendor/local/share/gtk-doc/html/pango/api-index-full.html +2 -2
  156. data/vendor/local/share/gtk-doc/html/pango/index.html +3 -3
  157. data/vendor/local/share/gtk-doc/html/pango/lowlevel.html +2 -2
  158. data/vendor/local/share/gtk-doc/html/pango/pango-Bidirectional-Text.html +2 -2
  159. data/vendor/local/share/gtk-doc/html/pango/pango-Cairo-Rendering.html +2 -2
  160. data/vendor/local/share/gtk-doc/html/pango/pango-CoreText-Fonts.html +2 -2
  161. data/vendor/local/share/gtk-doc/html/pango/pango-Coverage-Maps.html +2 -2
  162. data/vendor/local/share/gtk-doc/html/pango/pango-Engines.html +2 -2
  163. data/vendor/local/share/gtk-doc/html/pango/pango-Fonts.html +2 -2
  164. data/vendor/local/share/gtk-doc/html/pango/pango-FreeType-Fonts-and-Rendering.html +2 -2
  165. data/vendor/local/share/gtk-doc/html/pango/pango-Glyph-Storage.html +2 -2
  166. data/vendor/local/share/gtk-doc/html/pango/pango-Layout-Objects.html +2 -2
  167. data/vendor/local/share/gtk-doc/html/pango/pango-Miscellaneous-Utilities.html +2 -2
  168. data/vendor/local/share/gtk-doc/html/pango/pango-Modules.html +2 -2
  169. data/vendor/local/share/gtk-doc/html/pango/pango-OpenType-Font-Handling.html +2 -2
  170. data/vendor/local/share/gtk-doc/html/pango/pango-Scripts-and-Languages.html +2 -2
  171. data/vendor/local/share/gtk-doc/html/pango/pango-Tab-Stops.html +2 -2
  172. data/vendor/local/share/gtk-doc/html/pango/pango-Text-Attributes.html +2 -2
  173. data/vendor/local/share/gtk-doc/html/pango/pango-Text-Processing.html +2 -2
  174. data/vendor/local/share/gtk-doc/html/pango/pango-Version-Checking.html +4 -4
  175. data/vendor/local/share/gtk-doc/html/pango/pango-Vertical-Text.html +2 -2
  176. data/vendor/local/share/gtk-doc/html/pango/pango-Win32-Fonts-and-Rendering.html +2 -2
  177. data/vendor/local/share/gtk-doc/html/pango/pango-Xft-Fonts-and-Rendering.html +2 -2
  178. data/vendor/local/share/gtk-doc/html/pango/pango-hierarchy.html +2 -2
  179. data/vendor/local/share/gtk-doc/html/pango/pango.html +2 -2
  180. data/vendor/local/share/gtk-doc/html/pango/rendering.html +2 -2
  181. data/vendor/local/share/gtk-doc/html/pango/style.css +4 -0
  182. data/vendor/local/share/icu/{61.1 → 62.1}/LICENSE +0 -0
  183. data/vendor/local/share/icu/{61.1 → 62.1}/config/mh-mingw64 +0 -0
  184. data/vendor/local/share/icu/{61.1 → 62.1}/install-sh +0 -0
  185. data/vendor/local/share/icu/{61.1 → 62.1}/mkinstalldirs +0 -0
  186. data/vendor/local/share/man/man1/derb.1 +2 -2
  187. data/vendor/local/share/man/man1/genbrk.1 +2 -2
  188. data/vendor/local/share/man/man1/gencfu.1 +1 -1
  189. data/vendor/local/share/man/man1/gencnval.1 +3 -3
  190. data/vendor/local/share/man/man1/gendict.1 +2 -2
  191. data/vendor/local/share/man/man1/genrb.1 +3 -3
  192. data/vendor/local/share/man/man1/icu-config.1 +2 -2
  193. data/vendor/local/share/man/man1/makeconv.1 +3 -3
  194. data/vendor/local/share/man/man1/pkgdata.1 +2 -2
  195. data/vendor/local/share/man/man1/uconv.1 +2 -2
  196. data/vendor/local/share/man/man8/genccode.8 +2 -2
  197. data/vendor/local/share/man/man8/gencmn.8 +3 -3
  198. data/vendor/local/share/man/man8/gensprep.8 +3 -3
  199. data/vendor/local/share/man/man8/icupkg.8 +1 -1
  200. metadata +20 -54
  201. data/vendor/local/lib/icuin61.dll +0 -0
  202. data/vendor/local/libexec/installed-tests/graphene-1.0/box.exe +0 -0
  203. data/vendor/local/libexec/installed-tests/graphene-1.0/euler.exe +0 -0
  204. data/vendor/local/libexec/installed-tests/graphene-1.0/frustum.exe +0 -0
  205. data/vendor/local/libexec/installed-tests/graphene-1.0/matrix.exe +0 -0
  206. data/vendor/local/libexec/installed-tests/graphene-1.0/plane.exe +0 -0
  207. data/vendor/local/libexec/installed-tests/graphene-1.0/point.exe +0 -0
  208. data/vendor/local/libexec/installed-tests/graphene-1.0/point3d.exe +0 -0
  209. data/vendor/local/libexec/installed-tests/graphene-1.0/quaternion.exe +0 -0
  210. data/vendor/local/libexec/installed-tests/graphene-1.0/ray.exe +0 -0
  211. data/vendor/local/libexec/installed-tests/graphene-1.0/rect.exe +0 -0
  212. data/vendor/local/libexec/installed-tests/graphene-1.0/simd.exe +0 -0
  213. data/vendor/local/libexec/installed-tests/graphene-1.0/size.exe +0 -0
  214. data/vendor/local/libexec/installed-tests/graphene-1.0/sphere.exe +0 -0
  215. data/vendor/local/libexec/installed-tests/graphene-1.0/triangle.exe +0 -0
  216. data/vendor/local/libexec/installed-tests/graphene-1.0/vec2.exe +0 -0
  217. data/vendor/local/libexec/installed-tests/graphene-1.0/vec3.exe +0 -0
  218. data/vendor/local/libexec/installed-tests/graphene-1.0/vec4.exe +0 -0
  219. data/vendor/local/share/installed-tests/graphene-1.0/box.test +0 -3
  220. data/vendor/local/share/installed-tests/graphene-1.0/euler.test +0 -3
  221. data/vendor/local/share/installed-tests/graphene-1.0/frustum.test +0 -3
  222. data/vendor/local/share/installed-tests/graphene-1.0/matrix.test +0 -3
  223. data/vendor/local/share/installed-tests/graphene-1.0/plane.test +0 -3
  224. data/vendor/local/share/installed-tests/graphene-1.0/point.test +0 -3
  225. data/vendor/local/share/installed-tests/graphene-1.0/point3d.test +0 -3
  226. data/vendor/local/share/installed-tests/graphene-1.0/quad.test +0 -3
  227. data/vendor/local/share/installed-tests/graphene-1.0/quaternion.test +0 -3
  228. data/vendor/local/share/installed-tests/graphene-1.0/ray.test +0 -3
  229. data/vendor/local/share/installed-tests/graphene-1.0/rect.test +0 -3
  230. data/vendor/local/share/installed-tests/graphene-1.0/simd.test +0 -3
  231. data/vendor/local/share/installed-tests/graphene-1.0/size.test +0 -3
  232. data/vendor/local/share/installed-tests/graphene-1.0/sphere.test +0 -3
  233. data/vendor/local/share/installed-tests/graphene-1.0/triangle.test +0 -3
  234. data/vendor/local/share/installed-tests/graphene-1.0/vec2.test +0 -3
  235. data/vendor/local/share/installed-tests/graphene-1.0/vec3.test +0 -3
  236. data/vendor/local/share/installed-tests/graphene-1.0/vec4.test +0 -3
@@ -139,7 +139,7 @@
139
139
  * </tr>
140
140
  * <tr>
141
141
  * <td>Number Formatting</td>
142
- * <td>unum.h</td>
142
+ * <td>unumberformatter.h, unum.h</td>
143
143
  * <td>icu::number::NumberFormatter (ICU 60+) or icu::NumberFormat (older versions)</td>
144
144
  * </tr>
145
145
  * <tr>
@@ -17,10 +17,57 @@
17
17
 
18
18
  U_NAMESPACE_BEGIN
19
19
 
20
+ class UnicodeString;
21
+
20
22
  /**
21
- * Records lengths of string edits but not replacement text.
22
- * Supports replacements, insertions, deletions in linear progression.
23
- * Does not support moving/reordering of text.
23
+ * Records lengths of string edits but not replacement text. Supports replacements, insertions, deletions
24
+ * in linear progression. Does not support moving/reordering of text.
25
+ *
26
+ * There are two types of edits: <em>change edits</em> and <em>no-change edits</em>. Add edits to
27
+ * instances of this class using {@link #addReplace(int, int)} (for change edits) and
28
+ * {@link #addUnchanged(int)} (for no-change edits). Change edits are retained with full granularity,
29
+ * whereas adjacent no-change edits are always merged together. In no-change edits, there is a one-to-one
30
+ * mapping between code points in the source and destination strings.
31
+ *
32
+ * After all edits have been added, instances of this class should be considered immutable, and an
33
+ * {@link Edits::Iterator} can be used for queries.
34
+ *
35
+ * There are four flavors of Edits::Iterator:
36
+ *
37
+ * <ul>
38
+ * <li>{@link #getFineIterator()} retains full granularity of change edits.
39
+ * <li>{@link #getFineChangesIterator()} retains full granularity of change edits, and when calling
40
+ * next() on the iterator, skips over no-change edits (unchanged regions).
41
+ * <li>{@link #getCoarseIterator()} treats adjacent change edits as a single edit. (Adjacent no-change
42
+ * edits are automatically merged during the construction phase.)
43
+ * <li>{@link #getCoarseChangesIterator()} treats adjacent change edits as a single edit, and when
44
+ * calling next() on the iterator, skips over no-change edits (unchanged regions).
45
+ * </ul>
46
+ *
47
+ * For example, consider the string "abcßDeF", which case-folds to "abcssdef". This string has the
48
+ * following fine edits:
49
+ * <ul>
50
+ * <li>abc ⇨ abc (no-change)
51
+ * <li>ß ⇨ ss (change)
52
+ * <li>D ⇨ d (change)
53
+ * <li>e ⇨ e (no-change)
54
+ * <li>F ⇨ f (change)
55
+ * </ul>
56
+ * and the following coarse edits (note how adjacent change edits get merged together):
57
+ * <ul>
58
+ * <li>abc ⇨ abc (no-change)
59
+ * <li>ßD ⇨ ssd (change)
60
+ * <li>e ⇨ e (no-change)
61
+ * <li>F ⇨ f (change)
62
+ * </ul>
63
+ *
64
+ * The "fine changes" and "coarse changes" iterators will step through only the change edits when their
65
+ * {@link Edits::Iterator#next()} methods are called. They are identical to the non-change iterators when
66
+ * their {@link Edits::Iterator#findSourceIndex(int)} or {@link Edits::Iterator#findDestinationIndex(int)}
67
+ * methods are used to walk through the string.
68
+ *
69
+ * For examples of how to use this class, see the test <code>TestCaseMapEditsIteratorDocs</code> in
70
+ * UCharacterCaseTest.java.
24
71
  *
25
72
  * An Edits object tracks a separate UErrorCode, but ICU string transformation functions
26
73
  * (e.g., case mapping functions) merge any such errors into their API's UErrorCode.
@@ -91,13 +138,13 @@ public:
91
138
  void reset() U_NOEXCEPT;
92
139
 
93
140
  /**
94
- * Adds a record for an unchanged segment of text.
141
+ * Adds a no-change edit: a record for an unchanged segment of text.
95
142
  * Normally called from inside ICU string transformation functions, not user code.
96
143
  * @stable ICU 59
97
144
  */
98
145
  void addUnchanged(int32_t unchangedLength);
99
146
  /**
100
- * Adds a record for a text replacement/insertion/deletion.
147
+ * Adds a change edit: a record for a text replacement/insertion/deletion.
101
148
  * Normally called from inside ICU string transformation functions, not user code.
102
149
  * @stable ICU 59
103
150
  */
@@ -136,6 +183,18 @@ public:
136
183
 
137
184
  /**
138
185
  * Access to the list of edits.
186
+ *
187
+ * At any moment in time, an instance of this class points to a single edit: a "window" into a span
188
+ * of the source string and the corresponding span of the destination string. The source string span
189
+ * starts at {@link #sourceIndex()} and runs for {@link #oldLength()} chars; the destination string
190
+ * span starts at {@link #destinationIndex()} and runs for {@link #newLength()} chars.
191
+ *
192
+ * The iterator can be moved between edits using the {@link #next()}, {@link #findSourceIndex(int)},
193
+ * and {@link #findDestinationIndex(int)} methods. Calling any of these methods mutates the iterator
194
+ * to make it point to the corresponding edit.
195
+ *
196
+ * For more information, see the documentation for {@link Edits}.
197
+ *
139
198
  * @see getCoarseIterator
140
199
  * @see getFineIterator
141
200
  * @stable ICU 59
@@ -162,7 +221,7 @@ public:
162
221
  Iterator &operator=(const Iterator &other) = default;
163
222
 
164
223
  /**
165
- * Advances to the next edit.
224
+ * Advances the iterator to the next edit.
166
225
  * @param errorCode ICU error code. Its input value must pass the U_SUCCESS() test,
167
226
  * or else the function returns immediately. Check for U_FAILURE()
168
227
  * on output or use with function chaining. (See User Guide for details.)
@@ -172,9 +231,9 @@ public:
172
231
  UBool next(UErrorCode &errorCode) { return next(onlyChanges_, errorCode); }
173
232
 
174
233
  /**
175
- * Finds the edit that contains the source index.
176
- * The source index may be found in a non-change
177
- * even if normal iteration would skip non-changes.
234
+ * Moves the iterator to the edit that contains the source index.
235
+ * The source index may be found in a no-change edit
236
+ * even if normal iteration would skip no-change edits.
178
237
  * Normal iteration can continue from a found edit.
179
238
  *
180
239
  * The iterator state before this search logically does not matter.
@@ -196,9 +255,9 @@ public:
196
255
 
197
256
  #ifndef U_HIDE_DRAFT_API
198
257
  /**
199
- * Finds the edit that contains the destination index.
200
- * The destination index may be found in a non-change
201
- * even if normal iteration would skip non-changes.
258
+ * Moves the iterator to the edit that contains the destination index.
259
+ * The destination index may be found in a no-change edit
260
+ * even if normal iteration would skip no-change edits.
202
261
  * Normal iteration can continue from a found edit.
203
262
  *
204
263
  * The iterator state before this search logically does not matter.
@@ -219,7 +278,7 @@ public:
219
278
  }
220
279
 
221
280
  /**
222
- * Returns the destination index corresponding to the given source index.
281
+ * Computes the destination index corresponding to the given source index.
223
282
  * If the source index is inside a change edit (not at its start),
224
283
  * then the destination index at the end of that edit is returned,
225
284
  * since there is no information about index mapping inside a change edit.
@@ -243,7 +302,7 @@ public:
243
302
  int32_t destinationIndexFromSourceIndex(int32_t i, UErrorCode &errorCode);
244
303
 
245
304
  /**
246
- * Returns the source index corresponding to the given destination index.
305
+ * Computes the source index corresponding to the given destination index.
247
306
  * If the destination index is inside a change edit (not at its start),
248
307
  * then the source index at the end of that edit is returned,
249
308
  * since there is no information about index mapping inside a change edit.
@@ -268,17 +327,27 @@ public:
268
327
  #endif // U_HIDE_DRAFT_API
269
328
 
270
329
  /**
330
+ * Returns whether the edit currently represented by the iterator is a change edit.
331
+ *
271
332
  * @return TRUE if this edit replaces oldLength() units with newLength() different ones.
272
333
  * FALSE if oldLength units remain unchanged.
273
334
  * @stable ICU 59
274
335
  */
275
336
  UBool hasChange() const { return changed; }
337
+
276
338
  /**
339
+ * The length of the current span in the source string, which starts at {@link #sourceIndex}.
340
+ *
277
341
  * @return the number of units in the original string which are replaced or remain unchanged.
278
342
  * @stable ICU 59
279
343
  */
280
344
  int32_t oldLength() const { return oldLength_; }
345
+
281
346
  /**
347
+ * The length of the current span in the destination string, which starts at
348
+ * {@link #destinationIndex}, or in the replacement string, which starts at
349
+ * {@link #replacementIndex}.
350
+ *
282
351
  * @return the number of units in the modified string, if hasChange() is TRUE.
283
352
  * Same as oldLength if hasChange() is FALSE.
284
353
  * @stable ICU 59
@@ -286,22 +355,52 @@ public:
286
355
  int32_t newLength() const { return newLength_; }
287
356
 
288
357
  /**
358
+ * The start index of the current span in the source string; the span has length
359
+ * {@link #oldLength}.
360
+ *
289
361
  * @return the current index into the source string
290
362
  * @stable ICU 59
291
363
  */
292
364
  int32_t sourceIndex() const { return srcIndex; }
365
+
293
366
  /**
367
+ * The start index of the current span in the replacement string; the span has length
368
+ * {@link #newLength}. Well-defined only if the current edit is a change edit.
369
+ * <p>
370
+ * The <em>replacement string</em> is the concatenation of all substrings of the destination
371
+ * string corresponding to change edits.
372
+ * <p>
373
+ * This method is intended to be used together with operations that write only replacement
374
+ * characters (e.g., {@link CaseMap#omitUnchangedText()}). The source string can then be modified
375
+ * in-place.
376
+ *
294
377
  * @return the current index into the replacement-characters-only string,
295
378
  * not counting unchanged spans
296
379
  * @stable ICU 59
297
380
  */
298
- int32_t replacementIndex() const { return replIndex; }
381
+ int32_t replacementIndex() const {
382
+ // TODO: Throw an exception if we aren't in a change edit?
383
+ return replIndex;
384
+ }
385
+
299
386
  /**
387
+ * The start index of the current span in the destination string; the span has length
388
+ * {@link #newLength}.
389
+ *
300
390
  * @return the current index into the full destination string
301
391
  * @stable ICU 59
302
392
  */
303
393
  int32_t destinationIndex() const { return destIndex; }
304
394
 
395
+ #ifndef U_HIDE_INTERNAL_API
396
+ /**
397
+ * A string representation of the current edit represented by the iterator for debugging. You
398
+ * should not depend on the contents of the return string.
399
+ * @internal
400
+ */
401
+ UnicodeString& toString(UnicodeString& appendTo) const;
402
+ #endif // U_HIDE_INTERNAL_API
403
+
305
404
  private:
306
405
  friend class Edits;
307
406
 
@@ -330,8 +429,10 @@ public:
330
429
  };
331
430
 
332
431
  /**
333
- * Returns an Iterator for coarse-grained changes for simple string updates.
334
- * Skips non-changes.
432
+ * Returns an Iterator for coarse-grained change edits
433
+ * (adjacent change edits are treated as one).
434
+ * Can be used to perform simple string updates.
435
+ * Skips no-change edits.
335
436
  * @return an Iterator that merges adjacent changes.
336
437
  * @stable ICU 59
337
438
  */
@@ -340,7 +441,10 @@ public:
340
441
  }
341
442
 
342
443
  /**
343
- * Returns an Iterator for coarse-grained changes and non-changes for simple string updates.
444
+ * Returns an Iterator for coarse-grained change and no-change edits
445
+ * (adjacent change edits are treated as one).
446
+ * Can be used to perform simple string updates.
447
+ * Adjacent change edits are treated as one edit.
344
448
  * @return an Iterator that merges adjacent changes.
345
449
  * @stable ICU 59
346
450
  */
@@ -349,8 +453,10 @@ public:
349
453
  }
350
454
 
351
455
  /**
352
- * Returns an Iterator for fine-grained changes for modifying styled text.
353
- * Skips non-changes.
456
+ * Returns an Iterator for fine-grained change edits
457
+ * (full granularity of change edits is retained).
458
+ * Can be used for modifying styled text.
459
+ * Skips no-change edits.
354
460
  * @return an Iterator that separates adjacent changes.
355
461
  * @stable ICU 59
356
462
  */
@@ -359,7 +465,9 @@ public:
359
465
  }
360
466
 
361
467
  /**
362
- * Returns an Iterator for fine-grained changes and non-changes for modifying styled text.
468
+ * Returns an Iterator for fine-grained change and no-change edits
469
+ * (full granularity of change edits is retained).
470
+ * Can be used for modifying styled text.
363
471
  * @return an Iterator that separates adjacent changes.
364
472
  * @stable ICU 59
365
473
  */
@@ -33,17 +33,11 @@
33
33
  U_NAMESPACE_BEGIN
34
34
 
35
35
  class CharString;
36
- class DigitList;
37
-
38
- /**
39
- * \def UNUM_INTERNAL_STACKARRAY_SIZE
40
- * @internal
41
- */
42
- #if U_PLATFORM == U_PF_OS400
43
- #define UNUM_INTERNAL_STACKARRAY_SIZE 144
44
- #else
45
- #define UNUM_INTERNAL_STACKARRAY_SIZE 128
46
- #endif
36
+ namespace number {
37
+ namespace impl {
38
+ class DecimalQuantity;
39
+ }
40
+ }
47
41
 
48
42
  /**
49
43
  * Formattable objects can be passed to the Format class or
@@ -649,24 +643,25 @@ public:
649
643
  * Internal function, do not use.
650
644
  * TODO: figure out how to make this be non-public.
651
645
  * NumberFormat::format(Formattable, ...
652
- * needs to get at the DigitList, if it exists, for
646
+ * needs to get at the DecimalQuantity, if it exists, for
653
647
  * big decimal formatting.
654
648
  * @internal
655
649
  */
656
- DigitList *getDigitList() const { return fDecimalNum;}
650
+ number::impl::DecimalQuantity *getDecimalQuantity() const { return fDecimalQuantity;}
657
651
 
658
652
  /**
659
- * @internal
653
+ * Export the value of this Formattable to a DecimalQuantity.
654
+ * @internal
660
655
  */
661
- DigitList *getInternalDigitList();
656
+ void populateDecimalQuantity(number::impl::DecimalQuantity& output, UErrorCode& status) const;
662
657
 
663
658
  /**
664
- * Adopt, and set value from, a DigitList
659
+ * Adopt, and set value from, a DecimalQuantity
665
660
  * Internal Function, do not use.
666
- * @param dl the Digit List to be adopted
661
+ * @param dl the DecimalQuantity to be adopted
667
662
  * @internal
668
663
  */
669
- void adoptDigitList(DigitList *dl);
664
+ void adoptDecimalQuantity(number::impl::DecimalQuantity *dq);
670
665
 
671
666
  /**
672
667
  * Internal function to return the CharString pointer.
@@ -706,9 +701,7 @@ private:
706
701
 
707
702
  CharString *fDecimalStr;
708
703
 
709
- DigitList *fDecimalNum;
710
-
711
- char fStackData[UNUM_INTERNAL_STACKARRAY_SIZE]; // must be big enough for DigitList
704
+ number::impl::DecimalQuantity *fDecimalQuantity;
712
705
 
713
706
  Type fType;
714
707
  UnicodeString fBogus; // Bogus string when it's needed.
@@ -47,13 +47,6 @@ U_NAMESPACE_BEGIN
47
47
 
48
48
  class UVector32;
49
49
 
50
- // Forward declaration for number formatting:
51
- namespace number {
52
- namespace impl {
53
- class NumberStringBuilder;
54
- }
55
- }
56
-
57
50
  /**
58
51
  * FieldPositionIterator returns the field ids and their start/limit positions generated
59
52
  * by a call to Format::format. See Format, NumberFormat, DecimalFormat.
@@ -114,7 +107,6 @@ private:
114
107
  void setData(UVector32 *adopt, UErrorCode& status);
115
108
 
116
109
  friend class FieldPositionIteratorHandler;
117
- friend class number::impl::NumberStringBuilder;
118
110
 
119
111
  UVector32 *data;
120
112
  int32_t pos;
@@ -400,14 +400,6 @@ class U_I18N_API MeasureUnit: public UObject {
400
400
  */
401
401
  static MeasureUnit *createMilePerGallonImperial(UErrorCode &status);
402
402
 
403
- /*
404
- * The following were draft ICU 58, but have been withdrawn:
405
- * static MeasureUnit *createEast(UErrorCode &status);
406
- * static MeasureUnit *createNorth(UErrorCode &status);
407
- * static MeasureUnit *createSouth(UErrorCode &status);
408
- * static MeasureUnit *createWest(UErrorCode &status);
409
- */
410
-
411
403
  /**
412
404
  * Returns unit of digital: bit.
413
405
  * Caller owns returned value and must free it.
@@ -61,6 +61,12 @@ public:
61
61
  */
62
62
  NoUnit(const NoUnit& other);
63
63
 
64
+ /**
65
+ * Destructor.
66
+ * @draft ICU 60
67
+ */
68
+ virtual ~NoUnit();
69
+
64
70
  /**
65
71
  * Return a polymorphic clone of this object. The result will
66
72
  * have the same class as returned by getDynamicClassID().
@@ -86,12 +92,6 @@ public:
86
92
  */
87
93
  static UClassID U_EXPORT2 getStaticClassID();
88
94
 
89
- /**
90
- * Destructor.
91
- * @draft ICU 60
92
- */
93
- virtual ~NoUnit();
94
-
95
95
  private:
96
96
  /**
97
97
  * Constructor
@@ -17,6 +17,8 @@
17
17
  #include "unicode/plurrule.h"
18
18
  #include "unicode/ucurr.h"
19
19
  #include "unicode/unum.h"
20
+ #include "unicode/unumberformatter.h"
21
+ #include "unicode/uobject.h"
20
22
 
21
23
  #ifndef U_HIDE_DRAFT_API
22
24
 
@@ -31,11 +33,11 @@
31
33
  * // Most basic usage:
32
34
  * NumberFormatter::withLocale(...).format(123).toString(); // 1,234 in en-US
33
35
  *
34
- * // Custom notation, unit, and rounding strategy:
36
+ * // Custom notation, unit, and rounding precision:
35
37
  * NumberFormatter::with()
36
38
  * .notation(Notation::compactShort())
37
39
  * .unit(CurrencyUnit("EUR", status))
38
- * .rounding(Rounder::maxDigits(2))
40
+ * .precision(Precision::maxDigits(2))
39
41
  * .locale(...)
40
42
  * .format(1234)
41
43
  * .toString(); // €1.2K in en-US
@@ -43,7 +45,7 @@
43
45
  * // Create a formatter in a singleton for use later:
44
46
  * static const LocalizedNumberFormatter formatter = NumberFormatter::withLocale(...)
45
47
  * .unit(NoUnit::percent())
46
- * .rounding(Rounder::fixedFraction(3));
48
+ * .precision(Precision::fixedFraction(3));
47
49
  * formatter.format(5.9831).toString(); // 5.983% in en-US
48
50
  *
49
51
  * // Create a "template" in a singleton but without setting a locale until the call site:
@@ -63,7 +65,7 @@
63
65
  *
64
66
  * <pre>
65
67
  * UnlocalizedNumberFormatter formatter = UnlocalizedNumberFormatter::with().notation(Notation::scientific());
66
- * formatter.rounding(Rounder.maxFraction(2)); // does nothing!
68
+ * formatter.precision(Precision.maxFraction(2)); // does nothing!
67
69
  * formatter.locale(Locale.getEnglish()).format(9.8765).toString(); // prints "9.8765E0", not "9.88E0"
68
70
  * </pre>
69
71
  *
@@ -74,321 +76,23 @@
74
76
  * @author Shane Carr
75
77
  */
76
78
 
77
- /**
78
- * An enum declaring how to render units, including currencies. Example outputs when formatting 123 USD and 123
79
- * meters in <em>en-CA</em>:
80
- *
81
- * <p>
82
- * <ul>
83
- * <li>NARROW*: "$123.00" and "123 m"
84
- * <li>SHORT: "US$ 123.00" and "123 m"
85
- * <li>FULL_NAME: "123.00 US dollars" and "123 meters"
86
- * <li>ISO_CODE: "USD 123.00" and undefined behavior
87
- * <li>HIDDEN: "123.00" and "123"
88
- * </ul>
89
- *
90
- * <p>
91
- * This enum is similar to {@link com.ibm.icu.text.MeasureFormat.FormatWidth}.
92
- *
93
- * @draft ICU 60
94
- */
95
- typedef enum UNumberUnitWidth {
96
- /**
97
- * Print an abbreviated version of the unit name. Similar to SHORT, but always use the shortest available
98
- * abbreviation or symbol. This option can be used when the context hints at the identity of the unit. For more
99
- * information on the difference between NARROW and SHORT, see SHORT.
100
- *
101
- * <p>
102
- * In CLDR, this option corresponds to the "Narrow" format for measure units and the "¤¤¤¤¤" placeholder for
103
- * currencies.
104
- *
105
- * @draft ICU 60
106
- */
107
- UNUM_UNIT_WIDTH_NARROW,
108
-
109
- /**
110
- * Print an abbreviated version of the unit name. Similar to NARROW, but use a slightly wider abbreviation or
111
- * symbol when there may be ambiguity. This is the default behavior.
112
- *
113
- * <p>
114
- * For example, in <em>es-US</em>, the SHORT form for Fahrenheit is "{0} °F", but the NARROW form is "{0}°",
115
- * since Fahrenheit is the customary unit for temperature in that locale.
116
- *
117
- * <p>
118
- * In CLDR, this option corresponds to the "Short" format for measure units and the "¤" placeholder for
119
- * currencies.
120
- *
121
- * @draft ICU 60
122
- */
123
- UNUM_UNIT_WIDTH_SHORT,
124
-
125
- /**
126
- * Print the full name of the unit, without any abbreviations.
127
- *
128
- * <p>
129
- * In CLDR, this option corresponds to the default format for measure units and the "¤¤¤" placeholder for
130
- * currencies.
131
- *
132
- * @draft ICU 60
133
- */
134
- UNUM_UNIT_WIDTH_FULL_NAME,
135
-
136
- /**
137
- * Use the three-digit ISO XXX code in place of the symbol for displaying currencies. The behavior of this
138
- * option is currently undefined for use with measure units.
139
- *
140
- * <p>
141
- * In CLDR, this option corresponds to the "¤¤" placeholder for currencies.
142
- *
143
- * @draft ICU 60
144
- */
145
- UNUM_UNIT_WIDTH_ISO_CODE,
146
-
147
- /**
148
- * Format the number according to the specified unit, but do not display the unit. For currencies, apply
149
- * monetary symbols and formats as with SHORT, but omit the currency symbol. For measure units, the behavior is
150
- * equivalent to not specifying the unit at all.
151
- *
152
- * @draft ICU 60
153
- */
154
- UNUM_UNIT_WIDTH_HIDDEN
155
-
156
- #ifndef U_HIDE_INTERNAL_API
157
- ,
158
- /**
159
- * One more than the highest UNumberUnitWidth value.
160
- *
161
- * @internal ICU 60: The numeric value may change over time; see ICU ticket #12420.
162
- */
163
- UNUM_UNIT_WIDTH_COUNT
164
- #endif // U_HIDE_INTERNAL_API
165
- } UNumberUnitWidth;
166
-
167
- /**
168
- * An enum declaring the strategy for when and how to display grouping separators (i.e., the
169
- * separator, often a comma or period, after every 2-3 powers of ten). The choices are several
170
- * pre-built strategies for different use cases that employ locale data whenever possible. Example
171
- * outputs for 1234 and 1234567 in <em>en-IN</em>:
172
- *
173
- * <ul>
174
- * <li>OFF: 1234 and 12345
175
- * <li>MIN2: 1234 and 12,34,567
176
- * <li>AUTO: 1,234 and 12,34,567
177
- * <li>ON_ALIGNED: 1,234 and 12,34,567
178
- * <li>THOUSANDS: 1,234 and 1,234,567
179
- * </ul>
180
- *
181
- * <p>
182
- * The default is AUTO, which displays grouping separators unless the locale data says that grouping
183
- * is not customary. To force grouping for all numbers greater than 1000 consistently across locales,
184
- * use ON_ALIGNED. On the other hand, to display grouping less frequently than the default, use MIN2
185
- * or OFF. See the docs of each option for details.
186
- *
187
- * <p>
188
- * Note: This enum specifies the strategy for grouping sizes. To set which character to use as the
189
- * grouping separator, use the "symbols" setter.
190
- *
191
- * @draft ICU 61
192
- */
193
- typedef enum UGroupingStrategy {
194
- /**
195
- * Do not display grouping separators in any locale.
196
- *
197
- * @draft ICU 61
198
- */
199
- UNUM_GROUPING_OFF,
200
-
201
- /**
202
- * Display grouping using locale defaults, except do not show grouping on values smaller than
203
- * 10000 (such that there is a <em>minimum of two digits</em> before the first separator).
204
- *
205
- * <p>
206
- * Note that locales may restrict grouping separators to be displayed only on 1 million or
207
- * greater (for example, ee and hu) or disable grouping altogether (for example, bg currency).
208
- *
209
- * <p>
210
- * Locale data is used to determine whether to separate larger numbers into groups of 2
211
- * (customary in South Asia) or groups of 3 (customary in Europe and the Americas).
212
- *
213
- * @draft ICU 61
214
- */
215
- UNUM_GROUPING_MIN2,
216
-
217
- /**
218
- * Display grouping using the default strategy for all locales. This is the default behavior.
219
- *
220
- * <p>
221
- * Note that locales may restrict grouping separators to be displayed only on 1 million or
222
- * greater (for example, ee and hu) or disable grouping altogether (for example, bg currency).
223
- *
224
- * <p>
225
- * Locale data is used to determine whether to separate larger numbers into groups of 2
226
- * (customary in South Asia) or groups of 3 (customary in Europe and the Americas).
227
- *
228
- * @draft ICU 61
229
- */
230
- UNUM_GROUPING_AUTO,
231
-
232
- /**
233
- * Always display the grouping separator on values of at least 1000.
234
- *
235
- * <p>
236
- * This option ignores the locale data that restricts or disables grouping, described in MIN2 and
237
- * AUTO. This option may be useful to normalize the alignment of numbers, such as in a
238
- * spreadsheet.
239
- *
240
- * <p>
241
- * Locale data is used to determine whether to separate larger numbers into groups of 2
242
- * (customary in South Asia) or groups of 3 (customary in Europe and the Americas).
243
- *
244
- * @draft ICU 61
245
- */
246
- UNUM_GROUPING_ON_ALIGNED,
247
-
248
- /**
249
- * Use the Western defaults: groups of 3 and enabled for all numbers 1000 or greater. Do not use
250
- * locale data for determining the grouping strategy.
251
- *
252
- * @draft ICU 61
253
- */
254
- UNUM_GROUPING_THOUSANDS
255
-
256
- } UGroupingStrategy;
257
-
258
- /**
259
- * An enum declaring how to denote positive and negative numbers. Example outputs when formatting
260
- * 123, 0, and -123 in <em>en-US</em>:
261
- *
262
- * <ul>
263
- * <li>AUTO: "123", "0", and "-123"
264
- * <li>ALWAYS: "+123", "+0", and "-123"
265
- * <li>NEVER: "123", "0", and "123"
266
- * <li>ACCOUNTING: "$123", "$0", and "($123)"
267
- * <li>ACCOUNTING_ALWAYS: "+$123", "+$0", and "($123)"
268
- * <li>EXCEPT_ZERO: "+123", "0", and "-123"
269
- * <li>ACCOUNTING_EXCEPT_ZERO: "+$123", "$0", and "($123)"
270
- * </ul>
271
- *
272
- * <p>
273
- * The exact format, including the position and the code point of the sign, differ by locale.
274
- *
275
- * @draft ICU 60
276
- */
277
- typedef enum UNumberSignDisplay {
278
- /**
279
- * Show the minus sign on negative numbers, and do not show the sign on positive numbers. This is the default
280
- * behavior.
281
- *
282
- * @draft ICU 60
283
- */
284
- UNUM_SIGN_AUTO,
285
-
286
- /**
287
- * Show the minus sign on negative numbers and the plus sign on positive numbers, including zero.
288
- * To hide the sign on zero, see {@link UNUM_SIGN_EXCEPT_ZERO}.
289
- *
290
- * @draft ICU 60
291
- */
292
- UNUM_SIGN_ALWAYS,
293
-
294
- /**
295
- * Do not show the sign on positive or negative numbers.
296
- *
297
- * @draft ICU 60
298
- */
299
- UNUM_SIGN_NEVER,
300
-
301
- /**
302
- * Use the locale-dependent accounting format on negative numbers, and do not show the sign on positive numbers.
303
- *
304
- * <p>
305
- * The accounting format is defined in CLDR and varies by locale; in many Western locales, the format is a pair
306
- * of parentheses around the number.
307
- *
308
- * <p>
309
- * Note: Since CLDR defines the accounting format in the monetary context only, this option falls back to the
310
- * AUTO sign display strategy when formatting without a currency unit. This limitation may be lifted in the
311
- * future.
312
- *
313
- * @draft ICU 60
314
- */
315
- UNUM_SIGN_ACCOUNTING,
316
-
317
- /**
318
- * Use the locale-dependent accounting format on negative numbers, and show the plus sign on
319
- * positive numbers, including zero. For more information on the accounting format, see the
320
- * ACCOUNTING sign display strategy. To hide the sign on zero, see
321
- * {@link UNUM_SIGN_ACCOUNTING_EXCEPT_ZERO}.
322
- *
323
- * @draft ICU 60
324
- */
325
- UNUM_SIGN_ACCOUNTING_ALWAYS,
326
-
327
- /**
328
- * Show the minus sign on negative numbers and the plus sign on positive numbers. Do not show a
329
- * sign on zero.
330
- *
331
- * @draft ICU 61
332
- */
333
- UNUM_SIGN_EXCEPT_ZERO,
334
-
335
- /**
336
- * Use the locale-dependent accounting format on negative numbers, and show the plus sign on
337
- * positive numbers. Do not show a sign on zero. For more information on the accounting format,
338
- * see the ACCOUNTING sign display strategy.
339
- *
340
- * @draft ICU 61
341
- */
342
- UNUM_SIGN_ACCOUNTING_EXCEPT_ZERO
79
+ U_NAMESPACE_BEGIN
343
80
 
344
- #ifndef U_HIDE_INTERNAL_API
345
- ,
346
- /**
347
- * One more than the highest UNumberSignDisplay value.
348
- *
349
- * @internal ICU 60: The numeric value may change over time; see ICU ticket #12420.
350
- */
351
- UNUM_SIGN_COUNT
352
- #endif // U_HIDE_INTERNAL_API
353
- } UNumberSignDisplay;
81
+ // Forward declarations:
82
+ class IFixedDecimal;
83
+ class FieldPositionIteratorHandler;
354
84
 
355
- /**
356
- * An enum declaring how to render the decimal separator.
357
- *
358
- * <p>
359
- * <ul>
360
- * <li>UNUM_DECIMAL_SEPARATOR_AUTO: "1", "1.1"
361
- * <li>UNUM_DECIMAL_SEPARATOR_ALWAYS: "1.", "1.1"
362
- * </ul>
363
- */
364
- typedef enum UNumberDecimalSeparatorDisplay {
365
- /**
366
- * Show the decimal separator when there are one or more digits to display after the separator, and do not show
367
- * it otherwise. This is the default behavior.
368
- *
369
- * @draft ICU 60
370
- */
371
- UNUM_DECIMAL_SEPARATOR_AUTO,
85
+ namespace numparse {
86
+ namespace impl {
372
87
 
373
- /**
374
- * Always show the decimal separator, even if there are no digits to display after the separator.
375
- *
376
- * @draft ICU 60
377
- */
378
- UNUM_DECIMAL_SEPARATOR_ALWAYS
88
+ // Forward declarations:
89
+ class NumberParserImpl;
90
+ class MultiplierParseHandler;
379
91
 
380
- #ifndef U_HIDE_INTERNAL_API
381
- ,
382
- /**
383
- * One more than the highest UNumberDecimalSeparatorDisplay value.
384
- *
385
- * @internal ICU 60: The numeric value may change over time; see ICU ticket #12420.
386
- */
387
- UNUM_DECIMAL_SEPARATOR_COUNT
388
- #endif // U_HIDE_INTERNAL_API
389
- } UNumberDecimalMarkDisplay;
92
+ }
93
+ }
390
94
 
391
- U_NAMESPACE_BEGIN namespace number { // icu::number
95
+ namespace number { // icu::number
392
96
 
393
97
  // Forward declarations:
394
98
  class UnlocalizedNumberFormatter;
@@ -396,15 +100,14 @@ class LocalizedNumberFormatter;
396
100
  class FormattedNumber;
397
101
  class Notation;
398
102
  class ScientificNotation;
399
- class Rounder;
400
- class FractionRounder;
401
- class CurrencyRounder;
402
- class IncrementRounder;
103
+ class Precision;
104
+ class FractionPrecision;
105
+ class CurrencyPrecision;
106
+ class IncrementPrecision;
403
107
  class IntegerWidth;
404
108
 
405
109
  namespace impl {
406
110
 
407
- #ifndef U_HIDE_INTERNAL_API
408
111
  /**
409
112
  * Datatype for minimum/maximum fraction digits. Must be able to hold kMaxIntFracSig.
410
113
  *
@@ -419,24 +122,28 @@ typedef int16_t digits_t;
419
122
  * @internal
420
123
  */
421
124
  static constexpr int32_t DEFAULT_THRESHOLD = 3;
422
- #endif // U_HIDE_INTERNAL_API
423
125
 
424
126
  // Forward declarations:
425
127
  class Padder;
426
128
  struct MacroProps;
427
129
  struct MicroProps;
428
130
  class DecimalQuantity;
429
- struct NumberFormatterResults;
131
+ struct UFormattedNumberData;
430
132
  class NumberFormatterImpl;
431
133
  struct ParsedPatternInfo;
432
134
  class ScientificModifier;
433
135
  class MultiplierProducer;
434
- class MutablePatternModifier;
435
- class LongNameHandler;
136
+ class RoundingImpl;
436
137
  class ScientificHandler;
437
- class CompactHandler;
438
138
  class Modifier;
439
139
  class NumberStringBuilder;
140
+ class AffixPatternProvider;
141
+ class NumberPropertyMapper;
142
+ struct DecimalFormatProperties;
143
+ class MultiplierFormatHandler;
144
+ class CurrencySymbols;
145
+ class GeneratorHelpers;
146
+ class DecNum;
440
147
 
441
148
  } // namespace impl
442
149
 
@@ -530,13 +237,13 @@ class U_I18N_API Notation : public UMemory {
530
237
  * </pre>
531
238
  *
532
239
  * <p>
533
- * When compact notation is specified without an explicit rounding strategy, numbers are rounded off to the closest
240
+ * When compact notation is specified without an explicit rounding precision, numbers are rounded off to the closest
534
241
  * integer after scaling the number by the corresponding power of 10, but with a digit shown after the decimal
535
- * separator if there is only one digit before the decimal separator. The default compact notation rounding strategy
242
+ * separator if there is only one digit before the decimal separator. The default compact notation rounding precision
536
243
  * is equivalent to:
537
244
  *
538
245
  * <pre>
539
- * Rounder.integer().withMinDigits(2)
246
+ * Precision::integer().withMinDigits(2)
540
247
  * </pre>
541
248
  *
542
249
  * @return A CompactNotation for passing to the NumberFormatter notation() setter.
@@ -641,6 +348,9 @@ class U_I18N_API Notation : public UMemory {
641
348
  friend class impl::NumberFormatterImpl;
642
349
  friend class impl::ScientificModifier;
643
350
  friend class impl::ScientificHandler;
351
+
352
+ // To allow access to the skeleton generation code:
353
+ friend class impl::GeneratorHelpers;
644
354
  };
645
355
 
646
356
  /**
@@ -687,21 +397,36 @@ class U_I18N_API ScientificNotation : public Notation {
687
397
  // Inherit constructor
688
398
  using Notation::Notation;
689
399
 
400
+ // Raw constructor for NumberPropertyMapper
401
+ ScientificNotation(int8_t fEngineeringInterval, bool fRequireMinInt, impl::digits_t fMinExponentDigits,
402
+ UNumberSignDisplay fExponentSignDisplay);
403
+
690
404
  friend class Notation;
405
+
406
+ // So that NumberPropertyMapper can create instances
407
+ friend class impl::NumberPropertyMapper;
691
408
  };
692
409
 
693
410
  // Reserve extra names in case they are added as classes in the future:
694
- typedef Rounder DigitRounder;
411
+ typedef Precision SignificantDigitsPrecision;
412
+
413
+ // Typedefs for ICU 60/61 compatibility.
414
+ // These will be removed in ICU 64.
415
+ // See http://bugs.icu-project.org/trac/ticket/13746
416
+ typedef Precision Rounder;
417
+ typedef FractionPrecision FractionRounder;
418
+ typedef IncrementPrecision IncrementRounder;
419
+ typedef CurrencyPrecision CurrencyRounder;
695
420
 
696
421
  /**
697
- * A class that defines the rounding strategy to be used when formatting numbers in NumberFormatter.
422
+ * A class that defines the rounding precision to be used when formatting numbers in NumberFormatter.
698
423
  *
699
424
  * <p>
700
- * To create a Rounder, use one of the factory methods.
425
+ * To create a Precision, use one of the factory methods.
701
426
  *
702
427
  * @draft ICU 60
703
428
  */
704
- class U_I18N_API Rounder : public UMemory {
429
+ class U_I18N_API Precision : public UMemory {
705
430
 
706
431
  public:
707
432
  /**
@@ -717,18 +442,18 @@ class U_I18N_API Rounder : public UMemory {
717
442
  * <p>
718
443
  * http://www.serpentine.com/blog/2011/06/29/here-be-dragons-advances-in-problems-you-didnt-even-know-you-had/
719
444
  *
720
- * @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
445
+ * @return A Precision for chaining or passing to the NumberFormatter precision() setter.
721
446
  * @draft ICU 60
722
447
  */
723
- static Rounder unlimited();
448
+ static Precision unlimited();
724
449
 
725
450
  /**
726
451
  * Show numbers rounded if necessary to the nearest integer.
727
452
  *
728
- * @return A FractionRounder for chaining or passing to the NumberFormatter rounding() setter.
453
+ * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter.
729
454
  * @draft ICU 60
730
455
  */
731
- static FractionRounder integer();
456
+ static FractionPrecision integer();
732
457
 
733
458
  /**
734
459
  * Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator).
@@ -754,10 +479,10 @@ class U_I18N_API Rounder : public UMemory {
754
479
  * @param minMaxFractionPlaces
755
480
  * The minimum and maximum number of numerals to display after the decimal separator (rounding if too
756
481
  * long or padding with zeros if too short).
757
- * @return A FractionRounder for chaining or passing to the NumberFormatter rounding() setter.
482
+ * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter.
758
483
  * @draft ICU 60
759
484
  */
760
- static FractionRounder fixedFraction(int32_t minMaxFractionPlaces);
485
+ static FractionPrecision fixedFraction(int32_t minMaxFractionPlaces);
761
486
 
762
487
  /**
763
488
  * Always show at least a certain number of fraction places after the decimal separator, padding with zeros if
@@ -769,10 +494,10 @@ class U_I18N_API Rounder : public UMemory {
769
494
  * @param minFractionPlaces
770
495
  * The minimum number of numerals to display after the decimal separator (padding with zeros if
771
496
  * necessary).
772
- * @return A FractionRounder for chaining or passing to the NumberFormatter rounding() setter.
497
+ * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter.
773
498
  * @draft ICU 60
774
499
  */
775
- static FractionRounder minFraction(int32_t minFractionPlaces);
500
+ static FractionPrecision minFraction(int32_t minFractionPlaces);
776
501
 
777
502
  /**
778
503
  * Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator).
@@ -781,10 +506,10 @@ class U_I18N_API Rounder : public UMemory {
781
506
  *
782
507
  * @param maxFractionPlaces
783
508
  * The maximum number of numerals to display after the decimal mark (rounding if necessary).
784
- * @return A FractionRounder for chaining or passing to the NumberFormatter rounding() setter.
509
+ * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter.
785
510
  * @draft ICU 60
786
511
  */
787
- static FractionRounder maxFraction(int32_t maxFractionPlaces);
512
+ static FractionPrecision maxFraction(int32_t maxFractionPlaces);
788
513
 
789
514
  /**
790
515
  * Show numbers rounded if necessary to a certain number of fraction places (numerals after the decimal separator);
@@ -796,10 +521,10 @@ class U_I18N_API Rounder : public UMemory {
796
521
  * necessary).
797
522
  * @param maxFractionPlaces
798
523
  * The maximum number of numerals to display after the decimal separator (rounding if necessary).
799
- * @return A FractionRounder for chaining or passing to the NumberFormatter rounding() setter.
524
+ * @return A FractionPrecision for chaining or passing to the NumberFormatter precision() setter.
800
525
  * @draft ICU 60
801
526
  */
802
- static FractionRounder minMaxFraction(int32_t minFractionPlaces, int32_t maxFractionPlaces);
527
+ static FractionPrecision minMaxFraction(int32_t minFractionPlaces, int32_t maxFractionPlaces);
803
528
 
804
529
  /**
805
530
  * Show numbers rounded if necessary to a certain number of significant digits or significant figures. Additionally,
@@ -811,10 +536,10 @@ class U_I18N_API Rounder : public UMemory {
811
536
  * @param minMaxSignificantDigits
812
537
  * The minimum and maximum number of significant digits to display (rounding if too long or padding with
813
538
  * zeros if too short).
814
- * @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
815
- * @draft ICU 60
539
+ * @return A precision for chaining or passing to the NumberFormatter precision() setter.
540
+ * @draft ICU 62
816
541
  */
817
- static DigitRounder fixedDigits(int32_t minMaxSignificantDigits);
542
+ static SignificantDigitsPrecision fixedSignificantDigits(int32_t minMaxSignificantDigits);
818
543
 
819
544
  /**
820
545
  * Always show at least a certain number of significant digits/figures, padding with zeros if necessary. Do not
@@ -825,20 +550,20 @@ class U_I18N_API Rounder : public UMemory {
825
550
  *
826
551
  * @param minSignificantDigits
827
552
  * The minimum number of significant digits to display (padding with zeros if too short).
828
- * @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
829
- * @draft ICU 60
553
+ * @return A precision for chaining or passing to the NumberFormatter precision() setter.
554
+ * @draft ICU 62
830
555
  */
831
- static DigitRounder minDigits(int32_t minSignificantDigits);
556
+ static SignificantDigitsPrecision minSignificantDigits(int32_t minSignificantDigits);
832
557
 
833
558
  /**
834
559
  * Show numbers rounded if necessary to a certain number of significant digits/figures.
835
560
  *
836
561
  * @param maxSignificantDigits
837
562
  * The maximum number of significant digits to display (rounding if too long).
838
- * @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
839
- * @draft ICU 60
563
+ * @return A precision for chaining or passing to the NumberFormatter precision() setter.
564
+ * @draft ICU 62
840
565
  */
841
- static DigitRounder maxDigits(int32_t maxSignificantDigits);
566
+ static SignificantDigitsPrecision maxSignificantDigits(int32_t maxSignificantDigits);
842
567
 
843
568
  /**
844
569
  * Show numbers rounded if necessary to a certain number of significant digits/figures; in addition, always show at
@@ -848,10 +573,36 @@ class U_I18N_API Rounder : public UMemory {
848
573
  * The minimum number of significant digits to display (padding with zeros if necessary).
849
574
  * @param maxSignificantDigits
850
575
  * The maximum number of significant digits to display (rounding if necessary).
851
- * @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
852
- * @draft ICU 60
576
+ * @return A precision for chaining or passing to the NumberFormatter precision() setter.
577
+ * @draft ICU 62
853
578
  */
854
- static DigitRounder minMaxDigits(int32_t minSignificantDigits, int32_t maxSignificantDigits);
579
+ static SignificantDigitsPrecision minMaxSignificantDigits(int32_t minSignificantDigits,
580
+ int32_t maxSignificantDigits);
581
+
582
+ #ifndef U_HIDE_DEPRECATED_API
583
+ // Compatiblity methods that will be removed in ICU 64.
584
+ // See http://bugs.icu-project.org/trac/ticket/13746
585
+
586
+ /** @deprecated ICU 62 */
587
+ static inline SignificantDigitsPrecision fixedDigits(int32_t a) {
588
+ return fixedSignificantDigits(a);
589
+ }
590
+
591
+ /** @deprecated ICU 62 */
592
+ static inline SignificantDigitsPrecision minDigits(int32_t a) {
593
+ return minSignificantDigits(a);
594
+ }
595
+
596
+ /** @deprecated ICU 62 */
597
+ static inline SignificantDigitsPrecision maxDigits(int32_t a) {
598
+ return maxSignificantDigits(a);
599
+ }
600
+
601
+ /** @deprecated ICU 62 */
602
+ static inline SignificantDigitsPrecision minMaxDigits(int32_t a, int32_t b) {
603
+ return minMaxSignificantDigits(a, b);
604
+ }
605
+ #endif /* U_HIDE_DEPRECATED_API */
855
606
 
856
607
  /**
857
608
  * Show numbers rounded if necessary to the closest multiple of a certain rounding increment. For example, if the
@@ -864,20 +615,21 @@ class U_I18N_API Rounder : public UMemory {
864
615
  * decimal separator (to display 1.2 as "1.00" and 1.3 as "1.50"), you can run:
865
616
  *
866
617
  * <pre>
867
- * Rounder::increment(0.5).withMinFraction(2)
618
+ * Precision::increment(0.5).withMinFraction(2)
868
619
  * </pre>
869
620
  *
870
621
  * @param roundingIncrement
871
622
  * The increment to which to round numbers.
872
- * @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
623
+ * @return A precision for chaining or passing to the NumberFormatter precision() setter.
873
624
  * @draft ICU 60
874
625
  */
875
- static IncrementRounder increment(double roundingIncrement);
626
+ static IncrementPrecision increment(double roundingIncrement);
876
627
 
877
628
  /**
878
- * Show numbers rounded and padded according to the rules for the currency unit. The most common rounding settings
879
- * for currencies include <code>Rounder.fixedFraction(2)</code>, <code>Rounder.integer()</code>, and
880
- * <code>Rounder.increment(0.05)</code> for cash transactions ("nickel rounding").
629
+ * Show numbers rounded and padded according to the rules for the currency unit. The most common
630
+ * rounding precision settings for currencies include <code>Precision::fixedFraction(2)</code>,
631
+ * <code>Precision::integer()</code>, and <code>Precision::increment(0.05)</code> for cash transactions
632
+ * ("nickel rounding").
881
633
  *
882
634
  * <p>
883
635
  * The exact rounding details will be resolved at runtime based on the currency unit specified in the
@@ -887,24 +639,28 @@ class U_I18N_API Rounder : public UMemory {
887
639
  * @param currencyUsage
888
640
  * Either STANDARD (for digital transactions) or CASH (for transactions where the rounding increment may
889
641
  * be limited by the available denominations of cash or coins).
890
- * @return A CurrencyRounder for chaining or passing to the NumberFormatter rounding() setter.
642
+ * @return A CurrencyPrecision for chaining or passing to the NumberFormatter precision() setter.
891
643
  * @draft ICU 60
892
644
  */
893
- static CurrencyRounder currency(UCurrencyUsage currencyUsage);
645
+ static CurrencyPrecision currency(UCurrencyUsage currencyUsage);
894
646
 
647
+ #ifndef U_HIDE_DEPRECATED_API
895
648
  /**
896
649
  * Sets the rounding mode to use when picking the direction to round (up or down). Common values
897
650
  * include HALF_EVEN, HALF_UP, and FLOOR. The default is HALF_EVEN.
898
651
  *
899
652
  * @param roundingMode
900
653
  * The RoundingMode to use.
901
- * @return A Rounder for passing to the NumberFormatter rounding() setter.
902
- * @draft ICU 60
654
+ * @return A Precision for passing to the NumberFormatter precision() setter.
655
+ * @deprecated ICU 62 Use the top-level roundingMode() setting instead.
656
+ * This method will be removed in ICU 64.
657
+ * See http://bugs.icu-project.org/trac/ticket/13746
903
658
  */
904
- Rounder withMode(UNumberFormatRoundingMode roundingMode) const;
659
+ Precision withMode(UNumberFormatRoundingMode roundingMode) const;
660
+ #endif /* U_HIDE_DEPRECATED_API */
905
661
 
906
662
  private:
907
- enum RounderType {
663
+ enum PrecisionType {
908
664
  RND_BOGUS,
909
665
  RND_NONE,
910
666
  RND_FRACTION,
@@ -912,11 +668,10 @@ class U_I18N_API Rounder : public UMemory {
912
668
  RND_FRACTION_SIGNIFICANT,
913
669
  RND_INCREMENT,
914
670
  RND_CURRENCY,
915
- RND_PASS_THROUGH,
916
671
  RND_ERROR
917
672
  } fType;
918
673
 
919
- union RounderUnion {
674
+ union PrecisionUnion {
920
675
  struct FractionSignificantSettings {
921
676
  // For RND_FRACTION, RND_SIGNIFICANT, and RND_FRACTION_SIGNIFICANT
922
677
  impl::digits_t fMinFrac;
@@ -927,24 +682,27 @@ class U_I18N_API Rounder : public UMemory {
927
682
  struct IncrementSettings {
928
683
  double fIncrement;
929
684
  impl::digits_t fMinFrac;
685
+ impl::digits_t fMaxFrac;
930
686
  } increment; // For RND_INCREMENT
931
687
  UCurrencyUsage currencyUsage; // For RND_CURRENCY
932
688
  UErrorCode errorCode; // For RND_ERROR
933
689
  } fUnion;
934
690
 
935
- typedef RounderUnion::FractionSignificantSettings FractionSignificantSettings;
936
- typedef RounderUnion::IncrementSettings IncrementSettings;
691
+ typedef PrecisionUnion::FractionSignificantSettings FractionSignificantSettings;
692
+ typedef PrecisionUnion::IncrementSettings IncrementSettings;
937
693
 
694
+ /** The Precision encapsulates the RoundingMode when used within the implementation. */
938
695
  UNumberFormatRoundingMode fRoundingMode;
939
696
 
940
- Rounder(const RounderType &type, const RounderUnion &union_, UNumberFormatRoundingMode roundingMode)
697
+ Precision(const PrecisionType& type, const PrecisionUnion& union_,
698
+ UNumberFormatRoundingMode roundingMode)
941
699
  : fType(type), fUnion(union_), fRoundingMode(roundingMode) {}
942
700
 
943
- Rounder(UErrorCode errorCode) : fType(RND_ERROR) {
701
+ Precision(UErrorCode errorCode) : fType(RND_ERROR) {
944
702
  fUnion.errorCode = errorCode;
945
703
  }
946
704
 
947
- Rounder() : fType(RND_BOGUS) {}
705
+ Precision() : fType(RND_BOGUS) {}
948
706
 
949
707
  bool isBogus() const {
950
708
  return fType == RND_BOGUS;
@@ -958,47 +716,21 @@ class U_I18N_API Rounder : public UMemory {
958
716
  return FALSE;
959
717
  }
960
718
 
961
- // On the parent type so that this method can be called internally on Rounder instances.
962
- Rounder withCurrency(const CurrencyUnit &currency, UErrorCode &status) const;
963
-
964
- /** NON-CONST: mutates the current instance. */
965
- void setLocaleData(const CurrencyUnit &currency, UErrorCode &status);
966
-
967
- void apply(impl::DecimalQuantity &value, UErrorCode &status) const;
968
-
969
- /** Version of {@link #apply} that obeys minInt constraints. Used for scientific notation compatibility mode. */
970
- void apply(impl::DecimalQuantity &value, int32_t minInt, UErrorCode status);
971
-
972
- /**
973
- * Rounding endpoint used by Engineering and Compact notation. Chooses the most appropriate multiplier (magnitude
974
- * adjustment), applies the adjustment, rounds, and returns the chosen multiplier.
975
- *
976
- * <p>
977
- * In most cases, this is simple. However, when rounding the number causes it to cross a multiplier boundary, we
978
- * need to re-do the rounding. For example, to display 999,999 in Engineering notation with 2 sigfigs, first you
979
- * guess the multiplier to be -3. However, then you end up getting 1000E3, which is not the correct output. You then
980
- * change your multiplier to be -6, and you get 1.0E6, which is correct.
981
- *
982
- * @param input The quantity to process.
983
- * @param producer Function to call to return a multiplier based on a magnitude.
984
- * @return The number of orders of magnitude the input was adjusted by this method.
985
- */
986
- int32_t
987
- chooseMultiplierAndApply(impl::DecimalQuantity &input, const impl::MultiplierProducer &producer,
988
- UErrorCode &status);
719
+ // On the parent type so that this method can be called internally on Precision instances.
720
+ Precision withCurrency(const CurrencyUnit &currency, UErrorCode &status) const;
989
721
 
990
- static FractionRounder constructFraction(int32_t minFrac, int32_t maxFrac);
722
+ static FractionPrecision constructFraction(int32_t minFrac, int32_t maxFrac);
991
723
 
992
- static Rounder constructSignificant(int32_t minSig, int32_t maxSig);
724
+ static Precision constructSignificant(int32_t minSig, int32_t maxSig);
993
725
 
994
- static Rounder
995
- constructFractionSignificant(const FractionRounder &base, int32_t minSig, int32_t maxSig);
726
+ static Precision
727
+ constructFractionSignificant(const FractionPrecision &base, int32_t minSig, int32_t maxSig);
996
728
 
997
- static IncrementRounder constructIncrement(double increment, int32_t minFrac);
729
+ static IncrementPrecision constructIncrement(double increment, int32_t minFrac);
998
730
 
999
- static CurrencyRounder constructCurrency(UCurrencyUsage usage);
731
+ static CurrencyPrecision constructCurrency(UCurrencyUsage usage);
1000
732
 
1001
- static Rounder constructPassThrough();
733
+ static Precision constructPassThrough();
1002
734
 
1003
735
  // To allow MacroProps/MicroProps to initialize bogus instances:
1004
736
  friend struct impl::MacroProps;
@@ -1007,28 +739,31 @@ class U_I18N_API Rounder : public UMemory {
1007
739
  // To allow NumberFormatterImpl to access isBogus() and other internal methods:
1008
740
  friend class impl::NumberFormatterImpl;
1009
741
 
1010
- // To give access to apply() and chooseMultiplierAndApply():
1011
- friend class impl::MutablePatternModifier;
1012
- friend class impl::LongNameHandler;
1013
- friend class impl::ScientificHandler;
1014
- friend class impl::CompactHandler;
742
+ // To allow NumberPropertyMapper to create instances from DecimalFormatProperties:
743
+ friend class impl::NumberPropertyMapper;
744
+
745
+ // To allow access to the main implementation class:
746
+ friend class impl::RoundingImpl;
1015
747
 
1016
748
  // To allow child classes to call private methods:
1017
- friend class FractionRounder;
1018
- friend class CurrencyRounder;
1019
- friend class IncrementRounder;
749
+ friend class FractionPrecision;
750
+ friend class CurrencyPrecision;
751
+ friend class IncrementPrecision;
752
+
753
+ // To allow access to the skeleton generation code:
754
+ friend class impl::GeneratorHelpers;
1020
755
  };
1021
756
 
1022
757
  /**
1023
- * A class that defines a rounding strategy based on a number of fraction places and optionally significant digits to be
758
+ * A class that defines a rounding precision based on a number of fraction places and optionally significant digits to be
1024
759
  * used when formatting numbers in NumberFormatter.
1025
760
  *
1026
761
  * <p>
1027
- * To create a FractionRounder, use one of the factory methods on Rounder.
762
+ * To create a FractionPrecision, use one of the factory methods on Precision.
1028
763
  *
1029
764
  * @draft ICU 60
1030
765
  */
1031
- class U_I18N_API FractionRounder : public Rounder {
766
+ class U_I18N_API FractionPrecision : public Precision {
1032
767
  public:
1033
768
  /**
1034
769
  * Ensure that no less than this number of significant digits are retained when rounding according to fraction
@@ -1043,10 +778,10 @@ class U_I18N_API FractionRounder : public Rounder {
1043
778
  *
1044
779
  * @param minSignificantDigits
1045
780
  * The number of significant figures to guarantee.
1046
- * @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
781
+ * @return A precision for chaining or passing to the NumberFormatter precision() setter.
1047
782
  * @draft ICU 60
1048
783
  */
1049
- Rounder withMinDigits(int32_t minSignificantDigits) const;
784
+ Precision withMinDigits(int32_t minSignificantDigits) const;
1050
785
 
1051
786
  /**
1052
787
  * Ensure that no more than this number of significant digits are retained when rounding according to fraction
@@ -1062,36 +797,36 @@ class U_I18N_API FractionRounder : public Rounder {
1062
797
  *
1063
798
  * @param maxSignificantDigits
1064
799
  * Round the number to no more than this number of significant figures.
1065
- * @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
800
+ * @return A precision for chaining or passing to the NumberFormatter precision() setter.
1066
801
  * @draft ICU 60
1067
802
  */
1068
- Rounder withMaxDigits(int32_t maxSignificantDigits) const;
803
+ Precision withMaxDigits(int32_t maxSignificantDigits) const;
1069
804
 
1070
805
  private:
1071
806
  // Inherit constructor
1072
- using Rounder::Rounder;
807
+ using Precision::Precision;
1073
808
 
1074
809
  // To allow parent class to call this class's constructor:
1075
- friend class Rounder;
810
+ friend class Precision;
1076
811
  };
1077
812
 
1078
813
  /**
1079
- * A class that defines a rounding strategy parameterized by a currency to be used when formatting numbers in
814
+ * A class that defines a rounding precision parameterized by a currency to be used when formatting numbers in
1080
815
  * NumberFormatter.
1081
816
  *
1082
817
  * <p>
1083
- * To create a CurrencyRounder, use one of the factory methods on Rounder.
818
+ * To create a CurrencyPrecision, use one of the factory methods on Precision.
1084
819
  *
1085
820
  * @draft ICU 60
1086
821
  */
1087
- class U_I18N_API CurrencyRounder : public Rounder {
822
+ class U_I18N_API CurrencyPrecision : public Precision {
1088
823
  public:
1089
824
  /**
1090
- * Associates a currency with this rounding strategy.
825
+ * Associates a currency with this rounding precision.
1091
826
  *
1092
827
  * <p>
1093
828
  * <strong>Calling this method is <em>not required</em></strong>, because the currency specified in unit()
1094
- * is automatically applied to currency rounding strategies. However,
829
+ * is automatically applied to currency rounding precisions. However,
1095
830
  * this method enables you to override that automatic association.
1096
831
  *
1097
832
  * <p>
@@ -1099,30 +834,30 @@ class U_I18N_API CurrencyRounder : public Rounder {
1099
834
  * currency format.
1100
835
  *
1101
836
  * @param currency
1102
- * The currency to associate with this rounding strategy.
1103
- * @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
837
+ * The currency to associate with this rounding precision.
838
+ * @return A precision for chaining or passing to the NumberFormatter precision() setter.
1104
839
  * @draft ICU 60
1105
840
  */
1106
- Rounder withCurrency(const CurrencyUnit &currency) const;
841
+ Precision withCurrency(const CurrencyUnit &currency) const;
1107
842
 
1108
843
  private:
1109
844
  // Inherit constructor
1110
- using Rounder::Rounder;
845
+ using Precision::Precision;
1111
846
 
1112
847
  // To allow parent class to call this class's constructor:
1113
- friend class Rounder;
848
+ friend class Precision;
1114
849
  };
1115
850
 
1116
851
  /**
1117
- * A class that defines a rounding strategy parameterized by a rounding increment to be used when formatting numbers in
852
+ * A class that defines a rounding precision parameterized by a rounding increment to be used when formatting numbers in
1118
853
  * NumberFormatter.
1119
854
  *
1120
855
  * <p>
1121
- * To create an IncrementRounder, use one of the factory methods on Rounder.
856
+ * To create an IncrementPrecision, use one of the factory methods on Precision.
1122
857
  *
1123
858
  * @draft ICU 60
1124
859
  */
1125
- class U_I18N_API IncrementRounder : public Rounder {
860
+ class U_I18N_API IncrementPrecision : public Precision {
1126
861
  public:
1127
862
  /**
1128
863
  * Specifies the minimum number of fraction digits to render after the decimal separator, padding with zeros if
@@ -1136,17 +871,17 @@ class U_I18N_API IncrementRounder : public Rounder {
1136
871
  * Note: In ICU4J, this functionality is accomplished via the scale of the BigDecimal rounding increment.
1137
872
  *
1138
873
  * @param minFrac The minimum number of digits after the decimal separator.
1139
- * @return A Rounder for chaining or passing to the NumberFormatter rounding() setter.
874
+ * @return A precision for chaining or passing to the NumberFormatter precision() setter.
1140
875
  * @draft ICU 60
1141
876
  */
1142
- Rounder withMinFraction(int32_t minFrac) const;
877
+ Precision withMinFraction(int32_t minFrac) const;
1143
878
 
1144
879
  private:
1145
880
  // Inherit constructor
1146
- using Rounder::Rounder;
881
+ using Precision::Precision;
1147
882
 
1148
883
  // To allow parent class to call this class's constructor:
1149
- friend class Rounder;
884
+ friend class Precision;
1150
885
  };
1151
886
 
1152
887
  /**
@@ -1170,7 +905,6 @@ class U_I18N_API IntegerWidth : public UMemory {
1170
905
  * The minimum number of places before the decimal separator.
1171
906
  * @return An IntegerWidth for chaining or passing to the NumberFormatter integerWidth() setter.
1172
907
  * @draft ICU 60
1173
- * @see NumberFormatter
1174
908
  */
1175
909
  static IntegerWidth zeroFillTo(int32_t minInt);
1176
910
 
@@ -1184,7 +918,6 @@ class U_I18N_API IntegerWidth : public UMemory {
1184
918
  * truncation.
1185
919
  * @return An IntegerWidth for passing to the NumberFormatter integerWidth() setter.
1186
920
  * @draft ICU 60
1187
- * @see NumberFormatter
1188
921
  */
1189
922
  IntegerWidth truncateAt(int32_t maxInt);
1190
923
 
@@ -1193,12 +926,13 @@ class U_I18N_API IntegerWidth : public UMemory {
1193
926
  struct {
1194
927
  impl::digits_t fMinInt;
1195
928
  impl::digits_t fMaxInt;
929
+ bool fFormatFailIfMoreThanMaxDigits;
1196
930
  } minMaxInt;
1197
931
  UErrorCode errorCode;
1198
932
  } fUnion;
1199
933
  bool fHasError = false;
1200
934
 
1201
- IntegerWidth(impl::digits_t minInt, impl::digits_t maxInt);
935
+ IntegerWidth(impl::digits_t minInt, impl::digits_t maxInt, bool formatFailIfMoreThanMaxDigits);
1202
936
 
1203
937
  IntegerWidth(UErrorCode errorCode) { // NOLINT
1204
938
  fUnion.errorCode = errorCode;
@@ -1209,6 +943,11 @@ class U_I18N_API IntegerWidth : public UMemory {
1209
943
  fUnion.minMaxInt.fMinInt = -1;
1210
944
  }
1211
945
 
946
+ /** Returns the default instance. */
947
+ static IntegerWidth standard() {
948
+ return IntegerWidth::zeroFillTo(1);
949
+ }
950
+
1212
951
  bool isBogus() const {
1213
952
  return !fHasError && fUnion.minMaxInt.fMinInt == -1;
1214
953
  }
@@ -1223,69 +962,214 @@ class U_I18N_API IntegerWidth : public UMemory {
1223
962
 
1224
963
  void apply(impl::DecimalQuantity &quantity, UErrorCode &status) const;
1225
964
 
965
+ bool operator==(const IntegerWidth& other) const;
966
+
1226
967
  // To allow MacroProps/MicroProps to initialize empty instances:
1227
968
  friend struct impl::MacroProps;
1228
969
  friend struct impl::MicroProps;
1229
970
 
1230
971
  // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1231
972
  friend class impl::NumberFormatterImpl;
1232
- };
1233
-
1234
- namespace impl {
1235
-
1236
- // Do not enclose entire SymbolsWrapper with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1237
- /** @internal */
1238
- class U_I18N_API SymbolsWrapper : public UMemory {
1239
- public:
1240
- /** @internal */
1241
- SymbolsWrapper() : fType(SYMPTR_NONE), fPtr{nullptr} {}
1242
973
 
1243
- /** @internal */
1244
- SymbolsWrapper(const SymbolsWrapper &other);
1245
-
1246
- /** @internal */
1247
- ~SymbolsWrapper();
974
+ // So that NumberPropertyMapper can create instances
975
+ friend class impl::NumberPropertyMapper;
1248
976
 
1249
- /** @internal */
1250
- SymbolsWrapper &operator=(const SymbolsWrapper &other);
977
+ // To allow access to the skeleton generation code:
978
+ friend class impl::GeneratorHelpers;
979
+ };
1251
980
 
1252
- #ifndef U_HIDE_INTERNAL_API
981
+ /**
982
+ * A class that defines a quantity by which a number should be multiplied when formatting.
983
+ *
984
+ * <p>
985
+ * To create a Scale, use one of the factory methods.
986
+ *
987
+ * @draft ICU 62
988
+ */
989
+ class U_I18N_API Scale : public UMemory {
990
+ public:
1253
991
  /**
1254
- * The provided object is copied, but we do not adopt it.
1255
- * @internal
992
+ * Do not change the value of numbers when formatting or parsing.
993
+ *
994
+ * @return A Scale to prevent any multiplication.
995
+ * @draft ICU 62
1256
996
  */
1257
- void setTo(const DecimalFormatSymbols &dfs);
997
+ static Scale none();
1258
998
 
1259
999
  /**
1260
- * Adopt the provided object.
1261
- * @internal
1000
+ * Multiply numbers by a power of ten before formatting. Useful for combining with a percent unit:
1001
+ *
1002
+ * <pre>
1003
+ * NumberFormatter::with().unit(NoUnit::percent()).multiplier(Scale::powerOfTen(2))
1004
+ * </pre>
1005
+ *
1006
+ * @return A Scale for passing to the setter in NumberFormatter.
1007
+ * @draft ICU 62
1262
1008
  */
1263
- void setTo(const NumberingSystem *ns);
1009
+ static Scale powerOfTen(int32_t power);
1264
1010
 
1265
1011
  /**
1266
- * Whether the object is currently holding a DecimalFormatSymbols.
1267
- * @internal
1012
+ * Multiply numbers by an arbitrary value before formatting. Useful for unit conversions.
1013
+ *
1014
+ * This method takes a string in a decimal number format with syntax
1015
+ * as defined in the Decimal Arithmetic Specification, available at
1016
+ * http://speleotrove.com/decimal
1017
+ *
1018
+ * Also see the version of this method that takes a double.
1019
+ *
1020
+ * @return A Scale for passing to the setter in NumberFormatter.
1021
+ * @draft ICU 62
1268
1022
  */
1269
- bool isDecimalFormatSymbols() const;
1023
+ static Scale byDecimal(StringPiece multiplicand);
1270
1024
 
1271
1025
  /**
1272
- * Whether the object is currently holding a NumberingSystem.
1273
- * @internal
1026
+ * Multiply numbers by an arbitrary value before formatting. Useful for unit conversions.
1027
+ *
1028
+ * This method takes a double; also see the version of this method that takes an exact decimal.
1029
+ *
1030
+ * @return A Scale for passing to the setter in NumberFormatter.
1031
+ * @draft ICU 62
1274
1032
  */
1275
- bool isNumberingSystem() const;
1033
+ static Scale byDouble(double multiplicand);
1276
1034
 
1277
1035
  /**
1278
- * Get the DecimalFormatSymbols pointer. No ownership change.
1279
- * @internal
1036
+ * Multiply a number by both a power of ten and by an arbitrary double value.
1037
+ *
1038
+ * @return A Scale for passing to the setter in NumberFormatter.
1039
+ * @draft ICU 62
1280
1040
  */
1281
- const DecimalFormatSymbols *getDecimalFormatSymbols() const;
1041
+ static Scale byDoubleAndPowerOfTen(double multiplicand, int32_t power);
1282
1042
 
1283
- /**
1043
+ // We need a custom destructor for the DecNum, which means we need to declare
1044
+ // the copy/move constructor/assignment quartet.
1045
+
1046
+ /** @draft ICU 62 */
1047
+ Scale(const Scale& other);
1048
+
1049
+ /** @draft ICU 62 */
1050
+ Scale& operator=(const Scale& other);
1051
+
1052
+ /** @draft ICU 62 */
1053
+ Scale(Scale&& src) U_NOEXCEPT;
1054
+
1055
+ /** @draft ICU 62 */
1056
+ Scale& operator=(Scale&& src) U_NOEXCEPT;
1057
+
1058
+ /** @draft ICU 62 */
1059
+ ~Scale();
1060
+
1061
+ #ifndef U_HIDE_INTERNAL_API
1062
+ /** @internal */
1063
+ Scale(int32_t magnitude, impl::DecNum* arbitraryToAdopt);
1064
+ #endif /* U_HIDE_INTERNAL_API */
1065
+
1066
+ private:
1067
+ int32_t fMagnitude;
1068
+ impl::DecNum* fArbitrary;
1069
+ UErrorCode fError;
1070
+
1071
+ Scale(UErrorCode error) : fMagnitude(0), fArbitrary(nullptr), fError(error) {}
1072
+
1073
+ Scale() : fMagnitude(0), fArbitrary(nullptr), fError(U_ZERO_ERROR) {}
1074
+
1075
+ bool isValid() const {
1076
+ return fMagnitude != 0 || fArbitrary != nullptr;
1077
+ }
1078
+
1079
+ UBool copyErrorTo(UErrorCode &status) const {
1080
+ if (fError != U_ZERO_ERROR) {
1081
+ status = fError;
1082
+ return TRUE;
1083
+ }
1084
+ return FALSE;
1085
+ }
1086
+
1087
+ void applyTo(impl::DecimalQuantity& quantity) const;
1088
+
1089
+ void applyReciprocalTo(impl::DecimalQuantity& quantity) const;
1090
+
1091
+ // To allow MacroProps/MicroProps to initialize empty instances:
1092
+ friend struct impl::MacroProps;
1093
+ friend struct impl::MicroProps;
1094
+
1095
+ // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1096
+ friend class impl::NumberFormatterImpl;
1097
+
1098
+ // To allow the helper class MultiplierFormatHandler access to private fields:
1099
+ friend class impl::MultiplierFormatHandler;
1100
+
1101
+ // To allow access to the skeleton generation code:
1102
+ friend class impl::GeneratorHelpers;
1103
+
1104
+ // To allow access to parsing code:
1105
+ friend class ::icu::numparse::impl::NumberParserImpl;
1106
+ friend class ::icu::numparse::impl::MultiplierParseHandler;
1107
+ };
1108
+
1109
+ namespace impl {
1110
+
1111
+ // Do not enclose entire SymbolsWrapper with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
1112
+ /** @internal */
1113
+ class U_I18N_API SymbolsWrapper : public UMemory {
1114
+ public:
1115
+ /** @internal */
1116
+ SymbolsWrapper() : fType(SYMPTR_NONE), fPtr{nullptr} {}
1117
+
1118
+ /** @internal */
1119
+ SymbolsWrapper(const SymbolsWrapper &other);
1120
+
1121
+ /** @internal */
1122
+ SymbolsWrapper &operator=(const SymbolsWrapper &other);
1123
+
1124
+ /** @internal */
1125
+ SymbolsWrapper(SymbolsWrapper&& src) U_NOEXCEPT;
1126
+
1127
+ /** @internal */
1128
+ SymbolsWrapper &operator=(SymbolsWrapper&& src) U_NOEXCEPT;
1129
+
1130
+ /** @internal */
1131
+ ~SymbolsWrapper();
1132
+
1133
+ #ifndef U_HIDE_INTERNAL_API
1134
+
1135
+ /**
1136
+ * The provided object is copied, but we do not adopt it.
1137
+ * @internal
1138
+ */
1139
+ void setTo(const DecimalFormatSymbols &dfs);
1140
+
1141
+ /**
1142
+ * Adopt the provided object.
1143
+ * @internal
1144
+ */
1145
+ void setTo(const NumberingSystem *ns);
1146
+
1147
+ /**
1148
+ * Whether the object is currently holding a DecimalFormatSymbols.
1149
+ * @internal
1150
+ */
1151
+ bool isDecimalFormatSymbols() const;
1152
+
1153
+ /**
1154
+ * Whether the object is currently holding a NumberingSystem.
1155
+ * @internal
1156
+ */
1157
+ bool isNumberingSystem() const;
1158
+
1159
+ /**
1160
+ * Get the DecimalFormatSymbols pointer. No ownership change.
1161
+ * @internal
1162
+ */
1163
+ const DecimalFormatSymbols *getDecimalFormatSymbols() const;
1164
+
1165
+ /**
1284
1166
  * Get the NumberingSystem pointer. No ownership change.
1285
1167
  * @internal
1286
1168
  */
1287
1169
  const NumberingSystem *getNumberingSystem() const;
1288
1170
 
1171
+ #endif // U_HIDE_INTERNAL_API
1172
+
1289
1173
  /** @internal */
1290
1174
  UBool copyErrorTo(UErrorCode &status) const {
1291
1175
  if (fType == SYMPTR_DFS && fPtr.dfs == nullptr) {
@@ -1297,7 +1181,6 @@ class U_I18N_API SymbolsWrapper : public UMemory {
1297
1181
  }
1298
1182
  return FALSE;
1299
1183
  }
1300
- #endif // U_HIDE_INTERNAL_API
1301
1184
 
1302
1185
  private:
1303
1186
  enum SymbolsPointerType {
@@ -1311,6 +1194,8 @@ class U_I18N_API SymbolsWrapper : public UMemory {
1311
1194
 
1312
1195
  void doCopyFrom(const SymbolsWrapper &other);
1313
1196
 
1197
+ void doMoveFrom(SymbolsWrapper&& src);
1198
+
1314
1199
  void doCleanup();
1315
1200
  };
1316
1201
 
@@ -1322,13 +1207,28 @@ class U_I18N_API Grouper : public UMemory {
1322
1207
  /** @internal */
1323
1208
  static Grouper forStrategy(UGroupingStrategy grouping);
1324
1209
 
1210
+ /**
1211
+ * Resolve the values in Properties to a Grouper object.
1212
+ * @internal
1213
+ */
1214
+ static Grouper forProperties(const DecimalFormatProperties& properties);
1215
+
1325
1216
  // Future: static Grouper forProperties(DecimalFormatProperties& properties);
1326
1217
 
1327
1218
  /** @internal */
1328
- Grouper(int16_t grouping1, int16_t grouping2, int16_t minGrouping)
1329
- : fGrouping1(grouping1), fGrouping2(grouping2), fMinGrouping(minGrouping) {}
1219
+ Grouper(int16_t grouping1, int16_t grouping2, int16_t minGrouping, UGroupingStrategy strategy)
1220
+ : fGrouping1(grouping1),
1221
+ fGrouping2(grouping2),
1222
+ fMinGrouping(minGrouping),
1223
+ fStrategy(strategy) {}
1330
1224
  #endif // U_HIDE_INTERNAL_API
1331
1225
 
1226
+ /** @internal */
1227
+ int16_t getPrimary() const;
1228
+
1229
+ /** @internal */
1230
+ int16_t getSecondary() const;
1231
+
1332
1232
  private:
1333
1233
  /**
1334
1234
  * The grouping sizes, with the following special values:
@@ -1342,7 +1242,7 @@ class U_I18N_API Grouper : public UMemory {
1342
1242
  int16_t fGrouping2;
1343
1243
 
1344
1244
  /**
1345
- * The minimum gropuing size, with the following special values:
1245
+ * The minimum grouping size, with the following special values:
1346
1246
  * <ul>
1347
1247
  * <li>-2 = needs locale data
1348
1248
  * <li>-3 = no less than 2
@@ -1350,6 +1250,12 @@ class U_I18N_API Grouper : public UMemory {
1350
1250
  */
1351
1251
  int16_t fMinGrouping;
1352
1252
 
1253
+ /**
1254
+ * The UGroupingStrategy that was used to create this Grouper, or UNUM_GROUPING_COUNT if this
1255
+ * was not created from a UGroupingStrategy.
1256
+ */
1257
+ UGroupingStrategy fStrategy;
1258
+
1353
1259
  Grouper() : fGrouping1(-3) {};
1354
1260
 
1355
1261
  bool isBogus() const {
@@ -1367,6 +1273,12 @@ class U_I18N_API Grouper : public UMemory {
1367
1273
 
1368
1274
  // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1369
1275
  friend class NumberFormatterImpl;
1276
+
1277
+ // To allow NumberParserImpl to perform setLocaleData():
1278
+ friend class ::icu::numparse::impl::NumberParserImpl;
1279
+
1280
+ // To allow access to the skeleton generation code:
1281
+ friend class impl::GeneratorHelpers;
1370
1282
  };
1371
1283
 
1372
1284
  // Do not enclose entire Padder with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
@@ -1381,6 +1293,9 @@ class U_I18N_API Padder : public UMemory {
1381
1293
  static Padder codePoints(UChar32 cp, int32_t targetWidth, UNumberFormatPadPosition position);
1382
1294
  #endif // U_HIDE_INTERNAL_API
1383
1295
 
1296
+ /** @internal */
1297
+ static Padder forProperties(const DecimalFormatProperties& properties);
1298
+
1384
1299
  private:
1385
1300
  UChar32 fWidth; // -3 = error; -2 = bogus; -1 = no padding
1386
1301
  union {
@@ -1427,6 +1342,9 @@ class U_I18N_API Padder : public UMemory {
1427
1342
 
1428
1343
  // To allow NumberFormatterImpl to access isBogus() and perform other operations:
1429
1344
  friend class impl::NumberFormatterImpl;
1345
+
1346
+ // To allow access to the skeleton generation code:
1347
+ friend class impl::GeneratorHelpers;
1430
1348
  };
1431
1349
 
1432
1350
  // Do not enclose entire MacroProps with #ifndef U_HIDE_INTERNAL_API, needed for a protected field
@@ -1442,7 +1360,10 @@ struct U_I18N_API MacroProps : public UMemory {
1442
1360
  MeasureUnit perUnit; // = NoUnit::base();
1443
1361
 
1444
1362
  /** @internal */
1445
- Rounder rounder; // = Rounder(); (bogus)
1363
+ Precision precision; // = Precision(); (bogus)
1364
+
1365
+ /** @internal */
1366
+ UNumberFormatRoundingMode roundingMode = UNUM_ROUND_HALFEVEN;
1446
1367
 
1447
1368
  /** @internal */
1448
1369
  Grouper grouper; // = Grouper(); (bogus)
@@ -1468,20 +1389,33 @@ struct U_I18N_API MacroProps : public UMemory {
1468
1389
  UNumberDecimalSeparatorDisplay decimal = UNUM_DECIMAL_SEPARATOR_COUNT;
1469
1390
 
1470
1391
  /** @internal */
1471
- PluralRules *rules = nullptr; // no ownership
1392
+ Scale scale; // = Scale(); (benign value)
1393
+
1394
+ /** @internal */
1395
+ const AffixPatternProvider* affixProvider = nullptr; // no ownership
1396
+
1397
+ /** @internal */
1398
+ const PluralRules* rules = nullptr; // no ownership
1399
+
1400
+ /** @internal */
1401
+ const CurrencySymbols* currencySymbols = nullptr; // no ownership
1472
1402
 
1473
1403
  /** @internal */
1474
1404
  int32_t threshold = DEFAULT_THRESHOLD;
1405
+
1406
+ /** @internal */
1475
1407
  Locale locale;
1476
1408
 
1409
+ // NOTE: Uses default copy and move constructors.
1410
+
1477
1411
  /**
1478
1412
  * Check all members for errors.
1479
1413
  * @internal
1480
1414
  */
1481
1415
  bool copyErrorTo(UErrorCode &status) const {
1482
- return notation.copyErrorTo(status) || rounder.copyErrorTo(status) ||
1416
+ return notation.copyErrorTo(status) || precision.copyErrorTo(status) ||
1483
1417
  padder.copyErrorTo(status) || integerWidth.copyErrorTo(status) ||
1484
- symbols.copyErrorTo(status);
1418
+ symbols.copyErrorTo(status) || scale.copyErrorTo(status);
1485
1419
  }
1486
1420
  };
1487
1421
 
@@ -1505,7 +1439,7 @@ class U_I18N_API NumberFormatterSettings {
1505
1439
  *
1506
1440
  * <p>
1507
1441
  * All notation styles will be properly localized with locale data, and all notation styles are compatible with
1508
- * units, rounding strategies, and other number formatter settings.
1442
+ * units, rounding precisions, and other number formatter settings.
1509
1443
  *
1510
1444
  * <p>
1511
1445
  * Pass this method the return value of a {@link Notation} factory method. For example:
@@ -1522,7 +1456,18 @@ class U_I18N_API NumberFormatterSettings {
1522
1456
  * @see Notation
1523
1457
  * @draft ICU 60
1524
1458
  */
1525
- Derived notation(const Notation &notation) const;
1459
+ Derived notation(const Notation &notation) const &;
1460
+
1461
+ /**
1462
+ * Overload of notation() for use on an rvalue reference.
1463
+ *
1464
+ * @param notation
1465
+ * The notation strategy to use.
1466
+ * @return The fluent chain.
1467
+ * @see #notation
1468
+ * @draft ICU 62
1469
+ */
1470
+ Derived notation(const Notation &notation) &&;
1526
1471
 
1527
1472
  /**
1528
1473
  * Specifies the unit (unit of measure, currency, or percent) to associate with rendered numbers.
@@ -1534,7 +1479,7 @@ class U_I18N_API NumberFormatterSettings {
1534
1479
  * </ul>
1535
1480
  *
1536
1481
  * All units will be properly localized with locale data, and all units are compatible with notation styles,
1537
- * rounding strategies, and other number formatter settings.
1482
+ * rounding precisions, and other number formatter settings.
1538
1483
  *
1539
1484
  * Pass this method any instance of {@link MeasureUnit}. For units of measure (which often involve the
1540
1485
  * factory methods that return a pointer):
@@ -1568,7 +1513,18 @@ class U_I18N_API NumberFormatterSettings {
1568
1513
  * @see #perUnit
1569
1514
  * @draft ICU 60
1570
1515
  */
1571
- Derived unit(const icu::MeasureUnit &unit) const;
1516
+ Derived unit(const icu::MeasureUnit &unit) const &;
1517
+
1518
+ /**
1519
+ * Overload of unit() for use on an rvalue reference.
1520
+ *
1521
+ * @param unit
1522
+ * The unit to render.
1523
+ * @return The fluent chain.
1524
+ * @see #unit
1525
+ * @draft ICU 62
1526
+ */
1527
+ Derived unit(const icu::MeasureUnit &unit) &&;
1572
1528
 
1573
1529
  /**
1574
1530
  * Like unit(), but takes ownership of a pointer. Convenient for use with the MeasureFormat factory
@@ -1585,7 +1541,18 @@ class U_I18N_API NumberFormatterSettings {
1585
1541
  * @see MeasureUnit
1586
1542
  * @draft ICU 60
1587
1543
  */
1588
- Derived adoptUnit(icu::MeasureUnit *unit) const;
1544
+ Derived adoptUnit(icu::MeasureUnit *unit) const &;
1545
+
1546
+ /**
1547
+ * Overload of adoptUnit() for use on an rvalue reference.
1548
+ *
1549
+ * @param unit
1550
+ * The unit to render.
1551
+ * @return The fluent chain.
1552
+ * @see #adoptUnit
1553
+ * @draft ICU 62
1554
+ */
1555
+ Derived adoptUnit(icu::MeasureUnit *unit) &&;
1589
1556
 
1590
1557
  /**
1591
1558
  * Sets a unit to be used in the denominator. For example, to format "3 m/s", pass METER to the unit and SECOND to
@@ -1604,7 +1571,18 @@ class U_I18N_API NumberFormatterSettings {
1604
1571
  * @see #unit
1605
1572
  * @draft ICU 61
1606
1573
  */
1607
- Derived perUnit(const icu::MeasureUnit &perUnit) const;
1574
+ Derived perUnit(const icu::MeasureUnit &perUnit) const &;
1575
+
1576
+ /**
1577
+ * Overload of perUnit() for use on an rvalue reference.
1578
+ *
1579
+ * @param perUnit
1580
+ * The unit to render in the denominator.
1581
+ * @return The fluent chain.
1582
+ * @see #perUnit
1583
+ * @draft ICU 62
1584
+ */
1585
+ Derived perUnit(const icu::MeasureUnit &perUnit) &&;
1608
1586
 
1609
1587
  /**
1610
1588
  * Like perUnit(), but takes ownership of a pointer. Convenient for use with the MeasureFormat factory
@@ -1623,10 +1601,21 @@ class U_I18N_API NumberFormatterSettings {
1623
1601
  * @see MeasureUnit
1624
1602
  * @draft ICU 61
1625
1603
  */
1626
- Derived adoptPerUnit(icu::MeasureUnit *perUnit) const;
1604
+ Derived adoptPerUnit(icu::MeasureUnit *perUnit) const &;
1627
1605
 
1628
1606
  /**
1629
- * Specifies the rounding strategy to use when formatting numbers.
1607
+ * Overload of adoptPerUnit() for use on an rvalue reference.
1608
+ *
1609
+ * @param perUnit
1610
+ * The unit to render in the denominator.
1611
+ * @return The fluent chain.
1612
+ * @see #adoptPerUnit
1613
+ * @draft ICU 62
1614
+ */
1615
+ Derived adoptPerUnit(icu::MeasureUnit *perUnit) &&;
1616
+
1617
+ /**
1618
+ * Specifies the rounding precision to use when formatting numbers.
1630
1619
  *
1631
1620
  * <ul>
1632
1621
  * <li>Round to 3 decimal places: "3.142"
@@ -1636,27 +1625,77 @@ class U_I18N_API NumberFormatterSettings {
1636
1625
  * </ul>
1637
1626
  *
1638
1627
  * <p>
1639
- * Pass this method the return value of one of the factory methods on {@link Rounder}. For example:
1628
+ * Pass this method the return value of one of the factory methods on {@link Precision}. For example:
1640
1629
  *
1641
1630
  * <pre>
1642
- * NumberFormatter::with().rounding(Rounder::fixedFraction(2))
1631
+ * NumberFormatter::with().precision(Precision::fixedFraction(2))
1643
1632
  * </pre>
1644
1633
  *
1645
1634
  * <p>
1646
1635
  * In most cases, the default rounding strategy is to round to 6 fraction places; i.e.,
1647
- * <code>Rounder.maxFraction(6)</code>. The exceptions are if compact notation is being used, then the compact
1636
+ * <code>Precision.maxFraction(6)</code>. The exceptions are if compact notation is being used, then the compact
1648
1637
  * notation rounding strategy is used (see {@link Notation#compactShort} for details), or if the unit is a currency,
1649
- * then standard currency rounding is used, which varies from currency to currency (see {@link Rounder#currency} for
1638
+ * then standard currency rounding is used, which varies from currency to currency (see {@link Precision#currency} for
1650
1639
  * details).
1651
1640
  *
1652
- * @param rounder
1653
- * The rounding strategy to use.
1641
+ * @param precision
1642
+ * The rounding precision to use.
1654
1643
  * @return The fluent chain.
1655
- * @see Rounder
1656
- * @provisional This API might change or be removed in a future release.
1657
- * @draft ICU 60
1644
+ * @see Precision
1645
+ * @draft ICU 62
1646
+ */
1647
+ Derived precision(const Precision& precision) const &;
1648
+
1649
+ /**
1650
+ * Overload of precision() for use on an rvalue reference.
1651
+ *
1652
+ * @param precision
1653
+ * The rounding precision to use.
1654
+ * @return The fluent chain.
1655
+ * @see #precision
1656
+ * @draft ICU 62
1657
+ */
1658
+ Derived precision(const Precision& precision) &&;
1659
+
1660
+ #ifndef U_HIDE_DEPRECATED_API
1661
+ // Compatibility method that will be removed in ICU 64.
1662
+ // Use precision() instead.
1663
+ // See http://bugs.icu-project.org/trac/ticket/13746
1664
+ /** @deprecated ICU 62 */
1665
+ Derived rounding(const Rounder& rounder) const & {
1666
+ return precision(rounder);
1667
+ }
1668
+ #endif /* U_HIDE_DEPRECATED_API */
1669
+
1670
+ /**
1671
+ * Specifies how to determine the direction to round a number when it has more digits than fit in the
1672
+ * desired precision. When formatting 1.235:
1673
+ *
1674
+ * <ul>
1675
+ * <li>Ceiling rounding mode with integer precision: "2"
1676
+ * <li>Half-down rounding mode with 2 fixed fraction digits: "1.23"
1677
+ * <li>Half-up rounding mode with 2 fixed fraction digits: "1.24"
1678
+ * </ul>
1679
+ *
1680
+ * The default is HALF_EVEN. For more information on rounding mode, see the ICU userguide here:
1681
+ *
1682
+ * http://userguide.icu-project.org/formatparse/numbers/rounding-modes
1683
+ *
1684
+ * @param roundingMode The rounding mode to use.
1685
+ * @return The fluent chain.
1686
+ * @draft ICU 62
1687
+ */
1688
+ Derived roundingMode(UNumberFormatRoundingMode roundingMode) const &;
1689
+
1690
+ /**
1691
+ * Overload of roundingMode() for use on an rvalue reference.
1692
+ *
1693
+ * @param roundingMode The rounding mode to use.
1694
+ * @return The fluent chain.
1695
+ * @see #roundingMode
1696
+ * @draft ICU 62
1658
1697
  */
1659
- Derived rounding(const Rounder &rounder) const;
1698
+ Derived roundingMode(UNumberFormatRoundingMode roundingMode) &&;
1660
1699
 
1661
1700
  /**
1662
1701
  * Specifies the grouping strategy to use when formatting numbers.
@@ -1685,7 +1724,19 @@ class U_I18N_API NumberFormatterSettings {
1685
1724
  * @return The fluent chain.
1686
1725
  * @draft ICU 61
1687
1726
  */
1688
- Derived grouping(const UGroupingStrategy &strategy) const;
1727
+ Derived grouping(UGroupingStrategy strategy) const &;
1728
+
1729
+ /**
1730
+ * Overload of grouping() for use on an rvalue reference.
1731
+ *
1732
+ * @param strategy
1733
+ * The grouping strategy to use.
1734
+ * @return The fluent chain.
1735
+ * @see #grouping
1736
+ * @provisional This API might change or be removed in a future release.
1737
+ * @draft ICU 62
1738
+ */
1739
+ Derived grouping(UGroupingStrategy strategy) &&;
1689
1740
 
1690
1741
  /**
1691
1742
  * Specifies the minimum and maximum number of digits to render before the decimal mark.
@@ -1711,7 +1762,18 @@ class U_I18N_API NumberFormatterSettings {
1711
1762
  * @see IntegerWidth
1712
1763
  * @draft ICU 60
1713
1764
  */
1714
- Derived integerWidth(const IntegerWidth &style) const;
1765
+ Derived integerWidth(const IntegerWidth &style) const &;
1766
+
1767
+ /**
1768
+ * Overload of integerWidth() for use on an rvalue reference.
1769
+ *
1770
+ * @param style
1771
+ * The integer width to use.
1772
+ * @return The fluent chain.
1773
+ * @see #integerWidth
1774
+ * @draft ICU 62
1775
+ */
1776
+ Derived integerWidth(const IntegerWidth &style) &&;
1715
1777
 
1716
1778
  /**
1717
1779
  * Specifies the symbols (decimal separator, grouping separator, percent sign, numerals, etc.) to use when rendering
@@ -1741,8 +1803,8 @@ class U_I18N_API NumberFormatterSettings {
1741
1803
  * after passing it into the fluent chain will not be seen.
1742
1804
  *
1743
1805
  * <p>
1744
- * <strong>Note:</strong> Calling this method will override the NumberingSystem previously specified in
1745
- * {@link #symbols(NumberingSystem)}.
1806
+ * <strong>Note:</strong> Calling this method will override any previously specified DecimalFormatSymbols
1807
+ * or NumberingSystem.
1746
1808
  *
1747
1809
  * <p>
1748
1810
  * The default is to choose the symbols based on the locale specified in the fluent chain.
@@ -1753,7 +1815,18 @@ class U_I18N_API NumberFormatterSettings {
1753
1815
  * @see DecimalFormatSymbols
1754
1816
  * @draft ICU 60
1755
1817
  */
1756
- Derived symbols(const DecimalFormatSymbols &symbols) const;
1818
+ Derived symbols(const DecimalFormatSymbols &symbols) const &;
1819
+
1820
+ /**
1821
+ * Overload of symbols() for use on an rvalue reference.
1822
+ *
1823
+ * @param symbols
1824
+ * The DecimalFormatSymbols to use.
1825
+ * @return The fluent chain.
1826
+ * @see #symbols
1827
+ * @draft ICU 62
1828
+ */
1829
+ Derived symbols(const DecimalFormatSymbols &symbols) &&;
1757
1830
 
1758
1831
  /**
1759
1832
  * Specifies that the given numbering system should be used when fetching symbols.
@@ -1773,8 +1846,8 @@ class U_I18N_API NumberFormatterSettings {
1773
1846
  * </pre>
1774
1847
  *
1775
1848
  * <p>
1776
- * <strong>Note:</strong> Calling this method will override the DecimalFormatSymbols previously specified in
1777
- * {@link #symbols(DecimalFormatSymbols)}.
1849
+ * <strong>Note:</strong> Calling this method will override any previously specified DecimalFormatSymbols
1850
+ * or NumberingSystem.
1778
1851
  *
1779
1852
  * <p>
1780
1853
  * The default is to choose the best numbering system for the locale.
@@ -1788,7 +1861,18 @@ class U_I18N_API NumberFormatterSettings {
1788
1861
  * @see NumberingSystem
1789
1862
  * @draft ICU 60
1790
1863
  */
1791
- Derived adoptSymbols(NumberingSystem *symbols) const;
1864
+ Derived adoptSymbols(NumberingSystem *symbols) const &;
1865
+
1866
+ /**
1867
+ * Overload of adoptSymbols() for use on an rvalue reference.
1868
+ *
1869
+ * @param symbols
1870
+ * The NumberingSystem to use.
1871
+ * @return The fluent chain.
1872
+ * @see #adoptSymbols
1873
+ * @draft ICU 62
1874
+ */
1875
+ Derived adoptSymbols(NumberingSystem *symbols) &&;
1792
1876
 
1793
1877
  /**
1794
1878
  * Sets the width of the unit (measure unit or currency). Most common values:
@@ -1815,7 +1899,18 @@ class U_I18N_API NumberFormatterSettings {
1815
1899
  * @see UNumberUnitWidth
1816
1900
  * @draft ICU 60
1817
1901
  */
1818
- Derived unitWidth(const UNumberUnitWidth &width) const;
1902
+ Derived unitWidth(UNumberUnitWidth width) const &;
1903
+
1904
+ /**
1905
+ * Overload of unitWidth() for use on an rvalue reference.
1906
+ *
1907
+ * @param width
1908
+ * The width to use when rendering numbers.
1909
+ * @return The fluent chain.
1910
+ * @see #unitWidth
1911
+ * @draft ICU 62
1912
+ */
1913
+ Derived unitWidth(UNumberUnitWidth width) &&;
1819
1914
 
1820
1915
  /**
1821
1916
  * Sets the plus/minus sign display strategy. Most common values:
@@ -1836,14 +1931,24 @@ class U_I18N_API NumberFormatterSettings {
1836
1931
  * <p>
1837
1932
  * The default is AUTO sign display.
1838
1933
  *
1839
- * @param width
1934
+ * @param style
1840
1935
  * The sign display strategy to use when rendering numbers.
1841
1936
  * @return The fluent chain
1842
1937
  * @see UNumberSignDisplay
1843
- * @provisional This API might change or be removed in a future release.
1844
1938
  * @draft ICU 60
1845
1939
  */
1846
- Derived sign(const UNumberSignDisplay &width) const;
1940
+ Derived sign(UNumberSignDisplay style) const &;
1941
+
1942
+ /**
1943
+ * Overload of sign() for use on an rvalue reference.
1944
+ *
1945
+ * @param style
1946
+ * The sign display strategy to use when rendering numbers.
1947
+ * @return The fluent chain.
1948
+ * @see #sign
1949
+ * @draft ICU 62
1950
+ */
1951
+ Derived sign(UNumberSignDisplay style) &&;
1847
1952
 
1848
1953
  /**
1849
1954
  * Sets the decimal separator display strategy. This affects integer numbers with no fraction part. Most common
@@ -1864,23 +1969,73 @@ class U_I18N_API NumberFormatterSettings {
1864
1969
  * <p>
1865
1970
  * The default is AUTO decimal separator display.
1866
1971
  *
1867
- * @param width
1972
+ * @param style
1868
1973
  * The decimal separator display strategy to use when rendering numbers.
1869
1974
  * @return The fluent chain
1870
1975
  * @see UNumberDecimalSeparatorDisplay
1871
- * @provisional This API might change or be removed in a future release.
1872
1976
  * @draft ICU 60
1873
1977
  */
1874
- Derived decimal(const UNumberDecimalSeparatorDisplay &width) const;
1978
+ Derived decimal(UNumberDecimalSeparatorDisplay style) const &;
1979
+
1980
+ /**
1981
+ * Overload of decimal() for use on an rvalue reference.
1982
+ *
1983
+ * @param style
1984
+ * The decimal separator display strategy to use when rendering numbers.
1985
+ * @return The fluent chain.
1986
+ * @see #decimal
1987
+ * @draft ICU 62
1988
+ */
1989
+ Derived decimal(UNumberDecimalSeparatorDisplay style) &&;
1990
+
1991
+ /**
1992
+ * Sets a scale (multiplier) to be used to scale the number by an arbitrary amount before formatting.
1993
+ * Most common values:
1994
+ *
1995
+ * <ul>
1996
+ * <li>Multiply by 100: useful for percentages.
1997
+ * <li>Multiply by an arbitrary value: useful for unit conversions.
1998
+ * </ul>
1999
+ *
2000
+ * <p>
2001
+ * Pass an element from a {@link Scale} factory method to this setter. For example:
2002
+ *
2003
+ * <pre>
2004
+ * NumberFormatter::with().scale(Scale::powerOfTen(2))
2005
+ * </pre>
2006
+ *
2007
+ * <p>
2008
+ * The default is to not apply any multiplier.
2009
+ *
2010
+ * @param scale
2011
+ * The scale to apply when rendering numbers.
2012
+ * @return The fluent chain
2013
+ * @draft ICU 62
2014
+ */
2015
+ Derived scale(const Scale &scale) const &;
2016
+
2017
+ /**
2018
+ * Overload of scale() for use on an rvalue reference.
2019
+ *
2020
+ * @param scale
2021
+ * The scale to apply when rendering numbers.
2022
+ * @return The fluent chain.
2023
+ * @see #scale
2024
+ * @draft ICU 62
2025
+ */
2026
+ Derived scale(const Scale &scale) &&;
1875
2027
 
1876
2028
  #ifndef U_HIDE_INTERNAL_API
1877
2029
 
1878
2030
  /**
1879
- * Set the padding strategy. May be added to ICU 61; see #13338.
2031
+ * Set the padding strategy. May be added in the future; see #13338.
1880
2032
  *
1881
2033
  * @internal ICU 60: This API is ICU internal only.
1882
2034
  */
1883
- Derived padding(const impl::Padder &padder) const;
2035
+ Derived padding(const impl::Padder &padder) const &;
2036
+
2037
+ /** @internal */
2038
+ Derived padding(const impl::Padder &padder) &&;
1884
2039
 
1885
2040
  /**
1886
2041
  * Internal fluent setter to support a custom regulation threshold. A threshold of 1 causes the data structures to
@@ -1888,10 +2043,45 @@ class U_I18N_API NumberFormatterSettings {
1888
2043
  *
1889
2044
  * @internal ICU 60: This API is ICU internal only.
1890
2045
  */
1891
- Derived threshold(int32_t threshold) const;
2046
+ Derived threshold(int32_t threshold) const &;
2047
+
2048
+ /** @internal */
2049
+ Derived threshold(int32_t threshold) &&;
2050
+
2051
+ /**
2052
+ * Internal fluent setter to overwrite the entire macros object.
2053
+ *
2054
+ * @internal ICU 60: This API is ICU internal only.
2055
+ */
2056
+ Derived macros(const impl::MacroProps& macros) const &;
2057
+
2058
+ /** @internal */
2059
+ Derived macros(const impl::MacroProps& macros) &&;
2060
+
2061
+ /** @internal */
2062
+ Derived macros(impl::MacroProps&& macros) const &;
2063
+
2064
+ /** @internal */
2065
+ Derived macros(impl::MacroProps&& macros) &&;
1892
2066
 
1893
2067
  #endif /* U_HIDE_INTERNAL_API */
1894
2068
 
2069
+ /**
2070
+ * Creates a skeleton string representation of this number formatter. A skeleton string is a
2071
+ * locale-agnostic serialized form of a number formatter.
2072
+ *
2073
+ * Not all options are capable of being represented in the skeleton string; for example, a
2074
+ * DecimalFormatSymbols object. If any such option is encountered, the error code is set to
2075
+ * U_UNSUPPORTED_ERROR.
2076
+ *
2077
+ * The returned skeleton is in normalized form, such that two number formatters with equivalent
2078
+ * behavior should produce the same skeleton.
2079
+ *
2080
+ * @return A number skeleton string with behavior corresponding to this number formatter.
2081
+ * @draft ICU 62
2082
+ */
2083
+ UnicodeString toSkeleton(UErrorCode& status) const;
2084
+
1895
2085
  /**
1896
2086
  * Sets the UErrorCode if an error occurred in the fluent chain.
1897
2087
  * Preserves older error codes in the outErrorCode.
@@ -1905,7 +2095,9 @@ class U_I18N_API NumberFormatterSettings {
1905
2095
  }
1906
2096
  fMacros.copyErrorTo(outErrorCode);
1907
2097
  return U_FAILURE(outErrorCode);
1908
- }
2098
+ };
2099
+
2100
+ // NOTE: Uses default copy and move constructors.
1909
2101
 
1910
2102
  protected:
1911
2103
  impl::MacroProps fMacros;
@@ -1944,21 +2136,58 @@ class U_I18N_API UnlocalizedNumberFormatter
1944
2136
  * @return The fluent chain.
1945
2137
  * @draft ICU 60
1946
2138
  */
1947
- LocalizedNumberFormatter locale(const icu::Locale &locale) const;
2139
+ LocalizedNumberFormatter locale(const icu::Locale &locale) const &;
2140
+
2141
+ /**
2142
+ * Overload of locale() for use on an rvalue reference.
2143
+ *
2144
+ * @param locale
2145
+ * The locale to use when loading data for number formatting.
2146
+ * @return The fluent chain.
2147
+ * @see #locale
2148
+ * @draft ICU 62
2149
+ */
2150
+ LocalizedNumberFormatter locale(const icu::Locale &locale) &&;
2151
+
2152
+ /**
2153
+ * Default constructor: puts the formatter into a valid but undefined state.
2154
+ *
2155
+ * @draft ICU 62
2156
+ */
2157
+ UnlocalizedNumberFormatter() = default;
1948
2158
 
1949
2159
  // Make default copy constructor call the NumberFormatterSettings copy constructor.
1950
2160
  /**
1951
2161
  * Returns a copy of this UnlocalizedNumberFormatter.
1952
2162
  * @draft ICU 60
1953
2163
  */
1954
- UnlocalizedNumberFormatter(const UnlocalizedNumberFormatter &other) : UnlocalizedNumberFormatter(
1955
- static_cast<const NumberFormatterSettings<UnlocalizedNumberFormatter> &>(other)) {}
2164
+ UnlocalizedNumberFormatter(const UnlocalizedNumberFormatter &other);
2165
+
2166
+ /**
2167
+ * Move constructor:
2168
+ * The source UnlocalizedNumberFormatter will be left in a valid but undefined state.
2169
+ * @draft ICU 62
2170
+ */
2171
+ UnlocalizedNumberFormatter(UnlocalizedNumberFormatter&& src) U_NOEXCEPT;
2172
+
2173
+ /**
2174
+ * Copy assignment operator.
2175
+ * @draft ICU 62
2176
+ */
2177
+ UnlocalizedNumberFormatter& operator=(const UnlocalizedNumberFormatter& other);
2178
+
2179
+ /**
2180
+ * Move assignment operator:
2181
+ * The source UnlocalizedNumberFormatter will be left in a valid but undefined state.
2182
+ * @draft ICU 62
2183
+ */
2184
+ UnlocalizedNumberFormatter& operator=(UnlocalizedNumberFormatter&& src) U_NOEXCEPT;
1956
2185
 
1957
2186
  private:
1958
- UnlocalizedNumberFormatter() = default;
2187
+ explicit UnlocalizedNumberFormatter(const NumberFormatterSettings<UnlocalizedNumberFormatter>& other);
1959
2188
 
1960
2189
  explicit UnlocalizedNumberFormatter(
1961
- const NumberFormatterSettings<UnlocalizedNumberFormatter> &other);
2190
+ NumberFormatterSettings<UnlocalizedNumberFormatter>&& src) U_NOEXCEPT;
1962
2191
 
1963
2192
  // To give the fluent setters access to this class's constructor:
1964
2193
  friend class NumberFormatterSettings<UnlocalizedNumberFormatter>;
@@ -2016,15 +2245,99 @@ class U_I18N_API LocalizedNumberFormatter
2016
2245
  * @return A FormattedNumber object; call .toString() to get the string.
2017
2246
  * @draft ICU 60
2018
2247
  */
2019
- FormattedNumber formatDecimal(StringPiece value, UErrorCode &status) const;
2248
+ FormattedNumber formatDecimal(StringPiece value, UErrorCode& status) const;
2249
+
2250
+ #ifndef U_HIDE_INTERNAL_API
2251
+
2252
+ /** Internal method.
2253
+ * @internal
2254
+ */
2255
+ FormattedNumber formatDecimalQuantity(const impl::DecimalQuantity& dq, UErrorCode& status) const;
2256
+
2257
+ /** Internal method for DecimalFormat compatibility.
2258
+ * @internal
2259
+ */
2260
+ void getAffixImpl(bool isPrefix, bool isNegative, UnicodeString& result, UErrorCode& status) const;
2261
+
2262
+ /**
2263
+ * Internal method for testing.
2264
+ * @internal
2265
+ */
2266
+ const impl::NumberFormatterImpl* getCompiled() const;
2267
+
2268
+ /**
2269
+ * Internal method for testing.
2270
+ * @internal
2271
+ */
2272
+ int32_t getCallCount() const;
2273
+
2274
+ #endif
2275
+
2276
+ /**
2277
+ * Creates a representation of this LocalizedNumberFormat as an icu::Format, enabling the use
2278
+ * of this number formatter with APIs that need an object of that type, such as MessageFormat.
2279
+ *
2280
+ * This API is not intended to be used other than for enabling API compatibility. The formatDouble,
2281
+ * formatInt, and formatDecimal methods should normally be used when formatting numbers, not the Format
2282
+ * object returned by this method.
2283
+ *
2284
+ * The caller owns the returned object and must delete it when finished.
2285
+ *
2286
+ * @return A Format wrapping this LocalizedNumberFormatter.
2287
+ * @draft ICU 62
2288
+ */
2289
+ Format* toFormat(UErrorCode& status) const;
2290
+
2291
+ /**
2292
+ * Default constructor: puts the formatter into a valid but undefined state.
2293
+ *
2294
+ * @draft ICU 62
2295
+ */
2296
+ LocalizedNumberFormatter() = default;
2020
2297
 
2021
2298
  // Make default copy constructor call the NumberFormatterSettings copy constructor.
2022
2299
  /**
2023
2300
  * Returns a copy of this LocalizedNumberFormatter.
2024
2301
  * @draft ICU 60
2025
2302
  */
2026
- LocalizedNumberFormatter(const LocalizedNumberFormatter &other) : LocalizedNumberFormatter(
2027
- static_cast<const NumberFormatterSettings<LocalizedNumberFormatter> &>(other)) {}
2303
+ LocalizedNumberFormatter(const LocalizedNumberFormatter &other);
2304
+
2305
+ /**
2306
+ * Move constructor:
2307
+ * The source LocalizedNumberFormatter will be left in a valid but undefined state.
2308
+ * @draft ICU 62
2309
+ */
2310
+ LocalizedNumberFormatter(LocalizedNumberFormatter&& src) U_NOEXCEPT;
2311
+
2312
+ /**
2313
+ * Copy assignment operator.
2314
+ * @draft ICU 62
2315
+ */
2316
+ LocalizedNumberFormatter& operator=(const LocalizedNumberFormatter& other);
2317
+
2318
+ /**
2319
+ * Move assignment operator:
2320
+ * The source LocalizedNumberFormatter will be left in a valid but undefined state.
2321
+ * @draft ICU 62
2322
+ */
2323
+ LocalizedNumberFormatter& operator=(LocalizedNumberFormatter&& src) U_NOEXCEPT;
2324
+
2325
+ #ifndef U_HIDE_INTERNAL_API
2326
+
2327
+ /**
2328
+ * This is the core entrypoint to the number formatting pipeline. It performs self-regulation: a static code path
2329
+ * for the first few calls, and compiling a more efficient data structure if called repeatedly.
2330
+ *
2331
+ * <p>
2332
+ * This function is very hot, being called in every call to the number formatting pipeline.
2333
+ *
2334
+ * @param results
2335
+ * The results object. This method will mutate it to save the results.
2336
+ * @internal
2337
+ */
2338
+ void formatImpl(impl::UFormattedNumberData *results, UErrorCode &status) const;
2339
+
2340
+ #endif
2028
2341
 
2029
2342
  /**
2030
2343
  * Destruct this LocalizedNumberFormatter, cleaning up any memory it might own.
@@ -2033,27 +2346,25 @@ class U_I18N_API LocalizedNumberFormatter
2033
2346
  ~LocalizedNumberFormatter();
2034
2347
 
2035
2348
  private:
2349
+ // Note: fCompiled can't be a LocalPointer because impl::NumberFormatterImpl is defined in an internal
2350
+ // header, and LocalPointer needs the full class definition in order to delete the instance.
2036
2351
  const impl::NumberFormatterImpl* fCompiled {nullptr};
2037
2352
  char fUnsafeCallCount[8] {}; // internally cast to u_atomic_int32_t
2038
2353
 
2039
- LocalizedNumberFormatter() = default;
2354
+ explicit LocalizedNumberFormatter(const NumberFormatterSettings<LocalizedNumberFormatter>& other);
2040
2355
 
2041
- explicit LocalizedNumberFormatter(const NumberFormatterSettings<LocalizedNumberFormatter> &other);
2356
+ explicit LocalizedNumberFormatter(NumberFormatterSettings<LocalizedNumberFormatter>&& src) U_NOEXCEPT;
2042
2357
 
2043
2358
  LocalizedNumberFormatter(const impl::MacroProps &macros, const Locale &locale);
2044
2359
 
2360
+ LocalizedNumberFormatter(impl::MacroProps &&macros, const Locale &locale);
2361
+
2362
+ void lnfMoveHelper(LocalizedNumberFormatter&& src);
2363
+
2045
2364
  /**
2046
- * This is the core entrypoint to the number formatting pipeline. It performs self-regulation: a static code path
2047
- * for the first few calls, and compiling a more efficient data structure if called repeatedly.
2048
- *
2049
- * <p>
2050
- * This function is very hot, being called in every call to the number formatting pipeline.
2051
- *
2052
- * @param results
2053
- * The results object. This method takes ownership.
2054
- * @return The formatted number result.
2365
+ * @return true if the compiled formatter is available.
2055
2366
  */
2056
- FormattedNumber formatImpl(impl::NumberFormatterResults *results, UErrorCode &status) const;
2367
+ bool computeCompiled(UErrorCode& status) const;
2057
2368
 
2058
2369
  // To give the fluent setters access to this class's constructor:
2059
2370
  friend class NumberFormatterSettings<UnlocalizedNumberFormatter>;
@@ -2071,25 +2382,57 @@ class U_I18N_API LocalizedNumberFormatter
2071
2382
  */
2072
2383
  class U_I18N_API FormattedNumber : public UMemory {
2073
2384
  public:
2385
+ #ifndef U_HIDE_DEPRECATED_API
2074
2386
  /**
2075
2387
  * Returns a UnicodeString representation of the formatted number.
2076
2388
  *
2077
2389
  * @return a UnicodeString containing the localized number.
2078
- * @draft ICU 60
2390
+ * @deprecated ICU 62 Use the version of this method with an error code instead.
2391
+ * This method was never @stable and will be removed in a future release.
2392
+ * See http://bugs.icu-project.org/trac/ticket/13746
2079
2393
  */
2080
2394
  UnicodeString toString() const;
2395
+ #endif /* U_HIDE_DEPRECATED_API */
2396
+
2397
+ /**
2398
+ * Returns a UnicodeString representation of the formatted number.
2399
+ *
2400
+ * @param status
2401
+ * Set if an error occurs while formatting the number to the UnicodeString.
2402
+ * @return a UnicodeString containing the localized number.
2403
+ * @draft ICU 62
2404
+ */
2405
+ UnicodeString toString(UErrorCode& status) const;
2081
2406
 
2407
+ #ifndef U_HIDE_DEPRECATED_API
2082
2408
  /**
2083
2409
  * Appends the formatted number to an Appendable.
2084
2410
  *
2085
2411
  * @param appendable
2086
2412
  * The Appendable to which to append the formatted number string.
2087
2413
  * @return The same Appendable, for chaining.
2088
- * @draft ICU 60
2414
+ * @deprecated ICU 62 Use the version of this method with an error code instead.
2415
+ * This method was never @stable and will be removed in a future release.
2416
+ * See http://bugs.icu-project.org/trac/ticket/13746
2089
2417
  * @see Appendable
2090
2418
  */
2091
2419
  Appendable &appendTo(Appendable &appendable);
2420
+ #endif /* U_HIDE_DEPRECATED_API */
2092
2421
 
2422
+ /**
2423
+ * Appends the formatted number to an Appendable.
2424
+ *
2425
+ * @param appendable
2426
+ * The Appendable to which to append the formatted number string.
2427
+ * @param status
2428
+ * Set if an error occurs while formatting the number to the Appendable.
2429
+ * @return The same Appendable, for chaining.
2430
+ * @draft ICU 62
2431
+ * @see Appendable
2432
+ */
2433
+ Appendable &appendTo(Appendable &appendable, UErrorCode& status);
2434
+
2435
+ #ifndef U_HIDE_DEPRECATED_API
2093
2436
  /**
2094
2437
  * Determine the start and end indices of the first occurrence of the given <em>field</em> in the output string.
2095
2438
  * This allows you to determine the locations of the integer part, fraction part, and sign.
@@ -2106,11 +2449,47 @@ class U_I18N_API FormattedNumber : public UMemory {
2106
2449
  * The FieldPosition to populate with the start and end indices of the desired field.
2107
2450
  * @param status
2108
2451
  * Set if an error occurs while populating the FieldPosition.
2109
- * @draft ICU 60
2452
+ * @deprecated ICU 62 Use {@link #nextFieldPosition} instead. This method will be removed in a future
2453
+ * release. See http://bugs.icu-project.org/trac/ticket/13746
2110
2454
  * @see UNumberFormatFields
2111
2455
  */
2112
2456
  void populateFieldPosition(FieldPosition &fieldPosition, UErrorCode &status);
2457
+ #endif /* U_HIDE_DEPRECATED_API */
2458
+
2459
+ /**
2460
+ * Determines the start and end indices of the next occurrence of the given <em>field</em> in the
2461
+ * output string. This allows you to determine the locations of, for example, the integer part,
2462
+ * fraction part, or symbols.
2463
+ *
2464
+ * If a field occurs just once, calling this method will find that occurrence and return it. If a
2465
+ * field occurs multiple times, this method may be called repeatedly with the following pattern:
2466
+ *
2467
+ * <pre>
2468
+ * FieldPosition fpos(UNUM_GROUPING_SEPARATOR_FIELD);
2469
+ * while (formattedNumber.nextFieldPosition(fpos, status)) {
2470
+ * // do something with fpos.
2471
+ * }
2472
+ * </pre>
2473
+ *
2474
+ * This method is useful if you know which field to query. If you want all available field position
2475
+ * information, use #getAllFieldPositions().
2476
+ *
2477
+ * @param fieldPosition
2478
+ * Input+output variable. On input, the "field" property determines which field to look
2479
+ * up, and the "beginIndex" and "endIndex" properties determine where to begin the search.
2480
+ * On output, the "beginIndex" is set to the beginning of the first occurrence of the
2481
+ * field with either begin or end indices after the input indices, "endIndex" is set to
2482
+ * the end of that occurrence of the field (exclusive index). If a field position is not
2483
+ * found, the method returns FALSE and the FieldPosition may or may not be changed.
2484
+ * @param status
2485
+ * Set if an error occurs while populating the FieldPosition.
2486
+ * @return TRUE if a new occurrence of the field was found; FALSE otherwise.
2487
+ * @draft ICU 62
2488
+ * @see UNumberFormatFields
2489
+ */
2490
+ UBool nextFieldPosition(FieldPosition& fieldPosition, UErrorCode& status) const;
2113
2491
 
2492
+ #ifndef U_HIDE_DEPRECATED_API
2114
2493
  /**
2115
2494
  * Export the formatted number to a FieldPositionIterator. This allows you to determine which characters in
2116
2495
  * the output string correspond to which <em>fields</em>, such as the integer part, fraction part, and sign.
@@ -2122,10 +2501,67 @@ class U_I18N_API FormattedNumber : public UMemory {
2122
2501
  * The FieldPositionIterator to populate with all of the fields present in the formatted number.
2123
2502
  * @param status
2124
2503
  * Set if an error occurs while populating the FieldPositionIterator.
2125
- * @draft ICU 60
2504
+ * @deprecated ICU 62 Use {@link #getAllFieldPositions} instead. This method will be removed in a
2505
+ * future release. See http://bugs.icu-project.org/trac/ticket/13746
2126
2506
  * @see UNumberFormatFields
2127
2507
  */
2128
2508
  void populateFieldPositionIterator(FieldPositionIterator &iterator, UErrorCode &status);
2509
+ #endif /* U_HIDE_DEPRECATED_API */
2510
+
2511
+ /**
2512
+ * Export the formatted number to a FieldPositionIterator. This allows you to determine which characters in
2513
+ * the output string correspond to which <em>fields</em>, such as the integer part, fraction part, and sign.
2514
+ *
2515
+ * If information on only one field is needed, use #nextFieldPosition() instead.
2516
+ *
2517
+ * @param iterator
2518
+ * The FieldPositionIterator to populate with all of the fields present in the formatted number.
2519
+ * @param status
2520
+ * Set if an error occurs while populating the FieldPositionIterator.
2521
+ * @draft ICU 62
2522
+ * @see UNumberFormatFields
2523
+ */
2524
+ void getAllFieldPositions(FieldPositionIterator &iterator, UErrorCode &status) const;
2525
+
2526
+ #ifndef U_HIDE_INTERNAL_API
2527
+
2528
+ /**
2529
+ * Gets the raw DecimalQuantity for plural rule selection.
2530
+ * @internal
2531
+ */
2532
+ void getDecimalQuantity(impl::DecimalQuantity& output, UErrorCode& status) const;
2533
+
2534
+ /**
2535
+ * Populates the mutable builder type FieldPositionIteratorHandler.
2536
+ * @internal
2537
+ */
2538
+ void getAllFieldPositionsImpl(FieldPositionIteratorHandler& fpih, UErrorCode& status) const;
2539
+
2540
+ #endif
2541
+
2542
+ /**
2543
+ * Copying not supported; use move constructor instead.
2544
+ */
2545
+ FormattedNumber(const FormattedNumber&) = delete;
2546
+
2547
+ /**
2548
+ * Copying not supported; use move assignment instead.
2549
+ */
2550
+ FormattedNumber& operator=(const FormattedNumber&) = delete;
2551
+
2552
+ /**
2553
+ * Move constructor:
2554
+ * Leaves the source FormattedNumber in an undefined state.
2555
+ * @draft ICU 62
2556
+ */
2557
+ FormattedNumber(FormattedNumber&& src) U_NOEXCEPT;
2558
+
2559
+ /**
2560
+ * Move assignment:
2561
+ * Leaves the source FormattedNumber in an undefined state.
2562
+ * @draft ICU 62
2563
+ */
2564
+ FormattedNumber& operator=(FormattedNumber&& src) U_NOEXCEPT;
2129
2565
 
2130
2566
  /**
2131
2567
  * Destruct an instance of FormattedNumber, cleaning up any memory it might own.
@@ -2134,13 +2570,17 @@ class U_I18N_API FormattedNumber : public UMemory {
2134
2570
  ~FormattedNumber();
2135
2571
 
2136
2572
  private:
2137
- // Can't use LocalPointer because NumberFormatterResults is forward-declared
2138
- const impl::NumberFormatterResults *fResults;
2573
+ // Can't use LocalPointer because UFormattedNumberData is forward-declared
2574
+ const impl::UFormattedNumberData *fResults;
2139
2575
 
2140
2576
  // Error code for the terminal methods
2141
2577
  UErrorCode fErrorCode;
2142
2578
 
2143
- explicit FormattedNumber(impl::NumberFormatterResults *results)
2579
+ /**
2580
+ * Internal constructor from data type. Adopts the data pointer.
2581
+ * @internal
2582
+ */
2583
+ explicit FormattedNumber(impl::UFormattedNumberData *results)
2144
2584
  : fResults(results), fErrorCode(U_ZERO_ERROR) {};
2145
2585
 
2146
2586
  explicit FormattedNumber(UErrorCode errorCode)
@@ -2177,9 +2617,21 @@ class U_I18N_API NumberFormatter final {
2177
2617
  */
2178
2618
  static LocalizedNumberFormatter withLocale(const Locale &locale);
2179
2619
 
2620
+ /**
2621
+ * Call this method at the beginning of a NumberFormatter fluent chain to create an instance based
2622
+ * on a given number skeleton string.
2623
+ *
2624
+ * @param skeleton
2625
+ * The skeleton string off of which to base this NumberFormatter.
2626
+ * @param status
2627
+ * Set to U_NUMBER_SKELETON_SYNTAX_ERROR if the skeleton was invalid.
2628
+ * @return An UnlocalizedNumberFormatter, to be used for chaining.
2629
+ * @draft ICU 62
2630
+ */
2631
+ static UnlocalizedNumberFormatter forSkeleton(const UnicodeString& skeleton, UErrorCode& status);
2632
+
2180
2633
  /**
2181
2634
  * Use factory methods instead of the constructor to create a NumberFormatter.
2182
- * @draft ICU 60
2183
2635
  */
2184
2636
  NumberFormatter() = delete;
2185
2637
  };