}
bool added = result.append(singleUnit, status);
if (sawPlus && !added) {
- // Two similar units are not allowed in a sequence unit
+ // Two similar units are not allowed in a mixed unit
status = kUnitIdentifierSyntaxError;
return;
}
if ((++unitNum) >= 2) {
UMeasureUnitComplexity complexity = sawPlus
- ? UMEASURE_UNIT_SEQUENCE
+ ? UMEASURE_UNIT_MIXED
: UMEASURE_UNIT_COMPOUND;
if (unitNum == 2) {
U_ASSERT(result.complexity == UMEASURE_UNIT_SINGLE);
result.complexity = complexity;
} else if (result.complexity != complexity) {
- // Mixed sequence and compound units
+ // Can't have mixed compound units
status = kUnitIdentifierSyntaxError;
return;
}
return;
}
if (impl.complexity == UMEASURE_UNIT_COMPOUND) {
- // Note: don't sort a SEQUENCE unit
+ // Note: don't sort a MIXED unit
uprv_sortArray(
impl.units.getAlias(),
impl.units.length(),
for (int32_t i = 1; i < impl.units.length(); i++) {
const SingleUnitImpl& prev = *impl.units[i-1];
const SingleUnitImpl& curr = *impl.units[i];
- if (impl.complexity == UMEASURE_UNIT_SEQUENCE) {
+ if (impl.complexity == UMEASURE_UNIT_MIXED) {
impl.identifier.append("-and-", status);
serializeSingle(curr, true, impl.identifier, status);
} else {
MeasureUnitImpl impl = MeasureUnitImpl::forMeasureUnitMaybeCopy(*this, status);
MeasureUnitImpl temp;
const MeasureUnitImpl& otherImpl = MeasureUnitImpl::forMeasureUnit(other, temp, status);
- if (impl.complexity == UMEASURE_UNIT_SEQUENCE || otherImpl.complexity == UMEASURE_UNIT_SEQUENCE) {
+ if (impl.complexity == UMEASURE_UNIT_MIXED || otherImpl.complexity == UMEASURE_UNIT_MIXED) {
status = U_ILLEGAL_ARGUMENT_ERROR;
return {};
}
* square-kilometer, kilojoule, one-per-second.
* - COMPOUND: A unit composed of the product of multiple single units. Examples:
* meter-per-second, kilowatt-hour, kilogram-meter-per-square-second.
- * - SEQUENCE: A unit composed of the sum of multiple single units. Examples: foot+inch,
- * hour+minute+second, degree+arcminute+arcsecond.
+ * - MIXED: A unit composed of the sum of multiple single units. Examples: foot+inch,
+ * hour+minute+second, degree+arcminute+arcsecond.
*
* The complexity determines which operations are available. For example, you cannot set the power
* or SI prefix of a compound unit.
UMEASURE_UNIT_COMPOUND,
/**
- * A sequence unit, like hour+minute.
+ * A mixed unit, like hour+minute.
*
* @draft ICU 67
*/
- UMEASURE_UNIT_SEQUENCE
+ UMEASURE_UNIT_MIXED
};
/**
MeasureUnit(MeasureUnit &&other) noexcept;
/**
- * Construct a MeasureUnit from a CLDR Sequence Unit Identifier, defined in UTS 35.
+ * Construct a MeasureUnit from a CLDR Unit Identifier, defined in UTS 35.
* Validates and canonicalizes the identifier.
*
* <pre>
* MeasureUnit example = MeasureUnit::forIdentifier("furlong-per-nanosecond")
* </pre>
*
- * @param identifier The CLDR Sequence Unit Identifier
+ * @param identifier The CLDR Unit Identifier
* @param status Set if the identifier is invalid.
* @draft ICU 67
*/
#ifndef U_HIDE_DRAFT_API
/**
- * Get the CLDR Sequence Unit Identifier for this MeasureUnit, as defined in UTS 35.
+ * Get the CLDR Unit Identifier for this MeasureUnit, as defined in UTS 35.
*
* @return The string form of this unit, owned by this MeasureUnit.
* @draft ICU 67
*
* There is sufficient locale data to format all standard SI prefixes.
*
- * NOTE: Only works on SINGLE units. If this is a COMPOUND or SEQUENCE unit, an error will
+ * NOTE: Only works on SINGLE units. If this is a COMPOUND or MIXED unit, an error will
* occur. For more information, see UMeasureUnitComplexity.
*
* @param prefix The SI prefix, from UMeasureSIPrefix.
* Gets the current SI prefix of this SINGLE unit. For example, if the unit has the SI prefix
* "kilo", then UMEASURE_SI_PREFIX_KILO is returned.
*
- * NOTE: Only works on SINGLE units. If this is a COMPOUND or SEQUENCE unit, an error will
+ * NOTE: Only works on SINGLE units. If this is a COMPOUND or MIXED unit, an error will
* occur. For more information, see UMeasureUnitComplexity.
*
* @param status Set if this is not a SINGLE unit or if another error occurs.
* Creates a MeasureUnit which is this SINGLE unit augmented with the specified dimensionality
* (power). For example, if dimensionality is 2, the unit will be squared.
*
- * NOTE: Only works on SINGLE units. If this is a COMPOUND or SEQUENCE unit, an error will
+ * NOTE: Only works on SINGLE units. If this is a COMPOUND or MIXED unit, an error will
* occur. For more information, see UMeasureUnitComplexity.
*
* @param dimensionality The dimensionality (power).
* Gets the dimensionality (power) of this MeasureUnit. For example, if the unit is square,
* then 2 is returned.
*
- * NOTE: Only works on SINGLE units. If this is a COMPOUND or SEQUENCE unit, an error will
+ * NOTE: Only works on SINGLE units. If this is a COMPOUND or MIXED unit, an error will
* occur. For more information, see UMeasureUnitComplexity.
*
* @param status Set if this is not a SINGLE unit or if another error occurs.
*
* For example, if the receiver is "meter-per-second", the unit "second-per-meter" is returned.
*
- * NOTE: Only works on SINGLE and COMPOUND units. If this is a SEQUENCE unit, an error will
+ * NOTE: Only works on SINGLE and COMPOUND units. If this is a MIXED unit, an error will
* occur. For more information, see UMeasureUnitComplexity.
*
- * @param status Set if this is a SEQUENCE unit or if another error occurs.
+ * @param status Set if this is a MIXED unit or if another error occurs.
* @return The reciprocal of the target unit.
* @draft ICU 67
*/
* unit "kilowatt-hour-per-day" is returned.
*
* NOTE: Only works on SINGLE and COMPOUND units. If either unit (receivee and argument) is a
- * SEQUENCE unit, an error will occur. For more information, see UMeasureUnitComplexity.
+ * MIXED unit, an error will occur. For more information, see UMeasureUnitComplexity.
*
* @param other The MeasureUnit to multiply with the target.
- * @param status Set if this or other is a SEQUENCE unit or if another error occurs.
+ * @param status Set if this or other is a MIXED unit or if another error occurs.
* @return The product of the target unit with the provided unit.
* @draft ICU 67
*/
#ifndef U_HIDE_INTERNAL_API
/**
- * Gets the list of SINGLE units contained within a SEQUENCE of COMPOUND unit.
+ * Gets the list of SINGLE units contained within a MIXED of COMPOUND unit.
*
* Examples:
* - Given "meter-kilogram-per-second", three units will be returned: "meter",
const char* identifier,
const char** subIdentifiers,
int32_t subIdentifierCount);
- void verifySequenceUnit(
+ void verifyMixedUnit(
const MeasureUnit& unit,
const char* identifier,
const char** subIdentifiers,
MeasureUnit inchFoot = MeasureUnit::forIdentifier("inch-and-foot", status);
const char* footInchSub[] = {"foot", "inch"};
- verifySequenceUnit(footInch, "foot-and-inch",
+ verifyMixedUnit(footInch, "foot-and-inch",
footInchSub, UPRV_LENGTHOF(footInchSub));
const char* inchFootSub[] = {"inch", "foot"};
- verifySequenceUnit(inchFoot, "inch-and-foot",
+ verifyMixedUnit(inchFoot, "inch-and-foot",
inchFootSub, UPRV_LENGTHOF(inchFootSub));
assertTrue("order matters inequality", footInch != inchFoot);
}
}
-void MeasureFormatTest::verifySequenceUnit(
+void MeasureFormatTest::verifyMixedUnit(
const MeasureUnit& unit,
const char* identifier,
const char** subIdentifiers,
int32_t subIdentifierCount) {
- IcuTestErrorCode status(*this, "verifySequenceUnit");
+ IcuTestErrorCode status(*this, "verifyMixedUnit");
UnicodeString uid(identifier, -1, US_INV);
assertEquals(uid + ": Identifier",
identifier,
unit == MeasureUnit::forIdentifier(identifier, status));
status.errIfFailureAndReset("%s: Constructor", identifier);
assertEquals(uid + ": Complexity",
- UMEASURE_UNIT_SEQUENCE,
+ UMEASURE_UNIT_MIXED,
unit.getComplexity(status));
status.errIfFailureAndReset("%s: Complexity", identifier);