From c7e236db5cde7fb473c07da8ad92ddd993d92fa1 Mon Sep 17 00:00:00 2001 From: James Turk Date: Tue, 10 Jun 2003 23:15:31 +0000 Subject: [PATCH] versioning info --- include/VersionInfo.h | 79 +++++++++++++++++++++++++++++++++++++++++++ src/VersionInfo.cpp | 55 ++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) create mode 100755 include/VersionInfo.h create mode 100755 src/VersionInfo.cpp diff --git a/include/VersionInfo.h b/include/VersionInfo.h new file mode 100755 index 0000000..5835b25 --- /dev/null +++ b/include/VersionInfo.h @@ -0,0 +1,79 @@ +/******************************************************************************* + This file is Part of the ZEngine Library for 2D game development. + Copyright (C) 2002, 2003 James Turk + + Licensed under a BSD-style license. + + The maintainer of this library is James Turk (james@conceptofzero.net) + and the home of this Library is http://www.zengine.sourceforge.net +*******************************************************************************/ + +/*! + \file VersionInfo.h + \brief Definition file for VersionInfo class. + + Definition file for VersinInfo class, simple class for containing and comparing + version numbers. +
$Id: VersionInfo.h,v 1.1 2003/06/10 23:15:31 cozman Exp $
+ \author James Turk +**/ + +#ifndef __versioninfo_h__ +#define __versioninfo_h__ + +#include "ZE_Utility.h" + +/*! + \brief Class for holding version information. + + Class for holding version information on a library. +**/ +class VersionInfo +{ + public: + //! Major version number. + unsigned int major; + //! Minor version number, changes upon signifigant releases. (Often upon compatibility breaks.) + unsigned int minor; + //! Version release number, changes on every release. + unsigned int release; + //! String Description of release. (Often blank.) + string extra; + + /*! + \brief Get string representing version number. + + Get dotted version number major.minor.release [extra]. + \return Formatted version string. + **/ + string GetString() const; + + /*! + \brief Less than operator overload for comparing VersionInfo. + + Overload of the less than (<) operator for two VersionInfos. + \param rhs Right hand side of comparison. + \return true if less than, false if greater than or equal to. + **/ + bool operator<(const VersionInfo &rhs) const; + + /*! + \brief Equals to operator overload for comparing VersionInfo. + + Overload of the equals to (==) operator for two VersionInfos. + \param rhs Right hand side of comparison. + \return true if equal to, false if not equals to. + **/ + bool operator==(const VersionInfo &rhs) const; + + /*! + \brief Greater than operator overload for comparing VersionInfo. + + Overload of the greater than (>) operator for two VersionInfos. + \param rhs Right hand side of comparison. + \return true if greater than, false if less than or equal to. + **/ + bool operator>(const VersionInfo &rhs) const; +}; + +#endif //__versioninfo_h__ diff --git a/src/VersionInfo.cpp b/src/VersionInfo.cpp new file mode 100755 index 0000000..9222621 --- /dev/null +++ b/src/VersionInfo.cpp @@ -0,0 +1,55 @@ +#include "VersionInfo.h" + +/*! + \file VersionInfo.cpp + \brief Implementation file for VersionInfo class. + + Implementation file for VersinInfo class, simple class for containing and comparing + version numbers. +
$Id: VersionInfo.cpp,v 1.1 2003/06/10 23:15:32 cozman Exp $
+ \author James Turk +**/ + +string VersionInfo::GetString() const +{ + if(extra.length()) + return ZE::FormatStr("%d.%d.%d [%s]",major,minor,release,extra.c_str()); + else + return ZE::FormatStr("%d.%d.%d",major,minor,release); +} + +bool VersionInfo::operator<(const VersionInfo &rhs) const +{ + if(this->major < rhs.major) + return true; + else if(this->major == rhs.major) + { + if(this->minor < rhs.minor) + return true; + else if(this->minor == rhs.minor) + { + if(this->release < rhs.release) + return true; + else if(this->release == rhs.release) + { + if(this->extra.length() == 0 && rhs.extra.length() != 0) + return true; + else if(this->extra.length() && rhs.extra.length()) + { + return this->extra[0] < rhs.extra[0]; + } + } + } + } + return false; +} + +bool VersionInfo::operator==(const VersionInfo &rhs) const +{ + return this->GetString() == rhs.GetString(); +} + +bool VersionInfo::operator>(const VersionInfo &rhs) const +{ + return !((*this) < rhs || (*this) == rhs); +}