Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 0f759ae

Browse files
committed
EnumParameter: value space is irrelevant for serialization
The ValueSpace attribute is explicitly prohibited by the XML Schemas. Treating it as a special case is a mistake since it may break bijection. Signed-off-by: David Wagner <[email protected]>
1 parent 7087a69 commit 0f759ae

File tree

1 file changed

+6
-37
lines changed

1 file changed

+6
-37
lines changed

parameter/EnumParameterType.cpp

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -129,45 +129,14 @@ int32_t CEnumParameterType::getMax() const {
129129
return getMaxValue<int32_t>();
130130
}
131131

132-
bool CEnumParameterType::fromBlackboard(string& strValue, const uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const
132+
bool CEnumParameterType::fromBlackboard(string& strValue, const uint32_t& uiValue, CParameterAccessContext& /*ctx*/) const
133133
{
134-
// Take care of format
135-
if (parameterAccessContext.valueSpaceIsRaw()) {
136-
137-
// Format
138-
std::ostringstream strStream;
139-
140-
// Numerical format requested
141-
if (parameterAccessContext.outputRawFormatIsHex()) {
142-
143-
// Hexa display with unecessary bits cleared out
144-
strStream << "0x" << std::hex << std::uppercase << std::setw(getSize()*2) << std::setfill('0') << makeEncodable(uiValue);
145-
146-
strValue = strStream.str();
147-
} else {
148-
149-
// Integer display
150-
int32_t iValue = uiValue;
151-
152-
// Sign extend
153-
signExtend(iValue);
154-
155-
strStream << iValue;
156-
157-
strValue = strStream.str();
158-
}
159-
} else {
160-
161-
// Integer display
162-
int32_t iValue = uiValue;
163-
164-
// Sign extend
165-
signExtend(iValue);
134+
// Convert the raw value from the blackboard
135+
int32_t iValue = uiValue;
136+
signExtend(iValue);
166137

167-
// Literal display requested (should succeed)
168-
getLiteral(iValue, strValue);
169-
}
170-
return true;
138+
// Convert from numerical space to literal space
139+
return getLiteral(iValue, strValue);
171140
}
172141

173142
// Value access

0 commit comments

Comments
 (0)