Public Member Functions | Friends | List of all members
ignition::math::SemanticVersion Class Reference

ignition/math/SemanticVersion.hh More...

#include <SemanticVersion.hh>

Public Member Functions

 SemanticVersion ()
 Default constructor. More...
 
 SemanticVersion (const std::string &_v)
 Constructor. More...
 
 SemanticVersion (const SemanticVersion &_copy)
 Copy constructor. More...
 
 SemanticVersion (const unsigned int _major, const unsigned int _minor=0, const unsigned int _patch=0, const std::string &_prerelease="", const std::string &_build="")
 Constructor. More...
 
 ~SemanticVersion ()
 Destructor. More...
 
std::string Build () const
 Get the build metadata string. More...
 
unsigned int Major () const
 Get the major number. More...
 
unsigned int Minor () const
 Get the minor number. More...
 
bool operator!= (const SemanticVersion &_other) const
 Inequality comparison operator. More...
 
bool operator< (const SemanticVersion &_other) const
 Less than comparison operator. More...
 
bool operator<= (const SemanticVersion &_other) const
 Less than or equal comparison operator. More...
 
SemanticVersionoperator= (const SemanticVersion &_other)
 Assignment operator. More...
 
bool operator== (const SemanticVersion &_other) const
 Equality comparison operator. More...
 
bool operator> (const SemanticVersion &_other) const
 Greater than comparison operator. More...
 
bool operator>= (const SemanticVersion &_other) const
 Greater than or equal comparison operator. More...
 
bool Parse (const std::string &_versionStr)
 Parse a version string and set the major, minor, patch numbers, and prerelease and build strings. More...
 
unsigned int Patch () const
 Get the patch number. More...
 
std::string Prerelease () const
 Get the prerelease string. More...
 
std::string Version () const
 Returns the version as a string. More...
 

Friends

std::ostream & operator<< (std::ostream &_out, const SemanticVersion &_v)
 Stream insertion operator. More...
 

Detailed Description

ignition/math/SemanticVersion.hh

Version comparison class based on Semantic Versioning 2.0.0 http://semver.org/ Compares versions and converts versions from string.

Constructor & Destructor Documentation

◆ SemanticVersion() [1/4]

ignition::math::SemanticVersion::SemanticVersion ( )

Default constructor.

Use the Parse function to populate an instance with version information.

◆ SemanticVersion() [2/4]

ignition::math::SemanticVersion::SemanticVersion ( const std::string &  _v)

Constructor.

Parameters
[in]_vthe string version. ex: "0.3.2"

◆ SemanticVersion() [3/4]

ignition::math::SemanticVersion::SemanticVersion ( const SemanticVersion _copy)

Copy constructor.

Parameters
[in]_copythe other version

◆ SemanticVersion() [4/4]

ignition::math::SemanticVersion::SemanticVersion ( const unsigned int  _major,
const unsigned int  _minor = 0,
const unsigned int  _patch = 0,
const std::string &  _prerelease = "",
const std::string &  _build = "" 
)

Constructor.

Parameters
[in]_majorThe major number
[in]_minorThe minor number
[in]_patchThe patch number
[in]_prereleaseThe prerelease string
[in]_buildThe build metadata string

◆ ~SemanticVersion()

ignition::math::SemanticVersion::~SemanticVersion ( )

Destructor.

Member Function Documentation

◆ Build()

std::string ignition::math::SemanticVersion::Build ( ) const

Get the build metadata string.

Build meta data is not used when determining precedence.

Returns
Build metadata string, empty if a build metadata string was not specified.

◆ Major()

unsigned int ignition::math::SemanticVersion::Major ( ) const

Get the major number.

Returns
The major number

◆ Minor()

unsigned int ignition::math::SemanticVersion::Minor ( ) const

Get the minor number.

Returns
The minor number

◆ operator!=()

bool ignition::math::SemanticVersion::operator!= ( const SemanticVersion _other) const

Inequality comparison operator.

Parameters
[in]_otherThe other version to compare to
Returns
True if _other version is different

◆ operator<()

bool ignition::math::SemanticVersion::operator< ( const SemanticVersion _other) const

Less than comparison operator.

Parameters
[in]_otherThe other version to compare to
Returns
True if _other version is newer

◆ operator<=()

bool ignition::math::SemanticVersion::operator<= ( const SemanticVersion _other) const

Less than or equal comparison operator.

Parameters
[in]_otherThe other version to compare to
Returns
True if _other version is newer or equal

◆ operator=()

SemanticVersion& ignition::math::SemanticVersion::operator= ( const SemanticVersion _other)

Assignment operator.

Parameters
[in]_otherThe version to assign from.
Returns
The reference to this instance

◆ operator==()

bool ignition::math::SemanticVersion::operator== ( const SemanticVersion _other) const

Equality comparison operator.

Parameters
[in]_otherThe other version to compare to
Returns
True if _other version is the same

◆ operator>()

bool ignition::math::SemanticVersion::operator> ( const SemanticVersion _other) const

Greater than comparison operator.

Parameters
[in]_otherThe other version to compare to
Returns
True if _other version is older

◆ operator>=()

bool ignition::math::SemanticVersion::operator>= ( const SemanticVersion _other) const

Greater than or equal comparison operator.

Parameters
[in]_otherThe other version to compare to
Returns
True if _other version is older or the same

◆ Parse()

bool ignition::math::SemanticVersion::Parse ( const std::string &  _versionStr)

Parse a version string and set the major, minor, patch numbers, and prerelease and build strings.

Parameters
[in]_versionStrThe version string, such as "1.2.3-pr+123" True on success.

◆ Patch()

unsigned int ignition::math::SemanticVersion::Patch ( ) const

Get the patch number.

Returns
The patch number

◆ Prerelease()

std::string ignition::math::SemanticVersion::Prerelease ( ) const

Get the prerelease string.

Returns
Prelrease string, empty if a prerelease string was not specified.

◆ Version()

std::string ignition::math::SemanticVersion::Version ( ) const

Returns the version as a string.

Returns
The semantic version string

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  _out,
const SemanticVersion _v 
)
friend

Stream insertion operator.

Parameters
_outoutput stream
_vSemantic version to output
Returns
the stream

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