diff OrthancServer/FromDcmtkBridge.cpp @ 1929:cda5b0ab4ce5

ORTHANC_MAXIMUM_TAG_LENGTH made explicit
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 21 Mar 2016 14:28:59 +0100
parents 84c7eaeb5244
children 1c147c3c3121
line wrap: on
line diff
--- a/OrthancServer/FromDcmtkBridge.cpp	Mon Mar 21 14:12:31 2016 +0100
+++ b/OrthancServer/FromDcmtkBridge.cpp	Mon Mar 21 14:28:59 2016 +0100
@@ -306,6 +306,7 @@
 
   void FromDcmtkBridge::Convert(DicomMap& target, 
                                 DcmDataset& dataset,
+                                unsigned int maxStringLength,
                                 Encoding defaultEncoding)
   {
     Encoding encoding = DetectEncoding(dataset, defaultEncoding);
@@ -318,7 +319,7 @@
       {
         target.SetValue(element->getTag().getGTag(),
                         element->getTag().getETag(),
-                        ConvertLeafElement(*element, DicomToJsonFlags_Default, encoding));
+                        ConvertLeafElement(*element, DicomToJsonFlags_Default, maxStringLength, encoding));
       }
     }
   }
@@ -338,6 +339,7 @@
 
   DicomValue* FromDcmtkBridge::ConvertLeafElement(DcmElement& element,
                                                   DicomToJsonFlags flags,
+                                                  unsigned int maxStringLength,
                                                   Encoding encoding)
   {
     if (!element.isLeaf())
@@ -359,7 +361,8 @@
         std::string s(c);
         std::string utf8 = Toolbox::ConvertToUtf8(s, encoding);
 
-        if (utf8.size() > ORTHANC_MAXIMUM_TAG_LENGTH)
+        if (maxStringLength != 0 &&
+            utf8.size() > maxStringLength)
         {
           return new DicomValue;  // Create a NULL value
         }
@@ -705,7 +708,7 @@
 
     if (element.isLeaf())
     {
-      std::auto_ptr<DicomValue> v(FromDcmtkBridge::ConvertLeafElement(element, flags, encoding));
+      std::auto_ptr<DicomValue> v(FromDcmtkBridge::ConvertLeafElement(element, flags, maxStringLength, encoding));
       LeafValueToJson(target, *v, format, flags, maxStringLength);
     }
     else