Mercurial > hg > orthanc-webviewer
changeset 33:d7bd116777eb
Use of OrthancPluginGetConfiguration
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 26 Jun 2015 15:33:08 +0200 |
parents | c6ac4deb303b |
children | 86299731dc4e |
files | Plugin/ViewerToolbox.cpp |
diffstat | 1 files changed, 12 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/Plugin/ViewerToolbox.cpp Wed Jun 24 16:21:47 2015 +0200 +++ b/Plugin/ViewerToolbox.cpp Fri Jun 26 15:33:08 2015 +0200 @@ -27,7 +27,6 @@ #include <zlib.h> #include <stdexcept> #include <boost/lexical_cast.hpp> -#include <fstream> #include <sys/stat.h> namespace OrthancPlugins @@ -216,33 +215,30 @@ bool ReadConfiguration(Json::Value& configuration, OrthancPluginContext* context) { - std::string path; + std::string s; { - char* pathTmp = OrthancPluginGetConfigurationPath(context); - if (pathTmp == NULL) + char* tmp = OrthancPluginGetConfiguration(context); + if (tmp == NULL) { - OrthancPluginLogError(context, "No configuration file is provided"); + OrthancPluginLogError(context, "Error while retrieving the configuration from Orthanc"); return false; } - path = std::string(pathTmp); - - OrthancPluginFreeString(context, pathTmp); + s.assign(tmp); + OrthancPluginFreeString(context, tmp); } - std::ifstream f(path.c_str()); - Json::Reader reader; - if (!reader.parse(f, configuration) || - configuration.type() != Json::objectValue) + if (reader.parse(s, configuration)) { - std::string s = "Unable to parse the configuration file: " + std::string(path); - OrthancPluginLogError(context, s.c_str()); + return true; + } + else + { + OrthancPluginLogError(context, "Unable to parse the configuration"); return false; } - - return true; }