1 | // LAF Base Library |
2 | // Copyright (c) 2019-2021 Igara Studio S.A. |
3 | // Copyright (c) 2001-2016 David Capello |
4 | // |
5 | // This file is released under the terms of the MIT license. |
6 | // Read LICENSE.txt for more information. |
7 | |
8 | #ifndef BASE_VERSION_H_INCLUDED |
9 | #define BASE_VERSION_H_INCLUDED |
10 | #pragma once |
11 | |
12 | #include <string> |
13 | #include <vector> |
14 | |
15 | namespace base { |
16 | |
17 | class Version { |
18 | public: |
19 | typedef std::vector<int> Numbers; |
20 | |
21 | Version(); |
22 | explicit Version(const std::string& from); |
23 | Version(int major, int minor, int patch, int build); |
24 | |
25 | int major() const { return (m_numbers.size() > 0 ? m_numbers[0]: 0); } |
26 | int minor() const { return (m_numbers.size() > 1 ? m_numbers[1]: 0); } |
27 | int patch() const { return (m_numbers.size() > 2 ? m_numbers[2]: 0); } |
28 | int build() const { return (m_numbers.size() > 3 ? m_numbers[3]: 0); } |
29 | |
30 | bool operator<(const Version& other) const; |
31 | bool operator==(const Version& other) const; |
32 | bool operator!=(const Version& other) const { return !operator==(other); } |
33 | |
34 | bool empty() const { return m_numbers.empty(); } |
35 | const Numbers& numbers() const { return m_numbers; } |
36 | const std::string& prereleaseLabel() const { return m_prereleaseLabel; } |
37 | const int prereleaseNumber() const { return m_prereleaseNumber; } |
38 | |
39 | std::string str() const; |
40 | |
41 | private: |
42 | Numbers m_numbers; |
43 | std::string m_prereleaseLabel; // alpha, beta, dev, rc (empty if it's official release) |
44 | int m_prereleaseNumber = 0; |
45 | }; |
46 | |
47 | } |
48 | |
49 | #endif |
50 | |