Mantid
Loading...
Searching...
No Matches
SemanticVersion.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2008 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9#include "MantidDataObjects/DllConfig.h"
10
11#include <compare>
12#include <cstdint>
13#include <regex>
14#include <string>
15
16namespace Mantid {
17
18namespace DataObjects {
19
41class MANTID_DATAOBJECTS_DLL SemanticVersion {
42
43public:
44 // The SemVer regex
45 static std::regex version_regex;
46
47 // Default constructor
48 SemanticVersion() = delete;
49
50 // Copy constructor
51 SemanticVersion(const SemanticVersion &other) = default;
52
53 // Constructor from string
54 SemanticVersion(const std::string &);
55
56 // Constructor from major, minor, patch and identifier;
57 SemanticVersion(std::uint32_t major, std::uint32_t minor = 0, std::uint32_t patch = 0,
58 const std::string &prerelease = "", const std::string &build = "");
59
60 // Destructor
61 ~SemanticVersion() = default;
62
63 // Assignment operators
64 SemanticVersion &operator=(const SemanticVersion &other) = default;
65
66 // Equality operator
67 bool operator==(const SemanticVersion &other) const;
68
69 // Comparison operators
70 std::strong_ordering operator<=>(const SemanticVersion &other) const;
71 std::strong_ordering operator<=>(const std::string &versionStr) const;
72
73 // Returns the build
74 const std::string &getBuild() const;
75
76 // Returns the major version
77 std::uint32_t getMajor() const;
78
79 // Returns the minor version
80 std::uint32_t getMinor() const;
81
82 // Returns the patch version
83 std::uint32_t getPatch() const;
84
85 // Returns the prerelease
86 const std::string &getPrerelease() const;
87
88 // Returns the version
89 const std::string &getVersion() const;
90
91private:
92 // Proceeds to the internal validation of the version
93 void parse_version(const std::string &);
94
95 // The full version
96 std::string m_version = "";
97
98 // The major number
99 std::uint32_t m_major = 0;
100
101 // The minor number
102 std::uint32_t m_minor = 0;
103
104 // The patch number
105 std::uint32_t m_patch = 0;
106
107 // The prerelease
108 std::string m_prerelease = "";
109
110 // The build
111 std::string m_build = "";
112};
113
114} // end namespace DataObjects
115
116} // end namespace Mantid
Implementation of a SemVer parser.
SemanticVersion & operator=(const SemanticVersion &other)=default
SemanticVersion(const SemanticVersion &other)=default
Helper class which provides the Collimation Length for SANS instruments.
constexpr bool operator==(const wide_integer< Bits, Signed > &lhs, const wide_integer< Bits2, Signed2 > &rhs)