371 unsigned int s=attr.size();
373 json::const_iterator
it = j.begin();
374 for (
unsigned int i(0);
i!=
s;++
i){
377 auto & att =
const_cast<coral::Attribute&
>(attr[
i]);
381 const auto thisVal =
it.value();
385 if (thisVal.is_null()){
390 for(
auto &
p : tSpec){
391 if(
p.first.compare(att.specification().name())==0){
392 auto pElement = Crest::s_typeToString.find(
p.second);
393 if (pElement == Crest::s_typeToString.
end()){
394 throw std::runtime_error(
"CoralCrestManager::createAttributeList: name not found.");
396 std::string str_spec = pElement ->second;
399 throw std::runtime_error(
"CoralCrestManager::createAttributeList: typespec not found.");
401 typespec=pTypespec->second;
406 if(strVal.size()>2&& strVal[0]==
'"'&& strVal[strVal.size()-1]==
'"')
407 strVal=strVal.substr(1,strVal.size()-2);
409 if((strVal.compare(
"NULL")==0||strVal.compare(
"null")==0)&&
410 (typespec==cool::StorageType::Bool || typespec==cool::StorageType::Int16 || typespec==cool::StorageType::UInt16
411 || typespec==cool::StorageType::Int32 || typespec==cool::StorageType::UInt32
412 || typespec==cool::StorageType::Int64 || typespec==cool::StorageType::UInt63
413 || typespec==cool::StorageType::Float || typespec==cool::StorageType::Double)){
418 case cool::StorageType::Bool:
420 const bool newVal=(strVal ==
"true");
421 att.setValue<
bool>(newVal);
424 case cool::StorageType::UChar:
426 const unsigned char newVal=std::stoul(strVal);
427 att.setValue<
unsigned char>(newVal);
430 case cool::StorageType::Int16:
432 const short newVal=std::stol(strVal);
433 att.setValue<
short>(newVal);
436 case cool::StorageType::UInt16:
438 const unsigned short newVal=std::stoul(strVal);
439 att.setValue<
unsigned short>(newVal);
442 case cool::StorageType::Int32:
444 const int newVal=std::stoi(strVal);
445 att.setValue<
int>(newVal);
448 case cool::StorageType::UInt32:
450 const unsigned int newVal=std::stoull(strVal);
451 att.setValue<
unsigned int>(newVal);
454 case cool::StorageType::UInt63:
456 const unsigned long long newVal=std::stoull(strVal);
457 att.setValue<
unsigned long long>(newVal);
460 case cool::StorageType::Int64:
462 const long long newVal=std::stoll(strVal);
463 att.setValue<
long long>(newVal);
466 case cool::StorageType::Float:
468 const float newVal=std::stof(strVal);
469 att.setValue<
float>(newVal);
472 case cool::StorageType::Double:
474 const double newVal=std::stod(strVal);
475 att.setValue<
double>(newVal);
478 case cool::StorageType::String255:
479 case cool::StorageType::String4k:
480 case cool::StorageType::String64k:
481 case cool::StorageType::String16M:
482 case cool::StorageType::String128M:
484 att.setValue<std::string>(thisVal.get<std::string>());
487 case cool::StorageType::Blob128M:
488 case cool::StorageType::Blob16M:
489 case cool::StorageType::Blob64k:
493 memcpy(
blob.startingAddress(), charVec.data(), charVec.size());
499 std::string errorMessage(
"UNTREATED TYPE! " +
std::to_string(typespec));
501 gLog << MSG::ERROR <<
"LoadPayloadForHash:" <<errorMessage<<
endmsg;
502 throw std::runtime_error(errorMessage);
508 gLog << MSG::ERROR <<
"Error CoralCrestManager::createAttributeList: "<<
e.what()<<
endmsg;
509 throw std::runtime_error(
e.what());