Reputation: 11
I have a C++ method that returns a std::string. I am using SWIG and I want to add logic to SWIG to make the std::string that is returned, be received in Java as a byte[].
If this is possible, how can I do this?
Thanks
Upvotes: 1
Views: 1212
Reputation: 177765
SWIG comes with pre-written interface files for many C++ constructs. The are found in SWIG's Lib directory for many languages, including Java.
Add %include <std_string.i>
in your SWIG interface file. Check SWIG's Lib/Java directory for support for other constructs as well.
Upvotes: 2
Reputation: 13160
std::string has a member function c_str that does essentially that. It would probably make sense to write a wrapper function that calls your function and returns the corresponding c string.
Upvotes: 0