Mercurial > hg > orthanc
comparison Plugins/Samples/Common/OrthancPluginCppWrapper.cpp @ 2803:579acc5e5412
OrthancConfiguration::GetDictionary
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 28 Aug 2018 15:14:33 +0200 |
parents | 4df3c64402ba |
children | 473bf302d629 |
comparison
equal
deleted
inserted
replaced
2802:c48ddc902e3e | 2803:579acc5e5412 |
---|---|
777 return defaultValue; | 777 return defaultValue; |
778 } | 778 } |
779 } | 779 } |
780 | 780 |
781 | 781 |
782 void OrthancConfiguration::GetDictionary(std::map<std::string, std::string>& target, | |
783 const std::string& key) const | |
784 { | |
785 assert(configuration_.type() == Json::objectValue); | |
786 | |
787 target.clear(); | |
788 | |
789 if (!configuration_.isMember(key)) | |
790 { | |
791 return; | |
792 } | |
793 | |
794 if (configuration_[key].type() != Json::objectValue) | |
795 { | |
796 if (context_ != NULL) | |
797 { | |
798 std::string s = "The configuration option \"" + GetPath(key) + "\" is not a string as expected"; | |
799 OrthancPluginLogError(context_, s.c_str()); | |
800 } | |
801 | |
802 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); | |
803 } | |
804 | |
805 Json::Value::Members members = configuration_[key].getMemberNames(); | |
806 | |
807 for (size_t i = 0; i < members.size(); i++) | |
808 { | |
809 const Json::Value& value = configuration_[key][members[i]]; | |
810 | |
811 if (value.type() == Json::stringValue) | |
812 { | |
813 target[members[i]] = value.asString(); | |
814 } | |
815 else | |
816 { | |
817 if (context_ != NULL) | |
818 { | |
819 std::string s = "The configuration option \"" + GetPath(key) + "\" is not a dictionary mapping strings to strings"; | |
820 OrthancPluginLogError(context_, s.c_str()); | |
821 } | |
822 | |
823 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); | |
824 } | |
825 } | |
826 } | |
827 | |
828 | |
782 void OrthancImage::Clear() | 829 void OrthancImage::Clear() |
783 { | 830 { |
784 if (image_ != NULL) | 831 if (image_ != NULL) |
785 { | 832 { |
786 OrthancPluginFreeImage(context_, image_); | 833 OrthancPluginFreeImage(context_, image_); |