i''m doing this simple class for tracking versions.
base format of the version is like this:
MAJOR.MINOR.BUILD
anyway, i''m still struggling with const correct stuff and references and need some advice/check up
header
#ifndef _AXP_VERSION_H_
#define _AXP_VERSION_H_
// SYSTEM INCLUDES
// PROJECT INCLUDES
#include "..\axpBase\axpBase.hpp"
// LOCAL INCLUDES
namespace axp
{
class Version
{
public:
// LIFECYCLE
Version ();
Version (const axpUInt16&,
const axpUInt16&,
const axpUInt16&);
Version (const Version&);
virtual ~Version ();
// OPERATORS
axpBool operator== (const Version&) const;
axpBool operator<= (const Version&) const;
axpBool operator>= (const Version&) const;
axpBool operator< (const Version&) const;
axpBool operator> (const Version&) const;
// OPERATIONS
// ACCESS
inline axpVoid Major (const axpUInt16&);
inline axpVoid Minor (const axpUInt16&);
inline axpVoid Build (const axpUInt16&);
// INQUIRY
inline axpUInt16& Major ();
inline axpUInt16& Minor ();
inline axpUInt16& Build ();
inline axpString String ();
// VARIABLES
protected:
// LIFECYCLE
// OPERATORS
// OPERATIONS
// ACCESS
// INQUIRY
// VARIABLES
private:
// LIFECYCLE
// OPERATORS
// OPERATIONS
inline axpUInt64 VersionValue () const;
// ACCESS
// INQUIRY
// VARIABLES
axpUInt16 mMajor;
axpUInt16 mMinor;
axpUInt16 mBuild;
};
#include "axpVersion.inl"
} // namespace axp
#endif // _AXP_VERSION_H_
inline
//////////////////// PUBLIC /////////////////////////////////////////////////
//================= LIFECYCLE ===============================================
//================= OPERATORS ===============================================
//================= OPERATIONS ==============================================
//================= ACCESS ==================================================
inline axpVoid Version::Major(const axpUInt16& lMajor)
{
mMajor = lMajor;
}
inline axpVoid Version::Minor(const axpUInt16& lMinor)
{
mMinor = lMinor;
}
inline axpVoid Version::Build(const axpUInt16& lBuild)
{
mBuild = lBuild;
}
//================= INQUIRY =================================================
inline axpUInt16& Version::Major()
{
return(mMajor);
}
inline axpUInt16& Version::Minor()
{
return(mMinor);
}
inline axpUInt16& Version::Build()
{
return(mBuild);
}
inline axpString Version::String()
{
axpString lString;
axpChar lBuffer[8];
_itoa(mMajor,lBuffer,10);
lString.append(lBuffer);
lString.append(".");
_itoa(mMinor,lBuffer,10);
lString.append(lBuffer);
lString.append(".");
_itoa(mBuild,lBuffer,10);
lString.append(lBuffer);
return(lString);
}
/////////////////// PROTECTED ///////////////////////////////////////////////
//================= LIFECYCLE ===============================================
//================= OPERATORS ===============================================
//================= OPERATIONS ==============================================
//================= ACCESS ==================================================
//================= INQUIRY =================================================
/////////////////// PRIVATE /////////////////////////////////////////////////
//================= LIFECYCLE ===============================================
//================= OPERATORS ===============================================
//================= OPERATIONS ==============================================
inline axpUInt64 Version::VersionValue() const
{
return(mBuild + mMinor * 100000 + mMajor * 100000000000);
}
//================= ACCESS ==================================================
//================= INQUIRY =================================================
source
#include "axpVersion.hpp"
using namespace axp;
//////////////////// PUBLIC /////////////////////////////////////////////////
//================= LIFECYCLE ===============================================
Version::Version()
{
mMajor = 0;
mMinor = 0;
mBuild = 0;
}
Version::Version(const axpUInt16& lMajor,
const axpUInt16& lMinor,
const axpUInt16& lBuild)
{
mMajor = lMajor;
mMinor = lMinor;
mBuild = lBuild;
}
Version::Version(const Version& lLeft)
{
mMajor = lLeft.mMajor;
mMinor = lLeft.mMinor;
mBuild = lLeft.mBuild;
}
Version::~Version()
{
}
//================= OPERATORS ===============================================
axpBool Version::operator == (const Version& lRight) const
{
return( VersionValue() == lRight.VersionValue() );
}
axpBool Version::operator <= (const Version& lRight) const
{
return( VersionValue() <= lRight.VersionValue() );
}
axpBool Version::operator >= (const Version& lRight) const
{
return( VersionValue() >= lRight.VersionValue() );
}
axpBool Version::operator < (const Version& lRight) const
{
return( VersionValue() < lRight.VersionValue() );
}
axpBool Version::operator > (const Version& lRight) const
{
return( VersionValue() > lRight.VersionValue() );
}
//================= OPERATIONS ==============================================
//================= ACCESS ==================================================
//================= INQUIRY =================================================
/////////////////// PROTECTED ///////////////////////////////////////////////
//================= LIFECYCLE ===============================================
//================= OPERATORS ===============================================
//================= OPERATIONS ==============================================
//================= ACCESS ==================================================
//================= INQUIRY =================================================
/////////////////// PRIVATE /////////////////////////////////////////////////
//================= LIFECYCLE ===============================================
//================= OPERATORS ===============================================
//================= OPERATIONS ==============================================
//================= ACCESS ==================================================
//================= INQUIRY =================================================
//================= INQUIRY =================================================
so... what am i doing wrong, what correct and what could be improved???