PVersion Class Reference

Detailed Description

The PVersion class represents a software version number: major.minor[.maintenance[.build]]; immutable, so thread-safe.

PVersion also holds DEBUG vs RELEASE status and 32-bits vs 64-bits status.

Definition at line 26 of file PVersion.h.

#include <PVersion.h>

Constructor & Destructor Documentation

◆ PVersion() [1/3]

PVersion::PVersion ( papillon::int32  major = 0,
papillon::int32  minor = 0,
papillon::int32  maintenance = 0,
papillon::int32  build = 0 
)
explicit

Constructs a version number.

  • major number must be positive integers in 0..255.
  • minor, maintenance and build numbers (optional) must be positive integers in 0..65535. In case of failure, version number will be set to "0.0.0.0" and can be tested with IsNull().

◆ PVersion() [2/3]

PVersion::PVersion ( const PString strVersion)
explicit

Constructs a version number from a string; expected format is "X[.Y.Z.W]".

  • X must be positive integers in 0..255
  • Y, Z, W (optional) must be positive integers in 0..65535. In case of failure, version number will be set to "0.0.0.0" and can be tested with IsNull().

◆ PVersion() [3/3]

PVersion::PVersion ( const PVersion other)

Constructs a shared copy of other.

◆ ~PVersion()

virtual PVersion::~PVersion ( )
virtual

Destroys this object.

Member Function Documentation

◆ Compare()

papillon::int32 PVersion::Compare ( const PVersion other) const

Compares this version with another one, then returns 0 if equal, a negative number if this version is lower than other, a positive number if this version is higher than other.

◆ GetBuild()

papillon::int32 PVersion::GetBuild ( ) const

Returns the build part of this version number.

Value is in 0..65535.

◆ GetMaintenance()

papillon::int32 PVersion::GetMaintenance ( ) const

Returns the maintenance part of this version number.

Value is in 0..65535.

◆ GetMajor()

papillon::int32 PVersion::GetMajor ( ) const

Returns the major part of this version number.

Value is in 0..255.

◆ GetMinor()

papillon::int32 PVersion::GetMinor ( ) const

Returns the minor part of this version number.

Value is in 0..65535.

◆ IsDebug()

bool PVersion::IsDebug ( ) const

Returns true if this version is a debug version, false otherwise.

◆ IsNull()

bool PVersion::IsNull ( ) const

Returns true if this version number is 0.0.0.0, indicating that this is probably an invalid version.

◆ IsRelease()

bool PVersion::IsRelease ( ) const

Returns true if this version is a release version, false otherwise.

◆ IsX64()

bool PVersion::IsX64 ( ) const

Returns true if this version is 64-bits, false otherwise.

◆ IsX86()

bool PVersion::IsX86 ( ) const

Returns true if this version is 32-bits, false otherwise.

◆ Null()

static const PVersion& PVersion::Null ( )
inlinestatic

Returns the constant holding the "0.0.0.0" (invalid) version number.

Definition at line 150 of file PVersion.h.

◆ operator!=()

bool PVersion::operator!= ( const PVersion v) const

Returns true if this version is different from v; otherwise returns false.

◆ operator<()

bool PVersion::operator< ( const PVersion v) const

Returns true if this version is earlier than v; otherwise returns false.

◆ operator<=()

bool PVersion::operator<= ( const PVersion v) const

Returns true if this version is earlier than or equal to v; otherwise returns false.

◆ operator=()

PVersion& PVersion::operator= ( const PVersion other)

Performs a shared copy of other to this object.

◆ operator==()

bool PVersion::operator== ( const PVersion v) const

Returns true if this version is equal to v; otherwise returns false.

◆ operator>()

bool PVersion::operator> ( const PVersion v) const

Returns true if this version is later than v; otherwise returns false.

◆ operator>=()

bool PVersion::operator>= ( const PVersion v) const

Returns true if this version is later than or equal to v; otherwise returns false.

◆ ToString4Numbers()

PString PVersion::ToString4Numbers ( ) const

Returns the string "major.minor.maintenance.build" corresponding to this version number.

◆ ToStringMajorMinor()

PString PVersion::ToStringMajorMinor ( ) const

Returns the string "major.minor" corresponding to this version number.

◆ ToStringShort()

PString PVersion::ToStringShort ( ) const

Returns the string "major.minor[.maintenance[.build]]" corresponding to this version number (maintenance and build are filled only if non null).