예제 #1
0
Qtilities::Core::VersionNumber::VersionNumber(const VersionNumber& ref)  {
    d = new VersionNumberPrivateData;
    d->version_major = ref.versionMajor();
    d->version_minor = ref.versionMinor();
    d->version_revision = ref.versionRevision();

    d->field_width_minor = ref.fieldWidthMinor();
    d->field_width_revision = ref.fieldWidthRevision();
    d->is_version_minor_used = ref.isVersionMinorUsed();
    d->is_version_revision_used = ref.isVersionRevisionUsed();

    d->development_stage = ref.developmentStage();
    d->development_stage_identifier = ref.developmentStageIdentifier();
    d->version_development_stage = ref.versionDevelopmentStage();
}
예제 #2
0
bool Qtilities::Core::VersionNumber::operator==(const VersionNumber& ref) const {
    if (d->version_major != ref.versionMajor())
        return false;
    if (d->is_version_minor_used && ref.isVersionMinorUsed()) {
        if (d->version_minor != ref.versionMinor())
            return false;
    }
    if (d->is_version_revision_used && ref.isVersionRevisionUsed()) {
        if (d->version_revision != ref.versionRevision())
            return false;
    }
    if (developmentStage(true) != ref.developmentStage(true))
        return false;
    // We can just check developmentStage(true) since we already know ref has the same stage:
    if (developmentStage(true) != DevelopmentStageNone) {
        if (d->version_development_stage != ref.versionDevelopmentStage())
            return false;
    }

    return true;
}
예제 #3
0
bool Qtilities::Core::VersionNumber::operator<(const VersionNumber& ref) {
    if (*this == ref)
        return false;

    if (developmentStage(true) != DevelopmentStageNone || ref.developmentStage(true) != DevelopmentStageNone) {
        // Handle case: 1.5.3 < 2.5.3
        if (d->version_major < ref.versionMajor())
            return true;
        // Handle case: 1.4.3 < 1.5.3 and 2.4.3 < 1.5.3
        if (d->version_minor < ref.versionMinor() && d->version_major == ref.versionMajor())
            return true;
        // Handle case: 1.5.2 < 1.5.3 and 2.5.2 < 1.5.3 and 2.6.2 < 1.5.3
        if (d->version_revision < ref.versionRevision() && d->version_minor == ref.versionMinor() && d->version_major == ref.versionMajor())
            return true;

        // If we get here, we know the major, minor and revision version is NOT smaller. Thus, we check if they are the same if and
        // they are we know we can check the development stage versions:
        if (d->version_revision == ref.versionRevision() && d->version_minor == ref.versionMinor() && d->version_major == ref.versionMajor()) {
            if (developmentStage(true) == ref.developmentStage(true)) {
                if (d->version_development_stage < ref.versionDevelopmentStage())
                    return true;
            } else {
                // In this case consider the development stage order:
                if ((int) developmentStage(true) < (int) ref.developmentStage(true))
                    return true;
            }
        }

        return false;
    }

    if (d->is_version_revision_used && ref.isVersionRevisionUsed()) {
        // Handle case: 1.5.3 < 2.5.3
        if (d->version_major < ref.versionMajor())
            return true;
        if (d->is_version_minor_used && ref.isVersionMinorUsed()) {
            // Handle case: 1.4.3 < 1.5.3 and 2.4.3 < 1.5.3
            if (d->version_minor < ref.versionMinor() && d->version_major == ref.versionMajor())
                return true;
        }
        // Handle case: 1.5.2 < 1.5.3 and 2.5.2 < 1.5.3 and 1.6.2 < 1.5.3
        if (d->version_revision < ref.versionRevision() && d->version_minor == ref.versionMinor() && d->version_major == ref.versionMajor())
            return true;
        // All other cases
        return false;
    }

    if (d->is_version_minor_used && ref.isVersionMinorUsed()) {
        // Handle case: 1.5 < 2.5
        if (d->version_major < ref.versionMajor())
            return true;
        // Handle case: 1.4 < 1.5 and 2.4 < 1.5
        if (d->version_minor < ref.versionMinor() && d->version_major == ref.versionMajor())
            return true;
        // All other cases
        return false;
    }

    if (d->version_major < ref.versionMajor())
        return true;

    return false;
}