ATLAS Offline Software
IOVDbStringFunctions.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 //@file IOVDbStringFunctions.h
5 //@brief Helper functions for string manipulation and parsing
6 //@author Shaun Roe
7 #ifndef IOVDbSvc_IOVDbStringFunctions_h
8 #define IOVDbSvc_IOVDbStringFunctions_h
9 
10 #include <string>
11 #include <vector>
12 #include <utility>
13 #include <limits>
14 
15 namespace Gaudi{
16  class StoreGateSvc;
17 }
18 class MsgStream;
19 
20 namespace IOVDbNamespace{
21 
23  std::string
24  spaceStrip( const std::string & input);
25 
27  int
28  makeChannel(const std::string& strval, const int defchan);
29 
32  template <class IntType>
33  std::vector<std::pair<IntType, IntType>>
34  parseChannelSpec(const std::string & chanspecString){
35  typedef std::pair<IntType, IntType> ChanRange;
36  const auto defaults=ChanRange(0,std::numeric_limits<IntType>::max());
37  //
38  std::vector<ChanRange> result;
39  std::string::size_type index;
40  std::string rangespec, chanspec(chanspecString);
41  bool first=true;
42  do {
43  index=chanspec.find(',');
44  if (index!=std::string::npos) {
45  rangespec=chanspec.substr(0,index);
46  chanspec=chanspec.substr(index+1,chanspec.size());
47  } else {
48  rangespec=chanspec;
49  }
50  if (!rangespec.empty()) {
51  // parse the range specification, look for : separator between limits
52  std::string::size_type icol=rangespec.find(':');
53  int lower,upper;
54  if (icol!=std::string::npos) {
55  lower=makeChannel(spaceStrip(rangespec.substr(0,icol)),defaults.first);
56  upper=makeChannel(spaceStrip(rangespec.substr(icol+1,rangespec.size())),defaults.second);
57  } else {
58  lower=atol(spaceStrip(rangespec).c_str());
59  upper=lower;
60  }
61  if (first) {
62  first=false;
63  }
64  result.push_back(ChanRange(lower,upper));
65  }
66  } while (index!=std::string::npos);
67  return result;
68  }
69 
71  unsigned long long
72  iovFromTimeString(const std::string & iovString);
73 
75  unsigned long long
76  iovFromRunString(const std::string & runString);
77 
80  unsigned long long
81  iovFromLumiBlockString(const std::string & lbString);
82 
85  int
86  parseClid(const std::string & addrHeaderStr);
87 
89  std::string
90  parseTypename(const std::string & description);
91 
93  std::string
94  deleteRegex(const std::string & original, const std::string & regex);
95 
97  std::string
98  quote(const std::string & sentence);
99 
101  std::string
102  sanitiseFilename(const std::string & fname);
103 
105  std::string
106  sanitiseCrestTag(const std::string & fname);
107 
110  std::string
111  replaceNULL(const std::string & possibleNULL);
112 
114  std::string
115  sanitiseXml(const std::string & pseudoXmlString);
116 
118  std::string
119  sanitiseJsonString(const std::string & dataString);
120 
122  bool
123  looksLikeMagicTag(const std::string & candidateTag);
124 
126  bool
127  tagIsMagic(const std::string & candidateTag);
128 
132  std::vector<std::string>
133  parseMagicTag(const std::string & candidateTag);
134 
138  std::pair<std::string, std::string>
139  tag2PrefixTarget(const std::vector<std::string>& parseResult);
140 
141  bool
142  replaceServiceType71(std::string & addrHeader);
143 
144  std::string
145  unescapeQuotes(const std::string & original);
146 
147  std::string
148  unescapeBackslash(const std::string & original);
150  std::vector<std::string>
151  parseLinkNames(const std::string &linktext);
152 
153 
154 }
155 
156 #endif
IOVDbNamespace::spaceStrip
std::string spaceStrip(const std::string &input)
Trim leading and trailing spaces,return a new trimmed string.
Definition: IOVDbStringFunctions.cxx:11
IOVDbNamespace::parseMagicTag
std::vector< std::string > parseMagicTag(const std::string &v)
Takes a tag of form TagInfo{Major|Minor}/<tag> or TagInfo{Major|Minor}/<prefix>/<tag> and resolve it ...
Definition: IOVDbStringFunctions.cxx:164
IOVDbNamespace::tag2PrefixTarget
std::pair< std::string, std::string > tag2PrefixTarget(const std::vector< std::string > &tagParseResults)
Takes a vector<string> containing {"<fulltag>", "Major|Minor", "<prefix>", "<tag>"} and returns a pai...
Definition: IOVDbStringFunctions.cxx:198
get_generator_info.result
result
Definition: get_generator_info.py:21
max
#define max(a, b)
Definition: cfImp.cxx:41
index
Definition: index.py:1
parseResult
const char * parseResult(const asg::AcceptData &result, const char *selection="Cleaning")
Definition: TestJetCleaningTool.cxx:21
upper
int upper(int c)
Definition: LArBadChannelParser.cxx:49
IOVDbNamespace::deleteRegex
std::string deleteRegex(const std::string &original, const std::string &regex)
Delete characters of a matching regex from the input string.
Definition: IOVDbStringFunctions.cxx:79
IOVDbNamespace::sanitiseJsonString
std::string sanitiseJsonString(const std::string &dataString)
Sanitise json string, escaping raw carriage returns.
Definition: IOVDbStringFunctions.cxx:52
IOVDbNamespace::iovFromTimeString
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.
Definition: IOVDbStringFunctions.cxx:31
IOVDbNamespace::parseLinkNames
std::vector< std::string > parseLinkNames(const std::string &linktext)
Parse string of format "A:X::B:C" to "A" , "X::B", "C".
Definition: IOVDbStringFunctions.cxx:178
atlasStyleMacro.icol
int icol
Definition: atlasStyleMacro.py:13
IOVDbNamespace::replaceServiceType71
bool replaceServiceType71(std::string &addrHeader)
Definition: IOVDbStringFunctions.cxx:212
IOVDbNamespace::sanitiseCrestTag
std::string sanitiseCrestTag(const std::string &fname)
return valid CREST tag name from folder name
Definition: IOVDbStringFunctions.cxx:121
PrepareReferenceFile.regex
regex
Definition: PrepareReferenceFile.py:43
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:125
IOVDbNamespace::iovFromLumiBlockString
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.
Definition: IOVDbStringFunctions.cxx:45
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
IOVDbNamespace::parseTypename
std::string parseTypename(const std::string &description)
Extract the typename from a folder description.
Definition: IOVDbStringFunctions.cxx:70
IOVDbNamespace::unescapeBackslash
std::string unescapeBackslash(const std::string &original)
Definition: IOVDbStringFunctions.cxx:102
IOVDbNamespace::sanitiseFilename
std::string sanitiseFilename(const std::string &fname)
Replace the '/' of a file path with '^'.
Definition: IOVDbStringFunctions.cxx:110
Base_Fragment.defaults
dictionary defaults
This includes now the top quark, the leptons and the bosons.
Definition: GeneratorFilters/share/common/Base_Fragment.py:79
python.AthDsoLogger.fname
string fname
Definition: AthDsoLogger.py:67
IOVDbNamespace::replaceNULL
std::string replaceNULL(const std::string &possibleNULL)
replace an uppercase NULL (such as returned by oracle) in string with a lowercase null (such as used ...
Definition: IOVDbStringFunctions.cxx:127
DeMoScan.index
string index
Definition: DeMoScan.py:364
IOVDbNamespace::tagIsMagic
bool tagIsMagic(const std::string &candidateTag)
Resolve magic tag.
Definition: IOVDbStringFunctions.cxx:157
WriteCalibToCool.strval
strval
Definition: WriteCalibToCool.py:583
DeMoScan.first
bool first
Definition: DeMoScan.py:536
IOVDbNamespace::unescapeQuotes
std::string unescapeQuotes(const std::string &original)
Definition: IOVDbStringFunctions.cxx:95
Gaudi
=============================================================================
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:273
IOVDbNamespace::looksLikeMagicTag
bool looksLikeMagicTag(const std::string &candidateTag)
Looks like it should be magic.
Definition: IOVDbStringFunctions.cxx:151
IOVDbNamespace::quote
std::string quote(const std::string &sentence)
Enclose a string in ".
Definition: IOVDbStringFunctions.cxx:85
IOVDbNamespace::sanitiseXml
std::string sanitiseXml(const std::string &pseudoXmlString)
for use when converting cool folder description JSON
Definition: IOVDbStringFunctions.cxx:135
IOVDbNamespace::parseClid
int parseClid(const std::string &addrHeaderStr)
Extract the Class ID (an integer) from a string of form <addrHeader><address_header service_type="256...
Definition: IOVDbStringFunctions.cxx:59
IOVDbNamespace::parseChannelSpec
std::vector< std::pair< IntType, IntType > > parseChannelSpec(const std::string &chanspecString)
Parse a channel specification string of the format ":3, 65:67,100:120, 130: " into a vector of pairs.
Definition: IOVDbStringFunctions.h:34
IOVDbNamespace::makeChannel
cool::ChannelId makeChannel(const std::string &strval, const cool::ChannelId defchan)
Create a ChannelId from a string; if string is empty, return the default channel number given.
Definition: IOVDbCoolFunctions.cxx:128
description
std::string description
glabal timer - how long have I taken so far?
Definition: hcg.cxx:88
IOVDbNamespace
Definition: Base64Codec.cxx:16
IOVDbNamespace::iovFromRunString
unsigned long long iovFromRunString(const std::string &runString)
Take a string run number and convert it to an ULL representing run<<32.
Definition: IOVDbStringFunctions.cxx:38