|
//*******************************************************************
//
// $Workfile: AppVersion.cpp $
//
// $Modtime: 8/15/04 10:14a $
//
// AppVersion class implementation module.
//
// This class provides application version number handling.
//
#include "StdAfx.h"
#include "AppVersion.h"
#if defined(_DEBUG)
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif // defined(_DEBUG)
IMPLEMENT_SERIAL(AppVersion, CObject, VERSIONABLE_SCHEMA | 1)
//*******************************************************************
//
AppVersion::AppVersion() :
CObject(),
m_Major(0),
m_Minor(0),
m_Build(0),
m_Revision(0)
{
}
///******************************************************************
//
AppVersion::AppVersion(unsigned long Major, unsigned long Minor,
unsigned long Build, unsigned long Revision) :
CObject(),
m_Major(Major),
m_Minor(Minor),
m_Build(Build),
m_Revision(Revision)
{
}
//*******************************************************************
//
AppVersion::AppVersion(const AppVersion& b) :
m_Major(b.m_Major),
m_Minor(b.m_Minor),
m_Build(b.m_Build),
m_Revision(b.m_Revision)
{
ASSERT_VALID(&b);
}
//*******************************************************************
//
AppVersion::~AppVersion()
{
}
//*******************************************************************
//
AppVersion& AppVersion::operator=(const AppVersion& b)
{
ASSERT_VALID(this);
ASSERT_VALID(&b);
m_Major = b.m_Major;
m_Minor = b.m_Minor;
m_Build = b.m_Build;
m_Revision = b.m_Revision;
return (*this);
}
//*******************************************************************
//
bool AppVersion::operator<(const AppVersion& b) const
{
ASSERT_VALID(this);
ASSERT_VALID(&b);
bool Result = false;
if (m_Major < b.m_Major)
{
Result = true;
}
else if (m_Major == b.m_Major)
{
if (m_Minor < b.m_Minor)
{
Result = true;
}
else if (m_Minor == b.m_Minor)
{
if (m_Build < b.m_Build)
{
Result = true;
}
else if (m_Build == b.m_Build)
{
if (m_Revision < b.m_Revision)
{
Result = true;
}
}
}
}
return (Result);
}
//*******************************************************************
//
bool AppVersion::operator==(const AppVersion& b) const
{
ASSERT_VALID(this);
ASSERT_VALID(&b);
if ((m_Major == b.m_Major) &&
(m_Minor == b.m_Minor) &&
(m_Build == b.m_Build) &&
(m_Revision == b.m_Revision))
return (true);
return (false);
}
//*******************************************************************
//
unsigned long AppVersion::GetMajor() const
{
ASSERT_VALID(this);
return (m_Major);
}
//*******************************************************************
//
unsigned long AppVersion::GetMinor() const
{
ASSERT_VALID(this);
return (m_Minor);
}
//*******************************************************************
//
unsigned long AppVersion::GetBuild() const
{
ASSERT_VALID(this);
return (m_Build);
}
//*******************************************************************
//
unsigned long AppVersion::GetRevision() const
{
ASSERT_VALID(this);
return (m_Revision);
}
//*******************************************************************
//
void AppVersion::Serialize(CArchive& ar)
{
ASSERT_VALID(this);
CObject::Serialize(ar);
ar.SerializeClass(GetRuntimeClass());
if (ar.IsStoring())
{
// store the data
ar << m_Major;
ar << m_Minor;
ar << m_Build;
ar << m_Revision;
}
else
{
// load the data
unsigned int Schema;
Schema = ar.GetObjectSchema();
switch (Schema)
{
case 1 :
ar >> m_Major;
ar >> m_Minor;
ar >> m_Build;
ar >> m_Revision;
break;
default :
AfxThrowArchiveException(CArchiveException::badSchema, "AppVersion");
break;
}
}
}
//*******************************************************************
//
#ifdef _DEBUG
void AppVersion::Dump(CDumpContext& dc) const
{
dc << "AppVersion:\n";
// call base class function first
CObject::Dump(dc);
dc << "Major: " << m_Major << "\n";
dc << "Minor: " << m_Minor << "\n";
dc << "Build: " << m_Build << "\n";
dc << "Revision: " << m_Revision << "\n";
}
#endif
//********************************************************************
//
const CString GetText(const AppVersion& AV)
{
ASSERT_VALID(&AV);
CString Result;
Result.Format("%lu.%lu.%lu.%lu",
AV.GetMajor(), AV.GetMinor(),
AV.GetBuild(), AV.GetRevision());
return (Result);
}
//*******************************************************************
//
std::ostream& operator<<(std::ostream& os, const AppVersion& AV)
{
os << static_cast<LPCTSTR>(GetText(AV));
return (os);
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Jim has been developing software for over 25 years. He is a consultant specializing in writing software for commercial products. He has developed software for embedded systems, device drivers, and windows applications.