Produces cool objects from their JSON representation, storing them in a 'BasicFolder'.
More...
#include <Json2Cool.h>
Produces cool objects from their JSON representation, storing them in a 'BasicFolder'.
Definition at line 28 of file Json2Cool.h.
◆ Json2Cool()
◆ ~Json2Cool()
IOVDbNamespace::Json2Cool::~Json2Cool |
( |
| ) |
|
|
default |
◆ createAttributeList()
cool::Record IOVDbNamespace::Json2Cool::createAttributeList |
( |
cool::RecordSpecification * |
pSpec, |
|
|
const nlohmann::json & |
j |
|
) |
| |
|
static |
Definition at line 137 of file Json2Cool.cxx.
138 cool::Record
a(*pSpec);
139 unsigned int s=
a.size();
141 json::const_iterator
it = j.begin();
142 for (
unsigned int i(0);
i!=
s;++
i){
147 const auto thisVal =
it.value();
154 if (thisVal.is_null()){
158 cool::StorageType::TypeId typespec =
f.storageType().id();
160 if(strVal.size()>2&& strVal[0]==
'"'&& strVal[strVal.size()-1]==
'"')
161 strVal=strVal.substr(1,strVal.size()-2);
163 if((strVal.compare(
"NULL")==0||strVal.compare(
"null")==0)&&
164 (typespec==StorageType::Bool || typespec==StorageType::Int16 || typespec==StorageType::UInt16
165 || typespec==StorageType::Int32 || typespec==StorageType::UInt32
166 || typespec==StorageType::Int64 || typespec==StorageType::UInt63
167 || typespec==StorageType::Float || typespec==StorageType::Double)){
172 case StorageType::Bool:
174 const bool newVal=(strVal ==
"true");
175 att.setValue<
bool>(newVal);
178 case StorageType::UChar:
180 const unsigned char newVal=std::stoul(strVal);
181 att.setValue<
unsigned char>(newVal);
184 case StorageType::Int16:
186 const short newVal=std::stol(strVal);
187 att.setValue<
short>(newVal);
190 case StorageType::UInt16:
192 const unsigned short newVal=std::stoul(strVal);
193 att.setValue<
unsigned short>(newVal);
196 case StorageType::Int32:
198 const int newVal=std::stoi(strVal);
199 att.setValue<
int>(newVal);
202 case StorageType::UInt32:
204 const unsigned int newVal=std::stoull(strVal);
205 att.setValue<
unsigned int>(newVal);
208 case StorageType::UInt63:
210 const unsigned long long newVal=std::stoull(strVal);
211 att.setValue<
unsigned long long>(newVal);
214 case StorageType::Int64:
216 const long long newVal=std::stoll(strVal);
217 att.setValue<
long long>(newVal);
220 case StorageType::Float:
222 const float newVal=std::stof(strVal);
223 att.setValue<
float>(newVal);
226 case StorageType::Double:
228 const double newVal=std::stod(strVal);
229 att.setValue<
double>(newVal);
232 case StorageType::String255:
233 case StorageType::String4k:
234 case StorageType::String64k:
235 case StorageType::String16M:
236 case StorageType::String128M:
238 att.setValue<std::string>(thisVal.get<std::string>());
241 case StorageType::Blob128M:
242 case StorageType::Blob16M:
243 case StorageType::Blob64k:
252 for (
auto& [
key,
val] : typeCorrespondance) {
261 std::string errorMessage(
"UNTREATED TYPE! " +
typeName);
262 std::cerr << errorMessage << std::endl;
263 throw std::runtime_error(errorMessage);
269 std::cerr <<
e.what() << std::endl;
270 throw std::runtime_error(
e.what());
◆ init()
Definition at line 60 of file Json2Cool.cxx.
61 if (not
s.good() or
s.eof()){
62 const std::string
msg(
"Json2Cool constructor; Input is invalid and could not be opened.");
63 throw std::runtime_error(
msg);
69 std::cout<<
"ERROR AT LINE "<<__LINE__<<
" of "<<__FILE__<<std::endl;
70 std::cout<<
e.what()<<std::endl;
86 const std::string& ks=
k.key();
87 const long long key=std::stoll(ks);
88 std::vector<coral::AttributeList> tempVector;
89 for (json::const_iterator
i=
f.begin();
i!=
f.end();++
i){
90 const json& arrayElem=
i.value();
92 const auto & attList=
r.attributeList();
93 tempVector.push_back(attList);
101 const std::string& ks=
i.key();
102 const long long key=std::stoll(ks);
104 const auto & attList=
r.attributeList();
◆ parsePayloadSpec()
cool::RecordSpecification * IOVDbNamespace::Json2Cool::parsePayloadSpec |
( |
const std::string & |
stringSpecification | ) |
|
|
static |
Definition at line 114 of file Json2Cool.cxx.
115 if (stringSpecification.empty())
return nullptr;
116 std::string
input(stringSpecification);
117 auto *
spec =
new cool::RecordSpecification();
119 std::string
regex=R
"delim(([^\s,:]*):\s?([^\s,]*),?)delim";
125 std::string
n(
what[1]);
126 std::string
t(
what[2]);
128 spec->extend(
n, typeCorrespondance.find(
t)->second);
◆ m_basicFolder
◆ m_sharedSpec
cool::RecordSpecification* IOVDbNamespace::Json2Cool::m_sharedSpec = nullptr |
|
private |
The documentation for this class was generated from the following files: