changeset 7013:c11bace73f8c

fix for older compilers
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Jul 2026 12:02:11 +0200
parents 7c518a774b76
children aeda053db543
files OrthancFramework/Sources/DicomParsing/DicomWebJsonVisitor.cpp OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp
diffstat 2 files changed, 16 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomParsing/DicomWebJsonVisitor.cpp	Tue Jul 07 11:46:39 2026 +0200
+++ b/OrthancFramework/Sources/DicomParsing/DicomWebJsonVisitor.cpp	Tue Jul 07 12:02:11 2026 +0200
@@ -409,7 +409,8 @@
 #endif
 
 
-  template <typename TargetType,
+  template <typename MemoryType,
+            typename JsonCppType,
             typename SourceType>
   static void ApplyBinaryModeToOtherTypes(Json::Value& node,
                                           DicomWebJsonVisitor::BinaryMode mode,
@@ -430,15 +431,17 @@
         if (!values.empty())
         {
           std::string raw;
-          raw.resize(values.size() * sizeof(TargetType));
+          raw.resize(values.size() * sizeof(MemoryType));
 
           if (!raw.empty())
           {
-            TargetType *p = reinterpret_cast<TargetType*>(&raw[0]);
+            assert(Toolbox::DetectEndianness() == Endianness_Little);  // TODO - Add support for big endian
+
+            MemoryType *p = reinterpret_cast<MemoryType*>(&raw[0]);
 
             for (size_t i = 0; i < values.size(); i++, p++)
             {
-              *p = static_cast<TargetType>(values[i]);
+              *p = static_cast<MemoryType>(values[i]);
             }
           }
 
@@ -459,7 +462,7 @@
 
           for (size_t i = 0; i < values.size(); i++)
           {
-            a.append(values[i]);
+            a.append(static_cast<JsonCppType>(values[i]));
           }
         }
 
@@ -624,15 +627,15 @@
           switch (vr)
           {
             case ValueRepresentation_OtherWord:
-              ApplyBinaryModeToOtherTypes<uint16_t, int64_t>(node, mode, bulkDataUri, values);
+              ApplyBinaryModeToOtherTypes<uint16_t, Json::Value::UInt, int64_t>(node, mode, bulkDataUri, values);
               break;
 
             case ValueRepresentation_OtherLong:
-              ApplyBinaryModeToOtherTypes<uint32_t, int64_t>(node, mode, bulkDataUri, values);
+              ApplyBinaryModeToOtherTypes<uint32_t, Json::Value::UInt, int64_t>(node, mode, bulkDataUri, values);
               break;
 
             case ValueRepresentation_OtherVeryLong:
-              ApplyBinaryModeToOtherTypes<uint64_t, int64_t>(node, mode, bulkDataUri, values);
+              ApplyBinaryModeToOtherTypes<uint64_t, Json::Value::UInt64, int64_t>(node, mode, bulkDataUri, values);
               break;
 
             default:
@@ -700,11 +703,11 @@
           switch (vr)
           {
             case ValueRepresentation_OtherDouble:
-              ApplyBinaryModeToOtherTypes<double, double>(node, mode, bulkDataUri, values);
+              ApplyBinaryModeToOtherTypes<double, double, double>(node, mode, bulkDataUri, values);
               break;
 
             case ValueRepresentation_OtherFloat:
-              ApplyBinaryModeToOtherTypes<float, double>(node, mode, bulkDataUri, values);
+              ApplyBinaryModeToOtherTypes<float, float, double>(node, mode, bulkDataUri, values);
               break;
 
             default:
--- a/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp	Tue Jul 07 11:46:39 2026 +0200
+++ b/OrthancFramework/UnitTestsSources/FromDcmtkTests.cpp	Tue Jul 07 12:02:11 2026 +0200
@@ -2051,7 +2051,7 @@
   dicom.ReplacePlainString(DicomTag(0x0040, 0x0031), "UT");  
 
 #if DCMTK_VERSION_NUMBER >= 365
-  dicom.ReplacePlainString(DicomTag(0x7056, 0x1000), "-17");  // OV
+  dicom.ReplacePlainString(DicomTag(0x7056, 0x1000), "17");  // OV
   dicom.ReplacePlainString(DicomTag(0x7056, 0x1001), "-18");  // SV
   dicom.ReplacePlainString(DicomTag(0x7056, 0x1002), "19");  // UV
 #endif
@@ -2183,7 +2183,7 @@
 
 #if DCMTK_VERSION_NUMBER >= 365
   ASSERT_EQ("OV", visitor.GetResult() ["70561000"]["vr"].asString());
-  ASSERT_EQ(-17, visitor.GetResult() ["70561000"]["Value"][0].asInt());
+  ASSERT_EQ(17, visitor.GetResult() ["70561000"]["Value"][0].asInt());
   ASSERT_EQ("SV", visitor.GetResult() ["70561001"]["vr"].asString());
   ASSERT_EQ(-18, visitor.GetResult() ["70561001"]["Value"][0].asInt());
   ASSERT_EQ("UV", visitor.GetResult() ["70561002"]["vr"].asString());
@@ -2254,7 +2254,7 @@
 #endif    
 
 #if DCMTK_VERSION_NUMBER >= 365
-    ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x7056, 0x1000), true));  ASSERT_EQ("-17", s);  // OV
+    ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x7056, 0x1000), true));  ASSERT_EQ("17", s);  // OV
     ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x7056, 0x1001), true));  ASSERT_EQ("-18", s);  // SV
     ASSERT_TRUE(m.LookupStringValue(s, DicomTag(0x7056, 0x1002), true));  ASSERT_EQ("19", s);  // UV
 #endif