vitrio 0.1.4
High-throughput image I/O for Cryo-Electron Microscopy (CryoEM)
Loading...
Searching...
No Matches
version.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2
3#pragma once
4
5#include <cstdint>
6#include <ostream>
7
8namespace vitrio
9{
10
18{
19public:
27 constexpr version(
28 std::uint32_t major,
29 std::uint32_t minor,
30 std::uint32_t patch
31 ) noexcept;
32 version(const version &other) = default;
33 ~version() = default;
34
35 version& operator=(const version &other) = default;
36
42 constexpr std::uint32_t get_major() const noexcept;
43
50
57
60 {
61 return
62 lhs.get_major() == rhs.get_major() &&
63 lhs.get_minor() == rhs.get_minor() &&
64 lhs.get_patch() == rhs.get_patch();
65 }
66
67 friend constexpr
68 bool operator!=(const version &lhs, const version &rhs) noexcept
69 {
70 return !(lhs == rhs);
71 }
72
73 friend constexpr
74 bool operator<(const version &lhs, const version &rhs) noexcept
75 {
76 if (lhs.get_major() != rhs.get_major())
77 {
78 return lhs.get_major() < rhs.get_major();
79 }
80 if (lhs.get_minor() != rhs.get_minor())
81 {
82 return lhs.get_minor() < rhs.get_minor();
83 }
84 return lhs.get_patch() < rhs.get_patch();
85 }
86
87 friend constexpr
88 bool operator<=(const version &lhs, const version &rhs) noexcept
89 {
90 return !(rhs < lhs);
91 }
92
93 friend constexpr
94 bool operator>(const version &lhs, const version &rhs) noexcept
95 {
96 return rhs < lhs;
97 }
98
99 friend constexpr
100 bool operator>=(const version &lhs, const version &rhs) noexcept
101 {
102 return !(lhs < rhs);
103 }
104
105 template <typename T>
106 friend std::basic_ostream<T>&
107 operator<<(std::basic_ostream<T> &os, const version &ver)
108 {
109 return os
110 << ver.get_major() << '.'
111 << ver.get_minor() << '.'
112 << ver.get_patch();
113 }
114
115private:
116 std::uint32_t m_major;
117 std::uint32_t m_minor;
118 std::uint32_t m_patch;
119};
120
121} // namespace vitrio
122
123#include "version.inl"
A view of a contiguous sequence of elements.
Definition span.hpp:29
A version number of three components.
Definition version.hpp:18
constexpr std::uint32_t get_patch() const noexcept
Get the patch component.
constexpr std::uint32_t get_major() const noexcept
Get the major component.
constexpr std::uint32_t get_minor() const noexcept
Get the minor component.
constexpr version(std::uint32_t major, std::uint32_t minor, std::uint32_t patch) noexcept
Construct a version from its components.