Lodestone.Common
Loading...
Searching...
No Matches
Semver.h
Go to the documentation of this file.
1
11#ifndef LODESTONE_SEMVER_H
12#define LODESTONE_SEMVER_H
13#include <optional>
14#include <string>
15
21 struct Semver {
22 static constexpr int NONE = -1;
23
24 constexpr std::string toString() const {
25 return "v" + this->toVersionString();
26 }
27
28 constexpr std::string toVersionString() const {
29 std::string ver = std::to_string(major) +
30 "." + std::to_string(minor) +
31 "." + std::to_string(patch);
32
33 if (devVer != NONE) {
34 ver += "-dev." + std::to_string(devVer);
35 }
36
37 return ver;
38 }
39
40 explicit constexpr operator std::string() const {
41 return this->toString();
42 }
43
44 const int major;
45 const int minor;
46 const int patch;
47 const int devVer;
48 };
49} // util
50// app
51// lodestone
52
53#endif // LODESTONE_SEMVER_H
Definition Casts.cpp:10
Rough impl of a Semver class, if you can even call it that... hardly follows the specification lmao.
Definition Semver.h:21
constexpr std::string toVersionString() const
Definition Semver.h:28
static constexpr int NONE
Definition Semver.h:22
const int devVer
Definition Semver.h:47
constexpr std::string toString() const
Definition Semver.h:24
const int minor
Definition Semver.h:45
const int major
Definition Semver.h:44
const int patch
Definition Semver.h:46