-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpntl_obj.pas
394 lines (360 loc) · 11.7 KB
/
pntl_obj.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
Unit PntL_Obj;
INTERFACE
Uses
Use32,
App,Objects,Views,Dialogs,Drivers,Menus,Memory,HistList,
{** pm units **}
Incl,MCommon,Address,StrUnit,Parser,Logger;
Type
PTemplateBody=^TTemplateBody;
TTemplateBody=Object(TStringCollection)
Function Compare(Key1,Key2:Pointer):Integer;Virtual;
End;
Type
PMessageBody=^TMessageBody;
TMessageBody=Object(TStringCollection)
Function Compare(Key1,Key2:Pointer):Integer;Virtual;
End;
Type
PBossRecSortedCollection=^TBossRecSortedCollection;
TBossRecSortedCollection=Object(TSortedCollection)
Function Compare(Key1,Key2:Pointer):Integer;Virtual;
Function KeyOf(Item:Pointer):Pointer;Virtual;
Procedure Error(Code, Info: Integer);Virtual;
End;
Type
PPointsCollection=^TPointsCollection;
TPointsCollection=Object(TStringCollection)
Function Compare(Key1,Key2:Pointer):Integer;Virtual;
Procedure Error(Code, Info: Integer);Virtual;
End;
Type
PCommentsCollection=^TCommentsCollection;
TCommentsCollection=Object(TStringCollection)
Function Compare(Key1,Key2:Pointer):Integer;Virtual;
Procedure Error(Code, Info: Integer);Virtual;
End;
Type
PBossRecord=^TBossRecord;
TBossRecord=Object(TObject)
PBossString:PString;
PComments:PCommentsCollection;
PPoints:PPointsCollection;
Constructor Init(BossString:String;
CommentsCollection:PCommentsCollection;
PointsCollection:PPointsCollection);
Destructor Done;Virtual;
End;
Type
PBossWithSegmentErrors=^TBossWithSegmentErrors;
TBossWithSegmentErrors=Object(TObject)
TBossAddress:TAddress;
PSegmentName:PString;
PErrorsMap:PMessageBody;
Constructor Init(ABossAddress:String;ASegmentName:String;AErrorsMap:PMessageBody);
Destructor Done;Virtual;
End;
Type
PBossWithSegmentErrorsArray=^TBossWithSegmentErrorsArray;
TBossWithSegmentErrorsArray=Object(TSortedCollection)
Procedure Insert(Item: Pointer); virtual;
Function KeyOf(Item: Pointer): Pointer; virtual;
Function Compare(Key1, Key2: Pointer): Integer; virtual;
End;
Var
BossWithSegmentErrorsArray:PBossWithSegmentErrorsArray;
DupeBossesStrings:PMessageBody;
IMPLEMENTATION
Function TBossWithSegmentErrorsArray.KeyOf(Item: Pointer): Pointer;
Begin
KeyOf:=@PBossWithSegmentErrors(Item)^.TBossAddress;
End;
Function TBossWithSegmentErrorsArray.Compare(Key1, Key2: Pointer):Integer;
Var
FBoss,SBoss: TAddress;
Begin
FBoss:=TAddress(Key1^);
SBoss:=TAddress(Key2^);
If (FBoss.Zone=SBoss.Zone) And (FBoss.Net=SBoss.Net) And
(FBoss.Node=SBoss.Node) And (FBoss.Point=SBoss.Point) Then
Compare:=0
Else
Compare:=-1;
End;
Procedure TBossWithSegmentErrorsArray.Insert(Item: Pointer);
Var
Counter,I: Integer;
PBoss,PNewBoss: PBossWithSegmentErrors;
Begin
If Not Search(KeyOf(Item), I) {or Duplicates} then AtInsert(I, Item)
Else
Begin
PBoss:=PBossWithSegmentErrors(At(I));
PNewBoss:=PBossWithSegmentErrors(Item);
PBoss^.PErrorsMap^.Insert(MCommon.NewStr(' '));
For Counter:=0 To Pred(PNewBoss^.PErrorsMap^.Count) Do
Begin
PBoss^.PErrorsMap^.Insert(MCommon.NewStr(
PString(PNewBoss^.PErrorsMap^.At(Counter))^));
End;
If PNewBoss<> Nil Then
Dispose(PNewBoss,Done);
End;
End;
Constructor TBossWithSegmentErrors.Init(ABossAddress:String;ASegmentName:String;AErrorsMap:PMessageBody);
Var
Counter: Integer;
Begin
Inherited Init;
SetAddressFromString(ABossAddress,TBossAddress);
If StrTrim(ASegmentName)='' Then
PSegmentName:=MCommon.NewStr(' ')
Else
PSegmentName:=MCommon.NewStr(ASegmentName);
PErrorsMap:=New(PMessageBody,Init(5,5));
If AErrorsMap<>Nil Then
Begin
For Counter:=0 To Pred(AErrorsMap^.Count) Do
PErrorsMap^.Insert(MCOmmon.NewStr(PString(AErrorsMap^.At(Counter))^));
End;
End;
Destructor TBossWithSegmentErrors.Done;
Begin
If PErrorsMap<> Nil Then
PErrorsMap^.Done;
If PSegmentName<>Nil Then
Begin
DisposeStr(PSegmentName);
PSegmentName:=Nil;
End;
Inherited Done;
End;
Function TTemplateBody.Compare(Key1,Key2:Pointer):Integer;
Begin
Compare:=-1;
End;
Function TBossRecSortedCollection.KeyOf (Item:Pointer):Pointer;
Begin
KeyOf:=@PBossRecord(Item)^.PBossString^;
End;
Function TBossRecSortedCollection.Compare(Key1,Key2:Pointer):Integer;
Var
FStr,SStr: PString;
BeginPos,EndPos,
FBoss,SBoss,Code: Word;
Begin
FStr:=PString(Key1);
SStr:=PString(Key2);
If (FStr=Nil) or (SStr=Nil) or (FStr^='') or (SStr^='') Then
Begin
Compare:=1;
Exit;
End;
BeginPos:=Pos(',',FStr^);
EndPos:=Pos(':',FStr^);
Val(Copy(FStr^,BeginPos+1,EndPos-1-BeginPos),FBoss,Code);
BeginPos:=Pos(',',SStr^);
EndPos:=Pos(':',FStr^);
Val(Copy(SStr^,BeginPos+1,EndPos-1-BeginPos),SBoss,Code);
If FBoss<SBoss Then
Begin
Compare:=-1;
Exit;
End
Else
If FBoss=SBoss Then
Begin
End
Else
If FBoss>SBoss Then
Begin
Compare:=1;
Exit;
End;
BeginPos:=Pos('/',FStr^);
Val(Copy(FStr^,EndPos+1,BeginPos-EndPos-1),FBoss,Code);
BeginPos:=Pos('/',SStr^);
Val(Copy(SStr^,EndPos+1,BeginPos-EndPos-1),SBoss,Code);
If FBoss<SBoss Then
Begin
Compare:=-1;
Exit;
End
Else
If FBoss=SBoss Then
Begin
End
Else
If FBoss>SBoss Then
Begin
Compare:=1;
Exit;
End;
BeginPos:=Pos('/',FStr^);
Val(Copy(FStr^,BeginPos+1,Length(FStr^)),FBoss,Code);
BeginPos:=Pos('/',SStr^);
Val(Copy(SStr^,BeginPos+1,Length(SStr^)),SBoss,Code);
If FBoss<SBoss Then
Compare:=-1
Else
If FBoss=SBoss Then
Begin
Compare:=0;
Inc(DuplicateBosses);
If DupeBossesStrings=Nil Then
DupeBossesStrings:=New({PStringCollection}PMessageBody,Init(5,5));
If StrUp(GetVar(LanguageTag.Tag,_varNONE))=EnglishTag Then
DupeBossesStrings^.Insert(NewStr('File ('+GetFNameAndExt(PntListName)+').['+FStr^+']'))
Else
DupeBossesStrings^.Insert(NewStr('Файл ('+GetFNameAndExt(PntListName)+').['+FStr^+']'));
End
Else
If FBoss>SBoss Then
Compare:=1;
End;
Procedure TBossRecSortedCollection.Error(Code,Info:Integer);
Begin
If StrUp(GetVar(LanguageTag.Tag,_varNONE))=EnglishTag Then
Begin
Case Code Of
-1: LogWriteLn('!Bosses index out of range. Requested index: '+IntToStr(Info));
-2: LogWriteLn('!Bosses collection overflow. Requested index: '+IntToStr(Info));
End;
End
Else
Begin
Case Code Of
-1: LogWriteLn('!Индекс боссов выходит за допyстимые пpеделы. Запpошенный индекс: '+IntToStr(Info));
-2: LogWriteLn('!Пеpеполнение коллекции боссов. Зпpошенный индекс: '+IntToStr(Info));
End;
End;
End;
Function TPointsCollection.Compare(Key1,Key2:Pointer):Integer;
Var
FStr: PString {absolute Key1};
SStr: PString {absolute Key2};
BeginPos,EndPos:Word;
FPoint,SPoint,Code:Word;
Begin
FStr:=PString(Key1);
SStr:=PString(Key2);
If (FStr=Nil) or (SStr=Nil) or (FStr^='') or (SStr^='') Then
Begin
Compare:=1;
Exit;
End;
BeginPos:=Pos(',',FStr^);
EndPos:=Pos(',',Copy(FStr^,BeginPos+1,Length(FStr^)));
Val(Copy(FStr^,BeginPos+1,EndPos-1),FPoint,Code);
BeginPos:=Pos(',',SStr^);
EndPos:=Pos(',',Copy(SStr^,BeginPos+1,Length(SStr^)));
Val(Copy(SStr^,BeginPos+1,EndPos-1),SPoint,Code);
If FPoint<SPoint Then
Compare:=-1
Else
If FPoint=Spoint Then
Compare:=0
Else
If FPoint>SPoint Then
Compare:=1;
End;
Procedure TPointsCollection.Error(Code,Info:Integer);
Begin
If StrUp(GetVar(LanguageTag.Tag,_varNONE))=EnglishTag Then
Begin
Case Code Of
-1:LogWriteLn('!Points index out of range. Requested index: '+IntToStr(Info));
-2:LogWriteLn('!Points collection overflow. Requested index: '+IntToStr(Info));
End;
End
Else
Begin
Case Code Of
-1:LogWriteLn('!Индекс поинтов выходит за допyстимые пpеделы. Запpошенный индекс: '+IntToStr(Info));
-2:LogWriteLn('!Пеpеполнение коллекции поинтов. Запpошенный индекс: '+IntToStr(Info));
End;
End;
End;
Function TCommentsCollection.Compare(Key1,Key2:Pointer):Integer;
Begin
Compare:=-1;
End;
Procedure TCommentsCollection.Error(Code,Info:Integer);
Begin
If StrUp(GetVar(LanguageTag.Tag,_varNONE))=EnglishTag Then
Begin
Case Code Of
-1:LogWriteLn('!Comments index out of range. Requested index: '+IntToStr(Info));
-2:LogWriteLn('!Comments collection overflow. Requested index: '+IntToStr(Info));
End;
End
Else
Begin
Case Code Of
-1:LogWriteLn('!Индекс комментаpиев выходит за допyстимы пpеделы. Запpошенный индекс: '+IntToStr(Info));
-2:LogWriteLn('!Пеpеполнение коллекции комментаpиев. Запpошенный индекс: '+IntToStr(Info));
End;
End;
End;
Function TMessageBody.Compare(Key1,Key2:Pointer):Integer;
Begin
Compare:=-1;
End;
Constructor TBossRecord.Init(BossString:String;
CommentsCollection:PCommentsCollection;
PointsCollection:PPointsCollection);
Var
Counter:Integer;
Begin
Inherited Init;
BossString:=StrDown(BossString);
BossString[1]:=UpCase(BossString[1]);
PBossString:=MCommon.NewStr(BossString);
If CommentsCollection<>Nil Then
Begin
PComments:=New(PCommentsCollection,Init(CommentsCollection^.Count+1,1));
If CommentsCollection^.Count<>0 Then
Begin
For Counter:=0 To Pred(CommentsCollection^.Count) Do
Begin
PComments^.Insert(MCommon.NewStr(PString(CommentsCollection^.At(Counter))^))
End;
End;
End
Else
Begin
PComments:=New(PCommentsCollection,Init(1,1));
End;
If PointsCollection<>Nil Then
Begin
PPoints:=New(PPointsCollection,Init(PointsCollection^.Count+1,1));
If PointsCollection^.Count<>0 Then
Begin
For Counter:=0 To Pred(PointsCollection^.Count) Do
Begin
PString(PointsCollection^.At(Counter))^[1]:=UpCase(PString(PointsCollection^.At(Counter))^[1]);
PString(PointsCollection^.At(Counter))^[2]:=DownCase(PString(PointsCollection^.At(Counter))^[2]);
PString(PointsCollection^.At(Counter))^[3]:=DownCase(PString(PointsCollection^.At(Counter))^[3]);
PString(PointsCollection^.At(Counter))^[4]:=DownCase(PString(PointsCollection^.At(Counter))^[4]);
PString(PointsCollection^.At(Counter))^[5]:=DownCase(PString(PointsCollection^.At(Counter))^[5]);
PPoints^.Insert(MCommon.NewStr(PString(PointsCollection^.At(Counter))^));
End;
End;
End
Else
Begin
PPoints:=New(PPointsCollection,Init(1,1));
End;
End;
Destructor TBossRecord.Done;
Begin
DisposeStr(PBossString);
PBossString:=Nil;
Dispose(PComments,Done);
PComments:=Nil;
Dispose(PPoints,Done);
PPoints:=Nil;
Inherited Done;
End;
Begin
End.