Mercurial > hg > orthanc
comparison Core/RestApi/RestApiPath.cpp @ 994:b3d4f8a30324 lua-scripting
integration mainline->lua-scripting
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 02 Jul 2014 14:42:49 +0200 |
parents | c550e99c452b |
children | 6e7e5ed91c2d |
comparison
equal
deleted
inserted
replaced
954:a91e7b4080d1 | 994:b3d4f8a30324 |
---|---|
30 **/ | 30 **/ |
31 | 31 |
32 | 32 |
33 #include "../PrecompiledHeaders.h" | 33 #include "../PrecompiledHeaders.h" |
34 #include "RestApiPath.h" | 34 #include "RestApiPath.h" |
35 | |
36 #include "../OrthancException.h" | |
35 | 37 |
36 #include <cassert> | 38 #include <cassert> |
37 | 39 |
38 namespace Orthanc | 40 namespace Orthanc |
39 { | 41 { |
74 components_[i] = ""; | 76 components_[i] = ""; |
75 } | 77 } |
76 } | 78 } |
77 } | 79 } |
78 | 80 |
79 bool RestApiPath::Match(Components& components, | 81 bool RestApiPath::Match(HttpHandler::Arguments& components, |
80 UriComponents& trailing, | 82 UriComponents& trailing, |
81 const std::string& uriRaw) const | 83 const std::string& uriRaw) const |
82 { | 84 { |
83 UriComponents uri; | 85 UriComponents uri; |
84 Toolbox::SplitUriComponents(uri, uriRaw); | 86 Toolbox::SplitUriComponents(uri, uriRaw); |
85 return Match(components, trailing, uri); | 87 return Match(components, trailing, uri); |
86 } | 88 } |
87 | 89 |
88 bool RestApiPath::Match(Components& components, | 90 bool RestApiPath::Match(HttpHandler::Arguments& components, |
89 UriComponents& trailing, | 91 UriComponents& trailing, |
90 const UriComponents& uri) const | 92 const UriComponents& uri) const |
91 { | 93 { |
94 assert(uri_.size() == components_.size()); | |
95 | |
92 if (uri.size() < uri_.size()) | 96 if (uri.size() < uri_.size()) |
93 { | 97 { |
94 return false; | 98 return false; |
95 } | 99 } |
96 | 100 |
129 } | 133 } |
130 | 134 |
131 | 135 |
132 bool RestApiPath::Match(const UriComponents& uri) const | 136 bool RestApiPath::Match(const UriComponents& uri) const |
133 { | 137 { |
134 Components components; | 138 HttpHandler::Arguments components; |
135 UriComponents trailing; | 139 UriComponents trailing; |
136 return Match(components, trailing, uri); | 140 return Match(components, trailing, uri); |
137 } | 141 } |
142 | |
143 | |
144 bool RestApiPath::IsWildcardLevel(size_t level) const | |
145 { | |
146 assert(uri_.size() == components_.size()); | |
147 | |
148 if (level >= uri_.size()) | |
149 { | |
150 throw OrthancException(ErrorCode_ParameterOutOfRange); | |
151 } | |
152 | |
153 return uri_[level].length() == 0; | |
154 } | |
155 | |
156 const std::string& RestApiPath::GetWildcardName(size_t level) const | |
157 { | |
158 assert(uri_.size() == components_.size()); | |
159 | |
160 if (!IsWildcardLevel(level)) | |
161 { | |
162 throw OrthancException(ErrorCode_BadParameterType); | |
163 } | |
164 | |
165 return components_[level]; | |
166 } | |
167 | |
168 const std::string& RestApiPath::GetLevelName(size_t level) const | |
169 { | |
170 assert(uri_.size() == components_.size()); | |
171 | |
172 if (IsWildcardLevel(level)) | |
173 { | |
174 throw OrthancException(ErrorCode_BadParameterType); | |
175 } | |
176 | |
177 return uri_[level]; | |
178 } | |
138 } | 179 } |
180 |