return Token(match);
}
- void nextSingleUnit(TempSingleUnit& result, bool& sawPlus, UErrorCode& status) {
+ void nextSingleUnit(SingleUnitImpl& result, bool& sawPlus, UErrorCode& status) {
sawPlus = false;
if (U_FAILURE(status)) {
return;
int32_t unitNum = 0;
while (hasNext()) {
bool sawPlus;
- TempSingleUnit singleUnit;
+ SingleUnitImpl singleUnit;
nextSingleUnit(singleUnit, sawPlus, status);
if (U_FAILURE(status)) {
return;
int32_t U_CALLCONV
compareSingleUnits(const void* /*context*/, const void* left, const void* right) {
- auto realLeft = static_cast<const TempSingleUnit* const*>(left);
- auto realRight = static_cast<const TempSingleUnit* const*>(right);
+ auto realLeft = static_cast<const SingleUnitImpl* const*>(left);
+ auto realRight = static_cast<const SingleUnitImpl* const*>(right);
return (*realLeft)->compareTo(**realRight);
}
/**
* Generate the identifier string for a single unit in place.
*/
-void serializeSingle(const TempSingleUnit& singleUnit, bool first, CharString& output, UErrorCode& status) {
+void serializeSingle(const SingleUnitImpl& singleUnit, bool first, CharString& output, UErrorCode& status) {
if (first && singleUnit.dimensionality < 0) {
output.append("one-per-", status);
}
return;
}
for (int32_t i = 1; i < impl.units.length(); i++) {
- const TempSingleUnit& prev = *impl.units[i-1];
- const TempSingleUnit& curr = *impl.units[i];
+ const SingleUnitImpl& prev = *impl.units[i-1];
+ const SingleUnitImpl& curr = *impl.units[i];
if (impl.complexity == UMEASURE_UNIT_SEQUENCE) {
impl.identifier.append('+', status);
serializeSingle(curr, true, impl.identifier, status);
}
/** @return true if a new item was added */
-bool appendImpl(MeasureUnitImpl& impl, const TempSingleUnit& unit, UErrorCode& status) {
+bool appendImpl(MeasureUnitImpl& impl, const SingleUnitImpl& unit, UErrorCode& status) {
// Find a similar unit that already exists, to attempt to coalesce
- TempSingleUnit* oldUnit = nullptr;
+ SingleUnitImpl* oldUnit = nullptr;
for (int32_t i = 0; i < impl.units.length(); i++) {
auto* candidate = impl.units[i];
if (candidate->isCompatibleWith(unit)) {
if (oldUnit) {
oldUnit->dimensionality += unit.dimensionality;
} else {
- TempSingleUnit* destination = impl.units.emplaceBack();
+ SingleUnitImpl* destination = impl.units.emplaceBack();
if (!destination) {
status = U_MEMORY_ALLOCATION_ERROR;
return false;
} // namespace
-TempSingleUnit TempSingleUnit::forMeasureUnit(const MeasureUnit& measureUnit, UErrorCode& status) {
+SingleUnitImpl SingleUnitImpl::forMeasureUnit(const MeasureUnit& measureUnit, UErrorCode& status) {
MeasureUnitImpl temp;
const MeasureUnitImpl& impl = MeasureUnitImpl::forMeasureUnit(measureUnit, temp, status);
if (U_FAILURE(status)) {
}
}
-MeasureUnit TempSingleUnit::build(UErrorCode& status) {
+MeasureUnit SingleUnitImpl::build(UErrorCode& status) {
MeasureUnitImpl temp;
temp.append(*this, status);
return std::move(temp).build(status);
}
}
-bool MeasureUnitImpl::append(const TempSingleUnit& singleUnit, UErrorCode& status) {
+bool MeasureUnitImpl::append(const SingleUnitImpl& singleUnit, UErrorCode& status) {
identifier.clear();
return appendImpl(*this, singleUnit, status);
}
}
UMeasureSIPrefix MeasureUnit::getSIPrefix(UErrorCode& status) const {
- return TempSingleUnit::forMeasureUnit(*this, status).siPrefix;
+ return SingleUnitImpl::forMeasureUnit(*this, status).siPrefix;
}
MeasureUnit MeasureUnit::withSIPrefix(UMeasureSIPrefix prefix, UErrorCode& status) const {
- TempSingleUnit singleUnit = TempSingleUnit::forMeasureUnit(*this, status);
+ SingleUnitImpl singleUnit = SingleUnitImpl::forMeasureUnit(*this, status);
singleUnit.siPrefix = prefix;
return singleUnit.build(status);
}
int32_t MeasureUnit::getDimensionality(UErrorCode& status) const {
- return TempSingleUnit::forMeasureUnit(*this, status).dimensionality;
+ return SingleUnitImpl::forMeasureUnit(*this, status).dimensionality;
}
MeasureUnit MeasureUnit::withDimensionality(int32_t dimensionality, UErrorCode& status) const {
- TempSingleUnit singleUnit = TempSingleUnit::forMeasureUnit(*this, status);
+ SingleUnitImpl singleUnit = SingleUnitImpl::forMeasureUnit(*this, status);
singleUnit.dimensionality = dimensionality;
return singleUnit.build(status);
}
U_NAMESPACE_BEGIN
-struct TempSingleUnit : public UMemory {
+struct SingleUnitImpl : public UMemory {
/**
* Gets a single unit from the MeasureUnit. If there are multiple single units, sets an error
* code and return the base dimensionless unit. Parses if necessary.
*/
- static TempSingleUnit forMeasureUnit(const MeasureUnit& measureUnit, UErrorCode& status);
+ static SingleUnitImpl forMeasureUnit(const MeasureUnit& measureUnit, UErrorCode& status);
- /** Transform this TemplSingleUnit into a MeasureUnit, simplifying if possible. */
+ /** Transform this SingleUnitImpl into a MeasureUnit, simplifying if possible. */
MeasureUnit build(UErrorCode& status);
- /** Compare this TempSingleUnit to another TempSingleUnit. */
- int32_t compareTo(const TempSingleUnit& other) const {
+ /** Compare this SingleUnitImpl to another SingleUnitImpl. */
+ int32_t compareTo(const SingleUnitImpl& other) const {
if (dimensionality < 0 && other.dimensionality > 0) {
// Positive dimensions first
return 1;
}
/**
- * Return whether this TempSingleUnit is compatible with another for the purpose of coalescing.
+ * Return whether this SingleUnitImpl is compatible with another for the purpose of coalescing.
*
* Units with the same base unit and SI prefix should match, except that they must also have
* the same dimensionality sign, such that we don't merge numerator and denominator.
*/
- bool isCompatibleWith(const TempSingleUnit& other) const {
+ bool isCompatibleWith(const SingleUnitImpl& other) const {
return (compareTo(other) == 0);
}
void takeReciprocal(UErrorCode& status);
/** Mutates this MeasureUnitImpl to append a single unit. */
- bool append(const TempSingleUnit& singleUnit, UErrorCode& status);
+ bool append(const SingleUnitImpl& singleUnit, UErrorCode& status);
/** The complexity, either SINGLE, COMPOUND, or SEQUENCE. */
UMeasureUnitComplexity complexity = UMEASURE_UNIT_SINGLE;
* The list of simple units. These may be summed or multiplied, based on the value of the
* complexity field.
*/
- MaybeStackVector<TempSingleUnit> units;
+ MaybeStackVector<SingleUnitImpl> units;
/**
* The full unit identifier. Owned by the MeasureUnitImpl. Empty if not computed.