1 // Copyright (C) 2006-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "TypeConversions.hxx"
21 #include "XMLCppConv.hxx"
24 #include <libxml/parser.h>
30 #include "YacsTrace.hxx"
38 Any * convertXmlCpp(const TypeCode *t, xmlDocPtr doc, xmlNodePtr cur)
40 return convertXmlNeutral(t, doc, cur);
43 XmlCpp::XmlCpp(InputPort* p)
44 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
48 void XmlCpp::put(const void *data) throw(ConversionException)
50 DEBTRACE(" XmlCpp::put(const void *data)");
51 put((const char *)data);
54 //!Convert received XML (char *) value to C++ (Any *) value and send it to proxy port
56 * \param data : Xml::char *
59 void XmlCpp::put(const char *data) throw(ConversionException)
61 DEBTRACE("XmlCpp::put " << data);
66 doc = xmlParseMemory(data, strlen(data));
70 msg << "Problem in conversion: XML Document not parsed successfully ";
71 msg << " (" << __FILE__ << ":" << __LINE__ << ")";
72 throw ConversionException(msg.str());
74 cur = xmlDocGetRootElement(doc);
79 msg << "Problem in conversion: empty XML Document";
80 msg << " (" << __FILE__ << ":" << __LINE__ << ")";
81 throw ConversionException(msg.str());
85 if ((!xmlStrcmp(cur->name, (const xmlChar *)"value")))
87 ob=convertXmlCpp(edGetType(),doc,cur);
96 msg << "Problem in conversion: incorrect XML value";
97 msg << " (" << __FILE__ << ":" << __LINE__ << ")";
98 throw ConversionException(msg.str());
105 int isAdaptableCppXml(const TypeCode *t1, const TypeCode *t2)
107 return isAdaptableNeutralXml(t1, t2);