version_t Derived Type

type, public :: version_t


Type-Bound Procedures

generic, public :: operator(.match.) => match

Compare a version against a version constraint (x.x.0 <= v < x.x.HUGE)

  • private elemental function match(lhs, rhs)

    Try to match first version against second version

    Arguments

    Type IntentOptional Attributes Name
    class(version_t), intent(in) :: lhs

    First version number

    class(version_t), intent(in) :: rhs

    Second version number

    Return Value logical

    Version match following semantic versioning rules

generic, public :: operator(/=) => not_equals

  • private elemental function not_equals(lhs, rhs) result(not_equal)

    Check two versions for inequality

    Arguments

    Type IntentOptional Attributes Name
    class(version_t), intent(in) :: lhs

    First version number

    class(version_t), intent(in) :: rhs

    Second version number

    Return Value logical

    Version mismatch

generic, public :: operator(<) => less

  • private elemental function less(lhs, rhs) result(is_less)

    Relative comparison of two versions

    Arguments

    Type IntentOptional Attributes Name
    class(version_t), intent(in) :: lhs

    First version number

    class(version_t), intent(in) :: rhs

    Second version number

    Return Value logical

    First version is less

generic, public :: operator(<=) => less_equals

  • private elemental function less_equals(lhs, rhs) result(is_less_equal)

    Relative comparison of two versions

    Arguments

    Type IntentOptional Attributes Name
    class(version_t), intent(in) :: lhs

    First version number

    class(version_t), intent(in) :: rhs

    Second version number

    Return Value logical

    First version is less or equal

generic, public :: operator(==) => equals

  • private elemental function equals(lhs, rhs) result(is_equal)

    Check to version numbers for equality

    Arguments

    Type IntentOptional Attributes Name
    class(version_t), intent(in) :: lhs

    First version number

    class(version_t), intent(in) :: rhs

    Second version number

    Return Value logical

    Version match

generic, public :: operator(>) => greater

  • private elemental function greater(lhs, rhs) result(is_greater)

    Relative comparison of two versions

    Arguments

    Type IntentOptional Attributes Name
    class(version_t), intent(in) :: lhs

    First version number

    class(version_t), intent(in) :: rhs

    Second version number

    Return Value logical

    First version is greater

generic, public :: operator(>=) => greater_equals

  • private elemental function greater_equals(lhs, rhs) result(is_greater_equal)

    Relative comparison of two versions

    Arguments

    Type IntentOptional Attributes Name
    class(version_t), intent(in) :: lhs

    First version number

    class(version_t), intent(in) :: rhs

    Second version number

    Return Value logical

    First version is greater or equal

procedure, public :: s

Create a printable string from a version data type

  • private pure function s(self) result(string)

    Arguments

    Type IntentOptional Attributes Name
    class(version_t), intent(in) :: self

    Version number

    Return Value character(len=:), allocatable

    Character representation of the version

Source Code

    type :: version_t
        private

        !> Version numbers found
        integer, allocatable :: num(:)

    contains

        generic :: operator(==) => equals
        procedure, private :: equals

        generic :: operator(/=) => not_equals
        procedure, private :: not_equals

        generic :: operator(>) => greater
        procedure, private :: greater

        generic :: operator(<) => less
        procedure, private :: less

        generic :: operator(>=) => greater_equals
        procedure, private :: greater_equals

        generic :: operator(<=) => less_equals
        procedure, private :: less_equals

        !> Compare a version against a version constraint (x.x.0 <= v < x.x.HUGE)
        generic :: operator(.match.) => match
        procedure, private :: match

        !> Create a printable string from a version data type
        procedure :: s

    end type version_t