1/* -----------------------------------------------------------------------------
2 * See the LICENSE file for information on copyright, usage and redistribution
3 * of SWIG, and the README file for authors - http://www.swig.org/release.html.
4 *
5 * std_string.i
6 *
7 * Typemaps for std::string and const std::string&
8 * These are mapped to a C# String and are passed around by value.
9 *
10 * To use non-const std::string references use the following %apply.  Note
11 * that they are passed by value.
12 * %apply const std::string & {std::string &};
13 * ----------------------------------------------------------------------------- */
14
15%{
16#include <string>
17%}
18
19namespace std {
20
21%naturalvar string;
22
23class string;
24
25// string
26%typemap(ctype) string "char *"
27%typemap(imtype) string "string"
28%typemap(cstype) string "string"
29
30%typemap(csdirectorin) string "$iminput"
31%typemap(csdirectorout) string "$cscall"
32
33%typemap(in, canthrow=1) string
34%{ if (!$input) {
35    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
36    return $null;
37   }
38   $1.assign($input); %}
39%typemap(out) string %{ $result = SWIG_csharp_string_callback($1.c_str()); %}
40
41%typemap(directorout, canthrow=1) string
42%{ if (!$input) {
43    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
44    return $null;
45   }
46   $result.assign($input); %}
47
48%typemap(directorin) string %{ $input = SWIG_csharp_string_callback($1.c_str()); %}
49
50%typemap(csin) string "$csinput"
51%typemap(csout, excode=SWIGEXCODE) string {
52    string ret = $imcall;$excode
53    return ret;
54  }
55
56%typemap(typecheck) string = char *;
57
58%typemap(throws, canthrow=1) string
59%{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str());
60   return $null; %}
61
62// const string &
63%typemap(ctype) const string & "char *"
64%typemap(imtype) const string & "string"
65%typemap(cstype) const string & "string"
66
67%typemap(csdirectorin) const string & "$iminput"
68%typemap(csdirectorout) const string & "$cscall"
69
70%typemap(in, canthrow=1) const string &
71%{ if (!$input) {
72    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
73    return $null;
74   }
75   std::string $1_str($input);
76   $1 = &$1_str; %}
77%typemap(out) const string & %{ $result = SWIG_csharp_string_callback($1->c_str()); %}
78
79%typemap(csin) const string & "$csinput"
80%typemap(csout, excode=SWIGEXCODE) const string & {
81    string ret = $imcall;$excode
82    return ret;
83  }
84
85%typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string &
86%{ if (!$input) {
87    SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
88    return $null;
89   }
90   /* possible thread/reentrant code problem */
91   static std::string $1_str;
92   $1_str = $input;
93   $result = &$1_str; %}
94
95%typemap(directorin) const string & %{ $input = SWIG_csharp_string_callback($1.c_str()); %}
96
97%typemap(csvarin, excode=SWIGEXCODE2) const string & %{
98    set {
99      $imcall;$excode
100    } %}
101%typemap(csvarout, excode=SWIGEXCODE2) const string & %{
102    get {
103      string ret = $imcall;$excode
104      return ret;
105    } %}
106
107%typemap(typecheck) const string & = char *;
108
109%typemap(throws, canthrow=1) const string &
110%{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str());
111   return $null; %}
112
113}
114
115