Home | History | Annotate | Download | only in ruby
      1 #if !defined(SWIG_STD_STRING)
      2 #define SWIG_STD_BASIC_STRING
      3 
      4 %include <rubycontainer.swg>
      5 
      6 #define %swig_basic_string(Type...)  %swig_sequence_methods_val(Type)
      7 
      8 
      9 %traits_swigtype(std::basic_string<char>);
     10 %fragment(SWIG_Traits_frag(std::basic_string<char>));
     11 
     12 
     13 %fragment(SWIG_AsPtr_frag(std::basic_string<char>),"header",
     14 	  fragment="SWIG_AsCharPtrAndSize") {
     15 SWIGINTERN int
     16 SWIG_AsPtr(std::basic_string<char>)(VALUE obj, std::string **val)
     17 {
     18   static swig_type_info* string_info =
     19     SWIG_TypeQuery("std::basic_string<char> *");
     20   std::string *vptr;
     21   if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) {
     22     if (val) *val = vptr;
     23     return SWIG_OLDOBJ;
     24   } else {
     25     char* buf = 0 ; size_t size = 0; int alloc = 0;
     26     if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) {
     27       if (buf) {
     28 	if (val) *val = new std::string(buf, size - 1);
     29 	if (alloc == SWIG_NEWOBJ) %delete_array(buf);
     30 	return SWIG_NEWOBJ;
     31       }
     32     }
     33     if (val) {
     34       rb_raise( rb_eTypeError, "a string is expected");
     35     }
     36     return 0;
     37   }
     38 }
     39 }
     40 
     41 %fragment(SWIG_From_frag(std::basic_string<char>),"header",
     42 	  fragment="SWIG_FromCharPtrAndSize") {
     43 SWIGINTERNINLINE VALUE
     44   SWIG_From(std::basic_string<char>)(const std::string& s)
     45   {
     46     return SWIG_FromCharPtrAndSize(s.data(), s.size());
     47   }
     48 }
     49 
     50 %include <std/std_basic_string.i>
     51 %typemaps_asptrfromn(%checkcode(STRING), std::basic_string<char>);
     52 
     53 #endif
     54 
     55 
     56 #if !defined(SWIG_STD_WSTRING)
     57 
     58 %fragment(SWIG_AsPtr_frag(std::basic_string<wchar_t>),"header",
     59 	  fragment="SWIG_AsWCharPtrAndSize") {
     60 SWIGINTERN int
     61   SWIG_AsPtr(std::basic_string<wchar_t>)(VALUE obj, std::wstring **val)
     62   {
     63     static swig_type_info* string_info =
     64       SWIG_TypeQuery("std::basic_string<wchar_t> *");
     65     std::wstring *vptr;
     66     if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) {
     67       if (val) *val = vptr;
     68       return SWIG_OLDOBJ;
     69     } else {
     70       wchar_t *buf = 0 ; size_t size = 0; int alloc = 0;
     71       if (SWIG_AsWCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) {
     72 	if (buf) {
     73 	  if (val) *val = new std::wstring(buf, size - 1);
     74 	  if (alloc == SWIG_NEWOBJ) %delete_array(buf);
     75 	  return SWIG_NEWOBJ;
     76 	}
     77       }
     78       if (val) {
     79 	rb_raise( rb_eTypeError, "a string is expected");
     80       }
     81       return 0;
     82     }
     83   }
     84 }
     85 
     86 %fragment(SWIG_From_frag(std::basic_string<wchar_t>),"header",
     87 	  fragment="SWIG_FromWCharPtrAndSize") {
     88 SWIGINTERNINLINE VALUE
     89   SWIG_From(std::basic_string<wchar_t>)(const std::wstring& s)
     90   {
     91     return SWIG_FromWCharPtrAndSize(s.data(), s.size());
     92   }
     93 }
     94 
     95 %typemaps_asptrfromn(%checkcode(UNISTRING), std::basic_string<wchar_t>);
     96 
     97 #endif
     98