Version: 9.15.0
TypeConversions.hxx
Go to the documentation of this file.
1 // Copyright (C) 2006-2025 CEA, EDF
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef _TYPECONVERSIONS_HXX_
21 #define _TYPECONVERSIONS_HXX_
22 
24 
25 #define PY_SSIZE_T_CLEAN
26 
27 #include <Python.h>
28 #include <omniORB4/CORBA.h>
29 #include <libxml/parser.h>
30 #include <string>
31 
32 #if PY_VERSION_HEX < 0x03050000
33 static char*
34 Py_EncodeLocale(const wchar_t *arg, size_t *size)
35 {
36  return _Py_wchar2char(arg, size);
37 }
38 static wchar_t*
39 Py_DecodeLocale(const char *arg, size_t *size)
40 {
41  return _Py_char2wchar(arg, size);
42 }
43 #endif
44 
45 namespace YACS
46 {
47  namespace ENGINE
48  {
49 
50  typedef enum
51  {
52  CORBAImpl = 1,
55  XMLImpl = 4,
56  CPPImpl = 5,
57  } ImplType;
58 
59  class TypeCode;
60  class Any;
61 
62  YACSRUNTIMESALOME_EXPORT CORBA::TypeCode_ptr getCorbaTC(const TypeCode *t);
63 
64  YACSRUNTIMESALOME_EXPORT int isAdaptableCorbaPyObject(const TypeCode * t1, const TypeCode * t2);
65  YACSRUNTIMESALOME_EXPORT int isAdaptableCorbaNeutral(const TypeCode * t1, const TypeCode * t2);
66  YACSRUNTIMESALOME_EXPORT int isAdaptableCorbaCorba(const TypeCode * t1, const TypeCode * t2);
67 
68  YACSRUNTIMESALOME_EXPORT int isAdaptableNeutralCorba(const TypeCode * t1, const TypeCode * t2);
69  YACSRUNTIMESALOME_EXPORT int isAdaptableNeutralNeutral(const TypeCode * t1, const TypeCode * t2);
70  YACSRUNTIMESALOME_EXPORT int isAdaptableNeutralXml(const TypeCode * t1, const TypeCode * t2);
71  YACSRUNTIMESALOME_EXPORT int isAdaptableNeutralPyObject(const TypeCode * t1, const TypeCode * t2);
72 
73  YACSRUNTIMESALOME_EXPORT int isAdaptablePyObjectPyObject(const TypeCode * t1, const TypeCode * t2);
74  YACSRUNTIMESALOME_EXPORT int isAdaptablePyObjectCorba(const TypeCode * t1, const TypeCode * t2);
75  YACSRUNTIMESALOME_EXPORT int isAdaptablePyObjectNeutral(const TypeCode * t1, const TypeCode * t2);
76 
77  YACSRUNTIMESALOME_EXPORT int isAdaptableXmlNeutral(const TypeCode *t1,const TypeCode *t2);
78  YACSRUNTIMESALOME_EXPORT int isAdaptableXmlCorba(const TypeCode *t1, const TypeCode *t2);
79 
80  YACSRUNTIMESALOME_EXPORT PyObject *convertCorbaPyObject(const TypeCode * t,CORBA::Any* ob);
81  YACSRUNTIMESALOME_EXPORT PyObject *convertCorbaPyObject(const TypeCode * t,CORBA::Any* ob);
82  YACSRUNTIMESALOME_EXPORT PyObject *convertCorbaPyObject(const TypeCode * t,CORBA::Any* ob);
83  YACSRUNTIMESALOME_EXPORT CORBA::Any *convertCorbaCorba(const TypeCode * t,CORBA::Any* ob);
84  YACSRUNTIMESALOME_EXPORT YACS::ENGINE::Any *convertCorbaNeutral(const TypeCode *t,CORBA::Any* ob);
85  YACSRUNTIMESALOME_EXPORT std::string convertCorbaXml(const TypeCode * t,CORBA::Any* ob);
86 
87  YACSRUNTIMESALOME_EXPORT CORBA::Any *convertPyObjectCorba(const TypeCode *t,PyObject *ob);
88  YACSRUNTIMESALOME_EXPORT std::string convertPyObjectXml(const TypeCode * t,PyObject* ob);
90  YACSRUNTIMESALOME_EXPORT PyObject* convertPyObjectPyObject(const TypeCode *t,PyObject *ob);
91  YACSRUNTIMESALOME_EXPORT std::string convertPyObjectToString(PyObject* ob);
92  YACSRUNTIMESALOME_EXPORT bool checkPyObject(const TypeCode *t,PyObject* ob);
93 
94  YACSRUNTIMESALOME_EXPORT PyObject *convertXmlPyObject(const TypeCode * t,xmlDocPtr doc,xmlNodePtr cur );
95  YACSRUNTIMESALOME_EXPORT PyObject *convertXmlStrPyObject(const TypeCode * t,std::string data );
96  YACSRUNTIMESALOME_EXPORT CORBA::Any *convertXmlCorba(const TypeCode * t,xmlDocPtr doc,xmlNodePtr cur );
97  YACSRUNTIMESALOME_EXPORT YACS::ENGINE::Any *convertXmlNeutral(const TypeCode * t,xmlDocPtr doc,xmlNodePtr cur );
98 
100  YACSRUNTIMESALOME_EXPORT std::string convertNeutralXml(const TypeCode * t,YACS::ENGINE::Any* ob);
101  YACSRUNTIMESALOME_EXPORT CORBA::Any *convertNeutralCorba(const TypeCode *t,YACS::ENGINE::Any *ob);
103  }
104 
105 }
106 
107 #endif
static wchar_t * Py_DecodeLocale(const char *arg, size_t *size)
static char * Py_EncodeLocale(const wchar_t *arg, size_t *size)
#define YACSRUNTIMESALOME_EXPORT
: Interface for management of storage of data formated dynamically in its TypeCode....
Definition: Any.hxx:79
static char doc[]
Definition: driver.cxx:63
int isAdaptableNeutralNeutral(const TypeCode *t1, const TypeCode *t2)
PyObject * convertXmlStrPyObject(const TypeCode *t, std::string data)
CORBA::Any * convertPyObjectCorba(const TypeCode *t, PyObject *data)
int isAdaptableNeutralPyObject(const TypeCode *t1, const TypeCode *t2)
CORBA::Any * convertCorbaCorba(const TypeCode *t, CORBA::Any *data)
std::string convertPyObjectToString(PyObject *ob)
int isAdaptableCorbaCorba(const TypeCode *t1, const TypeCode *t2)
PyObject * convertPyObjectPyObject(const TypeCode *t, PyObject *data)
YACS::ENGINE::Any * convertCorbaNeutral(const TypeCode *t, CORBA::Any *data)
int isAdaptableCorbaNeutral(const TypeCode *t1, const TypeCode *t2)
std::string convertPyObjectXml(const TypeCode *t, PyObject *data)
PyObject * convertXmlPyObject(const TypeCode *t, xmlDocPtr doc, xmlNodePtr cur)
CORBA::Any * convertXmlCorba(const TypeCode *t, xmlDocPtr doc, xmlNodePtr cur)
int isAdaptablePyObjectCorba(const TypeCode *t1, const TypeCode *t2)
int isAdaptablePyObjectPyObject(const TypeCode *t1, const TypeCode *t2)
int isAdaptableCorbaPyObject(const TypeCode *t1, const TypeCode *t2)
YACS::ENGINE::Any * convertNeutralNeutral(const TypeCode *t, YACS::ENGINE::Any *data)
CORBA::TypeCode_ptr getCorbaTC(const TypeCode *t)
PyObject * convertNeutralPyObject(const TypeCode *t, YACS::ENGINE::Any *data)
int isAdaptableXmlCorba(const TypeCode *t1, const TypeCode *t2)
YACS::ENGINE::Any * convertPyObjectNeutral(const TypeCode *t, PyObject *data)
std::string convertNeutralXml(const TypeCode *t, YACS::ENGINE::Any *data)
int isAdaptableXmlNeutral(const TypeCode *t1, const TypeCode *t2)
PyObject * convertCorbaPyObject(const TypeCode *t, CORBA::Any *data)
int isAdaptableNeutralXml(const TypeCode *t1, const TypeCode *t2)
YACS::ENGINE::Any * convertXmlNeutral(const TypeCode *t, xmlDocPtr doc, xmlNodePtr cur)
int isAdaptableNeutralCorba(const TypeCode *t1, const TypeCode *t2)
int isAdaptablePyObjectNeutral(const TypeCode *t1, const TypeCode *t2)
bool checkPyObject(const TypeCode *t, PyObject *ob)
CORBA::Any * convertNeutralCorba(const TypeCode *t, YACS::ENGINE::Any *data)
std::string convertCorbaXml(const TypeCode *t, CORBA::Any *data)
static std::string t1[]
static std::string t2[]