Bug Summary

File:out/../deps/icu-small/source/i18n/measunit.cpp
Warning:line 2196, column 5
Undefined or garbage value returned to caller

Annotated Source Code

Press '?' to see keyboard shortcuts

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