]> Creatis software - gdcm.git/blob - gdcmPython/gdcm.i
ENH: hopefully fixed swig wrapping
[gdcm.git] / gdcmPython / gdcm.i
1 %module gdcm
2 #pragma SWIG nowarn=504,510
3 %{
4 #include <iostream>
5
6 #include "gdcmCommon.h"
7 #include "gdcmBase.h"
8 #include "gdcmRefCounter.h"
9 #include "gdcmCommand.h"
10 #include "gdcmCommandPy.h"
11 #include "gdcmDebug.h"
12 #include "gdcmCommandManager.h"
13 #include "gdcmTagKey.h"
14 #include "gdcmVRKey.h"
15 #include "gdcmDict.h"
16 #include "gdcmDictEntry.h"
17 #include "gdcmDictSet.h"
18 #include "gdcmDicomDir.h"
19 #include "gdcmDicomDirElement.h"
20 #include "gdcmDicomDirImage.h"
21 #include "gdcmDicomDirMeta.h"
22 #include "gdcmDicomDirObject.h"
23 #include "gdcmDicomDirPatient.h"
24 #include "gdcmDicomDirStudy.h"
25 #include "gdcmDicomDirSerie.h"
26 #include "gdcmDocEntrySet.h"
27 #include "gdcmDocument.h"
28 #include "gdcmElementSet.h"
29 #include "gdcmFileHelper.h"
30 #include "gdcmGlobal.h"
31 #include "gdcmFile.h"
32 #include "gdcmSerieHelper.h"
33 #include "gdcmRLEFramesInfo.h"
34 #include "gdcmJPEGFragmentsInfo.h"
35 #include "gdcmSQItem.h"
36 #include "gdcmUtil.h"
37 #include "gdcmDocEntry.h"
38 #include "gdcmDataEntry.h"
39 #include "gdcmSeqEntry.h"
40 #include "gdcmVR.h"
41 #include "gdcmTS.h"
42 #include "gdcmDictGroupName.h"
43
44 /// This is required in order to avoid %including all the gdcm include files.
45 using namespace gdcm;
46 %}
47
48
49 ///////////////////////  typemap section  ////////////////////////////////////
50
51 ////////////////////////////////////////////////
52 // Redefine all types used
53 typedef char               int8_t;
54 typedef unsigned char      uint8_t;
55 typedef short              int16_t;
56 typedef unsigned short     uint16_t;
57 typedef int                int32_t;
58 typedef unsigned int       uint32_t;
59 typedef long long          int64_t;
60 typedef unsigned long long uint64_t;
61
62 ////////////////////////////////////////////////
63 // Convert a DocEntry * to the real derived class
64 %typemap(out) gdcm::DocEntry *
65 {
66    PyObject *newEntry;
67
68    if($1)
69    {
70       if(dynamic_cast<SeqEntry *>($1)) // SeqEntry *
71          newEntry = SWIG_NewPointerObj($1,SWIGTYPE_p_gdcm__SeqEntry,0);
72       else if(dynamic_cast<DataEntry *>($1)) // DataEntry *
73          newEntry = SWIG_NewPointerObj($1,SWIGTYPE_p_gdcm__DataEntry,0);
74       else
75          newEntry = NULL;
76    }
77    else
78    {
79       newEntry = Py_BuildValue("");
80    }
81    $result = newEntry;
82 }
83
84 ////////////////////  STL string versus Python str  ////////////////////////
85 // Convertion returning a C++ string.
86 %typemap(out) std::string
87 {
88     $result = PyString_FromString(($1).c_str());
89 }
90
91 %typemap(out) string
92 {
93     $result = PyString_FromString(($1).c_str());
94 }
95
96 %typemap(out) std::string const &
97 {
98     $result = PyString_FromString(($1)->c_str());
99 }
100
101 // Convertion of incoming Python str to STL string
102 %typemap(python, in) const std::string, std::string
103 {
104   $1 = PyString_AsString($input);
105 }
106
107 // Same convertion as above but references (since swig converts C++
108 // refererences to pointers)
109 %typemap(python, in) std::string const &
110 {
111    $1 = new std::string( PyString_AsString( $input ) );
112 }
113
114 ////////////////////  gdcm.TagName versus Python str  //////////////////////
115 %typemap(out) gdcm::TagName, const gdcm::TagName &
116 {
117     $result = PyString_FromString(($1)->c_str());
118 }
119
120 // Convertion of incoming Python str to STL string
121 %typemap(python, in) const gdcm::TagName, gdcm::TagName
122 {
123   $1 = PyString_AsString($input);
124 }
125
126 // Same convertion as above but references (since swig converts C++
127 // refererences to pointers)
128 %typemap(python, in) gdcm::TagName const &
129 {
130    $1 = new std::string( PyString_AsString( $input ) );
131 }
132
133 ////////////////////////////////////////////////////////////////////////////
134 // Because overloading and %rename don't work together (see below Note 1)
135 // we need to ignore some methods (e.g. the overloaded default constructor).
136 // The gdcm::File class doesn't have any SetFilename method anyhow, and
137 // this constructor is only used internaly (not from the API) so this is
138 // not a big loss.
139 %ignore gdcm::binary_write(std::ostream &,uint32_t const &);
140 %ignore gdcm::binary_write(std::ostream &,uint16_t const &);
141
142 %ignore gdcm::VRKey::operator=(const VRKey &_val);
143 %ignore gdcm::VRKey::operator=(const std::string &_val);
144 %ignore gdcm::VRKey::operator=(const char *_val);
145 %ignore gdcm::VRKey::operator[](const unsigned int &_id) const;
146 %ignore gdcm::VRKey::operator[](const unsigned int &_id);
147
148 %ignore gdcm::TagKey::operator=(const TagKey &_val);
149 %ignore gdcm::TagKey::operator[](const unsigned int &_id) const;
150 %ignore gdcm::TagKey::operator[](const unsigned int &_id);
151
152 // Ignore all placed in gdcmCommon.h
153 %ignore GDCM_UNKNOWN;
154 %ignore GDCM_UNFOUND;
155 %ignore GDCM_BINLOADED;
156 %ignore GDCM_NOTLOADED;
157 %ignore GDCM_UNREAD;
158 %ignore GDCM_NOTASCII;
159 %ignore GDCM_PIXELDATA;
160 %ignore GDCM_LEGACY;
161 %ignore GDCM_VRUNKNOWN;
162 %ignore GDCM_FILESEPARATOR;
163
164 %constant const char *UNKNOWN        = "gdcm::Unknown";
165 %constant const char *UNFOUND        = "gdcm::Unfound";
166 %constant const char *BINLOADED      = "gdcm::Binary data loaded";
167 %constant const char *NOTLOADED      = "gdcm::NotLoaded";
168 %constant const char *UNREAD         = "gdcm::UnRead";
169 %constant const char *GDCM_NOTASCII  = "gdcm::NotAscii";
170 %constant const char *GDCM_PIXELDATA = "gdcm::Pixel Data to be loaded";
171 %constant const char *VRUNKNOWN      = "  ";
172 %constant const char GDCM_FILESEPARATOR = '\\';
173 ////////////////////////////////////////////////////////////////////////////
174 // Warning: Order matters !
175 %include "gdcmCommon.h"
176 %include "gdcmBase.h"
177 %include "gdcmRefCounter.h"
178 %include "gdcmCommand.h"
179 %include "gdcmCommandPy.h"
180 %include "gdcmDebug.h"
181 %include "gdcmCommandManager.h"
182 %include "gdcmTagKey.h"
183 %include "gdcmVRKey.h"
184 %include "gdcmDictEntry.h"
185 %include "gdcmDict.h"
186 %include "gdcmDictSet.h"
187 %include "gdcmDocEntrySet.h"
188 %include "gdcmElementSet.h"
189 %include "gdcmSQItem.h"
190 %include "gdcmDicomDirElement.h"
191 %include "gdcmDicomDirObject.h"
192 %include "gdcmDicomDirImage.h"
193 %include "gdcmDicomDirSerie.h"
194 %include "gdcmDicomDirStudy.h"
195 %include "gdcmDicomDirPatient.h"
196 %include "gdcmDicomDirMeta.h"
197 %include "gdcmDocument.h"
198 %include "gdcmFile.h"
199 %include "gdcmSerieHelper.h"
200 %include "gdcmFileHelper.h"
201 %include "gdcmUtil.h"
202 %include "gdcmGlobal.h"
203 %include "gdcmDicomDir.h"
204 %include "gdcmDocEntry.h"
205 %include "gdcmDataEntry.h"
206 %include "gdcmSeqEntry.h"
207 %include "gdcmVR.h"
208 %include "gdcmTS.h"
209 %include "gdcmDictGroupName.h"