VersionNumber Class Reference

A data type for version numbers. More...

#include <versionnumber.h>

List of all members.

Public Member Functions

 VersionNumber ()
 VersionNumber (const VersionNumber &value)
 VersionNumber (const QString &value)
 VersionNumber (const qint64 value)
virtual ~VersionNumber ()
QString toString () const
VersionNumber operator= (const VersionNumber &value)
VersionNumber operator= (const QString &value)
VersionNumber operator= (qint64 value)
bool operator< (const VersionNumber &value) const
bool operator<= (const VersionNumber &value) const
bool operator> (const VersionNumber &value) const
bool operator>= (const VersionNumber &value) const
bool operator== (const VersionNumber &value) const
bool operator!= (const VersionNumber &value) const

Private Types

enum  characterType {
  letter, digit,
  other
}
enum  type_whichIsBigger {
  first_one, second_one,
  both_are_equal
}
typedef QStringList simpleNumber
typedef QList< simpleNumbernumberWithPoints
typedef QList< numberWithPointsnumberWithPointsAndDashes

Private Member Functions

void helper_copyFromHere (const VersionNumber &value)
void helper_setValue (const QString &value)

Static Private Member Functions

static VersionNumber::characterType helper_characterType (const QChar &value)
static VersionNumber::simpleNumber helper_createSimpleNumber (const QString &value)
static
VersionNumber::numberWithPoints 
helper_createNumberWithPoints (const QString &value)
static
VersionNumber::numberWithPointsAndDashes 
helper_createNumberWithPointsAndDashes (const QString &value)
static
VersionNumber::type_whichIsBigger 
whichIsBigger (const VersionNumber &firstValue, const VersionNumber &secondValue)
static
VersionNumber::type_whichIsBigger 
whichIsBigger (const numberWithPointsAndDashes &firstValue, const numberWithPointsAndDashes &secondValue)
static
VersionNumber::type_whichIsBigger 
whichIsBigger (const numberWithPoints &firstValue, const numberWithPoints &secondValue)
static
VersionNumber::type_whichIsBigger 
whichIsBigger (const simpleNumber &firstValue, const simpleNumber &secondValue)
static
VersionNumber::type_whichIsBigger 
whichIsBigger (const QString &firstValue, const QString &secondValue)
static
VersionNumber::type_whichIsBigger 
helper_whichNumberIsBigger (const QString &firstValue, const QString &secondValue)
static
VersionNumber::type_whichIsBigger 
helper_whichStringIsBigger (const QString &firstValue, const QString &secondValue)

Private Attributes

QString theString
numberWithPointsAndDashes epoch
numberWithPointsAndDashes version_and_release


Detailed Description

A data type for version numbers.

This class provides a data type for version numbers. Think of it as a QString which provides special behavior for version numbers in the six relational operators (<, <=, >, >=, ==, !=).

The behavior of the relational operators is similar to the behavior of RPM when comparing versions. "Similar" means that it is not equal! See http://rpm.org/wiki/PackagerDocs/Dependencies for a good description of the algorithm used by RPM to determinate version ordering.

You can assign values of the type QString and even qint64 (which will be converted to a QString) and of course of the type VersionNumber itself to it. You can use the assignment operator or the constructor for initiation. The data type is made available to QMetaType and is this way available in for example QVariant. If you want to use it in in non-template based functions like queued signal and slot connections, do something like int id = qRegisterMetaType<VersionNumber>("VersionNumber"); at the begin of your main function. This will register the type also for this use case. id will contain the type identifier used by QMetaObject. However, for most cases id isn't intresting.

You can convert to a string with toString(). This function returns always exactly the string which was used to initialize this object.

To compare version numbers, the QString is segmented into small parts. See http://rpm.org/wiki/PackagerDocs/Dependencies for details. The algorithm of VersionNumber differs in some points from the algorithm of RPM:

Definition at line 71 of file versionnumber.h.


Member Typedef Documentation

typedef QList< simpleNumber > VersionNumber::numberWithPoints [private]

Internally used data type for parts of the version number like "2.12rc1.3".

Definition at line 96 of file versionnumber.h.

Internally used data type for parts of the version number like "2.12rc1.3-9.7".

Definition at line 98 of file versionnumber.h.

typedef QStringList VersionNumber::simpleNumber [private]

Internally used data type for parts of the version number like "12rc1".

Definition at line 94 of file versionnumber.h.


Member Enumeration Documentation

Internally used data type for determinating if a QChar is

  • QChar::isLetter() or
  • QChar::isDigit or
  • neither the one nor the other
Enumerator:
letter 
digit 
other 

Definition at line 103 of file versionnumber.h.

Internally used data type for determinating if when comparing two values

  • the first one is bigger or
  • the second one is bigger or
  • both are equal
Enumerator:
first_one 
second_one 
both_are_equal 

Definition at line 112 of file versionnumber.h.


Constructor & Destructor Documentation

VersionNumber::VersionNumber (  ) 

Definition at line 23 of file versionnumber.cpp.

VersionNumber::VersionNumber ( const VersionNumber value  ) 

Definition at line 32 of file versionnumber.cpp.

References helper_copyFromHere().

Here is the call graph for this function:

VersionNumber::VersionNumber ( const QString &  value  ) 

Definition at line 27 of file versionnumber.cpp.

References helper_setValue().

Here is the call graph for this function:

VersionNumber::VersionNumber ( const qint64  value  ) 

Definition at line 37 of file versionnumber.cpp.

References helper_setValue().

Here is the call graph for this function:

VersionNumber::~VersionNumber (  )  [virtual]

Definition at line 42 of file versionnumber.cpp.


Member Function Documentation

VersionNumber::characterType VersionNumber::helper_characterType ( const QChar &  value  )  [static, private]

Internally used to determinate the type of a QChar.

See also:
VersionNumber::characterType

Definition at line 113 of file versionnumber.cpp.

References digit, letter, and other.

Referenced by helper_createSimpleNumber().

Here is the caller graph for this function:

void VersionNumber::helper_copyFromHere ( const VersionNumber value  )  [private]

Internally used to copy another object to this object.

Definition at line 192 of file versionnumber.cpp.

References epoch, theString, and version_and_release.

Referenced by operator=(), and VersionNumber().

Here is the caller graph for this function:

VersionNumber::numberWithPoints VersionNumber::helper_createNumberWithPoints ( const QString &  value  )  [static, private]

Internally used to create a VersionNumber::numberWithPoints from a QString.

Definition at line 160 of file versionnumber.cpp.

References helper_createSimpleNumber().

Referenced by helper_createNumberWithPointsAndDashes().

Here is the call graph for this function:

Here is the caller graph for this function:

VersionNumber::numberWithPointsAndDashes VersionNumber::helper_createNumberWithPointsAndDashes ( const QString &  value  )  [static, private]

Internally used to create a VersionNumber::numberWithPointsAndDashes from a QString.

Definition at line 176 of file versionnumber.cpp.

References helper_createNumberWithPoints().

Referenced by helper_setValue().

Here is the call graph for this function:

Here is the caller graph for this function:

VersionNumber::simpleNumber VersionNumber::helper_createSimpleNumber ( const QString &  value  )  [static, private]

Internally used to create a VersionNumber::simpleNumber from a QString.

Definition at line 131 of file versionnumber.cpp.

References helper_characterType().

Referenced by helper_createNumberWithPoints().

Here is the call graph for this function:

Here is the caller graph for this function:

void VersionNumber::helper_setValue ( const QString &  value  )  [private]

Internally used to set the value of this object to a specified string and create the segmented version of the string in epoch and version_and_release.

Definition at line 99 of file versionnumber.cpp.

References epoch, helper_createNumberWithPointsAndDashes(), theString, and version_and_release.

Referenced by operator=(), and VersionNumber().

Here is the call graph for this function:

Here is the caller graph for this function:

VersionNumber::type_whichIsBigger VersionNumber::helper_whichNumberIsBigger ( const QString &  firstValue,
const QString &  secondValue 
) [static, private]

Internally used to compare 2 QStrings which are assumed to contain digits.

Note:
This function assumes the values to be strings which contain numbers. If not, this function will not have a useful result.

Definition at line 340 of file versionnumber.cpp.

References both_are_equal, first_one, and second_one.

Referenced by whichIsBigger().

Here is the caller graph for this function:

VersionNumber::type_whichIsBigger VersionNumber::helper_whichStringIsBigger ( const QString &  firstValue,
const QString &  secondValue 
) [static, private]

Internally used to compare 2 QStrings which are assumed to not contain digits.

Definition at line 372 of file versionnumber.cpp.

References both_are_equal, first_one, and second_one.

Referenced by whichIsBigger().

Here is the caller graph for this function:

bool VersionNumber::operator!= ( const VersionNumber value  )  const

Definition at line 94 of file versionnumber.cpp.

References both_are_equal, and whichIsBigger().

Here is the call graph for this function:

bool VersionNumber::operator< ( const VersionNumber value  )  const

Definition at line 69 of file versionnumber.cpp.

References second_one, and whichIsBigger().

Here is the call graph for this function:

bool VersionNumber::operator<= ( const VersionNumber value  )  const

Definition at line 74 of file versionnumber.cpp.

References first_one, and whichIsBigger().

Here is the call graph for this function:

VersionNumber VersionNumber::operator= ( qint64  value  ) 

Definition at line 63 of file versionnumber.cpp.

References helper_setValue().

Here is the call graph for this function:

VersionNumber VersionNumber::operator= ( const QString &  value  ) 

Definition at line 57 of file versionnumber.cpp.

References helper_setValue().

Here is the call graph for this function:

VersionNumber VersionNumber::operator= ( const VersionNumber value  ) 

Definition at line 51 of file versionnumber.cpp.

References helper_copyFromHere().

Here is the call graph for this function:

bool VersionNumber::operator== ( const VersionNumber value  )  const

Definition at line 89 of file versionnumber.cpp.

References both_are_equal, and whichIsBigger().

Here is the call graph for this function:

bool VersionNumber::operator> ( const VersionNumber value  )  const

Definition at line 79 of file versionnumber.cpp.

References first_one, and whichIsBigger().

Here is the call graph for this function:

bool VersionNumber::operator>= ( const VersionNumber value  )  const

Definition at line 84 of file versionnumber.cpp.

References second_one, and whichIsBigger().

Here is the call graph for this function:

QString VersionNumber::toString (  )  const

Definition at line 46 of file versionnumber.cpp.

References theString.

VersionNumber::type_whichIsBigger VersionNumber::whichIsBigger ( const QString &  firstValue,
const QString &  secondValue 
) [static, private]

Internally used to compare 2 segments (list entries, QStrings) of a VersionNumber::simpleNumber.

Warning:
Both strings must have size() > 0! Otherwise this function will crash!

Definition at line 390 of file versionnumber.cpp.

References helper_whichNumberIsBigger(), and helper_whichStringIsBigger().

Here is the call graph for this function:

VersionNumber::type_whichIsBigger VersionNumber::whichIsBigger ( const simpleNumber firstValue,
const simpleNumber secondValue 
) [static, private]

Internally used to compare 2 VersionNumber::simpleNumber.

Definition at line 299 of file versionnumber.cpp.

References both_are_equal, first_one, second_one, and whichIsBigger().

Here is the call graph for this function:

VersionNumber::type_whichIsBigger VersionNumber::whichIsBigger ( const numberWithPoints firstValue,
const numberWithPoints secondValue 
) [static, private]

Internally used to compare 2 VersionNumber::numberWithPoints.

Definition at line 257 of file versionnumber.cpp.

References both_are_equal, first_one, second_one, and whichIsBigger().

Here is the call graph for this function:

VersionNumber::type_whichIsBigger VersionNumber::whichIsBigger ( const numberWithPointsAndDashes firstValue,
const numberWithPointsAndDashes secondValue 
) [static, private]

Internally used to compare 2 VersionNumber::numberWithPointsAndDashes.

Definition at line 216 of file versionnumber.cpp.

References both_are_equal, first_one, second_one, and whichIsBigger().

Here is the call graph for this function:

VersionNumber::type_whichIsBigger VersionNumber::whichIsBigger ( const VersionNumber firstValue,
const VersionNumber secondValue 
) [static, private]

Internally used to compare 2 VersionNumber.

Definition at line 199 of file versionnumber.cpp.

References both_are_equal, epoch, and version_and_release.

Referenced by operator!=(), operator<(), operator<=(), operator==(), operator>(), operator>=(), and whichIsBigger().

Here is the caller graph for this function:


Member Data Documentation

Internally used to hold a segmented version of the first part of the version number (means: the part before the first ":").

Definition at line 126 of file versionnumber.h.

Referenced by helper_copyFromHere(), helper_setValue(), and whichIsBigger().

QString VersionNumber::theString [private]

Internally used to hold the string who contents the version number.

If this class gets initialized with a qint64, than this number is converted to a string.

Definition at line 123 of file versionnumber.h.

Referenced by helper_copyFromHere(), helper_setValue(), and toString().

Internally used to hold a segmented version of the second part of the version number (means: the part after the first ":").

Definition at line 129 of file versionnumber.h.

Referenced by helper_copyFromHere(), helper_setValue(), and whichIsBigger().


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

doxygen