1 // Copyright (C) 2006-2008 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.
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
19 #include "TypeConversions.hxx"
20 #include "XMLCppConv.hxx"
23 #include <libxml/parser.h>
29 #include "YacsTrace.hxx"
37 Any * convertXmlCpp(const TypeCode *t, xmlDocPtr doc, xmlNodePtr cur)
39 return convertXmlNeutral(t, doc, cur);
42 XmlCpp::XmlCpp(InputPort* p)
43 : ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
47 void XmlCpp::put(const void *data) throw(ConversionException)
49 DEBTRACE(" XmlCpp::put(const void *data)");
50 put((const char *)data);
53 //!Convert received XML (char *) value to C++ (Any *) value and send it to proxy port
55 * \param data : Xml::char *
58 void XmlCpp::put(const char *data) throw(ConversionException)
60 DEBTRACE("XmlCpp::put " << data);
65 doc = xmlParseMemory(data, strlen(data));
69 msg << "Problem in conversion: XML Document not parsed successfully ";
70 msg << " (" << __FILE__ << ":" << __LINE__ << ")";
71 throw ConversionException(msg.str());
73 cur = xmlDocGetRootElement(doc);
78 msg << "Problem in conversion: empty XML Document";
79 msg << " (" << __FILE__ << ":" << __LINE__ << ")";
80 throw ConversionException(msg.str());
84 if ((!xmlStrcmp(cur->name, (const xmlChar *)"value")))
86 ob=convertXmlCpp(edGetType(),doc,cur);
95 msg << "Problem in conversion: incorrect XML value";
96 msg << " (" << __FILE__ << ":" << __LINE__ << ")";
97 throw ConversionException(msg.str());
104 int isAdaptableCppXml(const TypeCode *t1, const TypeCode *t2)
106 return isAdaptableNeutralXml(t1, t2);