-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2016 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
return ret;
}
+PyObject *convertVecPairIntToPy(const std::vector< std::pair<int,int> >& vec)
+{
+ PyObject *ret(PyList_New(vec.size()));
+ int rk=0;
+ for(std::vector< std::pair<int,int> >::const_iterator iter=vec.begin();iter!=vec.end();iter++,rk++)
+ {
+ PyObject *elt=PyTuple_New(2);
+ PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
+ PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
+ PyList_SetItem(ret,rk,elt);
+ }
+ return ret;
+}
+
PyObject *convertVecPairVecStToPy(const std::vector< std::pair<std::vector<std::string>, std::string > >& vec)
{
int sz=(int)vec.size();
else
throw INTERP_KERNEL::Exception("MEDFileFields::__getitem__ : only integer or string with fieldname supported !");
}
+
+void convertToMapIntDataArrayInt(PyObject *pyMap, std::map<int, MCAuto<DataArrayInt> >& cppMap)
+{
+ if(!PyDict_Check(pyMap))
+ throw INTERP_KERNEL::Exception("convertToMapIntDataArrayInt : input is not a python map !");
+ PyObject *key, *value;
+ Py_ssize_t pos(0);
+ cppMap.clear();
+ while (PyDict_Next(pyMap,&pos,&key,&value))
+ {
+ if(!PyInt_Check(key))
+ throw INTERP_KERNEL::Exception("convertToMapIntDataArrayInt : keys in map must be PyInt !");
+ long k(PyInt_AS_LONG(key));
+ void *argp(0);
+ int status(SWIG_ConvertPtr(value,&argp,SWIGTYPE_p_MEDCoupling__DataArrayInt,0|0));
+ if(!SWIG_IsOK(status))
+ {
+ std::ostringstream oss; oss << "convertToMapIntDataArrayInt : values in map must be DataArrayInt !";
+ throw INTERP_KERNEL::Exception(oss.str().c_str());
+ }
+ DataArrayInt *arg(reinterpret_cast<DataArrayInt*>(argp));
+ MCAuto<DataArrayInt> arg2(arg);
+ if(arg)
+ arg->incrRef();
+ cppMap[k]=arg2;
+ }
+}
+