CMS 3D CMS Logo

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