Support for std::string and const std::string &
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5105 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
542dd1c9d6
commit
964f56d0d9
1 changed files with 60 additions and 0 deletions
60
SWIG/Lib/csharp/std_string.i
Normal file
60
SWIG/Lib/csharp/std_string.i
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
//
|
||||
// SWIG typemaps for std::string
|
||||
// William Fulton
|
||||
//
|
||||
// C# implementation
|
||||
//
|
||||
/* ------------------------------------------------------------------------
|
||||
Typemaps for std::string and const std::string&
|
||||
These are mapped to a C# String and are passed around by value.
|
||||
|
||||
To use non-const std::string references use the following %apply. Note
|
||||
that they are passed by value.
|
||||
%apply const std::string & {std::string &};
|
||||
------------------------------------------------------------------------ */
|
||||
|
||||
%{
|
||||
#include <string>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
|
||||
class string;
|
||||
|
||||
// string
|
||||
%typemap(ctype) string "char *"
|
||||
%typemap(imtype) string "string"
|
||||
%typemap(cstype) string "string"
|
||||
|
||||
%typemap(in) string
|
||||
%{ if (!$input) SWIG_CSharpThrowException(SWIG_CSharpNullReferenceException, "null string");
|
||||
$1 = std::string($input); %}
|
||||
%typemap(out) string %{ $result = SWIG_csharp_string_callback($1.c_str()); %}
|
||||
|
||||
%typemap(csin) string "$csinput"
|
||||
%typemap(csout) string {
|
||||
return $imcall;
|
||||
}
|
||||
|
||||
%typemap(typecheck) string = char *;
|
||||
|
||||
// const string &
|
||||
%typemap(ctype) const string & "char *"
|
||||
%typemap(imtype) const string & "string"
|
||||
%typemap(cstype) const string & "string"
|
||||
|
||||
%typemap(in) const string &
|
||||
%{ if (!$input) SWIG_CSharpThrowException(SWIG_CSharpNullReferenceException, "null string");
|
||||
$1 = new std::string($input); %}
|
||||
%typemap(out) const string & %{ $result = SWIG_csharp_string_callback($1->c_str()); %}
|
||||
%typemap(freearg) const string & %{ delete $1; %}
|
||||
|
||||
%typemap(csin) const string & "$csinput"
|
||||
%typemap(csout) const string & {
|
||||
return $imcall;
|
||||
}
|
||||
|
||||
%typemap(typecheck) const string & = char *;
|
||||
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue