src/third_party/icu/source/i18n/number_usageprefs.cpp
// Populates micros.mixedMeasures and modifies quantity, based on the values in
// measures.
Populates micros.mixedMeasures and modifies quantity, based on the values in
measures.
Populates micros . mixedMeasures and modifies quantity based on the values in measures .
void mixedMeasuresToMicros(const MaybeStackVector<Measure> &measures, DecimalQuantity *quantity,
                           MicroProps *micros, UErrorCode status) {
    micros->mixedMeasuresCount = measures.length() - 1;
    if (micros->mixedMeasuresCount > 0) {
#ifdef U_DEBUG
        U_ASSERT(micros->outputUnit.getComplexity(status) == UMEASURE_UNIT_MIXED);
        U_ASSERT(U_SUCCESS(status));
        MeasureUnitImpl temp;
        const MeasureUnitImpl& impl = MeasureUnitImpl::forMeasureUnit(micros->outputUnit, temp, status);
        U_ASSERT(U_SUCCESS(status));
        U_ASSERT(measures.length() == impl.units.length());
        for (int32_t i = 0; i < measures.length(); i++) {
            U_ASSERT(measures[i]->getUnit() == impl.units[i]->build(status));
        }
        (void)impl;
#endif
        if (micros->mixedMeasures.getCapacity() < micros->mixedMeasuresCount) {
            if (micros->mixedMeasures.resize(micros->mixedMeasuresCount) == nullptr) {
                status = U_MEMORY_ALLOCATION_ERROR;
                return;
            }
        }
        for (int32_t i = 0; i < micros->mixedMeasuresCount; i++) {
            micros->mixedMeasures[i] = measures[i]->getNumber().getInt64();
        }
    } else {
        micros->mixedMeasuresCount = 0;
    }
    quantity->setToDouble(measures[measures.length() - 1]->getNumber().getDouble());
}
void mixedMeasuresToMicros ( const MaybeStackVector < Measure > & measures , DecimalQuantity * quantity , MicroProps * micros , UErrorCode status ) { micros -> mixedMeasuresCount = measures . length ( ) - 1 ; if ( micros -> mixedMeasuresCount > 0 ) { #ifdef U_DEBUG U_ASSERT ( micros -> outputUnit . getComplexity ( status ) == UMEASURE_UNIT_MIXED ) ; U_ASSERT ( U_SUCCESS ( status ) ) ; MeasureUnitImpl temp ; const MeasureUnitImpl & impl = MeasureUnitImpl :: forMeasureUnit ( micros -> outputUnit , temp , status ) ; U_ASSERT ( U_SUCCESS ( status ) ) ; U_ASSERT ( measures . length ( ) == impl . units . length ( ) ) ; for ( int32_t i = 0 ; i < measures . length ( ) ; i ++ ) { U_ASSERT ( measures [ i ] -> getUnit ( ) == impl . units [ i ] -> build ( status ) ) ; } ( void ) impl ; #endif if ( micros -> mixedMeasures . getCapacity ( ) < micros -> mixedMeasuresCount ) { if ( micros -> mixedMeasures . resize ( micros -> mixedMeasuresCount ) == nullptr ) { status = U_MEMORY_ALLOCATION_ERROR ; return ; } } for ( int32_t i = 0 ; i < micros -> mixedMeasuresCount ; i ++ ) { micros -> mixedMeasures [ i ] = measures [ i ] -> getNumber ( ) . getInt64 ( ) ; } } else { micros -> mixedMeasuresCount = 0 ; } quantity -> setToDouble ( measures [ measures . length ( ) - 1 ] -> getNumber ( ) . getDouble ( ) ) ; }
Populates micros.mixedMeasures and modifies quantity, based on the values in
measures.
Populates micros . mixedMeasures and modifies quantity based on the values in measures .
// Check that we received measurements with the expected MeasureUnits: // Mixed units: except for the last value, we pass all values to the // LongNameHandler via micros->mixedMeasures. // The last value (potentially the only value) gets passed on via quantity.