[807] | 1 | # $Id: G4String.i,v 1.1 2003/06/17 15:25:01 mdressel Exp $ |
---|
| 2 | # ------------------------------------------------------------------- |
---|
| 3 | # GEANT4 tag $Name: $ |
---|
| 4 | # ------------------------------------------------------------------- |
---|
| 5 | |
---|
| 6 | // coppied from std_string.i |
---|
| 7 | |
---|
| 8 | %include exception.i |
---|
| 9 | |
---|
| 10 | %{ |
---|
| 11 | #include "G4String.hh" |
---|
| 12 | %} |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | class G4String; |
---|
| 16 | |
---|
| 17 | /* Overloading check */ |
---|
| 18 | |
---|
| 19 | %typemap(typecheck) G4String = char *; |
---|
| 20 | %typemap(typecheck) const G4String & = char *; |
---|
| 21 | |
---|
| 22 | %typemap(in) G4String { |
---|
| 23 | if (PyString_Check($input)) |
---|
| 24 | $1 = G4String(PyString_AsString($input)); |
---|
| 25 | else |
---|
| 26 | SWIG_exception(SWIG_TypeError, "G4String expected"); |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | %typemap(in) const G4String & (G4String temp) { |
---|
| 30 | if (PyString_Check($input)) { |
---|
| 31 | temp = G4String(PyString_AsString($input)); |
---|
| 32 | $1 = &temp; |
---|
| 33 | } else { |
---|
| 34 | SWIG_exception(SWIG_TypeError, "G4String expected"); |
---|
| 35 | } |
---|
| 36 | } |
---|
| 37 | |
---|
| 38 | %typemap(out) G4String { |
---|
| 39 | $result = PyString_FromStringAndSize($1.data(),$1.size()); |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | %typemap(out) const G4String & { |
---|
| 43 | $result = PyString_FromStringAndSize($1->data(),$1->size()); |
---|
| 44 | } |
---|
| 45 | |
---|
| 46 | %typemap(inv, parse="s") G4String, const G4String &, G4String & "$1_name.c_str()"; |
---|
| 47 | |
---|
| 48 | %typemap(inv, parse="s") G4String *, const G4String * "$1_name->c_str()"; |
---|
| 49 | |
---|
| 50 | %typemap(outv) G4String { |
---|
| 51 | if (PyString_Check($input)) |
---|
| 52 | $result = G4String(PyString_AsString($input)); |
---|
| 53 | else |
---|
| 54 | throw SWIG_DIRECTOR_TYPE_MISMATCH("G4String expected"); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | %typemap(outv) const G4String & (G4String temp) { |
---|
| 58 | if (PyString_Check($input)) { |
---|
| 59 | temp = G4String(PyString_AsString($input)); |
---|
| 60 | $result = &temp; |
---|
| 61 | } else { |
---|
| 62 | throw SWIG_DIRECTOR_TYPE_MISMATCH("G4String expected"); |
---|
| 63 | } |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | |
---|