🛰️航天仿真算法库 SpaceAST 0.0.1
载入中...
搜索中...
未找到
Version.hpp
浏览该文件的文档.
1
20
21#pragma once
22
23#include "AstGlobal.h"
24#include <string>
25#include "AstUtil/StringView.hpp"
26
27AST_NAMESPACE_BEGIN
28
39class AST_UTIL_API Version
40{
41public:
43 Version() = default;
44
48 static Version Parse(StringView version);
49
51 explicit Version(StringView version);
52
58 Version(int major, int minor, int patch=-1, StringView prerelease = {}, StringView build = {});
59
60public:
61 int compare(const Version& other) const;
62
63 bool operator==(const Version& other) const{return compare(other) == 0;}
64 bool operator!=(const Version& other) const{return compare(other) != 0;}
65 bool operator<(const Version& other) const{return compare(other) < 0;}
66 bool operator>(const Version& other) const{return compare(other) > 0;}
67 bool operator<=(const Version& other) const{return compare(other) <= 0;}
68 bool operator>=(const Version& other) const{return compare(other) >= 0;}
69
70public:
71 bool valid() const{return major_ > 0;}
72
73 int major() const{return major_;}
74 void setMajor(int major){major_ = major;}
75
76 int minor() const{return minor_;}
77 void setMinor(int minor){minor_ = minor;}
78
79 int patch() const{return patch_;}
80 void setPatch(int patch){patch_ = patch;}
81
82 const std::string& prerelease() const{return prerelease_;}
83 void setPrerelease(StringView prerelease){prerelease_ = std::string(prerelease);}
84
85 const std::string& build() const{return build_;}
86 void setBuild(StringView build){build_ = std::string(build);}
87
88private:
89 int major_{-1};
90 int minor_{0};
91 int patch_{0};
92 std::string prerelease_;
93 std::string build_;
94};
95
98AST_NAMESPACE_END
版本号
定义 Version.hpp:40
Version()=default
默认构造(无效版本,major_ = -1)