1
+ {
2
+ * This Source Code Form is subject to the terms of the Mozilla Public License,
3
+ * v. 2.0. If a copy of the MPL was not distributed with this file, You can
4
+ * obtain one at http://mozilla.org/MPL/2.0/
5
+ *
6
+ * Copyright (C) 2020, Peter Johnson (gravatar.com/delphidabbler).
7
+ *
8
+ * Provides a class that reads and validates the SWAG collection's version
9
+ * information from file.
10
+ }
11
+
12
+
1
13
unit SWAG.UVersion;
2
14
3
15
@@ -14,25 +26,69 @@ interface
14
26
15
27
16
28
type
29
+ // / <summary>Class that reads and validates the SWAG collection's version
30
+ // / information from file.</summary>
17
31
TSWAGVersion = class (TNoPublicConstructObject)
18
32
strict private
19
33
const
34
+ // / <summary>First supported SWAG version.</summary>
20
35
LowestSupportedVersion: TVersionNumber = (V1: 1 ; V2: 0 ; V3: 0 ; V4: 0 );
36
+ // / <summary>Lowest SWAG version that is NOT supported.</summary>
21
37
LowestUnSupportedVersion: TVersionNumber = (V1: 1 ; V2: 1 ; V3: 0 ; V4: 0 );
38
+ // / <summary>SWAG version file name, without path.</summary>
22
39
SWAGVersionFileName = ' VERSION' ;
23
40
var
41
+ // / <summary>Stores fully specified path to SWAG version file.</summary>
24
42
fSWAGFilePath: TFileName;
43
+ // / <summary>Reads and returns the version string from the version file.
44
+ // / </summary>
25
45
function ReadVersionStr : string;
46
+ // / <summary>Reads, parses and validates version information from file.
47
+ // / </summary>
48
+ // / <returns>TVersionNumber. Structure containing version information.
49
+ // / </returns>
50
+ // / <exception>ECorruptSWAGVersion raised if version information in file
51
+ // / is corrupt, missing, or if the file is missing.</exception>
52
+ // / <exception>EUnsupportedSWAGVersion raised if the version information
53
+ // / read represents an unsupported format.</exception>
26
54
function ReadAndValidateVersionFile : TVersionNumber;
27
55
strict protected
56
+ // / <summary>Constructor that can only be called from with the class.
57
+ // / </summary>
58
+ // / <param name="SWAGDir">TFileName [in] Directory where version file
59
+ // / should be located.</param>
28
60
constructor InternalCreate(const SWAGDir: TFileName);
29
61
public
62
+ // / <summary>Validates the version file. Returns normally if there are no
63
+ // / errors or raises an exception if an error is found.</summary>
64
+ // / <param name="SWAGDir">TFileName [in] Directory where version file
65
+ // / should be located.</param>
66
+ // / <exception>ECorruptSWAGVersion raised if version information in file
67
+ // / is corrupt, missing, or if the file is missing.</exception>
68
+ // / <exception>EUnsupportedSWAGVersion raised if the version information
69
+ // / read represents an unsupported format.</exception>
30
70
class procedure ValidateVersionFile (const SWAGDir: TFileName);
31
- class function GetVersion (const SWAGDir: TFileName): TVersionNumber;
71
+ // / <summary>Gets SWAG version from file.</summary>
72
+ // / <param name="SWAGDir">TFileName [in] Directory where version file
73
+ // / should be located.</param>
74
+ // / <returns>TVersionNumber. Structure containing version information.
75
+ // / </returns>
76
+ // / <exception>ECorruptSWAGVersion raised if version information in file
77
+ // / is corrupt, missing, or if the file is missing.</exception>
78
+ // / <exception>EUnsupportedSWAGVersion raised if the version information
79
+ // / read represents an unsupported format.</exception>
80
+ class function GetVersion (const SWAGDir: TFileName): TVersionNumber;
32
81
end ;
33
82
83
+ // / <summary>Base class for exceptions raised in this unit.</summary>
84
+ // / <remarks>Exceptions of this type should NOT be raised directly: use
85
+ // / sub-classes.</remarks>
34
86
ESWAGVersion = class (ECodeSnip);
87
+ // / <summary>Type of exception raised when the SWAG version file is missing
88
+ // / or corrupt.</summary>
35
89
ECorruptSWAGVersion = class (ESWAGVersion);
90
+ // / <summary>Type of exception raised when the SWAG version is outside the
91
+ // / range of supported versions.</summary>
36
92
EUnsupportedSWAGVersion = class (ESWAGVersion);
37
93
38
94
0 commit comments