Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
SemanticVersion.h
Go to the documentation of this file.
1#pragma once
2
3#include <Common/primitive_type.h>
4
5#include <string>
6#include <compare>
7#include <string_view>
8
9namespace ph
10{
11
15class SemanticVersion final
16{
17public:
19 SemanticVersion(uint16 major, uint16 minor, uint16 patch);
20 explicit SemanticVersion(std::string_view version);
21
22 bool isInitial() const;
23
24 std::string toString() const;
25
26 inline bool operator == (const SemanticVersion& other) const = default;
27 std::strong_ordering operator <=> (const SemanticVersion& other) const;
28
29private:
30 uint16 m_major;
31 uint16 m_minor;
32 uint16 m_patch;
33};
34
35// In-header Implementations:
36
40
41inline SemanticVersion::SemanticVersion(const uint16 major, const uint16 minor, const uint16 patch) :
42 m_major(major), m_minor(minor), m_patch(patch)
43{}
44
45inline bool SemanticVersion::isInitial() const
46{
47 return m_major == 0 && m_minor == 0 && m_patch == 0;
48}
49
50inline std::strong_ordering SemanticVersion::operator <=> (const SemanticVersion& other) const
51{
52 if(auto cmp = m_major <=> other.m_major; cmp != 0)
53 {
54 return cmp;
55 }
56
57 if(auto cmp = m_minor <=> other.m_minor; cmp != 0)
58 {
59 return cmp;
60 }
61
62 return m_patch <=> other.m_patch;
63}
64
65}// end namespace ph
Convenient software version handling routines. See https://semver.org/ for a detailed explaination of...
Definition SemanticVersion.h:16
bool isInitial() const
Definition SemanticVersion.h:45
std::strong_ordering operator<=>(const SemanticVersion &other) const
Definition SemanticVersion.h:50
std::string toString() const
Definition SemanticVersion.cpp:36
bool operator==(const SemanticVersion &other) const =default
SemanticVersion()
Definition SemanticVersion.h:37
The root for all renderer implementations.
Definition EEngineProject.h:6