diff Framework/Oracle/ParseDicomFileCommand.cpp @ 1111:3730956f41a5 broker

ParseDicomFileCommand::GetDicomDirPath()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 31 Oct 2019 18:38:26 +0100
parents b82b74d13830
children a08699daf78b
line wrap: on
line diff
--- a/Framework/Oracle/ParseDicomFileCommand.cpp	Thu Oct 31 15:05:46 2019 +0100
+++ b/Framework/Oracle/ParseDicomFileCommand.cpp	Thu Oct 31 18:38:26 2019 +0100
@@ -21,6 +21,10 @@
 
 #include "ParseDicomFileCommand.h"
 
+#include <Core/OrthancException.h>
+
+#include <boost/filesystem/path.hpp>
+
 namespace OrthancStone
 {
   ParseDicomFileCommand::SuccessMessage::SuccessMessage(const ParseDicomFileCommand& command,
@@ -29,4 +33,45 @@
   {
     dicom_.reset(new Orthanc::ParsedDicomFile(content));
   }
+
+
+  Orthanc::ParsedDicomFile& ParseDicomFileCommand::SuccessMessage::GetDicom() const
+  {
+    if (dicom_.get())
+    {
+      return *dicom_;
+    }
+    else
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
+    }
+  }
+
+
+  Orthanc::ParsedDicomFile* ParseDicomFileCommand::SuccessMessage::ReleaseDicom()
+  {
+    if (dicom_.get())
+    {
+      return dicom_.release();
+    }
+    else
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
+    }
+  }
+
+  
+  std::string ParseDicomFileCommand::GetDicomDirPath(const std::string& dicomDirPath,
+                                                     const std::string& file)
+  {
+    std::string tmp = file;
+
+#if !defined(_WIN32)
+    std::replace(tmp.begin(), tmp.end(), '\\', '/');
+#endif
+
+    boost::filesystem::path base = boost::filesystem::path(dicomDirPath).parent_path();
+
+    return (base / tmp).string();
+  }
 }