# HG changeset patch # User Sebastien Jodogne # Date 1421858847 -3600 # Node ID 4287285709d136114e7d6e852ce915d4b6f6a275 # Parent b9e2ed59cae44e6c044f50eb22b7d9905af92150 new functions for initialization diff -r b9e2ed59cae4 -r 4287285709d1 OrthancServer/OrthancInitialization.cpp --- a/OrthancServer/OrthancInitialization.cpp Wed Jan 21 17:32:53 2015 +0100 +++ b/OrthancServer/OrthancInitialization.cpp Wed Jan 21 17:47:27 2015 +0100 @@ -186,6 +186,52 @@ } + static std::string GetStringValue(const Json::Value& configuration, + const std::string& key, + const std::string& defaultValue) + { + if (configuration.type() != Json::objectValue) + { + throw OrthancException(ErrorCode_BadFileFormat); + } + + if (!configuration.isMember(key)) + { + return defaultValue; + } + + if (configuration[key].type() != Json::stringValue) + { + throw OrthancException(ErrorCode_BadFileFormat); + } + + return configuration[key].asString(); + } + + + static int GetIntegerValue(const Json::Value& configuration, + const std::string& key, + int defaultValue) + { + if (configuration.type() != Json::objectValue) + { + throw OrthancException(ErrorCode_BadFileFormat); + } + + if (!configuration.isMember(key)) + { + return defaultValue; + } + + if (configuration[key].type() != Json::intValue) + { + throw OrthancException(ErrorCode_BadFileFormat); + } + + return configuration[key].asInt(); + } + + void OrthancInitialize(const char* configurationFile) { boost::mutex::scoped_lock lock(globalMutex_);