logo       

How to return a std::vector of pointers to Java?: msg#00142

programming.swig

Subject: How to return a std::vector of pointers to Java?

Hi, I'm just getting started with SWIG as a Java to C++ bridge. I need to return a std::vector of pointers from C++ to Java and I'm stuck; the code below works beautifully, I just need to convert the values to pointers.

namespace std {
%template(VectorOfClassA) vector<ClassA>;
};

class ClassA{
public:
int amember;
};

class ClassB{
public:
// this is handled fine; why not in vectors?
ClassA* createClassA();

// this works too but I want to avoid creating new objects
// via the copy c'tor when adding to the vector.
vector<ClassA> getClassAVector();
};

Can anybody help me change all of "vector<ClassA>" to "vector<ClassA*>", which I guess may need a new or improved typemap. Using the current std_vector.i typemap with the pointers generates a "VectorOfClassA.java" with a get() method that returns a "SWIGTYPE_p_p_ClassA" - I want it to return a "ClassA".

Thanks for any advice.
Henrietta

_________________________________________________________________
Express yourself with cool new emoticons http://www.msn.co.uk/specials/myemo

_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise