PageRenderTime 41ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/trunk/Lib/csharp/std_string.i

#
Swig | 111 lines | 77 code | 23 blank | 11 comment | 0 complexity | 4086351ef34604b4924a3ba03fb55cd1 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* -----------------------------------------------------------------------------
  2. * std_string.i
  3. *
  4. * Typemaps for std::string and const std::string&
  5. * These are mapped to a C# String and are passed around by value.
  6. *
  7. * To use non-const std::string references use the following %apply. Note
  8. * that they are passed by value.
  9. * %apply const std::string & {std::string &};
  10. * ----------------------------------------------------------------------------- */
  11. %{
  12. #include <string>
  13. %}
  14. namespace std {
  15. %naturalvar string;
  16. class string;
  17. // string
  18. %typemap(ctype) string "char *"
  19. %typemap(imtype) string "string"
  20. %typemap(cstype) string "string"
  21. %typemap(csdirectorin) string "$iminput"
  22. %typemap(csdirectorout) string "$cscall"
  23. %typemap(in, canthrow=1) string
  24. %{ if (!$input) {
  25. SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
  26. return $null;
  27. }
  28. $1.assign($input); %}
  29. %typemap(out) string %{ $result = SWIG_csharp_string_callback($1.c_str()); %}
  30. %typemap(directorout, canthrow=1) string
  31. %{ if (!$input) {
  32. SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
  33. return $null;
  34. }
  35. $result.assign($input); %}
  36. %typemap(directorin) string %{ $input = SWIG_csharp_string_callback($1.c_str()); %}
  37. %typemap(csin) string "$csinput"
  38. %typemap(csout, excode=SWIGEXCODE) string {
  39. string ret = $imcall;$excode
  40. return ret;
  41. }
  42. %typemap(typecheck) string = char *;
  43. %typemap(throws, canthrow=1) string
  44. %{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str());
  45. return $null; %}
  46. // const string &
  47. %typemap(ctype) const string & "char *"
  48. %typemap(imtype) const string & "string"
  49. %typemap(cstype) const string & "string"
  50. %typemap(csdirectorin) const string & "$iminput"
  51. %typemap(csdirectorout) const string & "$cscall"
  52. %typemap(in, canthrow=1) const string &
  53. %{ if (!$input) {
  54. SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
  55. return $null;
  56. }
  57. std::string $1_str($input);
  58. $1 = &$1_str; %}
  59. %typemap(out) const string & %{ $result = SWIG_csharp_string_callback($1->c_str()); %}
  60. %typemap(csin) const string & "$csinput"
  61. %typemap(csout, excode=SWIGEXCODE) const string & {
  62. string ret = $imcall;$excode
  63. return ret;
  64. }
  65. %typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string &
  66. %{ if (!$input) {
  67. SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "null string", 0);
  68. return $null;
  69. }
  70. /* possible thread/reentrant code problem */
  71. static std::string $1_str;
  72. $1_str = $input;
  73. $result = &$1_str; %}
  74. %typemap(directorin) const string & %{ $input = SWIG_csharp_string_callback($1.c_str()); %}
  75. %typemap(csvarin, excode=SWIGEXCODE2) const string & %{
  76. set {
  77. $imcall;$excode
  78. } %}
  79. %typemap(csvarout, excode=SWIGEXCODE2) const string & %{
  80. get {
  81. string ret = $imcall;$excode
  82. return ret;
  83. } %}
  84. %typemap(typecheck) const string & = char *;
  85. %typemap(throws, canthrow=1) const string &
  86. %{ SWIG_CSharpSetPendingException(SWIG_CSharpApplicationException, $1.c_str());
  87. return $null; %}
  88. }