1 // Copyright (C) 2007-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
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))
38 aStrs[i] = PyString_AsString(s);
39 %#if PY_VERSION_HEX >= 0x03000000
40 else if (PyUnicode_Check(s))
41 aStrs[i] = PyUnicode_AsUTF8(s);
45 PyErr_SetString(PyExc_ValueError, "List items must be strings");
53 %typemap(freearg) (int *argc, char ***argv) {
57 /* MACRO: IN typemap for std::set<TYPE> C++ object */
58 %define TYPEMAP_INPUT_SET_BY_VALUE( TYPE )
60 /* typemap in for set<TYPE> */
61 /* Check if is a list */
62 if (PyList_Check($input))
64 int size = PyList_Size($input);
65 std::set< TYPE > tmpSet;
67 for (int i=0; i < size; i++)
69 PyObject * tmp = PyList_GetItem($input,i);
70 TYPE elem = PyInt_AsLong(tmp);
77 PyErr_SetString(PyExc_TypeError,"not a list");
83 %typemap(in) std::set<int>
85 TYPEMAP_INPUT_SET_BY_VALUE( int )
87 %typecheck(SWIG_TYPECHECK_POINTER) std::set<int> {
88 $1 = PyList_Check($input) ? 1 : 0;