Click here to Skip to main content
15,883,821 members
Articles / Programming Languages / Objective C

Designing Robust Objects with Boost

Rate me:
Please Sign up or sign in to vote.
4.78/5 (34 votes)
16 Aug 200411 min read 110.1K   710   87  
Tutorial on designing classes using Boost libraries
//*******************************************************************
//
// $Workfile: AppVersion.h $
//
// $Modtime: 8/15/04 7:59a $
//
// Header for AddVersion class.
//
// This class provides application version number handling.
//

#pragma once

#if _MSC_VER == 1200
#pragma warning(push, 3)	// turn off some STL warnings in VS6
#endif
#include <iostream>
#include "boost\operators.hpp"
#if _MSC_VER == 1200
#pragma warning(pop)
#endif

//*******************************************************************
//
class AppVersion : public CObject,
				   public boost::totally_ordered<AppVersion>
{
	DECLARE_SERIAL(AppVersion)

	public :
		AppVersion();
		AppVersion(unsigned long Major,
				   unsigned long Minor,
				   unsigned long Build,
				   unsigned long Revision);
		AppVersion(const AppVersion& b);

		virtual ~AppVersion();

		AppVersion& operator=(const AppVersion& b);

		bool operator<(const AppVersion& b) const;
		bool operator==(const AppVersion& b) const;

		unsigned long GetMajor() const;
		unsigned long GetMinor() const;
		unsigned long GetBuild() const;
		unsigned long GetRevision() const;

		virtual void Serialize(CArchive& ar);

#if defined _DEBUG
		virtual void Dump(CDumpContext& dc) const;
#endif

	private :
		unsigned long m_Major;
		unsigned long m_Minor;
		unsigned long m_Build;
		unsigned long m_Revision;
};


//*******************************************************************
//
// AppVersion support functions
//
const CString GetText(const AppVersion& AV);
std::ostream& operator<<(std::ostream& os, const AppVersion& AV);

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.


Written By
Technical Lead
United States United States
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.

Comments and Discussions