Files
scylladb/version.hh
Avi Kivity fcb8d040e8 treewide: use Software Package Data Exchange (SPDX) license identifiers
Instead of lengthy blurbs, switch to single-line, machine-readable
standardized (https://spdx.dev) license identifiers. The Linux kernel
switched long ago, so there is strong precedent.

Three cases are handled: AGPL-only, Apache-only, and dual licensed.
For the latter case, I chose (AGPL-3.0-or-later and Apache-2.0),
reasoning that our changes are extensive enough to apply our license.

The changes we applied mechanically with a script, except to
licenses/README.md.

Closes #9937
2022-01-18 12:15:18 +01:00

58 lines
1.2 KiB
C++

/*
* Copyright (C) 2015-present ScyllaDB
*/
/*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#pragma once
#include <seastar/core/sstring.hh>
#include <seastar/core/print.hh>
#include <tuple>
namespace version {
class version {
std::tuple<uint16_t, uint16_t, uint16_t> _version;
public:
version(uint16_t x, uint16_t y = 0, uint16_t z = 0): _version(std::make_tuple(x, y, z)) {}
seastar::sstring to_sstring() {
return seastar::format("{:d}.{:d}.{:d}", std::get<0>(_version), std::get<1>(_version), std::get<2>(_version));
}
static version current() {
static version v(3, 0, 8);
return v;
}
bool operator==(version v) const {
return _version == v._version;
}
bool operator!=(version v) const {
return _version != v._version;
}
bool operator<(version v) const {
return _version < v._version;
}
bool operator<=(version v) {
return _version <= v._version;
}
bool operator>(version v) {
return _version > v._version;
}
bool operator>=(version v) {
return _version >= v._version;
}
};
inline const seastar::sstring& release() {
static thread_local auto str_ver = version::current().to_sstring();
return str_ver;
}
}