]> Creatis software - creaCLI.git/blob - bbtk_Slicer_PKG/src/CreationTool.cxx
All Slicer modules succesfully compiled into BBTK boxes :P
[creaCLI.git] / bbtk_Slicer_PKG / src / CreationTool.cxx
1 /* 
2  * File:   CreationTool.cxx
3  * Author: riveros
4  * 
5  * Created on 23 mars 2012, 10:12
6  */
7
8 #include "CreationTool.h"
9
10 std::string Mthd::Aux::toString ( float n ) {
11     std::ostringstream oss ;
12     oss << n ;
13     return oss.str ( ) ;
14 }
15
16 std::string Mthd::Aux::toString ( double n ) {
17     std::ostringstream oss ;
18     oss << n ;
19     return oss.str ( ) ;
20 }
21
22 std::string Mthd::Aux::toString ( long double n ) {
23     std::ostringstream oss ;
24     oss << n ;
25     return oss.str ( ) ;
26 }
27
28 std::string Mthd::Aux::toString ( char n ) {
29     std::ostringstream oss ;
30     oss << n ;
31     return oss.str ( ) ;
32 }
33
34 std::string Mthd::Aux::toString ( unsigned char n ) {
35     std::ostringstream oss ;
36     oss << n ;
37     return oss.str ( ) ;
38 }
39
40 std::string Mthd::Aux::toString ( short n ) {
41     std::ostringstream oss ;
42     oss << n ;
43     return oss.str ( ) ;
44 }
45
46 std::string Mthd::Aux::toString ( unsigned short n ) {
47     std::ostringstream oss ;
48     oss << n ;
49     return oss.str ( ) ;
50 }
51
52 std::string Mthd::Aux::toString ( int n ) {
53     std::ostringstream oss ;
54     oss << n ;
55     return oss.str ( ) ;
56 }
57
58 std::string Mthd::Aux::toString ( long int n ) {
59     std::ostringstream oss ;
60     oss << n ;
61     return oss.str ( ) ;
62 }
63
64 std::string Mthd::Aux::toString ( unsigned int n ) {
65     std::ostringstream oss ;
66     oss << n ;
67     return oss.str ( ) ;
68 }
69
70 std::string Mthd::Aux::toString ( unsigned long n ) {
71     std::ostringstream oss ;
72     oss << n ;
73     return oss.str ( ) ;
74 }
75
76 std::string Mthd::Aux::toString ( unsigned long long n ) {
77     std::ostringstream oss ;
78     oss << n ;
79     return oss.str ( ) ;
80 }
81
82 std::string Mthd::Aux::toString ( std::vector<int> v ) {
83     std::ostringstream oss ;
84     std::string _vector = std::string ( "" ) ;
85     for ( long unsigned int i = 0 ; i < v.size ( ) ; i ++ ) {
86         oss << v.at ( i ) ;
87         _vector += oss.str ( ) ;
88         if ( i + 1 < v.size ( ) ) {
89             _vector += "," ;
90         }
91     }
92     return _vector ;
93 }
94
95 std::string Mthd::Aux::toString ( std::vector<float> v ) {
96     std::ostringstream oss ;
97     std::string _vector = std::string ( "" ) ;
98     for ( long unsigned int i = 0 ; i < v.size ( ) ; i ++ ) {
99         oss << v.at ( i ) ;
100         _vector += oss.str ( ) ;
101         if ( i + 1 < v.size ( ) ) {
102             _vector += "," ;
103         }
104     }
105     return _vector ;
106 }
107
108 std::string Mthd::Aux::toString ( std::vector<double> v ) {
109     std::ostringstream oss ;
110     std::string _vector = std::string ( "" ) ;
111     for ( long unsigned int i = 0 ; i < v.size ( ) ; i ++ ) {
112         oss << v.at ( i ) ;
113         _vector += oss.str ( ) ;
114         if ( i + 1 < v.size ( ) ) {
115             _vector += "," ;
116         }
117     }
118     return _vector ;
119 }
120
121 std::string Mthd::Aux::toString ( std::vector<long double> v ) {
122     std::ostringstream oss ;
123     std::string _vector = std::string ( "" ) ;
124     for ( long unsigned int i = 0 ; i < v.size ( ) ; i ++ ) {
125         oss << v.at ( i ) ;
126         _vector += oss.str ( ) ;
127         if ( i + 1 < v.size ( ) ) {
128             _vector += "," ;
129         }
130     }
131     return _vector ;
132 }
133
134 std::string Mthd::Aux::toString ( std::vector<long int> v ) {
135     std::ostringstream oss ;
136     std::string _vector = std::string ( "" ) ;
137     for ( long unsigned int i = 0 ; i < v.size ( ) ; i ++ ) {
138         oss << v.at ( i ) ;
139         _vector += oss.str ( ) ;
140         if ( i + 1 < v.size ( ) ) {
141             _vector += "," ;
142         }
143     }
144     return _vector ;
145 }
146
147 std::string Mthd::Aux::toString ( std::vector<unsigned int> v ) {
148     std::ostringstream oss ;
149     std::string _vector = std::string ( "" ) ;
150     for ( long unsigned int i = 0 ; i < v.size ( ) ; i ++ ) {
151         oss << v.at ( i ) ;
152         _vector += oss.str ( ) ;
153         if ( i + 1 < v.size ( ) ) {
154             _vector += "," ;
155         }
156     }
157     return _vector ;
158 }
159
160 std::string Mthd::Aux::toString ( std::vector<unsigned long> v ) {
161     std::ostringstream oss ;
162     std::string _vector = std::string ( "" ) ;
163     for ( long unsigned int i = 0 ; i < v.size ( ) ; i ++ ) {
164         oss << v.at ( i ) ;
165         _vector += oss.str ( ) ;
166         if ( i + 1 < v.size ( ) ) {
167             _vector += "," ;
168         }
169     }
170     return _vector ;
171 }
172
173 std::string Mthd::Aux::toString ( std::vector<unsigned long long> v ) {
174     std::ostringstream oss ;
175     std::string _vector = std::string ( "" ) ;
176     for ( long unsigned int i = 0 ; i < v.size ( ) ; i ++ ) {
177         oss << v.at ( i ) ;
178         _vector += oss.str ( ) ;
179         if ( i + 1 < v.size ( ) ) {
180             _vector += "," ;
181         }
182     }
183     return _vector ;
184 }
185
186 std::string Mthd::Aux::toString ( std::vector<std::basic_string<char> > v ) {
187     std::ostringstream oss ;
188     std::string _vector = std::string ( "" ) ;
189     for ( long unsigned int i = 0 ; i < v.size ( ) ; i ++ ) {
190         oss << v.at ( i ) ;
191         _vector += oss.str ( ) ;
192         if ( i + 1 < v.size ( ) ) {
193             _vector += "," ;
194         }
195     }
196     return _vector ;
197 }
198
199 std::string Mthd::Aux::toString ( std::vector<std::vector< int > > v ) {
200     return "Not implemented";
201 }
202
203 std::string Mthd::Aux::toString ( std::vector<std::vector< float > > v ) {
204     return "Not implemented";
205 }
206
207 std::string Mthd::Aux::toString ( std::vector<std::vector< double > > v ) {
208     return "Not implemented";
209 }
210
211 std::string Mthd::Aux::toString ( std::vector<std::vector< long int > > v ) {
212     return "Not implemented";
213 }
214
215 std::string Mthd::Aux::toString ( std::vector<std::vector< long double > > v ) {
216     return "Not implemented";
217 }
218
219 std::string Mthd::Aux::toString ( std::vector<std::vector< unsigned int > > v ) {
220     return "Not implemented";
221 }
222
223 std::string Mthd::Aux::toString ( std::vector<std::vector< unsigned long > > v ) {
224     return "Not implemented";
225 }
226
227 std::string Mthd::Aux::toString ( std::vector<std::vector< unsigned long long > > v ) {
228     return "Not implemented";
229 }
230
231 std::string Mthd::Aux::toString ( std::string n ) {
232     return n ;
233 }
234
235 char* Mthd::Aux::toCharArrray ( float n ) {
236     std::ostringstream oss ;
237     oss << n ;
238     return const_cast < char* > ( oss.str ( ).data ( ) ) ;
239 }
240
241 char* Mthd::Aux::toCharArrray ( double n ) {
242     std::ostringstream oss ;
243     oss << n ;
244     return const_cast < char* > ( oss.str ( ).data ( ) ) ;
245 }
246
247 char* Mthd::Aux::toCharArrray ( long double n ) {
248     std::ostringstream oss ;
249     oss << n ;
250     return const_cast < char* > ( oss.str ( ).data ( ) ) ;
251 }
252
253 char* Mthd::Aux::toCharArrray ( char n ) {
254     std::ostringstream oss ;
255     oss << n ;
256     return const_cast < char* > ( oss.str ( ).data ( ) ) ;
257 }
258
259 char* Mthd::Aux::toCharArrray ( unsigned char n ) {
260     std::ostringstream oss ;
261     oss << n ;
262     return const_cast < char* > ( oss.str ( ).data ( ) ) ;
263 }
264
265 char* Mthd::Aux::toCharArrray ( short n ) {
266     std::ostringstream oss ;
267     oss << n ;
268     return const_cast < char* > ( oss.str ( ).data ( ) ) ;
269 }
270
271 char* Mthd::Aux::toCharArrray ( unsigned short n ) {
272     std::ostringstream oss ;
273     oss << n ;
274     return const_cast < char* > ( oss.str ( ).data ( ) ) ;
275 }
276
277 char* Mthd::Aux::toCharArrray ( int n ) {
278     std::ostringstream oss ;
279     oss << n ;
280     return const_cast < char* > ( oss.str ( ).data ( ) ) ;
281 }
282
283 char* Mthd::Aux::toCharArrray ( long int n ) {
284     std::ostringstream oss ;
285     oss << n ;
286     return const_cast < char* > ( oss.str ( ).data ( ) ) ;
287 }
288
289 char* Mthd::Aux::toCharArrray ( unsigned int n ) {
290     std::ostringstream oss ;
291     oss << n ;
292     return const_cast < char* > ( oss.str ( ).data ( ) ) ;
293 }
294
295 char* Mthd::Aux::toCharArrray ( long unsigned int n ) {
296     std::ostringstream oss ;
297     oss << n ;
298     return const_cast < char* > ( oss.str ( ).data ( ) ) ;
299 }
300
301 char* Mthd::Aux::toCharArrray ( std::string n ) {
302     return const_cast < char* > ( n.data ( ) ) ;
303 }
304
305 char* Mthd::Aux::toCharArrray ( std::vector<int> v ) {
306     std::ostringstream oss ;
307     std::string _vector = std::string ( "" ) ;
308     for ( long unsigned int i = 0 ; i < v.size ( ) ; i ++ ) {
309         oss << v.at ( i ) ;
310         _vector += oss.str ( ) ;
311         if ( i + 1 < v.size ( ) ) {
312             _vector += "," ;
313         }
314     }
315     return const_cast < char* > ( _vector.data ( ) ) ;
316 }
317
318 char* Mthd::Aux::toCharArrray ( std::vector<float> v ) {
319     std::ostringstream oss ;
320     std::string _vector = std::string ( "" ) ;
321     for ( long unsigned int i = 0 ; i < v.size ( ) ; i ++ ) {
322         oss << v.at ( i ) ;
323         _vector += oss.str ( ) ;
324         if ( i + 1 < v.size ( ) ) {
325             _vector += "," ;
326         }
327     }
328     return const_cast < char* > ( _vector.data ( ) ) ;
329 }
330
331 char* Mthd::Aux::toCharArrray ( std::vector<double> v ) {
332     std::ostringstream oss ;
333     std::string _vector = std::string ( "" ) ;
334     for ( long unsigned int i = 0 ; i < v.size ( ) ; i ++ ) {
335         oss << v.at ( i ) ;
336         _vector += oss.str ( ) ;
337         if ( i + 1 < v.size ( ) ) {
338             _vector += "," ;
339         }
340     }
341     return const_cast < char* > ( _vector.data ( ) ) ;
342 }
343
344 char* Mthd::Aux::toCharArrray ( std::vector<long double> v ) {
345     std::ostringstream oss ;
346     std::string _vector = std::string ( "" ) ;
347     for ( long unsigned int i = 0 ; i < v.size ( ) ; i ++ ) {
348         oss << v.at ( i ) ;
349         _vector += oss.str ( ) ;
350         if ( i + 1 < v.size ( ) ) {
351             _vector += "," ;
352         }
353     }
354     return const_cast < char* > ( _vector.data ( ) ) ;
355 }
356
357 char* Mthd::Aux::toCharArrray ( std::vector<long int> v ) {
358     std::ostringstream oss ;
359     std::string _vector = std::string ( "" ) ;
360     for ( long unsigned int i = 0 ; i < v.size ( ) ; i ++ ) {
361         oss << v.at ( i ) ;
362         _vector += oss.str ( ) ;
363         if ( i + 1 < v.size ( ) ) {
364             _vector += "," ;
365         }
366     }
367     return const_cast < char* > ( _vector.data ( ) ) ;
368 }
369
370 char* Mthd::Aux::toCharArrray ( std::vector<unsigned int> v ) {
371     std::ostringstream oss ;
372     std::string _vector = std::string ( "" ) ;
373     for ( long unsigned int i = 0 ; i < v.size ( ) ; i ++ ) {
374         oss << v.at ( i ) ;
375         _vector += oss.str ( ) ;
376         if ( i + 1 < v.size ( ) ) {
377             _vector += "," ;
378         }
379     }
380     return const_cast < char* > ( _vector.data ( ) ) ;
381 }
382
383 char* Mthd::Aux::toCharArrray ( std::vector<unsigned long> v ) {
384     std::ostringstream oss ;
385     std::string _vector = std::string ( "" ) ;
386     for ( long unsigned int i = 0 ; i < v.size ( ) ; i ++ ) {
387         oss << v.at ( i ) ;
388         _vector += oss.str ( ) ;
389         if ( i + 1 < v.size ( ) ) {
390             _vector += "," ;
391         }
392     }
393     return const_cast < char* > ( _vector.data ( ) ) ;
394 }
395
396 char* Mthd::Aux::toCharArrray ( std::vector<unsigned long long> v ) {
397     std::ostringstream oss ;
398     std::string _vector = std::string ( "" ) ;
399     for ( long unsigned int i = 0 ; i < v.size ( ) ; i ++ ) {
400         oss << v.at ( i ) ;
401         _vector += oss.str ( ) ;
402         if ( i + 1 < v.size ( ) ) {
403             _vector += "," ;
404         }
405     }
406     return const_cast < char* > ( _vector.data ( ) ) ;
407 }
408
409 std::string Mthd::Aux::replace_str ( std::string input , std::string old_str , std::string new_str ) {
410     size_t found = input.find ( old_str ) ;
411     while ( found != std::string::npos ) {
412         input.replace ( found , old_str.length ( ) , new_str ) ;
413         found = input.find ( old_str ) ;
414     }
415     return input ;
416 }
417
418 bool Mthd::Aux::str_ends_with ( std::string total_str , std::string sub_str ) {
419     size_t found = total_str.find ( sub_str ) ;
420     if ( found != std::string::npos ) {
421         return true ;
422     }
423     return false ;
424 }
425