ATLAS Offline Software
Loading...
Searching...
No Matches
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
15namespace Gaudi{
16 class StoreGateSvc;
17}
18class MsgStream;
19
20namespace 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
int upper(int c)
const char * parseResult(const asg::AcceptData &result, const char *selection="Cleaning")
std::string description
glabal timer - how long have I taken so far?
Definition hcg.cxx:91
=============================================================================
unsigned long long iovFromRunString(const std::string &runString)
Take a string run number and convert it to an ULL representing run<<32.
std::string deleteRegex(const std::string &original, const std::string &regex)
Delete characters of a matching regex from the input string.
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.
std::string sanitiseFilename(const std::string &fname)
Replace the '/' of a file path with '^'.
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 ...
std::string quote(const std::string &sentence)
Enclose a string in ".
std::string unescapeBackslash(const std::string &original)
std::string unescapeQuotes(const std::string &original)
std::string sanitiseCrestTag(const std::string &fname)
return valid CREST tag name from folder name
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::pair< std::string, std::string > tag2PrefixTarget(const std::vector< std::string > &tagParseResults)
Takes a vector<string> containing {"<fulltag>", "Major|Minor", "<prefix>", "<tag>"}...
std::string spaceStrip(const std::string &input)
Trim leading and trailing spaces,return a new trimmed string.
std::string parseTypename(const std::string &description)
Extract the typename from a folder description.
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.
bool tagIsMagic(const std::string &candidateTag)
Resolve magic tag.
int parseClid(const std::string &addrHeaderStr)
Extract the Class ID (an integer) from a string of form <addrHeader><address_header service_type="256...
std::string sanitiseXml(const std::string &pseudoXmlString)
for use when converting cool folder description JSON
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 ...
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.
bool looksLikeMagicTag(const std::string &candidateTag)
Looks like it should be magic.
std::vector< std::string > parseLinkNames(const std::string &linktext)
Parse string of format "A:X::B:C" to "A" , "X::B", "C".
std::string sanitiseJsonString(const std::string &dataString)
Sanitise json string, escaping raw carriage returns.
Definition index.py:1