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 * ----------------------------------------------------------------------------- */
10 // ------------------------------------------------------------------------
11 // std::string is typemapped by value
12 // This can prevent exporting methods which return a string
13 // in order for the user to modify it.
14 // However, I think I'll wait until someone asks for it...
15 // ------------------------------------------------------------------------
17 %include <exception.i>
29 %typemap(typecheck) string = char *;
30 %typemap(typecheck) const string & = char *;
32 %typemap(in) string (char* tempptr) {
33 if (gh_string_p($input)) {
34 tempptr = SWIG_scm2str($input);
36 if (tempptr) SWIG_free(tempptr);
38 SWIG_exception(SWIG_TypeError, "string expected");
42 %typemap(in) const string & (std::string temp,
44 if (gh_string_p($input)) {
45 tempptr = SWIG_scm2str($input);
47 if (tempptr) SWIG_free(tempptr);
50 SWIG_exception(SWIG_TypeError, "string expected");
54 %typemap(in) string * (char* tempptr) {
55 if (gh_string_p($input)) {
56 tempptr = SWIG_scm2str($input);
57 $1 = new std::string(tempptr);
58 if (tempptr) SWIG_free(tempptr);
60 SWIG_exception(SWIG_TypeError, "string expected");
64 %typemap(out) string {
65 $result = gh_str02scm($1.c_str());
68 %typemap(out) const string & {
69 $result = gh_str02scm($1->c_str());
72 %typemap(out) string * {
73 $result = gh_str02scm($1->c_str());
76 %typemap(varin) string {
77 if (gh_string_p($input)) {
78 char *tempptr = SWIG_scm2str($input);
80 if (tempptr) SWIG_free(tempptr);
82 SWIG_exception(SWIG_TypeError, "string expected");
86 %typemap(varout) string {
87 $result = gh_str02scm($1.c_str());