2023-08-28 12:31:18 +02:00
|
|
|
/* Version.
|
2018-08-27 11:09:25 +02:00
|
|
|
*
|
2023-08-31 17:35:12 +02:00
|
|
|
* Author: Steffen Vogel <post@steffenvogel.de>
|
2023-08-31 11:17:07 +02:00
|
|
|
* SPDX-FileCopyrightText: 2014-2023 Institute for Automation of Complex Power Systems, RWTH Aachen University
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2023-08-28 12:31:18 +02:00
|
|
|
*/
|
2018-08-27 11:09:25 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace villas {
|
|
|
|
namespace utils {
|
|
|
|
|
|
|
|
class Version {
|
|
|
|
|
|
|
|
protected:
|
2023-09-07 13:19:19 +02:00
|
|
|
int components[3];
|
2018-08-27 11:09:25 +02:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
static int cmp(const Version &lhs, const Version &rhs);
|
2018-08-27 11:09:25 +02:00
|
|
|
|
|
|
|
public:
|
2023-09-07 13:19:19 +02:00
|
|
|
// Parse a dotted version string.
|
|
|
|
Version(const std::string &s);
|
2018-08-27 11:09:25 +02:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
Version(int maj, int min = 0, int pat = 0);
|
2018-08-27 11:09:25 +02:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
inline bool operator==(const Version &rhs) { return cmp(*this, rhs) == 0; }
|
2022-12-02 17:16:44 +01:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
inline bool operator!=(const Version &rhs) { return cmp(*this, rhs) != 0; }
|
2022-12-02 17:16:44 +01:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
inline bool operator<(const Version &rhs) { return cmp(*this, rhs) < 0; }
|
2022-12-02 17:16:44 +01:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
inline bool operator>(const Version &rhs) { return cmp(*this, rhs) > 0; }
|
2022-12-02 17:16:44 +01:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
inline bool operator<=(const Version &rhs) { return cmp(*this, rhs) <= 0; }
|
2022-12-02 17:16:44 +01:00
|
|
|
|
2023-09-07 13:19:19 +02:00
|
|
|
inline bool operator>=(const Version &rhs) { return cmp(*this, rhs) >= 0; }
|
2018-08-27 11:09:25 +02:00
|
|
|
};
|
|
|
|
|
2022-12-02 17:16:44 +01:00
|
|
|
} // namespace utils
|
2023-09-07 13:19:19 +02:00
|
|
|
} // namespace villas
|