summaryrefslogtreecommitdiffstats
path: root/xmlserializer
diff options
context:
space:
mode:
Diffstat (limited to 'xmlserializer')
-rw-r--r--xmlserializer/Android.mk38
l---------xmlserializer/XML1
-rw-r--r--xmlserializer/XmlComposer.cpp111
-rw-r--r--xmlserializer/XmlComposer.h55
-rw-r--r--xmlserializer/XmlElement.cpp235
-rw-r--r--xmlserializer/XmlElement.h93
-rw-r--r--xmlserializer/XmlParser.cpp162
-rw-r--r--xmlserializer/XmlParser.h54
-rw-r--r--xmlserializer/XmlSerializer.cpp89
-rw-r--r--xmlserializer/XmlSerializer.h74
-rw-r--r--xmlserializer/XmlSerializingContext.cpp51
-rw-r--r--xmlserializer/XmlSerializingContext.h49
-rw-r--r--xmlserializer/XmlSink.h40
-rw-r--r--xmlserializer/XmlSource.h40
l---------xmlserializer/parameter1
l---------xmlserializer/parameter-connector-test1
l---------xmlserializer/parameter-test1
l---------xmlserializer/remote-process1
l---------xmlserializer/remote-processor1
l---------xmlserializer/remote-processor-test1
l---------xmlserializer/utility1
l---------xmlserializer/xmlparser-test1
22 files changed, 1100 insertions, 0 deletions
diff --git a/xmlserializer/Android.mk b/xmlserializer/Android.mk
new file mode 100644
index 0000000..6d68dad
--- /dev/null
+++ b/xmlserializer/Android.mk
@@ -0,0 +1,38 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)
+
+LOCAL_SRC_FILES:= \
+ XmlParser.cpp \
+ XmlElement.cpp \
+ XmlComposer.cpp \
+ XmlSerializingContext.cpp \
+ XmlSerializer.cpp
+
+LOCAL_MODULE:= libxmlserializer
+
+LOCAL_MODULE_TAGS := optional
+
+TARGET_ERROR_FLAGS += -Wno-non-virtual-dtor
+
+LOCAL_C_INCLUDES +=
+
+LOCAL_C_INCLUDES += \
+ external/stlport/stlport/ \
+ external/libxml2/include/ \
+ external/webkit/WebCore/icu/ \
+ bionic/libstdc++ \
+ bionic/
+
+LOCAL_C_INCLUDES +=
+
+LOCAL_SHARED_LIBRARIES := libstlport libicuuc
+LOCAL_STATIC_LIBRARIES := libxml2
+
+LOCAL_LDLIBS += -Lexternal/libxml2/lib
+
+
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/xmlserializer/XML b/xmlserializer/XML
new file mode 120000
index 0000000..7f870ca
--- /dev/null
+++ b/xmlserializer/XML
@@ -0,0 +1 @@
+/home/lab/projects/qt/parameter-framework/XML \ No newline at end of file
diff --git a/xmlserializer/XmlComposer.cpp b/xmlserializer/XmlComposer.cpp
new file mode 100644
index 0000000..2cdd5dc
--- /dev/null
+++ b/xmlserializer/XmlComposer.cpp
@@ -0,0 +1,111 @@
+/* <auto_header>
+ * <FILENAME>
+ *
+ * INTEL CONFIDENTIAL
+ * Copyright © 2011 Intel
+ * Corporation All Rights Reserved.
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel’s prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ *
+ * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com)
+ * CREATED: 2011-06-01
+ * UPDATED: 2011-07-27
+ *
+ *
+ * </auto_header>
+ */
+#include "XmlComposer.h"
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <time.h>
+
+#define base CXmlSerializer
+
+#ifndef LIBXML_TREE_ENABLED
+#warning "LIBXML_TREE_ENABLED undefined. XML file exporting feature won't be supported!"
+#endif
+
+CXmlComposer::CXmlComposer(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, CXmlSerializingContext& serializingContext) :
+ base(strXmlInstanceFile, strXmlSchemaFile, strRootElementType, serializingContext)
+{
+}
+
+CXmlComposer::~CXmlComposer()
+{
+}
+
+// open / close
+bool CXmlComposer::open()
+{
+#ifdef LIBXML_TREE_ENABLED
+ // Create document from scratch
+ _pDoc = xmlNewDoc(BAD_CAST "1.0");
+
+ // Create root node
+ _pRootNode = xmlNewNode(NULL, BAD_CAST _strRootElementType.c_str());
+
+ // Assign it to document
+ xmlDocSetRootElement(_pDoc, _pRootNode);
+#else
+ _serializingContext.setError("XML file exporting feature unsupported on this image. This easiest way to activate it is to do a global recompilation with LIBXML_TREE_ENABLED compiler switch set");
+#endif
+ return base::open();
+}
+
+bool CXmlComposer::close()
+{
+ // Write file (formatted)
+ if (xmlSaveFormatFileEnc(_strXmlInstanceFile.c_str(), _pDoc, "UTF-8", 1) == -1) {
+
+ _serializingContext.setError("Could not write file " + _strXmlInstanceFile);
+
+ return false;
+ }
+
+ return base::close();
+}
+
+// Composing contents
+void CXmlComposer::compose(const IXmlSource* pXmlSource)
+{
+ // Compose document
+ CXmlElement docElement(_pRootNode);
+
+ // Schema namespace
+ docElement.setAttributeString("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
+
+ // Schema location
+ docElement.setAttributeString("xsi:noNamespaceSchemaLocation", _strXmlSchemaFile);
+
+ // Comment for date/time
+ docElement.setComment(string(" Exported on ") + getTimeAsString() + " from parameter-framework ");
+
+ pXmlSource->toXml(docElement, _serializingContext);
+}
+
+string CXmlComposer::getTimeAsString()
+{
+ char acBuf[200];
+ time_t t;
+ struct tm *tmp;
+ t = time(NULL);
+ tmp = localtime(&t);
+
+ strftime(acBuf, sizeof(acBuf), "%F, %T", tmp);
+
+ return acBuf;
+}
diff --git a/xmlserializer/XmlComposer.h b/xmlserializer/XmlComposer.h
new file mode 100644
index 0000000..2f5090f
--- /dev/null
+++ b/xmlserializer/XmlComposer.h
@@ -0,0 +1,55 @@
+/* <auto_header>
+ * <FILENAME>
+ *
+ * INTEL CONFIDENTIAL
+ * Copyright © 2011 Intel
+ * Corporation All Rights Reserved.
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel’s prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ *
+ * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com)
+ * CREATED: 2011-06-01
+ * UPDATED: 2011-07-27
+ *
+ *
+ * </auto_header>
+ */
+#pragma once
+
+#include "XmlSerializer.h"
+#include "XmlSource.h"
+
+struct _xmlDoc;
+struct _xmlNode;
+
+class CXmlComposer : public CXmlSerializer
+{
+public:
+ CXmlComposer(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, CXmlSerializingContext& serializingContext);
+ virtual ~CXmlComposer();
+
+ // open / close
+ virtual bool open();
+ virtual bool close();
+
+ // Composing contents
+ void compose(const IXmlSource* pXmlSource);
+
+private:
+ static string getTimeAsString();
+};
+
diff --git a/xmlserializer/XmlElement.cpp b/xmlserializer/XmlElement.cpp
new file mode 100644
index 0000000..cea7a1d
--- /dev/null
+++ b/xmlserializer/XmlElement.cpp
@@ -0,0 +1,235 @@
+/* <auto_header>
+ * <FILENAME>
+ *
+ * INTEL CONFIDENTIAL
+ * Copyright © 2011 Intel
+ * Corporation All Rights Reserved.
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel’s prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ *
+ * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com)
+ * CREATED: 2011-06-01
+ * UPDATED: 2011-07-27
+ *
+ *
+ * </auto_header>
+ */
+#include "XmlElement.h"
+#include <libxml/tree.h>
+#include <stdlib.h>
+
+CXmlElement::CXmlElement(_xmlNode* pXmlElement) : _pXmlElement(pXmlElement)
+{
+}
+
+CXmlElement::CXmlElement() : _pXmlElement(NULL)
+{
+}
+
+void CXmlElement::setXmlElement(_xmlNode* pXmlElement)
+{
+ _pXmlElement = pXmlElement;
+}
+
+string CXmlElement::getType() const
+{
+ return (const char*)_pXmlElement->name;
+}
+
+string CXmlElement::getPath() const
+{
+ string strPathElement = "/" + getType();
+
+ if (hasAttribute("Name")) {
+
+ strPathElement += "[@Name=" + getNameAttribute() + "]";
+ }
+
+ CXmlElement parentElement;
+
+ if (getParentElement(parentElement)) {
+
+ // Done
+ return parentElement.getPath() + strPathElement;
+ }
+ return strPathElement;
+}
+
+string CXmlElement::getNameAttribute() const
+{
+ return getAttributeString("Name");
+}
+
+bool CXmlElement::hasAttribute(const string& strAttributeName) const
+{
+ return xmlHasProp(_pXmlElement, (const xmlChar*)strAttributeName.c_str()) != NULL;
+}
+
+string CXmlElement::getAttributeString(const string &strAttributeName) const
+{
+ if (!hasAttribute(strAttributeName)) {
+
+ return "";
+ }
+ xmlChar* pucXmlValue = xmlGetProp((xmlNode*)_pXmlElement, (const xmlChar*)strAttributeName.c_str());
+
+ string strValue((const char*)pucXmlValue);
+
+ xmlFree(pucXmlValue);
+
+ return strValue;
+}
+
+bool CXmlElement::getAttributeBoolean(const string& strAttributeName, const string& strTrueValue) const
+{
+ return getAttributeString(strAttributeName) == strTrueValue;
+}
+
+bool CXmlElement::getAttributeBoolean(const string& strAttributeName) const
+{
+ string strAttributeValue(getAttributeString(strAttributeName));
+
+ return strAttributeValue == "true" || strAttributeValue == "1";
+}
+
+uint32_t CXmlElement::getAttributeInteger(const string &strAttributeName) const
+{
+ string strAttributeValue(getAttributeString(strAttributeName));
+
+ return strtoul(strAttributeValue.c_str(), NULL, 0);
+}
+
+int32_t CXmlElement::getAttributeSignedInteger(const string &strAttributeName) const
+{
+ string strAttributeValue(getAttributeString(strAttributeName));
+
+ return strtol(strAttributeValue.c_str(), NULL, 0);
+}
+
+double CXmlElement::getAttributeDouble(const string &strAttributeName) const
+{
+ string strAttributeValue(getAttributeString(strAttributeName));
+
+ return strtod(strAttributeValue.c_str(), NULL);
+}
+
+string CXmlElement::getTextContent() const
+{
+ xmlChar* pucXmlContent = xmlNodeGetContent(_pXmlElement);
+
+ string strContent((const char*)pucXmlContent);
+
+ xmlFree(pucXmlContent);
+
+ return strContent;
+}
+
+bool CXmlElement::getChildElement(const string& strType, CXmlElement& childElement) const
+{
+ CChildIterator childIterator(*this);
+
+ while (childIterator.next(childElement)) {
+
+ if (childElement.getType() == strType) {
+
+ return true;
+ }
+ }
+ return false;
+}
+
+bool CXmlElement::getChildElement(const string& strType, const string& strNameAttribute, CXmlElement& childElement) const
+{
+ CChildIterator childIterator(*this);
+
+ while (childIterator.next(childElement)) {
+
+ if ((childElement.getType() == strType) && (childElement.getNameAttribute() == strNameAttribute)) {
+
+ return true;
+ }
+ }
+ return false;
+}
+
+bool CXmlElement::getParentElement(CXmlElement& parentElement) const
+{
+ _xmlNode* pXmlNode = _pXmlElement->parent;
+
+ if (pXmlNode->type == XML_ELEMENT_NODE) {
+
+ parentElement.setXmlElement(pXmlNode);
+
+ return true;
+ }
+ return false;
+}
+
+// Setters
+void CXmlElement::setAttributeString(const string& strAttributeName, const string& strValue)
+{
+ xmlNewProp(_pXmlElement, BAD_CAST strAttributeName.c_str(), BAD_CAST strValue.c_str());
+}
+
+void CXmlElement::setNameAttribute(const string& strValue)
+{
+ setAttributeString("Name", strValue);
+}
+
+void CXmlElement::setTextContent(const string& strContent)
+{
+ xmlAddChild(_pXmlElement, xmlNewText(BAD_CAST strContent.c_str()));
+}
+
+void CXmlElement::setComment(const string& strComment)
+{
+ xmlAddChild(_pXmlElement, xmlNewComment(BAD_CAST strComment.c_str()));
+}
+
+// Child creation
+void CXmlElement::createChild(CXmlElement& childElement, const string& strType)
+{
+#ifdef LIBXML_TREE_ENABLED
+ xmlNodePtr pChildNode = xmlNewChild(_pXmlElement, NULL, BAD_CAST strType.c_str(), NULL);
+
+ childElement.setXmlElement(pChildNode);
+#endif
+}
+
+// Child iteration
+CXmlElement::CChildIterator::CChildIterator(const CXmlElement& xmlElement) : _pCurNode(xmlElement._pXmlElement->children)
+{
+}
+
+bool CXmlElement::CChildIterator::next(CXmlElement& xmlChildElement)
+{
+ while (_pCurNode) {
+
+ if (_pCurNode->type == XML_ELEMENT_NODE) {
+
+ xmlChildElement.setXmlElement(_pCurNode);
+
+ _pCurNode = _pCurNode->next;
+
+ return true;
+ }
+ _pCurNode = _pCurNode->next;
+ }
+
+ return false;
+}
+
diff --git a/xmlserializer/XmlElement.h b/xmlserializer/XmlElement.h
new file mode 100644
index 0000000..797179f
--- /dev/null
+++ b/xmlserializer/XmlElement.h
@@ -0,0 +1,93 @@
+/* <auto_header>
+ * <FILENAME>
+ *
+ * INTEL CONFIDENTIAL
+ * Copyright © 2011 Intel
+ * Corporation All Rights Reserved.
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel’s prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ *
+ * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com)
+ * CREATED: 2011-06-01
+ * UPDATED: 2011-07-27
+ *
+ *
+ * </auto_header>
+ */
+#pragma once
+
+#include <stdint.h>
+#include <string>
+
+using namespace std;
+
+struct _xmlNode;
+struct _xmlDoc;
+
+class CXmlElement
+{
+ friend class CChildIterator;
+public:
+ CXmlElement(_xmlNode* pXmlElement);
+ CXmlElement();
+
+ // Xml element
+ void setXmlElement(_xmlNode* pXmlElement);
+
+ // Getters
+ string getType() const;
+ string getPath() const;
+ string getNameAttribute() const;
+ bool hasAttribute(const string& strAttributeName) const;
+ bool getAttributeBoolean(const string& strAttributeName, const string& strTrueValue) const;
+ bool getAttributeBoolean(const string& strAttributeName) const;
+ string getAttributeString(const string& strAttributeName) const;
+ uint32_t getAttributeInteger(const string& strAttributeName) const;
+ int32_t getAttributeSignedInteger(const string& strAttributeName) const;
+ double getAttributeDouble(const string& strAttributeName) const;
+ string getTextContent() const;
+
+ // Navigation
+ bool getChildElement(const string& strType, CXmlElement& childElement) const;
+ bool getChildElement(const string& strType, const string& strNameAttribute, CXmlElement& childElement) const;
+ bool getParentElement(CXmlElement& parentElement) const;
+
+ // Setters
+ void setAttributeString(const string& strAttributeName, const string& strValue);
+ void setNameAttribute(const string& strValue);
+ void setTextContent(const string& strContent);
+ void setComment(const string& strComment);
+
+ // Child creation
+ void createChild(CXmlElement& childElement, const string& strType);
+
+public:
+ // Child iteration
+ class CChildIterator
+ {
+ public:
+ CChildIterator(const CXmlElement& xmlElement);
+
+ bool next(CXmlElement& xmlChildElement);
+ private:
+ _xmlNode* _pCurNode;
+ };
+
+private:
+ _xmlNode* _pXmlElement;
+};
+
diff --git a/xmlserializer/XmlParser.cpp b/xmlserializer/XmlParser.cpp
new file mode 100644
index 0000000..9477c0f
--- /dev/null
+++ b/xmlserializer/XmlParser.cpp
@@ -0,0 +1,162 @@
+/* <auto_header>
+ * <FILENAME>
+ *
+ * INTEL CONFIDENTIAL
+ * Copyright © 2011 Intel
+ * Corporation All Rights Reserved.
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel’s prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ *
+ * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com)
+ * CREATED: 2011-06-01
+ * UPDATED: 2011-07-27
+ *
+ *
+ * </auto_header>
+ */
+#include "XmlParser.h"
+#include <stdio.h>
+#include <stdarg.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xmlschemas.h>
+
+#define base CXmlSerializer
+
+
+CXmlParser::CXmlParser(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, CXmlSerializingContext& serializingContext) :
+ base(strXmlInstanceFile, strXmlSchemaFile, strRootElementType, serializingContext)
+{
+}
+
+CXmlParser::~CXmlParser()
+{
+}
+
+void CXmlParser::schemaValidityStructuredErrorFunc(void* pUserData, _xmlError* pError)
+{
+ (void)pUserData;
+
+#ifdef LIBXML_SCHEMAS_ENABLED
+ // Display message
+ puts(pError->message);
+#endif
+}
+
+bool CXmlParser::isInstanceDocumentValid()
+{
+#ifdef LIBXML_SCHEMAS_ENABLED
+ xmlDocPtr pSchemaDoc = xmlReadFile(_strXmlSchemaFile.c_str(), NULL, XML_PARSE_NONET);
+
+ if (!pSchemaDoc) {
+ // Unable to load Schema
+ return false;
+ }
+
+ xmlSchemaParserCtxtPtr pParserCtxt = xmlSchemaNewDocParserCtxt(pSchemaDoc);
+
+ if (!pParserCtxt) {
+
+ // Unable to create schema context
+ xmlFreeDoc(pSchemaDoc);
+ return false;
+ }
+
+ // Get Schema
+ xmlSchemaPtr pSchema = xmlSchemaParse(pParserCtxt);
+
+ if (!pSchema) {
+
+ // Invalid Schema
+ xmlSchemaFreeParserCtxt(pParserCtxt);
+ xmlFreeDoc(pSchemaDoc);
+ return false;
+ }
+ xmlSchemaValidCtxtPtr pValidationCtxt = xmlSchemaNewValidCtxt(pSchema);
+
+ if (!pValidationCtxt) {
+
+ // Unable to create validation context
+ xmlSchemaFree(pSchema);
+ xmlSchemaFreeParserCtxt(pParserCtxt);
+ xmlFreeDoc(pSchemaDoc);
+ return false;
+ }
+
+ xmlSetStructuredErrorFunc(this, schemaValidityStructuredErrorFunc);
+ //xmlSchemaSetValidErrors(pValidationCtxt, schemaValidityErrorFunc, schemaValidityWarningFunc, NULL);
+
+ bool isDocValid = xmlSchemaValidateDoc(pValidationCtxt, _pDoc) == 0;
+
+ xmlSchemaFreeValidCtxt(pValidationCtxt);
+ xmlSchemaFree(pSchema);
+ xmlSchemaFreeParserCtxt(pParserCtxt);
+ xmlFreeDoc(pSchemaDoc);
+
+ return isDocValid;
+#else
+ return true;
+#endif
+}
+
+bool CXmlParser::open()
+{
+ // Parse the file and get the DOM
+ _pDoc = xmlReadFile(_strXmlInstanceFile.c_str(), NULL, 0);
+
+ if (!_pDoc) {
+
+ _serializingContext.setError("Could not parse file " + _strXmlInstanceFile);
+
+ return false;
+ }
+ // Validate
+ if (!isInstanceDocumentValid()) {
+
+ _serializingContext.setError("Document " + _strXmlInstanceFile + " is not valid");
+
+ // Free XML doc
+ xmlFreeDoc(_pDoc);
+
+ _pDoc = NULL;
+
+ return false;
+ }
+
+ // Get the root element node
+ _pRootNode = xmlDocGetRootElement(_pDoc);
+
+ // Check Root element type
+ if (getRootElementName() != _strRootElementType) {
+
+ _serializingContext.setError("Error: Wrong XML structure file " + _strXmlInstanceFile);
+ _serializingContext.appendLineToError("Root Element " + getRootElementName() + " mismatches expected type " + _strRootElementType);
+
+ return false;
+ }
+
+ return base::open();
+}
+
+bool CXmlParser::parse(IXmlSink* pXmlSink)
+{
+ // Parse document
+ CXmlElement topMostElement(_pRootNode);
+
+ return pXmlSink->fromXml(topMostElement, _serializingContext);
+}
+
diff --git a/xmlserializer/XmlParser.h b/xmlserializer/XmlParser.h
new file mode 100644
index 0000000..4e38f56
--- /dev/null
+++ b/xmlserializer/XmlParser.h
@@ -0,0 +1,54 @@
+/* <auto_header>
+ * <FILENAME>
+ *
+ * INTEL CONFIDENTIAL
+ * Copyright © 2011 Intel
+ * Corporation All Rights Reserved.
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel’s prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ *
+ * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com)
+ * CREATED: 2011-06-01
+ * UPDATED: 2011-07-27
+ *
+ *
+ * </auto_header>
+ */
+#pragma once
+
+#include "XmlSerializer.h"
+#include "XmlSink.h"
+
+struct _xmlError;
+
+class CXmlParser : public CXmlSerializer
+{
+public:
+ CXmlParser(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, CXmlSerializingContext& serializingContext);
+ virtual ~CXmlParser();
+
+ // Parsing file
+ virtual bool open();
+
+ // Parsing contents
+ bool parse(IXmlSink* pXmlSink);
+
+private:
+ // Validity checks
+ bool isInstanceDocumentValid();
+ static void schemaValidityStructuredErrorFunc(void* pUserData, _xmlError* pError);
+};
diff --git a/xmlserializer/XmlSerializer.cpp b/xmlserializer/XmlSerializer.cpp
new file mode 100644
index 0000000..73ae90c
--- /dev/null
+++ b/xmlserializer/XmlSerializer.cpp
@@ -0,0 +1,89 @@
+/* <auto_header>
+ * <FILENAME>
+ *
+ * INTEL CONFIDENTIAL
+ * Copyright © 2011 Intel
+ * Corporation All Rights Reserved.
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel’s prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ *
+ * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com)
+ * CREATED: 2011-06-01
+ * UPDATED: 2011-07-27
+ *
+ *
+ * </auto_header>
+ */
+#include "XmlSerializer.h"
+#include <libxml/tree.h>
+#include <stdlib.h>
+
+// Schedule for libxml2 library
+bool CXmlSerializer::_bLibXml2CleanupScheduled;
+
+CXmlSerializer::CXmlSerializer(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, CXmlSerializingContext& serializingContext) :
+ _strXmlInstanceFile(strXmlInstanceFile), _strXmlSchemaFile(strXmlSchemaFile), _strRootElementType(strRootElementType), _serializingContext(serializingContext), _pDoc(NULL), _pRootNode(NULL)
+{
+ if (_bLibXml2CleanupScheduled) {
+
+ // Schedule cleanup
+ atexit(xmlCleanupParser);
+
+ _bLibXml2CleanupScheduled = true;
+ }
+}
+
+CXmlSerializer::~CXmlSerializer()
+{
+ // Free XML doc
+ xmlFreeDoc(_pDoc);
+}
+
+bool CXmlSerializer::close()
+{
+ // Free XML doc
+ xmlFreeDoc(_pDoc);
+
+ _pDoc = NULL;
+
+ return true;
+}
+
+bool CXmlSerializer::open()
+{
+ return _pDoc != NULL;
+}
+
+// Root element
+void CXmlSerializer::getRootElement(CXmlElement& xmlRootElement) const
+{
+ xmlRootElement.setXmlElement(_pRootNode);
+}
+
+string CXmlSerializer::getRootElementName() const
+{
+ return (const char*)_pRootNode->name;
+}
+
+string CXmlSerializer::getRootElementAttributeString(const string& strAttributeName) const
+{
+ CXmlElement topMostElement(_pRootNode);
+
+ return topMostElement.getAttributeString(strAttributeName);
+}
+
+
diff --git a/xmlserializer/XmlSerializer.h b/xmlserializer/XmlSerializer.h
new file mode 100644
index 0000000..9490bdf
--- /dev/null
+++ b/xmlserializer/XmlSerializer.h
@@ -0,0 +1,74 @@
+/* <auto_header>
+ * <FILENAME>
+ *
+ * INTEL CONFIDENTIAL
+ * Copyright © 2011 Intel
+ * Corporation All Rights Reserved.
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel’s prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ *
+ * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com)
+ * CREATED: 2011-06-01
+ * UPDATED: 2011-07-27
+ *
+ *
+ * </auto_header>
+ */
+#pragma once
+
+#include "XmlElement.h"
+#include "XmlSerializingContext.h"
+
+struct _xmlDoc;
+struct _xmlNode;
+
+class CXmlSerializer
+{
+public:
+ CXmlSerializer(const string& strXmlInstanceFile, const string& strXmlSchemaFile, const string& strRootElementType, CXmlSerializingContext& serializingContext);
+ virtual ~CXmlSerializer();
+
+ // Open/Close
+ virtual bool open();
+ virtual bool close();
+
+ // Root element
+ void getRootElement(CXmlElement& xmlRootElement) const;
+ string getRootElementName() const;
+ string getRootElementAttributeString(const string& strAttributeName) const;
+protected:
+ // Instance file
+ string _strXmlInstanceFile;
+
+ // Schema file
+ string _strXmlSchemaFile;
+
+ // Root element type
+ string _strRootElementType;
+
+ // Serializing context
+ CXmlSerializingContext& _serializingContext;
+
+ // XML document
+ _xmlDoc* _pDoc;
+
+ // Root node
+ _xmlNode* _pRootNode;
+
+ // libxml2 library cleanup
+ static bool _bLibXml2CleanupScheduled;
+};
diff --git a/xmlserializer/XmlSerializingContext.cpp b/xmlserializer/XmlSerializingContext.cpp
new file mode 100644
index 0000000..9ad71d8
--- /dev/null
+++ b/xmlserializer/XmlSerializingContext.cpp
@@ -0,0 +1,51 @@
+/* <auto_header>
+ * <FILENAME>
+ *
+ * INTEL CONFIDENTIAL
+ * Copyright © 2011 Intel
+ * Corporation All Rights Reserved.
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel’s prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ *
+ * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com)
+ * CREATED: 2011-06-01
+ * UPDATED: 2011-07-27
+ *
+ *
+ * </auto_header>
+ */
+#include "XmlSerializingContext.h"
+
+CXmlSerializingContext::CXmlSerializingContext(string& strError) : _strError(strError)
+{
+}
+
+// Error
+void CXmlSerializingContext::setError(const string& strError)
+{
+ _strError = strError;
+}
+
+void CXmlSerializingContext::appendLineToError(const string& strAppend)
+{
+ _strError += "\n" + strAppend;
+}
+
+const string& CXmlSerializingContext::getError() const
+{
+ return _strError;
+}
diff --git a/xmlserializer/XmlSerializingContext.h b/xmlserializer/XmlSerializingContext.h
new file mode 100644
index 0000000..c287d55
--- /dev/null
+++ b/xmlserializer/XmlSerializingContext.h
@@ -0,0 +1,49 @@
+/* <auto_header>
+ * <FILENAME>
+ *
+ * INTEL CONFIDENTIAL
+ * Copyright © 2011 Intel
+ * Corporation All Rights Reserved.
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel’s prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ *
+ * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com)
+ * CREATED: 2011-06-01
+ * UPDATED: 2011-07-27
+ *
+ *
+ * </auto_header>
+ */
+#pragma once
+
+#include <string>
+
+using namespace std;
+
+class CXmlSerializingContext
+{
+public:
+ CXmlSerializingContext(string& strError);
+
+ // Error
+ void setError(const string& strError);
+ void appendLineToError(const string& strAppend);
+ const string& getError() const;
+
+private:
+ string& _strError;
+};
diff --git a/xmlserializer/XmlSink.h b/xmlserializer/XmlSink.h
new file mode 100644
index 0000000..104dd5b
--- /dev/null
+++ b/xmlserializer/XmlSink.h
@@ -0,0 +1,40 @@
+/* <auto_header>
+ * <FILENAME>
+ *
+ * INTEL CONFIDENTIAL
+ * Copyright © 2011 Intel
+ * Corporation All Rights Reserved.
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel’s prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ *
+ * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com)
+ * CREATED: 2011-06-01
+ * UPDATED: 2011-07-27
+ *
+ *
+ * </auto_header>
+ */
+#pragma once
+
+#include "XmlElement.h"
+#include "XmlSerializingContext.h"
+
+class IXmlSink
+{
+public:
+ virtual bool fromXml(const CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) = 0;
+};
diff --git a/xmlserializer/XmlSource.h b/xmlserializer/XmlSource.h
new file mode 100644
index 0000000..b73322e
--- /dev/null
+++ b/xmlserializer/XmlSource.h
@@ -0,0 +1,40 @@
+/* <auto_header>
+ * <FILENAME>
+ *
+ * INTEL CONFIDENTIAL
+ * Copyright © 2011 Intel
+ * Corporation All Rights Reserved.
+ *
+ * The source code contained or described herein and all documents related to
+ * the source code ("Material") are owned by Intel Corporation or its suppliers
+ * or licensors. Title to the Material remains with Intel Corporation or its
+ * suppliers and licensors. The Material contains trade secrets and proprietary
+ * and confidential information of Intel or its suppliers and licensors. The
+ * Material is protected by worldwide copyright and trade secret laws and
+ * treaty provisions. No part of the Material may be used, copied, reproduced,
+ * modified, published, uploaded, posted, transmitted, distributed, or
+ * disclosed in any way without Intel’s prior express written permission.
+ *
+ * No license under any patent, copyright, trade secret or other intellectual
+ * property right is granted to or conferred upon you by disclosure or delivery
+ * of the Materials, either expressly, by implication, inducement, estoppel or
+ * otherwise. Any license under such intellectual property rights must be
+ * express and approved by Intel in writing.
+ *
+ * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com)
+ * CREATED: 2011-06-01
+ * UPDATED: 2011-07-27
+ *
+ *
+ * </auto_header>
+ */
+#pragma once
+
+#include "XmlElement.h"
+#include "XmlSerializingContext.h"
+
+class IXmlSource
+{
+public:
+ virtual void toXml(CXmlElement& xmlElement, CXmlSerializingContext& serializingContext) const = 0;
+};
diff --git a/xmlserializer/parameter b/xmlserializer/parameter
new file mode 120000
index 0000000..ad0e2c4
--- /dev/null
+++ b/xmlserializer/parameter
@@ -0,0 +1 @@
+/home/lab/projects/qt/parameter-framework/parameter \ No newline at end of file
diff --git a/xmlserializer/parameter-connector-test b/xmlserializer/parameter-connector-test
new file mode 120000
index 0000000..423f3bd
--- /dev/null
+++ b/xmlserializer/parameter-connector-test
@@ -0,0 +1 @@
+/home/lab/projects/qt/parameter-framework/parameter-connector-test \ No newline at end of file
diff --git a/xmlserializer/parameter-test b/xmlserializer/parameter-test
new file mode 120000
index 0000000..ce9f218
--- /dev/null
+++ b/xmlserializer/parameter-test
@@ -0,0 +1 @@
+/home/lab/projects/qt/parameter-framework/parameter-test \ No newline at end of file
diff --git a/xmlserializer/remote-process b/xmlserializer/remote-process
new file mode 120000
index 0000000..dc88707
--- /dev/null
+++ b/xmlserializer/remote-process
@@ -0,0 +1 @@
+/home/lab/projects/qt/parameter-framework/remote-process \ No newline at end of file
diff --git a/xmlserializer/remote-processor b/xmlserializer/remote-processor
new file mode 120000
index 0000000..d66076c
--- /dev/null
+++ b/xmlserializer/remote-processor
@@ -0,0 +1 @@
+/home/lab/projects/qt/parameter-framework/remote-processor \ No newline at end of file
diff --git a/xmlserializer/remote-processor-test b/xmlserializer/remote-processor-test
new file mode 120000
index 0000000..76384be
--- /dev/null
+++ b/xmlserializer/remote-processor-test
@@ -0,0 +1 @@
+/home/lab/projects/qt/parameter-framework/remote-processor-test \ No newline at end of file
diff --git a/xmlserializer/utility b/xmlserializer/utility
new file mode 120000
index 0000000..e87d41a
--- /dev/null
+++ b/xmlserializer/utility
@@ -0,0 +1 @@
+/home/lab/projects/qt/parameter-framework/utility \ No newline at end of file
diff --git a/xmlserializer/xmlparser-test b/xmlserializer/xmlparser-test
new file mode 120000
index 0000000..e084673
--- /dev/null
+++ b/xmlserializer/xmlparser-test
@@ -0,0 +1 @@
+/home/lab/projects/qt/parameter-framework/xmlparser-test \ No newline at end of file