I used SWIG to wrap my c++ class. Some methods have a const std::string&
as a parameter. SWIG creates a type called SWIGTYPE_p_std__string
however you cannot just pass a normal string for this when invoking the method in c#. The below example is just a modified example that comes with the SWIG package.:
public void setName(SWIGTYPE_p_std__string name)
{
examplePINVOKE.Shape_setName(swigCPtr, SWIGTYPE_p_std__string.getCPtr(name));
if (examplePINVOKE.SWIGPendingException.Pending) throw examplePINVOKE.SWIGPendingException.Retrieve();
}
In my interface file I just have:
/* File : example.i */
%module example
%{
#include "example.h"
%}
/* Let's just grab the original header file here */
%include "example.h"
And the method that is being wrapped in C++ is:
void Shape::setName(const std::string& name)
{
mName = name;
}
Is there some sort of typemap I have to put in the interface file? If so, how do I do that?