Data Access Library (DAL)
 All Classes Functions Variables Typedefs Friends
Public Member Functions | Public Attributes
dal::VersionType Struct Reference

#include <versiontype.h>

List of all members.

Public Member Functions

 VersionType (unsigned major=0, unsigned minor=0, unsigned release=0)
 VersionType (const std::string &str)
std::string to_string () const
int cmp (const VersionType &other) const
bool operator< (const VersionType &other) const
bool operator<= (const VersionType &other) const
bool operator> (const VersionType &other) const
bool operator>= (const VersionType &other) const
bool operator== (const VersionType &other) const
bool operator!= (const VersionType &other) const

Public Attributes

unsigned major
unsigned minor
unsigned release

Detailed Description

Encodes a version such as 1.2.3.

Python example:

    # Initialisation through (major, minor, release) values
    >>> v = VersionType(1,2,3)
    >>> str(v)
    '1.2.3'

    # Initialisation through a version string
    >>> v = VersionType('1.2.3')
    >>> str(v)
    '1.2.3'

    # Retrieve individual fields
    >>> v = VersionType('1.2.3')
    >>> v.major
    1
    >>> v.minor
    2
    >>> v.release
    3

    # Compare versions
    >>> old = VersionType('1.2.3')
    >>> new = VersionType('3.2.1')
    >>> old < new
    True
    >>> old > new
    False
    >>> old == new
    False

Constructor & Destructor Documentation

dal::VersionType::VersionType ( const std::string &  str)

Convert a string of format major.minor.release. Any fields that could not be converted are set to 0. For example:

VersionType("2.5").to_string() == "2.5.0"


Member Function Documentation

int dal::VersionType::cmp ( const VersionType other) const

Compares *this with other. Returns: -1 if *this < other 0 if *this == other +1 if *this > other

std::string dal::VersionType::to_string ( ) const

Returns this version in string form (major.minor.release)


The documentation for this struct was generated from the following files:
 All Classes Functions Variables Typedefs Friends