]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/measunit.cpp
ICU-64252.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / measunit.cpp
CommitLineData
f3c0d7a5
A
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
57a6839d
A
3/*
4**********************************************************************
2ca993e8 5* Copyright (c) 2004-2016, International Business Machines
57a6839d
A
6* Corporation and others. All Rights Reserved.
7**********************************************************************
8* Author: Alan Liu
9* Created: April 26, 2004
10* Since: ICU 3.0
11**********************************************************************
12*/
13#include "utypeinfo.h" // for 'typeid' to work
14
15#include "unicode/measunit.h"
16
17#if !UCONFIG_NO_FORMATTING
18
19#include "unicode/uenum.h"
20#include "ustrenum.h"
21#include "cstring.h"
22#include "uassert.h"
23
57a6839d
A
24U_NAMESPACE_BEGIN
25
26UOBJECT_DEFINE_RTTI_IMPLEMENTATION(MeasureUnit)
27
b331163b
A
28// All code between the "Start generated code" comment and
29// the "End generated code" comment is auto generated code
30// and must not be edited manually. For instructions on how to correctly
31// update this code, refer to:
32// http://site.icu-project.org/design/formatting/measureformat/updating-measure-unit
33//
34// Start generated code
35
0f5d89e8 36
57a6839d
A
37static const int32_t gOffsets[] = {
38 0,
b331163b 39 2,
2ca993e8 40 7,
3d1f044b
A
41 17,
42 25,
43 29,
44 328,
45 339,
46 354,
47 358,
48 366,
49 368,
50 372,
51 393,
52 395,
53 409,
54 412,
55 418,
56 426,
57 430,
58 434,
59 436,
60 463
57a6839d
A
61};
62
63static const int32_t gIndexes[] = {
64 0,
b331163b 65 2,
2ca993e8 66 7,
3d1f044b
A
67 17,
68 25,
69 29,
70 29,
71 40,
2ca993e8
A
72 55,
73 59,
3d1f044b
A
74 67,
75 69,
76 73,
0f5d89e8 77 94,
3d1f044b
A
78 96,
79 110,
0f5d89e8 80 113,
3d1f044b
A
81 119,
82 127,
83 131,
84 135,
85 137,
86 164
57a6839d
A
87};
88
b331163b 89// Must be sorted alphabetically.
57a6839d
A
90static const char * const gTypes[] = {
91 "acceleration",
92 "angle",
93 "area",
2ca993e8 94 "concentr",
b331163b 95 "consumption",
57a6839d 96 "currency",
b331163b 97 "digital",
57a6839d 98 "duration",
b331163b
A
99 "electric",
100 "energy",
3d1f044b 101 "force",
b331163b 102 "frequency",
57a6839d 103 "length",
b331163b 104 "light",
57a6839d 105 "mass",
0f5d89e8 106 "none",
57a6839d
A
107 "power",
108 "pressure",
109 "speed",
110 "temperature",
3d1f044b 111 "torque",
b331163b 112 "volume"
57a6839d
A
113};
114
b331163b 115// Must be grouped by type and sorted alphabetically within each type.
57a6839d 116static const char * const gSubTypes[] = {
b331163b
A
117 "g-force",
118 "meter-per-second-squared",
119 "arc-minute",
57a6839d
A
120 "arc-second",
121 "degree",
b331163b 122 "radian",
2ca993e8 123 "revolution",
b331163b 124 "acre",
3d1f044b 125 "dunam",
57a6839d 126 "hectare",
b331163b 127 "square-centimeter",
57a6839d 128 "square-foot",
b331163b 129 "square-inch",
57a6839d
A
130 "square-kilometer",
131 "square-meter",
132 "square-mile",
b331163b 133 "square-yard",
2ca993e8
A
134 "karat",
135 "milligram-per-deciliter",
136 "millimole-per-liter",
3d1f044b 137 "mole",
2ca993e8 138 "part-per-million",
3d1f044b
A
139 "percent",
140 "permille",
141 "permyriad",
2ca993e8 142 "liter-per-100kilometers",
b331163b
A
143 "liter-per-kilometer",
144 "mile-per-gallon",
2ca993e8 145 "mile-per-gallon-imperial",
b331163b 146 "ADP",
57a6839d
A
147 "AED",
148 "AFA",
149 "AFN",
0f5d89e8 150 "ALK",
57a6839d
A
151 "ALL",
152 "AMD",
153 "ANG",
154 "AOA",
0f5d89e8 155 "AOK",
57a6839d
A
156 "AON",
157 "AOR",
158 "ARA",
159 "ARP",
160 "ARS",
0f5d89e8 161 "ARY",
57a6839d
A
162 "ATS",
163 "AUD",
164 "AWG",
165 "AYM",
166 "AZM",
167 "AZN",
168 "BAD",
169 "BAM",
170 "BBD",
171 "BDT",
172 "BEC",
173 "BEF",
174 "BEL",
0f5d89e8
A
175 "BGJ",
176 "BGK",
57a6839d
A
177 "BGL",
178 "BGN",
179 "BHD",
180 "BIF",
181 "BMD",
182 "BND",
183 "BOB",
0f5d89e8 184 "BOP",
57a6839d 185 "BOV",
0f5d89e8 186 "BRB",
57a6839d
A
187 "BRC",
188 "BRE",
189 "BRL",
190 "BRN",
191 "BRR",
192 "BSD",
193 "BTN",
0f5d89e8 194 "BUK",
57a6839d
A
195 "BWP",
196 "BYB",
f3c0d7a5 197 "BYN",
57a6839d
A
198 "BYR",
199 "BZD",
200 "CAD",
201 "CDF",
202 "CHC",
203 "CHE",
204 "CHF",
205 "CHW",
206 "CLF",
207 "CLP",
208 "CNY",
209 "COP",
210 "COU",
211 "CRC",
212 "CSD",
0f5d89e8 213 "CSJ",
57a6839d
A
214 "CSK",
215 "CUC",
216 "CUP",
217 "CVE",
218 "CYP",
219 "CZK",
220 "DDM",
221 "DEM",
222 "DJF",
223 "DKK",
224 "DOP",
225 "DZD",
226 "ECS",
227 "ECV",
228 "EEK",
229 "EGP",
230 "ERN",
231 "ESA",
232 "ESB",
233 "ESP",
234 "ETB",
235 "EUR",
236 "FIM",
237 "FJD",
238 "FKP",
239 "FRF",
240 "GBP",
241 "GEK",
242 "GEL",
243 "GHC",
244 "GHP",
245 "GHS",
246 "GIP",
247 "GMD",
0f5d89e8 248 "GNE",
57a6839d 249 "GNF",
0f5d89e8 250 "GNS",
57a6839d
A
251 "GQE",
252 "GRD",
253 "GTQ",
0f5d89e8 254 "GWE",
57a6839d
A
255 "GWP",
256 "GYD",
257 "HKD",
258 "HNL",
259 "HRD",
260 "HRK",
261 "HTG",
262 "HUF",
263 "IDR",
264 "IEP",
0f5d89e8
A
265 "ILP",
266 "ILR",
57a6839d
A
267 "ILS",
268 "INR",
269 "IQD",
270 "IRR",
0f5d89e8 271 "ISJ",
57a6839d
A
272 "ISK",
273 "ITL",
274 "JMD",
275 "JOD",
276 "JPY",
277 "KES",
278 "KGS",
279 "KHR",
280 "KMF",
281 "KPW",
282 "KRW",
283 "KWD",
284 "KYD",
285 "KZT",
0f5d89e8 286 "LAJ",
57a6839d
A
287 "LAK",
288 "LBP",
289 "LKR",
290 "LRD",
291 "LSL",
0f5d89e8 292 "LSM",
57a6839d
A
293 "LTL",
294 "LTT",
295 "LUC",
296 "LUF",
297 "LUL",
298 "LVL",
299 "LVR",
300 "LYD",
301 "MAD",
302 "MDL",
303 "MGA",
304 "MGF",
305 "MKD",
306 "MLF",
307 "MMK",
308 "MNT",
309 "MOP",
310 "MRO",
0f5d89e8 311 "MRU",
57a6839d 312 "MTL",
0f5d89e8 313 "MTP",
57a6839d 314 "MUR",
0f5d89e8 315 "MVQ",
57a6839d
A
316 "MVR",
317 "MWK",
318 "MXN",
0f5d89e8 319 "MXP",
57a6839d
A
320 "MXV",
321 "MYR",
0f5d89e8 322 "MZE",
57a6839d
A
323 "MZM",
324 "MZN",
325 "NAD",
326 "NGN",
0f5d89e8 327 "NIC",
57a6839d
A
328 "NIO",
329 "NLG",
330 "NOK",
331 "NPR",
332 "NZD",
333 "OMR",
334 "PAB",
0f5d89e8 335 "PEH",
57a6839d
A
336 "PEI",
337 "PEN",
338 "PES",
339 "PGK",
340 "PHP",
341 "PKR",
342 "PLN",
343 "PLZ",
344 "PTE",
345 "PYG",
346 "QAR",
0f5d89e8
A
347 "RHD",
348 "ROK",
57a6839d
A
349 "ROL",
350 "RON",
351 "RSD",
352 "RUB",
353 "RUR",
354 "RWF",
355 "SAR",
356 "SBD",
357 "SCR",
358 "SDD",
359 "SDG",
0f5d89e8 360 "SDP",
57a6839d
A
361 "SEK",
362 "SGD",
363 "SHP",
364 "SIT",
365 "SKK",
366 "SLL",
367 "SOS",
368 "SRD",
369 "SRG",
370 "SSP",
371 "STD",
0f5d89e8
A
372 "STN",
373 "SUR",
57a6839d
A
374 "SVC",
375 "SYP",
376 "SZL",
377 "THB",
378 "TJR",
379 "TJS",
380 "TMM",
381 "TMT",
382 "TND",
383 "TOP",
384 "TPE",
385 "TRL",
386 "TRY",
387 "TTD",
388 "TWD",
389 "TZS",
390 "UAH",
391 "UAK",
0f5d89e8
A
392 "UGS",
393 "UGW",
57a6839d
A
394 "UGX",
395 "USD",
396 "USN",
397 "USS",
398 "UYI",
0f5d89e8
A
399 "UYN",
400 "UYP",
57a6839d 401 "UYU",
3d1f044b 402 "UYW",
57a6839d
A
403 "UZS",
404 "VEB",
405 "VEF",
4f1e1a09 406 "VES",
0f5d89e8 407 "VNC",
57a6839d
A
408 "VND",
409 "VUV",
410 "WST",
411 "XAF",
412 "XAG",
413 "XAU",
414 "XBA",
415 "XBB",
416 "XBC",
417 "XBD",
418 "XCD",
419 "XDR",
420 "XEU",
421 "XOF",
422 "XPD",
423 "XPF",
424 "XPT",
425 "XSU",
426 "XTS",
427 "XUA",
428 "XXX",
429 "YDD",
430 "YER",
0f5d89e8 431 "YUD",
57a6839d
A
432 "YUM",
433 "YUN",
434 "ZAL",
435 "ZAR",
436 "ZMK",
437 "ZMW",
438 "ZRN",
439 "ZRZ",
0f5d89e8 440 "ZWC",
57a6839d
A
441 "ZWD",
442 "ZWL",
443 "ZWN",
444 "ZWR",
b331163b
A
445 "bit",
446 "byte",
447 "gigabit",
448 "gigabyte",
449 "kilobit",
450 "kilobyte",
451 "megabit",
452 "megabyte",
3d1f044b 453 "petabyte",
b331163b
A
454 "terabit",
455 "terabyte",
2ca993e8 456 "century",
b331163b 457 "day",
3d1f044b 458 "day-person",
57a6839d 459 "hour",
b331163b 460 "microsecond",
57a6839d
A
461 "millisecond",
462 "minute",
463 "month",
3d1f044b 464 "month-person",
b331163b 465 "nanosecond",
57a6839d
A
466 "second",
467 "week",
3d1f044b 468 "week-person",
57a6839d 469 "year",
3d1f044b 470 "year-person",
b331163b
A
471 "ampere",
472 "milliampere",
473 "ohm",
474 "volt",
3d1f044b 475 "british-thermal-unit",
b331163b 476 "calorie",
3d1f044b 477 "electronvolt",
b331163b
A
478 "foodcalorie",
479 "joule",
480 "kilocalorie",
481 "kilojoule",
482 "kilowatt-hour",
3d1f044b
A
483 "newton",
484 "pound-force",
b331163b
A
485 "gigahertz",
486 "hertz",
487 "kilohertz",
488 "megahertz",
489 "astronomical-unit",
490 "centimeter",
491 "decimeter",
492 "fathom",
57a6839d 493 "foot",
b331163b 494 "furlong",
57a6839d
A
495 "inch",
496 "kilometer",
497 "light-year",
498 "meter",
b331163b 499 "micrometer",
57a6839d 500 "mile",
2ca993e8 501 "mile-scandinavian",
57a6839d 502 "millimeter",
b331163b
A
503 "nanometer",
504 "nautical-mile",
505 "parsec",
57a6839d 506 "picometer",
f3c0d7a5 507 "point",
3d1f044b 508 "solar-radius",
57a6839d 509 "yard",
b331163b 510 "lux",
3d1f044b 511 "solar-luminosity",
b331163b 512 "carat",
3d1f044b
A
513 "dalton",
514 "earth-mass",
b331163b 515 "gram",
57a6839d 516 "kilogram",
b331163b
A
517 "metric-ton",
518 "microgram",
519 "milligram",
57a6839d 520 "ounce",
b331163b 521 "ounce-troy",
57a6839d 522 "pound",
3d1f044b 523 "solar-mass",
b331163b
A
524 "stone",
525 "ton",
0f5d89e8
A
526 "base",
527 "percent",
528 "permille",
b331163b
A
529 "gigawatt",
530 "horsepower",
57a6839d 531 "kilowatt",
b331163b
A
532 "megawatt",
533 "milliwatt",
57a6839d 534 "watt",
3d1f044b 535 "atmosphere",
b331163b 536 "hectopascal",
57a6839d 537 "inch-hg",
3d1f044b
A
538 "kilopascal",
539 "megapascal",
57a6839d 540 "millibar",
b331163b
A
541 "millimeter-of-mercury",
542 "pound-per-square-inch",
b331163b 543 "kilometer-per-hour",
2ca993e8 544 "knot",
57a6839d
A
545 "meter-per-second",
546 "mile-per-hour",
b331163b 547 "celsius",
57a6839d 548 "fahrenheit",
b331163b 549 "generic",
2ca993e8 550 "kelvin",
3d1f044b
A
551 "newton-meter",
552 "pound-foot",
b331163b 553 "acre-foot",
3d1f044b 554 "barrel",
b331163b
A
555 "bushel",
556 "centiliter",
557 "cubic-centimeter",
558 "cubic-foot",
559 "cubic-inch",
560 "cubic-kilometer",
561 "cubic-meter",
57a6839d 562 "cubic-mile",
b331163b
A
563 "cubic-yard",
564 "cup",
2ca993e8 565 "cup-metric",
b331163b
A
566 "deciliter",
567 "fluid-ounce",
3d1f044b 568 "fluid-ounce-imperial",
b331163b 569 "gallon",
2ca993e8 570 "gallon-imperial",
b331163b 571 "hectoliter",
57a6839d 572 "liter",
b331163b
A
573 "megaliter",
574 "milliliter",
575 "pint",
2ca993e8 576 "pint-metric",
b331163b
A
577 "quart",
578 "tablespoon",
579 "teaspoon"
580};
581
582// Must be sorted by first value and then second value.
583static int32_t unitPerUnitToSingleUnit[][4] = {
3d1f044b
A
584 {379, 342, 18, 0},
585 {381, 349, 18, 2},
586 {383, 342, 18, 3},
587 {383, 452, 4, 2},
588 {383, 453, 4, 3},
589 {402, 449, 3, 1},
590 {405, 12, 17, 7},
591 {455, 379, 4, 1}
b331163b 592};
57a6839d 593
0f5d89e8 594// Shortcuts to the base unit in order to make the default constructor fast
3d1f044b 595static const int32_t kBaseTypeIdx = 15;
0f5d89e8
A
596static const int32_t kBaseSubTypeIdx = 0;
597
57a6839d
A
598MeasureUnit *MeasureUnit::createGForce(UErrorCode &status) {
599 return MeasureUnit::create(0, 0, status);
600}
601
3d1f044b
A
602MeasureUnit MeasureUnit::getGForce() {
603 return MeasureUnit(0, 0);
604}
605
b331163b
A
606MeasureUnit *MeasureUnit::createMeterPerSecondSquared(UErrorCode &status) {
607 return MeasureUnit::create(0, 1, status);
608}
609
3d1f044b
A
610MeasureUnit MeasureUnit::getMeterPerSecondSquared() {
611 return MeasureUnit(0, 1);
612}
613
57a6839d
A
614MeasureUnit *MeasureUnit::createArcMinute(UErrorCode &status) {
615 return MeasureUnit::create(1, 0, status);
616}
617
3d1f044b
A
618MeasureUnit MeasureUnit::getArcMinute() {
619 return MeasureUnit(1, 0);
620}
621
57a6839d
A
622MeasureUnit *MeasureUnit::createArcSecond(UErrorCode &status) {
623 return MeasureUnit::create(1, 1, status);
624}
625
3d1f044b
A
626MeasureUnit MeasureUnit::getArcSecond() {
627 return MeasureUnit(1, 1);
628}
629
57a6839d
A
630MeasureUnit *MeasureUnit::createDegree(UErrorCode &status) {
631 return MeasureUnit::create(1, 2, status);
632}
633
3d1f044b
A
634MeasureUnit MeasureUnit::getDegree() {
635 return MeasureUnit(1, 2);
636}
637
b331163b
A
638MeasureUnit *MeasureUnit::createRadian(UErrorCode &status) {
639 return MeasureUnit::create(1, 3, status);
640}
641
3d1f044b
A
642MeasureUnit MeasureUnit::getRadian() {
643 return MeasureUnit(1, 3);
644}
645
2ca993e8
A
646MeasureUnit *MeasureUnit::createRevolutionAngle(UErrorCode &status) {
647 return MeasureUnit::create(1, 4, status);
648}
649
3d1f044b
A
650MeasureUnit MeasureUnit::getRevolutionAngle() {
651 return MeasureUnit(1, 4);
652}
653
57a6839d
A
654MeasureUnit *MeasureUnit::createAcre(UErrorCode &status) {
655 return MeasureUnit::create(2, 0, status);
656}
657
3d1f044b
A
658MeasureUnit MeasureUnit::getAcre() {
659 return MeasureUnit(2, 0);
660}
661
662MeasureUnit *MeasureUnit::createDunam(UErrorCode &status) {
57a6839d
A
663 return MeasureUnit::create(2, 1, status);
664}
665
3d1f044b
A
666MeasureUnit MeasureUnit::getDunam() {
667 return MeasureUnit(2, 1);
668}
669
670MeasureUnit *MeasureUnit::createHectare(UErrorCode &status) {
57a6839d
A
671 return MeasureUnit::create(2, 2, status);
672}
673
3d1f044b
A
674MeasureUnit MeasureUnit::getHectare() {
675 return MeasureUnit(2, 2);
676}
677
678MeasureUnit *MeasureUnit::createSquareCentimeter(UErrorCode &status) {
57a6839d
A
679 return MeasureUnit::create(2, 3, status);
680}
681
3d1f044b
A
682MeasureUnit MeasureUnit::getSquareCentimeter() {
683 return MeasureUnit(2, 3);
684}
685
686MeasureUnit *MeasureUnit::createSquareFoot(UErrorCode &status) {
57a6839d
A
687 return MeasureUnit::create(2, 4, status);
688}
689
3d1f044b
A
690MeasureUnit MeasureUnit::getSquareFoot() {
691 return MeasureUnit(2, 4);
692}
693
694MeasureUnit *MeasureUnit::createSquareInch(UErrorCode &status) {
57a6839d
A
695 return MeasureUnit::create(2, 5, status);
696}
697
3d1f044b
A
698MeasureUnit MeasureUnit::getSquareInch() {
699 return MeasureUnit(2, 5);
700}
701
702MeasureUnit *MeasureUnit::createSquareKilometer(UErrorCode &status) {
b331163b
A
703 return MeasureUnit::create(2, 6, status);
704}
705
3d1f044b
A
706MeasureUnit MeasureUnit::getSquareKilometer() {
707 return MeasureUnit(2, 6);
708}
709
710MeasureUnit *MeasureUnit::createSquareMeter(UErrorCode &status) {
b331163b
A
711 return MeasureUnit::create(2, 7, status);
712}
713
3d1f044b
A
714MeasureUnit MeasureUnit::getSquareMeter() {
715 return MeasureUnit(2, 7);
716}
717
718MeasureUnit *MeasureUnit::createSquareMile(UErrorCode &status) {
b331163b
A
719 return MeasureUnit::create(2, 8, status);
720}
721
3d1f044b
A
722MeasureUnit MeasureUnit::getSquareMile() {
723 return MeasureUnit(2, 8);
724}
725
726MeasureUnit *MeasureUnit::createSquareYard(UErrorCode &status) {
727 return MeasureUnit::create(2, 9, status);
728}
729
730MeasureUnit MeasureUnit::getSquareYard() {
731 return MeasureUnit(2, 9);
732}
733
2ca993e8 734MeasureUnit *MeasureUnit::createKarat(UErrorCode &status) {
b331163b
A
735 return MeasureUnit::create(3, 0, status);
736}
737
3d1f044b
A
738MeasureUnit MeasureUnit::getKarat() {
739 return MeasureUnit(3, 0);
740}
741
2ca993e8 742MeasureUnit *MeasureUnit::createMilligramPerDeciliter(UErrorCode &status) {
b331163b
A
743 return MeasureUnit::create(3, 1, status);
744}
745
3d1f044b
A
746MeasureUnit MeasureUnit::getMilligramPerDeciliter() {
747 return MeasureUnit(3, 1);
748}
749
2ca993e8
A
750MeasureUnit *MeasureUnit::createMillimolePerLiter(UErrorCode &status) {
751 return MeasureUnit::create(3, 2, status);
752}
753
3d1f044b
A
754MeasureUnit MeasureUnit::getMillimolePerLiter() {
755 return MeasureUnit(3, 2);
756}
757
758MeasureUnit *MeasureUnit::createMole(UErrorCode &status) {
2ca993e8
A
759 return MeasureUnit::create(3, 3, status);
760}
761
3d1f044b
A
762MeasureUnit MeasureUnit::getMole() {
763 return MeasureUnit(3, 3);
764}
765
766MeasureUnit *MeasureUnit::createPartPerMillion(UErrorCode &status) {
767 return MeasureUnit::create(3, 4, status);
768}
769
770MeasureUnit MeasureUnit::getPartPerMillion() {
771 return MeasureUnit(3, 4);
772}
773
774MeasureUnit *MeasureUnit::createPercent(UErrorCode &status) {
775 return MeasureUnit::create(3, 5, status);
776}
777
778MeasureUnit MeasureUnit::getPercent() {
779 return MeasureUnit(3, 5);
780}
781
782MeasureUnit *MeasureUnit::createPermille(UErrorCode &status) {
783 return MeasureUnit::create(3, 6, status);
784}
785
786MeasureUnit MeasureUnit::getPermille() {
787 return MeasureUnit(3, 6);
788}
789
790MeasureUnit *MeasureUnit::createPermyriad(UErrorCode &status) {
791 return MeasureUnit::create(3, 7, status);
792}
793
794MeasureUnit MeasureUnit::getPermyriad() {
795 return MeasureUnit(3, 7);
796}
797
2ca993e8
A
798MeasureUnit *MeasureUnit::createLiterPer100Kilometers(UErrorCode &status) {
799 return MeasureUnit::create(4, 0, status);
800}
801
3d1f044b
A
802MeasureUnit MeasureUnit::getLiterPer100Kilometers() {
803 return MeasureUnit(4, 0);
804}
805
2ca993e8
A
806MeasureUnit *MeasureUnit::createLiterPerKilometer(UErrorCode &status) {
807 return MeasureUnit::create(4, 1, status);
808}
809
3d1f044b
A
810MeasureUnit MeasureUnit::getLiterPerKilometer() {
811 return MeasureUnit(4, 1);
812}
813
2ca993e8
A
814MeasureUnit *MeasureUnit::createMilePerGallon(UErrorCode &status) {
815 return MeasureUnit::create(4, 2, status);
816}
817
3d1f044b
A
818MeasureUnit MeasureUnit::getMilePerGallon() {
819 return MeasureUnit(4, 2);
820}
821
2ca993e8
A
822MeasureUnit *MeasureUnit::createMilePerGallonImperial(UErrorCode &status) {
823 return MeasureUnit::create(4, 3, status);
824}
825
3d1f044b
A
826MeasureUnit MeasureUnit::getMilePerGallonImperial() {
827 return MeasureUnit(4, 3);
828}
829
b331163b 830MeasureUnit *MeasureUnit::createBit(UErrorCode &status) {
2ca993e8 831 return MeasureUnit::create(6, 0, status);
b331163b
A
832}
833
3d1f044b
A
834MeasureUnit MeasureUnit::getBit() {
835 return MeasureUnit(6, 0);
836}
837
b331163b 838MeasureUnit *MeasureUnit::createByte(UErrorCode &status) {
2ca993e8 839 return MeasureUnit::create(6, 1, status);
b331163b
A
840}
841
3d1f044b
A
842MeasureUnit MeasureUnit::getByte() {
843 return MeasureUnit(6, 1);
844}
845
b331163b 846MeasureUnit *MeasureUnit::createGigabit(UErrorCode &status) {
2ca993e8 847 return MeasureUnit::create(6, 2, status);
b331163b
A
848}
849
3d1f044b
A
850MeasureUnit MeasureUnit::getGigabit() {
851 return MeasureUnit(6, 2);
852}
853
b331163b 854MeasureUnit *MeasureUnit::createGigabyte(UErrorCode &status) {
2ca993e8 855 return MeasureUnit::create(6, 3, status);
b331163b
A
856}
857
3d1f044b
A
858MeasureUnit MeasureUnit::getGigabyte() {
859 return MeasureUnit(6, 3);
860}
861
b331163b 862MeasureUnit *MeasureUnit::createKilobit(UErrorCode &status) {
2ca993e8 863 return MeasureUnit::create(6, 4, status);
b331163b
A
864}
865
3d1f044b
A
866MeasureUnit MeasureUnit::getKilobit() {
867 return MeasureUnit(6, 4);
868}
869
b331163b 870MeasureUnit *MeasureUnit::createKilobyte(UErrorCode &status) {
2ca993e8 871 return MeasureUnit::create(6, 5, status);
b331163b
A
872}
873
3d1f044b
A
874MeasureUnit MeasureUnit::getKilobyte() {
875 return MeasureUnit(6, 5);
876}
877
b331163b 878MeasureUnit *MeasureUnit::createMegabit(UErrorCode &status) {
2ca993e8 879 return MeasureUnit::create(6, 6, status);
b331163b
A
880}
881
3d1f044b
A
882MeasureUnit MeasureUnit::getMegabit() {
883 return MeasureUnit(6, 6);
884}
885
b331163b 886MeasureUnit *MeasureUnit::createMegabyte(UErrorCode &status) {
2ca993e8 887 return MeasureUnit::create(6, 7, status);
b331163b
A
888}
889
3d1f044b
A
890MeasureUnit MeasureUnit::getMegabyte() {
891 return MeasureUnit(6, 7);
892}
893
894MeasureUnit *MeasureUnit::createPetabyte(UErrorCode &status) {
2ca993e8 895 return MeasureUnit::create(6, 8, status);
b331163b
A
896}
897
3d1f044b
A
898MeasureUnit MeasureUnit::getPetabyte() {
899 return MeasureUnit(6, 8);
900}
901
902MeasureUnit *MeasureUnit::createTerabit(UErrorCode &status) {
2ca993e8
A
903 return MeasureUnit::create(6, 9, status);
904}
905
3d1f044b
A
906MeasureUnit MeasureUnit::getTerabit() {
907 return MeasureUnit(6, 9);
908}
909
910MeasureUnit *MeasureUnit::createTerabyte(UErrorCode &status) {
911 return MeasureUnit::create(6, 10, status);
912}
913
914MeasureUnit MeasureUnit::getTerabyte() {
915 return MeasureUnit(6, 10);
916}
917
2ca993e8
A
918MeasureUnit *MeasureUnit::createCentury(UErrorCode &status) {
919 return MeasureUnit::create(7, 0, status);
b331163b
A
920}
921
3d1f044b
A
922MeasureUnit MeasureUnit::getCentury() {
923 return MeasureUnit(7, 0);
924}
925
57a6839d 926MeasureUnit *MeasureUnit::createDay(UErrorCode &status) {
2ca993e8 927 return MeasureUnit::create(7, 1, status);
57a6839d
A
928}
929
3d1f044b
A
930MeasureUnit MeasureUnit::getDay() {
931 return MeasureUnit(7, 1);
932}
933
934MeasureUnit *MeasureUnit::createDayPerson(UErrorCode &status) {
2ca993e8 935 return MeasureUnit::create(7, 2, status);
b331163b
A
936}
937
3d1f044b
A
938MeasureUnit MeasureUnit::getDayPerson() {
939 return MeasureUnit(7, 2);
940}
941
942MeasureUnit *MeasureUnit::createHour(UErrorCode &status) {
2ca993e8 943 return MeasureUnit::create(7, 3, status);
57a6839d
A
944}
945
3d1f044b
A
946MeasureUnit MeasureUnit::getHour() {
947 return MeasureUnit(7, 3);
948}
949
950MeasureUnit *MeasureUnit::createMicrosecond(UErrorCode &status) {
2ca993e8 951 return MeasureUnit::create(7, 4, status);
57a6839d
A
952}
953
3d1f044b
A
954MeasureUnit MeasureUnit::getMicrosecond() {
955 return MeasureUnit(7, 4);
956}
957
958MeasureUnit *MeasureUnit::createMillisecond(UErrorCode &status) {
2ca993e8 959 return MeasureUnit::create(7, 5, status);
57a6839d
A
960}
961
3d1f044b
A
962MeasureUnit MeasureUnit::getMillisecond() {
963 return MeasureUnit(7, 5);
964}
965
966MeasureUnit *MeasureUnit::createMinute(UErrorCode &status) {
2ca993e8 967 return MeasureUnit::create(7, 6, status);
b331163b
A
968}
969
3d1f044b
A
970MeasureUnit MeasureUnit::getMinute() {
971 return MeasureUnit(7, 6);
972}
973
974MeasureUnit *MeasureUnit::createMonth(UErrorCode &status) {
2ca993e8 975 return MeasureUnit::create(7, 7, status);
57a6839d
A
976}
977
3d1f044b
A
978MeasureUnit MeasureUnit::getMonth() {
979 return MeasureUnit(7, 7);
980}
981
982MeasureUnit *MeasureUnit::createMonthPerson(UErrorCode &status) {
2ca993e8 983 return MeasureUnit::create(7, 8, status);
57a6839d
A
984}
985
3d1f044b
A
986MeasureUnit MeasureUnit::getMonthPerson() {
987 return MeasureUnit(7, 8);
988}
989
990MeasureUnit *MeasureUnit::createNanosecond(UErrorCode &status) {
2ca993e8 991 return MeasureUnit::create(7, 9, status);
57a6839d
A
992}
993
3d1f044b
A
994MeasureUnit MeasureUnit::getNanosecond() {
995 return MeasureUnit(7, 9);
996}
997
998MeasureUnit *MeasureUnit::createSecond(UErrorCode &status) {
2ca993e8 999 return MeasureUnit::create(7, 10, status);
b331163b
A
1000}
1001
3d1f044b
A
1002MeasureUnit MeasureUnit::getSecond() {
1003 return MeasureUnit(7, 10);
1004}
1005
1006MeasureUnit *MeasureUnit::createWeek(UErrorCode &status) {
1007 return MeasureUnit::create(7, 11, status);
1008}
1009
1010MeasureUnit MeasureUnit::getWeek() {
1011 return MeasureUnit(7, 11);
1012}
1013
1014MeasureUnit *MeasureUnit::createWeekPerson(UErrorCode &status) {
1015 return MeasureUnit::create(7, 12, status);
1016}
1017
1018MeasureUnit MeasureUnit::getWeekPerson() {
1019 return MeasureUnit(7, 12);
1020}
1021
1022MeasureUnit *MeasureUnit::createYear(UErrorCode &status) {
1023 return MeasureUnit::create(7, 13, status);
1024}
1025
1026MeasureUnit MeasureUnit::getYear() {
1027 return MeasureUnit(7, 13);
1028}
1029
1030MeasureUnit *MeasureUnit::createYearPerson(UErrorCode &status) {
1031 return MeasureUnit::create(7, 14, status);
1032}
1033
1034MeasureUnit MeasureUnit::getYearPerson() {
1035 return MeasureUnit(7, 14);
1036}
1037
b331163b 1038MeasureUnit *MeasureUnit::createAmpere(UErrorCode &status) {
2ca993e8 1039 return MeasureUnit::create(8, 0, status);
b331163b
A
1040}
1041
3d1f044b
A
1042MeasureUnit MeasureUnit::getAmpere() {
1043 return MeasureUnit(8, 0);
1044}
1045
b331163b 1046MeasureUnit *MeasureUnit::createMilliampere(UErrorCode &status) {
2ca993e8 1047 return MeasureUnit::create(8, 1, status);
b331163b
A
1048}
1049
3d1f044b
A
1050MeasureUnit MeasureUnit::getMilliampere() {
1051 return MeasureUnit(8, 1);
1052}
1053
b331163b 1054MeasureUnit *MeasureUnit::createOhm(UErrorCode &status) {
2ca993e8 1055 return MeasureUnit::create(8, 2, status);
b331163b
A
1056}
1057
3d1f044b
A
1058MeasureUnit MeasureUnit::getOhm() {
1059 return MeasureUnit(8, 2);
1060}
1061
b331163b 1062MeasureUnit *MeasureUnit::createVolt(UErrorCode &status) {
2ca993e8 1063 return MeasureUnit::create(8, 3, status);
b331163b
A
1064}
1065
3d1f044b
A
1066MeasureUnit MeasureUnit::getVolt() {
1067 return MeasureUnit(8, 3);
1068}
1069
1070MeasureUnit *MeasureUnit::createBritishThermalUnit(UErrorCode &status) {
2ca993e8 1071 return MeasureUnit::create(9, 0, status);
b331163b
A
1072}
1073
3d1f044b
A
1074MeasureUnit MeasureUnit::getBritishThermalUnit() {
1075 return MeasureUnit(9, 0);
1076}
1077
1078MeasureUnit *MeasureUnit::createCalorie(UErrorCode &status) {
2ca993e8 1079 return MeasureUnit::create(9, 1, status);
b331163b
A
1080}
1081
3d1f044b
A
1082MeasureUnit MeasureUnit::getCalorie() {
1083 return MeasureUnit(9, 1);
1084}
1085
1086MeasureUnit *MeasureUnit::createElectronvolt(UErrorCode &status) {
2ca993e8 1087 return MeasureUnit::create(9, 2, status);
b331163b
A
1088}
1089
3d1f044b
A
1090MeasureUnit MeasureUnit::getElectronvolt() {
1091 return MeasureUnit(9, 2);
1092}
1093
1094MeasureUnit *MeasureUnit::createFoodcalorie(UErrorCode &status) {
2ca993e8 1095 return MeasureUnit::create(9, 3, status);
b331163b
A
1096}
1097
3d1f044b
A
1098MeasureUnit MeasureUnit::getFoodcalorie() {
1099 return MeasureUnit(9, 3);
1100}
1101
1102MeasureUnit *MeasureUnit::createJoule(UErrorCode &status) {
2ca993e8 1103 return MeasureUnit::create(9, 4, status);
b331163b
A
1104}
1105
3d1f044b
A
1106MeasureUnit MeasureUnit::getJoule() {
1107 return MeasureUnit(9, 4);
1108}
1109
1110MeasureUnit *MeasureUnit::createKilocalorie(UErrorCode &status) {
2ca993e8 1111 return MeasureUnit::create(9, 5, status);
b331163b
A
1112}
1113
3d1f044b
A
1114MeasureUnit MeasureUnit::getKilocalorie() {
1115 return MeasureUnit(9, 5);
1116}
1117
1118MeasureUnit *MeasureUnit::createKilojoule(UErrorCode &status) {
1119 return MeasureUnit::create(9, 6, status);
1120}
1121
1122MeasureUnit MeasureUnit::getKilojoule() {
1123 return MeasureUnit(9, 6);
1124}
1125
1126MeasureUnit *MeasureUnit::createKilowattHour(UErrorCode &status) {
1127 return MeasureUnit::create(9, 7, status);
1128}
1129
1130MeasureUnit MeasureUnit::getKilowattHour() {
1131 return MeasureUnit(9, 7);
1132}
1133
1134MeasureUnit *MeasureUnit::createNewton(UErrorCode &status) {
2ca993e8 1135 return MeasureUnit::create(10, 0, status);
b331163b
A
1136}
1137
3d1f044b
A
1138MeasureUnit MeasureUnit::getNewton() {
1139 return MeasureUnit(10, 0);
1140}
1141
1142MeasureUnit *MeasureUnit::createPoundForce(UErrorCode &status) {
2ca993e8 1143 return MeasureUnit::create(10, 1, status);
b331163b
A
1144}
1145
3d1f044b
A
1146MeasureUnit MeasureUnit::getPoundForce() {
1147 return MeasureUnit(10, 1);
1148}
1149
1150MeasureUnit *MeasureUnit::createGigahertz(UErrorCode &status) {
1151 return MeasureUnit::create(11, 0, status);
1152}
1153
1154MeasureUnit MeasureUnit::getGigahertz() {
1155 return MeasureUnit(11, 0);
1156}
1157
1158MeasureUnit *MeasureUnit::createHertz(UErrorCode &status) {
1159 return MeasureUnit::create(11, 1, status);
1160}
1161
1162MeasureUnit MeasureUnit::getHertz() {
1163 return MeasureUnit(11, 1);
1164}
1165
b331163b 1166MeasureUnit *MeasureUnit::createKilohertz(UErrorCode &status) {
3d1f044b
A
1167 return MeasureUnit::create(11, 2, status);
1168}
1169
1170MeasureUnit MeasureUnit::getKilohertz() {
1171 return MeasureUnit(11, 2);
b331163b
A
1172}
1173
1174MeasureUnit *MeasureUnit::createMegahertz(UErrorCode &status) {
3d1f044b
A
1175 return MeasureUnit::create(11, 3, status);
1176}
1177
1178MeasureUnit MeasureUnit::getMegahertz() {
1179 return MeasureUnit(11, 3);
b331163b
A
1180}
1181
1182MeasureUnit *MeasureUnit::createAstronomicalUnit(UErrorCode &status) {
3d1f044b
A
1183 return MeasureUnit::create(12, 0, status);
1184}
1185
1186MeasureUnit MeasureUnit::getAstronomicalUnit() {
1187 return MeasureUnit(12, 0);
57a6839d
A
1188}
1189
1190MeasureUnit *MeasureUnit::createCentimeter(UErrorCode &status) {
3d1f044b
A
1191 return MeasureUnit::create(12, 1, status);
1192}
1193
1194MeasureUnit MeasureUnit::getCentimeter() {
1195 return MeasureUnit(12, 1);
b331163b
A
1196}
1197
1198MeasureUnit *MeasureUnit::createDecimeter(UErrorCode &status) {
3d1f044b
A
1199 return MeasureUnit::create(12, 2, status);
1200}
1201
1202MeasureUnit MeasureUnit::getDecimeter() {
1203 return MeasureUnit(12, 2);
b331163b
A
1204}
1205
1206MeasureUnit *MeasureUnit::createFathom(UErrorCode &status) {
3d1f044b
A
1207 return MeasureUnit::create(12, 3, status);
1208}
1209
1210MeasureUnit MeasureUnit::getFathom() {
1211 return MeasureUnit(12, 3);
57a6839d
A
1212}
1213
1214MeasureUnit *MeasureUnit::createFoot(UErrorCode &status) {
3d1f044b
A
1215 return MeasureUnit::create(12, 4, status);
1216}
1217
1218MeasureUnit MeasureUnit::getFoot() {
1219 return MeasureUnit(12, 4);
b331163b
A
1220}
1221
1222MeasureUnit *MeasureUnit::createFurlong(UErrorCode &status) {
3d1f044b
A
1223 return MeasureUnit::create(12, 5, status);
1224}
1225
1226MeasureUnit MeasureUnit::getFurlong() {
1227 return MeasureUnit(12, 5);
57a6839d
A
1228}
1229
1230MeasureUnit *MeasureUnit::createInch(UErrorCode &status) {
3d1f044b
A
1231 return MeasureUnit::create(12, 6, status);
1232}
1233
1234MeasureUnit MeasureUnit::getInch() {
1235 return MeasureUnit(12, 6);
57a6839d
A
1236}
1237
1238MeasureUnit *MeasureUnit::createKilometer(UErrorCode &status) {
3d1f044b
A
1239 return MeasureUnit::create(12, 7, status);
1240}
1241
1242MeasureUnit MeasureUnit::getKilometer() {
1243 return MeasureUnit(12, 7);
57a6839d
A
1244}
1245
1246MeasureUnit *MeasureUnit::createLightYear(UErrorCode &status) {
3d1f044b
A
1247 return MeasureUnit::create(12, 8, status);
1248}
1249
1250MeasureUnit MeasureUnit::getLightYear() {
1251 return MeasureUnit(12, 8);
57a6839d
A
1252}
1253
1254MeasureUnit *MeasureUnit::createMeter(UErrorCode &status) {
3d1f044b
A
1255 return MeasureUnit::create(12, 9, status);
1256}
1257
1258MeasureUnit MeasureUnit::getMeter() {
1259 return MeasureUnit(12, 9);
b331163b
A
1260}
1261
1262MeasureUnit *MeasureUnit::createMicrometer(UErrorCode &status) {
3d1f044b
A
1263 return MeasureUnit::create(12, 10, status);
1264}
1265
1266MeasureUnit MeasureUnit::getMicrometer() {
1267 return MeasureUnit(12, 10);
57a6839d
A
1268}
1269
1270MeasureUnit *MeasureUnit::createMile(UErrorCode &status) {
3d1f044b
A
1271 return MeasureUnit::create(12, 11, status);
1272}
1273
1274MeasureUnit MeasureUnit::getMile() {
1275 return MeasureUnit(12, 11);
2ca993e8
A
1276}
1277
1278MeasureUnit *MeasureUnit::createMileScandinavian(UErrorCode &status) {
3d1f044b
A
1279 return MeasureUnit::create(12, 12, status);
1280}
1281
1282MeasureUnit MeasureUnit::getMileScandinavian() {
1283 return MeasureUnit(12, 12);
57a6839d
A
1284}
1285
1286MeasureUnit *MeasureUnit::createMillimeter(UErrorCode &status) {
3d1f044b
A
1287 return MeasureUnit::create(12, 13, status);
1288}
1289
1290MeasureUnit MeasureUnit::getMillimeter() {
1291 return MeasureUnit(12, 13);
b331163b
A
1292}
1293
1294MeasureUnit *MeasureUnit::createNanometer(UErrorCode &status) {
3d1f044b
A
1295 return MeasureUnit::create(12, 14, status);
1296}
1297
1298MeasureUnit MeasureUnit::getNanometer() {
1299 return MeasureUnit(12, 14);
b331163b
A
1300}
1301
1302MeasureUnit *MeasureUnit::createNauticalMile(UErrorCode &status) {
3d1f044b
A
1303 return MeasureUnit::create(12, 15, status);
1304}
1305
1306MeasureUnit MeasureUnit::getNauticalMile() {
1307 return MeasureUnit(12, 15);
b331163b
A
1308}
1309
1310MeasureUnit *MeasureUnit::createParsec(UErrorCode &status) {
3d1f044b
A
1311 return MeasureUnit::create(12, 16, status);
1312}
1313
1314MeasureUnit MeasureUnit::getParsec() {
1315 return MeasureUnit(12, 16);
57a6839d
A
1316}
1317
1318MeasureUnit *MeasureUnit::createPicometer(UErrorCode &status) {
3d1f044b
A
1319 return MeasureUnit::create(12, 17, status);
1320}
1321
1322MeasureUnit MeasureUnit::getPicometer() {
1323 return MeasureUnit(12, 17);
57a6839d
A
1324}
1325
f3c0d7a5 1326MeasureUnit *MeasureUnit::createPoint(UErrorCode &status) {
3d1f044b
A
1327 return MeasureUnit::create(12, 18, status);
1328}
1329
1330MeasureUnit MeasureUnit::getPoint() {
1331 return MeasureUnit(12, 18);
1332}
1333
1334MeasureUnit *MeasureUnit::createSolarRadius(UErrorCode &status) {
1335 return MeasureUnit::create(12, 19, status);
1336}
1337
1338MeasureUnit MeasureUnit::getSolarRadius() {
1339 return MeasureUnit(12, 19);
b331163b
A
1340}
1341
f3c0d7a5 1342MeasureUnit *MeasureUnit::createYard(UErrorCode &status) {
3d1f044b
A
1343 return MeasureUnit::create(12, 20, status);
1344}
1345
1346MeasureUnit MeasureUnit::getYard() {
1347 return MeasureUnit(12, 20);
f3c0d7a5
A
1348}
1349
b331163b 1350MeasureUnit *MeasureUnit::createLux(UErrorCode &status) {
3d1f044b
A
1351 return MeasureUnit::create(13, 0, status);
1352}
1353
1354MeasureUnit MeasureUnit::getLux() {
1355 return MeasureUnit(13, 0);
1356}
1357
1358MeasureUnit *MeasureUnit::createSolarLuminosity(UErrorCode &status) {
1359 return MeasureUnit::create(13, 1, status);
1360}
1361
1362MeasureUnit MeasureUnit::getSolarLuminosity() {
1363 return MeasureUnit(13, 1);
b331163b
A
1364}
1365
1366MeasureUnit *MeasureUnit::createCarat(UErrorCode &status) {
3d1f044b
A
1367 return MeasureUnit::create(14, 0, status);
1368}
1369
1370MeasureUnit MeasureUnit::getCarat() {
1371 return MeasureUnit(14, 0);
1372}
1373
1374MeasureUnit *MeasureUnit::createDalton(UErrorCode &status) {
1375 return MeasureUnit::create(14, 1, status);
1376}
1377
1378MeasureUnit MeasureUnit::getDalton() {
1379 return MeasureUnit(14, 1);
1380}
1381
1382MeasureUnit *MeasureUnit::createEarthMass(UErrorCode &status) {
1383 return MeasureUnit::create(14, 2, status);
1384}
1385
1386MeasureUnit MeasureUnit::getEarthMass() {
1387 return MeasureUnit(14, 2);
57a6839d
A
1388}
1389
1390MeasureUnit *MeasureUnit::createGram(UErrorCode &status) {
3d1f044b
A
1391 return MeasureUnit::create(14, 3, status);
1392}
1393
1394MeasureUnit MeasureUnit::getGram() {
1395 return MeasureUnit(14, 3);
57a6839d
A
1396}
1397
1398MeasureUnit *MeasureUnit::createKilogram(UErrorCode &status) {
3d1f044b
A
1399 return MeasureUnit::create(14, 4, status);
1400}
1401
1402MeasureUnit MeasureUnit::getKilogram() {
1403 return MeasureUnit(14, 4);
b331163b
A
1404}
1405
1406MeasureUnit *MeasureUnit::createMetricTon(UErrorCode &status) {
3d1f044b
A
1407 return MeasureUnit::create(14, 5, status);
1408}
1409
1410MeasureUnit MeasureUnit::getMetricTon() {
1411 return MeasureUnit(14, 5);
b331163b
A
1412}
1413
1414MeasureUnit *MeasureUnit::createMicrogram(UErrorCode &status) {
3d1f044b
A
1415 return MeasureUnit::create(14, 6, status);
1416}
1417
1418MeasureUnit MeasureUnit::getMicrogram() {
1419 return MeasureUnit(14, 6);
b331163b
A
1420}
1421
1422MeasureUnit *MeasureUnit::createMilligram(UErrorCode &status) {
3d1f044b
A
1423 return MeasureUnit::create(14, 7, status);
1424}
1425
1426MeasureUnit MeasureUnit::getMilligram() {
1427 return MeasureUnit(14, 7);
57a6839d
A
1428}
1429
1430MeasureUnit *MeasureUnit::createOunce(UErrorCode &status) {
3d1f044b
A
1431 return MeasureUnit::create(14, 8, status);
1432}
1433
1434MeasureUnit MeasureUnit::getOunce() {
1435 return MeasureUnit(14, 8);
b331163b
A
1436}
1437
1438MeasureUnit *MeasureUnit::createOunceTroy(UErrorCode &status) {
3d1f044b
A
1439 return MeasureUnit::create(14, 9, status);
1440}
1441
1442MeasureUnit MeasureUnit::getOunceTroy() {
1443 return MeasureUnit(14, 9);
57a6839d
A
1444}
1445
1446MeasureUnit *MeasureUnit::createPound(UErrorCode &status) {
3d1f044b
A
1447 return MeasureUnit::create(14, 10, status);
1448}
1449
1450MeasureUnit MeasureUnit::getPound() {
1451 return MeasureUnit(14, 10);
1452}
1453
1454MeasureUnit *MeasureUnit::createSolarMass(UErrorCode &status) {
1455 return MeasureUnit::create(14, 11, status);
1456}
1457
1458MeasureUnit MeasureUnit::getSolarMass() {
1459 return MeasureUnit(14, 11);
57a6839d
A
1460}
1461
1462MeasureUnit *MeasureUnit::createStone(UErrorCode &status) {
3d1f044b
A
1463 return MeasureUnit::create(14, 12, status);
1464}
1465
1466MeasureUnit MeasureUnit::getStone() {
1467 return MeasureUnit(14, 12);
b331163b
A
1468}
1469
1470MeasureUnit *MeasureUnit::createTon(UErrorCode &status) {
3d1f044b
A
1471 return MeasureUnit::create(14, 13, status);
1472}
1473
1474MeasureUnit MeasureUnit::getTon() {
1475 return MeasureUnit(14, 13);
b331163b
A
1476}
1477
1478MeasureUnit *MeasureUnit::createGigawatt(UErrorCode &status) {
3d1f044b
A
1479 return MeasureUnit::create(16, 0, status);
1480}
1481
1482MeasureUnit MeasureUnit::getGigawatt() {
1483 return MeasureUnit(16, 0);
57a6839d
A
1484}
1485
1486MeasureUnit *MeasureUnit::createHorsepower(UErrorCode &status) {
3d1f044b
A
1487 return MeasureUnit::create(16, 1, status);
1488}
1489
1490MeasureUnit MeasureUnit::getHorsepower() {
1491 return MeasureUnit(16, 1);
57a6839d
A
1492}
1493
1494MeasureUnit *MeasureUnit::createKilowatt(UErrorCode &status) {
3d1f044b
A
1495 return MeasureUnit::create(16, 2, status);
1496}
1497
1498MeasureUnit MeasureUnit::getKilowatt() {
1499 return MeasureUnit(16, 2);
b331163b
A
1500}
1501
1502MeasureUnit *MeasureUnit::createMegawatt(UErrorCode &status) {
3d1f044b
A
1503 return MeasureUnit::create(16, 3, status);
1504}
1505
1506MeasureUnit MeasureUnit::getMegawatt() {
1507 return MeasureUnit(16, 3);
b331163b
A
1508}
1509
1510MeasureUnit *MeasureUnit::createMilliwatt(UErrorCode &status) {
3d1f044b
A
1511 return MeasureUnit::create(16, 4, status);
1512}
1513
1514MeasureUnit MeasureUnit::getMilliwatt() {
1515 return MeasureUnit(16, 4);
57a6839d
A
1516}
1517
1518MeasureUnit *MeasureUnit::createWatt(UErrorCode &status) {
3d1f044b
A
1519 return MeasureUnit::create(16, 5, status);
1520}
1521
1522MeasureUnit MeasureUnit::getWatt() {
1523 return MeasureUnit(16, 5);
1524}
1525
1526MeasureUnit *MeasureUnit::createAtmosphere(UErrorCode &status) {
1527 return MeasureUnit::create(17, 0, status);
1528}
1529
1530MeasureUnit MeasureUnit::getAtmosphere() {
1531 return MeasureUnit(17, 0);
57a6839d
A
1532}
1533
1534MeasureUnit *MeasureUnit::createHectopascal(UErrorCode &status) {
3d1f044b
A
1535 return MeasureUnit::create(17, 1, status);
1536}
1537
1538MeasureUnit MeasureUnit::getHectopascal() {
1539 return MeasureUnit(17, 1);
57a6839d
A
1540}
1541
1542MeasureUnit *MeasureUnit::createInchHg(UErrorCode &status) {
3d1f044b
A
1543 return MeasureUnit::create(17, 2, status);
1544}
1545
1546MeasureUnit MeasureUnit::getInchHg() {
1547 return MeasureUnit(17, 2);
1548}
1549
1550MeasureUnit *MeasureUnit::createKilopascal(UErrorCode &status) {
1551 return MeasureUnit::create(17, 3, status);
1552}
1553
1554MeasureUnit MeasureUnit::getKilopascal() {
1555 return MeasureUnit(17, 3);
1556}
1557
1558MeasureUnit *MeasureUnit::createMegapascal(UErrorCode &status) {
1559 return MeasureUnit::create(17, 4, status);
1560}
1561
1562MeasureUnit MeasureUnit::getMegapascal() {
1563 return MeasureUnit(17, 4);
57a6839d
A
1564}
1565
1566MeasureUnit *MeasureUnit::createMillibar(UErrorCode &status) {
3d1f044b
A
1567 return MeasureUnit::create(17, 5, status);
1568}
1569
1570MeasureUnit MeasureUnit::getMillibar() {
1571 return MeasureUnit(17, 5);
b331163b
A
1572}
1573
1574MeasureUnit *MeasureUnit::createMillimeterOfMercury(UErrorCode &status) {
3d1f044b
A
1575 return MeasureUnit::create(17, 6, status);
1576}
1577
1578MeasureUnit MeasureUnit::getMillimeterOfMercury() {
1579 return MeasureUnit(17, 6);
b331163b
A
1580}
1581
1582MeasureUnit *MeasureUnit::createPoundPerSquareInch(UErrorCode &status) {
3d1f044b
A
1583 return MeasureUnit::create(17, 7, status);
1584}
1585
1586MeasureUnit MeasureUnit::getPoundPerSquareInch() {
1587 return MeasureUnit(17, 7);
57a6839d
A
1588}
1589
1590MeasureUnit *MeasureUnit::createKilometerPerHour(UErrorCode &status) {
3d1f044b
A
1591 return MeasureUnit::create(18, 0, status);
1592}
1593
1594MeasureUnit MeasureUnit::getKilometerPerHour() {
1595 return MeasureUnit(18, 0);
57a6839d
A
1596}
1597
2ca993e8 1598MeasureUnit *MeasureUnit::createKnot(UErrorCode &status) {
3d1f044b
A
1599 return MeasureUnit::create(18, 1, status);
1600}
1601
1602MeasureUnit MeasureUnit::getKnot() {
1603 return MeasureUnit(18, 1);
57a6839d
A
1604}
1605
2ca993e8 1606MeasureUnit *MeasureUnit::createMeterPerSecond(UErrorCode &status) {
3d1f044b
A
1607 return MeasureUnit::create(18, 2, status);
1608}
1609
1610MeasureUnit MeasureUnit::getMeterPerSecond() {
1611 return MeasureUnit(18, 2);
57a6839d
A
1612}
1613
2ca993e8 1614MeasureUnit *MeasureUnit::createMilePerHour(UErrorCode &status) {
3d1f044b
A
1615 return MeasureUnit::create(18, 3, status);
1616}
1617
1618MeasureUnit MeasureUnit::getMilePerHour() {
1619 return MeasureUnit(18, 3);
2ca993e8
A
1620}
1621
57a6839d 1622MeasureUnit *MeasureUnit::createCelsius(UErrorCode &status) {
3d1f044b
A
1623 return MeasureUnit::create(19, 0, status);
1624}
1625
1626MeasureUnit MeasureUnit::getCelsius() {
1627 return MeasureUnit(19, 0);
57a6839d
A
1628}
1629
1630MeasureUnit *MeasureUnit::createFahrenheit(UErrorCode &status) {
3d1f044b
A
1631 return MeasureUnit::create(19, 1, status);
1632}
1633
1634MeasureUnit MeasureUnit::getFahrenheit() {
1635 return MeasureUnit(19, 1);
b331163b
A
1636}
1637
2ca993e8 1638MeasureUnit *MeasureUnit::createGenericTemperature(UErrorCode &status) {
3d1f044b
A
1639 return MeasureUnit::create(19, 2, status);
1640}
1641
1642MeasureUnit MeasureUnit::getGenericTemperature() {
1643 return MeasureUnit(19, 2);
b331163b
A
1644}
1645
2ca993e8 1646MeasureUnit *MeasureUnit::createKelvin(UErrorCode &status) {
3d1f044b
A
1647 return MeasureUnit::create(19, 3, status);
1648}
1649
1650MeasureUnit MeasureUnit::getKelvin() {
1651 return MeasureUnit(19, 3);
1652}
1653
1654MeasureUnit *MeasureUnit::createNewtonMeter(UErrorCode &status) {
1655 return MeasureUnit::create(20, 0, status);
1656}
1657
1658MeasureUnit MeasureUnit::getNewtonMeter() {
1659 return MeasureUnit(20, 0);
1660}
1661
1662MeasureUnit *MeasureUnit::createPoundFoot(UErrorCode &status) {
1663 return MeasureUnit::create(20, 1, status);
1664}
1665
1666MeasureUnit MeasureUnit::getPoundFoot() {
1667 return MeasureUnit(20, 1);
b331163b
A
1668}
1669
1670MeasureUnit *MeasureUnit::createAcreFoot(UErrorCode &status) {
3d1f044b
A
1671 return MeasureUnit::create(21, 0, status);
1672}
1673
1674MeasureUnit MeasureUnit::getAcreFoot() {
1675 return MeasureUnit(21, 0);
1676}
1677
1678MeasureUnit *MeasureUnit::createBarrel(UErrorCode &status) {
1679 return MeasureUnit::create(21, 1, status);
1680}
1681
1682MeasureUnit MeasureUnit::getBarrel() {
1683 return MeasureUnit(21, 1);
b331163b
A
1684}
1685
1686MeasureUnit *MeasureUnit::createBushel(UErrorCode &status) {
3d1f044b
A
1687 return MeasureUnit::create(21, 2, status);
1688}
1689
1690MeasureUnit MeasureUnit::getBushel() {
1691 return MeasureUnit(21, 2);
b331163b
A
1692}
1693
1694MeasureUnit *MeasureUnit::createCentiliter(UErrorCode &status) {
3d1f044b
A
1695 return MeasureUnit::create(21, 3, status);
1696}
1697
1698MeasureUnit MeasureUnit::getCentiliter() {
1699 return MeasureUnit(21, 3);
b331163b
A
1700}
1701
1702MeasureUnit *MeasureUnit::createCubicCentimeter(UErrorCode &status) {
3d1f044b
A
1703 return MeasureUnit::create(21, 4, status);
1704}
1705
1706MeasureUnit MeasureUnit::getCubicCentimeter() {
1707 return MeasureUnit(21, 4);
b331163b
A
1708}
1709
1710MeasureUnit *MeasureUnit::createCubicFoot(UErrorCode &status) {
3d1f044b
A
1711 return MeasureUnit::create(21, 5, status);
1712}
1713
1714MeasureUnit MeasureUnit::getCubicFoot() {
1715 return MeasureUnit(21, 5);
b331163b
A
1716}
1717
1718MeasureUnit *MeasureUnit::createCubicInch(UErrorCode &status) {
3d1f044b
A
1719 return MeasureUnit::create(21, 6, status);
1720}
1721
1722MeasureUnit MeasureUnit::getCubicInch() {
1723 return MeasureUnit(21, 6);
57a6839d
A
1724}
1725
1726MeasureUnit *MeasureUnit::createCubicKilometer(UErrorCode &status) {
3d1f044b
A
1727 return MeasureUnit::create(21, 7, status);
1728}
1729
1730MeasureUnit MeasureUnit::getCubicKilometer() {
1731 return MeasureUnit(21, 7);
b331163b
A
1732}
1733
1734MeasureUnit *MeasureUnit::createCubicMeter(UErrorCode &status) {
3d1f044b
A
1735 return MeasureUnit::create(21, 8, status);
1736}
1737
1738MeasureUnit MeasureUnit::getCubicMeter() {
1739 return MeasureUnit(21, 8);
57a6839d
A
1740}
1741
1742MeasureUnit *MeasureUnit::createCubicMile(UErrorCode &status) {
3d1f044b
A
1743 return MeasureUnit::create(21, 9, status);
1744}
1745
1746MeasureUnit MeasureUnit::getCubicMile() {
1747 return MeasureUnit(21, 9);
b331163b
A
1748}
1749
1750MeasureUnit *MeasureUnit::createCubicYard(UErrorCode &status) {
3d1f044b
A
1751 return MeasureUnit::create(21, 10, status);
1752}
1753
1754MeasureUnit MeasureUnit::getCubicYard() {
1755 return MeasureUnit(21, 10);
b331163b
A
1756}
1757
1758MeasureUnit *MeasureUnit::createCup(UErrorCode &status) {
3d1f044b
A
1759 return MeasureUnit::create(21, 11, status);
1760}
1761
1762MeasureUnit MeasureUnit::getCup() {
1763 return MeasureUnit(21, 11);
b331163b
A
1764}
1765
2ca993e8 1766MeasureUnit *MeasureUnit::createCupMetric(UErrorCode &status) {
3d1f044b
A
1767 return MeasureUnit::create(21, 12, status);
1768}
1769
1770MeasureUnit MeasureUnit::getCupMetric() {
1771 return MeasureUnit(21, 12);
b331163b
A
1772}
1773
2ca993e8 1774MeasureUnit *MeasureUnit::createDeciliter(UErrorCode &status) {
3d1f044b
A
1775 return MeasureUnit::create(21, 13, status);
1776}
1777
1778MeasureUnit MeasureUnit::getDeciliter() {
1779 return MeasureUnit(21, 13);
b331163b
A
1780}
1781
2ca993e8 1782MeasureUnit *MeasureUnit::createFluidOunce(UErrorCode &status) {
3d1f044b
A
1783 return MeasureUnit::create(21, 14, status);
1784}
1785
1786MeasureUnit MeasureUnit::getFluidOunce() {
1787 return MeasureUnit(21, 14);
1788}
1789
1790MeasureUnit *MeasureUnit::createFluidOunceImperial(UErrorCode &status) {
1791 return MeasureUnit::create(21, 15, status);
1792}
1793
1794MeasureUnit MeasureUnit::getFluidOunceImperial() {
1795 return MeasureUnit(21, 15);
b331163b
A
1796}
1797
2ca993e8 1798MeasureUnit *MeasureUnit::createGallon(UErrorCode &status) {
3d1f044b
A
1799 return MeasureUnit::create(21, 16, status);
1800}
1801
1802MeasureUnit MeasureUnit::getGallon() {
1803 return MeasureUnit(21, 16);
57a6839d
A
1804}
1805
2ca993e8 1806MeasureUnit *MeasureUnit::createGallonImperial(UErrorCode &status) {
3d1f044b
A
1807 return MeasureUnit::create(21, 17, status);
1808}
1809
1810MeasureUnit MeasureUnit::getGallonImperial() {
1811 return MeasureUnit(21, 17);
57a6839d
A
1812}
1813
2ca993e8 1814MeasureUnit *MeasureUnit::createHectoliter(UErrorCode &status) {
3d1f044b
A
1815 return MeasureUnit::create(21, 18, status);
1816}
1817
1818MeasureUnit MeasureUnit::getHectoliter() {
1819 return MeasureUnit(21, 18);
57a6839d
A
1820}
1821
2ca993e8 1822MeasureUnit *MeasureUnit::createLiter(UErrorCode &status) {
3d1f044b
A
1823 return MeasureUnit::create(21, 19, status);
1824}
1825
1826MeasureUnit MeasureUnit::getLiter() {
1827 return MeasureUnit(21, 19);
57a6839d
A
1828}
1829
2ca993e8 1830MeasureUnit *MeasureUnit::createMegaliter(UErrorCode &status) {
3d1f044b
A
1831 return MeasureUnit::create(21, 20, status);
1832}
1833
1834MeasureUnit MeasureUnit::getMegaliter() {
1835 return MeasureUnit(21, 20);
57a6839d
A
1836}
1837
2ca993e8 1838MeasureUnit *MeasureUnit::createMilliliter(UErrorCode &status) {
3d1f044b
A
1839 return MeasureUnit::create(21, 21, status);
1840}
1841
1842MeasureUnit MeasureUnit::getMilliliter() {
1843 return MeasureUnit(21, 21);
57a6839d
A
1844}
1845
2ca993e8 1846MeasureUnit *MeasureUnit::createPint(UErrorCode &status) {
3d1f044b
A
1847 return MeasureUnit::create(21, 22, status);
1848}
1849
1850MeasureUnit MeasureUnit::getPint() {
1851 return MeasureUnit(21, 22);
b331163b
A
1852}
1853
2ca993e8 1854MeasureUnit *MeasureUnit::createPintMetric(UErrorCode &status) {
3d1f044b
A
1855 return MeasureUnit::create(21, 23, status);
1856}
1857
1858MeasureUnit MeasureUnit::getPintMetric() {
1859 return MeasureUnit(21, 23);
57a6839d
A
1860}
1861
2ca993e8 1862MeasureUnit *MeasureUnit::createQuart(UErrorCode &status) {
3d1f044b
A
1863 return MeasureUnit::create(21, 24, status);
1864}
1865
1866MeasureUnit MeasureUnit::getQuart() {
1867 return MeasureUnit(21, 24);
2ca993e8
A
1868}
1869
1870MeasureUnit *MeasureUnit::createTablespoon(UErrorCode &status) {
3d1f044b
A
1871 return MeasureUnit::create(21, 25, status);
1872}
1873
1874MeasureUnit MeasureUnit::getTablespoon() {
1875 return MeasureUnit(21, 25);
2ca993e8
A
1876}
1877
1878MeasureUnit *MeasureUnit::createTeaspoon(UErrorCode &status) {
3d1f044b
A
1879 return MeasureUnit::create(21, 26, status);
1880}
1881
1882MeasureUnit MeasureUnit::getTeaspoon() {
1883 return MeasureUnit(21, 26);
2ca993e8
A
1884}
1885
b331163b 1886// End generated code
57a6839d
A
1887
1888static int32_t binarySearch(
1889 const char * const * array, int32_t start, int32_t end, const char * key) {
1890 while (start < end) {
1891 int32_t mid = (start + end) / 2;
1892 int32_t cmp = uprv_strcmp(array[mid], key);
1893 if (cmp < 0) {
1894 start = mid + 1;
1895 continue;
1896 }
1897 if (cmp == 0) {
1898 return mid;
1899 }
1900 end = mid;
1901 }
1902 return -1;
1903}
0f5d89e8
A
1904
1905MeasureUnit::MeasureUnit() {
1906 fCurrency[0] = 0;
1907 fTypeId = kBaseTypeIdx;
1908 fSubTypeId = kBaseSubTypeIdx;
1909}
1910
57a6839d
A
1911MeasureUnit::MeasureUnit(const MeasureUnit &other)
1912 : fTypeId(other.fTypeId), fSubTypeId(other.fSubTypeId) {
1913 uprv_strcpy(fCurrency, other.fCurrency);
1914}
1915
1916MeasureUnit &MeasureUnit::operator=(const MeasureUnit &other) {
1917 if (this == &other) {
1918 return *this;
1919 }
1920 fTypeId = other.fTypeId;
1921 fSubTypeId = other.fSubTypeId;
1922 uprv_strcpy(fCurrency, other.fCurrency);
1923 return *this;
1924}
1925
1926UObject *MeasureUnit::clone() const {
1927 return new MeasureUnit(*this);
1928}
1929
1930MeasureUnit::~MeasureUnit() {
1931}
1932
1933const char *MeasureUnit::getType() const {
1934 return gTypes[fTypeId];
1935}
1936
1937const char *MeasureUnit::getSubtype() const {
1938 return fCurrency[0] == 0 ? gSubTypes[getOffset()] : fCurrency;
1939}
1940
1941UBool MeasureUnit::operator==(const UObject& other) const {
1942 if (this == &other) { // Same object, equal
1943 return TRUE;
1944 }
1945 if (typeid(*this) != typeid(other)) { // Different types, not equal
1946 return FALSE;
1947 }
1948 const MeasureUnit &rhs = static_cast<const MeasureUnit&>(other);
1949 return (
1950 fTypeId == rhs.fTypeId
1951 && fSubTypeId == rhs.fSubTypeId
1952 && uprv_strcmp(fCurrency, rhs.fCurrency) == 0);
1953}
1954
1955int32_t MeasureUnit::getIndex() const {
1956 return gIndexes[fTypeId] + fSubTypeId;
1957}
1958
1959int32_t MeasureUnit::getAvailable(
1960 MeasureUnit *dest,
1961 int32_t destCapacity,
1962 UErrorCode &errorCode) {
1963 if (U_FAILURE(errorCode)) {
1964 return 0;
1965 }
b331163b 1966 if (destCapacity < UPRV_LENGTHOF(gSubTypes)) {
57a6839d 1967 errorCode = U_BUFFER_OVERFLOW_ERROR;
b331163b 1968 return UPRV_LENGTHOF(gSubTypes);
57a6839d
A
1969 }
1970 int32_t idx = 0;
b331163b 1971 for (int32_t typeIdx = 0; typeIdx < UPRV_LENGTHOF(gTypes); ++typeIdx) {
57a6839d
A
1972 int32_t len = gOffsets[typeIdx + 1] - gOffsets[typeIdx];
1973 for (int32_t subTypeIdx = 0; subTypeIdx < len; ++subTypeIdx) {
1974 dest[idx].setTo(typeIdx, subTypeIdx);
1975 ++idx;
1976 }
1977 }
b331163b
A
1978 U_ASSERT(idx == UPRV_LENGTHOF(gSubTypes));
1979 return UPRV_LENGTHOF(gSubTypes);
57a6839d
A
1980}
1981
1982int32_t MeasureUnit::getAvailable(
1983 const char *type,
1984 MeasureUnit *dest,
1985 int32_t destCapacity,
1986 UErrorCode &errorCode) {
1987 if (U_FAILURE(errorCode)) {
1988 return 0;
1989 }
b331163b 1990 int32_t typeIdx = binarySearch(gTypes, 0, UPRV_LENGTHOF(gTypes), type);
57a6839d 1991 if (typeIdx == -1) {
b331163b 1992 return 0;
57a6839d
A
1993 }
1994 int32_t len = gOffsets[typeIdx + 1] - gOffsets[typeIdx];
1995 if (destCapacity < len) {
1996 errorCode = U_BUFFER_OVERFLOW_ERROR;
1997 return len;
1998 }
1999 for (int subTypeIdx = 0; subTypeIdx < len; ++subTypeIdx) {
2000 dest[subTypeIdx].setTo(typeIdx, subTypeIdx);
2001 }
2002 return len;
2003}
2004
2005StringEnumeration* MeasureUnit::getAvailableTypes(UErrorCode &errorCode) {
2006 UEnumeration *uenum = uenum_openCharStringsEnumeration(
b331163b 2007 gTypes, UPRV_LENGTHOF(gTypes), &errorCode);
57a6839d
A
2008 if (U_FAILURE(errorCode)) {
2009 uenum_close(uenum);
2010 return NULL;
2011 }
2012 StringEnumeration *result = new UStringEnumeration(uenum);
2013 if (result == NULL) {
2014 errorCode = U_MEMORY_ALLOCATION_ERROR;
2015 uenum_close(uenum);
2016 return NULL;
2017 }
2018 return result;
2019}
2020
2021int32_t MeasureUnit::getIndexCount() {
b331163b
A
2022 return gIndexes[UPRV_LENGTHOF(gIndexes) - 1];
2023}
2024
2ca993e8
A
2025int32_t MeasureUnit::internalGetIndexForTypeAndSubtype(const char *type, const char *subtype) {
2026 int32_t t = binarySearch(gTypes, 0, UPRV_LENGTHOF(gTypes), type);
2027 if (t < 0) {
2028 return t;
2029 }
2030 int32_t st = binarySearch(gSubTypes, gOffsets[t], gOffsets[t + 1], subtype);
2031 if (st < 0) {
2032 return st;
2033 }
2034 return gIndexes[t] + st - gOffsets[t];
2035}
2036
0f5d89e8
A
2037MeasureUnit MeasureUnit::resolveUnitPerUnit(
2038 const MeasureUnit &unit, const MeasureUnit &perUnit, bool* isResolved) {
b331163b
A
2039 int32_t unitOffset = unit.getOffset();
2040 int32_t perUnitOffset = perUnit.getOffset();
2041
2042 // binary search for (unitOffset, perUnitOffset)
2043 int32_t start = 0;
2044 int32_t end = UPRV_LENGTHOF(unitPerUnitToSingleUnit);
2045 while (start < end) {
2046 int32_t mid = (start + end) / 2;
2047 int32_t *midRow = unitPerUnitToSingleUnit[mid];
2048 if (unitOffset < midRow[0]) {
2049 end = mid;
2050 } else if (unitOffset > midRow[0]) {
2051 start = mid + 1;
2052 } else if (perUnitOffset < midRow[1]) {
2053 end = mid;
2054 } else if (perUnitOffset > midRow[1]) {
2055 start = mid + 1;
2056 } else {
2057 // We found a resolution for our unit / per-unit combo
2058 // return it.
0f5d89e8
A
2059 *isResolved = true;
2060 return MeasureUnit(midRow[2], midRow[3]);
b331163b
A
2061 }
2062 }
0f5d89e8
A
2063
2064 *isResolved = false;
2065 return MeasureUnit();
57a6839d
A
2066}
2067
2068MeasureUnit *MeasureUnit::create(int typeId, int subTypeId, UErrorCode &status) {
2069 if (U_FAILURE(status)) {
2070 return NULL;
2071 }
2072 MeasureUnit *result = new MeasureUnit(typeId, subTypeId);
2073 if (result == NULL) {
2074 status = U_MEMORY_ALLOCATION_ERROR;
2075 }
2076 return result;
2077}
2078
2079void MeasureUnit::initTime(const char *timeId) {
b331163b 2080 int32_t result = binarySearch(gTypes, 0, UPRV_LENGTHOF(gTypes), "duration");
57a6839d
A
2081 U_ASSERT(result != -1);
2082 fTypeId = result;
2083 result = binarySearch(gSubTypes, gOffsets[fTypeId], gOffsets[fTypeId + 1], timeId);
2084 U_ASSERT(result != -1);
2085 fSubTypeId = result - gOffsets[fTypeId];
2086}
2087
2088void MeasureUnit::initCurrency(const char *isoCurrency) {
b331163b 2089 int32_t result = binarySearch(gTypes, 0, UPRV_LENGTHOF(gTypes), "currency");
57a6839d
A
2090 U_ASSERT(result != -1);
2091 fTypeId = result;
2092 result = binarySearch(
2093 gSubTypes, gOffsets[fTypeId], gOffsets[fTypeId + 1], isoCurrency);
2094 if (result != -1) {
2095 fSubTypeId = result - gOffsets[fTypeId];
2096 } else {
b331163b 2097 uprv_strncpy(fCurrency, isoCurrency, UPRV_LENGTHOF(fCurrency));
2ca993e8 2098 fCurrency[3] = 0;
57a6839d
A
2099 }
2100}
2101
0f5d89e8
A
2102void MeasureUnit::initNoUnit(const char *subtype) {
2103 int32_t result = binarySearch(gTypes, 0, UPRV_LENGTHOF(gTypes), "none");
2104 U_ASSERT(result != -1);
2105 fTypeId = result;
2106 result = binarySearch(gSubTypes, gOffsets[fTypeId], gOffsets[fTypeId + 1], subtype);
2107 U_ASSERT(result != -1);
2108 fSubTypeId = result - gOffsets[fTypeId];
2109}
2110
57a6839d
A
2111void MeasureUnit::setTo(int32_t typeId, int32_t subTypeId) {
2112 fTypeId = typeId;
2113 fSubTypeId = subTypeId;
2114 fCurrency[0] = 0;
2115}
2116
2117int32_t MeasureUnit::getOffset() const {
2118 return gOffsets[fTypeId] + fSubTypeId;
2119}
2120
2121U_NAMESPACE_END
2122
2123#endif /* !UNCONFIG_NO_FORMATTING */