//
// Start generated code
+
static const int32_t gOffsets[] = {
0,
2,
16,
20,
24,
- 285,
- 295,
- 306,
- 310,
- 316,
- 320,
- 340,
- 341,
- 352,
- 358,
- 363,
- 367,
- 371,
- 396
+ 322,
+ 332,
+ 343,
+ 347,
+ 353,
+ 357,
+ 377,
+ 378,
+ 389,
+ 392,
+ 398,
+ 403,
+ 407,
+ 411,
+ 436
};
static const int32_t gIndexes[] = {
79,
80,
91,
- 97,
- 102,
- 106,
- 110,
- 135
+ 94,
+ 100,
+ 105,
+ 109,
+ 113,
+ 138
};
// Must be sorted alphabetically.
"length",
"light",
"mass",
+ "none",
"power",
"pressure",
"speed",
"AED",
"AFA",
"AFN",
+ "ALK",
"ALL",
"AMD",
"ANG",
"AOA",
+ "AOK",
"AON",
"AOR",
"ARA",
"ARP",
"ARS",
+ "ARY",
"ATS",
"AUD",
"AWG",
"BEC",
"BEF",
"BEL",
+ "BGJ",
+ "BGK",
"BGL",
"BGN",
"BHD",
"BMD",
"BND",
"BOB",
+ "BOP",
"BOV",
+ "BRB",
"BRC",
"BRE",
"BRL",
"BRR",
"BSD",
"BTN",
+ "BUK",
"BWP",
"BYB",
"BYN",
"COU",
"CRC",
"CSD",
+ "CSJ",
"CSK",
"CUC",
"CUP",
"GHS",
"GIP",
"GMD",
+ "GNE",
"GNF",
+ "GNS",
"GQE",
"GRD",
"GTQ",
+ "GWE",
"GWP",
"GYD",
"HKD",
"HUF",
"IDR",
"IEP",
+ "ILP",
+ "ILR",
"ILS",
"INR",
"IQD",
"IRR",
+ "ISJ",
"ISK",
"ITL",
"JMD",
"KWD",
"KYD",
"KZT",
+ "LAJ",
"LAK",
"LBP",
"LKR",
"LRD",
"LSL",
+ "LSM",
"LTL",
"LTT",
"LUC",
"MNT",
"MOP",
"MRO",
+ "MRU",
"MTL",
+ "MTP",
"MUR",
+ "MVQ",
"MVR",
"MWK",
"MXN",
+ "MXP",
"MXV",
"MYR",
+ "MZE",
"MZM",
"MZN",
"NAD",
"NGN",
+ "NIC",
"NIO",
"NLG",
"NOK",
"NZD",
"OMR",
"PAB",
+ "PEH",
"PEI",
"PEN",
"PES",
"PTE",
"PYG",
"QAR",
+ "RHD",
+ "ROK",
"ROL",
"RON",
"RSD",
"SCR",
"SDD",
"SDG",
+ "SDP",
"SEK",
"SGD",
"SHP",
"SRG",
"SSP",
"STD",
+ "STN",
+ "SUR",
"SVC",
"SYP",
"SZL",
"TZS",
"UAH",
"UAK",
+ "UGS",
+ "UGW",
"UGX",
"USD",
"USN",
"USS",
"UYI",
+ "UYN",
+ "UYP",
"UYU",
"UZS",
"VEB",
"VEF",
+ "VES",
+ "VNC",
"VND",
"VUV",
"WST",
"XXX",
"YDD",
"YER",
+ "YUD",
"YUM",
"YUN",
"ZAL",
"ZMW",
"ZRN",
"ZRZ",
+ "ZWC",
"ZWD",
"ZWL",
"ZWN",
"pound",
"stone",
"ton",
+ "base",
+ "percent",
+ "permille",
"gigawatt",
"horsepower",
"kilowatt",
// Must be sorted by first value and then second value.
static int32_t unitPerUnitToSingleUnit[][4] = {
- {327, 297, 16, 0},
- {329, 303, 16, 2},
- {331, 297, 16, 3},
- {331, 385, 4, 2},
- {331, 386, 4, 3},
- {346, 383, 3, 1},
- {349, 11, 15, 4},
- {388, 327, 4, 1}
+ {364, 334, 17, 0},
+ {366, 340, 17, 2},
+ {368, 334, 17, 3},
+ {368, 425, 4, 2},
+ {368, 426, 4, 3},
+ {383, 423, 3, 1},
+ {386, 11, 16, 4},
+ {428, 364, 4, 1}
};
+// Shortcuts to the base unit in order to make the default constructor fast
+static const int32_t kBaseTypeIdx = 14;
+static const int32_t kBaseSubTypeIdx = 0;
+
MeasureUnit *MeasureUnit::createGForce(UErrorCode &status) {
return MeasureUnit::create(0, 0, status);
}
return MeasureUnit::create(4, 3, status);
}
-// MeasureUnit *MeasureUnit::createEast(UErrorCode &status) {...}
-
-// MeasureUnit *MeasureUnit::createNorth(UErrorCode &status) {...}
-
-// MeasureUnit *MeasureUnit::createSouth(UErrorCode &status) {...}
-
-// MeasureUnit *MeasureUnit::createWest(UErrorCode &status) {...}
-
MeasureUnit *MeasureUnit::createBit(UErrorCode &status) {
return MeasureUnit::create(6, 0, status);
}
}
MeasureUnit *MeasureUnit::createGigawatt(UErrorCode &status) {
- return MeasureUnit::create(14, 0, status);
+ return MeasureUnit::create(15, 0, status);
}
MeasureUnit *MeasureUnit::createHorsepower(UErrorCode &status) {
- return MeasureUnit::create(14, 1, status);
+ return MeasureUnit::create(15, 1, status);
}
MeasureUnit *MeasureUnit::createKilowatt(UErrorCode &status) {
- return MeasureUnit::create(14, 2, status);
+ return MeasureUnit::create(15, 2, status);
}
MeasureUnit *MeasureUnit::createMegawatt(UErrorCode &status) {
- return MeasureUnit::create(14, 3, status);
+ return MeasureUnit::create(15, 3, status);
}
MeasureUnit *MeasureUnit::createMilliwatt(UErrorCode &status) {
- return MeasureUnit::create(14, 4, status);
+ return MeasureUnit::create(15, 4, status);
}
MeasureUnit *MeasureUnit::createWatt(UErrorCode &status) {
- return MeasureUnit::create(14, 5, status);
+ return MeasureUnit::create(15, 5, status);
}
MeasureUnit *MeasureUnit::createHectopascal(UErrorCode &status) {
- return MeasureUnit::create(15, 0, status);
+ return MeasureUnit::create(16, 0, status);
}
MeasureUnit *MeasureUnit::createInchHg(UErrorCode &status) {
- return MeasureUnit::create(15, 1, status);
+ return MeasureUnit::create(16, 1, status);
}
MeasureUnit *MeasureUnit::createMillibar(UErrorCode &status) {
- return MeasureUnit::create(15, 2, status);
+ return MeasureUnit::create(16, 2, status);
}
MeasureUnit *MeasureUnit::createMillimeterOfMercury(UErrorCode &status) {
- return MeasureUnit::create(15, 3, status);
+ return MeasureUnit::create(16, 3, status);
}
MeasureUnit *MeasureUnit::createPoundPerSquareInch(UErrorCode &status) {
- return MeasureUnit::create(15, 4, status);
+ return MeasureUnit::create(16, 4, status);
}
MeasureUnit *MeasureUnit::createKilometerPerHour(UErrorCode &status) {
- return MeasureUnit::create(16, 0, status);
+ return MeasureUnit::create(17, 0, status);
}
MeasureUnit *MeasureUnit::createKnot(UErrorCode &status) {
- return MeasureUnit::create(16, 1, status);
+ return MeasureUnit::create(17, 1, status);
}
MeasureUnit *MeasureUnit::createMeterPerSecond(UErrorCode &status) {
- return MeasureUnit::create(16, 2, status);
+ return MeasureUnit::create(17, 2, status);
}
MeasureUnit *MeasureUnit::createMilePerHour(UErrorCode &status) {
- return MeasureUnit::create(16, 3, status);
+ return MeasureUnit::create(17, 3, status);
}
MeasureUnit *MeasureUnit::createCelsius(UErrorCode &status) {
- return MeasureUnit::create(17, 0, status);
+ return MeasureUnit::create(18, 0, status);
}
MeasureUnit *MeasureUnit::createFahrenheit(UErrorCode &status) {
- return MeasureUnit::create(17, 1, status);
+ return MeasureUnit::create(18, 1, status);
}
MeasureUnit *MeasureUnit::createGenericTemperature(UErrorCode &status) {
- return MeasureUnit::create(17, 2, status);
+ return MeasureUnit::create(18, 2, status);
}
MeasureUnit *MeasureUnit::createKelvin(UErrorCode &status) {
- return MeasureUnit::create(17, 3, status);
+ return MeasureUnit::create(18, 3, status);
}
MeasureUnit *MeasureUnit::createAcreFoot(UErrorCode &status) {
- return MeasureUnit::create(18, 0, status);
+ return MeasureUnit::create(19, 0, status);
}
MeasureUnit *MeasureUnit::createBushel(UErrorCode &status) {
- return MeasureUnit::create(18, 1, status);
+ return MeasureUnit::create(19, 1, status);
}
MeasureUnit *MeasureUnit::createCentiliter(UErrorCode &status) {
- return MeasureUnit::create(18, 2, status);
+ return MeasureUnit::create(19, 2, status);
}
MeasureUnit *MeasureUnit::createCubicCentimeter(UErrorCode &status) {
- return MeasureUnit::create(18, 3, status);
+ return MeasureUnit::create(19, 3, status);
}
MeasureUnit *MeasureUnit::createCubicFoot(UErrorCode &status) {
- return MeasureUnit::create(18, 4, status);
+ return MeasureUnit::create(19, 4, status);
}
MeasureUnit *MeasureUnit::createCubicInch(UErrorCode &status) {
- return MeasureUnit::create(18, 5, status);
+ return MeasureUnit::create(19, 5, status);
}
MeasureUnit *MeasureUnit::createCubicKilometer(UErrorCode &status) {
- return MeasureUnit::create(18, 6, status);
+ return MeasureUnit::create(19, 6, status);
}
MeasureUnit *MeasureUnit::createCubicMeter(UErrorCode &status) {
- return MeasureUnit::create(18, 7, status);
+ return MeasureUnit::create(19, 7, status);
}
MeasureUnit *MeasureUnit::createCubicMile(UErrorCode &status) {
- return MeasureUnit::create(18, 8, status);
+ return MeasureUnit::create(19, 8, status);
}
MeasureUnit *MeasureUnit::createCubicYard(UErrorCode &status) {
- return MeasureUnit::create(18, 9, status);
+ return MeasureUnit::create(19, 9, status);
}
MeasureUnit *MeasureUnit::createCup(UErrorCode &status) {
- return MeasureUnit::create(18, 10, status);
+ return MeasureUnit::create(19, 10, status);
}
MeasureUnit *MeasureUnit::createCupMetric(UErrorCode &status) {
- return MeasureUnit::create(18, 11, status);
+ return MeasureUnit::create(19, 11, status);
}
MeasureUnit *MeasureUnit::createDeciliter(UErrorCode &status) {
- return MeasureUnit::create(18, 12, status);
+ return MeasureUnit::create(19, 12, status);
}
MeasureUnit *MeasureUnit::createFluidOunce(UErrorCode &status) {
- return MeasureUnit::create(18, 13, status);
+ return MeasureUnit::create(19, 13, status);
}
MeasureUnit *MeasureUnit::createGallon(UErrorCode &status) {
- return MeasureUnit::create(18, 14, status);
+ return MeasureUnit::create(19, 14, status);
}
MeasureUnit *MeasureUnit::createGallonImperial(UErrorCode &status) {
- return MeasureUnit::create(18, 15, status);
+ return MeasureUnit::create(19, 15, status);
}
MeasureUnit *MeasureUnit::createHectoliter(UErrorCode &status) {
- return MeasureUnit::create(18, 16, status);
+ return MeasureUnit::create(19, 16, status);
}
MeasureUnit *MeasureUnit::createLiter(UErrorCode &status) {
- return MeasureUnit::create(18, 17, status);
+ return MeasureUnit::create(19, 17, status);
}
MeasureUnit *MeasureUnit::createMegaliter(UErrorCode &status) {
- return MeasureUnit::create(18, 18, status);
+ return MeasureUnit::create(19, 18, status);
}
MeasureUnit *MeasureUnit::createMilliliter(UErrorCode &status) {
- return MeasureUnit::create(18, 19, status);
+ return MeasureUnit::create(19, 19, status);
}
MeasureUnit *MeasureUnit::createPint(UErrorCode &status) {
- return MeasureUnit::create(18, 20, status);
+ return MeasureUnit::create(19, 20, status);
}
MeasureUnit *MeasureUnit::createPintMetric(UErrorCode &status) {
- return MeasureUnit::create(18, 21, status);
+ return MeasureUnit::create(19, 21, status);
}
MeasureUnit *MeasureUnit::createQuart(UErrorCode &status) {
- return MeasureUnit::create(18, 22, status);
+ return MeasureUnit::create(19, 22, status);
}
MeasureUnit *MeasureUnit::createTablespoon(UErrorCode &status) {
- return MeasureUnit::create(18, 23, status);
+ return MeasureUnit::create(19, 23, status);
}
MeasureUnit *MeasureUnit::createTeaspoon(UErrorCode &status) {
- return MeasureUnit::create(18, 24, status);
+ return MeasureUnit::create(19, 24, status);
}
// End generated code
}
return -1;
}
-
+
+MeasureUnit::MeasureUnit() {
+ fCurrency[0] = 0;
+ fTypeId = kBaseTypeIdx;
+ fSubTypeId = kBaseSubTypeIdx;
+}
+
MeasureUnit::MeasureUnit(const MeasureUnit &other)
: fTypeId(other.fTypeId), fSubTypeId(other.fSubTypeId) {
uprv_strcpy(fCurrency, other.fCurrency);
return gIndexes[t] + st - gOffsets[t];
}
-MeasureUnit *MeasureUnit::resolveUnitPerUnit(
- const MeasureUnit &unit, const MeasureUnit &perUnit) {
+MeasureUnit MeasureUnit::resolveUnitPerUnit(
+ const MeasureUnit &unit, const MeasureUnit &perUnit, bool* isResolved) {
int32_t unitOffset = unit.getOffset();
int32_t perUnitOffset = perUnit.getOffset();
} else {
// We found a resolution for our unit / per-unit combo
// return it.
- return new MeasureUnit(midRow[2], midRow[3]);
+ *isResolved = true;
+ return MeasureUnit(midRow[2], midRow[3]);
}
}
- return NULL;
+
+ *isResolved = false;
+ return MeasureUnit();
}
MeasureUnit *MeasureUnit::create(int typeId, int subTypeId, UErrorCode &status) {
}
}
+void MeasureUnit::initNoUnit(const char *subtype) {
+ int32_t result = binarySearch(gTypes, 0, UPRV_LENGTHOF(gTypes), "none");
+ U_ASSERT(result != -1);
+ fTypeId = result;
+ result = binarySearch(gSubTypes, gOffsets[fTypeId], gOffsets[fTypeId + 1], subtype);
+ U_ASSERT(result != -1);
+ fSubTypeId = result - gOffsets[fTypeId];
+}
+
void MeasureUnit::setTo(int32_t typeId, int32_t subTypeId) {
fTypeId = typeId;
fSubTypeId = subTypeId;