Reputation: 41
I have been looking around at the relevant questions and i cannot get rid of the swig pointer.
Basically i have a simple structure
typedef struct mbuf{
int date
int time
}
and within my class i define a vector of vectors
class Profile {
private:
std::vector<std::vector<mbuf> > mbufArray;
std::vector<std::vector<mbuf> > getMbufArray() const {
return mbufArray;
}
void setMbufArray(std::vector<std::vector<mbuf> > mbufArray) {
this->mbufArray = mbufArray;
}
}
the get and set function have been auto generated for me. I have generated out the swig java class using the information from other questions
%{
define SWIG_JAVA_EXTRA_NATIVE_CONTAINERS
%}
%include "std_vector.i"
%{
include <vector>
%}
%template(ProfileVector) std::vector<std::vector<mbuf> >;
%typemap(out) std::vector<std::vector<mbuf> >::value_type {
$result = SWIG_NewPointerObj(SWIG_as_voidptr(&$1), $descriptor(std::vector<mbuf>), 0 | 0 );
}
%typemap(out) std::vector<std::vector<mbuf> >::value_type & {
$result = SWIG_NewPointerObj(SWIG_as_voidptr($1), $descriptor(std::vector<mbuf>), 0 | 0 );
}
My problem is i still receive a SWIGTYPE_p_std__vectorT_mbuf_t for my set and get types, i could create function that give me the elements but what i really need is more natural access to the vector elements in java.
Any help would be much appreciated.
Upvotes: 2
Views: 1300
Reputation: 41
Ok i figured it out i was missing a typedef for the actual vector.
I now have acces to the mbuf type by adding the line to my .i file
%template(ProfileVector) std::vector<mbuf>;
%template(VectorProfileVector) std::vector<std::vector<mbuf> >;
Upvotes: 1