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