Mercurial > hg > orthanc
comparison Plugins/Samples/Common/OrthancPluginCppWrapper.cpp @ 2263:b9775db0fd9b
OrthancPlugins::OrthancConfiguration::LookupListOfStrings
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 08 Feb 2017 15:27:20 +0100 |
parents | a3a65de1840f |
children | 8e5e0de75839 |
comparison
equal
deleted
inserted
replaced
2262:6d425452247e | 2263:b9775db0fd9b |
---|---|
555 | 555 |
556 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); | 556 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); |
557 } | 557 } |
558 } | 558 } |
559 | 559 |
560 | |
561 bool OrthancConfiguration::LookupListOfStrings(std::list<std::string>& target, | |
562 const std::string& key) const | |
563 { | |
564 assert(configuration_.type() == Json::objectValue); | |
565 | |
566 target.clear(); | |
567 | |
568 if (!configuration_.isMember(key)) | |
569 { | |
570 return false; | |
571 } | |
572 | |
573 bool ok = true; | |
574 | |
575 if (configuration_[key].type() != Json::arrayValue) | |
576 { | |
577 ok = false; | |
578 } | |
579 else | |
580 { | |
581 for (Json::Value::ArrayIndex i = 0; ok && i < configuration_[key].size(); i++) | |
582 { | |
583 if (configuration_[key][i].type() == Json::stringValue) | |
584 { | |
585 target.push_back(configuration_[key][i].asString()); | |
586 } | |
587 else | |
588 { | |
589 ok = false; | |
590 } | |
591 } | |
592 } | |
593 | |
594 if (ok) | |
595 { | |
596 return true; | |
597 } | |
598 else | |
599 { | |
600 if (context_ != NULL) | |
601 { | |
602 std::string s = ("The configuration option \"" + GetPath(key) + | |
603 "\" is not a list of strings as expected"); | |
604 OrthancPluginLogError(context_, s.c_str()); | |
605 } | |
606 | |
607 ORTHANC_PLUGINS_THROW_EXCEPTION(BadFileFormat); | |
608 } | |
609 } | |
610 | |
560 | 611 |
561 std::string OrthancConfiguration::GetStringValue(const std::string& key, | 612 std::string OrthancConfiguration::GetStringValue(const std::string& key, |
562 const std::string& defaultValue) const | 613 const std::string& defaultValue) const |
563 { | 614 { |
564 std::string tmp; | 615 std::string tmp; |