summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bindings/python/pfw.i4
-rw-r--r--parameter/ParameterMgr.cpp70
-rw-r--r--parameter/ParameterMgr.h14
-rw-r--r--parameter/ParameterMgrFullConnector.cpp5
-rw-r--r--parameter/SelectionCriterion.cpp13
-rw-r--r--parameter/SelectionCriterion.h9
-rw-r--r--parameter/SelectionCriterionType.cpp23
-rw-r--r--parameter/SelectionCriterionType.h9
-rw-r--r--parameter/include/ParameterMgrFullConnector.h10
-rw-r--r--xmlserializer/XmlElement.cpp7
-rw-r--r--xmlserializer/XmlElement.h8
11 files changed, 126 insertions, 46 deletions
diff --git a/bindings/python/pfw.i b/bindings/python/pfw.i
index ce27173..9dbccbd 100644
--- a/bindings/python/pfw.i
+++ b/bindings/python/pfw.i
@@ -169,10 +169,6 @@ public:
bool exportSingleDomainXml(std::string& strXmlDest, const std::string& strDomainName, bool bWithSettings,
bool bToFile, std::string& strError) const;
%clear std::string& strXmlDest;
-
-%apply std::string &OUTPUT { std::string& strResult }
- bool getSystemClassXMLString(std::string& strResult);
-%clear std::string& strResult;
};
// SWIG nested class support is not complete - cf.
diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp
index 47abd0d..a1f2087 100644
--- a/parameter/ParameterMgr.cpp
+++ b/parameter/ParameterMgr.cpp
@@ -87,8 +87,11 @@
#include "XmlStringDocSource.h"
#include "XmlMemoryDocSink.h"
#include "XmlMemoryDocSource.h"
+#include "SelectionCriteriaDefinition.h"
#include "Utility.h"
#include <sstream>
+#include <algorithm>
+#include <ctype.h>
#include <memory>
#define base CElement
@@ -160,7 +163,7 @@ const CParameterMgr::SRemoteCommandParserItem CParameterMgr::gastRemoteCommandPa
/// Criteria
{ "listCriteria", &CParameterMgr::listCriteriaCommmandProcess, 0,
- "[csv]", "List selection criteria" },
+ "[CSV|XML]", "List selection criteria" },
/// Domains
{ "listDomains", &CParameterMgr::listDomainsCommmandProcess, 0,
@@ -1083,28 +1086,52 @@ CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::syncCommmandProcess
/// Criteria
CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult)
{
- (void)remoteCommand;
+ if (remoteCommand.getArgumentCount() > 1) {
- bool humanReadable = true;
+ return CCommandHandler::EShowUsage;
+ }
+
+ string strOutputFormat;
// Look for optional arguments
- if (remoteCommand.getArgumentCount() >= 1) {
+ if (remoteCommand.getArgumentCount() == 1) {
+
+ // Get requested format
+ strOutputFormat = remoteCommand.getArgument(0);
+
+ // Capitalize
+ std::transform(strOutputFormat.begin(), strOutputFormat.end(), strOutputFormat.begin(), ::toupper);
+
+ if (strOutputFormat != "XML" && strOutputFormat != "CSV") {
- // If csv is provided, format the criterion list in Commas Separated Value pairs
- if (remoteCommand.getArgument(0) == "csv") {
- humanReadable = false;
- } else {
return CCommandHandler::EShowUsage;
}
}
- list<string> lstrResult;
- getSelectionCriteria()->listSelectionCriteria(lstrResult, true, humanReadable);
+ if (strOutputFormat == "XML") {
+ // Get Root element where to export from
+ const CSelectionCriteriaDefinition* pSelectionCriteriaDefinition = getConstSelectionCriteria()->getSelectionCriteriaDefinition();
- // Concatenate the criterion list as the command result
- CUtility::asString(lstrResult, strResult);
+ if (!exportElementToXMLString(pSelectionCriteriaDefinition, "SelectionCriteria", false, strResult)) {
- return CCommandHandler::ESucceeded;
+ return CCommandHandler::EFailed;
+ }
+
+ // Succeeded
+ return CCommandHandler::ESucceeded;
+ } else {
+
+ // Requested format will be either CSV or human readable based on strOutputFormat content
+ bool bHumanReadable = strOutputFormat.empty();
+
+ list<string> lstrResult;
+ getSelectionCriteria()->listSelectionCriteria(lstrResult, true, bHumanReadable);
+
+ // Concatenate the criterion list as the command result
+ CUtility::asString(lstrResult, strResult);
+
+ return CCommandHandler::ESucceeded;
+ }
}
/// Domains
@@ -1646,7 +1673,10 @@ CParameterMgr::CCommandHandler::CommandStatus
{
(void)remoteCommand;
- if (!getSystemClassXMLString(strResult)) {
+ // Get Root element where to export from
+ const CSystemClass* pSystemClass = getSystemClass();
+
+ if (!exportElementToXMLString(pSystemClass, pSystemClass->getKind(), false, strResult)) {
return CCommandHandler::EFailed;
}
@@ -2581,28 +2611,26 @@ void CParameterMgr::doApplyConfigurations(bool bForce)
getSelectionCriteria()->resetModifiedStatus();
}
-bool CParameterMgr::getSystemClassXMLString(string& strResult)
+// Export to XML string
+bool CParameterMgr::exportElementToXMLString(const IXmlSource *pXmlSource, const string& strRootElementType, bool bValidateWithSchema, string& strResult) const
{
- // Root element
- const CSystemClass* pSystemClass = getSystemClass();
-
string strError;
CXmlSerializingContext xmlSerializingContext(strError);
// Use a doc source by loading data from instantiated Configurable Domains
- CXmlMemoryDocSource memorySource(pSystemClass, pSystemClass->getKind(),
- _bValidateSchemasOnStart);
+ CXmlMemoryDocSource memorySource(pXmlSource, strRootElementType,
+ bValidateWithSchema);
// Use a doc sink that write the doc data in a string
CXmlStringDocSink stringSink(strResult);
+ // Do the export
bool bProcessSuccess = stringSink.process(memorySource, xmlSerializingContext);
if (!bProcessSuccess) {
strResult = strError;
-
}
return bProcessSuccess;
diff --git a/parameter/ParameterMgr.h b/parameter/ParameterMgr.h
index 7edace1..03a1e92 100644
--- a/parameter/ParameterMgr.h
+++ b/parameter/ParameterMgr.h
@@ -88,7 +88,7 @@ class CParameterMgr : private CElement
};
// Version
static const uint32_t guiEditionMajor = 0x2;
- static const uint32_t guiEditionMinor = 0x3;
+ static const uint32_t guiEditionMinor = 0x4;
static const uint32_t guiRevision = 0x0;
// Parameter handle friendship
@@ -340,14 +340,16 @@ public:
bool exportDomainsBinary(const std::string& strFileName, std::string& strError);
/**
- * Method that creates an Xml description of the instanciated parameter structure contained
- * in SystemClass.
+ * Method that exports an Xml description of the passed element into a string
*
- * @param[out] strResult contains the xml description of SystemClass or the errors if any
+ * @param[in] pXmlSource The source element to export
+ * @param[in] strRootElementType The XML root element name of the exported instance document
+ * @param[in] bValidateWithSchema true if source XML document requires validation against schema
+ * @param[out] strResult contains the xml description or the error description in case false is returned
*
- * @return false if any error occures during the creation of the xml description
+ * @return true for success, false if any error occurs during the creation of the xml description (validation or encoding)
*/
- bool getSystemClassXMLString(std::string& strResult);
+ bool exportElementToXMLString(const IXmlSource* pXmlSource, const std::string& strRootElementType, bool bValidateWithSchema, std::string& strResult) const;
// CElement
virtual std::string getKind() const;
diff --git a/parameter/ParameterMgrFullConnector.cpp b/parameter/ParameterMgrFullConnector.cpp
index b03facc..30f31e9 100644
--- a/parameter/ParameterMgrFullConnector.cpp
+++ b/parameter/ParameterMgrFullConnector.cpp
@@ -363,8 +363,3 @@ bool CParameterMgrFullConnector::exportSingleDomainXml(string& strXmlDest,
return _pParameterMgr->exportSingleDomainXml(strXmlDest, strDomainName, bWithSettings, bToFile,
strError);
}
-
-bool CParameterMgrFullConnector::getSystemClassXMLString(string& strResult)
-{
- return _pParameterMgr->getSystemClassXMLString(strResult);
-}
diff --git a/parameter/SelectionCriterion.cpp b/parameter/SelectionCriterion.cpp
index f49137b..7818924 100644
--- a/parameter/SelectionCriterion.cpp
+++ b/parameter/SelectionCriterion.cpp
@@ -27,6 +27,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
#include "SelectionCriterion.h"
#include "AutoLog.h"
@@ -168,3 +169,15 @@ std::string CSelectionCriterion::getFormattedDescription(bool bWithTypeInfo, boo
}
return strFormattedDescription;
}
+
+// XML export
+void CSelectionCriterion::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const
+{
+ // Current Value
+ xmlElement.setAttributeString("Value", _pType->getFormattedState(_iState));
+
+ // Serialize Type node
+ _pType->toXml(xmlElement, serializingContext);
+
+ base::toXml(xmlElement, serializingContext);
+}
diff --git a/parameter/SelectionCriterion.h b/parameter/SelectionCriterion.h
index c61d7d0..cf99035 100644
--- a/parameter/SelectionCriterion.h
+++ b/parameter/SelectionCriterion.h
@@ -63,6 +63,15 @@ public:
/// From CElement
virtual std::string getKind() const;
+
+ /**
+ * Export to XML
+ *
+ * @param[in] xmlElement The XML element to export to
+ * @param[in] serializingContext The serializing context
+ *
+ */
+ virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const;
private:
// Current state
int _iState;
diff --git a/parameter/SelectionCriterionType.cpp b/parameter/SelectionCriterionType.cpp
index 3e9cc80..95e8e46 100644
--- a/parameter/SelectionCriterionType.cpp
+++ b/parameter/SelectionCriterionType.cpp
@@ -203,3 +203,26 @@ std::string CSelectionCriterionType::getFormattedState(int iValue) const
return strFormattedState;
}
+
+// From IXmlSource
+void CSelectionCriterionType::toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const
+{
+ // Type Kind
+ xmlElement.setAttributeString("Kind", isTypeInclusive() ? "Inclusive" : "Exclusive");
+
+ // Value pairs as children
+ NumToLitMapConstIt it;
+
+ for (it = _numToLitMap.begin(); it != _numToLitMap.end(); ++it) {
+
+ CXmlElement childValuePairElement;
+
+ xmlElement.createChild(childValuePairElement, "ValuePair");
+ // Literal
+ childValuePairElement.setAttributeString("Literal", it->first);
+ // Numerical
+ childValuePairElement.setAttributeSignedInteger("Numerical", it->second);
+ }
+
+ base::toXml(xmlElement, serializingContext);
+}
diff --git a/parameter/SelectionCriterionType.h b/parameter/SelectionCriterionType.h
index bfef21e..ef4176a 100644
--- a/parameter/SelectionCriterionType.h
+++ b/parameter/SelectionCriterionType.h
@@ -63,6 +63,15 @@ public:
// Formatted state
virtual std::string getFormattedState(int iValue) const;
+ /**
+ * Export to XML
+ *
+ * @param[in] xmlElement The XML element to export to
+ * @param[in] serializingContext The serializing context
+ *
+ */
+ virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const;
+
// From CElement
virtual std::string getKind() const;
private:
diff --git a/parameter/include/ParameterMgrFullConnector.h b/parameter/include/ParameterMgrFullConnector.h
index 8ef7bb7..31022a6 100644
--- a/parameter/include/ParameterMgrFullConnector.h
+++ b/parameter/include/ParameterMgrFullConnector.h
@@ -259,16 +259,6 @@ public:
bool exportSingleDomainXml(std::string& strXmlDest, const std::string& strDomainName, bool bWithSettings,
bool bToFile, std::string& strError) const;
- /**
- * Method that creates an Xml description of the instanciated parameter structure contained
- * in SystemClass.
- *
- * @param[out] strResult contains the xml description of SystemClass or the errors if any
- *
- * @return false if any error occures during the creation of the xml description
- */
- bool getSystemClassXMLString(std::string& strResult);
-
private:
// disallow copying because this class manages raw pointers' lifecycle
CParameterMgrFullConnector(const CParameterMgrFullConnector&);
diff --git a/xmlserializer/XmlElement.cpp b/xmlserializer/XmlElement.cpp
index 106bfdc..d45f360 100644
--- a/xmlserializer/XmlElement.cpp
+++ b/xmlserializer/XmlElement.cpp
@@ -221,6 +221,13 @@ void CXmlElement::setAttributeInteger(const string& strAttributeName, uint32_t u
setAttributeString(strAttributeName, strStream.str());
}
+void CXmlElement::setAttributeSignedInteger(const string& strAttributeName, int32_t iValue)
+{
+ ostringstream strStream;
+ strStream << iValue;
+ setAttributeString(strAttributeName, strStream.str());
+}
+
void CXmlElement::setNameAttribute(const string& strValue)
{
setAttributeString("Name", strValue);
diff --git a/xmlserializer/XmlElement.h b/xmlserializer/XmlElement.h
index 9c5ca0e..7c1d518 100644
--- a/xmlserializer/XmlElement.h
+++ b/xmlserializer/XmlElement.h
@@ -71,6 +71,14 @@ public:
void setTextContent(const std::string& strContent);
void setComment(const std::string& strComment);
void setAttributeInteger(const std::string& strAttributeName, uint32_t uiValue);
+ /**
+ * Set attribute with signed integer
+ *
+ * @param[in] strAttributeName The attribute name
+ * @param[in] iValue The attribute value
+ *
+ */
+ void setAttributeSignedInteger(const std::string& strAttributeName, int32_t iValue);
// Child creation
void createChild(CXmlElement& childElement, const std::string& strType);