diff options
author | Trial97 <alexandru.tripon97@gmail.com> | 2023-07-26 21:33:15 +0300 |
---|---|---|
committer | Trial97 <alexandru.tripon97@gmail.com> | 2023-07-26 21:33:15 +0300 |
commit | c778dcbc9c326c1bf563852d7393bf43c1514346 (patch) | |
tree | b0b556492b5c83d07858f60d56feadca64983648 /launcher/java/JavaInstall.cpp | |
parent | d7f4e40f85d1e253fe62e1c9e1cfb1842ffb0c86 (diff) | |
parent | a0944dab7a8fff9b5d9c2c8d35cc55349c93a3cd (diff) | |
download | PrismLauncher-c778dcbc9c326c1bf563852d7393bf43c1514346.tar.gz PrismLauncher-c778dcbc9c326c1bf563852d7393bf43c1514346.tar.bz2 PrismLauncher-c778dcbc9c326c1bf563852d7393bf43c1514346.zip |
Merge branch 'develop' of https://github.com/PrismLauncher/PrismLauncher into curse
Diffstat (limited to 'launcher/java/JavaInstall.cpp')
-rw-r--r-- | launcher/java/JavaInstall.cpp | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/launcher/java/JavaInstall.cpp b/launcher/java/JavaInstall.cpp index d5932bcb..cfa47140 100644 --- a/launcher/java/JavaInstall.cpp +++ b/launcher/java/JavaInstall.cpp @@ -1,29 +1,64 @@ +// SPDX-License-Identifier: GPL-3.0-only +/* + * Prism Launcher - Minecraft Launcher + * Copyright (c) 2023 Trial97 <alexandru.tripon97@gmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, version 3. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + #include "JavaInstall.h" +#include "BaseVersion.h" #include "StringUtils.h" -bool JavaInstall::operator<(const JavaInstall &rhs) +bool JavaInstall::operator<(const JavaInstall& rhs) { auto archCompare = StringUtils::naturalCompare(arch, rhs.arch, Qt::CaseInsensitive); - if(archCompare != 0) + if (archCompare != 0) return archCompare < 0; - if(id < rhs.id) - { + if (id < rhs.id) { return true; } - if(id > rhs.id) - { + if (id > rhs.id) { return false; } return StringUtils::naturalCompare(path, rhs.path, Qt::CaseInsensitive) < 0; } -bool JavaInstall::operator==(const JavaInstall &rhs) +bool JavaInstall::operator==(const JavaInstall& rhs) { return arch == rhs.arch && id == rhs.id && path == rhs.path; } -bool JavaInstall::operator>(const JavaInstall &rhs) +bool JavaInstall::operator>(const JavaInstall& rhs) { return (!operator<(rhs)) && (!operator==(rhs)); } + +bool JavaInstall::operator<(BaseVersion& a) +{ + try { + return operator<(dynamic_cast<JavaInstall&>(a)); + } catch (const std::bad_cast& e) { + return BaseVersion::operator<(a); + } +} + +bool JavaInstall::operator>(BaseVersion& a) +{ + try { + return operator>(dynamic_cast<JavaInstall&>(a)); + } catch (const std::bad_cast& e) { + return BaseVersion::operator>(a); + } +} |