Mercurial > hg > orthanc
comparison Plugins/Samples/Common/FullOrthancDataset.cpp @ 2237:403d92d8df83
cont
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 16 Dec 2016 14:45:40 +0100 |
parents | 71b8bec8ca91 |
children | a3a65de1840f |
comparison
equal
deleted
inserted
replaced
2236:55843d0139d3 | 2237:403d92d8df83 |
---|---|
30 **/ | 30 **/ |
31 | 31 |
32 | 32 |
33 #include "FullOrthancDataset.h" | 33 #include "FullOrthancDataset.h" |
34 | 34 |
35 #include "OrthancPluginCppWrapper.h" | 35 #include "OrthancPluginException.h" |
36 | |
37 #include <stdio.h> | |
38 #include <cassert> | |
36 | 39 |
37 namespace OrthancPlugins | 40 namespace OrthancPlugins |
38 { | 41 { |
39 static const Json::Value* AccessTag(const Json::Value& dataset, | 42 static const Json::Value* AccessTag(const Json::Value& dataset, |
40 const DicomTag& tag) | 43 const DicomTag& tag) |
41 { | 44 { |
42 if (dataset.type() != Json::objectValue) | 45 if (dataset.type() != Json::objectValue) |
43 { | 46 { |
44 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); | 47 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); |
45 } | 48 } |
46 | 49 |
47 char name[16]; | 50 char name[16]; |
48 sprintf(name, "%04x,%04x", tag.GetGroup(), tag.GetElement()); | 51 sprintf(name, "%04x,%04x", tag.GetGroup(), tag.GetElement()); |
49 | 52 |
58 !value.isMember("Type") || | 61 !value.isMember("Type") || |
59 !value.isMember("Value") || | 62 !value.isMember("Value") || |
60 value["Name"].type() != Json::stringValue || | 63 value["Name"].type() != Json::stringValue || |
61 value["Type"].type() != Json::stringValue) | 64 value["Type"].type() != Json::stringValue) |
62 { | 65 { |
63 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); | 66 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); |
64 } | 67 } |
65 | 68 |
66 return &value; | 69 return &value; |
67 } | 70 } |
68 | 71 |
76 const Json::Value& value = sequence["Value"]; | 79 const Json::Value& value = sequence["Value"]; |
77 | 80 |
78 if (sequence["Type"].asString() != "Sequence" || | 81 if (sequence["Type"].asString() != "Sequence" || |
79 value.type() != Json::arrayValue) | 82 value.type() != Json::arrayValue) |
80 { | 83 { |
81 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); | 84 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); |
82 } | 85 } |
83 else | 86 else |
84 { | 87 { |
85 return value; | 88 return value; |
86 } | 89 } |
97 const Json::Value& value = tag["Value"]; | 100 const Json::Value& value = tag["Value"]; |
98 | 101 |
99 if (tag["Type"].asString() != "String" || | 102 if (tag["Type"].asString() != "String" || |
100 value.type() != Json::stringValue) | 103 value.type() != Json::stringValue) |
101 { | 104 { |
102 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); | 105 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); |
103 } | 106 } |
104 else | 107 else |
105 { | 108 { |
106 result = value.asString(); | 109 result = value.asString(); |
107 return true; | 110 return true; |
140 | 143 |
141 void FullOrthancDataset::CheckRoot() const | 144 void FullOrthancDataset::CheckRoot() const |
142 { | 145 { |
143 if (root_.type() != Json::objectValue) | 146 if (root_.type() != Json::objectValue) |
144 { | 147 { |
145 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); | 148 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); |
146 } | 149 } |
147 } | 150 } |
148 | 151 |
149 | 152 |
150 FullOrthancDataset::FullOrthancDataset(IOrthancConnection& orthanc, | 153 FullOrthancDataset::FullOrthancDataset(IOrthancConnection& orthanc, |