comparison Plugins/Samples/Common/SimplifiedOrthancDataset.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 "SimplifiedOrthancDataset.h" 33 #include "SimplifiedOrthancDataset.h"
34 34
35 #include "OrthancPluginCppWrapper.h" 35 #include "OrthancPluginException.h"
36 36
37 namespace OrthancPlugins 37 namespace OrthancPlugins
38 { 38 {
39 const Json::Value* SimplifiedOrthancDataset::LookupPath(const DicomPath& path) const 39 const Json::Value* SimplifiedOrthancDataset::LookupPath(const DicomPath& path) const
40 { 40 {
43 for (unsigned int depth = 0; depth < path.GetPrefixLength(); depth++) 43 for (unsigned int depth = 0; depth < path.GetPrefixLength(); depth++)
44 { 44 {
45 const char* name = path.GetPrefixTag(depth).GetName(); 45 const char* name = path.GetPrefixTag(depth).GetName();
46 if (content->type() != Json::objectValue) 46 if (content->type() != Json::objectValue)
47 { 47 {
48 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); 48 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
49 } 49 }
50 50
51 if (!content->isMember(name)) 51 if (!content->isMember(name))
52 { 52 {
53 return NULL; 53 return NULL;
54 } 54 }
55 55
56 const Json::Value& sequence = (*content) [name]; 56 const Json::Value& sequence = (*content) [name];
57 if (sequence.type() != Json::arrayValue) 57 if (sequence.type() != Json::arrayValue)
58 { 58 {
59 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); 59 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
60 } 60 }
61 61
62 size_t index = path.GetPrefixIndex(depth); 62 size_t index = path.GetPrefixIndex(depth);
63 if (index >= sequence.size()) 63 if (index >= sequence.size())
64 { 64 {
72 72
73 const char* name = path.GetFinalTag().GetName(); 73 const char* name = path.GetFinalTag().GetName();
74 74
75 if (content->type() != Json::objectValue) 75 if (content->type() != Json::objectValue)
76 { 76 {
77 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); 77 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
78 } 78 }
79 if (!content->isMember(name)) 79 if (!content->isMember(name))
80 { 80 {
81 return NULL; 81 return NULL;
82 } 82 }
89 89
90 void SimplifiedOrthancDataset::CheckRoot() const 90 void SimplifiedOrthancDataset::CheckRoot() const
91 { 91 {
92 if (root_.type() != Json::objectValue) 92 if (root_.type() != Json::objectValue)
93 { 93 {
94 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); 94 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
95 } 95 }
96 } 96 }
97 97
98 98
99 SimplifiedOrthancDataset::SimplifiedOrthancDataset(IOrthancConnection& orthanc, 99 SimplifiedOrthancDataset::SimplifiedOrthancDataset(IOrthancConnection& orthanc,
120 { 120 {
121 return false; 121 return false;
122 } 122 }
123 else if (value->type() != Json::stringValue) 123 else if (value->type() != Json::stringValue)
124 { 124 {
125 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); 125 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
126 } 126 }
127 else 127 else
128 { 128 {
129 result = value->asString(); 129 result = value->asString();
130 return true; 130 return true;
143 return false; 143 return false;
144 } 144 }
145 else if (sequence->type() != Json::arrayValue) 145 else if (sequence->type() != Json::arrayValue)
146 { 146 {
147 // Not a sequence 147 // Not a sequence
148 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_BadFileFormat); 148 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat);
149 } 149 }
150 else 150 else
151 { 151 {
152 size = sequence->size(); 152 size = sequence->size();
153 return true; 153 return true;