add string case

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7339 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2005-07-19 17:33:00 +00:00
commit a923a51bd6
2 changed files with 13 additions and 0 deletions

View file

@ -1,5 +1,6 @@
%module li_std_vector %module li_std_vector
%include "std_string.i"
%include "std_vector.i" %include "std_vector.i"
%include "cpointer.i" %include "cpointer.i"
%include "carrays.i" %include "carrays.i"
@ -14,6 +15,7 @@ namespace std {
%template() vector<short>; %template() vector<short>;
%template(IntVector) vector<int>; %template(IntVector) vector<int>;
%template(BoolVector) vector<bool>; %template(BoolVector) vector<bool>;
%template() vector<string>;
} }
%template(DoubleVector) std::vector<double>; %template(DoubleVector) std::vector<double>;
@ -107,6 +109,12 @@ std::vector<short> halfs(const std::vector<short>& v) {
return w; return w;
} }
std::vector<std::string> vecStr(std::vector<std::string> v) {
v[0] += v[1];
return v;
}
%} %}
%template(VecB) std::vector<Test::B>; %template(VecB) std::vector<Test::B>;
%template(VecA) std::vector<Test::A*>; %template(VecA) std::vector<Test::A*>;

View file

@ -89,3 +89,8 @@ if v.size() != 0:
raise RuntimeError,"bad getslice" raise RuntimeError,"bad getslice"
v = vecStr(["hello ", "world"])
if v[0] != 'hello world':
raise RuntimeError,"bad std::string+std::vector"