diff 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
line wrap: on
line diff
--- a/Core/SerializationToolbox.cpp	Thu Dec 06 13:10:24 2018 +0100
+++ b/Core/SerializationToolbox.cpp	Fri Dec 07 18:03:56 2018 +0100
@@ -36,10 +36,33 @@
 
 #include "OrthancException.h"
 
+#if ORTHANC_ENABLE_DCMTK == 1
+#  include "DicomParsing/FromDcmtkBridge.h"
+#endif
+
 namespace Orthanc
 {
   namespace SerializationToolbox
   {
+    static bool ParseTagInternal(DicomTag& tag,
+                                 const char* name)
+    {
+#if ORTHANC_ENABLE_DCMTK == 1
+      try
+      {
+        tag = FromDcmtkBridge::ParseTag(name);
+        return true;
+      }
+      catch (OrthancException& e)
+      {
+        return false;
+      }
+#else
+      return DicomTag::ParseHexadecimal(tag, name))
+#endif   
+    }
+
+    
     std::string ReadString(const Json::Value& value,
                            const std::string& field)
     {
@@ -191,7 +214,7 @@
         DicomTag tag(0, 0);
 
         if (arr[i].type() != Json::stringValue ||
-            !DicomTag::ParseHexadecimal(tag, arr[i].asCString()))
+            !ParseTagInternal(tag, arr[i].asCString()))
         {
           throw OrthancException(ErrorCode_BadFileFormat,
                                  "Set of DICOM tags expected in field: " + field);
@@ -263,7 +286,7 @@
 
         DicomTag tag(0, 0);
 
-        if (!DicomTag::ParseHexadecimal(tag, members[i].c_str()) ||
+        if (!ParseTagInternal(tag, members[i].c_str()) ||
             tmp.type() != Json::stringValue)
         {
           throw OrthancException(ErrorCode_BadFileFormat,