/tags/rel-1.3.35/Examples/test-suite/python/std_containers.i
Swig | 199 lines | 153 code | 46 blank | 0 comment | 0 complexity | a19f4c6057b14f3c89d3dfac15ac1b6c MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
1%module std_containers
2
3%{
4#include <set>
5%}
6%include std_vector.i
7%include std_string.i
8%include std_deque.i
9%include std_list.i
10%include std_set.i
11%include std_multiset.i
12%include std_pair.i
13%include std_map.i
14%include std_multimap.i
15%include std_complex.i
16
17%template() std::vector<double>;
18%template() std::pair<std::string, int>;
19%template() std::pair<int,double>;
20
21%template() std::vector< std::vector<double > > ;
22%template(ccube) std::vector< std::vector< std::vector<double > > >;
23
24%inline
25{
26 typedef
27 std::vector<std::vector<std::vector<double > > >
28 ccube;
29
30 ccube cident(const ccube& c)
31 {
32 return c;
33 }
34
35 struct C
36 {
37 };
38}
39
40
41%template(map_si) std::map<std::string, int>;
42%template(pair_iC) std::pair<int, C*>;
43%template(map_iC) std::map<int, C*>;
44%template(mmap_si) std::multimap<std::string, int>;
45%template(set_i) std::set<int>;
46%template(multiset_i) std::multiset<int>;
47%template(list_i) std::list<int>;
48%template(deque_i) std::deque<int>;
49
50%template(vector_b) std::vector<bool>;
51%template(vector_i) std::vector<int>;
52%template(vector_c) std::vector<std::complex<double> >;
53%template(vector_ui) std::vector<unsigned int>;
54
55%template(bmatrix) std::vector<std::vector<bool> >;
56%template(imatrix) std::vector<std::vector<int> >;
57%template(cmatrix) std::vector<std::vector<std::complex<double> > >;
58
59%apply std::vector<int> *INOUT {std::vector<int> *INOUT2};
60
61%inline
62{
63 typedef std::vector<std::vector<int> > imatrix;
64 imatrix midenti(const imatrix& v)
65 {
66 return v;
67 }
68
69 typedef std::vector<std::vector<bool> > bmatrix;
70 bmatrix midentb(const bmatrix& v)
71 {
72 return v;
73 }
74
75 std::map<int,C*> mapidentc(const std::map<int,C*>& v)
76 {
77 return v;
78 }
79
80 std::map<int,int> mapidenti(const std::map<int,int>& v)
81 {
82 return v;
83 }
84
85 std::map<std::string,int> mapident(const std::map<std::string,int>& v)
86 {
87 return v;
88 }
89
90 std::multimap<std::string,int> mapident(const std::multimap<std::string,int>& v)
91 {
92 return v;
93 }
94
95 std::vector<int> vident(const std::vector<int>& v)
96 {
97 return v;
98 }
99
100 std::set<int> sident(const std::set<int>& v)
101 {
102 return v;
103 }
104
105 std::vector<unsigned int> videntu(const std::vector<unsigned int>& v)
106 {
107 return v;
108 }
109
110
111 int get_elem(const std::vector<int>& v, int index)
112 {
113 return v[index];
114 }
115
116 std::pair<int,double> pident(const std::pair<int,double>& p)
117 {
118 return p;
119 }
120
121 void
122 v_inout(std::vector<int> *INOUT) {
123 *INOUT = *INOUT;
124 }
125
126 void
127 v_inout2(std::vector<int> *INOUT, std::vector<int> *INOUT2) {
128 std::swap(*INOUT, *INOUT2);
129 }
130
131}
132
133
134%{
135
136 template <class C> struct Param
137 {
138 };
139%}
140
141
142template <class C> struct Param
143{
144};
145
146
147%template(Param_c) Param<std::complex<double> >;
148%inline
149{
150 int hello(Param<std::complex<double> > c)
151 {
152 return 0;
153 }
154}
155
156%inline
157{
158 struct A
159 {
160 A(int aa = 0) : a(aa)
161 {
162 }
163 int a;
164 };
165}
166
167%template() std::pair<A,int>;
168%template(pair_iA) std::pair<int,A>;
169%template(vector_piA) std::vector<std::pair<int,A> >;
170
171
172%inline {
173 std::pair<A,int> ident(std::pair<int,A> a, const std::pair<int,int>& b)
174 {
175 return std::pair<A,int>();
176 }
177
178
179 std::vector<std::pair<int,A> > pia_vident(std::vector<std::pair<int,A> > a )
180 {
181 return a;
182 }
183
184 struct Foo
185 {
186 Foo(int i) {
187 }
188 };
189
190}
191
192
193%std_nodefconst_type(Foo);
194
195%template(vector_Foo) std::vector<Foo>;
196%template(deque_Foo) std::deque<Foo>;
197%template(list_Foo) std::list<Foo>;
198
199