src/third_party/icu/source/i18n/units_converter.cpp
/*
  Adds single factor to a `Factor` object. Single factor means "23^2", "23.3333", "ft2m^3" ...etc.
  However, complex factor are not included, such as "ft2m^3*200/3"
*/
Adds single factor to a `Factor` object.
Adds single factor to a ` Factor ` object .
void addFactorElement(Factor &factor, StringPiece elementStr, Signum signum, UErrorCode &status) {
    StringPiece baseStr;
    StringPiece powerStr;
    int32_t power =
        1; 
    int32_t powerInd = -1;
    for (int32_t i = 0, n = elementStr.length(); i < n; ++i) {
        if (elementStr.data()[i] == '^') {
            powerInd = i;
            break;
        }
    }
    if (powerInd > -1) {
        baseStr = elementStr.substr(0, powerInd);
        powerStr = elementStr.substr(powerInd + 1);
        power = static_cast<int32_t>(strToDouble(powerStr, status));
    } else {
        baseStr = elementStr;
    }
    addSingleFactorConstant(baseStr, power, signum, factor, status);
}
void addFactorElement ( Factor & factor , StringPiece elementStr , Signum signum , UErrorCode & status ) { StringPiece baseStr ; StringPiece powerStr ; int32_t power = 1 ; int32_t powerInd = -1 ; for ( int32_t i = 0 , n = elementStr . length ( ) ; i < n ; ++ i ) { if ( elementStr . data ( ) [ i ] == ' ' ) { powerInd = i ; break ; } } if ( powerInd > -1 ) { baseStr = elementStr . substr ( 0 , powerInd ) ; powerStr = elementStr . substr ( powerInd + 1 ) ; power = static_cast < int32_t > ( strToDouble ( powerStr , status ) ) ; } else { baseStr = elementStr ; } addSingleFactorConstant ( baseStr , power , signum , factor , status ) ; }
Adds single factor to a `Factor` object.
Adds single factor to a ` Factor ` object .
// In case the power is not written, then, the power is equal 1 ==> `ft2m^1` == `ft2m` // Search for the power part // There is power