plugify  1.0.0.0
version.hpp
1 #pragma once
2 
3 #include <cstdint>
4 #include <plugify_export.h>
5 
6 namespace plugify {
10  class PLUGIFY_API Version final {
11  public:
19  Version(uint8_t major, uint8_t minor, uint8_t patch, uint8_t tweak) noexcept;
20 
25  explicit Version(uint32_t version) noexcept;
26 
32  Version& operator=(uint32_t version) noexcept;
33 
38  operator uint32_t() const noexcept;
39 
45  auto operator<=>(const Version& rhs) const noexcept;
46 
51  std::string ToString() const;
52 
53  private:
54  uint8_t _major;
55  uint8_t _minor;
56  uint8_t _patch;
57  uint8_t _tweak;
58  };
59 } // namespace plugify
60 
61 #define PLUGIFY_MAKE_VERSION(major, minor, patch, tweak) ((((uint32_t)(major)) << 29) | (((uint32_t)(minor)) << 22) | (((uint32_t)(patch)) << 12) | ((uint32_t)(tweak)))
62 #define PLUGIFY_MAKE_VERSION_MAJOR(version) uint8_t((uint32_t)(version) >> 29)
63 #define PLUGIFY_MAKE_VERSION_MINOR(version) uint8_t(((uint32_t)(version) >> 22) & 0x7FU)
64 #define PLUGIFY_MAKE_VERSION_PATCH(version) uint8_t(((uint32_t)(version) >> 12) & 0x3FFU)
65 #define PLUGIFY_MAKE_VERSION_TWEAK(version) uint8_t((uint32_t)(version) & 0xFFFU)
66 
67 #define PLUGIFY_API_VERSION_1_0 PLUGIFY_MAKE_VERSION(1, 0, 0, 0)
Represents a version number with major, minor, patch, and tweak components.
Definition: version.hpp:10
Version(uint32_t version) noexcept
Explicit constructor to initialize a Version object from a packed 32-bit version number.
Version(uint8_t major, uint8_t minor, uint8_t patch, uint8_t tweak) noexcept
Constructor to initialize a Version object with individual components.
Version & operator=(uint32_t version) noexcept
Assignment operator to set the Version object from a packed 32-bit version number.