コード例 #1
0
bool CEnumParameterType::fromBlackboard(string &userValue, const uint32_t &value,
                                        CParameterAccessContext &ctx) const
{
    // Convert the raw value from the blackboard
    int32_t signedValue = static_cast<int32_t>(value);
    signExtend(signedValue);

    // Take care of format
    if (ctx.valueSpaceIsRaw()) {

        // Format
        std::ostringstream sstream;

        // Numerical format requested
        if (ctx.outputRawFormatIsHex()) {

            // Hexa display with unecessary bits cleared out
            sstream << "0x" << std::hex << std::uppercase
                    << std::setw(static_cast<int>(getSize() * 2)) << std::setfill('0')
                    << makeEncodable(value);

            userValue = sstream.str();
        } else {
            userValue = std::to_string(value);
        }
    } else {
        // Literal display requested (should succeed)
        getLiteral(signedValue, userValue);
    }
    return true;
}
コード例 #2
0
bool CEnumParameterType::fromBlackboard(string& strValue, const uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const
{
    // Take care of format
    if (parameterAccessContext.valueSpaceIsRaw()) {

        // Format
	std::ostringstream strStream;

        // Numerical format requested
        if (parameterAccessContext.outputRawFormatIsHex()) {

            // Hexa display with unecessary bits cleared out
            strStream << "0x" << std::hex << std::uppercase << std::setw(getSize()*2) << std::setfill('0') << makeEncodable(uiValue);

            strValue = strStream.str();
        } else {

            // Integer display
            int32_t iValue = uiValue;

            // Sign extend
            signExtend(iValue);

            strStream << iValue;

            strValue = strStream.str();
        }
    } else {

        // Integer display
        int32_t iValue = uiValue;

        // Sign extend
        signExtend(iValue);

        // Literal display requested (should succeed)
        getLiteral(iValue, strValue);
    }
    return true;
}
コード例 #3
0
bool CFixedPointParameterType::fromBlackboard(string& strValue, const uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const
{
    int32_t iData = uiValue;

    // Check encodability
    assert(isEncodable((uint32_t)iData, false));

    // Format
    std::ostringstream strStream;

    // Raw formatting?
    if (parameterAccessContext.valueSpaceIsRaw()) {

        // Hexa formatting?
        if (parameterAccessContext.outputRawFormatIsHex()) {

            strStream << "0x" << std::hex << std::uppercase << std::setw(getSize()*2) << std::setfill('0') << (uint32_t)iData;
        } else {

            // Sign extend
            signExtend(iData);

            strStream << iData;
        }
    } else {

        // Sign extend
        signExtend(iData);

        // Conversion
        double dData = binaryQnmToDouble(iData);

        strStream << std::fixed << std::setprecision(_uiFractional) << dData;
    }

    strValue = strStream.str();

    return true;
}