31
31
32
32
typedef QMultiMap<int, QgsServerFilter*> QgsServerFiltersMap;
33
33
34
+
35
+
36
+ template<int, TYPE2*>
37
+ %MappedType QMultiMap<int, TYPE2*>
38
+ {
39
+ %TypeHeaderCode
40
+ #include <QMultiMap>
41
+ %End
42
+
43
+ %ConvertFromTypeCode
44
+ // Create the dictionary.
45
+ PyObject *d = PyDict_New();
46
+
47
+ if (!d)
48
+ return NULL;
49
+
50
+ // Set the dictionary elements.
51
+ QMultiMap<int, TYPE2*>::iterator i = sipCpp->begin();
52
+
53
+ while (i != sipCpp->end())
54
+ {
55
+
56
+ const int t1 = i.key();
57
+ TYPE2 * t2 = i.value();
58
+ PyObject *t1obj = PyInt_FromSize_t(t1);
59
+ PyObject *t2obj = sipConvertFromType(t2, sipType_TYPE2, sipTransferObj);
60
+ ///////PyObject *t2obj = sipConvertFromNewType(t2, sipType_TYPE2, sipTransferObj);
61
+ if (PyDict_GetItem(d, t1obj) == NULL) {
62
+ PyObject *lst = PyList_New(0);
63
+ PyDict_SetItem(d, t1obj, lst);
64
+ if (lst)
65
+ {
66
+ Py_DECREF(lst);
67
+ }
68
+ }
69
+
70
+ if (t1obj == NULL || t2obj == NULL ||
71
+ PyList_Append(PyDict_GetItem(d, t1obj), t2obj) < 0)
72
+ {
73
+ Py_DECREF(d);
74
+ if (t1obj)
75
+ {
76
+ Py_DECREF(t1obj);
77
+ }
78
+
79
+ if (t2obj)
80
+ {
81
+ Py_DECREF(t2obj);
82
+ }
83
+
84
+ return NULL;
85
+ }
86
+ Py_DECREF(t1obj);
87
+ Py_DECREF(t2obj);
88
+
89
+ ++i;
90
+ }
91
+
92
+ return d;
93
+ %End
94
+
95
+ %ConvertToTypeCode
96
+ PyObject *t1obj, *t2obj;
97
+ #if PY_VERSION_HEX >= 0x02050000
98
+ Py_ssize_t i = 0;
99
+ #else
100
+ int i = 0;
101
+ #endif
102
+
103
+ // Check the type if that is all that is required.
104
+ if (sipIsErr == NULL)
105
+ {
106
+ if (!PyDict_Check(sipPy))
107
+ return 0;
108
+
109
+ while (PyDict_Next(sipPy, &i, &t1obj, &t2obj))
110
+ {
111
+ for (int i = 0; i < PyList_GET_SIZE(t2obj); ++i) {
112
+ if (!sipCanConvertToType(PyList_GET_ITEM(t2obj, i),
113
+ sipType_TYPE2, SIP_NOT_NONE))
114
+ return 0;
115
+ }
116
+ }
117
+
118
+ return 1;
119
+ }
120
+
121
+ QMultiMap<int, TYPE2*> *qm = new QMultiMap<int, TYPE2*>;
122
+ while (PyDict_Next(sipPy, &i, &t1obj, &t2obj))
123
+ {
124
+ int state2;
125
+ int k = (int) PyInt_AsLong(t1obj);
126
+ for (int i = 0; i < PyList_GET_SIZE(t2obj); ++i) {
127
+ TYPE2 *t2 =
128
+ reinterpret_cast<TYPE2 *>(sipConvertToType(PyList_GET_ITEM(t2obj, i),
129
+ sipType_TYPE2,
130
+ sipTransferObj,
131
+ SIP_NOT_NONE,
132
+ &state2,
133
+ sipIsErr));
134
+
135
+ if (*sipIsErr)
136
+ {
137
+ sipReleaseType(t2, sipType_TYPE2, state2);
138
+
139
+ delete qm;
140
+ return 0;
141
+ }
142
+
143
+ qm->insert(k, t2);
144
+
145
+ sipReleaseType(t2, sipType_TYPE2, state2);
146
+ }
147
+ }
148
+
149
+ *sipCppPtr = qm;
150
+
151
+ return sipGetState(sipTransferObj);
152
+ %End
153
+ };
154
+
155
+
156
+
157
+
34
158
class QgsServerInterface
35
159
{
36
160
%TypeHeaderCode
@@ -50,7 +174,7 @@ class QgsServerInterface
50
174
virtual QString getEnv(const QString& name ) const = 0;
51
175
// Commented because of problems with typedef QgsServerFiltersMap, provided
52
176
// methods to alter the filters map into QgsRequestHandler API
53
- // virtual QgsServerFiltersMap filters( ) = 0;
177
+ virtual QgsServerFiltersMap filters( ) = 0;
54
178
/** Returns the configFilePath as seen by the server, this value is only
55
179
* available after requestReady has been called.*/
56
180
virtual QString configFilePath( ) = 0;
0 commit comments