8#include "GaudiKernel/MsgStream.h"
20 std::string::size_type iofs=0;
21 std::string::size_type len=input.size();
22 while (iofs!=std::string::npos && iofs<len) {
24 std::string::size_type iofs1=input.find(
'<',iofs);
25 if (iofs1>iofs && iofs1!=std::string::npos) {
29 if (iofs1!=std::string::npos) {
32 std::string::size_type iofs2=input.find(
'>',iofs1);
33 std::string::size_type iofs3=input.find(
"/>",iofs1);
34 bool noClosingTag = (iofs2 == std::string::npos);
37 "Badly formed XML string, no closing tag in " << input <<
endmsg;
39 iofs=std::string::npos;
42 if (iofs2!=std::string::npos && iofs2<iofs3) {
46 std::string::size_type iofs4=input.find(
"</"+
tag,iofs2+1);
47 if (iofs4!=std::string::npos) {
51 iofs=input.find(
'>',iofs4);
52 if (iofs == std::string::npos) {
54 "Badly formed XML string, no closing tag in " << input <<
endmsg;
56 iofs=std::string::npos;
63 "Badly formed XML string, no closing tag in " << input <<
endmsg;
65 iofs=std::string::npos;
68 }
else if (iofs3!=std::string::npos) {
71 std::string::size_type iofs4=input.find(
' ',iofs1+1);
72 std::string value,
tag;
73 if (iofs4!=std::string::npos && iofs4<iofs3) {
77 tag=input.substr(iofs1+1,iofs3-iofs1-1);
85 log << MSG::FATAL <<
"Badly formed XML string, no closing > in input " <<
87 iofs=std::string::npos;
98 if (log.level()<=MSG::VERBOSE) {
99 log << MSG::VERBOSE <<
"parseXML processed input string: " << input <<
endmsg;
100 for (KeyValMap::const_iterator itr=
m_keys.begin();itr!=
m_keys.end();++itr) {
101 log << MSG::VERBOSE <<
"Key: " << itr->first <<
" value:" <<
109 std::string& value)
const {
117 auto [theValue,found] =
at(
key,defvalue);
118 value=std::move(theValue);
122std::pair<std::string, bool>
124 KeyValMap::const_iterator it =
m_keys.find(searchKey);
129 return std::pair<std::string, bool> (defaultValue,
false);
144 return at(
"key").second;
149 return at(
"tag").first;
154 return at(
"eventStoreName",
"StoreGateSvc").first;
159 return (
at(
"timeStamp").first==
"time");
164 return at(
"cache").first;
169 auto valuePair=
at(
"cachehint");
170 return valuePair.second ? std::stoi(valuePair.first) : 0;
175 return at(
"named").second;
180 return at(
"metaOnly").second;
185 return at(
"extensible").second;
192 auto [addrHeader,foundHeader]=
at(
"addrHeader");
195 msg << MSG::DEBUG <<
"Decode addrHeader "<< addrHeader <<
endmsg;
197 if (
auto addrPair=addrH.
at(
"address_header");addrPair.second) {
199 msg << MSG::DEBUG <<
"Got CLID " <<
result <<
" from " << addrPair.first <<
endmsg;
207 return at(
"addrHeader").first;
210std::vector<std::string>
212 const auto & symLinkString =
at(
"symlinks").first;
218 return at(
"noover").second;
223 auto it=
m_keys.find(
"dbConnection");
225 std::string connection=std::move(it->second);
227 m_keys[
"db"]=std::move(connection);
234 unsigned keyCounter=0;
235 for (
const auto& otherKeyValue : other.m_keys) {
236 const std::string& otherKey=otherKeyValue.first;
237 const std::string& otherValue=otherKeyValue.second;
238 if (otherKey.empty())
continue;
239 if (otherKey==
"prefix")
continue;
240 KeyValMap::iterator it=
m_keys.find(otherKey);
242 log << MSG::INFO <<
"Folder " <<
m_keys[
""] <<
", adding new key " << otherKey
243 <<
" with value " << otherValue <<
endmsg;
244 m_keys[otherKey]=otherValue;
247 log << MSG::INFO <<
"Folder " <<
m_keys[
""] <<
", Key: " << otherKey
248 <<
"Overriding existing value " <<
m_keys[otherKey] <<
" to new value " << otherValue <<
endmsg;
249 it->second=otherValue;
258 return ((this->
m_keys) == other.m_keys);
275 bool overrideIs_nsEpochIov{
true};
276 const bool overridingTimestamp=(
m_keys.find(
"forceTimestamp")!=
m_keys.end());
277 const bool overridingRun=(
m_keys.find(
"forceRunNumber")!=
m_keys.end());
278 const bool overridingLumi=(
m_keys.find(
"forceLumiblockNumber")!=
m_keys.end());
281 if (overridingLumi and not overridingRun){
282 msg << MSG::WARNING<<
"Trying to override lumi block without specifying the run"<<
endmsg;
286 if (overridingRun and overridingTimestamp){
287 msg << MSG::WARNING<<
"Trying to override using both run-lumi and ns timestamp"<<
endmsg;
291 if (overridingRun) overrideIs_nsEpochIov=
false;
293 if (performFolderCheck and (overrideIs_nsEpochIov != folderIs_nsOfEpoch)){
294 msg << MSG::WARNING<<
"Trying to override run-lumi for a ns folder, or ns for a run-lumi folder"<<
endmsg;
297 return (overridingTimestamp or overridingRun);
302 unsigned long long value{};
304 auto pTsPair =
m_keys.find(
"forceTimestamp");
305 if (pTsPair!=
m_keys.end()){
309 auto pRunPair =
m_keys.find(
"forceRunNumber");
310 auto pLumiPair =
m_keys.find(
"forceLumiblockNumber");
311 const auto & runString = (pRunPair!=
m_keys.end()) ? pRunPair->second :
"";
312 const auto & lumiString = (pLumiPair!=
m_keys.end()) ? pLumiPair->second :
"";
321 std::stringstream retval;
324 retval <<
", Attributes: ";
327 for (;it!=it_e;++it) {
328 if (it->first.empty())
continue;
329 retval <<
"[" << it->first <<
":" << it->second <<
"] ";
335 os << fldr.toString();
uint32_t CLID
The Class ID type.
MsgStream & operator<<(MsgStream &os, const IOVDbParser &fldr)
bool overridesIovImpl(MsgStream &msg, const bool performFolderCheck, const bool folderIs_nsOfEpoch=true) const
implementation of overridesIov, with or without check on folder compatibility
std::pair< std::string, bool > at(const std::string &searchKey, const std::string &defaultValue="") const
'at' accessor with an optional default; the bool is true if the key was found
std::string toString() const
std::vector< std::string > symLinks() const
std::string cache() const
CLID classId(MsgStream &msg) const
bool onlyReadMetadata() const
bool getKey(const std::string &key, const std::string &devvalue, std::string &value) const
original 'getKey' method, now implemented using 'at'
std::string eventStoreName() const
bool timebaseIs_nsOfEpoch() const
unsigned long long iovOverrideValue(MsgStream &msg) const
bool overridesIov(MsgStream &msg) const
return true if this description overrides the timestamp or runlumi
bool operator==(const IOVDbParser &other) const
bool noTagOverride() const
std::string addressHeader() const
unsigned applyOverrides(const IOVDbParser &other, MsgStream &log)
std::string folderName() const
give the folder name contained in the parsed description
unsigned long long iovFromRunString(const std::string &runString)
Take a string run number and convert it to an ULL representing run<<32.
unsigned long long iovFromLumiBlockString(const std::string &lbString)
String representation of lumiblock just converted to LL (as in original code) and returned as a ULL.
std::string spaceStrip(const std::string &input)
Trim leading and trailing spaces,return a new trimmed string.
bool replaceServiceType71(std::string &addrHeader)
unsigned long long iovFromTimeString(const std::string &iovString)
Take a string integer giving a time in seconds and convert it to a ULL in nanoseconds.
int parseClid(const std::string &addrHeaderStr)
Extract the Class ID (an integer) from a string of form <addrHeader><address_header service_type="256...
std::vector< std::string > parseLinkNames(const std::string &linktext)
Parse string of format "A:X::B:C" to "A" , "X::B", "C".