comparison Core/RestApi/RestApi.cpp @ 656:08eca5d86aad

fixes to cppcheck
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 04 Nov 2013 11:19:31 +0100
parents 6f8ae46ed90e
children 443cced10836
comparison
equal deleted inserted replaced
655:93adc693cc60 656:08eca5d86aad
49 bool RestApi::GetCall::ParseJsonRequest(Json::Value& result) const 49 bool RestApi::GetCall::ParseJsonRequest(Json::Value& result) const
50 { 50 {
51 result.clear(); 51 result.clear();
52 52
53 for (HttpHandler::Arguments::const_iterator 53 for (HttpHandler::Arguments::const_iterator
54 it = getArguments_->begin(); it != getArguments_->end(); it++) 54 it = getArguments_->begin(); it != getArguments_->end(); ++it)
55 { 55 {
56 result[it->first] = it->second; 56 result[it->first] = it->second;
57 } 57 }
58 58
59 return true; 59 return true;
61 61
62 62
63 bool RestApi::IsGetAccepted(const UriComponents& uri) 63 bool RestApi::IsGetAccepted(const UriComponents& uri)
64 { 64 {
65 for (GetHandlers::const_iterator it = getHandlers_.begin(); 65 for (GetHandlers::const_iterator it = getHandlers_.begin();
66 it != getHandlers_.end(); it++) 66 it != getHandlers_.end(); ++it)
67 { 67 {
68 if (it->first->Match(uri)) 68 if (it->first->Match(uri))
69 { 69 {
70 return true; 70 return true;
71 } 71 }
75 } 75 }
76 76
77 bool RestApi::IsPutAccepted(const UriComponents& uri) 77 bool RestApi::IsPutAccepted(const UriComponents& uri)
78 { 78 {
79 for (PutHandlers::const_iterator it = putHandlers_.begin(); 79 for (PutHandlers::const_iterator it = putHandlers_.begin();
80 it != putHandlers_.end(); it++) 80 it != putHandlers_.end(); ++it)
81 { 81 {
82 if (it->first->Match(uri)) 82 if (it->first->Match(uri))
83 { 83 {
84 return true; 84 return true;
85 } 85 }
89 } 89 }
90 90
91 bool RestApi::IsPostAccepted(const UriComponents& uri) 91 bool RestApi::IsPostAccepted(const UriComponents& uri)
92 { 92 {
93 for (PostHandlers::const_iterator it = postHandlers_.begin(); 93 for (PostHandlers::const_iterator it = postHandlers_.begin();
94 it != postHandlers_.end(); it++) 94 it != postHandlers_.end(); ++it)
95 { 95 {
96 if (it->first->Match(uri)) 96 if (it->first->Match(uri))
97 { 97 {
98 return true; 98 return true;
99 } 99 }
103 } 103 }
104 104
105 bool RestApi::IsDeleteAccepted(const UriComponents& uri) 105 bool RestApi::IsDeleteAccepted(const UriComponents& uri)
106 { 106 {
107 for (DeleteHandlers::const_iterator it = deleteHandlers_.begin(); 107 for (DeleteHandlers::const_iterator it = deleteHandlers_.begin();
108 it != deleteHandlers_.end(); it++) 108 it != deleteHandlers_.end(); ++it)
109 { 109 {
110 if (it->first->Match(uri)) 110 if (it->first->Match(uri))
111 { 111 {
112 return true; 112 return true;
113 } 113 }
145 } 145 }
146 146
147 RestApi::~RestApi() 147 RestApi::~RestApi()
148 { 148 {
149 for (GetHandlers::iterator it = getHandlers_.begin(); 149 for (GetHandlers::iterator it = getHandlers_.begin();
150 it != getHandlers_.end(); it++) 150 it != getHandlers_.end(); ++it)
151 { 151 {
152 delete it->first; 152 delete it->first;
153 } 153 }
154 154
155 for (PutHandlers::iterator it = putHandlers_.begin(); 155 for (PutHandlers::iterator it = putHandlers_.begin();
156 it != putHandlers_.end(); it++) 156 it != putHandlers_.end(); ++it)
157 { 157 {
158 delete it->first; 158 delete it->first;
159 } 159 }
160 160
161 for (PostHandlers::iterator it = postHandlers_.begin(); 161 for (PostHandlers::iterator it = postHandlers_.begin();
162 it != postHandlers_.end(); it++) 162 it != postHandlers_.end(); ++it)
163 { 163 {
164 delete it->first; 164 delete it->first;
165 } 165 }
166 166
167 for (DeleteHandlers::iterator it = deleteHandlers_.begin(); 167 for (DeleteHandlers::iterator it = deleteHandlers_.begin();
168 it != deleteHandlers_.end(); it++) 168 it != deleteHandlers_.end(); ++it)
169 { 169 {
170 delete it->first; 170 delete it->first;
171 } 171 }
172 } 172 }
173 173
192 UriComponents trailing; 192 UriComponents trailing;
193 193
194 if (method == HttpMethod_Get) 194 if (method == HttpMethod_Get)
195 { 195 {
196 for (GetHandlers::const_iterator it = getHandlers_.begin(); 196 for (GetHandlers::const_iterator it = getHandlers_.begin();
197 it != getHandlers_.end(); it++) 197 it != getHandlers_.end(); ++it)
198 { 198 {
199 if (it->first->Match(components, trailing, uri)) 199 if (it->first->Match(components, trailing, uri))
200 { 200 {
201 //LOG(INFO) << "REST GET call on: " << Toolbox::FlattenUri(uri); 201 //LOG(INFO) << "REST GET call on: " << Toolbox::FlattenUri(uri);
202 ok = true; 202 ok = true;
214 } 214 }
215 } 215 }
216 else if (method == HttpMethod_Put) 216 else if (method == HttpMethod_Put)
217 { 217 {
218 for (PutHandlers::const_iterator it = putHandlers_.begin(); 218 for (PutHandlers::const_iterator it = putHandlers_.begin();
219 it != putHandlers_.end(); it++) 219 it != putHandlers_.end(); ++it)
220 { 220 {
221 if (it->first->Match(components, trailing, uri)) 221 if (it->first->Match(components, trailing, uri))
222 { 222 {
223 //LOG(INFO) << "REST PUT call on: " << Toolbox::FlattenUri(uri); 223 //LOG(INFO) << "REST PUT call on: " << Toolbox::FlattenUri(uri);
224 ok = true; 224 ok = true;
236 } 236 }
237 } 237 }
238 else if (method == HttpMethod_Post) 238 else if (method == HttpMethod_Post)
239 { 239 {
240 for (PostHandlers::const_iterator it = postHandlers_.begin(); 240 for (PostHandlers::const_iterator it = postHandlers_.begin();
241 it != postHandlers_.end(); it++) 241 it != postHandlers_.end(); ++it)
242 { 242 {
243 if (it->first->Match(components, trailing, uri)) 243 if (it->first->Match(components, trailing, uri))
244 { 244 {
245 //LOG(INFO) << "REST POST call on: " << Toolbox::FlattenUri(uri); 245 //LOG(INFO) << "REST POST call on: " << Toolbox::FlattenUri(uri);
246 ok = true; 246 ok = true;
258 } 258 }
259 } 259 }
260 else if (method == HttpMethod_Delete) 260 else if (method == HttpMethod_Delete)
261 { 261 {
262 for (DeleteHandlers::const_iterator it = deleteHandlers_.begin(); 262 for (DeleteHandlers::const_iterator it = deleteHandlers_.begin();
263 it != deleteHandlers_.end(); it++) 263 it != deleteHandlers_.end(); ++it)
264 { 264 {
265 if (it->first->Match(components, trailing, uri)) 265 if (it->first->Match(components, trailing, uri))
266 { 266 {
267 //LOG(INFO) << "REST DELETE call on: " << Toolbox::FlattenUri(uri); 267 //LOG(INFO) << "REST DELETE call on: " << Toolbox::FlattenUri(uri);
268 ok = true; 268 ok = true;