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 150 of file Json2Cool.cxx.
151 cool::Record
a(*pSpec);
152 unsigned int s=
a.size();
154 json::const_iterator
it = j.begin();
155 for (
unsigned int i(0);
i!=
s;++
i){
160 const auto thisVal =
it.value();
167 if (thisVal.is_null()){
173 if(strVal.size()>2&& strVal[0]==
'"'&& strVal[strVal.size()-1]==
'"')
174 strVal=strVal.substr(1,strVal.size()-2);
176 if((strVal.compare(
"NULL")==0||strVal.compare(
"null")==0)&&
177 (typespec==StorageType::Bool || typespec==StorageType::Int16 || typespec==StorageType::UInt16
178 || typespec==StorageType::Int32 || typespec==StorageType::UInt32
179 || typespec==StorageType::Int64 || typespec==StorageType::UInt63
180 || typespec==StorageType::Float || typespec==StorageType::Double)){
185 case StorageType::Bool:
187 const bool newVal=(strVal ==
"true");
188 att.setValue<
bool>(newVal);
191 case StorageType::UChar:
193 const unsigned char newVal=std::stoul(strVal);
194 att.setValue<
unsigned char>(newVal);
197 case StorageType::Int16:
199 const short newVal=std::stol(strVal);
200 att.setValue<
short>(newVal);
203 case StorageType::UInt16:
205 const unsigned short newVal=std::stoul(strVal);
206 att.setValue<
unsigned short>(newVal);
209 case StorageType::Int32:
211 const int newVal=std::stoi(strVal);
212 att.setValue<
int>(newVal);
215 case StorageType::UInt32:
217 const unsigned int newVal=std::stoull(strVal);
218 att.setValue<
unsigned int>(newVal);
221 case StorageType::UInt63:
223 const unsigned long long newVal=std::stoull(strVal);
224 att.setValue<
unsigned long long>(newVal);
227 case StorageType::Int64:
229 const long long newVal=std::stoll(strVal);
230 att.setValue<
long long>(newVal);
233 case StorageType::Float:
235 const float newVal=std::stof(strVal);
236 att.setValue<
float>(newVal);
239 case StorageType::Double:
241 const double newVal=std::stod(strVal);
242 att.setValue<
double>(newVal);
245 case StorageType::String255:
246 case StorageType::String4k:
247 case StorageType::String64k:
248 case StorageType::String16M:
249 case StorageType::String128M:
251 att.setValue<std::string>(thisVal.get<std::string>());
254 case StorageType::Blob128M:
255 case StorageType::Blob16M:
256 case StorageType::Blob64k:
265 for (
auto& [
key,
val] : typeCorrespondance) {
274 std::string errorMessage(
"UNTREATED TYPE! " +
typeName);
275 std::cerr << errorMessage << std::endl;
276 throw std::runtime_error(errorMessage);
282 std::cerr <<
e.what() << std::endl;
283 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;
73 const auto &
payload=(j.contains(
"data")) ? j[
"data"] : j;
83 const std::string& ks=
k.key();
84 const long long key=std::stoll(ks);
85 std::vector<coral::AttributeList> tempVector;
86 for (json::const_iterator
i=
f.begin();
i!=
f.end();++
i){
87 const json& arrayElem=
i.value();
89 const auto & attList=
r.attributeList();
90 tempVector.push_back(attList);
98 const std::string& ks=
i.key();
99 const long long key=std::stoll(ks);
101 const auto & attList=
r.attributeList();
◆ parsePayloadSpec()
cool::RecordSpecification * IOVDbNamespace::Json2Cool::parsePayloadSpec |
( |
const std::string & |
stringSpecification | ) |
|
|
static |
Definition at line 111 of file Json2Cool.cxx.
112 if (stringSpecification.empty())
return nullptr;
113 auto *
spec =
new cool::RecordSpecification();
115 std::string inputObj=stringSpecification;
118 for (
unsigned int i = 0;
i < nl.size();
i++)
121 auto it = nl[
i].items().begin();
122 std::string
n((*it).key());
123 std::string
t((*it).value());
124 spec->extend(
n, typeCorrespondance.find(
t)->second);
130 std::string
input(stringSpecification);
132 std::string
regex=R
"delim(([^\s,:]*):\s?([^\s,]*),?)delim";
138 std::string
n(
what[1]);
139 std::string
t(
what[2]);
141 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: