-typedef unsigned short guint16;
-typedef unsigned int guint32;
-
-%typemap(out) list<string> * {
- PyObject* NewItem = (PyObject*)0;
- PyObject* NewList = PyList_New(0); // The result of this typemap
- for (list<string>::iterator NewString = ($1)->begin();
- NewString != ($1)->end(); ++NewString) {
- NewItem = PyString_FromString(NewString->c_str());
- PyList_Append( NewList, NewItem);
- }
- $result = NewList;
+
+
+/////////////////////// typemap section ////////////////////////////////////
+
+////////////////////////////////////////////////
+// Redefine all types used
+typedef char int8_t;
+typedef unsigned char uint8_t;
+typedef short int16_t;
+typedef unsigned short uint16_t;
+typedef int int32_t;
+typedef unsigned int uint32_t;
+typedef long long int64_t;
+typedef unsigned long long uint64_t;
+
+////////////////////////////////////////////////
+// Convert a DocEntry * to the real derived class
+%typemap(out) gdcm::DocEntry *
+{
+ PyObject *newEntry;
+
+ if($1)
+ {
+ if(dynamic_cast<SeqEntry *>($1)) // SeqEntry *
+ newEntry = SWIG_NewPointerObj($1,SWIGTYPE_p_gdcm__SeqEntry,0);
+ else if(dynamic_cast<DataEntry *>($1)) // DataEntry *
+ newEntry = SWIG_NewPointerObj($1,SWIGTYPE_p_gdcm__DataEntry,0);
+ else
+ newEntry = NULL;
+ }
+ else
+ {
+ newEntry = Py_BuildValue("");
+ }
+ $result = newEntry;
+}
+
+//////////////////// STL string versus Python str ////////////////////////
+// Convertion returning a C++ string.
+%typemap(out) std::string
+{
+ $result = PyString_FromString(($1).c_str());
+}
+
+%typemap(out) string
+{
+ $result = PyString_FromString(($1).c_str());
+}
+
+%typemap(out) std::string const &
+{
+ $result = PyString_FromString(($1)->c_str());
+}
+
+// Convertion of incoming Python str to STL string
+%typemap(python, in) const std::string, std::string
+{
+ $1 = PyString_AsString($input);
+}
+
+// Same convertion as above but references (since swig converts C++
+// refererences to pointers)
+%typemap(python, in) std::string const &
+{
+ $1 = new std::string( PyString_AsString( $input ) );
+}
+
+//////////////////// gdcm.TagName versus Python str //////////////////////
+%typemap(out) gdcm::TagName, const gdcm::TagName &
+{
+ $result = PyString_FromString(($1)->c_str());