Mercurial > hg > orthanc
diff Plugins/Samples/Common/OrthancPluginCppWrapper.cpp @ 2823:807169f85ba9
OrthancPluginGetPeerUserProperty()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 18 Sep 2018 15:38:18 +0200 |
parents | a0b729ac0549 |
children | dd3914a44b87 |
line wrap: on
line diff
--- a/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Mon Sep 17 12:08:49 2018 +0200 +++ b/Plugins/Samples/Common/OrthancPluginCppWrapper.cpp Tue Sep 18 15:38:18 2018 +0200 @@ -1288,6 +1288,22 @@ #if HAS_ORTHANC_PLUGIN_PEERS == 1 + size_t OrthancPeers::GetPeerIndex(const std::string& name) const + { + size_t index; + if (LookupName(index, name)) + { + return index; + } + else + { + std::string s = "Inexistent peer: " + name; + OrthancPluginLogError(context_, s.c_str()); + ORTHANC_PLUGINS_THROW_EXCEPTION(UnknownResource); + } + } + + OrthancPeers::OrthancPeers(OrthancPluginContext* context) : context_(context), peers_(NULL), @@ -1391,20 +1407,42 @@ std::string OrthancPeers::GetPeerUrl(const std::string& name) const { - size_t index; - if (LookupName(index, name)) + return GetPeerUrl(GetPeerIndex(name)); + } + + + bool OrthancPeers::LookupUserProperty(std::string& value, + size_t index, + const std::string& key) const + { + if (index >= index_.size()) { - return GetPeerUrl(index); + ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange); } else { - std::string s = "Inexistent peer: " + name; - OrthancPluginLogError(context_, s.c_str()); - ORTHANC_PLUGINS_THROW_EXCEPTION(UnknownResource); + const char* s = OrthancPluginGetPeerUserProperty(context_, peers_, static_cast<uint32_t>(index), key.c_str()); + if (s == NULL) + { + return false; + } + else + { + value.assign(s); + return true; + } } } + bool OrthancPeers::LookupUserProperty(std::string& value, + const std::string& peer, + const std::string& key) const + { + return LookupUserProperty(value, GetPeerIndex(peer), key); + } + + bool OrthancPeers::DoGet(MemoryBuffer& target, size_t index, const std::string& uri) const