comparison 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
comparison
equal deleted inserted replaced
2822:a0b729ac0549 2823:807169f85ba9
1286 1286
1287 1287
1288 1288
1289 1289
1290 #if HAS_ORTHANC_PLUGIN_PEERS == 1 1290 #if HAS_ORTHANC_PLUGIN_PEERS == 1
1291 size_t OrthancPeers::GetPeerIndex(const std::string& name) const
1292 {
1293 size_t index;
1294 if (LookupName(index, name))
1295 {
1296 return index;
1297 }
1298 else
1299 {
1300 std::string s = "Inexistent peer: " + name;
1301 OrthancPluginLogError(context_, s.c_str());
1302 ORTHANC_PLUGINS_THROW_EXCEPTION(UnknownResource);
1303 }
1304 }
1305
1306
1291 OrthancPeers::OrthancPeers(OrthancPluginContext* context) : 1307 OrthancPeers::OrthancPeers(OrthancPluginContext* context) :
1292 context_(context), 1308 context_(context),
1293 peers_(NULL), 1309 peers_(NULL),
1294 timeout_(0) 1310 timeout_(0)
1295 { 1311 {
1389 } 1405 }
1390 1406
1391 1407
1392 std::string OrthancPeers::GetPeerUrl(const std::string& name) const 1408 std::string OrthancPeers::GetPeerUrl(const std::string& name) const
1393 { 1409 {
1394 size_t index; 1410 return GetPeerUrl(GetPeerIndex(name));
1395 if (LookupName(index, name)) 1411 }
1396 { 1412
1397 return GetPeerUrl(index); 1413
1398 } 1414 bool OrthancPeers::LookupUserProperty(std::string& value,
1399 else 1415 size_t index,
1400 { 1416 const std::string& key) const
1401 std::string s = "Inexistent peer: " + name; 1417 {
1402 OrthancPluginLogError(context_, s.c_str()); 1418 if (index >= index_.size())
1403 ORTHANC_PLUGINS_THROW_EXCEPTION(UnknownResource); 1419 {
1404 } 1420 ORTHANC_PLUGINS_THROW_PLUGIN_ERROR_CODE(OrthancPluginErrorCode_ParameterOutOfRange);
1421 }
1422 else
1423 {
1424 const char* s = OrthancPluginGetPeerUserProperty(context_, peers_, static_cast<uint32_t>(index), key.c_str());
1425 if (s == NULL)
1426 {
1427 return false;
1428 }
1429 else
1430 {
1431 value.assign(s);
1432 return true;
1433 }
1434 }
1435 }
1436
1437
1438 bool OrthancPeers::LookupUserProperty(std::string& value,
1439 const std::string& peer,
1440 const std::string& key) const
1441 {
1442 return LookupUserProperty(value, GetPeerIndex(peer), key);
1405 } 1443 }
1406 1444
1407 1445
1408 bool OrthancPeers::DoGet(MemoryBuffer& target, 1446 bool OrthancPeers::DoGet(MemoryBuffer& target,
1409 size_t index, 1447 size_t index,