-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtemplate.pas
95 lines (76 loc) · 2.6 KB
/
template.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
{
@abstract( unit)
The unit is a part of Template Algorithms and Collections Library and contains related constants
@author(George Bakhtadze (avagames@gmail.com))
}
unit template;
{$I g3config.inc}
interface
// Template option constants
const
// sort in descending order
soDescending = 0;
// sort data can be extremely quicksort-unfriendly
soBadData = 1;
type
// Data structure options set elements
TDataStructureOption = (// data structure value can be nil
dsNullable,
// data structure should perform range checking
dsRangeCheck,
// disable vector/list memory initialization after allocation
dsDisableInit
// data structure key is a string (to correctly select hash function)
//dsStringKey
);
// Type for collection indexes, sizes etc
__CollectionIndexType = Integer;
TCollection = interface
end;
TTplList = interface
end;
TMap = interface
end;
// Implements base interface for template classes
TTemplateInterface = class(TObject, IInterface)
protected
function QueryInterface({$IFDEF FPC_HAS_CONSTREF}constref{$ELSE}const{$ENDIF} IID: TGUID; out Obj): HResult;
{$IFDEF FPC}
{$IF (not defined(WINDOWS)) AND (FPC_FULLVERSION>=20501)}cdecl{$ELSE}stdcall{$IFEND}
{$ELSE}stdcall{$ENDIF};
function _AddRef: Integer;
{$IFDEF FPC}
{$IF (not defined(WINDOWS)) AND (FPC_FULLVERSION>=20501)}cdecl{$ELSE}stdcall{$IFEND}
{$ELSE}stdcall{$ENDIF};
function _Release: Integer;
{$IFDEF FPC}
{$IF (not defined(WINDOWS)) AND (FPC_FULLVERSION>=20501)}cdecl{$ELSE}stdcall{$IFEND}
{$ELSE}stdcall{$ENDIF};
end;
implementation
{ TTemplateInterface }
function TTemplateInterface.QueryInterface({$IFDEF FPC_HAS_CONSTREF}constref{$ELSE}const{$ENDIF} IID: TGUID; out Obj): HResult;
{$IFDEF FPC}
{$IF (not defined(WINDOWS)) AND (FPC_FULLVERSION>=20501)}cdecl{$ELSE}stdcall{$IFEND}
{$ELSE}stdcall{$ENDIF};
begin
if GetInterface(IID, Obj) then
Result := 0
else
Result := E_NOINTERFACE;
end;
function TTemplateInterface._AddRef: Integer;
{$IFDEF FPC}
{$IF (not defined(WINDOWS)) AND (FPC_FULLVERSION>=20501)}cdecl{$ELSE}stdcall{$IFEND}
{$ELSE}stdcall{$ENDIF};
begin
Result := 1;
end;
function TTemplateInterface._Release: Integer;
{$IFDEF FPC}
{$IF (not defined(WINDOWS)) AND (FPC_FULLVERSION>=20501)}cdecl{$ELSE}stdcall{$IFEND}
{$ELSE}stdcall{$ENDIF};
begin
Result := 1;
end;
end.