CMS 3D CMS Logo

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