CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
16  return !isdigit(c);
17  }
18  };
19 
20  struct IsEmpty {
21  bool operator()(std::string const& s) const {
22  return s.empty();
23  }
24  };
25 
26  DecomposedReleaseVersion::DecomposedReleaseVersion(std::string releaseVersion) : irregular_(true), major_(0), minor_(0)/*, point_(0), patch_(0), pre_(0)*/ {
27  try {
28  std::vector<std::string> parts;
29  parts.reserve(releaseVersion.size());
30  boost::algorithm::split(parts, releaseVersion, IsNotDigit(), boost::algorithm::token_compress_on);
31  parts.erase(remove_if(parts.begin(), parts.end(), IsEmpty()), parts.end());
32 
33  if(parts.size() < 3) {
34  return;
35  }
36 /*
37  if(parts.size() == 4) {
38  if(releaseVersion.find("patch") != std::string::npos) {
39  patch_ = boost::lexical_cast<unsigned int>(parts[3]);
40  } else if(releaseVersion.find("pre") != std::string::npos) {
41  pre_ = boost::lexical_cast<unsigned int>(parts[3]);
42  } else {
43  return;
44  }
45  }
46 */
47  major_ = boost::lexical_cast<unsigned int>(parts[0]);
48  minor_ = boost::lexical_cast<unsigned int>(parts[1]);
49 // point_ = boost::lexical_cast<unsigned int>(parts[2]);
50  irregular_ = false;
51  } catch(std::exception const&) {
52  }
53  }
54 
55 
57  if(irregular_ || other.irregular_) return false;
58  if(major_ < other.major_) return true;
59  if(major_ > other.major_) return false;
60  if(minor_ < other.minor_) 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
71  isEarlierRelease(std::string const& a, std::string const& b) {
73  }
74 
75  bool
76  isEarlierRelease(DecomposedReleaseVersion const& a, std::string const& b) {
77  return(a < DecomposedReleaseVersion(b));
78  }
79 
80  bool
81  isEarlierRelease(std::string const& a, DecomposedReleaseVersion const& b) {
82  return(DecomposedReleaseVersion(a) < b);
83  }
84 
85  bool
87  return(a < b);
88  }
89 
90  }
91 }
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:120
bool operator()(char const c) const
double a
Definition: hdecay.h:121
double split
Definition: MVATrainer.cc:139
DecomposedReleaseVersion(std::string releaseVersion)