// // Created by Shell on 2026/7/21. // #ifndef SEADISK_VERSION_HPP #define SEADISK_VERSION_HPP #include #include #include namespace seafile::util { /** * @brief Semantic version parser. * * Supports: * 10 * 10.0 * 10.0.2 */ class Version final { public: Version() = default; explicit Version(const std::string &version); Version(const Version &) = default; Version(Version &&) noexcept = default; Version &operator=(const Version &) = default; Version &operator=(Version &&) noexcept = default; [[nodiscard]] int major() const noexcept; [[nodiscard]] std::optional minor() const noexcept; [[nodiscard]] std::optional patch() const noexcept; [[nodiscard]] std::string toString() const; std::strong_ordering operator<=>(const Version &other) const; private: void parse(const std::string &version); int major_{0}; std::optional minor_; std::optional patch_; }; } #endif //SEADISK_VERSION_HPP