Elements  5.12.0
A C++ base framework for the Euclid Software.
Version.cpp
Go to the documentation of this file.
1 
22 #include "ElementsKernel/Version.h"
23 
24 #include <string>
25 #include <vector>
26 #include <boost/utility.hpp>
27 #include <boost/algorithm/string.hpp>
28 
29 
30 using std::string;
31 
32 namespace Elements {
33 
35 string getVersionFromSvnKeywords(const string& svnUrl, const string& svnId) {
36 
37  using std::vector;
38 
39  // output to-be-returned version
40  string version {};
41 
42  // Delimiter to split the URL
43  const string delim("/");
44  // vector of elements of the URL between pairs of "/"
45  vector<string> urlElements {};
46  // Build a string vector with the URL elements
47  boost::split(urlElements, svnUrl, boost::is_any_of(delim));
48 
49  // Loop over all elements of the URL
50  for (auto it = urlElements.begin(); it != urlElements.end(); ++it) {
51  // If "trunk" is detected...
52  if ((*it).find("trunk") != string::npos) {
53  // ...return the SVN Id keyword
54  version = svnId;
55  break;
56  }
57  // If "tags" id detected ...
58  if ((*it).find("tags") != string::npos) {
59  // ...built a version from the project name and tags number
60  version = *(boost::prior(it)) + " " + *(boost::next(it));
61  break;
62  }
63  }
64  return version;
65  }
66 
68 string getVersionString(const unsigned short major, const unsigned short minor, const unsigned short patch) {
69 
70  using std::to_string;
71 
72  string version {""};
73 
74  version += to_string(major);
75  version += ".";
76  version += to_string(minor);
77 
78  if (0 != patch) {
79  version += ".";
80  version += to_string(patch);
81  }
82 
83  return version;
84 }
85 
86 } // namespace Elements
Software version handling.
ELEMENTS_API std::string getVersionString(const unsigned short major, const unsigned short minor, const unsigned short patch=0)
Function converting the version numbers into a string.
Definition: Version.cpp:68
ELEMENTS_API auto split(Args &&... args) -> decltype(splitPath(std::forward< Args >(args)...))
alias for the splitPath function
ELEMENTS_API std::string getVersionFromSvnKeywords(const std::string &svnUrl, const std::string &svnId)
Function returning a version string extracted from SVN keywords.
Definition: Version.cpp:35
T to_string(T... args)