summaryrefslogtreecommitdiffstats
path: root/parameter/BitParameterType.cpp
diff options
context:
space:
mode:
authorPatrick Benavoli <patrickx.benavoli@intel.com>2011-08-31 11:23:24 +0200
committerDavid Wagner <david.wagner@intel.com>2014-02-10 17:13:21 +0100
commit6ba361d96bc2581667b3400f87ff89fae6449e1f (patch)
treee72e959d7d4c3b0f0b6dc20ec4f07d957eae1a50 /parameter/BitParameterType.cpp
parent68a912857707864bbaaff9808717813105072a6e (diff)
downloadexternal_parameter-framework-6ba361d96bc2581667b3400f87ff89fae6449e1f.zip
external_parameter-framework-6ba361d96bc2581667b3400f87ff89fae6449e1f.tar.gz
external_parameter-framework-6ba361d96bc2581667b3400f87ff89fae6449e1f.tar.bz2
parameter-framework: improvements and corrections
BZ: 6721 - Bug correction concerning selection criteria display (inclusive type) - Adapted XML format to allow for only on parameter to be associated to a domain - Removed unused files in parameter project Change-Id: I9f42d08ff8cb60354714fe3d6b0f0b321ad0a7bf Orig-Change-Id: I837e553070f5acf2d275082c986ba29433493e31 Signed-off-by: Patrick Benavoli <patrickx.benavoli@intel.com> Reviewed-on: http://android.intel.com:8080/16878 Reviewed-by: Mahe, Erwan <erwan.mahe@intel.com> Tested-by: Barthes, FabienX <fabienx.barthes@intel.com> Reviewed-by: buildbot <buildbot@intel.com> Tested-by: buildbot <buildbot@intel.com>
Diffstat (limited to 'parameter/BitParameterType.cpp')
-rw-r--r--parameter/BitParameterType.cpp39
1 files changed, 36 insertions, 3 deletions
diff --git a/parameter/BitParameterType.cpp b/parameter/BitParameterType.cpp
index e12cd60..d9d1861 100644
--- a/parameter/BitParameterType.cpp
+++ b/parameter/BitParameterType.cpp
@@ -80,6 +80,10 @@ bool CBitParameterType::fromXml(const CXmlElement& xmlElement, CXmlSerializingCo
// Conversion
bool CBitParameterType::asInteger(const string& strValue, uint32_t& uiValue, CParameterAccessContext& parameterAccessContext) const
{
+ // Hexa
+ bool bValueProvidedAsHexa = !strValue.compare(0, 2, "0x");
+
+ // Get value
uint32_t uiConvertedValue = strtoul(strValue.c_str(), NULL, 0);
if (uiConvertedValue > getMaxValue()) {
@@ -87,26 +91,41 @@ bool CBitParameterType::asInteger(const string& strValue, uint32_t& uiValue, CPa
// Range exceeded
ostringstream strStream;
- strStream << strValue << " value out of range [0, " << getMaxValue() << "] for " + getKind();
+ strStream << "Value " << strValue << " standing out of admitted range [";
+
+ if (bValueProvidedAsHexa) {
+
+ strStream << "0x0, " << "0x" << hex << uppercase;
+ } else {
+
+ strStream << "0, ";
+ }
+ strStream << getMaxValue() << "] for " + getKind();
parameterAccessContext.setError(strStream.str());
return false;
}
- // Do bitwise operation
+ // Do bitwise RMW operation
uiValue = (uiValue & ~getMask()) | (uiConvertedValue << _uiBitPos);
return true;
}
-void CBitParameterType::asString(const uint32_t& uiValue, string& strValue) const
+void CBitParameterType::asString(const uint32_t& uiValue, string& strValue, CParameterAccessContext& parameterAccessContext) const
{
uint32_t uiConvertedValue = (uiValue & getMask()) >> _uiBitPos;
// Format
ostringstream strStream;
+ // Take care of format
+ if (parameterAccessContext.valueSpaceIsRaw() && parameterAccessContext.outputRawFormatIsHex()) {
+
+ strStream << "0x" << hex << uppercase;
+ }
+
strStream << uiConvertedValue;
strValue = strStream.str();
@@ -134,3 +153,17 @@ uint32_t CBitParameterType::getMask() const
{
return getMaxValue() << _uiBitPos;
}
+
+// Check data has no bit set outside available range
+bool CBitParameterType::isEncodable(uint32_t uiData) const
+{
+ uint32_t uiShift = 32 - _uiBitSize;
+
+ if (uiShift) {
+
+ // Check high bits are clean
+ return !(uiData >> uiShift);
+ }
+
+ return true;
+}