Mercurial > hg > orthanc
comparison Core/SerializationToolbox.cpp @ 2982:94c8222c52b7
New URIs to launch new C-FIND to explore the hierarchy of a C-FIND answer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 07 Dec 2018 18:03:56 +0100 |
parents | 10c610e80b15 |
children | af068a6b476b |
comparison
equal
deleted
inserted
replaced
2980:63b724c7b046 | 2982:94c8222c52b7 |
---|---|
34 #include "PrecompiledHeaders.h" | 34 #include "PrecompiledHeaders.h" |
35 #include "SerializationToolbox.h" | 35 #include "SerializationToolbox.h" |
36 | 36 |
37 #include "OrthancException.h" | 37 #include "OrthancException.h" |
38 | 38 |
39 #if ORTHANC_ENABLE_DCMTK == 1 | |
40 # include "DicomParsing/FromDcmtkBridge.h" | |
41 #endif | |
42 | |
39 namespace Orthanc | 43 namespace Orthanc |
40 { | 44 { |
41 namespace SerializationToolbox | 45 namespace SerializationToolbox |
42 { | 46 { |
47 static bool ParseTagInternal(DicomTag& tag, | |
48 const char* name) | |
49 { | |
50 #if ORTHANC_ENABLE_DCMTK == 1 | |
51 try | |
52 { | |
53 tag = FromDcmtkBridge::ParseTag(name); | |
54 return true; | |
55 } | |
56 catch (OrthancException& e) | |
57 { | |
58 return false; | |
59 } | |
60 #else | |
61 return DicomTag::ParseHexadecimal(tag, name)) | |
62 #endif | |
63 } | |
64 | |
65 | |
43 std::string ReadString(const Json::Value& value, | 66 std::string ReadString(const Json::Value& value, |
44 const std::string& field) | 67 const std::string& field) |
45 { | 68 { |
46 if (value.type() != Json::objectValue || | 69 if (value.type() != Json::objectValue || |
47 !value.isMember(field.c_str()) || | 70 !value.isMember(field.c_str()) || |
189 for (Json::Value::ArrayIndex i = 0; i < arr.size(); i++) | 212 for (Json::Value::ArrayIndex i = 0; i < arr.size(); i++) |
190 { | 213 { |
191 DicomTag tag(0, 0); | 214 DicomTag tag(0, 0); |
192 | 215 |
193 if (arr[i].type() != Json::stringValue || | 216 if (arr[i].type() != Json::stringValue || |
194 !DicomTag::ParseHexadecimal(tag, arr[i].asCString())) | 217 !ParseTagInternal(tag, arr[i].asCString())) |
195 { | 218 { |
196 throw OrthancException(ErrorCode_BadFileFormat, | 219 throw OrthancException(ErrorCode_BadFileFormat, |
197 "Set of DICOM tags expected in field: " + field); | 220 "Set of DICOM tags expected in field: " + field); |
198 } | 221 } |
199 else | 222 else |
261 { | 284 { |
262 const Json::Value& tmp = source[members[i]]; | 285 const Json::Value& tmp = source[members[i]]; |
263 | 286 |
264 DicomTag tag(0, 0); | 287 DicomTag tag(0, 0); |
265 | 288 |
266 if (!DicomTag::ParseHexadecimal(tag, members[i].c_str()) || | 289 if (!ParseTagInternal(tag, members[i].c_str()) || |
267 tmp.type() != Json::stringValue) | 290 tmp.type() != Json::stringValue) |
268 { | 291 { |
269 throw OrthancException(ErrorCode_BadFileFormat, | 292 throw OrthancException(ErrorCode_BadFileFormat, |
270 "Associative array of DICOM tags to strings expected in field: " + field); | 293 "Associative array of DICOM tags to strings expected in field: " + field); |
271 } | 294 } |