source: branch/egtra-stream-without-en_dec/Classes/System/Version.ab@ 673

Last change on this file since 673 was 497, checked in by イグトランス (egtra), 17 years ago

インクルードガードとその他不要な前処理定義などの削除

File size: 3.3 KB
Line 
1' Classes/System/Version.ab
2
3Namespace System
4
5Class Version
6 ' Inherits ICloneable, IComparable, IComparable<Version>, IEquatable<Version>
7Public
8 ' Constractor
9 Sub Version()
10 major = 0
11 minor = 0
12 build = -1
13 revision = -1
14 End Sub
15
16 'Sub Version(s As String)
17 'End Sub
18
19 Sub Version(major As Long, minor As Long)
20 This.major = major
21 This.minor = minor
22 This.build = -1
23 This.revision = -1
24 End Sub
25
26 Sub Version(major As Long, minor As Long, build As Long)
27 This.major = major
28 This.minor = minor
29 This.build = build
30 This.revision = -1
31 End Sub
32
33 Sub Version(major As Long, minor As Long, build As Long, revision As Long)
34 This.major = major
35 This.minor = minor
36 This.build = build
37 This.revision = revision
38 End Sub
39
40 Const Function Major() As Long
41 Return major
42 End Function
43
44 Const Function Minor() As Long
45 Return minor
46 End Function
47
48 Const Function Build() As Long
49 Return build
50 End Function
51
52 Const Function Revision() As Long
53 Return revision
54 End Function
55
56 Const Function MajorRevision() As Integer
57 Return HIWORD(revision) As Integer
58 End Function
59
60 Const Function MinorRevision() As Integer
61 Return LOWORD(revision) As Integer
62 End Function
63
64 Const Function CompareTo(v As Version) As Long
65 CompareTo = major - v.major
66 If CompareTo <> 0 Then Exit Function
67 CompareTo = minor - v.minor
68 If CompareTo <> 0 Then Exit Function
69 CompareTo = build - v.build
70 If CompareTo <> 0 Then Exit Function
71 CompareTo = revision - v.revision
72 End Function
73
74 Const Function Equals(v As Version) As Boolean
75 Return CompareTo(v) = 0
76 End Function
77
78 Override Function GetHashCode() As Long
79 Return _System_BSwap(major As DWord) Xor minor Xor build Xor _System_BSwap(revision As DWord)
80 End Function
81
82 Function Operator ==(v As Version) As Boolean
83 Return CompareTo(v) = 0
84 End Function
85
86 Function Operator <>(v As Version) As Boolean
87 Return CompareTo(v) <> 0
88 End Function
89
90 Function Operator <(v As Version) As Boolean
91 Return CompareTo(v) < 0
92 End Function
93
94 Function Operator >(v As Version) As Boolean
95 Return CompareTo(v) > 0
96 End Function
97
98 Function Operator <=(v As Version) As Boolean
99 Return CompareTo(v) <= 0
100 End Function
101
102 Function Operator >=(v As Version) As Boolean
103 Return CompareTo(v) >= 0
104 End Function
105
106 Override Function ToString() As String
107 ToString = Str$(major) + "." + Str$(minor)
108 If build >= 0 Then
109 ToString = ToString + "." + Str$(build)
110 If revision >= 0 Then
111 ToString = ToString + "." + Str$(revision)
112 End If
113 End If
114 End Function
115
116 Function ToString(fieldCount As Long) As String
117 If fieldCount < 0 Or fieldCount > 4 Then
118 Throw New ArgumentOutOfRangeException("fieldCount")
119 End If
120 ToString = ""
121 If fieldCount = 0 Then Exit Function
122 ToString = Str$(major)
123 If fieldCount = 1 Then Exit Function
124 ToString = ToString + "." + Str$(minor)
125 If fieldCount = 2 Then Exit Function
126
127 If build < 0 Then
128 Throw New ArgumentException
129 End If
130 ToString = ToString + "." + Str$(build)
131 If fieldCount = 3 Then Exit Function
132
133 If revision < 0 Then
134 Throw New ArgumentException
135 End If
136 ToString = ToString + "." + Str$(revision)
137 End Function
138Private
139 major As Long
140 minor As Long
141 build As Long
142 revision As Long
143End Class
144
145End Namespace 'System
Note: See TracBrowser for help on using the repository browser.