secureswitools/swisistools/source/interpretsislib/version.h
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 * version.cpp
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef	VERSION_H
       
    21 #define	VERSION_H
       
    22 
       
    23 #include <istream>
       
    24 #include "serialisable.h"
       
    25 #include "serialiser.h"
       
    26 #include "deserialiser.h"
       
    27 #include "symbiantypes.h"
       
    28 
       
    29 class Serialiser;
       
    30 class Deserialiser;
       
    31 /**
       
    32 * @file VERSION.H
       
    33 *
       
    34 * @internalComponent
       
    35 * @released
       
    36 */
       
    37 class Version : public Serialisable//<Version>
       
    38 	{
       
    39 public:
       
    40 	/**
       
    41 	Constructor
       
    42 	*/
       
    43 	Version () : iMajor(0), iMinor(0), iBuild(0) {}
       
    44 
       
    45 	Version (TInt aMa, TInt aMi, TInt aB )
       
    46 		: iMajor(aMa),
       
    47 		  iMinor(aMi),
       
    48 		  iBuild(aB) {}
       
    49 
       
    50 	~Version () {};
       
    51 
       
    52 	virtual void Internalize(Deserialiser& des)
       
    53 	{
       
    54 	des >> iMajor >> iMinor >> iBuild;
       
    55 	}
       
    56 	virtual void Externalize(Serialiser& ser)
       
    57 	{
       
    58 	ser << iMajor << iMinor << iBuild;
       
    59 	}
       
    60 	//virtual Serialisable* Make() { return new Version; }
       
    61 
       
    62 	TInt GetMajor() const { return iMajor;}
       
    63 	TInt GetMinor() const { return iMinor;}
       
    64 	TInt GetBuild() const { return iBuild;}
       
    65 
       
    66 	/**
       
    67 	 * Determines whether the iMajor, iMinor and iBuild components of the stored version are valid and
       
    68 	 * within range.
       
    69 	 *
       
    70 	 * Note: This function does NOT support Wildcards
       
    71 	 * 
       
    72 	 * @return		True is returned if ALL of the following conditions result to True:
       
    73 	 * 					- iMajor ranges between 0 and 127 inclusive
       
    74 	 * 					- iMinor ranges between 0 and 99 inclusive
       
    75 	 * 					- iBuild ranges between 0 and 32767 inclusive
       
    76 	 * 
       
    77 	 * 				Otherwise, False is returned. 
       
    78 	 */
       
    79 	bool IsValid() const;
       
    80 
       
    81 	friend bool operator==(const Version& aLhs, const Version& aRhs);
       
    82 	friend bool operator<(const Version& aLhs, const Version& aRhs);
       
    83 	friend bool operator>(const Version& aLhs, const Version& aRhs);
       
    84 	friend bool operator!=(const Version& aLhs, const Version& aRhs);
       
    85 	friend bool operator<=(const Version& aLhs, const Version& aRhs);
       
    86 	friend bool operator>=(const Version& aLhs, const Version& aRhs);
       
    87 
       
    88 private:
       
    89 	TInt iMajor;
       
    90 	TInt iMinor;
       
    91 	TInt iBuild;
       
    92 	};
       
    93 
       
    94 
       
    95 std::basic_ostream<wchar_t>& operator<<(std::basic_ostream<wchar_t>& os,
       
    96 										Version& ver);
       
    97 
       
    98 
       
    99 bool operator==(const Version& aLhs, const Version& aRhs);
       
   100 bool operator<(const Version& aLhs, const Version& aRhs);
       
   101 bool operator>(const Version& aLhs, const Version& aRhs);
       
   102 bool operator!=(const Version& aLhs, const Version& aRhs);
       
   103 bool operator<=(const Version& aLhs, const Version& aRhs);
       
   104 bool operator>=(const Version& aLhs, const Version& aRhs);
       
   105 
       
   106 #endif	/* VERSION_H */