/****************************************************************************************************

		MCVersionNumber.h
		Copyright: (c) 2001 Eovia Corp. All rights reserved.

		Author:	Arnaud
		Date:	7/31/2003

****************************************************************************************************/

#ifndef __MCVersionNumber__
#define __MCVersionNumber__

#if CP_PRAGMA_ONCE
#pragma once
#endif


#include "MCBasicTypes.h"

class TMCString;

/// Stores an application's version number in the form (fMajor, fMinor, fRevision, fBuild).
/// And provides comparison operators.
///
struct TMCVersionNumber : public TMCObject
{
	TMCVersionNumber()	{ fMajor= fMinor= fRevision= fBuild= 0; }

	TMCVersionNumber(int32 major, int32 minor, int32 revision, int32 build)
	{
		fMajor		= major;
		fMinor		= minor;
		fRevision	= revision;
		fBuild		= build;
	}

	inline boolean		operator==	(const TMCVersionNumber& version)	const	{ return (Compare(version) == 0); }
	inline boolean		operator!=	(const TMCVersionNumber& version)	const	{ return (Compare(version) != 0); }
	inline boolean		operator<	(const TMCVersionNumber& version)	const	{ return (Compare(version) <  0); }
	inline boolean		operator<=	(const TMCVersionNumber& version)	const	{ return (Compare(version) <= 0); }
	inline boolean		operator>	(const TMCVersionNumber& version)	const	{ return (Compare(version) >  0); }
	inline boolean		operator>=	(const TMCVersionNumber& version)	const	{ return (Compare(version) >= 0); }

	int32 Compare(const TMCVersionNumber& version) const
	{
		if (fMajor < version.fMajor)
			return -1;
		else if (fMajor > version.fMajor)
			return 1;
		else if (fMinor < version.fMinor)
			return -1;
		else if (fMinor > version.fMinor)
			return 1;
		else if (fRevision < version.fRevision)
			return -1;
		else if (fRevision > version.fRevision)
			return 1;
		else if (fBuild < version.fBuild)
			return -1;
		else if (fBuild > version.fBuild)
			return 1;
		else 
			return 0;
	}

	void GetVersionString(TMCString& string) const;
	void GetFullVersionString(TMCString& string) const;
	void FromVersionString(const TMCString& string);

	int32 fMajor;
	int32 fMinor;
	int32 fRevision;
	int32 fBuild;

protected:
	static uint32 GetIntergerFormVersionNumber(TMCString& string);
};








#endif
