CMS 3D CMS Logo

ReleaseVersion.cc
Go to the documentation of this file.
2 
3 #include "boost/algorithm/string.hpp"
4 
5 #include <algorithm>
6 #include <cassert>
7 #include <cctype>
8 #include <vector>
9 
10 namespace edm {
11  namespace releaseversion {
12 
13  struct IsNotDigit {
14  bool operator()(char const c) const { return !isdigit(c); }
15  };
16 
17  struct IsEmpty {
18  bool operator()(std::string const& s) const { return s.empty(); }
19  };
20 
22  : irregular_(true), major_(0), minor_(0) /*, point_(0), patch_(0), pre_(0)*/ {
23  try {
24  std::vector<std::string> parts;
25  parts.reserve(releaseVersion.size());
26  boost::algorithm::split(parts, releaseVersion, IsNotDigit(), boost::algorithm::token_compress_on);
27  parts.erase(remove_if(parts.begin(), parts.end(), IsEmpty()), parts.end());
28 
29  if (parts.size() < 3) {
30  return;
31  }
32  /*
33  if(parts.size() == 4) {
34  if(releaseVersion.find("patch") != std::string::npos) {
35  patch_ = std::stoul(parts[3]);
36  } else if(releaseVersion.find("pre") != std::string::npos) {
37  pre_ = std::stoul(parts[3]);
38  } else {
39  return;
40  }
41  }
42 */
43  major_ = std::stoul(parts[0]);
44  minor_ = std::stoul(parts[1]);
45  // point_ = std::stoul(parts[2]);
46  irregular_ = false;
47  } catch (std::exception const&) {
48  }
49  }
50 
52  if (irregular_ || other.irregular_)
53  return false;
54  if (major_ < other.major_)
55  return true;
56  if (major_ > other.major_)
57  return false;
58  if (minor_ < other.minor_)
59  return true;
60  // if(minor_ > other.minor_) return false;
61  // if(point_ < other.point_) return true;
62  // if(point_ > other.point_) return false;
63  // if(patch_ < other.patch_) return true;
64  // if(patch_ > other.patch_) return false;
65  // if(pre_ < other.pre_) return true;
66  return false;
67  }
68 
69  bool isEarlierRelease(std::string const& a, std::string const& b) {
71  }
72 
74  return (a < DecomposedReleaseVersion(b));
75  }
76 
78  return (DecomposedReleaseVersion(a) < b);
79  }
80 
82 
83  } // namespace releaseversion
84 } // namespace edm
bool operator()(std::string const &s) const
bool isEarlierRelease(std::string const &a, std::string const &b)
double b
Definition: hdecay.h:118
HLT enums.
double a
Definition: hdecay.h:119
bool operator()(char const c) const
DecomposedReleaseVersion(std::string releaseVersion)
bool operator<(DecomposedReleaseVersion const &other) const