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.
7 * SWIG typemaps for std::string
8 * ----------------------------------------------------------------------------- */
18 %insert(closprefix) %{ (declare (hide <std-string>)) %}
20 %rename("std-string") string;
29 #define std_string_str_get(s) ((char *)((s)->c_str()))
30 #define std_string_str_set(s,v) (s->assign((char *)(v)))
33 %typemap(typecheck) string = char *;
34 %typemap(typecheck) const string & = char *;
36 %typemap(in) string (char* tempptr) {
37 if ($input == C_SCHEME_FALSE) {
40 if (!C_swig_is_string ($input)) {
41 swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE,
42 "Argument #$argnum is not a string");
44 tempptr = SWIG_MakeString($input);
46 if (tempptr) SWIG_free(tempptr);
50 %typemap(in) const string& (std::string temp,
53 if ($input == C_SCHEME_FALSE) {
57 if (!C_swig_is_string ($input)) {
58 swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE,
59 "Argument #$argnum is not a string");
61 tempptr = SWIG_MakeString($input);
63 if (tempptr) SWIG_free(tempptr);
68 %typemap(out) string {
70 C_word *space = C_alloc (C_SIZEOF_STRING (size));
71 $result = C_string (&space, size, (char *) $1.c_str());
74 %typemap(out) const string& {
75 int size = $1->size();
76 C_word *space = C_alloc (C_SIZEOF_STRING (size));
77 $result = C_string (&space, size, (char *) $1->c_str());
80 %typemap(varin) string {
81 if ($input == C_SCHEME_FALSE) {
85 if (!C_swig_is_string ($input)) {
86 swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE,
87 "Argument #$argnum is not a string");
89 tempptr = SWIG_MakeString($input);
91 if (tempptr) SWIG_free(tempptr);
95 %typemap(varout) string {
97 C_word *space = C_alloc (C_SIZEOF_STRING (size));
98 $result = C_string (&space, size, (char *) $1.c_str());