// SWIG typemaps for std::string
// ------------------------------------------------------------------------
// std::string is typemapped by value
// This can prevent exporting methods which return a string
// in order for the user to modify it.
// However, I think I'll wait until someone asks for it...
// ------------------------------------------------------------------------
%typemap(typecheck) string = char *;
%typemap(typecheck) const string & = char *;
const char *ptr = SvPV($input, len);
SWIG_croak("Undefined variable in argument $argnum of $symname.");
$1 = std::string(ptr, len);
%typemap(in) string *INPUT(std::string temp),
const string & (std::string temp) {
const char *ptr = SvPV($input, len);
SWIG_croak("Undefined variable in argument $argnum of $symname.");
if (argvi >= items) EXTEND(sp, 1); // bump stack ptr, if needed
char *data = const_cast<char*>($1.data());
sv_setpvn($result = sv_newmortal(), data, $1.size());
%typemap(out) const string & {
if (argvi >= items) EXTEND(sp, 1); // bump stack ptr, if needed
char *data = const_cast<char*>($1->data());
sv_setpvn($result = sv_newmortal(), data, $1->size());
%typemap(throws) const string & {
%typemap(throws) string {