Mercurial > hg > orthanc
comparison OrthancServer/OrthancInitialization.cpp @ 1275:4287285709d1
new functions for initialization
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 21 Jan 2015 17:47:27 +0100 |
parents | b9e2ed59cae4 |
children | 6e7e5ed91c2d |
comparison
equal
deleted
inserted
replaced
1274:b9e2ed59cae4 | 1275:4287285709d1 |
---|---|
184 } | 184 } |
185 } | 185 } |
186 } | 186 } |
187 | 187 |
188 | 188 |
189 static std::string GetStringValue(const Json::Value& configuration, | |
190 const std::string& key, | |
191 const std::string& defaultValue) | |
192 { | |
193 if (configuration.type() != Json::objectValue) | |
194 { | |
195 throw OrthancException(ErrorCode_BadFileFormat); | |
196 } | |
197 | |
198 if (!configuration.isMember(key)) | |
199 { | |
200 return defaultValue; | |
201 } | |
202 | |
203 if (configuration[key].type() != Json::stringValue) | |
204 { | |
205 throw OrthancException(ErrorCode_BadFileFormat); | |
206 } | |
207 | |
208 return configuration[key].asString(); | |
209 } | |
210 | |
211 | |
212 static int GetIntegerValue(const Json::Value& configuration, | |
213 const std::string& key, | |
214 int defaultValue) | |
215 { | |
216 if (configuration.type() != Json::objectValue) | |
217 { | |
218 throw OrthancException(ErrorCode_BadFileFormat); | |
219 } | |
220 | |
221 if (!configuration.isMember(key)) | |
222 { | |
223 return defaultValue; | |
224 } | |
225 | |
226 if (configuration[key].type() != Json::intValue) | |
227 { | |
228 throw OrthancException(ErrorCode_BadFileFormat); | |
229 } | |
230 | |
231 return configuration[key].asInt(); | |
232 } | |
233 | |
234 | |
189 void OrthancInitialize(const char* configurationFile) | 235 void OrthancInitialize(const char* configurationFile) |
190 { | 236 { |
191 boost::mutex::scoped_lock lock(globalMutex_); | 237 boost::mutex::scoped_lock lock(globalMutex_); |
192 | 238 |
193 InitializeServerEnumerations(); | 239 InitializeServerEnumerations(); |