379 {
380 coral::AttributeList attr(*pSpec,true);
381 unsigned int s=attr.size();
382
383 json::const_iterator
it =
j.begin();
384 for (
unsigned int i(0);
i!=
s;++
i){
385
386
387 auto & att =
const_cast<coral::Attribute&
>(attr[
i]);
389 continue;
390 }
391 const auto thisVal =
it.value();
393
394 try{
395 if (thisVal.is_null()){
396 att.setNull();
397 continue;
398 }
399 cool::StorageType::TypeId typespec=cool::StorageType::Bool;
400 for(auto &p : tSpec){
401 if(
p.first.compare(att.specification().name())==0){
404 throw std::runtime_error("CoralCrestManager::createAttributeList: name not found.");
405 }
406 std::string str_spec = pElement ->second;
407 auto pTypespec = typeCorrespondance.find(str_spec);
408 if (pTypespec == typeCorrespondance.end()){
409 throw std::runtime_error("CoralCrestManager::createAttributeList: typespec not found.");
410 }
411 typespec=pTypespec->second;
412 break;
413 }
414 }
416 if(strVal.size()>2&& strVal[0]=='"'&& strVal[strVal.size()-1]=='"')
417 strVal=strVal.substr(1,strVal.size()-2);
418
419 if((strVal.compare("NULL")==0||strVal.compare("null")==0)&&
420 (typespec==cool::StorageType::Bool || typespec==cool::StorageType::Int16 || typespec==cool::StorageType::UInt16
421 || typespec==cool::StorageType::Int32 || typespec==cool::StorageType::UInt32
422 || typespec==cool::StorageType::Int64 || typespec==cool::StorageType::UInt63
423 || typespec==cool::StorageType::Float || typespec==cool::StorageType::Double)){
424 att.setNull();
425 continue;
426 }
427 switch (typespec) {
428 case cool::StorageType::Bool:
429 {
430 const bool newVal=(strVal == "true");
431 att.setValue<bool>(newVal);
432 break;
433 }
434 case cool::StorageType::UChar:
435 {
436 const unsigned char newVal=std::stoul(strVal);
437 att.setValue<unsigned char>(newVal);
438 break;
439 }
440 case cool::StorageType::Int16:
441 {
442 const short newVal=std::stol(strVal);
443 att.setValue<short>(newVal);
444 break;
445 }
446 case cool::StorageType::UInt16:
447 {
448 const unsigned short newVal=std::stoul(strVal);
449 att.setValue<unsigned short>(newVal);
450 break;
451 }
452 case cool::StorageType::Int32:
453 {
454 const int newVal=std::stoi(strVal);
455 att.setValue<int>(newVal);
456 break;
457 }
458 case cool::StorageType::UInt32:
459 {
460 const unsigned int newVal=std::stoull(strVal);
461 att.setValue<unsigned int>(newVal);
462 break;
463 }
464 case cool::StorageType::UInt63:
465 {
466 const unsigned long long newVal=std::stoull(strVal);
467 att.setValue<unsigned long long>(newVal);
468 break;
469 }
470 case cool::StorageType::Int64:
471 {
472 const long long newVal=std::stoll(strVal);
473 att.setValue< long long>(newVal);
474 break;
475 }
476 case cool::StorageType::Float:
477 {
478 const float newVal=std::stof(strVal);
479 att.setValue<float>(newVal);
480 break;
481 }
482 case cool::StorageType::Double:
483 {
484 const double newVal=std::stod(strVal);
485 att.setValue<double>(newVal);
486 break;
487 }
488 case cool::StorageType::String255:
489 case cool::StorageType::String4k:
490 case cool::StorageType::String64k:
491 case cool::StorageType::String16M:
492 case cool::StorageType::String128M:
493 {
494 att.setValue<std::string>(thisVal.get<std::string>());
495 break;
496 }
497 case cool::StorageType::Blob128M:
498 case cool::StorageType::Blob16M:
499 case cool::StorageType::Blob64k:
500 {
502 coral::Blob
blob(charVec.size());
503 memcpy(
blob.startingAddress(), charVec.data(), charVec.size());
504 att.setValue<coral::Blob>(
blob);
505 break;
506 }
507 default:
508 {
509 std::string errorMessage("UNTREATED TYPE! " + std::to_string(typespec));
511 gLog << MSG::ERROR <<
"LoadPayloadForHash:" <<errorMessage<<
endmsg;
512 throw std::runtime_error(errorMessage);
513 }
514 }
515 }
516 catch (json::exception& e){
518 gLog << MSG::ERROR <<
"Error CoralCrestManager::createAttributeList: "<<
e.what()<<
endmsg;
519 throw std::runtime_error(
e.what());
520 }
521 }
522 return attr;
523 }
IMessageSvc * getMessageSvc(bool quiet=false)
static const std::map< TypeId, std::string > s_typeToString
std::vector< unsigned char > base64_decode(const std::string &)
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)