Mercurial > hg > orthanc
comparison OrthancServer/OrthancFindRequestHandler.cpp @ 610:5ba825b87b21 find-move-scp
fix static build
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 18 Oct 2013 10:32:12 +0200 |
parents | 0bedf8ff9288 |
children | 9924aec1d694 |
comparison
equal
deleted
inserted
replaced
608:0bedf8ff9288 | 610:5ba825b87b21 |
---|---|
37 #include "../Core/DicomFormat/DicomArray.h" | 37 #include "../Core/DicomFormat/DicomArray.h" |
38 #include "ServerToolbox.h" | 38 #include "ServerToolbox.h" |
39 | 39 |
40 namespace Orthanc | 40 namespace Orthanc |
41 { | 41 { |
42 static std::string ToLowerCase(const std::string& s) | |
43 { | |
44 std::string result = s; | |
45 Toolbox::ToLowerCase(result); | |
46 return result; | |
47 } | |
48 | |
42 static bool ApplyRangeConstraint(const std::string& value, | 49 static bool ApplyRangeConstraint(const std::string& value, |
43 const std::string& constraint) | 50 const std::string& constraint) |
44 { | 51 { |
45 // TODO | 52 size_t separator = constraint.find('-'); |
46 return false; | 53 std::string lower = ToLowerCase(constraint.substr(0, separator)); |
54 std::string upper = ToLowerCase(constraint.substr(separator + 1)); | |
55 std::string v = ToLowerCase(value); | |
56 | |
57 if (lower.size() == 0 && upper.size() == 0) | |
58 { | |
59 return false; | |
60 } | |
61 | |
62 if (lower.size() == 0) | |
63 { | |
64 return v <= upper; | |
65 } | |
66 | |
67 if (upper.size() == 0) | |
68 { | |
69 return v >= lower; | |
70 } | |
71 | |
72 return (v >= lower && v <= upper); | |
47 } | 73 } |
48 | 74 |
49 | 75 |
50 static bool ApplyListConstraint(const std::string& value, | 76 static bool ApplyListConstraint(const std::string& value, |
51 const std::string& constraint) | 77 const std::string& constraint) |
52 { | 78 { |
53 std::cout << value << std::endl; | 79 std::cout << value << std::endl; |
54 | 80 |
55 std::string v1 = value; | 81 std::string v1 = ToLowerCase(value); |
56 Toolbox::ToLowerCase(v1); | |
57 | 82 |
58 std::vector<std::string> items; | 83 std::vector<std::string> items; |
59 Toolbox::TokenizeString(items, constraint, '\\'); | 84 Toolbox::TokenizeString(items, constraint, '\\'); |
60 | 85 |
61 for (size_t i = 0; i < items.size(); i++) | 86 for (size_t i = 0; i < items.size(); i++) |
95 boost::regex::icase /* case insensitive search */); | 120 boost::regex::icase /* case insensitive search */); |
96 return boost::regex_match(value, pattern); | 121 return boost::regex_match(value, pattern); |
97 } | 122 } |
98 else | 123 else |
99 { | 124 { |
100 std::string v1 = value; | 125 return ToLowerCase(value) == ToLowerCase(constraint); |
101 std::string v2 = constraint; | |
102 | |
103 Toolbox::ToLowerCase(v1); | |
104 Toolbox::ToLowerCase(v2); | |
105 | |
106 return v1 == v2; | |
107 } | 126 } |
108 } | 127 } |
109 | 128 |
110 | 129 |
111 static bool LookupOneInstance(std::string& result, | 130 static bool LookupOneInstance(std::string& result, |
148 { | 167 { |
149 continue; | 168 continue; |
150 } | 169 } |
151 | 170 |
152 std::string tag = query.GetElement(i).GetTag().Format(); | 171 std::string tag = query.GetElement(i).GetTag().Format(); |
153 std::cout << tag << std::endl; | |
154 | |
155 std::string value; | 172 std::string value; |
156 if (resource.isMember(tag)) | 173 if (resource.isMember(tag)) |
157 { | 174 { |
158 value = resource.get(tag, Json::arrayValue).get("Value", "").asString(); | 175 value = resource.get(tag, Json::arrayValue).get("Value", "").asString(); |
159 } | 176 } |
177 | |
178 std::cout << tag << " " << value << std::endl; | |
160 | 179 |
161 if (!Matches(value, query.GetElement(i).GetValue().AsString())) | 180 if (!Matches(value, query.GetElement(i).GetValue().AsString())) |
162 { | 181 { |
163 return false; | 182 return false; |
164 } | 183 } |