-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathUMasks.pas
56 lines (44 loc) · 991 Bytes
/
UMasks.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
unit UMasks;
interface
uses UConfig;
type
TMasks = class
public
class function GetMasks(const DefinitionMasks: string): string;
end;
implementation
uses System.Classes, System.SysUtils;
class function TMasks.GetMasks(const DefinitionMasks: string): string;
var
S: TStringList;
I: Integer;
A, MasksTable: string;
M: TMasksTable;
begin
S := TStringList.Create;
try
S.Text := DefinitionMasks;
for I := S.Count-1 downto 0 do
begin
A := Trim(S[I]);
if A.IsEmpty or A.StartsWith('//') then
begin
S.Delete(I);
Continue;
end;
if A.StartsWith(':') then
begin
MasksTable := A.Substring(1);
M := Config.FindMasksTable(MasksTable);
if M=nil then
raise Exception.CreateFmt('Masks table "%s" not found', [MasksTable]);
S[I] := M.Masks; //replace line by masks table
Continue;
end;
end;
Result := S.Text;
finally
S.Free;
end;
end;
end.