NOISSUE reorganize and document libraries
This commit is contained in:
.gitmodulesCMakeLists.txt
api
gui
logic
AbstractCommonModel.cppAbstractCommonModel.hBaseConfigObject.cppBaseConfigObject.hBaseInstaller.cppBaseInstaller.hBaseInstance.cppBaseInstance.hBaseVersion.hBaseVersionList.cppBaseVersionList.hCMakeLists.txtCommandline.cppCommandline.hDefaultVariable.hEnv.cppEnv.hException.hFileSystem.cppFileSystem.hGZip.cppGZip.hInstanceList.cppInstanceList.hJson.cppJson.hMMCStrings.cppMMCStrings.hMMCZip.cppMMCZip.hNullInstance.hQObjectPtr.hRWStorage.hRecursiveFileSystemWatcher.cppRecursiveFileSystemWatcher.hSeparatorPrefixTree.hTypeMagic.hVersion.cppVersion.h
java
JavaChecker.cppJavaChecker.hJavaCheckerJob.cppJavaCheckerJob.hJavaInstall.cppJavaInstall.hJavaInstallList.cppJavaInstallList.hJavaUtils.cppJavaUtils.hJavaVersion.cppJavaVersion.h
launch
LaunchStep.cppLaunchStep.hLaunchTask.cppLaunchTask.hLoggedProcess.cppLoggedProcess.hMessageLevel.cppMessageLevel.h
steps
minecraft
AssetsUtils.cppAssetsUtils.hGradleSpecifier.hJarMod.hLibrary.cppLibrary.hMinecraftInstance.cppMinecraftInstance.hMinecraftProfile.cppMinecraftProfile.hMinecraftVersion.cppMinecraftVersion.hMinecraftVersionList.cppMinecraftVersionList.hMod.cppMod.hModList.cppModList.hMojangDownloadInfo.hMojangVersionFormat.cppMojangVersionFormat.hOpSys.cppOpSys.hParseUtils.cppParseUtils.hProfilePatch.hProfileStrategy.hProfileUtils.cppProfileUtils.hRule.cppRule.hVersionBuildError.hVersionFile.cppVersionFile.hVersionFilterData.cppVersionFilterData.hWorld.cppWorld.hWorldList.cppWorldList.h
auth
AuthSession.cppAuthSession.hMojangAccount.cppMojangAccount.hMojangAccountList.cppMojangAccountList.hYggdrasilTask.cppYggdrasilTask.h
flows
forge
ForgeInstaller.cppForgeInstaller.hForgeVersion.cppForgeVersion.hForgeVersionList.cppForgeVersionList.hForgeXzDownload.cppForgeXzDownload.hLegacyForge.cppLegacyForge.h
ftb
FTBPlugin.cppFTBPlugin.hFTBProfileStrategy.cppFTBProfileStrategy.hFTBVersion.hLegacyFTBInstance.cppLegacyFTBInstance.hOneSixFTBInstance.cppOneSixFTBInstance.h
legacy
LegacyInstance.cppLegacyInstance.hLegacyUpdate.cppLegacyUpdate.hLwjglVersionList.cppLwjglVersionList.h
liteloader
onesix
net
ByteArrayDownload.cppByteArrayDownload.hCacheDownload.cppCacheDownload.hHttpMetaCache.cppHttpMetaCache.hMD5EtagDownload.cppMD5EtagDownload.hNetAction.hNetJob.cppNetJob.hPasteUpload.cppPasteUpload.hURLConstants.cppURLConstants.h
news
notifications
pathmatcher
resources
Resource.cppResource.hResourceHandler.cppResourceHandler.hResourceObserver.cppResourceObserver.hResourceProxyModel.cppResourceProxyModel.h
screenshots
settings
INIFile.cppINIFile.hINISettingsObject.cppINISettingsObject.hOverrideSetting.cppOverrideSetting.hPassthroughSetting.cppPassthroughSetting.hSetting.cppSetting.hSettingsObject.cppSettingsObject.h
status
tasks
tools
BaseExternalTool.cppBaseExternalTool.hBaseProfiler.cppBaseProfiler.hJProfiler.cppJProfiler.hJVisualVM.cppJVisualVM.hMCEditTool.cppMCEditTool.h
trans
updater
wonko
depends/LogicalGui
libraries
README.md
classparser
hoedown
iconfix
javacheck
launcher
.gitignoreCMakeLists.txt
libnbtplusplusnet
minecraft
org
pack200
rainbow
xz-embedded
112
api/logic/java/JavaVersion.cpp
Normal file
112
api/logic/java/JavaVersion.cpp
Normal file
@ -0,0 +1,112 @@
|
||||
#include "JavaVersion.h"
|
||||
#include <MMCStrings.h>
|
||||
|
||||
#include <QRegularExpression>
|
||||
#include <QString>
|
||||
|
||||
JavaVersion & JavaVersion::operator=(const QString & javaVersionString)
|
||||
{
|
||||
string = javaVersionString;
|
||||
|
||||
auto getCapturedInteger = [](const QRegularExpressionMatch & match, const QString &what) -> int
|
||||
{
|
||||
auto str = match.captured(what);
|
||||
if(str.isEmpty())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return str.toInt();
|
||||
};
|
||||
|
||||
QRegularExpression pattern;
|
||||
if(javaVersionString.startsWith("1."))
|
||||
{
|
||||
pattern = QRegularExpression ("1[.](?<major>[0-9]+)([.](?<minor>[0-9]+))?(_(?<security>[0-9]+)?)?(-(?<prerelease>[a-zA-Z0-9]+))?");
|
||||
}
|
||||
else
|
||||
{
|
||||
pattern = QRegularExpression("(?<major>[0-9]+)([.](?<minor>[0-9]+))?([.](?<security>[0-9]+))?(-(?<prerelease>[a-zA-Z0-9]+))?");
|
||||
}
|
||||
|
||||
auto match = pattern.match(string);
|
||||
parseable = match.hasMatch();
|
||||
major = getCapturedInteger(match, "major");
|
||||
minor = getCapturedInteger(match, "minor");
|
||||
security = getCapturedInteger(match, "security");
|
||||
prerelease = match.captured("prerelease");
|
||||
return *this;
|
||||
}
|
||||
|
||||
JavaVersion::JavaVersion(const QString &rhs)
|
||||
{
|
||||
operator=(rhs);
|
||||
}
|
||||
|
||||
QString JavaVersion::toString()
|
||||
{
|
||||
return string;
|
||||
}
|
||||
|
||||
bool JavaVersion::requiresPermGen()
|
||||
{
|
||||
if(parseable)
|
||||
{
|
||||
return major < 8;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool JavaVersion::operator<(const JavaVersion &rhs)
|
||||
{
|
||||
if(parseable && rhs.parseable)
|
||||
{
|
||||
if(major < rhs.major)
|
||||
return true;
|
||||
if(major > rhs.major)
|
||||
return false;
|
||||
if(minor < rhs.minor)
|
||||
return true;
|
||||
if(minor > rhs.minor)
|
||||
return false;
|
||||
if(security < rhs.security)
|
||||
return true;
|
||||
if(security > rhs.security)
|
||||
return false;
|
||||
|
||||
// everything else being equal, consider prerelease status
|
||||
bool thisPre = !prerelease.isEmpty();
|
||||
bool rhsPre = !rhs.prerelease.isEmpty();
|
||||
if(thisPre && !rhsPre)
|
||||
{
|
||||
// this is a prerelease and the other one isn't -> lesser
|
||||
return true;
|
||||
}
|
||||
else if(!thisPre && rhsPre)
|
||||
{
|
||||
// this isn't a prerelease and the other one is -> greater
|
||||
return false;
|
||||
}
|
||||
else if(thisPre && rhsPre)
|
||||
{
|
||||
// both are prereleases - use natural compare...
|
||||
return Strings::naturalCompare(prerelease, rhs.prerelease, Qt::CaseSensitive) < 0;
|
||||
}
|
||||
// neither is prerelease, so they are the same -> this cannot be less than rhs
|
||||
return false;
|
||||
}
|
||||
else return Strings::naturalCompare(string, rhs.string, Qt::CaseSensitive) < 0;
|
||||
}
|
||||
|
||||
bool JavaVersion::operator==(const JavaVersion &rhs)
|
||||
{
|
||||
if(parseable && rhs.parseable)
|
||||
{
|
||||
return major == rhs.major && minor == rhs.minor && security == rhs.security && prerelease == rhs.prerelease;
|
||||
}
|
||||
return string == rhs.string;
|
||||
}
|
||||
|
||||
bool JavaVersion::operator>(const JavaVersion &rhs)
|
||||
{
|
||||
return (!operator<(rhs)) && (!operator==(rhs));
|
||||
}
|
Reference in New Issue
Block a user