comparison Resources/Orthanc/Plugins/Samples/Common/DicomDatasetReader.cpp @ 86:319b8c45c231

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 16 Dec 2016 14:55:19 +0100
parents cd84f27bc8e2
children 3d83d34cd4db
comparison
equal deleted inserted replaced
85:8a20cd67b283 86:319b8c45c231
30 **/ 30 **/
31 31
32 32
33 #include "DicomDatasetReader.h" 33 #include "DicomDatasetReader.h"
34 34
35 #include "OrthancPluginCppWrapper.h" 35 #include "OrthancPluginException.h"
36 36
37 #include <boost/lexical_cast.hpp> 37 #include <boost/lexical_cast.hpp>
38 38
39 namespace OrthancPlugins 39 namespace OrthancPlugins
40 { 40 {
71 DicomDatasetReader::DicomDatasetReader(IDicomDataset* dataset) : // takes ownership 71 DicomDatasetReader::DicomDatasetReader(IDicomDataset* dataset) : // takes ownership
72 dataset_(dataset) 72 dataset_(dataset)
73 { 73 {
74 if (dataset == NULL) 74 if (dataset == NULL)
75 { 75 {
76 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); 76 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange);
77 } 77 }
78 } 78 }
79 79
80 80
81 std::string DicomDatasetReader::GetMandatoryStringValue(const DicomPath& path) const 81 std::string DicomDatasetReader::GetMandatoryStringValue(const DicomPath& path) const
85 { 85 {
86 return s; 86 return s;
87 } 87 }
88 else 88 else
89 { 89 {
90 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_InexistentTag); 90 ORTHANC_PLUGINS_THROW_EXCEPTION(InexistentTag);
91 } 91 }
92 } 92 }
93 93
94 94
95 int DicomDatasetReader::GetIntegerValue(const DicomPath& path) 95 int DicomDatasetReader::GetIntegerValue(const DicomPath& path)
99 std::string s = StripSpaces(GetMandatoryStringValue(path)); 99 std::string s = StripSpaces(GetMandatoryStringValue(path));
100 return boost::lexical_cast<int>(s); 100 return boost::lexical_cast<int>(s);
101 } 101 }
102 catch (boost::bad_lexical_cast&) 102 catch (boost::bad_lexical_cast&)
103 { 103 {
104 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); 104 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
105 } 105 }
106 } 106 }
107 107
108 108
109 unsigned int DicomDatasetReader::GetUnsignedIntegerValue(const DicomPath& path) 109 unsigned int DicomDatasetReader::GetUnsignedIntegerValue(const DicomPath& path)
114 { 114 {
115 return static_cast<unsigned int>(value); 115 return static_cast<unsigned int>(value);
116 } 116 }
117 else 117 else
118 { 118 {
119 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_ParameterOutOfRange); 119 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange);
120 } 120 }
121 } 121 }
122 } 122 }