1#ifndef SEMANTIC_VERSION_H_
2#define SEMANTIC_VERSION_H_
27 Version() : major(0), minor(0), patch(0) {}
35 Version(
int major,
int minor,
int patch) : major(major), minor(minor), patch(patch) {}
42 Version(
const char *version) : major(0), minor(0), patch(0)
44 if (version != NULL && strlen(version) > 0)
46 if (version[0] ==
'v')
50 sscanf(version,
"%d.%d.%d", &major, &minor, &patch);
88 return (major == other.major && minor == other.minor && patch == other.patch);
98 return !(*
this == other);
108 if (major < other.major)
110 if (major > other.major)
112 if (minor < other.minor)
114 if (minor > other.minor)
116 return patch < other.patch;
126 return other < *
this;
136 return !(other < *
this);
146 return !(*
this < other);
Represents a semantic version.
Definition SemanticVersion.h:17
bool operator!=(const Version &other) const
Checks if this Version object is not equal to another Version object.
Definition SemanticVersion.h:96
bool operator<=(const Version &other) const
Checks if this Version object is less than or equal to another Version object.
Definition SemanticVersion.h:134
bool operator>(const Version &other) const
Checks if this Version object is greater than another Version object.
Definition SemanticVersion.h:124
Version(int major, int minor, int patch)
Constructs a Version object with the specified major, minor, and patch version numbers.
Definition SemanticVersion.h:35
int getMajor() const
Gets the major version number.
Definition SemanticVersion.h:58
int getPatch() const
Gets the patch version number.
Definition SemanticVersion.h:76
bool operator==(const Version &other) const
Checks if this Version object is equal to another Version object.
Definition SemanticVersion.h:86
int getMinor() const
Gets the minor version number.
Definition SemanticVersion.h:67
bool operator>=(const Version &other) const
Checks if this Version object is greater than or equal to another Version object.
Definition SemanticVersion.h:144
Version()
Constructs a Version object with all version numbers set to 0.
Definition SemanticVersion.h:27
Version(const char *version)
Constructs a Version object from a string representation of the version.
Definition SemanticVersion.h:42
bool operator<(const Version &other) const
Checks if this Version object is less than another Version object.
Definition SemanticVersion.h:106