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