comparison Core/Enumerations.cpp @ 562:f64e3838d6e1 find-move-scp

refactoring enumerations
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 18 Sep 2013 16:49:48 +0200
parents 6f8ae46ed90e
children 2d0a347e8cfc
comparison
equal deleted inserted replaced
559:e0cfb413c86b 562:f64e3838d6e1
31 31
32 32
33 #include "Enumerations.h" 33 #include "Enumerations.h"
34 34
35 #include "OrthancException.h" 35 #include "OrthancException.h"
36 #include "Toolbox.h"
36 37
37 namespace Orthanc 38 namespace Orthanc
38 { 39 {
39 const char* EnumerationToString(HttpMethod method) 40 const char* EnumerationToString(HttpMethod method)
40 { 41 {
220 221
221 default: 222 default:
222 throw OrthancException(ErrorCode_ParameterOutOfRange); 223 throw OrthancException(ErrorCode_ParameterOutOfRange);
223 } 224 }
224 } 225 }
226
227
228 const char* EnumerationToString(ResourceType type)
229 {
230 switch (type)
231 {
232 case ResourceType_Patient:
233 return "Patient";
234
235 case ResourceType_Study:
236 return "Study";
237
238 case ResourceType_Series:
239 return "Series";
240
241 case ResourceType_Instance:
242 return "Instance";
243
244 default:
245 throw OrthancException(ErrorCode_ParameterOutOfRange);
246 }
247 }
248
249
250 ResourceType StringToResourceType(const char* type)
251 {
252 std::string s(type);
253 Toolbox::ToUpperCase(s);
254
255 if (s == "PATIENT")
256 {
257 return ResourceType_Patient;
258 }
259 else if (s == "STUDY")
260 {
261 return ResourceType_Study;
262 }
263 else if (s == "SERIES")
264 {
265 return ResourceType_Series;
266 }
267 else if (s == "INSTANCE" || s == "IMAGE")
268 {
269 return ResourceType_Instance;
270 }
271 else
272 {
273 throw OrthancException(ErrorCode_ParameterOutOfRange);
274 }
275 }
225 } 276 }