CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AlCaRecoTriggerBits.cc
Go to the documentation of this file.
2 
5 
7 
8 //_____________________________________________________________________
9 std::string AlCaRecoTriggerBits::compose(const std::vector<std::string> &paths) const {
10  std::string mergedPaths;
11  for (std::vector<std::string>::const_iterator iPath = paths.begin(); iPath != paths.end(); ++iPath) {
12  if (iPath != paths.begin())
13  mergedPaths += delimeter_;
14  if (iPath->find(delimeter_) != std::string::npos) {
15  // What to do in CondFormats?
16  // cms::Exception? std::cerr? edm::LogError?
17  }
18  mergedPaths += *iPath;
19  }
20 
21  // Special case: DB cannot store empty strings, see e.g.
22  // https://hypernews.cern.ch/HyperNews/CMS/get/database/674.html ,
23  // so choose delimeter_ for that - it cannot appear in a path anyway.
24  if (mergedPaths.empty())
25  mergedPaths = delimeter_;
26 
27  return mergedPaths;
28 }
29 
30 //_____________________________________________________________________
31 std::vector<std::string> AlCaRecoTriggerBits::decompose(const std::string &s) const {
32  // decompose 's' into its parts that are separated by 'delimeter_'
33  // (similar as in
34  // Alignment/CommonAlignmentAlgorithm/src/AlignmentParameterSelector.cc)
35 
36  std::vector<std::string> result;
37  if (!(s.size() == 1 && s[0] == delimeter_)) {
38  // delimeter_ only indicates an empty list as DB cannot store empty strings
39  std::string::size_type previousPos = 0;
40  while (true) {
41  const std::string::size_type delimiterPos = s.find(delimeter_, previousPos);
42  if (delimiterPos == std::string::npos) {
43  result.push_back(s.substr(previousPos)); // until end
44  break;
45  }
46  result.push_back(s.substr(previousPos, delimiterPos - previousPos));
47  previousPos = delimiterPos + 1; // +1: skip delim
48  }
49  }
50 
51  return result;
52 }
std::vector< std::string > decompose(const std::string &concatPaths) const
Decompose one value of map from concatenated string.
uint16_t size_type
tuple result
Definition: mps_fire.py:311
std::string compose(const std::vector< std::string > &paths) const
Compose several paths into one string :
static const std::string::value_type delimeter_
Delimeter for composing paths to one string in DB: