changeset 213:2a4e1f7de5ab

remove calls to deprecated classes of JsonCpp
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 22 Dec 2020 09:28:30 +0100
parents f1ea48f92d66
children 1e864138f0da
files Applications/Dicomizer.cpp Framework/Inputs/DicomPyramidInstance.cpp
diffstat 2 files changed, 17 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/Dicomizer.cpp	Tue Dec 22 09:19:43 2020 +0100
+++ b/Applications/Dicomizer.cpp	Tue Dec 22 09:28:30 2020 +0100
@@ -37,6 +37,7 @@
 #include <DicomParsing/FromDcmtkBridge.h>
 #include <Logging.h>
 #include <OrthancException.h>
+#include <Toolbox.h>
 #include <SystemToolbox.h>
 
 #include "ApplicationToolbox.h"
@@ -293,8 +294,7 @@
     std::string content;
     Orthanc::SystemToolbox::ReadFile(content, path);
 
-    Json::Reader reader;
-    if (!reader.parse(content, json, false))
+    if (!Orthanc::Toolbox::ReadJsonWithoutComments(json, content))
     {
       LOG(ERROR) << "Cannot parse the JSON file in: " << path;
       throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
@@ -468,8 +468,7 @@
     Orthanc::EmbeddedResources::GetFileResource(brightfield, Orthanc::EmbeddedResources::BRIGHTFIELD_OPTICAL_PATH);
 
     Json::Value json;
-    Json::Reader reader;
-    if (!reader.parse(brightfield, json, false))
+    if (!Orthanc::Toolbox::ReadJsonWithoutComments(json, brightfield))
     {
       throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError);
     }
--- a/Framework/Inputs/DicomPyramidInstance.cpp	Tue Dec 22 09:19:43 2020 +0100
+++ b/Framework/Inputs/DicomPyramidInstance.cpp	Tue Dec 22 09:28:30 2020 +0100
@@ -31,7 +31,6 @@
 #include <Toolbox.h>
 
 #include <cassert>
-#include <json/writer.h>
 
 #define SERIALIZED_METADATA  "4200"
 
@@ -54,7 +53,7 @@
     DicomDatasetReader header(dataset);
 
     std::string s = Orthanc::Toolbox::StripSpaces
-      (header.GetMandatoryStringValue(Orthanc::DICOM_TAG_TRANSFER_SYNTAX_UID));
+      (header.GetMandatoryStringValue(OrthancStone::DicomPath(Orthanc::DICOM_TAG_TRANSFER_SYNTAX_UID)));
 
     if (s == "1.2.840.10008.1.2" ||
         s == "1.2.840.10008.1.2.1")
@@ -85,7 +84,7 @@
     using namespace OrthancStone;
 
     std::string p = Orthanc::Toolbox::StripSpaces
-      (reader.GetMandatoryStringValue(Orthanc::DICOM_TAG_PHOTOMETRIC_INTERPRETATION));
+      (reader.GetMandatoryStringValue(OrthancStone::DicomPath(Orthanc::DICOM_TAG_PHOTOMETRIC_INTERPRETATION)));
     
     photometric = Orthanc::StringToPhotometricInterpretation(p.c_str());
 
@@ -97,9 +96,9 @@
 
     unsigned int bitsStored, samplesPerPixel, tmp;
 
-    if (!reader.GetUnsignedIntegerValue(bitsStored, Orthanc::DICOM_TAG_BITS_STORED) ||
-        !reader.GetUnsignedIntegerValue(samplesPerPixel, Orthanc::DICOM_TAG_SAMPLES_PER_PIXEL) ||
-        !reader.GetUnsignedIntegerValue(tmp, Orthanc::DICOM_TAG_PIXEL_REPRESENTATION))
+    if (!reader.GetUnsignedIntegerValue(bitsStored, OrthancStone::DicomPath(Orthanc::DICOM_TAG_BITS_STORED)) ||
+        !reader.GetUnsignedIntegerValue(samplesPerPixel, OrthancStone::DicomPath(Orthanc::DICOM_TAG_SAMPLES_PER_PIXEL)) ||
+        !reader.GetUnsignedIntegerValue(tmp, OrthancStone::DicomPath(Orthanc::DICOM_TAG_PIXEL_REPRESENTATION)))
     {
       throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentTag);
     }
@@ -154,8 +153,8 @@
     FullOrthancDataset dataset(orthanc, "/instances/" + instanceId + "/tags");
     DicomDatasetReader reader(dataset);
 
-    if (reader.GetMandatoryStringValue(Orthanc::DICOM_TAG_SOP_CLASS_UID) != "1.2.840.10008.5.1.4.1.1.77.1.6" ||
-        reader.GetMandatoryStringValue(Orthanc::DICOM_TAG_MODALITY) != "SM")
+    if (reader.GetMandatoryStringValue(OrthancStone::DicomPath(Orthanc::DICOM_TAG_SOP_CLASS_UID)) != "1.2.840.10008.5.1.4.1.1.77.1.6" ||
+        reader.GetMandatoryStringValue(OrthancStone::DicomPath(Orthanc::DICOM_TAG_MODALITY)) != "SM")
     {
       throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
     }
@@ -164,17 +163,17 @@
     DetectPixelFormat(format_, photometric_, reader);
 
     unsigned int tmp;
-    if (!reader.GetUnsignedIntegerValue(tileWidth_, Orthanc::DICOM_TAG_COLUMNS) ||
-        !reader.GetUnsignedIntegerValue(tileHeight_, Orthanc::DICOM_TAG_ROWS) ||
-        !reader.GetUnsignedIntegerValue(totalWidth_, DICOM_TAG_TOTAL_PIXEL_MATRIX_COLUMNS) ||
-        !reader.GetUnsignedIntegerValue(totalHeight_, DICOM_TAG_TOTAL_PIXEL_MATRIX_ROWS) ||
-        !reader.GetUnsignedIntegerValue(tmp, Orthanc::DICOM_TAG_NUMBER_OF_FRAMES))
+    if (!reader.GetUnsignedIntegerValue(tileWidth_, OrthancStone::DicomPath(Orthanc::DICOM_TAG_COLUMNS)) ||
+        !reader.GetUnsignedIntegerValue(tileHeight_, OrthancStone::DicomPath(Orthanc::DICOM_TAG_ROWS)) ||
+        !reader.GetUnsignedIntegerValue(totalWidth_, OrthancStone::DicomPath(DICOM_TAG_TOTAL_PIXEL_MATRIX_COLUMNS)) ||
+        !reader.GetUnsignedIntegerValue(totalHeight_, OrthancStone::DicomPath(DICOM_TAG_TOTAL_PIXEL_MATRIX_ROWS)) ||
+        !reader.GetUnsignedIntegerValue(tmp, OrthancStone::DicomPath(Orthanc::DICOM_TAG_NUMBER_OF_FRAMES)))
     {
       throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
     }
 
     size_t countFrames;
-    if (!reader.GetDataset().GetSequenceSize(countFrames, DICOM_TAG_PER_FRAME_FUNCTIONAL_GROUPS_SEQUENCE))
+    if (!reader.GetDataset().GetSequenceSize(countFrames, OrthancStone::DicomPath(DICOM_TAG_PER_FRAME_FUNCTIONAL_GROUPS_SEQUENCE)))
     {
       throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
     }
@@ -311,8 +310,7 @@
         throw Orthanc::OrthancException(Orthanc::ErrorCode_NotImplemented);
     }
 
-    Json::FastWriter writer;
-    result = writer.write(content);
+    Orthanc::Toolbox::WriteFastJson(result, content);
   }