"Fossies" - the Fresh Open Source Software Archive

Member "icu/source/i18n/measunit.cpp" (22 Apr 2020, 50981 Bytes) of package /linux/misc/icu4c-67_1-src.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "measunit.cpp" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes reports: 67rc_vs_67_1 or 66_1_vs_67_1.

    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 
   26 U_NAMESPACE_BEGIN
   27 
   28 UOBJECT_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 
   39 static 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 
   66 static 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.
   94 static 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.
  121 static 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.
  599 static 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
  613 static const int32_t kBaseTypeIdx = 16;
  614 static const int32_t kBaseSubTypeIdx = 0;
  615 
  616 MeasureUnit *MeasureUnit::createGForce(UErrorCode &status) {
  617     return MeasureUnit::create(0, 0, status);
  618 }
  619 
  620 MeasureUnit MeasureUnit::getGForce() {
  621     return MeasureUnit(0, 0);
  622 }
  623 
  624 MeasureUnit *MeasureUnit::createMeterPerSecondSquared(UErrorCode &status) {
  625     return MeasureUnit::create(0, 1, status);
  626 }
  627 
  628 MeasureUnit MeasureUnit::getMeterPerSecondSquared() {
  629     return MeasureUnit(0, 1);
  630 }
  631 
  632 MeasureUnit *MeasureUnit::createArcMinute(UErrorCode &status) {
  633     return MeasureUnit::create(1, 0, status);
  634 }
  635 
  636 MeasureUnit MeasureUnit::getArcMinute() {
  637     return MeasureUnit(1, 0);
  638 }
  639 
  640 MeasureUnit *MeasureUnit::createArcSecond(UErrorCode &status) {
  641     return MeasureUnit::create(1, 1, status);
  642 }
  643 
  644 MeasureUnit MeasureUnit::getArcSecond() {
  645     return MeasureUnit(1, 1);
  646 }
  647 
  648 MeasureUnit *MeasureUnit::createDegree(UErrorCode &status) {
  649     return MeasureUnit::create(1, 2, status);
  650 }
  651 
  652 MeasureUnit MeasureUnit::getDegree() {
  653     return MeasureUnit(1, 2);
  654 }
  655 
  656 MeasureUnit *MeasureUnit::createRadian(UErrorCode &status) {
  657     return MeasureUnit::create(1, 3, status);
  658 }
  659 
  660 MeasureUnit MeasureUnit::getRadian() {
  661     return MeasureUnit(1, 3);
  662 }
  663 
  664 MeasureUnit *MeasureUnit::createRevolutionAngle(UErrorCode &status) {
  665     return MeasureUnit::create(1, 4, status);
  666 }
  667 
  668 MeasureUnit MeasureUnit::getRevolutionAngle() {
  669     return MeasureUnit(1, 4);
  670 }
  671 
  672 MeasureUnit *MeasureUnit::createAcre(UErrorCode &status) {
  673     return MeasureUnit::create(2, 0, status);
  674 }
  675 
  676 MeasureUnit MeasureUnit::getAcre() {
  677     return MeasureUnit(2, 0);
  678 }
  679 
  680 MeasureUnit *MeasureUnit::createDunam(UErrorCode &status) {
  681     return MeasureUnit::create(2, 1, status);
  682 }
  683 
  684 MeasureUnit MeasureUnit::getDunam() {
  685     return MeasureUnit(2, 1);
  686 }
  687 
  688 MeasureUnit *MeasureUnit::createHectare(UErrorCode &status) {
  689     return MeasureUnit::create(2, 2, status);
  690 }
  691 
  692 MeasureUnit MeasureUnit::getHectare() {
  693     return MeasureUnit(2, 2);
  694 }
  695 
  696 MeasureUnit *MeasureUnit::createSquareCentimeter(UErrorCode &status) {
  697     return MeasureUnit::create(2, 3, status);
  698 }
  699 
  700 MeasureUnit MeasureUnit::getSquareCentimeter() {
  701     return MeasureUnit(2, 3);
  702 }
  703 
  704 MeasureUnit *MeasureUnit::createSquareFoot(UErrorCode &status) {
  705     return MeasureUnit::create(2, 4, status);
  706 }
  707 
  708 MeasureUnit MeasureUnit::getSquareFoot() {
  709     return MeasureUnit(2, 4);
  710 }
  711 
  712 MeasureUnit *MeasureUnit::createSquareInch(UErrorCode &status) {
  713     return MeasureUnit::create(2, 5, status);
  714 }
  715 
  716 MeasureUnit MeasureUnit::getSquareInch() {
  717     return MeasureUnit(2, 5);
  718 }
  719 
  720 MeasureUnit *MeasureUnit::createSquareKilometer(UErrorCode &status) {
  721     return MeasureUnit::create(2, 6, status);
  722 }
  723 
  724 MeasureUnit MeasureUnit::getSquareKilometer() {
  725     return MeasureUnit(2, 6);
  726 }
  727 
  728 MeasureUnit *MeasureUnit::createSquareMeter(UErrorCode &status) {
  729     return MeasureUnit::create(2, 7, status);
  730 }
  731 
  732 MeasureUnit MeasureUnit::getSquareMeter() {
  733     return MeasureUnit(2, 7);
  734 }
  735 
  736 MeasureUnit *MeasureUnit::createSquareMile(UErrorCode &status) {
  737     return MeasureUnit::create(2, 8, status);
  738 }
  739 
  740 MeasureUnit MeasureUnit::getSquareMile() {
  741     return MeasureUnit(2, 8);
  742 }
  743 
  744 MeasureUnit *MeasureUnit::createSquareYard(UErrorCode &status) {
  745     return MeasureUnit::create(2, 9, status);
  746 }
  747 
  748 MeasureUnit MeasureUnit::getSquareYard() {
  749     return MeasureUnit(2, 9);
  750 }
  751 
  752 MeasureUnit *MeasureUnit::createKarat(UErrorCode &status) {
  753     return MeasureUnit::create(3, 0, status);
  754 }
  755 
  756 MeasureUnit MeasureUnit::getKarat() {
  757     return MeasureUnit(3, 0);
  758 }
  759 
  760 MeasureUnit *MeasureUnit::createMilligramPerDeciliter(UErrorCode &status) {
  761     return MeasureUnit::create(3, 1, status);
  762 }
  763 
  764 MeasureUnit MeasureUnit::getMilligramPerDeciliter() {
  765     return MeasureUnit(3, 1);
  766 }
  767 
  768 MeasureUnit *MeasureUnit::createMillimolePerLiter(UErrorCode &status) {
  769     return MeasureUnit::create(3, 2, status);
  770 }
  771 
  772 MeasureUnit MeasureUnit::getMillimolePerLiter() {
  773     return MeasureUnit(3, 2);
  774 }
  775 
  776 MeasureUnit *MeasureUnit::createMole(UErrorCode &status) {
  777     return MeasureUnit::create(3, 3, status);
  778 }
  779 
  780 MeasureUnit MeasureUnit::getMole() {
  781     return MeasureUnit(3, 3);
  782 }
  783 
  784 MeasureUnit *MeasureUnit::createPartPerMillion(UErrorCode &status) {
  785     return MeasureUnit::create(3, 6, status);
  786 }
  787 
  788 MeasureUnit MeasureUnit::getPartPerMillion() {
  789     return MeasureUnit(3, 6);
  790 }
  791 
  792 MeasureUnit *MeasureUnit::createPercent(UErrorCode &status) {
  793     return MeasureUnit::create(3, 4, status);
  794 }
  795 
  796 MeasureUnit MeasureUnit::getPercent() {
  797     return MeasureUnit(3, 4);
  798 }
  799 
  800 MeasureUnit *MeasureUnit::createPermille(UErrorCode &status) {
  801     return MeasureUnit::create(3, 5, status);
  802 }
  803 
  804 MeasureUnit MeasureUnit::getPermille() {
  805     return MeasureUnit(3, 5);
  806 }
  807 
  808 MeasureUnit *MeasureUnit::createPermyriad(UErrorCode &status) {
  809     return MeasureUnit::create(3, 7, status);
  810 }
  811 
  812 MeasureUnit MeasureUnit::getPermyriad() {
  813     return MeasureUnit(3, 7);
  814 }
  815 
  816 MeasureUnit *MeasureUnit::createLiterPer100Kilometers(UErrorCode &status) {
  817     return MeasureUnit::create(4, 0, status);
  818 }
  819 
  820 MeasureUnit MeasureUnit::getLiterPer100Kilometers() {
  821     return MeasureUnit(4, 0);
  822 }
  823 
  824 MeasureUnit *MeasureUnit::createLiterPerKilometer(UErrorCode &status) {
  825     return MeasureUnit::create(4, 1, status);
  826 }
  827 
  828 MeasureUnit MeasureUnit::getLiterPerKilometer() {
  829     return MeasureUnit(4, 1);
  830 }
  831 
  832 MeasureUnit *MeasureUnit::createMilePerGallon(UErrorCode &status) {
  833     return MeasureUnit::create(4, 2, status);
  834 }
  835 
  836 MeasureUnit MeasureUnit::getMilePerGallon() {
  837     return MeasureUnit(4, 2);
  838 }
  839 
  840 MeasureUnit *MeasureUnit::createMilePerGallonImperial(UErrorCode &status) {
  841     return MeasureUnit::create(4, 3, status);
  842 }
  843 
  844 MeasureUnit MeasureUnit::getMilePerGallonImperial() {
  845     return MeasureUnit(4, 3);
  846 }
  847 
  848 MeasureUnit *MeasureUnit::createBit(UErrorCode &status) {
  849     return MeasureUnit::create(6, 0, status);
  850 }
  851 
  852 MeasureUnit MeasureUnit::getBit() {
  853     return MeasureUnit(6, 0);
  854 }
  855 
  856 MeasureUnit *MeasureUnit::createByte(UErrorCode &status) {
  857     return MeasureUnit::create(6, 1, status);
  858 }
  859 
  860 MeasureUnit MeasureUnit::getByte() {
  861     return MeasureUnit(6, 1);
  862 }
  863 
  864 MeasureUnit *MeasureUnit::createGigabit(UErrorCode &status) {
  865     return MeasureUnit::create(6, 2, status);
  866 }
  867 
  868 MeasureUnit MeasureUnit::getGigabit() {
  869     return MeasureUnit(6, 2);
  870 }
  871 
  872 MeasureUnit *MeasureUnit::createGigabyte(UErrorCode &status) {
  873     return MeasureUnit::create(6, 3, status);
  874 }
  875 
  876 MeasureUnit MeasureUnit::getGigabyte() {
  877     return MeasureUnit(6, 3);
  878 }
  879 
  880 MeasureUnit *MeasureUnit::createKilobit(UErrorCode &status) {
  881     return MeasureUnit::create(6, 4, status);
  882 }
  883 
  884 MeasureUnit MeasureUnit::getKilobit() {
  885     return MeasureUnit(6, 4);
  886 }
  887 
  888 MeasureUnit *MeasureUnit::createKilobyte(UErrorCode &status) {
  889     return MeasureUnit::create(6, 5, status);
  890 }
  891 
  892 MeasureUnit MeasureUnit::getKilobyte() {
  893     return MeasureUnit(6, 5);
  894 }
  895 
  896 MeasureUnit *MeasureUnit::createMegabit(UErrorCode &status) {
  897     return MeasureUnit::create(6, 6, status);
  898 }
  899 
  900 MeasureUnit MeasureUnit::getMegabit() {
  901     return MeasureUnit(6, 6);
  902 }
  903 
  904 MeasureUnit *MeasureUnit::createMegabyte(UErrorCode &status) {
  905     return MeasureUnit::create(6, 7, status);
  906 }
  907 
  908 MeasureUnit MeasureUnit::getMegabyte() {
  909     return MeasureUnit(6, 7);
  910 }
  911 
  912 MeasureUnit *MeasureUnit::createPetabyte(UErrorCode &status) {
  913     return MeasureUnit::create(6, 8, status);
  914 }
  915 
  916 MeasureUnit MeasureUnit::getPetabyte() {
  917     return MeasureUnit(6, 8);
  918 }
  919 
  920 MeasureUnit *MeasureUnit::createTerabit(UErrorCode &status) {
  921     return MeasureUnit::create(6, 9, status);
  922 }
  923 
  924 MeasureUnit MeasureUnit::getTerabit() {
  925     return MeasureUnit(6, 9);
  926 }
  927 
  928 MeasureUnit *MeasureUnit::createTerabyte(UErrorCode &status) {
  929     return MeasureUnit::create(6, 10, status);
  930 }
  931 
  932 MeasureUnit MeasureUnit::getTerabyte() {
  933     return MeasureUnit(6, 10);
  934 }
  935 
  936 MeasureUnit *MeasureUnit::createCentury(UErrorCode &status) {
  937     return MeasureUnit::create(7, 0, status);
  938 }
  939 
  940 MeasureUnit MeasureUnit::getCentury() {
  941     return MeasureUnit(7, 0);
  942 }
  943 
  944 MeasureUnit *MeasureUnit::createDay(UErrorCode &status) {
  945     return MeasureUnit::create(7, 1, status);
  946 }
  947 
  948 MeasureUnit MeasureUnit::getDay() {
  949     return MeasureUnit(7, 1);
  950 }
  951 
  952 MeasureUnit *MeasureUnit::createDayPerson(UErrorCode &status) {
  953     return MeasureUnit::create(7, 2, status);
  954 }
  955 
  956 MeasureUnit MeasureUnit::getDayPerson() {
  957     return MeasureUnit(7, 2);
  958 }
  959 
  960 MeasureUnit *MeasureUnit::createDecade(UErrorCode &status) {
  961     return MeasureUnit::create(7, 3, status);
  962 }
  963 
  964 MeasureUnit MeasureUnit::getDecade() {
  965     return MeasureUnit(7, 3);
  966 }
  967 
  968 MeasureUnit *MeasureUnit::createHour(UErrorCode &status) {
  969     return MeasureUnit::create(7, 4, status);
  970 }
  971 
  972 MeasureUnit MeasureUnit::getHour() {
  973     return MeasureUnit(7, 4);
  974 }
  975 
  976 MeasureUnit *MeasureUnit::createMicrosecond(UErrorCode &status) {
  977     return MeasureUnit::create(7, 5, status);
  978 }
  979 
  980 MeasureUnit MeasureUnit::getMicrosecond() {
  981     return MeasureUnit(7, 5);
  982 }
  983 
  984 MeasureUnit *MeasureUnit::createMillisecond(UErrorCode &status) {
  985     return MeasureUnit::create(7, 6, status);
  986 }
  987 
  988 MeasureUnit MeasureUnit::getMillisecond() {
  989     return MeasureUnit(7, 6);
  990 }
  991 
  992 MeasureUnit *MeasureUnit::createMinute(UErrorCode &status) {
  993     return MeasureUnit::create(7, 7, status);
  994 }
  995 
  996 MeasureUnit MeasureUnit::getMinute() {
  997     return MeasureUnit(7, 7);
  998 }
  999 
 1000 MeasureUnit *MeasureUnit::createMonth(UErrorCode &status) {
 1001     return MeasureUnit::create(7, 8, status);
 1002 }
 1003 
 1004 MeasureUnit MeasureUnit::getMonth() {
 1005     return MeasureUnit(7, 8);
 1006 }
 1007 
 1008 MeasureUnit *MeasureUnit::createMonthPerson(UErrorCode &status) {
 1009     return MeasureUnit::create(7, 9, status);
 1010 }
 1011 
 1012 MeasureUnit MeasureUnit::getMonthPerson() {
 1013     return MeasureUnit(7, 9);
 1014 }
 1015 
 1016 MeasureUnit *MeasureUnit::createNanosecond(UErrorCode &status) {
 1017     return MeasureUnit::create(7, 10, status);
 1018 }
 1019 
 1020 MeasureUnit MeasureUnit::getNanosecond() {
 1021     return MeasureUnit(7, 10);
 1022 }
 1023 
 1024 MeasureUnit *MeasureUnit::createSecond(UErrorCode &status) {
 1025     return MeasureUnit::create(7, 11, status);
 1026 }
 1027 
 1028 MeasureUnit MeasureUnit::getSecond() {
 1029     return MeasureUnit(7, 11);
 1030 }
 1031 
 1032 MeasureUnit *MeasureUnit::createWeek(UErrorCode &status) {
 1033     return MeasureUnit::create(7, 12, status);
 1034 }
 1035 
 1036 MeasureUnit MeasureUnit::getWeek() {
 1037     return MeasureUnit(7, 12);
 1038 }
 1039 
 1040 MeasureUnit *MeasureUnit::createWeekPerson(UErrorCode &status) {
 1041     return MeasureUnit::create(7, 13, status);
 1042 }
 1043 
 1044 MeasureUnit MeasureUnit::getWeekPerson() {
 1045     return MeasureUnit(7, 13);
 1046 }
 1047 
 1048 MeasureUnit *MeasureUnit::createYear(UErrorCode &status) {
 1049     return MeasureUnit::create(7, 14, status);
 1050 }
 1051 
 1052 MeasureUnit MeasureUnit::getYear() {
 1053     return MeasureUnit(7, 14);
 1054 }
 1055 
 1056 MeasureUnit *MeasureUnit::createYearPerson(UErrorCode &status) {
 1057     return MeasureUnit::create(7, 15, status);
 1058 }
 1059 
 1060 MeasureUnit MeasureUnit::getYearPerson() {
 1061     return MeasureUnit(7, 15);
 1062 }
 1063 
 1064 MeasureUnit *MeasureUnit::createAmpere(UErrorCode &status) {
 1065     return MeasureUnit::create(8, 0, status);
 1066 }
 1067 
 1068 MeasureUnit MeasureUnit::getAmpere() {
 1069     return MeasureUnit(8, 0);
 1070 }
 1071 
 1072 MeasureUnit *MeasureUnit::createMilliampere(UErrorCode &status) {
 1073     return MeasureUnit::create(8, 1, status);
 1074 }
 1075 
 1076 MeasureUnit MeasureUnit::getMilliampere() {
 1077     return MeasureUnit(8, 1);
 1078 }
 1079 
 1080 MeasureUnit *MeasureUnit::createOhm(UErrorCode &status) {
 1081     return MeasureUnit::create(8, 2, status);
 1082 }
 1083 
 1084 MeasureUnit MeasureUnit::getOhm() {
 1085     return MeasureUnit(8, 2);
 1086 }
 1087 
 1088 MeasureUnit *MeasureUnit::createVolt(UErrorCode &status) {
 1089     return MeasureUnit::create(8, 3, status);
 1090 }
 1091 
 1092 MeasureUnit MeasureUnit::getVolt() {
 1093     return MeasureUnit(8, 3);
 1094 }
 1095 
 1096 MeasureUnit *MeasureUnit::createBritishThermalUnit(UErrorCode &status) {
 1097     return MeasureUnit::create(9, 0, status);
 1098 }
 1099 
 1100 MeasureUnit MeasureUnit::getBritishThermalUnit() {
 1101     return MeasureUnit(9, 0);
 1102 }
 1103 
 1104 MeasureUnit *MeasureUnit::createCalorie(UErrorCode &status) {
 1105     return MeasureUnit::create(9, 1, status);
 1106 }
 1107 
 1108 MeasureUnit MeasureUnit::getCalorie() {
 1109     return MeasureUnit(9, 1);
 1110 }
 1111 
 1112 MeasureUnit *MeasureUnit::createElectronvolt(UErrorCode &status) {
 1113     return MeasureUnit::create(9, 2, status);
 1114 }
 1115 
 1116 MeasureUnit MeasureUnit::getElectronvolt() {
 1117     return MeasureUnit(9, 2);
 1118 }
 1119 
 1120 MeasureUnit *MeasureUnit::createFoodcalorie(UErrorCode &status) {
 1121     return MeasureUnit::create(9, 3, status);
 1122 }
 1123 
 1124 MeasureUnit MeasureUnit::getFoodcalorie() {
 1125     return MeasureUnit(9, 3);
 1126 }
 1127 
 1128 MeasureUnit *MeasureUnit::createJoule(UErrorCode &status) {
 1129     return MeasureUnit::create(9, 4, status);
 1130 }
 1131 
 1132 MeasureUnit MeasureUnit::getJoule() {
 1133     return MeasureUnit(9, 4);
 1134 }
 1135 
 1136 MeasureUnit *MeasureUnit::createKilocalorie(UErrorCode &status) {
 1137     return MeasureUnit::create(9, 5, status);
 1138 }
 1139 
 1140 MeasureUnit MeasureUnit::getKilocalorie() {
 1141     return MeasureUnit(9, 5);
 1142 }
 1143 
 1144 MeasureUnit *MeasureUnit::createKilojoule(UErrorCode &status) {
 1145     return MeasureUnit::create(9, 6, status);
 1146 }
 1147 
 1148 MeasureUnit MeasureUnit::getKilojoule() {
 1149     return MeasureUnit(9, 6);
 1150 }
 1151 
 1152 MeasureUnit *MeasureUnit::createKilowattHour(UErrorCode &status) {
 1153     return MeasureUnit::create(9, 7, status);
 1154 }
 1155 
 1156 MeasureUnit MeasureUnit::getKilowattHour() {
 1157     return MeasureUnit(9, 7);
 1158 }
 1159 
 1160 MeasureUnit *MeasureUnit::createThermUs(UErrorCode &status) {
 1161     return MeasureUnit::create(9, 8, status);
 1162 }
 1163 
 1164 MeasureUnit MeasureUnit::getThermUs() {
 1165     return MeasureUnit(9, 8);
 1166 }
 1167 
 1168 MeasureUnit *MeasureUnit::createNewton(UErrorCode &status) {
 1169     return MeasureUnit::create(10, 0, status);
 1170 }
 1171 
 1172 MeasureUnit MeasureUnit::getNewton() {
 1173     return MeasureUnit(10, 0);
 1174 }
 1175 
 1176 MeasureUnit *MeasureUnit::createPoundForce(UErrorCode &status) {
 1177     return MeasureUnit::create(10, 1, status);
 1178 }
 1179 
 1180 MeasureUnit MeasureUnit::getPoundForce() {
 1181     return MeasureUnit(10, 1);
 1182 }
 1183 
 1184 MeasureUnit *MeasureUnit::createGigahertz(UErrorCode &status) {
 1185     return MeasureUnit::create(11, 0, status);
 1186 }
 1187 
 1188 MeasureUnit MeasureUnit::getGigahertz() {
 1189     return MeasureUnit(11, 0);
 1190 }
 1191 
 1192 MeasureUnit *MeasureUnit::createHertz(UErrorCode &status) {
 1193     return MeasureUnit::create(11, 1, status);
 1194 }
 1195 
 1196 MeasureUnit MeasureUnit::getHertz() {
 1197     return MeasureUnit(11, 1);
 1198 }
 1199 
 1200 MeasureUnit *MeasureUnit::createKilohertz(UErrorCode &status) {
 1201     return MeasureUnit::create(11, 2, status);
 1202 }
 1203 
 1204 MeasureUnit MeasureUnit::getKilohertz() {
 1205     return MeasureUnit(11, 2);
 1206 }
 1207 
 1208 MeasureUnit *MeasureUnit::createMegahertz(UErrorCode &status) {
 1209     return MeasureUnit::create(11, 3, status);
 1210 }
 1211 
 1212 MeasureUnit MeasureUnit::getMegahertz() {
 1213     return MeasureUnit(11, 3);
 1214 }
 1215 
 1216 MeasureUnit *MeasureUnit::createDotPerCentimeter(UErrorCode &status) {
 1217     return MeasureUnit::create(12, 0, status);
 1218 }
 1219 
 1220 MeasureUnit MeasureUnit::getDotPerCentimeter() {
 1221     return MeasureUnit(12, 0);
 1222 }
 1223 
 1224 MeasureUnit *MeasureUnit::createDotPerInch(UErrorCode &status) {
 1225     return MeasureUnit::create(12, 1, status);
 1226 }
 1227 
 1228 MeasureUnit MeasureUnit::getDotPerInch() {
 1229     return MeasureUnit(12, 1);
 1230 }
 1231 
 1232 MeasureUnit *MeasureUnit::createEm(UErrorCode &status) {
 1233     return MeasureUnit::create(12, 2, status);
 1234 }
 1235 
 1236 MeasureUnit MeasureUnit::getEm() {
 1237     return MeasureUnit(12, 2);
 1238 }
 1239 
 1240 MeasureUnit *MeasureUnit::createMegapixel(UErrorCode &status) {
 1241     return MeasureUnit::create(12, 3, status);
 1242 }
 1243 
 1244 MeasureUnit MeasureUnit::getMegapixel() {
 1245     return MeasureUnit(12, 3);
 1246 }
 1247 
 1248 MeasureUnit *MeasureUnit::createPixel(UErrorCode &status) {
 1249     return MeasureUnit::create(12, 4, status);
 1250 }
 1251 
 1252 MeasureUnit MeasureUnit::getPixel() {
 1253     return MeasureUnit(12, 4);
 1254 }
 1255 
 1256 MeasureUnit *MeasureUnit::createPixelPerCentimeter(UErrorCode &status) {
 1257     return MeasureUnit::create(12, 5, status);
 1258 }
 1259 
 1260 MeasureUnit MeasureUnit::getPixelPerCentimeter() {
 1261     return MeasureUnit(12, 5);
 1262 }
 1263 
 1264 MeasureUnit *MeasureUnit::createPixelPerInch(UErrorCode &status) {
 1265     return MeasureUnit::create(12, 6, status);
 1266 }
 1267 
 1268 MeasureUnit MeasureUnit::getPixelPerInch() {
 1269     return MeasureUnit(12, 6);
 1270 }
 1271 
 1272 MeasureUnit *MeasureUnit::createAstronomicalUnit(UErrorCode &status) {
 1273     return MeasureUnit::create(13, 0, status);
 1274 }
 1275 
 1276 MeasureUnit MeasureUnit::getAstronomicalUnit() {
 1277     return MeasureUnit(13, 0);
 1278 }
 1279 
 1280 MeasureUnit *MeasureUnit::createCentimeter(UErrorCode &status) {
 1281     return MeasureUnit::create(13, 1, status);
 1282 }
 1283 
 1284 MeasureUnit MeasureUnit::getCentimeter() {
 1285     return MeasureUnit(13, 1);
 1286 }
 1287 
 1288 MeasureUnit *MeasureUnit::createDecimeter(UErrorCode &status) {
 1289     return MeasureUnit::create(13, 2, status);
 1290 }
 1291 
 1292 MeasureUnit MeasureUnit::getDecimeter() {
 1293     return MeasureUnit(13, 2);
 1294 }
 1295 
 1296 MeasureUnit *MeasureUnit::createFathom(UErrorCode &status) {
 1297     return MeasureUnit::create(13, 3, status);
 1298 }
 1299 
 1300 MeasureUnit MeasureUnit::getFathom() {
 1301     return MeasureUnit(13, 3);
 1302 }
 1303 
 1304 MeasureUnit *MeasureUnit::createFoot(UErrorCode &status) {
 1305     return MeasureUnit::create(13, 4, status);
 1306 }
 1307 
 1308 MeasureUnit MeasureUnit::getFoot() {
 1309     return MeasureUnit(13, 4);
 1310 }
 1311 
 1312 MeasureUnit *MeasureUnit::createFurlong(UErrorCode &status) {
 1313     return MeasureUnit::create(13, 5, status);
 1314 }
 1315 
 1316 MeasureUnit MeasureUnit::getFurlong() {
 1317     return MeasureUnit(13, 5);
 1318 }
 1319 
 1320 MeasureUnit *MeasureUnit::createInch(UErrorCode &status) {
 1321     return MeasureUnit::create(13, 6, status);
 1322 }
 1323 
 1324 MeasureUnit MeasureUnit::getInch() {
 1325     return MeasureUnit(13, 6);
 1326 }
 1327 
 1328 MeasureUnit *MeasureUnit::createKilometer(UErrorCode &status) {
 1329     return MeasureUnit::create(13, 7, status);
 1330 }
 1331 
 1332 MeasureUnit MeasureUnit::getKilometer() {
 1333     return MeasureUnit(13, 7);
 1334 }
 1335 
 1336 MeasureUnit *MeasureUnit::createLightYear(UErrorCode &status) {
 1337     return MeasureUnit::create(13, 8, status);
 1338 }
 1339 
 1340 MeasureUnit MeasureUnit::getLightYear() {
 1341     return MeasureUnit(13, 8);
 1342 }
 1343 
 1344 MeasureUnit *MeasureUnit::createMeter(UErrorCode &status) {
 1345     return MeasureUnit::create(13, 9, status);
 1346 }
 1347 
 1348 MeasureUnit MeasureUnit::getMeter() {
 1349     return MeasureUnit(13, 9);
 1350 }
 1351 
 1352 MeasureUnit *MeasureUnit::createMicrometer(UErrorCode &status) {
 1353     return MeasureUnit::create(13, 10, status);
 1354 }
 1355 
 1356 MeasureUnit MeasureUnit::getMicrometer() {
 1357     return MeasureUnit(13, 10);
 1358 }
 1359 
 1360 MeasureUnit *MeasureUnit::createMile(UErrorCode &status) {
 1361     return MeasureUnit::create(13, 11, status);
 1362 }
 1363 
 1364 MeasureUnit MeasureUnit::getMile() {
 1365     return MeasureUnit(13, 11);
 1366 }
 1367 
 1368 MeasureUnit *MeasureUnit::createMileScandinavian(UErrorCode &status) {
 1369     return MeasureUnit::create(13, 12, status);
 1370 }
 1371 
 1372 MeasureUnit MeasureUnit::getMileScandinavian() {
 1373     return MeasureUnit(13, 12);
 1374 }
 1375 
 1376 MeasureUnit *MeasureUnit::createMillimeter(UErrorCode &status) {
 1377     return MeasureUnit::create(13, 13, status);
 1378 }
 1379 
 1380 MeasureUnit MeasureUnit::getMillimeter() {
 1381     return MeasureUnit(13, 13);
 1382 }
 1383 
 1384 MeasureUnit *MeasureUnit::createNanometer(UErrorCode &status) {
 1385     return MeasureUnit::create(13, 14, status);
 1386 }
 1387 
 1388 MeasureUnit MeasureUnit::getNanometer() {
 1389     return MeasureUnit(13, 14);
 1390 }
 1391 
 1392 MeasureUnit *MeasureUnit::createNauticalMile(UErrorCode &status) {
 1393     return MeasureUnit::create(13, 15, status);
 1394 }
 1395 
 1396 MeasureUnit MeasureUnit::getNauticalMile() {
 1397     return MeasureUnit(13, 15);
 1398 }
 1399 
 1400 MeasureUnit *MeasureUnit::createParsec(UErrorCode &status) {
 1401     return MeasureUnit::create(13, 16, status);
 1402 }
 1403 
 1404 MeasureUnit MeasureUnit::getParsec() {
 1405     return MeasureUnit(13, 16);
 1406 }
 1407 
 1408 MeasureUnit *MeasureUnit::createPicometer(UErrorCode &status) {
 1409     return MeasureUnit::create(13, 17, status);
 1410 }
 1411 
 1412 MeasureUnit MeasureUnit::getPicometer() {
 1413     return MeasureUnit(13, 17);
 1414 }
 1415 
 1416 MeasureUnit *MeasureUnit::createPoint(UErrorCode &status) {
 1417     return MeasureUnit::create(13, 18, status);
 1418 }
 1419 
 1420 MeasureUnit MeasureUnit::getPoint() {
 1421     return MeasureUnit(13, 18);
 1422 }
 1423 
 1424 MeasureUnit *MeasureUnit::createSolarRadius(UErrorCode &status) {
 1425     return MeasureUnit::create(13, 19, status);
 1426 }
 1427 
 1428 MeasureUnit MeasureUnit::getSolarRadius() {
 1429     return MeasureUnit(13, 19);
 1430 }
 1431 
 1432 MeasureUnit *MeasureUnit::createYard(UErrorCode &status) {
 1433     return MeasureUnit::create(13, 20, status);
 1434 }
 1435 
 1436 MeasureUnit MeasureUnit::getYard() {
 1437     return MeasureUnit(13, 20);
 1438 }
 1439 
 1440 MeasureUnit *MeasureUnit::createLux(UErrorCode &status) {
 1441     return MeasureUnit::create(14, 0, status);
 1442 }
 1443 
 1444 MeasureUnit MeasureUnit::getLux() {
 1445     return MeasureUnit(14, 0);
 1446 }
 1447 
 1448 MeasureUnit *MeasureUnit::createSolarLuminosity(UErrorCode &status) {
 1449     return MeasureUnit::create(14, 1, status);
 1450 }
 1451 
 1452 MeasureUnit MeasureUnit::getSolarLuminosity() {
 1453     return MeasureUnit(14, 1);
 1454 }
 1455 
 1456 MeasureUnit *MeasureUnit::createCarat(UErrorCode &status) {
 1457     return MeasureUnit::create(15, 0, status);
 1458 }
 1459 
 1460 MeasureUnit MeasureUnit::getCarat() {
 1461     return MeasureUnit(15, 0);
 1462 }
 1463 
 1464 MeasureUnit *MeasureUnit::createDalton(UErrorCode &status) {
 1465     return MeasureUnit::create(15, 1, status);
 1466 }
 1467 
 1468 MeasureUnit MeasureUnit::getDalton() {
 1469     return MeasureUnit(15, 1);
 1470 }
 1471 
 1472 MeasureUnit *MeasureUnit::createEarthMass(UErrorCode &status) {
 1473     return MeasureUnit::create(15, 2, status);
 1474 }
 1475 
 1476 MeasureUnit MeasureUnit::getEarthMass() {
 1477     return MeasureUnit(15, 2);
 1478 }
 1479 
 1480 MeasureUnit *MeasureUnit::createGram(UErrorCode &status) {
 1481     return MeasureUnit::create(15, 3, status);
 1482 }
 1483 
 1484 MeasureUnit MeasureUnit::getGram() {
 1485     return MeasureUnit(15, 3);
 1486 }
 1487 
 1488 MeasureUnit *MeasureUnit::createKilogram(UErrorCode &status) {
 1489     return MeasureUnit::create(15, 4, status);
 1490 }
 1491 
 1492 MeasureUnit MeasureUnit::getKilogram() {
 1493     return MeasureUnit(15, 4);
 1494 }
 1495 
 1496 MeasureUnit *MeasureUnit::createMetricTon(UErrorCode &status) {
 1497     return MeasureUnit::create(15, 5, status);
 1498 }
 1499 
 1500 MeasureUnit MeasureUnit::getMetricTon() {
 1501     return MeasureUnit(15, 5);
 1502 }
 1503 
 1504 MeasureUnit *MeasureUnit::createMicrogram(UErrorCode &status) {
 1505     return MeasureUnit::create(15, 6, status);
 1506 }
 1507 
 1508 MeasureUnit MeasureUnit::getMicrogram() {
 1509     return MeasureUnit(15, 6);
 1510 }
 1511 
 1512 MeasureUnit *MeasureUnit::createMilligram(UErrorCode &status) {
 1513     return MeasureUnit::create(15, 7, status);
 1514 }
 1515 
 1516 MeasureUnit MeasureUnit::getMilligram() {
 1517     return MeasureUnit(15, 7);
 1518 }
 1519 
 1520 MeasureUnit *MeasureUnit::createOunce(UErrorCode &status) {
 1521     return MeasureUnit::create(15, 8, status);
 1522 }
 1523 
 1524 MeasureUnit MeasureUnit::getOunce() {
 1525     return MeasureUnit(15, 8);
 1526 }
 1527 
 1528 MeasureUnit *MeasureUnit::createOunceTroy(UErrorCode &status) {
 1529     return MeasureUnit::create(15, 9, status);
 1530 }
 1531 
 1532 MeasureUnit MeasureUnit::getOunceTroy() {
 1533     return MeasureUnit(15, 9);
 1534 }
 1535 
 1536 MeasureUnit *MeasureUnit::createPound(UErrorCode &status) {
 1537     return MeasureUnit::create(15, 10, status);
 1538 }
 1539 
 1540 MeasureUnit MeasureUnit::getPound() {
 1541     return MeasureUnit(15, 10);
 1542 }
 1543 
 1544 MeasureUnit *MeasureUnit::createSolarMass(UErrorCode &status) {
 1545     return MeasureUnit::create(15, 11, status);
 1546 }
 1547 
 1548 MeasureUnit MeasureUnit::getSolarMass() {
 1549     return MeasureUnit(15, 11);
 1550 }
 1551 
 1552 MeasureUnit *MeasureUnit::createStone(UErrorCode &status) {
 1553     return MeasureUnit::create(15, 12, status);
 1554 }
 1555 
 1556 MeasureUnit MeasureUnit::getStone() {
 1557     return MeasureUnit(15, 12);
 1558 }
 1559 
 1560 MeasureUnit *MeasureUnit::createTon(UErrorCode &status) {
 1561     return MeasureUnit::create(15, 13, status);
 1562 }
 1563 
 1564 MeasureUnit MeasureUnit::getTon() {
 1565     return MeasureUnit(15, 13);
 1566 }
 1567 
 1568 MeasureUnit *MeasureUnit::createGigawatt(UErrorCode &status) {
 1569     return MeasureUnit::create(17, 0, status);
 1570 }
 1571 
 1572 MeasureUnit MeasureUnit::getGigawatt() {
 1573     return MeasureUnit(17, 0);
 1574 }
 1575 
 1576 MeasureUnit *MeasureUnit::createHorsepower(UErrorCode &status) {
 1577     return MeasureUnit::create(17, 1, status);
 1578 }
 1579 
 1580 MeasureUnit MeasureUnit::getHorsepower() {
 1581     return MeasureUnit(17, 1);
 1582 }
 1583 
 1584 MeasureUnit *MeasureUnit::createKilowatt(UErrorCode &status) {
 1585     return MeasureUnit::create(17, 2, status);
 1586 }
 1587 
 1588 MeasureUnit MeasureUnit::getKilowatt() {
 1589     return MeasureUnit(17, 2);
 1590 }
 1591 
 1592 MeasureUnit *MeasureUnit::createMegawatt(UErrorCode &status) {
 1593     return MeasureUnit::create(17, 3, status);
 1594 }
 1595 
 1596 MeasureUnit MeasureUnit::getMegawatt() {
 1597     return MeasureUnit(17, 3);
 1598 }
 1599 
 1600 MeasureUnit *MeasureUnit::createMilliwatt(UErrorCode &status) {
 1601     return MeasureUnit::create(17, 4, status);
 1602 }
 1603 
 1604 MeasureUnit MeasureUnit::getMilliwatt() {
 1605     return MeasureUnit(17, 4);
 1606 }
 1607 
 1608 MeasureUnit *MeasureUnit::createWatt(UErrorCode &status) {
 1609     return MeasureUnit::create(17, 5, status);
 1610 }
 1611 
 1612 MeasureUnit MeasureUnit::getWatt() {
 1613     return MeasureUnit(17, 5);
 1614 }
 1615 
 1616 MeasureUnit *MeasureUnit::createAtmosphere(UErrorCode &status) {
 1617     return MeasureUnit::create(18, 0, status);
 1618 }
 1619 
 1620 MeasureUnit MeasureUnit::getAtmosphere() {
 1621     return MeasureUnit(18, 0);
 1622 }
 1623 
 1624 MeasureUnit *MeasureUnit::createBar(UErrorCode &status) {
 1625     return MeasureUnit::create(18, 1, status);
 1626 }
 1627 
 1628 MeasureUnit MeasureUnit::getBar() {
 1629     return MeasureUnit(18, 1);
 1630 }
 1631 
 1632 MeasureUnit *MeasureUnit::createHectopascal(UErrorCode &status) {
 1633     return MeasureUnit::create(18, 2, status);
 1634 }
 1635 
 1636 MeasureUnit MeasureUnit::getHectopascal() {
 1637     return MeasureUnit(18, 2);
 1638 }
 1639 
 1640 MeasureUnit *MeasureUnit::createInchHg(UErrorCode &status) {
 1641     return MeasureUnit::create(18, 3, status);
 1642 }
 1643 
 1644 MeasureUnit MeasureUnit::getInchHg() {
 1645     return MeasureUnit(18, 3);
 1646 }
 1647 
 1648 MeasureUnit *MeasureUnit::createKilopascal(UErrorCode &status) {
 1649     return MeasureUnit::create(18, 4, status);
 1650 }
 1651 
 1652 MeasureUnit MeasureUnit::getKilopascal() {
 1653     return MeasureUnit(18, 4);
 1654 }
 1655 
 1656 MeasureUnit *MeasureUnit::createMegapascal(UErrorCode &status) {
 1657     return MeasureUnit::create(18, 5, status);
 1658 }
 1659 
 1660 MeasureUnit MeasureUnit::getMegapascal() {
 1661     return MeasureUnit(18, 5);
 1662 }
 1663 
 1664 MeasureUnit *MeasureUnit::createMillibar(UErrorCode &status) {
 1665     return MeasureUnit::create(18, 6, status);
 1666 }
 1667 
 1668 MeasureUnit MeasureUnit::getMillibar() {
 1669     return MeasureUnit(18, 6);
 1670 }
 1671 
 1672 MeasureUnit *MeasureUnit::createMillimeterOfMercury(UErrorCode &status) {
 1673     return MeasureUnit::create(18, 7, status);
 1674 }
 1675 
 1676 MeasureUnit MeasureUnit::getMillimeterOfMercury() {
 1677     return MeasureUnit(18, 7);
 1678 }
 1679 
 1680 MeasureUnit *MeasureUnit::createPascal(UErrorCode &status) {
 1681     return MeasureUnit::create(18, 8, status);
 1682 }
 1683 
 1684 MeasureUnit MeasureUnit::getPascal() {
 1685     return MeasureUnit(18, 8);
 1686 }
 1687 
 1688 MeasureUnit *MeasureUnit::createPoundPerSquareInch(UErrorCode &status) {
 1689     return MeasureUnit::create(18, 9, status);
 1690 }
 1691 
 1692 MeasureUnit MeasureUnit::getPoundPerSquareInch() {
 1693     return MeasureUnit(18, 9);
 1694 }
 1695 
 1696 MeasureUnit *MeasureUnit::createKilometerPerHour(UErrorCode &status) {
 1697     return MeasureUnit::create(19, 0, status);
 1698 }
 1699 
 1700 MeasureUnit MeasureUnit::getKilometerPerHour() {
 1701     return MeasureUnit(19, 0);
 1702 }
 1703 
 1704 MeasureUnit *MeasureUnit::createKnot(UErrorCode &status) {
 1705     return MeasureUnit::create(19, 1, status);
 1706 }
 1707 
 1708 MeasureUnit MeasureUnit::getKnot() {
 1709     return MeasureUnit(19, 1);
 1710 }
 1711 
 1712 MeasureUnit *MeasureUnit::createMeterPerSecond(UErrorCode &status) {
 1713     return MeasureUnit::create(19, 2, status);
 1714 }
 1715 
 1716 MeasureUnit MeasureUnit::getMeterPerSecond() {
 1717     return MeasureUnit(19, 2);
 1718 }
 1719 
 1720 MeasureUnit *MeasureUnit::createMilePerHour(UErrorCode &status) {
 1721     return MeasureUnit::create(19, 3, status);
 1722 }
 1723 
 1724 MeasureUnit MeasureUnit::getMilePerHour() {
 1725     return MeasureUnit(19, 3);
 1726 }
 1727 
 1728 MeasureUnit *MeasureUnit::createCelsius(UErrorCode &status) {
 1729     return MeasureUnit::create(20, 0, status);
 1730 }
 1731 
 1732 MeasureUnit MeasureUnit::getCelsius() {
 1733     return MeasureUnit(20, 0);
 1734 }
 1735 
 1736 MeasureUnit *MeasureUnit::createFahrenheit(UErrorCode &status) {
 1737     return MeasureUnit::create(20, 1, status);
 1738 }
 1739 
 1740 MeasureUnit MeasureUnit::getFahrenheit() {
 1741     return MeasureUnit(20, 1);
 1742 }
 1743 
 1744 MeasureUnit *MeasureUnit::createGenericTemperature(UErrorCode &status) {
 1745     return MeasureUnit::create(20, 2, status);
 1746 }
 1747 
 1748 MeasureUnit MeasureUnit::getGenericTemperature() {
 1749     return MeasureUnit(20, 2);
 1750 }
 1751 
 1752 MeasureUnit *MeasureUnit::createKelvin(UErrorCode &status) {
 1753     return MeasureUnit::create(20, 3, status);
 1754 }
 1755 
 1756 MeasureUnit MeasureUnit::getKelvin() {
 1757     return MeasureUnit(20, 3);
 1758 }
 1759 
 1760 MeasureUnit *MeasureUnit::createNewtonMeter(UErrorCode &status) {
 1761     return MeasureUnit::create(21, 0, status);
 1762 }
 1763 
 1764 MeasureUnit MeasureUnit::getNewtonMeter() {
 1765     return MeasureUnit(21, 0);
 1766 }
 1767 
 1768 MeasureUnit *MeasureUnit::createPoundFoot(UErrorCode &status) {
 1769     return MeasureUnit::create(21, 1, status);
 1770 }
 1771 
 1772 MeasureUnit MeasureUnit::getPoundFoot() {
 1773     return MeasureUnit(21, 1);
 1774 }
 1775 
 1776 MeasureUnit *MeasureUnit::createAcreFoot(UErrorCode &status) {
 1777     return MeasureUnit::create(22, 0, status);
 1778 }
 1779 
 1780 MeasureUnit MeasureUnit::getAcreFoot() {
 1781     return MeasureUnit(22, 0);
 1782 }
 1783 
 1784 MeasureUnit *MeasureUnit::createBarrel(UErrorCode &status) {
 1785     return MeasureUnit::create(22, 1, status);
 1786 }
 1787 
 1788 MeasureUnit MeasureUnit::getBarrel() {
 1789     return MeasureUnit(22, 1);
 1790 }
 1791 
 1792 MeasureUnit *MeasureUnit::createBushel(UErrorCode &status) {
 1793     return MeasureUnit::create(22, 2, status);
 1794 }
 1795 
 1796 MeasureUnit MeasureUnit::getBushel() {
 1797     return MeasureUnit(22, 2);
 1798 }
 1799 
 1800 MeasureUnit *MeasureUnit::createCentiliter(UErrorCode &status) {
 1801     return MeasureUnit::create(22, 3, status);
 1802 }
 1803 
 1804 MeasureUnit MeasureUnit::getCentiliter() {
 1805     return MeasureUnit(22, 3);
 1806 }
 1807 
 1808 MeasureUnit *MeasureUnit::createCubicCentimeter(UErrorCode &status) {
 1809     return MeasureUnit::create(22, 4, status);
 1810 }
 1811 
 1812 MeasureUnit MeasureUnit::getCubicCentimeter() {
 1813     return MeasureUnit(22, 4);
 1814 }
 1815 
 1816 MeasureUnit *MeasureUnit::createCubicFoot(UErrorCode &status) {
 1817     return MeasureUnit::create(22, 5, status);
 1818 }
 1819 
 1820 MeasureUnit MeasureUnit::getCubicFoot() {
 1821     return MeasureUnit(22, 5);
 1822 }
 1823 
 1824 MeasureUnit *MeasureUnit::createCubicInch(UErrorCode &status) {
 1825     return MeasureUnit::create(22, 6, status);
 1826 }
 1827 
 1828 MeasureUnit MeasureUnit::getCubicInch() {
 1829     return MeasureUnit(22, 6);
 1830 }
 1831 
 1832 MeasureUnit *MeasureUnit::createCubicKilometer(UErrorCode &status) {
 1833     return MeasureUnit::create(22, 7, status);
 1834 }
 1835 
 1836 MeasureUnit MeasureUnit::getCubicKilometer() {
 1837     return MeasureUnit(22, 7);
 1838 }
 1839 
 1840 MeasureUnit *MeasureUnit::createCubicMeter(UErrorCode &status) {
 1841     return MeasureUnit::create(22, 8, status);
 1842 }
 1843 
 1844 MeasureUnit MeasureUnit::getCubicMeter() {
 1845     return MeasureUnit(22, 8);
 1846 }
 1847 
 1848 MeasureUnit *MeasureUnit::createCubicMile(UErrorCode &status) {
 1849     return MeasureUnit::create(22, 9, status);
 1850 }
 1851 
 1852 MeasureUnit MeasureUnit::getCubicMile() {
 1853     return MeasureUnit(22, 9);
 1854 }
 1855 
 1856 MeasureUnit *MeasureUnit::createCubicYard(UErrorCode &status) {
 1857     return MeasureUnit::create(22, 10, status);
 1858 }
 1859 
 1860 MeasureUnit MeasureUnit::getCubicYard() {
 1861     return MeasureUnit(22, 10);
 1862 }
 1863 
 1864 MeasureUnit *MeasureUnit::createCup(UErrorCode &status) {
 1865     return MeasureUnit::create(22, 11, status);
 1866 }
 1867 
 1868 MeasureUnit MeasureUnit::getCup() {
 1869     return MeasureUnit(22, 11);
 1870 }
 1871 
 1872 MeasureUnit *MeasureUnit::createCupMetric(UErrorCode &status) {
 1873     return MeasureUnit::create(22, 12, status);
 1874 }
 1875 
 1876 MeasureUnit MeasureUnit::getCupMetric() {
 1877     return MeasureUnit(22, 12);
 1878 }
 1879 
 1880 MeasureUnit *MeasureUnit::createDeciliter(UErrorCode &status) {
 1881     return MeasureUnit::create(22, 13, status);
 1882 }
 1883 
 1884 MeasureUnit MeasureUnit::getDeciliter() {
 1885     return MeasureUnit(22, 13);
 1886 }
 1887 
 1888 MeasureUnit *MeasureUnit::createFluidOunce(UErrorCode &status) {
 1889     return MeasureUnit::create(22, 14, status);
 1890 }
 1891 
 1892 MeasureUnit MeasureUnit::getFluidOunce() {
 1893     return MeasureUnit(22, 14);
 1894 }
 1895 
 1896 MeasureUnit *MeasureUnit::createFluidOunceImperial(UErrorCode &status) {
 1897     return MeasureUnit::create(22, 15, status);
 1898 }
 1899 
 1900 MeasureUnit MeasureUnit::getFluidOunceImperial() {
 1901     return MeasureUnit(22, 15);
 1902 }
 1903 
 1904 MeasureUnit *MeasureUnit::createGallon(UErrorCode &status) {
 1905     return MeasureUnit::create(22, 16, status);
 1906 }
 1907 
 1908 MeasureUnit MeasureUnit::getGallon() {
 1909     return MeasureUnit(22, 16);
 1910 }
 1911 
 1912 MeasureUnit *MeasureUnit::createGallonImperial(UErrorCode &status) {
 1913     return MeasureUnit::create(22, 17, status);
 1914 }
 1915 
 1916 MeasureUnit MeasureUnit::getGallonImperial() {
 1917     return MeasureUnit(22, 17);
 1918 }
 1919 
 1920 MeasureUnit *MeasureUnit::createHectoliter(UErrorCode &status) {
 1921     return MeasureUnit::create(22, 18, status);
 1922 }
 1923 
 1924 MeasureUnit MeasureUnit::getHectoliter() {
 1925     return MeasureUnit(22, 18);
 1926 }
 1927 
 1928 MeasureUnit *MeasureUnit::createLiter(UErrorCode &status) {
 1929     return MeasureUnit::create(22, 19, status);
 1930 }
 1931 
 1932 MeasureUnit MeasureUnit::getLiter() {
 1933     return MeasureUnit(22, 19);
 1934 }
 1935 
 1936 MeasureUnit *MeasureUnit::createMegaliter(UErrorCode &status) {
 1937     return MeasureUnit::create(22, 20, status);
 1938 }
 1939 
 1940 MeasureUnit MeasureUnit::getMegaliter() {
 1941     return MeasureUnit(22, 20);
 1942 }
 1943 
 1944 MeasureUnit *MeasureUnit::createMilliliter(UErrorCode &status) {
 1945     return MeasureUnit::create(22, 21, status);
 1946 }
 1947 
 1948 MeasureUnit MeasureUnit::getMilliliter() {
 1949     return MeasureUnit(22, 21);
 1950 }
 1951 
 1952 MeasureUnit *MeasureUnit::createPint(UErrorCode &status) {
 1953     return MeasureUnit::create(22, 22, status);
 1954 }
 1955 
 1956 MeasureUnit MeasureUnit::getPint() {
 1957     return MeasureUnit(22, 22);
 1958 }
 1959 
 1960 MeasureUnit *MeasureUnit::createPintMetric(UErrorCode &status) {
 1961     return MeasureUnit::create(22, 23, status);
 1962 }
 1963 
 1964 MeasureUnit MeasureUnit::getPintMetric() {
 1965     return MeasureUnit(22, 23);
 1966 }
 1967 
 1968 MeasureUnit *MeasureUnit::createQuart(UErrorCode &status) {
 1969     return MeasureUnit::create(22, 24, status);
 1970 }
 1971 
 1972 MeasureUnit MeasureUnit::getQuart() {
 1973     return MeasureUnit(22, 24);
 1974 }
 1975 
 1976 MeasureUnit *MeasureUnit::createTablespoon(UErrorCode &status) {
 1977     return MeasureUnit::create(22, 25, status);
 1978 }
 1979 
 1980 MeasureUnit MeasureUnit::getTablespoon() {
 1981     return MeasureUnit(22, 25);
 1982 }
 1983 
 1984 MeasureUnit *MeasureUnit::createTeaspoon(UErrorCode &status) {
 1985     return MeasureUnit::create(22, 26, status);
 1986 }
 1987 
 1988 MeasureUnit MeasureUnit::getTeaspoon() {
 1989     return MeasureUnit(22, 26);
 1990 }
 1991 
 1992 // End generated code
 1993 
 1994 static 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 
 2011 MeasureUnit::MeasureUnit() : MeasureUnit(kBaseTypeIdx, kBaseSubTypeIdx) {
 2012 }
 2013 
 2014 MeasureUnit::MeasureUnit(int32_t typeId, int32_t subTypeId)
 2015         : fImpl(nullptr), fSubTypeId(subTypeId), fTypeId(typeId) {
 2016 }
 2017 
 2018 MeasureUnit::MeasureUnit(const MeasureUnit &other)
 2019         : fImpl(nullptr) {
 2020     *this = other;
 2021 }
 2022 
 2023 MeasureUnit::MeasureUnit(MeasureUnit &&other) noexcept
 2024         : fImpl(other.fImpl),
 2025         fSubTypeId(other.fSubTypeId),
 2026         fTypeId(other.fTypeId) {
 2027     other.fImpl = nullptr;
 2028 }
 2029 
 2030 MeasureUnit::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 
 2037 MeasureUnit &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 
 2058 MeasureUnit &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 
 2070 MeasureUnit *MeasureUnit::clone() const {
 2071     return new MeasureUnit(*this);
 2072 }
 2073 
 2074 MeasureUnit::~MeasureUnit() {
 2075     delete fImpl;
 2076     fImpl = nullptr;
 2077 }
 2078 
 2079 const 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 
 2087 const 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 
 2095 const char *MeasureUnit::getIdentifier() const {
 2096     return fImpl ? fImpl->identifier.data() : gSubTypes[getOffset()];
 2097 }
 2098 
 2099 UBool 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 
 2110 int32_t MeasureUnit::getIndex() const {
 2111     return gIndexes[fTypeId] + fSubTypeId;
 2112 }
 2113 
 2114 int32_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 
 2137 int32_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 
 2160 StringEnumeration* 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 
 2176 int32_t MeasureUnit::getIndexCount() {
 2177     return gIndexes[UPRV_LENGTHOF(gIndexes) - 1];
 2178 }
 2179 
 2180 int32_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 
 2192 bool 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 
 2207 MeasureUnit 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 
 2242 MeasureUnit *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 
 2253 void 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 
 2262 void 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 
 2282 void 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 
 2291 void MeasureUnit::setTo(int32_t typeId, int32_t subTypeId) {
 2292     fTypeId = typeId;
 2293     fSubTypeId = subTypeId;
 2294     delete fImpl;
 2295     fImpl = nullptr;
 2296 }
 2297 
 2298 int32_t MeasureUnit::getOffset() const {
 2299     if (fTypeId < 0 || fSubTypeId < 0) {
 2300         return -1;
 2301     }
 2302     return gOffsets[fTypeId] + fSubTypeId;
 2303 }
 2304 
 2305 U_NAMESPACE_END
 2306 
 2307 #endif /* !UNCONFIG_NO_FORMATTING */