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