Sese Framework  x.y.z
A cross-platform framework
载入中...
搜索中...
未找到
Version.h
浏览该文件的文档.
1// Copyright 2024 libsese
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
19
20#pragma once
21
22#include <sese/Config.h>
23
24#include <optional>
25
26namespace sese {
27
29class Version {
30 uint16_t major_;
31 uint16_t minor_;
32 uint16_t patch_;
33 uint16_t revision_;
34
35public:
36 Version(uint16_t major, uint16_t minor, uint16_t patch, uint16_t revision);
37
38 [[nodiscard]] uint16_t getMajor() const { return major_; }
39 void setMajor(uint16_t major) { Version::major_ = major; }
40 [[nodiscard]] uint16_t getMinor() const { return minor_; }
41 void setMinor(uint16_t minor) { Version::minor_ = minor; }
42 [[nodiscard]] uint16_t getPatch() const { return patch_; }
43 void setPatch(uint16_t patch) { Version::patch_ = patch; }
44 [[nodiscard]] uint16_t getRevision() const { return revision_; }
45 void setRevision(uint16_t revision) { Version::revision_ = revision; }
46
47 static std::optional<Version> parse(const std::string &version);
48
51 [[nodiscard]] std::string toString() const;
52
55 [[nodiscard]] std::string toShortString() const;
56
57 bool operator==(const Version &other) const;
58 bool operator<(const Version &other) const;
59 bool operator>(const Version &other) const;
60 bool operator<=(const Version &other) const;
61 bool operator>=(const Version &other) const;
62 bool operator!=(const Version &other) const;
63};
64
65} // namespace sese