58 lines
1.5 KiB
C++
58 lines
1.5 KiB
C++
#ifndef NEXTCLOUD_VERSION_HPP
|
|
#define NEXTCLOUD_VERSION_HPP
|
|
|
|
#include <string>
|
|
|
|
namespace nextcloud {
|
|
|
|
// Semantic versioning
|
|
constexpr int VERSION_MAJOR = 0;
|
|
constexpr int VERSION_MINOR = 1;
|
|
constexpr int VERSION_PATCH = 0;
|
|
|
|
// Build metadata
|
|
constexpr const char* VERSION_STRING = "0.1.0";
|
|
constexpr const char* BUILD_DATE = __DATE__;
|
|
constexpr const char* BUILD_TIME = __TIME__;
|
|
|
|
/**
|
|
* @brief Get the library version as a string
|
|
* @return Version string in format "MAJOR.MINOR.PATCH"
|
|
*/
|
|
inline std::string getVersionString() {
|
|
return VERSION_STRING;
|
|
}
|
|
|
|
/**
|
|
* @brief Get the library version components
|
|
* @param major Output parameter for major version
|
|
* @param minor Output parameter for minor version
|
|
* @param patch Output parameter for patch version
|
|
*/
|
|
inline void getVersion(int& major, int& minor, int& patch) {
|
|
major = VERSION_MAJOR;
|
|
minor = VERSION_MINOR;
|
|
patch = VERSION_PATCH;
|
|
}
|
|
|
|
/**
|
|
* @brief Check if the library version is at least the specified version
|
|
* @param major Required major version
|
|
* @param minor Required minor version
|
|
* @param patch Required patch version
|
|
* @return True if current version >= required version
|
|
*/
|
|
inline bool isVersionAtLeast(int major, int minor, int patch) {
|
|
if (VERSION_MAJOR > major) return true;
|
|
if (VERSION_MAJOR < major) return false;
|
|
|
|
if (VERSION_MINOR > minor) return true;
|
|
if (VERSION_MINOR < minor) return false;
|
|
|
|
return VERSION_PATCH >= patch;
|
|
}
|
|
|
|
} // namespace nextcloud
|
|
|
|
#endif // NEXTCLOUD_VERSION_HPP
|