mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-03 03:54:04 -06:00
Initial implementation of configuration snapshotting.
This commit is contained in:
parent
2b8da333ef
commit
670061ac33
11 changed files with 787 additions and 31 deletions
|
@ -28,6 +28,24 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
static const Semver zero()
|
||||
{
|
||||
static semver_t ver = { 0, 0, 0, nullptr, nullptr };
|
||||
return Semver(ver);
|
||||
}
|
||||
|
||||
static const Semver inf()
|
||||
{
|
||||
static semver_t ver = { std::numeric_limits<int>::max(), std::numeric_limits<int>::max(), std::numeric_limits<int>::max(), nullptr, nullptr };
|
||||
return Semver(ver);
|
||||
}
|
||||
|
||||
static const Semver invalid()
|
||||
{
|
||||
static semver_t ver = { -1, 0, 0, nullptr, nullptr };
|
||||
return Semver(ver);
|
||||
}
|
||||
|
||||
Semver(Semver &&other) { *this = std::move(other); }
|
||||
Semver(const Semver &other) { *this = other; }
|
||||
|
||||
|
@ -36,13 +54,16 @@ public:
|
|||
ver = other.ver;
|
||||
other.ver.major = other.ver.minor = other.ver.patch = 0;
|
||||
other.ver.metadata = other.ver.prerelease = nullptr;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Semver &operator=(const Semver &other)
|
||||
{
|
||||
::semver_free(&ver);
|
||||
ver = other.ver;
|
||||
if (other.ver.metadata != nullptr) { std::strcpy(ver.metadata, other.ver.metadata); }
|
||||
if (other.ver.prerelease != nullptr) { std::strcpy(ver.prerelease, other.ver.prerelease); }
|
||||
return *this;
|
||||
}
|
||||
|
||||
~Semver() { ::semver_free(&ver); }
|
||||
|
@ -55,8 +76,10 @@ public:
|
|||
bool operator>=(const Semver &b) const { return ::semver_compare(ver, b.ver) >= 0; }
|
||||
bool operator>(const Semver &b) const { return ::semver_compare(ver, b.ver) == 1; }
|
||||
// We're using '&' instead of the '~' operator here as '~' is unary-only:
|
||||
// Satisfies patch if Major and minor are equal.
|
||||
bool operator&(const Semver &b) const { return ::semver_satisfies_patch(ver, b.ver); }
|
||||
bool operator^(const Semver &b) const { return ::semver_satisfies_caret(ver, b.ver); }
|
||||
bool in_range(const Semver &low, const Semver &high) const { return low <= *this && *this <= high; }
|
||||
|
||||
// Conversion
|
||||
std::string to_string() const {
|
||||
|
@ -79,6 +102,7 @@ public:
|
|||
Semver operator-(const Major &b) const { Semver res(*this); return res -= b; }
|
||||
Semver operator-(const Minor &b) const { Semver res(*this); return res -= b; }
|
||||
Semver operator-(const Patch &b) const { Semver res(*this); return res -= b; }
|
||||
|
||||
private:
|
||||
semver_t ver;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue