1 // Copyright (C) 2007-2013 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
23 %template() std::set<int>;
25 // Creates "int *argc, char ***argv" parameters from input list
26 %typemap(in) (int *argc, char ***argv) {
28 if (!PyList_Check($input)) {
29 PyErr_SetString(PyExc_ValueError, "Expecting a list");
32 int aSize = PyList_Size($input);
34 char** aStrs = (char **) malloc((aSize+1)*sizeof(char *));
35 for (i = 0; i < aSize; i++) {
36 PyObject *s = PyList_GetItem($input,i);
37 if (!PyString_Check(s)) {
39 PyErr_SetString(PyExc_ValueError, "List items must be strings");
42 aStrs[i] = PyString_AsString(s);
48 %typemap(freearg) (int *argc, char ***argv) {
52 /* MACRO: IN typemap for std::set<TYPE> C++ object */
53 %define TYPEMAP_INPUT_SET_BY_VALUE( TYPE )
55 /* typemap in for set<TYPE> */
56 /* Check if is a list */
57 if (PyList_Check($input))
59 int size = PyList_Size($input);
60 std::set< TYPE > tmpSet;
62 for (int i=0; i < size; i++)
64 PyObject * tmp = PyList_GetItem($input,i);
65 TYPE elem = PyInt_AsLong(tmp);
72 PyErr_SetString(PyExc_TypeError,"not a list");
78 %typemap(in) std::set<int>
80 TYPEMAP_INPUT_SET_BY_VALUE( int )
82 %typecheck(SWIG_TYPECHECK_POINTER) std::set<int> {
83 $1 = PyList_Check($input) ? 1 : 0;