Qx v0.5.7
Qt Extensions Library
Loading...
Searching...
No Matches
Qx::VersionNumber Class Reference

The VersionNumber class extends QVersionNumber to include a dedicated constructor and getter for the fourth version segment. More...

#include <qx/core/qx-versionnumber.h>

Collaboration diagram for Qx::VersionNumber:
[legend]

Public Member Functions

 VersionNumber ()
 
 VersionNumber (const QList< int > &seg)
 
 VersionNumber (int maj)
 
 VersionNumber (int maj, int min)
 
 VersionNumber (int maj, int min, int mic)
 
 VersionNumber (int maj, int min, int mic, int nan)
 
 VersionNumber (QList< int > &&seg)
 
 VersionNumber (std::initializer_list< int > args)
 
VersionNumber first (qsizetype n) const
 
int nanoVersion () const
 
VersionNumber normalized (qsizetype min=0) const
 
- Public Member Functions inherited from QVersionNumber
 QVersionNumber (const QList< int > &seg)
 
 QVersionNumber (const QVarLengthArray< int, N > &seg)
 
 QVersionNumber (int maj)
 
 QVersionNumber (int maj, int min)
 
 QVersionNumber (int maj, int min, int mic)
 
 QVersionNumber (QList< int > &&seg)
 
 QVersionNumber (std::initializer_list< int > args)
 
bool isNormalized () const const
 
bool isNull () const const
 
bool isPrefixOf (const QVersionNumber &other) const const
 
int majorVersion () const const
 
int microVersion () const const
 
int minorVersion () const const
 
QVersionNumber normalized () const const
 
bool operator!= (const QVersionNumber &lhs, const QVersionNumber &rhs)
 
bool operator< (const QVersionNumber &lhs, const QVersionNumber &rhs)
 
QDataStreamoperator<< (QDataStream &out, const QVersionNumber &version)
 
bool operator<= (const QVersionNumber &lhs, const QVersionNumber &rhs)
 
bool operator== (const QVersionNumber &lhs, const QVersionNumber &rhs)
 
bool operator> (const QVersionNumber &lhs, const QVersionNumber &rhs)
 
bool operator>= (const QVersionNumber &lhs, const QVersionNumber &rhs)
 
QDataStreamoperator>> (QDataStream &in, QVersionNumber &version)
 
int segmentAt (qsizetype index) const const
 
qsizetype segmentCount () const const
 
QList< int > segments () const const
 
QString toString () const const
 

Static Public Member Functions

static VersionNumber commonPrefix (const VersionNumber &v1, const VersionNumber &v2)
 
static VersionNumber fromString (const QString &string, int *suffixIndex=nullptr)
 
static VersionNumber fromString (QLatin1String string, int *suffixIndex=nullptr)
 
static VersionNumber fromString (QStringView string, int *suffixIndex=nullptr)
 
- Static Public Member Functions inherited from QVersionNumber
QVersionNumber commonPrefix (const QVersionNumber &v1, const QVersionNumber &v2)
 
int compare (const QVersionNumber &v1, const QVersionNumber &v2)
 
QVersionNumber fromString (QAnyStringView string, qsizetype *suffixIndex)
 

Detailed Description

While there are many terms used to describe each segment in a typical four part version number, the fourth segment in this class is dubbed "Nano Version" to stay consistent with the naming scheme of QVersionNumber.

Constructor & Destructor Documentation

◆ VersionNumber() [1/8]

Qx::VersionNumber::VersionNumber ( int maj,
int min,
int mic,
int nan )

Constructs a VersionNumber consisting of the major, minor, micro, and nano version numbers maj, min, mic, and nan, respectively.

◆ VersionNumber() [2/8]

Qx::VersionNumber::VersionNumber ( int maj,
int min,
int mic )

Constructs a VersionNumber consisting of the major, minor and micro version numbers maj, min and mic, respectively.

◆ VersionNumber() [3/8]

Qx::VersionNumber::VersionNumber ( int maj,
int min )

Constructs a VersionNumber consisting of the major and minor version numbers maj and min, respectively.

◆ VersionNumber() [4/8]

Qx::VersionNumber::VersionNumber ( int maj)

Constructs a VersionNumber consisting of just the major version number maj.

◆ VersionNumber() [5/8]

Qx::VersionNumber::VersionNumber ( std::initializer_list< int > args)

Construct a version number from the std::initializer_list specified by args.

◆ VersionNumber() [6/8]

Qx::VersionNumber::VersionNumber ( QList< int > && seg)

Move-constructs a version number from the list of numbers contained in seg.

◆ VersionNumber() [7/8]

Qx::VersionNumber::VersionNumber ( const QList< int > & seg)

Construct a version number from the std::initializer_list specified by args.

◆ VersionNumber() [8/8]

Qx::VersionNumber::VersionNumber ( )

Produces a null version.

Member Function Documentation

◆ commonPrefix()

VersionNumber Qx::VersionNumber::commonPrefix ( const VersionNumber & v1,
const VersionNumber & v2 )
static

Returns a version number that is a parent version of both v1 and v2.

See also
isPrefixOf()

◆ first()

VersionNumber Qx::VersionNumber::first ( qsizetype n) const

Returns a version number that contains the first n segments of this version number, or all segments if there are less than n available.

See also
commonPrefix().

◆ fromString() [1/3]

VersionNumber Qx::VersionNumber::fromString ( const QString & string,
int * suffixIndex = nullptr )
static

Constructs a VersionNumber from a specially formatted string of non-negative decimal delimited by a period (.).

Once the numerical segments have been parsed, the remainder of the string is considered to be the suffix string. The start index of that string will be stored in suffixIndex if it is not null.

See also
isNull().

◆ fromString() [2/3]

VersionNumber Qx::VersionNumber::fromString ( QLatin1String string,
int * suffixIndex = nullptr )
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ fromString() [3/3]

VersionNumber Qx::VersionNumber::fromString ( QStringView string,
int * suffixIndex = nullptr )
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ nanoVersion()

int Qx::VersionNumber::nanoVersion ( ) const

Returns the nano version number, that is, the fourth segment. This function is equivalent to segmentAt(3). If this VersionNumber object is null, this function returns 0.

See also
isNull(), segmentAt().

◆ normalized()

VersionNumber Qx::VersionNumber::normalized ( qsizetype min = 0) const

Returns an equivalent version number but with all trailing zeros removed.

If min is greater than 0, at least that many segments, up to segmentCount(), are kept in the resultant version number, even if some of them are trailing zeros.

VersionNumber v1(3,0,0,0);
VersionNumber v2(10,1,0);
VersionNumber v3(1,2,0,0);
VersionNumber n1 = v1.normalized(2);
VersionNumber n2 = v2.normalized(8);
VersionNumber n3 = v3.normalized();
// n1 is 3.0
// n2 is 10.1.0
// n3 is 1.2

The documentation for this class was generated from the following files: