#pragma once #include struct Version { byte parts[3]; ///< Version numbers: [0]=major, [1]=minor, [2]=patch] byte& major() { return parts[0]; } byte& minor() { return parts[1]; } byte& patch() { return parts[2]; } const byte& major() const { return parts[0]; } const byte& minor() const { return parts[1]; } const byte& patch() const { return parts[2]; } String toString() const { return String(parts[0]) + "." + String(parts[1]) + "." + String(parts[2]); } // Comparison operators bool operator==(const Version& other) const { return parts[0] == other.parts[0] && parts[1] == other.parts[1] && parts[2] == other.parts[2]; } bool operator!=(const Version& other) const { return !(*this == other); } bool operator<(const Version& other) const { return (parts[0] < other.parts[0]) || (parts[0] == other.parts[0] && parts[1] < other.parts[1]) || (parts[0] == other.parts[0] && parts[1] == other.parts[1] && parts[2] < other.parts[2]); } bool operator>(const Version& other) const { return other < *this; } bool operator<=(const Version& other) const { return !(*this > other); } bool operator>=(const Version& other) const { return !(*this < other); } };