diff options
author | Jean-Michel Trivi <jmtrivi@google.com> | 2015-07-15 15:37:57 -0700 |
---|---|---|
committer | Jean-Michel Trivi <jmtrivi@google.com> | 2015-07-15 17:09:51 -0700 |
commit | a9be2d378b7ad84e679a48efa81f42fb54f85d9a (patch) | |
tree | 587d34728dac3517a213d6d2a9a6ebdecd4e7531 /parameter/Element.cpp | |
parent | c99720d29f2ee618cc74c9336d2cd2a26544c020 (diff) | |
download | external_parameter-framework-a9be2d378b7ad84e679a48efa81f42fb54f85d9a.zip external_parameter-framework-a9be2d378b7ad84e679a48efa81f42fb54f85d9a.tar.gz external_parameter-framework-a9be2d378b7ad84e679a48efa81f42fb54f85d9a.tar.bz2 |
Drop release v2.6.0+no-stlport
Bug 246391
Change-Id: I662b7b0f90c97cb169978e1b64ad1fe32c440cf5
Signed-off-by: Jean-Michel Trivi <jmtrivi@google.com>
Diffstat (limited to 'parameter/Element.cpp')
-rw-r--r-- | parameter/Element.cpp | 80 |
1 files changed, 27 insertions, 53 deletions
diff --git a/parameter/Element.cpp b/parameter/Element.cpp index cacf49b..afd1f33 100644 --- a/parameter/Element.cpp +++ b/parameter/Element.cpp @@ -35,10 +35,11 @@ #include <stdio.h> #include <stdarg.h> #include <stdlib.h> -#include <sstream> using std::string; +const std::string CElement::gDescriptionPropertyName = "Description"; + CElement::CElement(const string& strName) : _strName(strName), _pParent(NULL) { } @@ -49,14 +50,14 @@ CElement::~CElement() } // Logging -void CElement::log_info(const string& strMessage, ...) const +void CElement::log_info(const char* strMessage, ...) const { char *pacBuffer; va_list listPointer; va_start(listPointer, strMessage); - vasprintf(&pacBuffer, strMessage.c_str(), listPointer); + vasprintf(&pacBuffer, strMessage, listPointer); va_end(listPointer); @@ -67,14 +68,14 @@ void CElement::log_info(const string& strMessage, ...) const free(pacBuffer); } -void CElement::log_warning(const string& strMessage, ...) const +void CElement::log_warning(const char* strMessage, ...) const { char *pacBuffer; va_list listPointer; va_start(listPointer, strMessage); - vasprintf(&pacBuffer, strMessage.c_str(), listPointer); + vasprintf(&pacBuffer, strMessage, listPointer); va_end(listPointer); @@ -200,43 +201,14 @@ void CElement::showProperties(string& strResult) const { strResult = "\n"; strResult += "Kind: " + getKind() + "\n"; + showDescriptionProperty(strResult); } -// Conversion utilities -string CElement::toString(uint32_t uiValue) +void CElement::showDescriptionProperty(std::string &strResult) const { - std::ostringstream ostr; - - ostr << uiValue; - - return ostr.str(); -} - -string CElement::toString(uint64_t uiValue) -{ - std::ostringstream ostr; - - ostr << uiValue; - - return ostr.str(); -} - -string CElement::toString(int32_t iValue) -{ - std::ostringstream ostr; - - ostr << iValue; - - return ostr.str(); -} - -string CElement::toString(double dValue) -{ - std::ostringstream ostr; - - ostr << dValue; - - return ostr.str(); + if (!getDescription().empty()) { + strResult += gDescriptionPropertyName + ": " + getDescription() + "\n"; + } } // Content dumping @@ -249,6 +221,8 @@ void CElement::logValue(string& strValue, CErrorContext& errorContext) const // From IXmlSink bool CElement::fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) { + setDescription(getXmlDescriptionAttribute(xmlElement)); + // Propagate through children CXmlElement::CChildIterator childIterator(xmlElement); @@ -316,9 +290,23 @@ void CElement::childrenToXml(CXmlElement& xmlElement, void CElement::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const { setXmlNameAttribute(xmlElement); + setXmlDescriptionAttribute(xmlElement); childrenToXml(xmlElement, serializingContext); } +void CElement::setXmlDescriptionAttribute(CXmlElement& xmlElement) const +{ + const string &description = getDescription(); + if (!description.empty()) { + xmlElement.setAttributeString(gDescriptionPropertyName, description); + } +} + +string CElement::getXmlDescriptionAttribute(const CXmlElement& xmlElement) const +{ + return xmlElement.getAttributeString(gDescriptionPropertyName); +} + void CElement::setXmlNameAttribute(CXmlElement& xmlElement) const { // By default, set Name attribute if any @@ -712,17 +700,3 @@ uint8_t CElement::computeStructureChecksum() const return uiChecksum; } - -// Utility to underline -void CElement::appendTitle(string& strTo, const string& strTitle) -{ - strTo += "\n" + strTitle + "\n"; - - string::size_type uiLength = strTitle.size(); - - while (uiLength--) { - - strTo += "="; - } - strTo += "\n"; -} |