add ustring.i which wraps otk::ustring for to/from python conversions
This commit is contained in:
parent
c97915f445
commit
c34f2a5241
1 changed files with 40 additions and 0 deletions
40
otk/ustring.i
Normal file
40
otk/ustring.i
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
// SWIG typemaps for otk::ustring
|
||||||
|
|
||||||
|
%{
|
||||||
|
#include "ustring.hh"
|
||||||
|
%}
|
||||||
|
|
||||||
|
namespace otk {
|
||||||
|
|
||||||
|
class ustring;
|
||||||
|
|
||||||
|
/* Overloading check */
|
||||||
|
|
||||||
|
%typemap(typecheck) ustring = char *;
|
||||||
|
%typemap(typecheck) const ustring & = char *;
|
||||||
|
|
||||||
|
%typemap(in) ustring {
|
||||||
|
if (PyString_Check($input))
|
||||||
|
$1 = otk::ustring(PyString_AsString($input));
|
||||||
|
else
|
||||||
|
SWIG_exception(SWIG_TypeError, "ustring expected");
|
||||||
|
}
|
||||||
|
|
||||||
|
%typemap(in) const ustring & (otk::ustring temp) {
|
||||||
|
if (PyString_Check($input)) {
|
||||||
|
temp = otk::ustring(PyString_AsString($input));
|
||||||
|
$1 = &temp;
|
||||||
|
} else {
|
||||||
|
SWIG_exception(SWIG_TypeError, "ustring expected");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
%typemap(out) ustring {
|
||||||
|
$result = PyString_FromString($1.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
%typemap(out) const ustring & {
|
||||||
|
$result = PyString_FromString($1->c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue