|
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 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "version.h" |
|
20 |
|
21 bool Version::IsValid() const |
|
22 { |
|
23 return ((iMajor >= 0 && iMajor <= 127) && |
|
24 (iMinor >= 0 && iMinor <= 99) && |
|
25 (iBuild >= 0 && iBuild <= 32767)); |
|
26 } |
|
27 |
|
28 bool operator==(const Version& aLhs, const Version& aRhs) |
|
29 { |
|
30 return |
|
31 aLhs.iMajor == aRhs.iMajor |
|
32 && aLhs.iMinor == aRhs.iMinor |
|
33 && aLhs.iBuild == aRhs.iBuild; |
|
34 } |
|
35 |
|
36 bool operator<(const Version& aLhs, const Version& aRhs) |
|
37 { |
|
38 return (aLhs != aRhs) && !(aLhs > aRhs); |
|
39 } |
|
40 |
|
41 bool operator>(const Version& aLhs, const Version& aRhs) |
|
42 { |
|
43 if (aLhs == aRhs || aLhs.iMajor < aRhs.iMajor) return false; |
|
44 |
|
45 if (aLhs.iMajor > aRhs.iMajor) |
|
46 return true; |
|
47 else if (aLhs.iMinor == aRhs.iMinor) // major == |
|
48 return aLhs.iBuild > aRhs.iBuild; |
|
49 else if (aLhs.iMinor > aRhs.iMinor) |
|
50 return true; |
|
51 else // minor == |
|
52 return aLhs.iBuild > aRhs.iBuild; |
|
53 |
|
54 return false; |
|
55 } |
|
56 |
|
57 bool operator!=(const Version& aLhs, const Version& aRhs) |
|
58 { |
|
59 return !(aLhs == aRhs); |
|
60 } |
|
61 |
|
62 bool operator<=(const Version& aLhs, const Version& aRhs) |
|
63 { |
|
64 return (aLhs == aRhs) || aLhs < aRhs; |
|
65 } |
|
66 |
|
67 bool operator>=(const Version& aLhs, const Version& aRhs) |
|
68 { |
|
69 return (aLhs == aRhs) || aLhs > aRhs; |
|
70 |
|
71 } |