@@ -18,7 +18,7 @@ interface
18
18
CSLE.Exceptions;
19
19
20
20
type
21
- TURI = record
21
+ TImmutableURI = record
22
22
strict private
23
23
var
24
24
// Record containing URI information. Must not be accessed if fEmpty is
@@ -91,20 +91,21 @@ TURI = record
91
91
// / <summary>Fragment part of the URI.</summary>
92
92
property Fragment: string read GetFragment;
93
93
94
- // / <summary>Compares two <c>TURI </c> records and returns a 0, -ve or +ve
95
- // / value depending on whether the <c>Left</c> is equal to, less than or
96
- // / greater than <c>Right</c>, respectively.</summary>
97
- class function Compare (const Left, Right: TURI ): Integer; static;
94
+ // / <summary>Compares two <c>TImmutableURI </c> records and returns a 0,
95
+ // / -ve or +ve value depending on whether the <c>Left</c> is equal to, less
96
+ // / than or greater than <c>Right</c>, respectively.</summary>
97
+ class function Compare (const Left, Right: TImmutableURI ): Integer; static;
98
98
99
99
// / <summary>Checks the validity of a given URI. An empty URI is only
100
100
// / considered to be valid if <c>APermitEmpty</c> is <c>True</c>.</summary>
101
101
class function IsValidURIString (const AURIStr: string;
102
102
const APermitEmpty: Boolean): Boolean; static;
103
103
104
104
// Operator overloads
105
- class operator Equal(const Left, Right: TURI): Boolean;
106
- class operator NotEqual(const Left, Right: TURI): Boolean;
107
- class operator Implicit(const AURI: System.Net.URLCLient.TURI): TURI;
105
+ class operator Equal(const Left, Right: TImmutableURI): Boolean;
106
+ class operator NotEqual(const Left, Right: TImmutableURI): Boolean;
107
+ class operator Implicit(const AURI: System.Net.URLCLient.TURI):
108
+ TImmutableURI;
108
109
end ;
109
110
110
111
EURI = class (EExpected);
@@ -115,9 +116,9 @@ implementation
115
116
System.SysUtils,
116
117
System.Types;
117
118
118
- { TURI }
119
+ { TImmutableURI }
119
120
120
- class function TURI .Compare (const Left, Right: TURI ): Integer;
121
+ class function TImmutableURI .Compare (const Left, Right: TImmutableURI ): Integer;
121
122
begin
122
123
// Deal with one or more empty URIs: empty is less than
123
124
if Left.IsEmpty and Right.IsEmpty then
@@ -169,7 +170,8 @@ class function TURI.Compare(const Left, Right: TURI): Integer;
169
170
);
170
171
end ;
171
172
172
- constructor TURI.Create(const AURIStr: string; const APermitEmpty: Boolean);
173
+ constructor TImmutableURI.Create(const AURIStr: string;
174
+ const APermitEmpty: Boolean);
173
175
begin
174
176
fIsEmpty := AURIStr.IsEmpty;
175
177
if fIsEmpty and not APermitEmpty then
@@ -181,95 +183,96 @@ constructor TURI.Create(const AURIStr: string; const APermitEmpty: Boolean);
181
183
end ;
182
184
end ;
183
185
184
- class operator TURI .Equal(const Left, Right: TURI ): Boolean;
186
+ class operator TImmutableURI .Equal(const Left, Right: TImmutableURI ): Boolean;
185
187
begin
186
188
Result := Compare(Left, Right) = 0 ;
187
189
end ;
188
190
189
- function TURI .GetFragment : string;
191
+ function TImmutableURI .GetFragment : string;
190
192
begin
191
193
if fIsEmpty then
192
194
Result := string.Empty
193
195
else
194
196
Result := fURI.Fragment;
195
197
end ;
196
198
197
- function TURI .GetHost : string;
199
+ function TImmutableURI .GetHost : string;
198
200
begin
199
201
if fIsEmpty then
200
202
Result := string.Empty
201
203
else
202
204
Result := fURI.Host;
203
205
end ;
204
206
205
- function TURI .GetParams : TURIParameters;
207
+ function TImmutableURI .GetParams : TURIParameters;
206
208
begin
207
209
if fIsEmpty then
208
210
SetLength(Result, 0 )
209
211
else
210
212
Result := fURI.Params;
211
213
end ;
212
214
213
- function TURI .GetPassword : string;
215
+ function TImmutableURI .GetPassword : string;
214
216
begin
215
217
if fIsEmpty then
216
218
Result := string.Empty
217
219
else
218
220
Result := fURI.Password;
219
221
end ;
220
222
221
- function TURI .GetPath : string;
223
+ function TImmutableURI .GetPath : string;
222
224
begin
223
225
if fIsEmpty then
224
226
Result := string.Empty
225
227
else
226
228
Result := fURI.Path;
227
229
end ;
228
230
229
- function TURI .GetPort : Integer;
231
+ function TImmutableURI .GetPort : Integer;
230
232
begin
231
233
if fIsEmpty then
232
234
Result := 0
233
235
else
234
236
Result := fURI.Port;
235
237
end ;
236
238
237
- function TURI .GetQuery : string;
239
+ function TImmutableURI .GetQuery : string;
238
240
begin
239
241
if fIsEmpty then
240
242
Result := string.Empty
241
243
else
242
244
Result := fURI.Query;
243
245
end ;
244
246
245
- function TURI .GetScheme : string;
247
+ function TImmutableURI .GetScheme : string;
246
248
begin
247
249
if fIsEmpty then
248
250
Result := string.Empty
249
251
else
250
252
Result := fURI.Scheme;
251
253
end ;
252
254
253
- function TURI .GetUsername : string;
255
+ function TImmutableURI .GetUsername : string;
254
256
begin
255
257
if fIsEmpty then
256
258
Result := string.Empty
257
259
else
258
260
Result := fURI.Username;
259
261
end ;
260
262
261
- class operator TURI.Implicit(const AURI: System.Net.URLCLient.TURI): TURI;
263
+ class operator TImmutableURI.Implicit(const AURI: System.Net.URLCLient.TURI):
264
+ TImmutableURI;
262
265
begin
263
266
Result.fURI := AURI;
264
267
Result.fIsEmpty := False;
265
268
end ;
266
269
267
- function TURI .IsEmpty : Boolean;
270
+ function TImmutableURI .IsEmpty : Boolean;
268
271
begin
269
272
Result := fIsEmpty;
270
273
end ;
271
274
272
- class function TURI .IsValidURIString (const AURIStr: string;
275
+ class function TImmutableURI .IsValidURIString (const AURIStr: string;
273
276
const APermitEmpty: Boolean): Boolean;
274
277
begin
275
278
if AURIStr.IsEmpty then
@@ -278,20 +281,21 @@ class function TURI.IsValidURIString(const AURIStr: string;
278
281
Result := TryDeconstructURI(AURIStr, Dummy);
279
282
end ;
280
283
281
- class operator TURI.NotEqual(const Left, Right: TURI): Boolean;
284
+ class operator TImmutableURI.NotEqual(const Left, Right: TImmutableURI):
285
+ Boolean;
282
286
begin
283
287
Result := Compare(Left, Right) <> 0 ;
284
288
end ;
285
289
286
- function TURI .ToString : string;
290
+ function TImmutableURI .ToString : string;
287
291
begin
288
292
if fIsEmpty then
289
293
Result := string.Empty
290
294
else
291
295
Result := fURI.ToString;
292
296
end ;
293
297
294
- class function TURI .TryDeconstructURI (const AURIStr: string;
298
+ class function TImmutableURI .TryDeconstructURI (const AURIStr: string;
295
299
out AURI: System.Net.URLClient.TURI): Boolean;
296
300
begin
297
301
Result := True;
0 commit comments