Skip to content

Commit 55a1501

Browse files
committed
Added comments: License boiler plate & XMLDoc documentation
1 parent b77c17a commit 55a1501

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

Src/SWAG.UVersion.pas

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
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+
113
unit SWAG.UVersion;
214

315

@@ -14,25 +26,69 @@ interface
1426

1527

1628
type
29+
/// <summary>Class that reads and validates the SWAG collection's version
30+
/// information from file.</summary>
1731
TSWAGVersion = class(TNoPublicConstructObject)
1832
strict private
1933
const
34+
/// <summary>First supported SWAG version.</summary>
2035
LowestSupportedVersion: TVersionNumber = (V1: 1; V2: 0; V3: 0; V4: 0);
36+
/// <summary>Lowest SWAG version that is NOT supported.</summary>
2137
LowestUnSupportedVersion: TVersionNumber = (V1: 1; V2: 1; V3: 0; V4: 0);
38+
/// <summary>SWAG version file name, without path.</summary>
2239
SWAGVersionFileName = 'VERSION';
2340
var
41+
/// <summary>Stores fully specified path to SWAG version file.</summary>
2442
fSWAGFilePath: TFileName;
43+
/// <summary>Reads and returns the version string from the version file.
44+
/// </summary>
2545
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>
2654
function ReadAndValidateVersionFile: TVersionNumber;
2755
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>
2860
constructor InternalCreate(const SWAGDir: TFileName);
2961
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>
3070
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;
3281
end;
3382

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>
3486
ESWAGVersion = class(ECodeSnip);
87+
/// <summary>Type of exception raised when the SWAG version file is missing
88+
/// or corrupt.</summary>
3589
ECorruptSWAGVersion = class(ESWAGVersion);
90+
/// <summary>Type of exception raised when the SWAG version is outside the
91+
/// range of supported versions.</summary>
3692
EUnsupportedSWAGVersion = class(ESWAGVersion);
3793

3894

0 commit comments

Comments
 (0)