374 unsigned int s=attr.size();
376 json::const_iterator
it = j.begin();
377 for (
unsigned int i(0);
i!=
s;++
i){
380 auto & att =
const_cast<coral::Attribute&
>(attr[
i]);
384 const auto thisVal =
it.value();
388 if (thisVal.is_null()){
393 for(
auto &
p : tSpec){
394 if(
p.first.compare(att.specification().name())==0){
395 auto pElement = Crest::s_typeToString.find(
p.second);
396 if (pElement == Crest::s_typeToString.
end()){
397 throw std::runtime_error(
"CoralCrestManager::createAttributeList: name not found.");
399 std::string str_spec = pElement ->second;
402 throw std::runtime_error(
"CoralCrestManager::createAttributeList: typespec not found.");
404 typespec=pTypespec->second;
409 if(strVal.size()>2&& strVal[0]==
'"'&& strVal[strVal.size()-1]==
'"')
410 strVal=strVal.substr(1,strVal.size()-2);
412 if((strVal.compare(
"NULL")==0||strVal.compare(
"null")==0)&&
413 (typespec==cool::StorageType::Bool || typespec==cool::StorageType::Int16 || typespec==cool::StorageType::UInt16
414 || typespec==cool::StorageType::Int32 || typespec==cool::StorageType::UInt32
415 || typespec==cool::StorageType::Int64 || typespec==cool::StorageType::UInt63
421 case cool::StorageType::Bool:
423 const bool newVal=(strVal ==
"true");
424 att.setValue<
bool>(newVal);
427 case cool::StorageType::UChar:
429 const unsigned char newVal=std::stoul(strVal);
430 att.setValue<
unsigned char>(newVal);
433 case cool::StorageType::Int16:
435 const short newVal=std::stol(strVal);
436 att.setValue<
short>(newVal);
439 case cool::StorageType::UInt16:
441 const unsigned short newVal=std::stoul(strVal);
442 att.setValue<
unsigned short>(newVal);
445 case cool::StorageType::Int32:
447 const int newVal=std::stoi(strVal);
448 att.setValue<
int>(newVal);
451 case cool::StorageType::UInt32:
453 const unsigned int newVal=std::stoull(strVal);
454 att.setValue<
unsigned int>(newVal);
457 case cool::StorageType::UInt63:
459 const unsigned long long newVal=std::stoull(strVal);
460 att.setValue<
unsigned long long>(newVal);
463 case cool::StorageType::Int64:
465 const long long newVal=std::stoll(strVal);
466 att.setValue<
long long>(newVal);
471 const float newVal=std::stof(strVal);
472 att.setValue<
float>(newVal);
475 case cool::StorageType::Double:
477 const double newVal=std::stod(strVal);
478 att.setValue<
double>(newVal);
481 case cool::StorageType::String255:
482 case cool::StorageType::String4k:
483 case cool::StorageType::String64k:
484 case cool::StorageType::String16M:
485 case cool::StorageType::String128M:
487 att.setValue<std::string>(thisVal.get<std::string>());
490 case cool::StorageType::Blob128M:
491 case cool::StorageType::Blob16M:
492 case cool::StorageType::Blob64k:
496 memcpy(
blob.startingAddress(), charVec.data(), charVec.size());
502 std::string errorMessage(
"UNTREATED TYPE! " +
std::to_string(typespec));
504 gLog << MSG::ERROR <<
"LoadPayloadForHash:" <<errorMessage<<
endmsg;
505 throw std::runtime_error(errorMessage);
511 gLog << MSG::ERROR <<
"Error CoralCrestManager::createAttributeList: "<<
e.what()<<
endmsg;
512 throw std::runtime_error(
e.what());