Elements 6.3.1
A C++ base framework for the Euclid Software.
Loading...
Searching...
No Matches
Version.cpp
Go to the documentation of this file.
1
23
24#include <boost/algorithm/string.hpp> // for is_any_ofF, is_any_of, split
25#include <boost/next_prior.hpp> // for next, prior
26
27#include <string> // for basic_string, allocator, string, to_string, char_traits, operator+
28#include <vector> // for vector
29
30using std::string;
31
32namespace Elements {
33
35string 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
68string 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(unsigned short major, unsigned short minor, unsigned short patch=0)
Function converting the version numbers into a string.
Definition Version.cpp:68
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)