/** Compare two version strings, tests if the gitHubVersion is more recent * @param localVersion Something like "2.3.4" * @param gitHubVersion Something like "2.3.4" * @returns True if gitHubVersion is more recent */ bool CheckMantidVersion::isVersionMoreRecent( const std::string &localVersion, const std::string &gitHubVersion) const { auto localVersionParts = splitVersionString(localVersion); auto gitHubVersionParts = splitVersionString(gitHubVersion); for (size_t i = 0; i < gitHubVersionParts.size(); i++) { // sanity check if (i >= localVersionParts.size()) { // ran out of items to compare break; } // the revision number needs to be handled separately if (i == 2) { if (localVersionParts[i] > 2000) { // this is a date string, nightly build // state that the local version is up to date return false; } } if (gitHubVersionParts[i] > localVersionParts[i]) { return true; } if (gitHubVersionParts[i] < localVersionParts[i]) { return false; } } return false; }
void K3bVersion::setVersion( const QString& v ) { QString suffix; splitVersionString( v.stripWhiteSpace(), m_majorVersion, suffix ); if( m_majorVersion >= 0 ) { if( suffix.startsWith(".") ) { suffix = suffix.mid( 1 ); splitVersionString( suffix, m_minorVersion, suffix ); if( m_minorVersion < 0 ) { kdDebug() << "(K3bVersion) suffix must not start with a dot!" << endl; m_majorVersion = -1; m_minorVersion = -1; m_patchLevel = -1; m_suffix = ""; } else { if( suffix.startsWith(".") ) { suffix = suffix.mid( 1 ); splitVersionString( suffix, m_patchLevel, suffix ); if( m_patchLevel < 0 ) { kdDebug() << "(K3bVersion) suffix must not start with a dot!" << endl; m_majorVersion = -1; m_minorVersion = -1; m_patchLevel = -1; m_suffix = ""; } else { m_suffix = suffix; } } else { m_patchLevel = -1; m_suffix = suffix; } } } else { m_minorVersion = -1; m_patchLevel = -1; m_suffix = suffix; } } m_versionString = createVersionString( m_majorVersion, m_minorVersion, m_patchLevel, m_suffix ); }