/**************************************************************************/1/* semver.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "core/string/ustring.h"3334#include "modules/regex/regex.h"3536// <sys/sysmacros.h> is included somewhere, which defines major(dev) to gnu_dev_major(dev)37#if defined(major)38#undef major39#endif40#if defined(minor)41#undef minor42#endif4344namespace godotsharp {4546struct SemVer {47private:48static bool parse_digit_only_field(const String &p_field, uint64_t &r_result);4950static int cmp(const SemVer &p_a, const SemVer &p_b);5152public:53int major = 0;54int minor = 0;55int patch = 0;56String prerelease;57String build_metadata;5859bool operator==(const SemVer &b) const {60return cmp(*this, b) == 0;61}6263bool operator!=(const SemVer &b) const {64return !operator==(b);65}6667bool operator<(const SemVer &b) const {68return cmp(*this, b) < 0;69}7071bool operator>(const SemVer &b) const {72return cmp(*this, b) > 0;73}7475bool operator<=(const SemVer &b) const {76return cmp(*this, b) <= 0;77}7879bool operator>=(const SemVer &b) const {80return cmp(*this, b) >= 0;81}8283SemVer() {}8485SemVer(int p_major, int p_minor, int p_patch,86const String &p_prerelease, const String &p_build_metadata) :87major(p_major),88minor(p_minor),89patch(p_patch),90prerelease(p_prerelease),91build_metadata(p_build_metadata) {92}93};9495struct SemVerParser {96private:97RegEx regex;9899public:100bool parse(const String &p_ver_text, SemVer &r_semver);101};102103} //namespace godotsharp104105106