hexsha
stringlengths 40
40
| size
int64 3
1.05M
| ext
stringclasses 163
values | lang
stringclasses 53
values | max_stars_repo_path
stringlengths 3
945
| max_stars_repo_name
stringlengths 4
112
| max_stars_repo_head_hexsha
stringlengths 40
78
| max_stars_repo_licenses
listlengths 1
10
| max_stars_count
float64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 3
945
| max_issues_repo_name
stringlengths 4
113
| max_issues_repo_head_hexsha
stringlengths 40
78
| max_issues_repo_licenses
listlengths 1
10
| max_issues_count
float64 1
116k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 3
945
| max_forks_repo_name
stringlengths 4
113
| max_forks_repo_head_hexsha
stringlengths 40
78
| max_forks_repo_licenses
listlengths 1
10
| max_forks_count
float64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | content
stringlengths 3
1.05M
| avg_line_length
float64 1
966k
| max_line_length
int64 1
977k
| alphanum_fraction
float64 0
1
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
179f34b3a2b392972ccdf2d3e00e7792d5dbe728
| 21,523 |
pas
|
Pascal
|
Version8/Source/Shared/CktTree.pas
|
dss-extensions/electricdss-src
|
fab07b5584090556b003ef037feb25ec2de3b7c9
|
[
"BSD-3-Clause"
] | 1 |
2022-01-23T14:43:30.000Z
|
2022-01-23T14:43:30.000Z
|
Version8/Source/Shared/CktTree.pas
|
PMeira/electricdss-src
|
fab07b5584090556b003ef037feb25ec2de3b7c9
|
[
"BSD-3-Clause"
] | 7 |
2018-08-15T04:00:26.000Z
|
2018-10-25T10:15:59.000Z
|
Version8/Source/Shared/CktTree.pas
|
PMeira/electricdss-src
|
fab07b5584090556b003ef037feb25ec2de3b7c9
|
[
"BSD-3-Clause"
] | null | null | null |
unit CktTree;
{
----------------------------------------------------------
Copyright (c) 2008-2015, Electric Power Research Institute, Inc.
All rights reserved.
----------------------------------------------------------
}
{ Change Log
8/12/99 Added level number to node
}
{$M+}
interface
uses
Classes,
ArrayDef,
StackDef,
PointerList,
CktElement;
type
TAdjArray = array of TList;
TCktTreeNode = class(TObject)
PRIVATE
FChildBranches: TPointerList; // List of CktTreeNode pointers
NumToBuses, ToBusPtr: Integer;
ToBusList: pIntegerArray;
function Get_FirstChild: TCktTreeNode;
function Get_NextChild: TCktTreeNode;
function Get_Parent: TCktTreeNode;
procedure Set_AddChild(const Value: TCktTreeNode);
procedure Set_AddObject(Value: Pointer);
function Get_NumChildren: Integer;
function Get_NumObjects: Integer;
function Get_ToBusReference: Integer;
procedure Set_ToBusReference(const Value: Integer);
function Get_FirstObject: Pointer;
function Get_NextObject: Pointer;
PROTECTED
ChildAdded: Boolean;
LexicalLevel: Integer;
FParentBranch: TCktTreeNode;
FShuntObjects: TPointerList; // Generic objects attached to the tree at this node
PUBLIC
CktObject: Pointer; // Pointer to the circuit object referenced
FromBusReference: Integer;
VoltBaseIndex: Integer;
FromTerminal: Integer;
IsLoopedHere, IsParallel, IsDangling: Boolean;
LoopLineObj: Pointer;
constructor Create(const pParent: TCktTreeNode; const pSelfObj: Pointer);
destructor Destroy; OVERRIDE;
procedure ResetToBusList;
property AddChildBranch: TCktTreeNode WRITE Set_AddChild;
property AddShuntObject: Pointer WRITE Set_AddObject;
property FirstChildBranch: TCktTreeNode READ Get_FirstChild;
property NextChildBranch: TCktTreeNode READ Get_NextChild;
property FirstShuntObject: Pointer READ Get_FirstObject;
property NextShuntObject: Pointer READ Get_NextObject;
property ParentBranch: TCktTreeNode READ Get_Parent;
property NumChildBranches: Integer READ Get_NumChildren; // Number of children at present node
property NumShuntObjects: Integer READ Get_NumObjects; // Number of objects at present node
property ToBusReference: Integer READ Get_ToBusReference WRITE Set_ToBusReference;
PUBLISHED
end;
TZoneEndsList = class(Tobject)
PRIVATE
EndNodeList: TPointerList;
EndBuses: pIntegerArray;
PROTECTED
PUBLIC
NumEnds: Integer;
constructor Create;
destructor Destroy; OVERRIDE;
procedure Add(const Node: TCktTreeNode; EndBusRef: Integer);
function Get(i: Integer; var Node: TCktTreeNode): Integer;
PUBLISHED
end;
TCktTree = class(TObject)
PRIVATE
FirstNode: TCktTreeNode;
ForwardStack: TPstack;
function Get_Forward: Pointer;
function Get_Backward: Pointer;
function Get_First: Pointer;
function Get_Parent: Pointer;
function Get_FirstObject: Pointer;
function Get_NextObject: Pointer;
function Get_Active: Pointer;
function Get_Level: Integer;
procedure Set_New(Value: Pointer);
procedure Set_NewObject(Value: Pointer);
procedure Set_Active(p: Pointer); // Set present node to this value
procedure PushAllChildren;
PROTECTED
PUBLIC
PresentBranch: TCktTreeNode;
ZoneEndsList: TZoneEndsList;
constructor Create;
destructor Destroy; OVERRIDE;
procedure StartHere; // Start Forward Search at the present location
// can also use active
procedure AddNewChild(Value: Pointer; BusRef, TerminalNo: Integer);
property New: Pointer WRITE Set_New; // Adds Child and makes it present
//Property NewChild :Pointer Write Set_NewChild; // Adds child to present, but doesn't change present
property NewObject: Pointer WRITE Set_NewObject; // Adds a pointer to an object to be associated with the current node
property First: Pointer READ Get_First; // Returns pointer to first cktobject
property Parent: Pointer READ Get_Parent;
property FirstObject: Pointer READ Get_FirstObject;
property NextObject: Pointer READ Get_NextObject;
property GoForward: Pointer READ Get_Forward;
property GoBackward: Pointer READ Get_Backward;
property Active: Pointer READ Get_Active WRITE Set_Active;
property Level: Integer READ Get_Level; {Get lexical level of present node}
PUBLISHED
end;
// build a tree of connected elements beginning at StartElement
// Analyze = TRUE will check for loops, isolated components, and parallel lines (takes longer)
function GetIsolatedSubArea(StartElement: TDSSCktElement; Analyze: Boolean = FALSE): TCktTree;
procedure BuildActiveBusAdjacencyLists(var lstPD, lstPC: TAdjArray; ActorID: Integer);
procedure FreeAndNilBusAdjacencyLists(var lstPD, lstPC: TAdjArray);
implementation
uses
Circuit,
PDElement,
PCElement,
DSSGlobals,
Utilities;
constructor TcktTreeNode.Create(const pParent: TCktTreeNode; const pSelfobj: Pointer);
begin
inherited create;
CktObject := pSelfObj;
FParentBranch := pParent;
if FParentBranch <> NIL then
LexicalLevel := FParentBranch.LexicalLevel + 1
else
LexicalLevel := 0;
FChildBranches := TPointerList.Create(2);
FShuntObjects := TPointerList.Create(1);
FromBusReference := 0;
VoltBaseIndex := 0; // Index to voltage base list used by energymeter and maybe others
NumToBuses := 0;
ToBusList := NIL;
ToBusPtr := 0;
ChildAdded := FALSE;
// TEMc - initialize some topology variables, 10/2009
IsDangling := TRUE;
IsLoopedHere := FALSE;
IsParallel := FALSE;
LoopLineObj := NIL;
end;
destructor TcktTreeNode.Destroy;
var
pChild, pNext: Pointer;
TempNode: TCktTreeNode;
begin
pChild := FChildBranches.First;
while pChild <> NIL do
begin
pNext := FChildBranches.Next;
TempNode := TcktTreeNode(pChild);
TempNode.Free;
pChild := pNext;
end;
Reallocmem(ToBusList, 0);
FChildBranches.Free;
FShuntObjects.Free;
inherited Destroy;
end;
procedure TcktTreeNode.Set_AddChild(const Value: TCktTreeNode);
begin
FChildBranches.New := Value;
ChildAdded := TRUE;
end;
procedure TcktTreeNode.Set_AddObject(Value: Pointer);
begin
FShuntObjects.New := Value;
end;
function TcktTreeNode.Get_FirstChild: TCktTreeNode;
begin
Result := FChildBranches.First;
end;
function TcktTreeNode.Get_NextChild: TCktTreeNode;
begin
Result := FChildBranches.Next;
end;
function TcktTreeNode.Get_Parent: TCktTreeNode;
begin
Result := FParentBranch;
end;
constructor TcktTree.Create;
begin
inherited create;
FirstNode := NIL;
PresentBranch := NIL;
ZoneEndsList := TZoneEndsList.Create;
ForwardStack := Tpstack.Create(20);
end;
destructor TcktTree.Destroy;
begin
ForwardStack.Free;
if assigned(ZoneEndsList) then
ZoneEndsList.Free;
if Assigned(FirstNode) then
FirstNode.Free;
inherited Destroy;
end;
procedure TcktTree.Set_New(Value: Pointer);
begin
PresentBranch := TcktTreeNode.Create(PresentBranch, Value);
if FirstNode = NIL then
FirstNode := PresentBranch;
end;
procedure TcktTree.AddNewChild(Value: Pointer; BusRef, TerminalNo: Integer);
var
TempNode: TCktTreeNode;
begin
if PresentBranch = NIL then
begin
Set_New(Value);
end
else
begin
TempNode := TcktTreeNode.Create(PresentBranch, Value);
with TempNode do
begin
FromBusReference := BusRef;
FromTerminal := TerminalNo;
end;
PresentBranch.AddChildBranch := TempNode;
end;
end;
procedure TcktTree.Set_NewObject(Value: Pointer);
begin
if PresentBranch <> NIL then
begin
PresentBranch.AddShuntObject := Value;
end;
end;
procedure TcktTree.PushAllChildren;
var
pChild: Pointer;
begin
if PresentBranch <> NIL then
begin
// Push all children of present node onto stack
pChild := PresentBranch.FirstChildBranch;
while pChild <> NIL do
begin
ForwardStack.Push(pChild);
pChild := PresentBranch.NextChildBranch;
end;
PresentBranch.ChildAdded := FALSE;
end;
end;
function TcktTree.Get_Forward: Pointer;
begin
// MoveForward from Present node
// If we have added children to the present node since we opened it push em on
if PresentBranch <> NIL then
if PresentBranch.ChildAdded then
PushAllChildren;
// If the forward stack is empty push stuff on it to get started
if ForwardStack.Size = 0 then
PushAllChildren;
PresentBranch := ForwardStack.Pop;
PushAllChildren; // push all children of latest
if PresentBranch <> NIL then
Result := PresentBranch.CktObject
else
Result := NIL;
end;
function TcktTree.Get_Backward: Pointer;
begin
// Move Backwardfrom Present node and reset forward stack
PresentBranch := PresentBranch.ParentBranch;
ForwardStack.Clear;
if PresentBranch <> NIL then
Result := PresentBranch.CktObject
else
Result := NIL;
end;
function TcktTree.Get_Parent: Pointer;
begin
if PresentBranch.FParentBranch <> NIL then
Result := PresentBranch.FParentBranch.CktObject
else
Result := NIL;
end;
function TcktTree.Get_First: Pointer;
begin
// go to beginning and reset forward stack
PresentBranch := FirstNode;
ForwardStack.Clear;
PushAllChildren;
if PresentBranch <> NIL then
Result := PresentBranch.CktObject
else
Result := NIL;
end;
function TcktTree.Get_FirstObject: Pointer;
begin
if PresentBranch <> NIL then
Result := PresentBranch.FShuntObjects.First
else
Result := NIL;
end;
function TcktTree.Get_NextObject: Pointer;
begin
if PresentBranch <> NIL then
Result := PresentBranch.FShuntObjects.Next
else
Result := NIL;
end;
function TcktTree.Get_Active: Pointer;
begin
if PresentBranch <> NIL then
Result := PresentBranch.CktObject
else
Result := NIL;
end;
procedure TcktTree.Set_Active(p: Pointer);
var
Temp: Pointer;
begin
Temp := Get_First;
while Temp <> NIL do
begin
if PresentBranch.CktObject = p then
Break;
Temp := Get_Forward;
end;
ForwardStack.Clear;
end;
procedure TcktTree.StartHere;
begin
ForwardStack.Clear;
if PresentBranch <> NIL then
ForwardStack.Push(PresentBranch);
end;
function TcktTree.Get_Level: Integer;
begin
if PresentBranch <> NIL then
result := PresentBranch.LexicalLevel
else
result := 0;
end;
function TCktTreeNode.Get_NumChildren: Integer;
begin
Result := FChildBranches.ListSize;
end;
function TCktTreeNode.Get_NumObjects: Integer;
begin
Result := FShuntObjects.ListSize;
end;
{ TZoneEndsList }
procedure TZoneEndsList.Add(const Node: TCktTreeNode; EndBusRef: Integer);
begin
Inc(NumEnds);
EndnodeList.New := Node;
Reallocmem(EndBuses, Sizeof(EndBuses) * NumEnds);
EndBuses^[NumEnds] := EndBusRef;
end;
constructor TZoneEndsList.Create;
begin
EndnodeList := TPointerList.Create(10);
NumEnds := 0;
EndBuses := NIL;
end;
destructor TZoneEndsList.Destroy;
begin
EndnodeList.Free;
Reallocmem(EndBuses, 0);
inherited;
end;
function TZoneEndsList.Get(i: Integer; var Node: TCktTreeNode): Integer;
begin
Node := EndnodeList.Get(i);
Result := EndBuses^[i];
end;
function TCktTreeNode.Get_ToBusReference: Integer;
{Sequentially access the To Bus list if more than one with each invocation of the property}
begin
if NumToBuses = 1 then
begin
Result := ToBusList^[1]; // Always return the first
end
else
begin
Inc(ToBusPtr);
if ToBusPtr > NumToBuses then
begin
Result := -1;
ToBusPtr := 0; // Ready for next sequence of access
end
else
Result := ToBusList^[ToBusPtr];
end;
end;
procedure TCktTreeNode.Set_ToBusReference(const Value: Integer);
begin
Inc(NumToBuses);
Reallocmem(ToBusList, Sizeof(ToBusList^[1]) * NumToBuses);
TobusList^[NumToBuses] := Value;
end;
procedure TCktTreeNode.ResetToBusList;
begin
ToBusPtr := 0;
end;
function TCktTreeNode.Get_FirstObject: Pointer;
begin
Result := FShuntObjects.First;
end;
function TCktTreeNode.Get_NextObject: Pointer;
begin
Result := FShuntObjects.Next;
end;
////////////////////////////////////////////////////////////////////////
//
// utility code for building a connected tree starting from a circuit element
//
////////////////////////////////////////////////////////////////////////
// sources are excluded from the PC element list, so this is a brute-force search
procedure GetSourcesConnectedToBus(BusNum: Integer; BranchList: TCktTree; Analyze: Boolean);
var
psrc: TPCElement; // Sources are special PC elements
begin
with ActiveCircuit[ActiveActor] do
begin
psrc := Sources.First;
while psrc <> NIL do
begin
if psrc.Enabled then
begin
if Analyze or (not psrc.Checked) then
begin
if (psrc.Terminals^[1].BusRef = BusNum) then
begin // ?Connected to this bus ?
if Analyze then
begin
psrc.IsIsolated := FALSE;
BranchList.PresentBranch.IsDangling := FALSE;
end;
if not psrc.checked then
begin
BranchList.NewObject := psrc;
psrc.Checked := TRUE;
end;
end;
end;
end;
psrc := Sources.Next;
end;
end;{With}
end;
procedure GetPCElementsConnectedToBus(adjLst: TList; BranchList: TCktTree; Analyze: Boolean);
var
p: TDSSCktElement;
i: Integer;
begin
for i := 0 to adjLst.Count - 1 do
begin
p := adjLst[i];
if p.Enabled then
begin
if Analyze then
begin
p.IsIsolated := FALSE;
BranchList.PresentBranch.IsDangling := FALSE;
end;
if not p.Checked then
begin
BranchList.NewObject := p;
p.Checked := TRUE;
end;
end;
end;
end;
procedure FindAllChildBranches(adjLst: TList; BusNum: Integer; BranchList: TCktTree;
Analyze: Boolean; ActiveBranch: TDSSCktElement);
var
i, j: Integer;
p: TDSSCktElement;
begin
for i := 0 to adjLst.Count - 1 do
begin
p := adjLst[i];
if p.Enabled and not (p = ActiveBranch) then
begin
if Analyze or (not p.Checked) then
begin
if (not IsShuntElement(p)) and AllTerminalsClosed(p) then
begin
for j := 1 to p.NTerms do
begin
if BusNum = p.Terminals^[j].BusRef then
begin
if Analyze then
begin
p.IsIsolated := FALSE;
BranchList.PresentBranch.IsDangling := FALSE;
if p.Checked and (BranchList.Level > 0) then
begin
BranchList.PresentBranch.IsLoopedHere := TRUE;
BranchList.PresentBranch.LoopLineObj := p;
if IsLineElement(p) and IsLineElement(ActiveBranch) then
if CheckParallel(ActiveBranch, p) then
BranchList.PresentBranch.IsParallel := TRUE;
end;
end;
if not p.Checked then
begin
BranchList.AddNewChild(p, BusNum, j);
p.Terminals^[j].checked := TRUE;
p.Checked := TRUE;
Break; {For}
end;
end;
end;
end;
end;
end;
end;
end;
procedure GetShuntPDElementsConnectedToBus(adjLst: TList; BranchList: TCktTree; Analyze: Boolean);
var
p: TDSSCktElement;
i: Integer;
begin
for i := 0 to adjLst.Count - 1 do
begin
p := adjLst[i];
if p.Enabled and IsShuntElement(p) then
begin
if Analyze then
begin
p.IsIsolated := FALSE;
BranchList.PresentBranch.IsDangling := FALSE;
end;
if not p.Checked then
begin
BranchList.NewObject := p;
p.Checked := TRUE;
end;
end;
end;
end;
function GetIsolatedSubArea(StartElement: TDSSCktElement; Analyze: Boolean): TCktTree;
var
TestBusNum: Integer;
BranchList: TCktTree;
iTerm: Integer;
TestBranch,
TestElement: TDSSCktElement;
lstPD, lstPC: TAdjArray;
begin
lstPD := ActiveCircuit[ActiveActor].GetBusAdjacentPDLists(ActiveActor);
lstPC := ActiveCircuit[ActiveActor].GetBusAdjacentPCLists(ActiveActor);
BranchList := TCktTree.Create;
TestElement := StartElement;
BranchList.New := TestElement;
if Analyze then
TestElement.IsIsolated := FALSE;
TestElement.LastTerminalChecked := 0; // We'll check things connected to both sides
// Check off this element so we don't use it again
TestElement.Checked := TRUE;
// Now start looking for other branches
// Finds any branch connected to the TestBranch and adds it to the list
// Goes until end of circuit, another energy meter, an open terminal, or disabled device.
TestBranch := TestElement;
while TestBranch <> NIL do
begin
for iTerm := 1 to TestBranch.Nterms do
begin
if not TestBranch.Terminals^[iTerm].Checked then
begin
// Now find all pc Elements connected to the bus on this end of branch
// attach them as generic objects to cktTree node.
TestBusNum := TestBranch.Terminals^[iTerm].BusRef;
BranchList.PresentBranch.ToBusReference := TestBusNum; // Add this as a "to" bus reference
if TestBusNum > 0 then
begin
ActiveCircuit[ActiveActor].Buses^[TestBusNum].BusChecked := TRUE;
GetSourcesConnectedToBus(TestBusNum, BranchList, Analyze);
GetPCElementsConnectedToBus(lstPC[TestBusNum], BranchList, Analyze);
GetShuntPDElementsConnectedToBus(lstPD[TestBusNum], BranchList, Analyze);
FindAllChildBranches(lstPD[TestBusNum], TestBusNum, BranchList, Analyze, TestBranch);
end;
end;
end; {FOR iTerm}
TestBranch := BranchList.GoForward;
end; {WHILE}
Result := BranchList;
end;
procedure BuildActiveBusAdjacencyLists(var lstPD, lstPC: TAdjArray; ActorID: Integer);
var
i, j, nBus: Integer;
pCktElement: TDSSCktElement;
begin
nBus := ActiveCircuit[ActorID].NumBuses;
// Circuit.Buses is effectively 1-based; bus 0 is ground
SetLength(lstPD, nBus + 1);
SetLength(lstPC, nBus + 1);
for i := 0 to nBus do
begin
lstPD[i] := TList.Create; // default capacity should be enough
lstPC[i] := TList.Create;
end;
pCktElement := ActiveCircuit[ActorID].PCElements.First;
while pCktElement <> NIL do
begin
if pCktElement.Enabled then
begin
i := pCktElement.Terminals^[1].BusRef;
lstPC[i].Add(pCktElement);
end;
pCktElement := ActiveCircuit[ActorID].PCElements.Next;
end;
pCktElement := ActiveCircuit[ActorID].PDElements.First;
{Put only eligible PDElements in the list}
while pCktElement <> NIL do
begin
if pCktElement.Enabled then
if IsShuntElement(pCktElement) then
begin
i := pCktElement.Terminals^[1].BusRef;
lstPC[i].Add(pCktElement);
end
else
if AllTerminalsClosed(pCktElement) then
for j := 1 to pCktElement.Nterms do
begin
i := pCktElement.Terminals^[j].BusRef;
lstPD[i].Add(pCktElement);
end;
pCktElement := ActiveCircuit[ActorID].PDElements.Next;
end;
end;
procedure FreeAndNilBusAdjacencyLists(var lstPD, lstPC: TAdjArray);
var
i: Integer;
begin
for i := Low(lstPD) to High(lstPD) do
begin
lstPD[i].Free;
lstPC[i].Free;
end;
SetLength(lstPD, 0);
SetLength(lstPC, 0);
lstPD := NIL;
lstPC := NIL;
end;
end.
| 27.807494 | 126 | 0.618083 |
85c6c8c421a3913c62bd024aaac9bf005d89ed1a
| 13,237 |
pas
|
Pascal
|
windows/src/ext/jedi/jvcl/jvcl/run/JvTFWeeks.pas
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 219 |
2017-06-21T03:37:03.000Z
|
2022-03-27T12:09:28.000Z
|
windows/src/ext/jedi/jvcl/jvcl/run/JvTFWeeks.pas
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 4,451 |
2017-05-29T02:52:06.000Z
|
2022-03-31T23:53:23.000Z
|
windows/src/ext/jedi/jvcl/jvcl/run/JvTFWeeks.pas
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 72 |
2017-05-26T04:08:37.000Z
|
2022-03-03T10:26:20.000Z
|
{-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: JvTFWeeks.PAS, released on 2003-08-01.
The Initial Developer of the Original Code is Unlimited Intelligence Limited.
Portions created by Unlimited Intelligence Limited are Copyright (C) 1999-2002 Unlimited Intelligence Limited.
All Rights Reserved.
Contributor(s):
Mike Kolter (original code)
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.delphi-jedi.org
Known Issues:
-----------------------------------------------------------------------------}
// $Id$
unit JvTFWeeks;
{$I jvcl.inc}
interface
uses
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
SysUtils, Classes, Windows, Messages, Graphics, Controls, Forms, Dialogs,
JvTFManager, JvTFGlance, JvTFUtils;
type
TJvTFDispOrder = (doLeftRight, doTopBottom);
{$IFDEF RTL230_UP}
[ComponentPlatformsAttribute(pidWin32 or pidWin64)]
{$ENDIF RTL230_UP}
TJvTFWeeks = class(TJvTFCustomGlance)
private
FWeekCount: Integer;
FDisplayDays: TTFDaysOfWeek;
FSplitDay: TTFDayOfWeek;
FIgnoreSplit: Boolean;
FDisplayOrder: TJvTFDispOrder;
FDWNames: TJvTFDWNames;
FDWTitleAttr: TJvTFGlanceTitle;
FOnDrawDWTitle: TJvTFDrawDWTitleEvent;
FOnUpdateTitle: TJvTFUpdateTitleEvent;
function GetDisplayDate: TDate;
procedure SetDisplayDate(Value: TDate);
procedure SetWeekCount(Value: Integer);
procedure SetDisplayDays(Value: TTFDaysOfWeek);
procedure SetSplitDay(Value: TTFDayOfWeek);
procedure SetIgnoreSplit(Value: Boolean);
procedure SetDisplayOrder(Value: TJvTFDispOrder);
procedure SetDWNames(Value: TJvTFDWNames);
procedure SetDWTitleAttr(Value: TJvTFGlanceTitle);
protected
procedure ConfigCells; override;
procedure SetStartOfWeek(Value: TTFDayOfWeek); override;
procedure DWNamesChange(Sender: TObject);
procedure Navigate(AControl: TJvTFControl; SchedNames: TStringList;
Dates: TJvTFDateList); override;
function GetSplitParentDay: TTFDayOfWeek;
function GetCellTitleText(Cell: TJvTFGlanceCell): string; override;
// draws the DW Titles
procedure DrawTitle(ACanvas: TCanvas); override;
procedure UpdateTitle;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function GetDataTop: Integer; override;
function DisplayDayCount: Integer;
procedure PrevWeek;
procedure NextWeek;
published
property DisplayDate: TDate read GetDisplayDate write SetDisplayDate;
property DisplayDays: TTFDaysOfWeek read FDisplayDays write SetDisplayDays
default [dowSunday..dowSaturday];
property DisplayOrder: TJvTFDispOrder read FDisplayOrder write SetDisplayOrder;
property DWNames: TJvTFDWNames read FDWNames write SetDWNames;
property DWTitleAttr: TJvTFGlanceTitle read FDWTitleAttr write SetDWTitleAttr;
property IgnoreSplit: Boolean read FIgnoreSplit write SetIgnoreSplit default False;
property SplitDay: TTFDayOfWeek read FSplitDay write SetSplitDay default dowSunday;
property WeekCount: Integer read FWeekCount write SetWeekCount default 1;
property OnDrawDWTitle: TJvTFDrawDWTitleEvent read FOnDrawDWTitle write FOnDrawDWTitle;
property OnUpdateTitle: TJvTFUpdateTitleEvent read FOnUpdateTitle write FOnUpdateTitle;
property StartOfWeek default dowMonday;
// property Navigator;
// property OnNavigate;
end;
{$IFDEF UNITVERSIONING}
const
UnitVersioning: TUnitVersionInfo = (
RCSfile: '$URL$';
Revision: '$Revision$';
Date: '$Date$';
LogPath: 'JVCL\run'
);
{$ENDIF UNITVERSIONING}
implementation
uses
JvResources;
procedure TJvTFWeeks.ConfigCells;
var
Row, Col, CalcRowCount: Integer;
CurrDate: TDateTime;
DayToSplit: TTFDayOfWeek;
CanSplit: Boolean;
procedure DisplayDateCheck;
begin
while not (DateToDOW(CurrDate) in DisplayDays) do
IncDays(CurrDate, 1);
end;
procedure ConfigCell(ACell: TJvTFGlanceCell);
var
TestDay: TTFDayOfWeek;
begin
DisplayDateCheck;
SetCellDate(ACell, CurrDate);
TestDay := DateToDOW(CurrDate);
IncDays(CurrDate, 1);
if (TestDay = DayToSplit) and (SplitDay in DisplayDays) and CanSplit then
begin
SplitCell(ACell);
DisplayDateCheck;
SetCellDate(ACell.Subcell, CurrDate);
IncDays(CurrDate, 1);
end
else
CombineCell(ACell);
end;
begin
if WeekCount = 1 then
begin
ColCount := 2;
CalcRowCount := DisplayDayCount;
if Odd(CalcRowCount) and not (SplitDay in DisplayDays) then
Inc(CalcRowCount);
RowCount := CalcRowCount div 2;
CanSplit := not IgnoreSplit and Odd(DisplayDayCount);
end
else
begin
if not IgnoreSplit and (SplitDay in DisplayDays) then
ColCount := DisplayDayCount - 1
else
ColCount := DisplayDayCount;
RowCount := WeekCount;
CanSplit := not IgnoreSplit;
end;
DayToSplit := GetSplitParentDay;
CurrDate := OriginDate;
if DisplayOrder = doLeftRight then
for Row := 0 to RowCount - 1 do
for Col := 0 to ColCount - 1 do
ConfigCell(Cells.Cells[Col, Row])
else
for Col := 0 to ColCount - 1 do
for Row := 0 to RowCount - 1 do
ConfigCell(Cells.Cells[Col, Row]);
inherited ConfigCells;
end;
constructor TJvTFWeeks.Create(AOwner: TComponent);
begin
FWeekCount := 1;
FDisplayDays := DOW_WEEK;
FSplitDay := dowSunday;
FIgnoreSplit := False;
inherited Create(AOwner);
GapSize := 4;
CellAttr.TitleAttr.Color := clWhite;
CellAttr.TitleAttr.FrameAttr.Color := clGray;
FDWNames := TJvTFDWNames.Create;
FDWNames.OnChange := DWNamesChange;
FDWTitleAttr := TJvTFGlanceTitle.Create(Self);
with FDWTitleAttr do
begin
Assign(TitleAttr);
TxtAttr.Font.Size := 8;
Height := 20;
OnChange := GlanceTitleChange;
end;
StartOfWeek := dowMonday;
DisplayDate := Date;
end;
destructor TJvTFWeeks.Destroy;
begin
FDWNames.OnChange := nil;
FDWNames.Free;
FDWTitleAttr.OnChange := nil;
FDWTitleAttr.Free;
inherited Destroy;
end;
function TJvTFWeeks.DisplayDayCount: Integer;
var
DOW: TTFDayOfWeek;
begin
Result := 0;
for DOW := Low(TTFDayOfWeek) to High(TTFDayOfWeek) do
if DOW in DisplayDays then
Inc(Result);
end;
procedure TJvTFWeeks.DrawTitle(ACanvas: TCanvas);
var
I, Col, LineBottom: Integer;
SplitParentDay, CurrDOW: TTFDayOfWeek;
ARect, TempRect, TxtRect, TextBounds: TRect;
OldPen: TPen;
OldBrush: TBrush;
OldFont: TFont;
Txt: string;
procedure CheckCurrDOW;
begin
while not (CurrDOW in DisplayDays) do
IncDOW(CurrDOW, 1);
end;
begin
inherited DrawTitle(ACanvas);
// Don't draw the DW Titles if we're only showing one week.
if not DWTitleAttr.Visible or (WeekCount = 1) then
Exit;
with ACanvas do
begin
OldPen := TPen.Create;
OldPen.Assign(Pen);
OldBrush := TBrush.Create;
OldBrush.Assign(Brush);
OldFont := TFont.Create;
OldFont.Assign(Font);
end;
// draw the DWTitles
ARect.Top := inherited GetDataTop;
ARect.Bottom := GetDataTop;
CurrDOW := StartOfWeek;
SplitParentDay := GetSplitParentDay;
for Col := 0 to ColCount - 1 do
begin
TempRect := WholeCellRect(Col, 0);
ARect.Left := TempRect.Left;
ARect.Right := TempRect.Right;
TxtRect := ARect;
Windows.InflateRect(TxtRect, -1, -1);
with ACanvas do
begin
Brush.Color := DWTitleAttr.Color;
FillRect(ARect);
case DWTitleAttr.FrameAttr.Style of
fs3DRaised:
Draw3DFrame(ACanvas, ARect, clBtnHighlight, clBtnShadow);
fs3DLowered:
Draw3DFrame(ACanvas, ARect, clBtnShadow, clBtnHighlight);
fsFlat:
begin
Pen.Color := DWTitleAttr.FrameAttr.Color;
Pen.Width := DWTitleAttr.FrameAttr.Width;
if Col = 0 then
begin
MoveTo(ARect.Left, ARect.Top);
LineTo(ARect.Left, ARect.Bottom);
end;
Polyline([Point(ARect.Right - 1, ARect.Top),
Point(ARect.Right - 1, ARect.Bottom - 1),
Point(ARect.Left - 1, ARect.Bottom - 1)]);
end;
fsNone:
begin
Pen.Color := DWTitleAttr.FrameAttr.Color;
Pen.Width := 1;
LineBottom := ARect.Bottom - 1;
for I := 1 to DWTitleAttr.FrameAttr.Width do
begin
MoveTo(ARect.Left, LineBottom);
LineTo(ARect.Right, LineBottom);
Dec(LineBottom);
end;
end;
end;
CheckCurrDOW;
Txt := DWNames.GetDWName(DOWToBorl(CurrDOW));
if (CurrDOW = SplitParentDay) and (SplitDay in DisplayDays) and not IgnoreSplit then
begin
IncDOW(CurrDOW, 1);
CheckCurrDOW;
Txt := Txt + '/' + DWNames.GetDWName(DOWToBorl(CurrDOW));
end;
Font := DWTitleAttr.TxtAttr.Font;
DrawAngleText(ACanvas, TxtRect, TextBounds,
DWTitleAttr.TxtAttr.Rotation,
DWTitleAttr.TxtAttr.AlignH,
DWTitleAttr.TxtAttr.AlignV, Txt);
end;
if Assigned(FOnDrawDWTitle) then
FOnDrawDWTitle(Self, ACanvas, ARect, CurrDOW, Txt);
IncDOW(CurrDOW, 1);
end;
with ACanvas do
begin
Pen.Assign(OldPen);
Brush.Assign(OldBrush);
Font.Assign(OldFont);
OldPen.Free;
OldBrush.Free;
OldFont.Free;
end;
end;
procedure TJvTFWeeks.DWNamesChange(Sender: TObject);
begin
UpdateCellTitles;
Invalidate;
end;
function TJvTFWeeks.GetCellTitleText(Cell: TJvTFGlanceCell): string;
begin
Result := '';
//Result := FormatDateTime('dddd, mmm d', Cell.CellDate);
if Assigned(DWNames) then
begin
if WeekCount = 1 then
Result := DWNames.GetDWName(DayOfWeek(Cell.CellDate)) + ', ';
if DateFormat = '' then
Result := Result + FormatDateTime('mmm d', Cell.CellDate)
else
Result := Result + FormatDateTime(DateFormat, Cell.CellDate);
end
else
Result := FormatDateTime(DateFormat, Cell.CellDate);
end;
function TJvTFWeeks.GetDataTop: Integer;
begin
Result := inherited GetDataTop;
if DWTitleAttr.Visible and (WeekCount > 1) then
Inc(Result, DWTitleAttr.Height);
end;
function TJvTFWeeks.GetDisplayDate: TDate;
begin
Result := StartDate;
end;
function TJvTFWeeks.GetSplitParentDay: TTFDayOfWeek;
begin
Result := SplitDay;
IncDOW(Result, -1);
while not (Result in DisplayDays) and (Result <> SplitDay) do
IncDOW(Result, -1);
end;
procedure TJvTFWeeks.Navigate(AControl: TJvTFControl;
SchedNames: TStringList; Dates: TJvTFDateList);
begin
inherited Navigate(AControl, SchedNames, Dates);
if Dates.Count > 0 then
DisplayDate := Dates[0];
end;
procedure TJvTFWeeks.NextWeek;
begin
DisplayDate := DisplayDate + 7;
end;
procedure TJvTFWeeks.PrevWeek;
begin
DisplayDate := DisplayDate - 7;
end;
procedure TJvTFWeeks.SetDisplayDate(Value: TDate);
begin
StartDate := Value;
UpdateTitle;
end;
procedure TJvTFWeeks.SetDisplayDays(Value: TTFDaysOfWeek);
begin
if Value = [] then
Exit;
if Value <> FDisplayDays then
begin
FDisplayDays := Value;
ReconfigCells;
end;
end;
procedure TJvTFWeeks.SetDisplayOrder(Value: TJvTFDispOrder);
begin
if WeekCount > 1 then
Value := doLeftRight;
if Value <> FDisplayOrder then
begin
FDisplayOrder := Value;
ReconfigCells;
end;
end;
procedure TJvTFWeeks.SetDWNames(Value: TJvTFDWNames);
begin
FDWNames.Assign(Value);
end;
procedure TJvTFWeeks.SetDWTitleAttr(Value: TJvTFGlanceTitle);
begin
FDWTitleAttr.Assign(Value);
end;
procedure TJvTFWeeks.SetIgnoreSplit(Value: Boolean);
begin
if Value <> FIgnoreSplit then
begin
FIgnoreSplit := Value;
ReconfigCells;
end;
end;
procedure TJvTFWeeks.SetSplitDay(Value: TTFDayOfWeek);
begin
if Value <> FSplitDay then
begin
FSplitDay := Value;
ReconfigCells;
end;
end;
procedure TJvTFWeeks.SetStartOfWeek(Value: TTFDayOfWeek);
begin
if not IgnoreSplit and (Value = SplitDay) then
IncDOW(Value, -1);
inherited SetStartOfWeek(Value);
end;
procedure TJvTFWeeks.SetWeekCount(Value: Integer);
begin
Value := Greater(Value, 1);
if Value <> FWeekCount then
begin
DisplayOrder := doLeftRight;
FWeekCount := Value;
ReconfigCells;
end;
end;
procedure TJvTFWeeks.UpdateTitle;
var
NewTitle: string;
begin
NewTitle := Format(RsWeekOf, [FormatDateTime('mmm d, yyyy', OriginDate)]);
if NewTitle <> TitleAttr.Title then
begin
if Assigned(FOnUpdateTitle) then
FOnUpdateTitle(Self, NewTitle);
TitleAttr.Title := NewTitle;
end;
end;
{$IFDEF UNITVERSIONING}
initialization
RegisterUnitVersion(HInstance, UnitVersioning);
finalization
UnregisterUnitVersion(HInstance);
{$ENDIF UNITVERSIONING}
end.
| 25.752918 | 110 | 0.697741 |
f1f65108609fcf51ed120f15709bfde76dd4415e
| 2,308 |
pas
|
Pascal
|
FirstQuarter/informatics/exercices/TP1/13/exercice.pas
|
AndresNakanishi/CAECE-LESYN
|
3537a198b4392b259d12cb8c6214f1f618a7ca50
|
[
"MIT"
] | null | null | null |
FirstQuarter/informatics/exercices/TP1/13/exercice.pas
|
AndresNakanishi/CAECE-LESYN
|
3537a198b4392b259d12cb8c6214f1f618a7ca50
|
[
"MIT"
] | null | null | null |
FirstQuarter/informatics/exercices/TP1/13/exercice.pas
|
AndresNakanishi/CAECE-LESYN
|
3537a198b4392b259d12cb8c6214f1f618a7ca50
|
[
"MIT"
] | null | null | null |
program piecesM;
uses crt;
var
// Pieces => Piezas totales
// Fail1 => Piezas falladas de grado 1
// Fail2 => Piezas falladas de grado 2
// failT => Total de piezas falladas
pieces, fail1, fail2, failT: integer;
// quality => Calidad de la producción
quality: string;
// totalPF => Porcentaje de fallas sobre el total producción
// pFail1 => Porcentaje de fallas de grado 1 sobre el total de piezas falladas
// pFail2 => Porcentaje de fallas de grado 2 sobre el total de piezas falladas
totalPF, pFail1, pFail2: real;
BEGIN
clrscr;
writeln('Ingrese la cantidad de piezas: ');
readln(pieces);
clrscr;
writeln('Ingrese la cantidad de fallas de grado 1: ');
readln(fail1);
clrscr;
writeln('Ingrese la cantidad de fallas de grado 2: ');
readln(fail2);
clrscr;
// Calcular los fallos totales
failT := fail1 + fail2;
// Se calcula el Porcentaje de fallas sobre el total de la producción
// Porcentaje total de fallas = Total de fallas * 100 / Total de las piezas
totalPF := failT * 100 / pieces;
// Se calcula el Porcentaje de fallas de grado 1 sobre el total de piezas falladas
// Fallas de Grado 1 en función de las fallas totales = Total de fallas grado 1 * 100 / Total de fallas
pFail1 := fail1 * 100 / failT;
// Se calcula el Porcentaje de fallas de grado 2 sobre el total de piezas falladas
// Fallas de Grado 2 en función de las fallas totales = Total de fallas grado 2 * 100 / Total de fallas
pFail2 := fail2 * 100 / failT;
if (totalPF < 10) then
begin
quality := 'Muy Buena';
end
else if ((pFail1 < 20) and (totalPF > 10)) then
begin
quality := 'Buena';
end
else if ((pFail1 = pFail2) and (totalPF > 10)) then
begin
quality := 'Regular';
end
else
begin
quality := 'Mala';
end;
writeln('Piezas totales: ', pieces);
writeln('Porcentaje de fallas: ', totalPF:4:2,'%');
writeln('Porcentaje de fallas de grado 1: ',pFail1:4:2,'%');
writeln('Porcentaje de fallas de grado 2: ',pFail2:4:2,'%');
writeln('Calidad de la produccion: ', quality);
readln();
END.
| 36.0625 | 107 | 0.606586 |
f1fdc01bb4f5aabcb9fbdfa7f867db33515e3390
| 6,745 |
pas
|
Pascal
|
crt/0015.pas
|
nickelsworth/swag
|
7c21c0da2291fc249b9dc5cfe121a7672a4ffc08
|
[
"BSD-2-Clause"
] | 11 |
2015-12-12T05:13:15.000Z
|
2020-10-14T13:32:08.000Z
|
crt/0015.pas
|
nickelsworth/swag
|
7c21c0da2291fc249b9dc5cfe121a7672a4ffc08
|
[
"BSD-2-Clause"
] | null | null | null |
crt/0015.pas
|
nickelsworth/swag
|
7c21c0da2291fc249b9dc5cfe121a7672a4ffc08
|
[
"BSD-2-Clause"
] | 8 |
2017-05-05T05:24:01.000Z
|
2021-07-03T20:30:09.000Z
|
{
Well here it is again, its a little rough and some of the Crt.tpu Functions
are left out. This Unit will generate Ansi TextColor and TextBackGrounds.
Becuase of the Ansi screen Writes you can send the Program to the com port
just by using CTTY or GateWay in a bat File before you start your Program.
}
Unit CrtClone;
Interface
Const
{ Foreground and background color Constants }
Black = 0;
Blue = 1;
Green = 2;
Cyan = 3;
Red = 4;
Magenta = 5;
Brown = 6;
LightGray = 7;
{ Foreground color Constants }
DarkGray = 8;
LightBlue = 9;
LightGreen = 10;
LightCyan = 11;
LightRed = 12;
LightMagenta = 13;
Yellow = 14;
White = 15;
{ Add-in For blinking }
Blink = 128;
Var
{ Interface Variables }
CheckBreak : Boolean; { Enable Ctrl-Break }
CheckEOF : Boolean; { Enable Ctrl-Z }
Procedure TextColor(Color : Byte);
Procedure TextBackground(Color : Byte);
Function KeyPressed : Boolean;
Function GetKey : Char;
Function ReadKey : Char;
Function WhereX : Byte;
Function WhereY : Byte;
Procedure NormVideo;
Procedure ClrEol;
Procedure ClrScr;
Procedure GotoXY(X, Y : Byte);
Implementation
Function KeyPressed : Boolean;
{ Replacement For Crt.KeyPressed }
{ ;Detects whether a key is pressed}
{ ;Does nothing With the key}
{ ;Returns True if key is pressed}
{ ;Otherwise, False}
{ ;Key remains in kbd buffer}
Var
IsThere : Byte;
begin
Inline(
$B4/$0B/ { MOV AH,+$0B ;Get input status}
$CD/$21/ { INT $21 ;Call Dos}
$88/$86/>ISTHERE); { MOV >IsThere[BP],AL ;Move into Variable}
KeyPressed := (IsThere = $FF);
end;
Procedure ClrEol; { ANSI replacement For Crt.ClrEol }
begin
Write(#27'[K');
end;
Procedure ClrScr; { ANSI replacement For Crt.ClrScr }
begin
Write(#27'[2J');
end;
Function GetKey : Char; { Additional Function. Not in Crt Unit }
Var
CH : Char;
begin
Inline(
{; Function GetKey : Char}
{; Clears the keyboard buffer then waits Until}
{; a key is struck. if the key is a special, e.g.}
{; Function key, goes back and reads the next}
{; Byte in the keyboard buffer. Thus does}
{; nothing special With Function keys.}
$B4/$0C { MOV AH,$0C ;Set up to clear buffer}
/$B0/$08 { MOV AL,8 ;then to get a Char}
/$CD/$21 {SPCL: INT $21 ;Call Dos}
/$3C/$00 { CMP AL,0 ;if it's a 0 Byte}
/$75/$04 { JNZ CHRDY ;is spec., get second Byte}
/$B4/$08 { MOV AH,8 ;else set up For another}
/$EB/$F6 { JMP SHORT SPCL ;and get it}
/$88/$46/>CH {CHRDY: MOV >CH[BP],AL ;else put into Function return}
);
if CheckBreak and (Ch = #3) then
begin {if CheckBreak is True and it's a ^C}
Inline( {then execute Ctrl_Brk}
$CD/$23);
end;
GetKey := Ch;
end; {Inline Function GetKey}
Function ReadKey : Char; { Replacement For Crt.ReadKey }
Var
chrout : Char;
begin
{ ;Just like ReadKey in Crt Unit}
Inline(
$B4/$07/ { MOV AH,$07 ;Char input w/o echo}
$CD/$21/ { INT $21 ;Call Dos}
$88/$86/>CHROUT); { MOV >chrout[bp],AL ;Put into Variable}
if CheckBreak and (chrout = #3) then {if it's a ^C and CheckBreak True}
{then execute Ctrl_Brk}
Inline($CD/$23); { INT $23}
ReadKey := chrout; {else return Character}
end;
Function WhereX : Byte; { ANSI replacement For Crt.WhereX }
Var { Cursor position report. This is column or }
ch : Char; { X axis report.}
st : String;
st1 : String[2];
x : Byte;
i : Integer;
begin
Write(#27'[6n'); { Ansi String to get X-Y position }
st := ''; { We will only use X here }
ch := #0; { Make sure Character is not 'R' }
While ch <> 'R' do { Return will be }
begin { Esc - [ - Ypos - ; - Xpos - R }
ch := #0;
ch := ReadKey; { Get one }
st := st + ch; { Build String }
end;
St1 := copy(St,6,2); { Pick off subString having number in ASCII}
Val(St1,x,i); { Make it numeric }
WhereX := x; { Return the number }
end;
Function WhereY : Byte; { ANSI replacement For Crt.WhereY }
Var { Cursor position report. This is row or }
ch : Char; { Y axis report.}
st : String;
st1 : String[2];
y : Byte;
i : Integer;
begin
Write(#27'[6n'); { Ansi String to get X-Y position }
st := ''; { We will only use Y here }
ch := #0; { Make sure Character is not 'R' }
While ch <> 'R' do { Return will be }
begin { Esc - [ - Ypos - ; - Xpos - R }
ch := #0;
ch := ReadKey; { Get one }
st := st + ch; { Build String }
end;
St1 := copy(St,3,2); { Pick off subString having number in ASCII}
Val(St1,y,i); { Make it numeric }
WhereY := y; { Return the number }
end;
Procedure GotoXY(x : Byte ; y : Byte); { ANSI replacement For Crt.GoToXY}
begin
if (x < 1) or (y < 1) then
Exit;
if (x > 80) or (y > 25) then
Exit;
Write(#27'[', y, ';', x, 'H');
end;
Procedure TextBackGround(Color : Byte);
begin
Case color of
0 : Write(#27#91#52#48#109);
1 : Write(#27#91#52#52#109);
2 : Write(#27#91#52#50#109);
3 : Write(#27#91#52#54#109);
4 : Write(#27#91#52#49#109);
5 : Write(#27#91#52#53#109);
6 : Write(#27#91#52#51#109);
6 : Write(#27#91#52#55#109);
end;
end;
Procedure TextColor(Color : Byte);
begin
Case color of
0 : Write(#27#91#51#48#109);
1 : Write(#27#91#51#52#109);
2 : Write(#27#91#51#50#109);
3 : Write(#27#91#51#54#109);
4 : Write(#27#91#51#49#109);
5 : Write(#27#91#51#53#109);
6 : Write(#27#91#51#51#109);
7 : Write(#27#91#51#55#109);
8 : Write(#27#91#49#59#51#48#109);
9 : Write(#27#91#49#59#51#52#109);
10 : Write(#27#91#49#59#51#50#109);
11 : Write(#27#91#49#59#51#54#109);
12 : Write(#27#91#49#59#51#49#109);
13 : Write(#27#91#49#59#51#53#109);
14 : Write(#27#91#49#59#51#51#109);
15 : Write(#27#91#49#59#51#55#109);
128 : Write(#27#91#53#109);
end;
end;
Procedure NormVideo;
begin
Write(#27#91#48#109);
end;
end.
| 30.111607 | 77 | 0.528243 |
85dc2a6f9887be45703aa034fecd53b86e55b138
| 1,775 |
dfm
|
Pascal
|
windows/src/ext/jedi/jvcl/tests/restructured/examples/JVCLMegaDemo/jvFormanimationdemo.dfm
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 219 |
2017-06-21T03:37:03.000Z
|
2022-03-27T12:09:28.000Z
|
windows/src/ext/jedi/jvcl/tests/restructured/examples/JVCLMegaDemo/jvFormanimationdemo.dfm
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 4,451 |
2017-05-29T02:52:06.000Z
|
2022-03-31T23:53:23.000Z
|
windows/src/ext/jedi/jvcl/tests/restructured/examples/JVCLMegaDemo/jvFormanimationdemo.dfm
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 72 |
2017-05-26T04:08:37.000Z
|
2022-03-03T10:26:20.000Z
|
object frFormAnimation: TfrFormAnimation
Left = 192
Top = 110
Width = 278
Height = 310
Caption = 'Formanimation'
Color = clHighlight
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Button1: TButton
Left = 24
Top = 16
Width = 225
Height = 25
Caption = 'Appear Ellipse'
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 24
Top = 48
Width = 225
Height = 25
Caption = 'Appear Rectangle'
TabOrder = 1
OnClick = Button2Click
end
object Button3: TButton
Left = 24
Top = 80
Width = 225
Height = 25
Caption = 'Appear Round Rectangle'
TabOrder = 2
OnClick = Button3Click
end
object Button4: TButton
Left = 24
Top = 112
Width = 225
Height = 25
Caption = 'Appear Horizontally'
TabOrder = 3
OnClick = Button4Click
end
object Button5: TButton
Left = 24
Top = 144
Width = 225
Height = 25
Caption = 'Appear Vertically'
TabOrder = 4
OnClick = Button5Click
end
object Button6: TButton
Left = 24
Top = 176
Width = 225
Height = 25
Caption = 'Appear Television'
TabOrder = 5
OnClick = Button6Click
end
object Button7: TButton
Left = 24
Top = 208
Width = 225
Height = 25
Caption = 'Appear To Top'
TabOrder = 6
OnClick = Button7Click
end
object Button8: TButton
Left = 24
Top = 240
Width = 225
Height = 25
Caption = 'Appear To Bottom'
TabOrder = 7
OnClick = Button8Click
end
object JvFormAnimation1: TJvFormAnimation
Left = 256
Top = 16
end
end
| 19.086022 | 43 | 0.619718 |
f16fd3294bf822ac469ec740464664c79dc1ea57
| 842 |
pas
|
Pascal
|
Ekon24FMXArchitecture/01_FMtoGPUcalls/FMtoGPUcalls_mainform.pas
|
marcocantu/DelphiSessions
|
c3fe2ab2eb8619343179b8474ae728c8b0f305db
|
[
"MIT"
] | 44 |
2017-05-30T20:54:06.000Z
|
2022-02-25T16:44:23.000Z
|
Ekon24FMXArchitecture/01_FMtoGPUcalls/FMtoGPUcalls_mainform.pas
|
marcocantu/DelphiSessions
|
c3fe2ab2eb8619343179b8474ae728c8b0f305db
|
[
"MIT"
] | null | null | null |
Ekon24FMXArchitecture/01_FMtoGPUcalls/FMtoGPUcalls_mainform.pas
|
marcocantu/DelphiSessions
|
c3fe2ab2eb8619343179b8474ae728c8b0f305db
|
[
"MIT"
] | 19 |
2017-07-25T10:03:13.000Z
|
2021-10-17T11:40:38.000Z
|
unit FMtoGPUcalls_mainform;
interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Graphics;
type
TFormFMtoGPU = class(TForm)
procedure FormPaint(Sender: TObject; Canvas: TCanvas; const ARect: TRectF);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FormFMtoGPU: TFormFMtoGPU;
implementation
{$R *.fmx}
procedure TFormFMtoGPU.FormPaint(Sender: TObject;
Canvas: TCanvas; const ARect: TRectF);
begin
Canvas.Fill.Color := TAlphaColorRec.Blue;
Canvas.Font.Size := Height div 3;
Canvas.FillText (
ARect, Canvas.ClassName, True, 1,
[], TTextAlign.taCenter);
end;
initialization
// GlobalUseDirect2D := False;
// GlobalUseGPUCanvas := True;
// GlobalUseMetal := True;
end.
| 20.047619 | 81 | 0.720903 |
83f65530067c39c7daa63a6495af4c8fbc7db226
| 14,276 |
pas
|
Pascal
|
unit-tests/src/testcase_orderedset.pas
|
atkins126/libpasc-algorithms
|
6aa8ad291a0b05d8b057be8c50790f6a80b9668c
|
[
"MIT"
] | null | null | null |
unit-tests/src/testcase_orderedset.pas
|
atkins126/libpasc-algorithms
|
6aa8ad291a0b05d8b057be8c50790f6a80b9668c
|
[
"MIT"
] | null | null | null |
unit-tests/src/testcase_orderedset.pas
|
atkins126/libpasc-algorithms
|
6aa8ad291a0b05d8b057be8c50790f6a80b9668c
|
[
"MIT"
] | null | null | null |
unit testcase_orderedset;
{$IFDEF FPC}
{$mode objfpc}{$H+}
{$ENDIF}
interface
uses
Classes, SysUtils, container.orderedset, utils.functor
{$IFDEF FPC}, fpcunit, testregistry{$ELSE}, TestFramework{$ENDIF};
type
TIntOrderedSet = {$IFDEF FPC}specialize{$ENDIF} TOrderedSet<Integer,
TCompareFunctorInteger>;
TStringOrderedSet = {$IFDEF FPC}specialize{$ENDIF} TOrderedSet<String,
TCompareFunctorString>;
TOrderedSetTestCase = class(TTestCase)
public
{$IFNDEF FPC}
procedure AssertTrue (AMessage : String; ACondition : Boolean);
{$ENDIF}
published
procedure Test_IntOrderedSet_CreateNewEmpty;
procedure Test_IntOrderedSet_InsertNewValueInto;
procedure Test_IntOrderedSet_RemoveValueFrom;
procedure Test_IntOrderedSet_IterateValues;
procedure Test_IntOrderedSet_IterateRange;
procedure Test_IntOrderedSet_InsertOneMillionValuesInto;
procedure Test_StringOrderedSet_CreateNewEmpty;
procedure Test_StringOrderedSet_InsertNewValueInto;
procedure Test_StringOrderedSet_RemoveValueFrom;
procedure Test_StringOrderedSet_IterateValues;
procedure Test_StringOrderedSet_IterateRange;
procedure Test_StringOrderedSet_InsertOneMillionValuesInto;
end;
implementation
{$IFNDEF FPC}
procedure TOrderedSetTestCase.AssertTrue(AMessage : String; ACondition :
Boolean);
begin
CheckTrue(ACondition, AMessage);
end;
{$ENDIF}
procedure TOrderedSetTestCase.Test_IntOrderedSet_CreateNewEmpty;
var
orderedset : TIntOrderedSet;
begin
orderedset := TIntOrderedSet.Create(@HashInteger);
AssertTrue('#Test_IntOrderedSet_CreateNewEmpty -> ' +
'OrderedSet must be empty', orderedset.NumEntries = 0);
FreeAndNil(orderedset);
end;
procedure TOrderedSetTestCase.Test_StringOrderedSet_CreateNewEmpty;
var
orderedset : TStringOrderedSet;
begin
orderedset := TStringOrderedSet.Create(@HashString);
AssertTrue('#Test_StringOrderedSet_CreateNewEmpty -> ' +
'OrderedSet must be empty', orderedset.NumEntries = 0);
FreeAndNil(orderedset);
end;
procedure TOrderedSetTestCase.Test_IntOrderedSet_InsertNewValueInto;
var
orderedset : TIntOrderedSet;
begin
orderedset := TIntOrderedSet.Create(@HashInteger);
AssertTrue('#Test_IntOrderedSet_InsertNewValueInto -> ' +
'OrderedSet value 1 not insert', orderedset.Insert(1));
AssertTrue('#Test_IntOrderedSet_InsertNewValueInto -> ' +
'OrderedSet value 5 not insert', orderedset.Insert(5));
AssertTrue('#Test_IntOrderedSet_InsertNewValueInto -> ' +
'OrderedSet value 121 not insert', orderedset.Insert(121));
AssertTrue('#Test_IntOrderedSet_InsertNewValueInto -> ' +
'OrderedSet hasn''t value 1', orderedset.HasValue(1));
AssertTrue('#Test_IntOrderedSet_InsertNewValueInto -> ' +
'OrderedSet hasn''t value 5', orderedset.HasValue(5));
AssertTrue('#Test_IntOrderedSet_InsertNewValueInto -> ' +
'OrderedSet hasn''t value 121', orderedset.HasValue(121));
FreeAndNil(orderedset);
end;
procedure TOrderedSetTestCase.Test_StringOrderedSet_InsertNewValueInto;
var
orderedset : TStringOrderedSet;
begin
orderedset := TStringOrderedSet.Create(@HashString);
AssertTrue('#Test_StringOrderedSet_InsertNewValueInto -> ' +
'OrderedSet value test1 not insert', orderedset.Insert('test1'));
AssertTrue('#Test_StringOrderedSet_InsertNewValueInto -> ' +
'OrderedSet value test5 not insert', orderedset.Insert('test5'));
AssertTrue('#Test_StringOrderedSet_InsertNewValueInto -> ' +
'OrderedSet value test121 not insert', orderedset.Insert('test121'));
AssertTrue('#Test_StringOrderedSet_InsertNewValueInto -> ' +
'OrderedSet hasn''t value test1', orderedset.HasValue('test1'));
AssertTrue('#Test_StringOrderedSet_InsertNewValueInto -> ' +
'OrderedSet hasn''t value test5', orderedset.HasValue('test5'));
AssertTrue('#Test_StringOrderedSet_InsertNewValueInto -> ' +
'OrderedSet hasn''t value test121', orderedset.HasValue('test121'));
FreeAndNil(orderedset);
end;
procedure TOrderedSetTestCase.Test_IntOrderedSet_RemoveValueFrom;
var
orderedset : TIntOrderedSet;
begin
orderedset := TIntOrderedSet.Create(@HashInteger);
AssertTrue('#Test_IntOrderedSet_RemoveValueFrom -> ' +
'OrderedSet value 1 not insert', orderedset.Insert(1));
AssertTrue('#Test_IntOrderedSet_RemoveValueFrom -> ' +
'OrderedSet value 5 not insert', orderedset.Insert(5));
AssertTrue('#Test_IntOrderedSet_RemoveValueFrom -> ' +
'OrderedSet value 121 not insert', orderedset.Insert(121));
AssertTrue('#Test_IntOrderedSet_RemoveValueFrom -> ' +
'OrderedSet hasn''t value 1', orderedset.HasValue(1));
AssertTrue('#Test_IntOrderedSet_RemoveValueFrom -> ' +
'OrderedSet hasn''t value 5', orderedset.HasValue(5));
AssertTrue('#Test_IntOrderedSet_RemoveValueFrom -> ' +
'OrderedSet hasn''t value 121', orderedset.HasValue(121));
AssertTrue('#Test_IntOrderedSet_RemoveValueFrom -> ' +
'OrderedSet value 1 not removed', orderedset.Remove(1));
AssertTrue('#Test_IntOrderedSet_RemoveValueFrom -> ' +
'OrderedSet value 5 not removed', orderedset.Remove(5));
AssertTrue('#Test_IntOrderedSet_RemoveValueFrom -> ' +
'OrderedSet value 121 not removed', orderedset.Remove(121));
AssertTrue('#Test_IntOrderedSet_RemoveValueFrom -> ' +
'OrderedSet must be empty', orderedset.NumEntries = 0);
FreeAndNil(orderedset);
end;
procedure TOrderedSetTestCase.Test_StringOrderedSet_RemoveValueFrom;
var
orderedset : TStringOrderedSet;
begin
orderedset := TStringOrderedSet.Create(@HashString);
AssertTrue('#Test_StringOrderedSet_RemoveValueFrom -> ' +
'OrderedSet value test1 not insert', orderedset.Insert('test1'));
AssertTrue('#Test_StringOrderedSet_RemoveValueFrom -> ' +
'OrderedSet value test5 not insert', orderedset.Insert('test5'));
AssertTrue('#Test_StringOrderedSet_RemoveValueFrom -> ' +
'OrderedSet value test121 not insert', orderedset.Insert('test121'));
AssertTrue('#Test_StringOrderedSet_RemoveValueFrom -> ' +
'OrderedSet hasn''t value test1', orderedset.HasValue('test1'));
AssertTrue('#Test_StringOrderedSet_RemoveValueFrom -> ' +
'OrderedSet hasn''t value test5', orderedset.HasValue('test5'));
AssertTrue('#Test_StringOrderedSet_RemoveValueFrom -> ' +
'OrderedSet hasn''t value test121', orderedset.HasValue('test121'));
AssertTrue('#Test_StringOrderedSet_RemoveValueFrom -> ' +
'OrderedSet value test1 not removed', orderedset.Remove('test1'));
AssertTrue('#Test_StringOrderedSet_RemoveValueFrom -> ' +
'OrderedSet value test5 not removed', orderedset.Remove('test5'));
AssertTrue('#Test_StringOrderedSet_RemoveValueFrom -> ' +
'OrderedSet value test121 not removed', orderedset.Remove('test121'));
AssertTrue('#Test_StringOrderedSet_RemoveValueFrom -> ' +
'OrderedSet must be empty', orderedset.NumEntries = 0);
FreeAndNil(orderedset);
end;
procedure TOrderedSetTestCase.Test_IntOrderedSet_IterateValues;
var
orderedset : TIntOrderedSet;
iterator : TIntOrderedSet.TIterator;
begin
orderedset := TIntOrderedSet.Create(@HashInteger);
AssertTrue('#Test_IntOrderedSet_IterateValues -> ' +
'OrderedSet value 1 not insert', orderedset.Insert(1));
AssertTrue('#Test_IntOrderedSet_IterateValues -> ' +
'OrderedSet value 5 not insert', orderedset.Insert(5));
AssertTrue('#Test_IntOrderedSet_IterateValues -> ' +
'OrderedSet value 121 not insert', orderedset.Insert(121));
iterator := orderedset.FirstEntry;
AssertTrue('#Test_IntOrderedSet_IterateValues -> ' +
'OrderedSet iterator hasn''t value', iterator.HasValue);
AssertTrue('#Test_IntOrderedSet_IterateValues -> ' +
'OrderedSet hasn''t value ' + IntToStr(iterator.Value{$IFDEF USE_OPTIONAL}
.Unwrap{$ENDIF}),
orderedset.HasValue(iterator.Value{$IFDEF USE_OPTIONAL}.Unwrap{$ENDIF}));
iterator := iterator.Next;
AssertTrue('#Test_IntOrderedSet_IterateValues -> ' +
'OrderedSet iterator hasn''t value', iterator.HasValue);
AssertTrue('#Test_IntOrderedSet_IterateValues -> ' +
'OrderedSet hasn''t value ' + IntToStr(iterator.Value{$IFDEF USE_OPTIONAL}
.Unwrap{$ENDIF}),
orderedset.HasValue(iterator.Value{$IFDEF USE_OPTIONAL}.Unwrap{$ENDIF}));
iterator := iterator.Next;
AssertTrue('#Test_IntOrderedSet_IterateValues -> ' +
'OrderedSet iterator hasn''t value', iterator.HasValue);
AssertTrue('#Test_IntOrderedSet_IterateValues -> ' +
'OrderedSet hasn''t value ' + IntToStr(iterator.Value{$IFDEF USE_OPTIONAL}
.Unwrap{$ENDIF}),
orderedset.HasValue(iterator.Value{$IFDEF USE_OPTIONAL}.Unwrap{$ENDIF}));
iterator := iterator.Next;
AssertTrue('#Test_IntOrderedSet_IterateValues -> ' +
'OrderedSet iterator not correct', not iterator.HasValue);
FreeAndNil(orderedset);
end;
procedure TOrderedSetTestCase.Test_StringOrderedSet_IterateValues;
var
orderedset : TStringOrderedSet;
iterator : TStringOrderedSet.TIterator;
begin
orderedset := TStringOrderedSet.Create(@HashString);
AssertTrue('#Test_StringOrderedSet_IterateValues -> ' +
'OrderedSet value test1 not insert', orderedset.Insert('test1'));
AssertTrue('#Test_StringOrderedSet_IterateValues -> ' +
'OrderedSet value test5 not insert', orderedset.Insert('test5'));
AssertTrue('#Test_StringOrderedSet_IterateValues -> ' +
'OrderedSet value test121 not insert', orderedset.Insert('test121'));
iterator := orderedset.FirstEntry;
AssertTrue('#Test_StringOrderedSet_IterateValues -> ' +
'OrderedSet iterator hasn''t value', iterator.HasValue);
AssertTrue('#Test_StringOrderedSet_IterateValues -> ' +
'OrderedSet hasn''t value ' + iterator.Value{$IFDEF USE_OPTIONAL}
.Unwrap{$ENDIF},
orderedset.HasValue(iterator.Value{$IFDEF USE_OPTIONAL}.Unwrap{$ENDIF}));
iterator := iterator.Next;
AssertTrue('#Test_StringOrderedSet_IterateValues -> ' +
'OrderedSet iterator hasn''t value', iterator.HasValue);
AssertTrue('#Test_StringOrderedSet_IterateValues -> ' +
'OrderedSet hasn''t value ' + iterator.Value{$IFDEF USE_OPTIONAL}
.Unwrap{$ENDIF},
orderedset.HasValue(iterator.Value{$IFDEF USE_OPTIONAL}.Unwrap{$ENDIF}));
iterator := iterator.Next;
AssertTrue('#Test_StringOrderedSet_IterateValues -> ' +
'OrderedSet iterator hasn''t value', iterator.HasValue);
AssertTrue('#Test_StringOrderedSet_IterateValues -> ' +
'OrderedSet hasn''t value ' + iterator.Value{$IFDEF USE_OPTIONAL}
.Unwrap{$ENDIF},
orderedset.HasValue(iterator.Value{$IFDEF USE_OPTIONAL}.Unwrap{$ENDIF}));
iterator := iterator.Next;
AssertTrue('#Test_StringOrderedSet_IterateValues -> ' +
'OrderedSet iterator not correct', not iterator.HasValue);
FreeAndNil(orderedset);
end;
procedure TOrderedSetTestCase.Test_IntOrderedSet_IterateRange;
var
orderedset : TIntOrderedSet;
value : {$IFNDEF USE_OPTIONAL}Integer{$ELSE}TIntOrderedSet.TOptionalValue
{$ENDIF};
counter : Cardinal;
begin
orderedset := TIntOrderedSet.Create(@hashInteger);
AssertTrue('#Test_IntOrderedSet_IterateRange -> ' +
'OrderedSet value 1 not insert', orderedset.Insert(1));
AssertTrue('#Test_IntOrderedSet_IterateRange -> ' +
'OrderedSet value 5 not insert', orderedset.Insert(5));
AssertTrue('#Test_IntOrderedSet_IterateRange -> ' +
'OrderedSet value 121 not insert', orderedset.Insert(121));
counter := 0;
for value in orderedset do
begin
AssertTrue('#Test_IntOrderedSet_IterateRange -> ' +
'OrderedSet hasn''t value ' + IntToStr(Value{$IFDEF USE_OPTIONAL}
.Unwrap{$ENDIF}),
orderedset.HasValue(Value{$IFDEF USE_OPTIONAL}.Unwrap{$ENDIF}));
Inc(counter);
end;
AssertTrue('#Test_IntOrderedSet_IterateRange -> ' +
'OrderedSet iterate through not all elements', counter = 3);
FreeAndNil(orderedset);
end;
procedure TOrderedSetTestCase.Test_StringOrderedSet_IterateRange;
var
orderedset : TStringOrderedSet;
value : {$IFNDEF USE_OPTIONAL}String{$ELSE}TStringOrderedSet.TOptionalValue
{$ENDIF};
counter : Cardinal;
begin
orderedset := TStringOrderedSet.Create(@hashString);
AssertTrue('#Test_StringOrderedSet_IterateRange -> ' +
'OrderedSet value test1 not insert', orderedset.Insert('test1'));
AssertTrue('#Test_StringOrderedSet_IterateRange -> ' +
'OrderedSet value test5 not insert', orderedset.Insert('test5'));
AssertTrue('#Test_StringOrderedSet_IterateRange -> ' +
'OrderedSet value test121 not insert', orderedset.Insert('test121'));
counter := 0;
for value in orderedset do
begin
AssertTrue('#Test_StringOrderedSet_IterateRange -> ' +
'OrderedSet hasn''t value ' + Value{$IFDEF USE_OPTIONAL}.Unwrap{$ENDIF},
orderedset.HasValue(Value{$IFDEF USE_OPTIONAL}.Unwrap{$ENDIF}));
Inc(counter);
end;
AssertTrue('#Test_StringOrderedSet_IterateRange -> ' +
'OrderedSet iterate through not all elements', counter = 3);
FreeAndNil(orderedset);
end;
procedure TOrderedSetTestCase.Test_IntOrderedSet_InsertOneMillionValuesInto;
var
orderedset : TIntOrderedSet;
index : Integer;
begin
orderedset := TIntOrderedSet.Create(@HashInteger);
for index := 0 to 1000000 do
begin
AssertTrue('#Test_IntOrderedSet_InsertOneMillionValuesInto -> ' +
'OrderedSet value ' + IntToStr(index) + ' not insert',
orderedset.Insert(index * 10 + 4));
end;
for index := 0 to 1000000 do
begin
AssertTrue('#Test_IntOrderedSet_InsertOneMillionValuesInto -> ' +
'OrderedSet hasn''t value '+ IntToStr(index),
orderedset.HasValue(index * 10 + 4));
end;
FreeAndNil(orderedset);
end;
procedure TOrderedSetTestCase.Test_StringOrderedSet_InsertOneMillionValuesInto;
var
orderedset : TStringOrderedSet;
index : Integer;
begin
orderedset := TStringOrderedSet.Create(@HashString);
for index := 0 to 1000000 do
begin
AssertTrue('#Test_StringOrderedSet_InsertOneMillionValuesInto -> ' +
'OrderedSet value test' + IntToStr(index) + ' not insert',
orderedset.Insert('test' + IntToStr(index * 10 + 4)));
end;
for index := 0 to 1000000 do
begin
AssertTrue('#Test_StringOrderedSet_InsertOneMillionValuesInto -> ' +
'OrderedSet hasn''t value test' + IntToStr(index),
orderedset.HasValue('test' + IntToStr(index * 10 + 4)));
end;
FreeAndNil(orderedset);
end;
initialization
RegisterTest(TOrderedSetTestCase{$IFNDEF FPC}.Suite{$ENDIF});
end.
| 36.605128 | 79 | 0.74944 |
f1c48f62608276400f2b799a3c9ba73361cc5a28
| 2,759 |
dfm
|
Pascal
|
demo/Unitopt_vcl.dfm
|
zekiguven/delphi_jpeg_jls
|
802c0e8601d6118cf84353df7bae3fe44d24608a
|
[
"MIT"
] | 13 |
2018-03-05T11:58:41.000Z
|
2021-06-13T03:02:11.000Z
|
demo/Unitopt_vcl.dfm
|
zekiguven/delphi_jpeg_jls
|
802c0e8601d6118cf84353df7bae3fe44d24608a
|
[
"MIT"
] | 1 |
2018-11-21T08:55:44.000Z
|
2018-11-21T10:54:47.000Z
|
demo/Unitopt_vcl.dfm
|
zekiguven/delphi_jpeg_jls
|
802c0e8601d6118cf84353df7bae3fe44d24608a
|
[
"MIT"
] | null | null | null |
object frmOptions: TfrmOptions
Left = 0
Top = 0
BorderStyle = bsDialog
Caption = 'Options'
ClientHeight = 252
ClientWidth = 409
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object lblT1: TLabel
Left = 230
Top = 103
Width = 12
Height = 13
Caption = 'T1'
end
object lblT2: TLabel
Left = 230
Top = 128
Width = 12
Height = 13
Caption = 'T2'
end
object lblT3: TLabel
Left = 232
Top = 155
Width = 12
Height = 13
Caption = 'T3'
end
object lblReset: TLabel
Left = 8
Top = 154
Width = 28
Height = 13
Caption = 'Reset'
end
object lbl2: TLabel
Left = 8
Top = 99
Width = 53
Height = 13
Caption = 'Error Value'
end
object lbl3: TLabel
Left = 8
Top = 8
Width = 174
Height = 13
Caption = 'Interleaved Mode for Colour Images'
WordWrap = True
end
object edtT3: TEdit
Left = 291
Top = 151
Width = 61
Height = 21
TabOrder = 0
Text = 'edtT3'
end
object edtT2: TEdit
Left = 291
Top = 124
Width = 61
Height = 21
TabOrder = 1
Text = 'edtT2'
end
object edtT1: TEdit
Left = 291
Top = 99
Width = 61
Height = 21
TabOrder = 2
Text = 'edtT1'
end
object chkDefaultT: TCheckBox
Left = 232
Top = 74
Width = 169
Height = 24
Caption = 'Use defaut thresold values'
TabOrder = 3
WordWrap = True
OnClick = chkDefaultTClick
end
object edtRESET: TEdit
Left = 77
Top = 151
Width = 80
Height = 21
TabOrder = 4
Text = 'edtRESET'
end
object chkR: TCheckBox
Left = 8
Top = 129
Width = 149
Height = 17
Caption = 'Use default RESET value'
TabOrder = 5
WordWrap = True
OnClick = chkRClick
end
object edtComp: TEdit
Left = 77
Top = 96
Width = 80
Height = 21
TabOrder = 6
Text = 'edtComp'
end
object chkComp: TCheckBox
Left = 8
Top = 77
Width = 149
Height = 17
Caption = 'Lossless Compression'
TabOrder = 7
OnClick = chkCompClick
end
object cbb1: TComboBox
Left = 8
Top = 31
Width = 233
Height = 21
Style = csDropDownList
ItemIndex = 0
TabOrder = 8
Text = 'Plane Interleaved Mode'
Items.Strings = (
'Plane Interleaved Mode'
'Line Interleaved Mode'
'Sample Interleaved Mode')
end
object bClose: TButton
Left = 316
Top = 209
Width = 75
Height = 25
Caption = 'Close'
ModalResult = 1
TabOrder = 9
end
end
| 17.8 | 50 | 0.584995 |
aa5a37b8451a6823fa547c6f3ce5a0d082db8758
| 36,377 |
dfm
|
Pascal
|
src/fMediaPanelOptions.dfm
|
tonywoode/quickPlay
|
dcff08d7732ac220a2ad8be6854a1261eed3f580
|
[
"BSD-3-Clause"
] | 9 |
2016-10-17T13:43:37.000Z
|
2021-07-03T06:59:26.000Z
|
src/fMediaPanelOptions.dfm
|
tonywoode/quickPlay
|
dcff08d7732ac220a2ad8be6854a1261eed3f580
|
[
"BSD-3-Clause"
] | null | null | null |
src/fMediaPanelOptions.dfm
|
tonywoode/quickPlay
|
dcff08d7732ac220a2ad8be6854a1261eed3f580
|
[
"BSD-3-Clause"
] | 1 |
2017-06-26T19:53:27.000Z
|
2017-06-26T19:53:27.000Z
|
object FrmMediaPanelOptions: TFrmMediaPanelOptions
Left = 0
Top = 0
BorderStyle = bsDialog
Caption = 'Media Panel Options'
ClientHeight = 787
ClientWidth = 1018
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -14
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poMainFormCenter
OnCreate = FormCreate
OnShow = FormShow
PixelsPerInch = 120
TextHeight = 17
object BtnOK: TButton
Left = 807
Top = 750
Width = 98
Height = 33
Caption = '&OK'
ModalResult = 1
TabOrder = 2
OnClick = BtnOKClick
end
object BtnCancel: TButton
Left = 912
Top = 750
Width = 98
Height = 33
Caption = '&Cancel'
ModalResult = 2
TabOrder = 3
end
object PanHeader: TPanel
Left = 0
Top = 0
Width = 1018
Height = 68
Align = alTop
BevelOuter = bvNone
TabOrder = 0
ExplicitWidth = 930
object lblHeader: TLabel
Left = 84
Top = 21
Width = 239
Height = 28
Caption = 'Media Panel Options'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -23
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ParentFont = False
end
object Image1: TImage
Left = 10
Top = 5
Width = 48
Height = 48
AutoSize = True
Picture.Data = {
07544269746D6170361B0000424D361B00000000000036000000280000003000
0000300000000100180000000000001B0000120B0000120B0000000000000000
00000000FF0000FF0000FF0000FF0000FF0000FF808080414141515151808080
B0B0B0D0D0D00000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000
FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF00
00FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF
0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000
FF80808001010101010101010101010101010101010101010131313151515180
8080B0B0B0D0D0D00000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF
0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000
FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF00
00FF0000FF0000FF0000FF0000FF0000FF313131010101010101010101010101
0101010101010101010101010101010101010101010101010101013131315151
51808080A0A0A0C0C0C00000FF0000FF0000FF0000FF0000FF0000FF0000FF00
00FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF
0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000
FF010101010101F8F8F8D9D9D9BBBBBB7E7E7E5E5E5E3F3F3F01010101010101
0101010101010101010101010101010101010101010101010101010101212121
414141808080A0A0A0C0C0C00000FF0000FF0000FF0000FF0000FF0000FF0000
FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF00
00FF0000FF0000FF0000FF0000FFB0B0B00101013F3F3FF8F8F8F8F8F8F8F8F8
F9F9F9F9F9F9F9F9F9F9F9F9EAEAEABCBCBC8D8D8D6E6E6E4040401111110101
0101010101010101010101010101010101010101010101010101010101010121
2121414141808080A0A0A0C0C0C00000FF0000FF0000FF0000FF0000FF0000FF
0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF7171
710101017D7D7DF7F7F7F8F8F8F8F8F8F8F8F8F8F8F8F9F9F9F9F9F9F9F9F9F9
F9F9FAFAFAFAFAFAFAFAFAFAFAFAEBEBEBBCBCBC8D8D8D6F6F6F404040111111
0101010101010101010101010101010101010101010101010101010101010101
01111111414141717171909090C0C0C00000FF0000FF0000FF0000FF0000FF00
00FF0000FF0000FF0000FF0000FF414141010101B9B9B9F7F7F7F7F7F7F7F7F7
F8F8F8F8F8F8F8F8F8F8F8F8F9F9F9F9F9F9F9F9F9F9F9F9FAFAFAFAFAFAFAFA
FAFBFBFBFBFBFBFBFBFBFBFBFBFCFCFCECECECBDBDBD9E9E9E7F7F7F40404021
2121010101010101010101010101010101010101010101010101010101010101
010101111111414141717171A0A0A00000FF0000FF0000FF0000FF0000FF0101
01010101F6F6F6F6F6F6F7F7F7F7F7F7F7F7F7F7F7F7F8F8F8F8F8F8F8F8F8F8
F8F8F9F9F9F9F9F9F9F9F9FAFAFAFAFAFAFAFAFAFAFAFAFBFBFBFBFBFBFBFBFB
FBFBFBFCFCFCFCFCFCFCFCFCFCFCFCFDFDFDFDFDFDBEBEBE9E9E9E8080804141
4121212101010101010101010101010101010101010101010101010101010180
80800000FF0000FF0000FFC0C0C00101012F2F2FF6F6F6F6F6F6F6F6F6F6F6F6
F7F7F7F7F7F7F7F7F7F7F7F7F8F8F8F8F8F8F8F8F8F9F9F9F9F9F9F9F9F9F9F9
F9FAFAFAFAFAFAFAFAFAFAFAFAFBFBFBFBFBFBFBFBFBFBFBFBFCFCFCFCFCFCFC
FCFCFDFDFDFDFDFDFDFDFDFDFDFDFEFEFEFEFEFEFEFEFEBFBFBF9F9F9F818181
5151513131310101010101010101014141410000FF0000FF0000FF9090900101
016C6C6CF5F5F5F5F5F5F6F6F6E9F0E9D0E3D0F6F6F6F7F7F7F7F7F7F7F7F7F8
F8F8F8F8F8F8F8F8F8F8F8F9F9F9F9F9F9F9F9F9F9F9F9FAFAFAFAFAFAFAFAFA
FAFAFAFBFBFBFBFBFBFBFBFBFCFCFCFCFCFCFCFCFCFCFCFCFDFDFDFDFDFDFDFD
FDFDFDFDFEFEFEFEFEFEFEFEFEFFFFFFFFFFFFFFFFFFFFFFFF41414101010161
61610000FF0000FF0000FF616161010101999999F5F5F5F5F5F5F5F5F592C692
2F952F2D932D52A4526AB06A8FC38FB6D6B6D0E3D0F8F8F8F8F8F8F8F8F8F8F8
F8F9F9F9F9F9F9F9F9F9F9F9F9FAFAFAFAFAFAFAFAFAFBFBFBFBFBFBFBFBFBFB
FBFBFCFCFCFCFCFCFCFCFCFCFCFCFDFDFDFDFDFDFDFDFDFEFEFEFEFEFEFEFEFE
FEFEFEFFFFFFFFFFFF010101010101A0A0A00000FF0000FF0000FF3131310101
01C6C6C6F4F4F4F4F4F4F5F5F564B2643299323097302F962F2D932D2B912B2A
8F2A288D28268B264D9F4D73B2738DBF8DC2DBC2DDEADDF9F9F9F9F9F9F9F9F9
FAFAFAFAFAFAFAFAFAFAFAFAFBFBFBFBFBFBFBFBFBFBFBFBFCFCFCFCFCFCFCFC
FCFDFDFDFDFDFDFDFDFDFDFDFDFEFEFEFEFEFEFEFEFEAFAFAF01010101010100
00FF0000FF0000FF0000FF010101010101F3F3F3F4F4F4F4F4F4F4F4F443A543
359D35339B33329A323098302F962F2D942D2B912B2A8F2A288E28278C27258A
2523882321862120832056A05670AE7098C398C1DAC1ECF2ECFAFAFAFAFAFAFA
FAFAFBFBFBFBFBFBFBFBFBFCFCFCFCFCFCFCFCFCFCFCFCFDFDFDFDFDFDFDFDFD
FDFDFDFEFEFE7070700101014141410000FF0000FF0000FFD0D0D00101013E3E
3EF3F3F3F3F3F3F4F4F4D1E5D13AA43A39A139379F37359D35349C34329A3231
98312F962F2D942D2B922B2A902A288E28278C27258A25238823218621208420
1E821E1C811C1B7F1B278427519A517BB17B95C195C1D9C1ECF3ECFBFBFBFBFB
FBFCFCFCFCFCFCFCFCFCFCFCFCFDFDFDFDFDFDFDFDFD21212101010190909000
00FF0000FF0000FFB0B0B00101015C5C5CF3F3F3F3F3F3F3F3F3BBDCBB3EA83E
3CA63C3AA43A39A13937A037369E36349C34329A323198312F962F2D942D2B92
2B2A902A288E28278C27258A252388232186212084201E821E1C811C1B7F1B19
7D19187B181679161477143085304C954C85B685A2C7A2CFE1CFFCFCFCFCFCFC
FCFCFCDDDDDD010101010101D0D0D00000FF0000FF0000FF8080800101017A7A
7AF2F2F2F2F2F2F3F3F39AD09A41AC4140AA403EA83E3CA63C3AA43A39A23937
A037369E36349C34329A323198312F962F2D942D2B922B2A902A288E28278C27
258A252388232286222084201F821F1D811D1B7F1B197D19187B181679161477
1412751211731168A468FBFBFBFCFCFCFCFCFC8E8E8E0101011111110000FF00
00FF0000FF0000FF515151010101B5B5B5F2F2F2F2F2F2F2F2F271C27145B045
43AE4341AC4140AA403EA83E3CA63C3AA43A39A23938A038369E36349C34329A
323198312F962F2D942D2B922B2A902A288E28278C27258A2523882322862220
84201F821F1D811D1B7F1B197D19187B18167916147714A3C8A3FBFBFBFBFBFB
FCFCFC5050500101015151510000FF0000FF0000FF0000FF313131010101D3D3
D3F1F1F1F1F1F1F2F2F2B6D18F48B44847B24745B04543AE4341AC4140AA403E
A83E3CA63C3BA43B39A23938A038369E36349C34329A323198312F962F2E942E
2C922C2A902A298E29278C27258A252388232286222084201F821F1D811D1B7F
1B197D19187B18DEEADEFBFBFBFBFBFBFBFBFB111111010101A0A0A00000FF00
00FF0000FF0000FF010101010101F0F0F0F1F1F1F1F1F1F1F1F1FADCAACED291
55B85048B44847B24745B04543AE4341AC4140AA403EA83E3CA63C3BA43B39A2
3938A038369E36349C34329A323198312F962F2E942E2C922C2A902A298E2927
8C27258A252388232286222084201F821F1D811D378E37FAFAFAFAFAFAFAFAFA
CCCCCC010101010101E0E0E00000FF0000FF0000FFE0E0E00101013D3D3DF0F0
F0F0F0F0F0F0F0F3EBDFFAD9A7FAD9A7D9D3966CBE5C4AB64A48B44847B24745
B04543AE4342AC4240AA403EA83E3DA63D3BA43B51A9475CAA4C369E36349C34
329A323198313096302E942E2C922C2A902A298E29278C27258A252388232286
2220842063A763F9F9F9FAFAFAFAFAFA8D8D8D0101012121210000FF0000FF00
00FF0000FFC0C0C00101014C4C4CEFEFEFF0F0F0F0F0F0F3E7D4F9D8A5F9D8A5
F9D8A5EED69F97C6734BB84B4AB64A48B44847B24745B04543AE4359B14E90BD
6CD6CE91F9D8A5F9D8A5B0C37D38A038369E36349C34329A323198313096302E
942E2C922C2A902A298E29278C27258A252388239AC79AF9F9F9F9F9F9F9F9F9
4F4F4F0101015151510000FF0000FF0000FF0000FF909090010101797979EFEF
EFEFEFEFF0F0F0F4E3C9F9D5A2F9D5A2F9D5A2F9D5A2F9D5A2CECE8D8CC36D77
BF618AC16BABC67BD7CE90F9D5A2F9D5A2F9D5A2F9D5A2F9D5A2F9D5A299BC6E
39A23938A038369E36349C34339A333198313097302E942E2C922C2A902A298E
29278C27C3DDC3F8F8F8F9F9F9F9F9F92020200101019090900000FF0000FF00
00FF0000FF808080010101868686EFEFEFEFEFEFEFEFEFF5DBB8F8D29FF8D29F
F8D29FF8D29FF8D29FF8D29FF8D29FF8D29FF8D29FF8D29FF8D29FF8D29FF8D2
9FF8D29FF8D29FF8D29FF8D29FF8D29F82B6613BA53B39A23938A038369E3634
9C34339A333199313097302E952E2C922C2A902AF8F8F8F8F8F8F8F8F8D9D9D9
010101010101D0D0D00000FF0000FF0000FF0000FF515151010101B3B3B3EEEE
EEEEEEEEEFEFEFF5D8B1F7D19DF7D19DF7D19DF7D19DF7D19DF7D19DF7D19DF7
D19DF7D19DF7D19DF7D19DF7D19DF7D19DF7D19DF7D19DF7D19DF7D19DF7D19D
ECCE9761B0503DA73D3BA53B3AA33A38A038369E36359D35339B333199313097
3061AD61F7F7F7F7F7F7F8F8F89B9B9B0101010101010000FF0000FF0000FF00
00FF0000FF414141010101C1C1C1EEEEEEEEEEEEEEEEEEF6D09FF7CE9AF7CE9A
F7CE9AF7CE9AF7CE9AF7CE9AF7CE9AF7CE9AF7CE9AF7CE9AF7CE9AF7CE9AF7CE
9AF7CE9AF7CE9AF7CE9AF7CE9AF7CE9AF7CE9AE0CA8F4CAD463FA93F3DA73D3B
A53B3AA33A38A138379F37359D35339B3387C287F7F7F7F7F7F7F7F7F76D6D6D
0101014141410000FF0000FF0000FF0000FF0000FF111111010101EDEDEDEDED
EDEDEDEDEEEEEEF6CC97F6CC97F6CC97F6CC97F6CC97F6CC97F6CC97F6CC97F6
CC97F6CC97F6CC97F6CC97F6CC97F6CC97F6CC97F6CC97F6CC97F6CC97F6CC97
F6CC97F6CC97BEC27D42AD4241AB413FA93F3DA73D3BA53B3AA33A38A138379F
37ADD5ADF6F6F6F7F7F7F7F7F73F3F3F0101017171710000FF0000FF0000FF00
00FF0000FF010101010101ECECECEDEDEDEDEDEDEEE9E2F6CA94F6CA94F6CA94
F6CA94F6CA94F6CA94F6CA94F6CA94F6CA94F6CA94F6CA94F6CA94F6CA94F6CA
94F6CA94F6CA94F6CA94F6CA94F6CA94F6CA94F6CA94F6CA949DBD6D44AF4442
AD4241AB413FA93F3DA73D3BA53B3AA33AD2E6D2F6F6F6F6F6F6F6F6F6010101
010101B0B0B00000FF0000FF0000FF0000FF0000FF0101013C3C3CECECECECEC
ECECECECEFE3D6F5C791F5C791F5C791F5C791F5C791F5C791F5C791F5C791F5
C791F5C791F5C791F5C791F5C791F5C791F5C791F5C791F5C791F5C791F5C791
F5C791F5C791F5C791F5C7917EB95E46B14644AF4442AD4241AB413FA93F3DA7
3DF5F5F5F5F5F5F6F6F6C8C8C8010101010101E0E0E00000FF0000FF0000FF00
00FFC0C0C00101013C3C3CEBEBEBECECECECECECEFE0CFF5C58EF5C58EF5C58E
F5C58EE5C8958ADEC07CE2C78ADEC0D6CC9DF5C58EF5C58EF5C58EF5C58EF5C5
8EF5C58EF5C58EF5C58EF5C58EF5C58EF5C58EF5C58EF5C58EF5C58EEAC48A69
B85648B34846B14644AF4442AD4263B963F5F5F5F5F5F5F5F5F5999999010101
1111110000FF0000FF0000FF0000FF0000FFC0C0C0010101686868EBEBEBEBEB
EBECECECF0D7BCF4C38CF4C38CF4C38CE5C7932FF4EA01FFFF01FFFF01FFFF10
FBF8C6CEA2F4C38CF4C38CF4C38CF4C38CF4C38CF4C38CF4C38CF4C38CF4C38C
F4C38CF4C38CF4C38CF4C38CF4C38CE9C2886AB95749B54952B44C86B760D3D1
A5F4F4F4F4F4F4F5F5F56C6C6C0101014141410000FF0000FF0000FF0000FF00
00FFA0A0A0010101767676EBEBEBEBEBEBEBEBEBEFD6BAF3C089F3C089F3C089
7BE0C401FFFF01FFFF01FFFF01FFFF01FFFF4DEBDAF3C089F3C089F3C089F3C0
89F3C089F3C089F3C089F3C089F3C089F3C089F3C089F3C089F3C089F3C089F3
C089F3C089F3C089F3C089F3C089F3DABEF4F4F4F4F4F4F4F4F43E3E3E010101
7171710000FF0000FF0000FF0000FF0000FF808080010101767676EAEAEAEAEA
EAEBEBEBF0D1B2F3BE86F3BE86F3BE863EEFE101FFFF01FFFF01FFFF01FFFF01
FFFF01FFFFF3BE86F3BE86F3BE86F3BE86F3BE86F3BE86F3BE86F3BE86F3BE86
F3BE86F3BE86F3BE86F3BE86F3BE86F3BE86F3BE86F3BE86F3BE86F3BE86F3E6
D8F3F3F3F3F3F3F4F4F4010101010101A0A0A00000FF0000FF0000FF0000FF00
00FF808080010101A0A0A0EAEAEAEAEAEAEAEAEAF0C79DF2BC84F2BC84F2BC84
5CE6D101FFFF01FFFF01FFFF01FFFF01FFFF1FF7F0F2BC84F2BC84F2BC84F2BC
84F2BC84F2BC84F2BC84F2BC84F2BC84F2BC84F2BC84F2BC84F2BC84F2BC84F2
BC84F2BC84F2BC84F2BC84F2BC84F2ECE5F3F3F3F3F3F3D5D5D5010101010101
C0C0C00000FF0000FF0000FF0000FF0000FF717171010101AFAFAFE9E9E9E9E9
E9EAEAEAF0C59BF2B981F2B981F2B981B5CAA001FFFF01FFFF01FFFF01FFFF01
FFFF7ADCC0F2B981F2B981F2B981F2B981F2B981F2B981F2B981F2B981F2B981
F2B981F2B981F2B981F2B981F2B981F2B981F2B981F2B981F2B981F2B981F2F2
F2F2F2F2F3F3F3B6B6B60101010101010000FF0000FF0000FF0000FF0000FF00
00FF414141010101AEAEAEE9E9E9E9E9E9E9E9E9EFC399F1B77FF1B77FF1B77F
F1B77F97D2AE1FF6EF01FFFF10FAF77ADBBEF1B77FF1B77FF1B77FF1B77FF1B7
7FF1B77FF1B77FF1B77FF1B77FF1B77FF1B77FF1B77FF1B77FF1B77FF1B77FF1
B77FF1B77FF1B77FF1B77FF1C294F2F2F2F2F2F2F2F2F27A7A7A010101212121
0000FF0000FF0000FF0000FF0000FF0000FF414141010101BDBDBDE8E8E8E9E9
E9E9E9E9F0BB89F1B57DF1B57DF1B57DF1B57DF1B57DF1B57DF1B57DF1B57DF1
B57DF1B57DF1B57DF1B57DF1B57DF1B57DF1B57DF1B57DF1B57DF1B57DF1B57D
F1B57DF1B57DF1B57DF1B57DF1B57DF1B57DF1B57DF1B57DF1B57DF1C499F1F1
F1F1F1F1F2F2F25C5C5C0101014141410000FF0000FF0000FF0000FF0000FF00
00FF414141010101E7E7E7E8E8E8E8E8E8E8E8E8F0B27AF0B27AF0B27AF0B27A
F0B27AF0B27AF0B27AF0B27AF0B27AF0B27AF0B27AF0B27AF0B27AF0B27AF0B2
7AF0B27AF0B27AF0B27AF0B27AF0B27AF0B27AF0B27AF0B27AF0B27AF0B27AF0
B27AF0B27AF0B27AF0B27AF0D1B5F1F1F1F1F1F1F1F1F13D3D3D010101717171
0000FF0000FF0000FF0000FF0000FF0000FF414141010101E7E7E7E7E7E7E8E8
E8E8E8E8EBD7C5ECCCB0EDC29AEEBB8CF0B077F0B077F0B077F0B077F0B077F0
B077F0B077F0B077F0B077F0B077F0B077F0B077F0B077F0B077F0B077F0B077
F0B077F0B077F0B077F0B077F0B077F0B077F0B077F0B077F0B077F0D4BBF0F0
F0F0F0F0F1F1F11010100101018080800000FF0000FF0000FF0000FF0000FF00
00FF212121010101E6E6E6E7E7E7E7E7E7E7E7E7E8E8E8E8E8E8E8E8E8E8E8E8
E9E9E9EADED3EBD7C5ECCCAFEDC199EEB98AEFAE75EFAE75EFAE75EFAE75EFAE
75EFAE75EFAE75EFAE75EFAE75EFAE75EFAE75EFAE75EFAE75EFAE75EFAE75EF
AE75EFAE75EFAE75EFAE75EFDFD0F0F0F0F0F0F0F0F0F0010101010101C0C0C0
0000FF0000FF0000FF0000FF0000FF0000FF010101010101E5E5E5E5E5E5E7E7
E7E7E7E7E7E7E7E7E7E7E8E8E8E8E8E8E8E8E8E9E9E9E9E9E9E9E9E9E9E9E9EA
EAEAEAEAEAEBDED4EBD7C4ECCBAEEDBF97EDB788EEAB72EEAB72EEAB72EEAB72
EEAB72EEAB72EEAB72EEAB72EEAB72EEAB72EEAB72EEAB72EEAB72EFE2D7EFEF
EFEFEFEFB4B4B4010101010101D0D0D00000FF0000FF0000FF0000FF0000FF00
00FF3131310101017474749D9D9DBABABAE6E6E6E7E7E7E7E7E7E7E7E7E8E8E8
E8E8E8E8E8E8E8E8E8E9E9E9E9E9E9E9E9E9E9E9E9EAEAEAEAEAEAEAEAEAEAEA
EAEBEBEBEBEBEBECDFD4ECD7C4EDCBAEEDBE96EEB686EEA96FEEA96FEEA96FEE
A96FEEA96FEEA96FEEA96FEEEEEEEFEFEFEFEFEFB3B3B30101010101010000FF
0000FF0000FF0000FF0000FF0000FF0000FFD0D0D02121210101010101010101
010101012C2C2C4949497575759F9F9FBCBCBCE8E8E8E8E8E8E8E8E8E8E8E8E9
E9E9E9E9E9E9E9E9E9E9E9EAEAEAEAEAEAEAEAEAEBEBEBEBEBEBEBEBEBEBEBEB
ECECECECECECECECECECDFD4EDD7C5EDCAADEDBD94EDB484EDA76DEEEEEEEEEE
EEEFEFEF7979790101010101010000FF0000FF0000FF0000FF0000FF0000FF00
00FF0000FF0000FF0000FFC0C0C0A0A0A0808080414141212121010101010101
0101010101012D2D2D4A4A4A757575A0A0A0BDBDBDE9E9E9E9E9E9E9E9E9EAEA
EAEAEAEAEAEAEAEAEAEAEBEBEBEBEBEBEBEBEBEBEBEBECECECECECECECECECEC
ECECEDEDEDEDEDEDEDEDEDEEEEEEEEEEEEEEEEEE7878780101014141410000FF
0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000
FF0000FF0000FF0000FF0000FFC0C0C0A0A0A080808041414121212101010101
01010101010101012D2D2D4A4A4A767676A0A0A0AFAFAFEAEAEAEAEAEAEAEAEA
EBEBEBEBEBEBEBEBEBEBEBEBECECECECECECECECECEDEDEDEDEDEDEDEDEDEDED
EDEEEEEE4B4B4B0101014141410000FF0000FF0000FF0000FF0000FF0000FF00
00FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF
0000FF0000FF0000FF0000FF0000FFC0C0C0A0A0A08080804141412121210101
010101010101010101011E1E1E3C3C3C767676939393B0B0B0EBEBEBEBEBEBEC
ECECECECECECECECECECECEDEDEDEDEDEDEDEDED3C3C3C0101017171710000FF
0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000
FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF00
00FF0000FF0000FF0000FF0000FF0000FFD0D0D0B0B0B0808080515151313131
0101010101010101010101011E1E1E3C3C3C777777949494B1B1B1ECECECECEC
ECEDEDED2D2D2D0101018080800000FF0000FF0000FF0000FF0000FF0000FF00
00FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF
0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000
FF0000FF0000FF0000FF0000FF0000FF0000FFD0D0D0B0B0B080808051515131
31310101010101010101010101011F1F1F3C3C3C010101010101A0A0A00000FF
0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000
FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF00
00FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF0000FF
0000FF0000FF0000FF0000FF0000FF0000FF0000FFD0D0D0B0B0B08080805151
513131311111117171710000FF0000FF0000FF0000FF0000FF0000FF0000FF00
00FF}
Transparent = True
end
end
object pgMediaOptions: TPageControl
Left = 0
Top = 68
Width = 1018
Height = 676
ActivePage = TabGeneral
Align = alTop
TabOrder = 1
ExplicitWidth = 930
object TabGeneral: TTabSheet
Caption = 'Media Options'
object ChkEmuTab: TCheckBox
Left = 565
Top = 167
Width = 388
Height = 23
Caption = 'Add Tab for emulators with media settings'
Checked = True
State = cbChecked
TabOrder = 0
end
object GrpFolderImg: TRadioGroup
Left = 565
Top = 21
Width = 336
Height = 137
Caption = 'Default Folder Image'
ItemIndex = 0
Items.Strings = (
'QuickPlay Logo'
'System Image Based On ROMs')
TabOrder = 1
end
object GrpAutoMove: TGroupBox
Left = 31
Top = 21
Width = 336
Height = 169
Caption = 'Auto Move Through Tabs'
TabOrder = 2
object TLabel
Left = 42
Top = 99
Width = 80
Height = 17
Caption = 'Time Per Tab'
end
object TLabel
Left = 211
Top = 99
Width = 52
Height = 17
Caption = 'Seconds'
end
object TxtTimePerTab: TSpinEdit
Left = 146
Top = 93
Width = 54
Height = 27
MaxValue = 0
MinValue = 0
TabOrder = 0
Value = 10
end
object ChkAutoMoveThroughTabs: TCheckBox
Left = 10
Top = 42
Width = 305
Height = 22
Caption = 'Automatically move through tabs'
Checked = True
State = cbChecked
TabOrder = 1
end
end
end
object TabPaths: TTabSheet
Caption = 'Path Configuration'
ImageIndex = 1
ExplicitWidth = 922
object lblSystems: TLabel
Left = 0
Top = 21
Width = 63
Height = 18
Caption = 'Systems'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ParentFont = False
end
object lblTabs: TLabel
Left = 290
Top = 21
Width = 35
Height = 18
Caption = 'Tabs'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -15
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ParentFont = False
end
object VTSystems: TVirtualStringTree
Left = 0
Top = 42
Width = 281
Height = 587
DefaultNodeHeight = 20
Header.AutoSizeIndex = 0
Header.DefaultHeight = 17
Header.Font.Charset = DEFAULT_CHARSET
Header.Font.Color = clWindowText
Header.Font.Height = -11
Header.Font.Name = 'Tahoma'
Header.Font.Style = []
Header.MainColumn = -1
Header.Options = [hoColumnResize, hoDrag]
Images = MainFrm.IconList
TabOrder = 0
TreeOptions.AutoOptions = [toDisableAutoscrollOnFocus]
TreeOptions.MiscOptions = [toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning]
TreeOptions.PaintOptions = [toThemeAware, toUseBlendedImages]
TreeOptions.SelectionOptions = [toExtendedFocus, toFullRowSelect]
OnFocusChanging = VTSystemsFocusChanging
OnGetText = VTSystemsGetText
OnGetImageIndex = VTSystemsGetImageIndex
Columns = <>
end
object VTTabs: TVirtualStringTree
Left = 287
Top = 42
Width = 187
Height = 587
DefaultNodeHeight = 24
DragMode = dmAutomatic
DragOperations = [doMove]
DragType = dtVCL
Header.AutoSizeIndex = 0
Header.DefaultHeight = 17
Header.Font.Charset = DEFAULT_CHARSET
Header.Font.Color = clWindowText
Header.Font.Height = -11
Header.Font.Name = 'Tahoma'
Header.Font.Style = []
Header.MainColumn = -1
Header.Options = [hoColumnResize, hoDrag]
TabOrder = 1
TreeOptions.AutoOptions = [toDisableAutoscrollOnFocus]
TreeOptions.MiscOptions = [toCheckSupport, toFullRepaintOnResize, toInitOnSave, toToggleOnDblClick, toWheelPanning, toFullRowDrag]
TreeOptions.PaintOptions = [toHideFocusRect, toShowDropmark, toThemeAware, toUseBlendedImages]
OnChecked = VTTabsChecked
OnCompareNodes = VTTabsCompareNodes
OnDragOver = VTTabsDragOver
OnDragDrop = VTTabsDragDrop
OnFocusChanging = VTTabsFocusChanging
OnGetText = VTTabsGetText
OnInitNode = VTTabsInitNode
Columns = <>
end
object pgConfig: TPageControl
Left = 480
Top = 42
Width = 527
Height = 584
ActivePage = TabTabConfig
TabOrder = 4
object TabSystemConfig: TTabSheet
Caption = 'TabSystemConfig'
OnExit = TabSystemConfigExit
ExplicitWidth = 537
object lblSysImage: TLabel
Left = 10
Top = 52
Width = 88
Height = 17
Caption = 'System Image'
end
object lblSystemConfigHeader: TLabel
Left = 10
Top = 0
Width = 240
Height = 27
Caption = 'System Configuration'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -22
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ParentFont = False
end
object TxtSysImage: TJvFilenameEdit
Left = 128
Top = 50
Width = 305
Height = 25
AddQuotes = False
DialogKind = dkOpenPicture
DialogOptions = [ofHideReadOnly, ofPathMustExist, ofFileMustExist]
ButtonWidth = 27
TabOrder = 0
end
object ChkShowAddInfo: TCheckBox
Left = 10
Top = 94
Width = 410
Height = 22
Caption = 'Show Additional Information'
TabOrder = 1
end
object MemoSysInfo: TMemo
Left = 31
Top = 136
Width = 483
Height = 388
ScrollBars = ssBoth
TabOrder = 2
end
end
object TabTabConfig: TTabSheet
Caption = 'TabTabConfig'
ImageIndex = 1
OnExit = TabTabConfigExit
ExplicitWidth = 537
object TLabel
Left = 44
Top = 21
Width = 58
Height = 17
Caption = 'Tab Type'
end
object TLabel
Left = 10
Top = 61
Width = 88
Height = 17
Caption = 'Search Criteria'
end
object pgTabOptions: TPageControl
Left = 7
Top = 355
Width = 503
Height = 194
ActivePage = TabTextConfig
TabOrder = 4
object TabThumbnails: TTabSheet
Caption = 'Thumbnail'
object lblThumbHeight: TLabel
Left = 51
Top = 18
Width = 39
Height = 17
Caption = 'Height'
end
object lblThumbWidth: TLabel
Left = 55
Top = 52
Width = 37
Height = 17
Caption = 'Width'
end
object lblThbHorzGap: TLabel
Left = 0
Top = 93
Width = 88
Height = 17
Caption = 'Horizontal Gap'
end
object lblThbVertGap: TLabel
Left = 17
Top = 128
Width = 71
Height = 17
Caption = 'Vertical Gap'
end
object RadThumbBottom: TRadioButton
Left = 230
Top = 12
Width = 221
Height = 22
Caption = 'Caption on Bottom'
Checked = True
TabOrder = 4
TabStop = True
end
object RadThumbOnTop: TRadioButton
Left = 230
Top = 43
Width = 242
Height = 22
Caption = 'Caption On Top'
TabOrder = 5
end
object ChkThumbCaption: TCheckBox
Left = 230
Top = 75
Width = 259
Height = 22
Caption = 'Show Caption (Filename)'
Checked = True
State = cbChecked
TabOrder = 6
end
object TxtThumbVertGap: TSpinEdit
Left = 115
Top = 122
Width = 75
Height = 27
MaxValue = 0
MinValue = 0
TabOrder = 3
Value = 4
end
object TxtThumbHorzGap: TSpinEdit
Left = 115
Top = 86
Width = 75
Height = 27
MaxValue = 0
MinValue = 0
TabOrder = 2
Value = 4
end
object TxtThumbWidth: TSpinEdit
Left = 115
Top = 46
Width = 75
Height = 27
MaxValue = 0
MinValue = 0
TabOrder = 1
Value = 120
end
object TxtThumbHeight: TSpinEdit
Left = 115
Top = 12
Width = 75
Height = 27
MaxValue = 0
MinValue = 0
TabOrder = 0
Value = 120
end
end
object TabImages: TTabSheet
Caption = 'Images'
ImageIndex = 1
object lblTimeOut: TLabel
Left = 10
Top = 48
Width = 84
Height = 17
Caption = 'Time Per Slide'
end
object lblSeconds: TLabel
Left = 184
Top = 48
Width = 52
Height = 17
Caption = 'Seconds'
end
object ChkEnableSlideshow: TCheckBox
Left = 10
Top = 10
Width = 357
Height = 23
Caption = 'Enable SlideShow'
Checked = True
State = cbChecked
TabOrder = 0
end
object ChkShowControlBar: TCheckBox
Left = 10
Top = 94
Width = 378
Height = 22
Caption = 'Show Control Bar'
Checked = True
State = cbChecked
TabOrder = 2
end
object TxtImageSlideTime: TSpinEdit
Left = 122
Top = 42
Width = 53
Height = 27
MaxValue = 0
MinValue = 0
TabOrder = 1
Value = 5
end
end
object TabTextConfig: TTabSheet
Caption = 'Text'
ImageIndex = 2
object ShpFontColour: TShape
Left = 63
Top = 61
Width = 64
Height = 23
Brush.Color = clBlack
end
object TLabel
Left = 10
Top = 10
Width = 35
Height = 17
Caption = 'Name'
end
object TLabel
Left = 10
Top = 34
Width = 23
Height = 17
Caption = 'Size'
end
object TLabel
Left = 10
Top = 64
Width = 40
Height = 17
Caption = 'Colour'
end
object TLabel
Left = 10
Top = 94
Width = 30
Height = 17
Caption = 'Style'
end
object lblFontName: TLabel
Left = 63
Top = 10
Width = 50
Height = 17
Caption = 'Tahoma'
end
object lblFontSize: TLabel
Left = 63
Top = 34
Width = 8
Height = 17
Caption = '8'
end
object lblFontStyle: TLabel
Left = 63
Top = 94
Width = 4
Height = 17
end
object BtnFontChange: TButton
Left = 370
Top = 115
Width = 116
Height = 33
Caption = 'Change Font'
TabOrder = 0
OnClick = BtnFontChangeClick
end
end
end
object GrpPaths: TGroupBox
Left = 11
Top = 120
Width = 502
Height = 229
Caption = 'Media Paths'
TabOrder = 3
object LstPaths: TListBox
Left = 8
Top = 27
Width = 486
Height = 155
TabStop = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = 'Tahoma'
Font.Style = []
ItemHeight = 14
ParentFont = False
TabOrder = 0
end
object BtnAddDir: TJvImgBtn
Left = 376
Top = 188
Width = 35
Height = 33
TabOrder = 1
OnClick = BtnAddDirClick
HotTrackFont.Charset = DEFAULT_CHARSET
HotTrackFont.Color = clWindowText
HotTrackFont.Height = -14
HotTrackFont.Name = 'Tahoma'
HotTrackFont.Style = []
Images = MainFrm.ImageList1
ImageIndex = 0
end
object BtnAddCompress: TJvImgBtn
Left = 417
Top = 188
Width = 35
Height = 32
TabOrder = 2
OnClick = BtnAddCompressClick
HotTrackFont.Charset = DEFAULT_CHARSET
HotTrackFont.Color = clWindowText
HotTrackFont.Height = -14
HotTrackFont.Name = 'Tahoma'
HotTrackFont.Style = []
Images = MainFrm.ImageList1
ImageIndex = 28
end
object BtnDelMedia: TJvImgBtn
Left = 458
Top = 188
Width = 35
Height = 33
TabOrder = 3
OnClick = BtnDelMediaClick
HotTrackFont.Charset = DEFAULT_CHARSET
HotTrackFont.Color = clWindowText
HotTrackFont.Height = -14
HotTrackFont.Name = 'Tahoma'
HotTrackFont.Style = []
Images = MainFrm.ImageList1
ImageIndex = 3
end
object ChkSearchROMdir: TCheckBox
Left = 8
Top = 196
Width = 309
Height = 22
Hint =
'If enabled the directory which contains the ROM will be searched' +
#13#10'for media. If disabled this directory won'#39't be searched unles' +
's it is'#13#10'configured by the user.'
Caption = 'Include ROM directory in search'
ParentShowHint = False
ShowHint = True
TabOrder = 4
end
end
object ChkCloneSearch: TCheckBox
Left = 127
Top = 98
Width = 376
Height = 22
Hint =
'If enabled media searchs for MAME roms will use the parent ROM (' +
'only applicable if you scanned ROMs using the '#39'scan merged roms'#39 +
')'
Caption = 'For MAME clones use Parent ROM for scan'
ParentShowHint = False
ShowHint = True
TabOrder = 2
end
object CmbTabType: TComboBox
Left = 124
Top = 16
Width = 190
Height = 25
Style = csDropDownList
ItemHeight = 17
ItemIndex = 0
TabOrder = 0
Text = 'Images/Slideshow'
Items.Strings = (
'Images/Slideshow'
'Game info dat file'
'Game history dat file'
'Thumbnails'
'System'
'Rom Info'
'Mame Command dat file'
'Mame Game init file'
'Mame Mess info file'
'Mame Story file'
'Mame Mess sysInfo file')
end
object CmbSearchMatch: TComboBox
Left = 127
Top = 56
Width = 305
Height = 25
Style = csDropDownList
ItemHeight = 17
ItemIndex = 0
TabOrder = 1
Text = 'Filename must match ROM filename'
Items.Strings = (
'Filename must match ROM filename'
'Filename must start with ROM filename'
'Filename must include ROM filename'
'All Files From Directory')
end
end
end
object btnDeleteDefaultTab: TJvImgBtn
Left = 368
Top = 9
Width = 33
Height = 33
TabOrder = 3
OnClick = btnDeleteDefaultTabClick
HotTrackFont.Charset = DEFAULT_CHARSET
HotTrackFont.Color = clWindowText
HotTrackFont.Height = -14
HotTrackFont.Name = 'Tahoma'
HotTrackFont.Style = []
Images = MainFrm.ImageList1
ImageIndex = 3
end
object btnAddDefaultTab: TJvImgBtn
Left = 334
Top = 9
Width = 33
Height = 33
TabOrder = 2
OnClick = btnAddDefaultTabClick
HotTrackFont.Charset = DEFAULT_CHARSET
HotTrackFont.Color = clWindowText
HotTrackFont.Height = -14
HotTrackFont.Name = 'Tahoma'
HotTrackFont.Style = []
Images = MainFrm.ImageList1
ImageIndex = 22
end
end
end
object jvBrowse: TJvBrowseForFolderDialog
Left = 432
Top = 8
end
end
| 39.199353 | 138 | 0.645793 |
83c98954240cbcc5025c8b1bfc28b312f8eb2b78
| 101,333 |
pas
|
Pascal
|
runmode.pas
|
Dankage102/Run-Mode
|
a85c6bc3eed8ca84ffa34fd18fc24c626f3687f2
|
[
"MIT"
] | 5 |
2018-08-18T04:14:32.000Z
|
2021-08-20T20:23:54.000Z
|
runmode.pas
|
Dankage102/Run-Mode
|
a85c6bc3eed8ca84ffa34fd18fc24c626f3687f2
|
[
"MIT"
] | null | null | null |
runmode.pas
|
Dankage102/Run-Mode
|
a85c6bc3eed8ca84ffa34fd18fc24c626f3687f2
|
[
"MIT"
] | null | null | null |
//Run Mode v3(1.7.1.1) by Savage
uses database;
const
DB_ID = 1;
DB_NAME = 'runmode.db';
COLOR_1 = $6495ed;
COLOR_2 = $F0E68C;
PATH_TO_FILES = '/home/shared_data/';
USED_IP_TIME = 8;//hours
type tCheckPoint = Record
X, Y: Single;
end;
type tRecord = Record
X, Y: Single;
end;
var
_CheckPoint: array of tCheckPoint;
_Laps: Byte;
_ReplayTime, _WorldTextLoop, _ReplayTime2, _WorldTextLoop2: Integer;
_LapsPassed, _CheckPointPassed: array[1..32] of Byte;
_Timer: array[1..32] of TDateTime;
{$IFDEF RUN_MODE_DEBUG}
_PingRespawn: array[1..32] of Integer;
{$ENDIF}
_ShowTimer, _RKill, _LoggedIn, _JustDied, _FlightMode, _GodMode: array[1..32] of Boolean;
_EliteList, _UsedIP: TStringList;
_Record: array[1..32] of array of tRecord;
_Replay, _Replay2: array of tRecord;
_ScoreId, _ReplayInfo, _ReplayInfo2: String;
_EditMode: Boolean;
_LastPosX, _LastPosY: array[1..32] of Single;
function EscapeApostrophe(Source: String): String;
begin
Result := ReplaceRegExpr('''', Source, '''''', FALSE);
end;
function GetPiece(Source, Delimiter: String; Number: Byte): String;
var
TempStrL: TStringList;
begin
Try
TempStrL := File.CreateStringList;
SplitRegExpr(Delimiter, Source, TempStrL);
Result := TempStrL[Number];
Except
Result := '';
Finally
TempStrL.Free;
end;
end;
{$IFDEF CLIMB}
procedure RecountAllStats;
var
PosCounter: Integer;
MapName, NewMapName: String;
begin
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Gold = 0, Silver = 0, Bronze = 0, NoMedal = 0, Points = 0;') then
WriteLn('RunModeError14: '+DB_Error);
if Not DB_Query(DB_ID, 'SELECT Account, Map FROM Scores ORDER BY Map, Time, Date;') then
WriteLn('RunModeError15: '+DB_Error)
else begin
DB_Update(DB_ID, 'BEGIN TRANSACTION;');
While DB_NextRow(DB_ID) Do begin
NewMapName := DB_GetString(DB_ID, 1);
if Game.MapsList.GetMapIdByName(NewMapName) = -1 then//Do not count maps that are not in maplist
Continue;
if MapName <> NewMapName then begin
MapName := NewMapName;
PosCounter := 0;
end;
Inc(PosCounter, 1);
if PosCounter = 1 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Gold = Gold + 1, Points = Points + 12 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError16: '+DB_Error);
if PosCounter = 2 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Silver = Silver + 1, Points = Points + 6 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError17: '+DB_Error);
if PosCounter = 3 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Bronze = Bronze + 1, Points = Points + 3 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError18: '+DB_Error);
if PosCounter > 3 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET NoMedal = NoMedal + 1, Points = Points + 1 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError19: '+DB_Error);
end;
DB_Update(DB_ID, 'COMMIT;');
end;
DB_FinishQuery(DB_ID);
end;
{$ELSE}
procedure RecountAllStats;
var
PosCounter: Integer;
MapName, NewMapName: String;
begin
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Gold = 0, Silver = 0, Bronze = 0, NoMedal = 0, Points = 0;') then
WriteLn('RunModeError1: '+DB_Error);
if Not DB_Query(DB_ID, 'SELECT Account, Map FROM Scores ORDER BY Map, Time, Date;') then
WriteLn('RunModeError2: '+DB_Error)
else begin
DB_Update(DB_ID, 'BEGIN TRANSACTION;');
While DB_NextRow(DB_ID) Do begin
NewMapName := DB_GetString(DB_ID, 1);
if Game.MapsList.GetMapIdByName(NewMapName) = -1 then//Do not count maps that are not in maplist
Continue;
if MapName <> NewMapName then begin
MapName := NewMapName;
PosCounter := 0;
end;
Inc(PosCounter, 1);
if PosCounter = 1 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Gold = Gold + 1, Points = Points + 25 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError3: '+DB_Error);
if PosCounter = 2 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Silver = Silver + 1, Points = Points + 20 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError4: '+DB_Error);
if PosCounter = 3 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Bronze = Bronze + 1, Points = Points + 15 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError5: '+DB_Error);
if PosCounter = 4 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET NoMedal = NoMedal + 1, Points = Points + 10 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError6: '+DB_Error);
if PosCounter = 5 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET NoMedal = NoMedal + 1, Points = Points + 7 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError7: '+DB_Error);
if PosCounter = 6 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET NoMedal = NoMedal + 1, Points = Points + 5 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError8: '+DB_Error);
if PosCounter = 7 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET NoMedal = NoMedal + 1, Points = Points + 4 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError9: '+DB_Error);
if PosCounter = 8 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET NoMedal = NoMedal + 1, Points = Points + 3 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError10: '+DB_Error);
if PosCounter = 9 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET NoMedal = NoMedal + 1, Points = Points + 2 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError11: '+DB_Error);
if PosCounter = 10 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET NoMedal = NoMedal + 1, Points = Points + 1 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError12: '+DB_Error);
if PosCounter > 10 then
if Not DB_Update(DB_ID, 'UPDATE Accounts SET NoMedal = NoMedal + 1 WHERE Name = '''+EscapeApostrophe(DB_GetString(DB_ID, 0))+''';') then
WriteLn('RunModeError13: '+DB_Error);
end;
DB_Update(DB_ID, 'COMMIT;');
end;
DB_FinishQuery(DB_ID);
end;
{$ENDIF}
procedure GenerateEliteList;
var
i, j, TempNumber: Integer;
TempTable: array[0..6] of TStringList;
TempString: String;
begin
_EliteList.Clear;
for i := 0 to 6 do
TempTable[i] := File.CreateStringList;
TempTable[0].Append('|Position');
TempTable[0].Append('|');
TempTable[1].Append('|Name');
TempTable[1].Append('');
TempTable[2].Append('|Gold');
TempTable[2].Append('');
TempTable[3].Append('|Silver');
TempTable[3].Append('');
TempTable[4].Append('|Bronze');
TempTable[4].Append('');
TempTable[5].Append('|NoMedal');
TempTable[5].Append('');
TempTable[6].Append('|Points');
TempTable[6].Append('');
if Not DB_Query(DB_ID, 'SELECT Name, Gold, Silver, Bronze, NoMedal, Points FROM Accounts ORDER BY Points DESC LIMIT 20;') then
WriteLn('RunModeError20: '+DB_Error)
else
While DB_NextRow(DB_ID) Do Begin
Inc(TempNumber, 1);
TempTable[0].Append('|'+IntToStr(TempNumber));
TempTable[1].Append('|'+DB_GetString(DB_ID, 0));
TempTable[2].Append('|'+DB_GetString(DB_ID, 1));
TempTable[3].Append('|'+DB_GetString(DB_ID, 2));
TempTable[4].Append('|'+DB_GetString(DB_ID, 3));
TempTable[5].Append('|'+DB_GetString(DB_ID, 4));
TempTable[6].Append('|'+DB_GetString(DB_ID, 5));
end;
TempNumber := 0;
for j := 0 to 6 do begin
TempNumber := 0;
for i := 0 to TempTable[j].Count-1 do
if length(TempTable[j][i]) > TempNumber then
TempNumber := length(TempTable[j][i]);
for i := 0 to TempTable[j].Count-1 do begin
TempString := TempTable[j][i];
While length(TempString) < TempNumber do
if i = 1 then
Insert('-', TempString, Length(TempString)+1)
else
Insert(' ', TempString, Length(TempString)+1);
TempTable[j][i] := TempString;
end;
end;
TempNumber := Length(TempTable[0][0])+Length(TempTable[1][0])+Length(TempTable[2][0])+Length(TempTable[3][0])+Length(TempTable[4][0])+Length(TempTable[5][0])+Length(TempTable[6][0])+1;
TempString := '-';
While length(TempString) < TempNumber do
Insert('-', TempString, Length(TempString)+1);
_EliteList.Append(TempString);
for i := 0 to TempTable[0].Count-1 do
_EliteList.Append(TempTable[0][i]+TempTable[1][i]+TempTable[2][i]+TempTable[3][i]+TempTable[4][i]+TempTable[5][i]+TempTable[6][i]+'|');
_EliteList.Append(TempString);
DB_FinishQuery(DB_ID);
for i := 0 to 6 do
TempTable[i].Free;
end;
function MapBestTime(MapName: String): TDateTime;
begin
if Not DB_Query(DB_ID, 'SELECT Time FROM Scores WHERE Map = '''+EscapeApostrophe(MapName)+''' ORDER BY Time, Date;') then
WriteLn('RunModeError21: '+DB_Error)
else begin
if Not DB_NextRow(DB_ID) then
Result := -1
else
Result := DB_GetDouble(DB_ID, 0);
DB_FinishQuery(DB_ID);
end;
end;
function PlayerBestTime(Account, MapName: String): TDateTime;
begin
if Not DB_Query(DB_ID, 'SELECT Time, Id FROM Scores WHERE Account = '''+EscapeApostrophe(Account)+''' AND Map = '''+EscapeApostrophe(MapName)+''' LIMIT 1;') then
WriteLn('RunModeError22: '+DB_Error)
else begin
if Not DB_NextRow(DB_ID) then
Result := -1
else begin
Result := DB_GetDouble(DB_ID, 0);
_ScoreId := DB_GetString(DB_ID, 1);
end;
DB_FinishQuery(DB_ID);
end;
end;
function ShowTime(DaysPassed: TDateTime): String;
begin
DaysPassed := Abs(DaysPassed);
if Trunc(DaysPassed) > 0 then
Result := IntToStr(Trunc(DaysPassed))+' '+iif(Trunc(DaysPassed) = 1, 'day', 'days')+', '+FormatDateTime('hh:nn:ss.zzz', DaysPassed)
else
if DaysPassed >= 1.0/24 then
Result := FormatDateTime('hh:nn:ss.zzz', DaysPassed)
else
if DaysPassed >= 1.0/1440 then
Result := FormatDateTime('nn:ss.zzz', DaysPassed)
else
if DaysPassed >= 1.0/86400 then
Result := FormatDateTime('ss.zzz', DaysPassed)
else
if DaysPassed >= 1.0/86400000 then
Result := FormatDateTime('zzz', DaysPassed)
else
Result := '000';
end;
procedure Clock(Ticks: Integer);
var
i: Byte;
j, PosCounter: Integer;
TempTime, TempTime2, Timer: TDateTime;
begin
if Ticks mod 6 = 0 then begin
if Length(_Replay) > 0 then begin
if _WorldTextLoop = 240 then
_WorldTextLoop := 200;
Inc(_WorldTextLoop, 1);
if _ReplayTime < Length(_Replay) then begin
Inc(_ReplayTime, 1);
Players.WorldText(_WorldTextLoop, '.', 240, $FF0000, 0.15, _Replay[_ReplayTime-1].X+30*-0.15, _Replay[_ReplayTime-1].Y+140*-0.15);
Players.BigText(10, _ReplayInfo+' '+IntToStr(_ReplayTime)+'/'+IntToStr(Length(_Replay)), 120, $FF0000, 0.05, 5, 340);
if (_ReplayTime = Length(_Replay)) and (Length(_Replay2) = 0) then
_ReplayTime := 0;
end;
end;
if Length(_Replay2) > 0 then begin
if _WorldTextLoop2 = 190 then
_WorldTextLoop2 := 150;
Inc(_WorldTextLoop2, 1);
if _ReplayTime2 < Length(_Replay2) then begin
Inc(_ReplayTime2, 1);
Players.WorldText(_WorldTextLoop2, '.', 240, $0000FF, 0.15, _Replay2[_ReplayTime2-1].X+30*-0.15, _Replay2[_ReplayTime2-1].Y+140*-0.15);
Players.BigText(11, _ReplayInfo2+' '+IntToStr(_ReplayTime2)+'/'+IntToStr(Length(_Replay2)), 120, $0000FF, 0.05, 5, 360);
end;
if (_ReplayTime2 = Length(_Replay2)) and (_ReplayTime = Length(_Replay)) then begin
_ReplayTime2 := 0;
_ReplayTime := 0;
end;
end;
end;
for i := 1 to 32 do
if Players[i].Active then begin
if Ticks mod 6 = 0 then
if Players[i].Alive then
if Length(_Record[i]) > 0 then begin
if Distance(_Record[i][High(_Record[i])].X, _Record[i][High(_Record[i])].Y, Players[i].X, Players[i].Y) >= 300 then begin
Players[i].Damage(i, 150);
Players.WriteConsole('Offmap bug, lag or teleport cheat detected, player '+Players[i].Name+' has been killed', $FF0000);
exit;
end;
SetLength(_Record[i], Length(_Record[i])+1);
_Record[i][High(_Record[i])].X := Players[i].X;
_Record[i][High(_Record[i])].Y := Players[i].Y;
end;
if _ShowTimer[i] then
if _Laps = 0 then
Players[i].BigText(3, ShowTime(Now - _Timer[i])+#10+IntToStr(Trunc(21.6*sqrt(Players[i].VelX*Players[i].VelX + Players[i].VelY*Players[i].VelY)))+'km/h', 120, $FFFFFF, 0.1, 320, 360)
else
Players[i].BigText(3, ShowTime(Now - _Timer[i])+#10+'Lap: '+IntToStr(_LapsPassed[i]+1)+'/'+IntToStr(_Laps)+#10+IntToStr(Trunc(21.6*sqrt(Players[i].VelX*Players[i].VelX + Players[i].VelY*Players[i].VelY)))+'km/h', 120, $FFFFFF, 0.1, 320, 360);
if length(_CheckPoint) > 1 then begin
for j := 0 to High(_CheckPoint) do begin
if (Players[i].Alive) and (not _EditMode) and (not _FlightMode[i]) and (not _GodMode[i]) then begin
if _Laps = 0 then begin
if (_CheckPointPassed[i] <> 0) and (_CheckPointPassed[i] = j) and (Distance(_CheckPoint[j].X, _CheckPoint[j].Y, Players[i].X, Players[i].Y) <= 30) and (Now - _Timer[i] >= 1.0/86400) then
if j <> High(_CheckPoint) then
_CheckPointPassed[i] := j+1
else begin
Timer := Now - _Timer[i];
{$IFDEF RUN_MODE_DEBUG}
Players[i].WriteConsole('Respawn Ping: '+IntToStr(_PingRespawn[i])+', Finish Ping: '+IntToStr(Players[i].Ping), $FF0000);
if _PingRespawn[i] >= Players[i].Ping then
Players[i].WriteConsole('Ping Compensated Time: '+ShowTime(Timer - (1.0/86400000*Players[i].Ping)), $FF0000)
else
Players[i].WriteConsole('Ping Compensated Time: '+ShowTime(Timer - (1.0/86400000*_PingRespawn[i])), $FF0000);
{$ENDIF}
end;
end else
if (_CheckPointPassed[i] <> 0) and (_CheckPointPassed[i] = j) and (Distance(_CheckPoint[j].X, _CheckPoint[j].Y, Players[i].X, Players[i].Y) <= 30) and (Now - _Timer[i] >= 1.0/86400) then
_CheckPointPassed[i] := j+1;
end;
if Ticks mod 15 = 0 then
if j+1 = _CheckPointPassed[i] then
Players[i].WorldText(j, IntToStr(j+1), 120, $00FF00, 0.3, _CheckPoint[j].X+65*-0.3, _CheckPoint[j].Y+120*-0.3)
else
Players[i].WorldText(j, IntToStr(j+1), 120, $FF0000, 0.3, _CheckPoint[j].X+65*-0.3, _CheckPoint[j].Y+120*-0.3);
end;
if (Players[i].Alive) and (not _EditMode) and (not _FlightMode[i]) and (not _GodMode[i]) then
if (_CheckPointPassed[i] = Length(_CheckPoint)) and (Distance(_CheckPoint[0].X, _CheckPoint[0].Y, Players[i].X, Players[i].Y) <= 30) then begin
Inc(_LapsPassed[i], 1);
if _LapsPassed[i] = _Laps then begin
Timer := Now - _Timer[i];
{$IFDEF RUN_MODE_DEBUG}
Players[i].WriteConsole('Respawn Ping: '+IntToStr(_PingRespawn[i])+', Finish Ping: '+IntToStr(Players[i].Ping), $FF0000);
{$ENDIF}
end else
_CheckPointPassed[i] := 1;
end;
end else
if length(_CheckPoint) = 1 then
if _CheckPointPassed[i] = 1 then
Players[i].WorldText(0, '1', 120, $00FF00, 0.3, _CheckPoint[0].X+65*-0.3, _CheckPoint[0].Y+120*-0.3)
else
Players[i].WorldText(0, '1', 120, $FF0000, 0.3, _CheckPoint[0].X+65*-0.3, _CheckPoint[0].Y+120*-0.3);
if Timer > 0 then begin
if Not DB_Query(DB_ID, 'SELECT Name FROM Accounts WHERE Name = '''+EscapeApostrophe(Players[i].Name)+''' LIMIT 1;') then
WriteLn('RunModeError23: '+DB_Error)
else begin
if DB_NextRow(DB_ID) then begin //If account was found
TempTime := MapBestTime(Game.CurrentMap);
if TempTime = -1 then begin
Players.WriteConsole('[1] First score by '+Players[i].Name+': '+ShowTime(Timer), $FFD700);
if _LoggedIn[i] then begin
DB_Update(DB_ID, 'BEGIN TRANSACTION;');
if Not DB_Update(DB_ID, 'INSERT INTO Scores(Account, Map, Date, Time) VALUES('''+EscapeApostrophe(Players[i].Name)+''', '''+EscapeApostrophe(Game.CurrentMap)+''', '+FloatToStr(Now)+', '+FloatToStr(Timer)+');') then //Add score
WriteLn('RunModeError24: '+DB_Error)
else begin
if Not DB_Query(DB_ID, 'SELECT last_insert_rowid();') then
WriteLn('RunModeError25: '+DB_Error)
else begin
DB_NextRow(DB_ID);
if Not DB_Update(DB_ID, 'CREATE TABLE '''+DB_GetString(DB_ID, 0)+'''(Id INTEGER PRIMARY KEY, PosX Double, PosY Double);') then begin
WriteLn('RunModeError26: '+DB_Error);
Players.WriteConsole('RunModeError27: '+DB_Error, $FF0000);
end else
begin
for j := 0 to High(_Record[i]) do
if Not DB_Update(DB_ID, 'INSERT INTO '''+DB_GetString(DB_ID, 0)+'''(PosX, PosY) VALUES('+FloatToStr(_Record[i][j].X)+', '+FloatToStr(_Record[i][j].Y)+');') then
WriteLn('RunModeError28: '+DB_Error);
end;
end;
end;
DB_Update(DB_ID, 'COMMIT;');
end else
Players.WriteConsole('Player '+Players[i].Name+' isn''t logged in - score wasn''t recorded', COLOR_1);
end else
begin
TempTime2 := PlayerBestTime(Players[i].Name, Game.CurrentMap);
if TempTime2 = -1 then begin
DB_Update(DB_ID, 'BEGIN TRANSACTION;');
if Not DB_Update(DB_ID, 'INSERT INTO Scores(Account, Map, Date, Time) VALUES('''+EscapeApostrophe(Players[i].Name)+''', '''+EscapeApostrophe(Game.CurrentMap)+''', '+FloatToStr(Now)+', '+FloatToStr(Timer)+');') then //Add score
WriteLn('RunModeError29: '+DB_Error)
else begin
if Not DB_Query(DB_ID, 'SELECT last_insert_rowid();') then
WriteLn('RunModeError30: '+DB_Error)
else begin
DB_NextRow(DB_ID);
if Not DB_Update(DB_ID, 'CREATE TABLE '''+DB_GetString(DB_ID, 0)+'''(Id INTEGER PRIMARY KEY, PosX Double, PosY Double);') then begin
WriteLn('RunModeError31: '+DB_Error);
Players.WriteConsole('RunModeError32: '+DB_Error, $FF0000);
end else
begin
for j := 0 to High(_Record[i]) do
if Not DB_Update(DB_ID, 'INSERT INTO '''+DB_GetString(DB_ID, 0)+'''(PosX, PosY) VALUES('+FloatToStr(_Record[i][j].X)+', '+FloatToStr(_Record[i][j].Y)+');') then
WriteLn('RunModeError33: '+DB_Error);
end;
end;
end;
if Not DB_Query(DB_ID, 'SELECT Account FROM Scores WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''' ORDER BY Time, Date;') then //Find position
WriteLn('RunModeError34: '+DB_Error)
else
While DB_NextRow(DB_ID) Do begin
Inc(PosCounter, 1);
if Players[i].Name = String(DB_GetString(DB_ID, 0)) then
break;
end;
if PosCounter = 1 then
Players.WriteConsole('[1] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: Not found, Map''s best time: -'+ShowTime(Timer - TempTime), $FFD700);
if PosCounter = 2 then
Players.WriteConsole('[2] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: Not found, Map''s best time: +'+ShowTime(Timer - TempTime), $C0C0C0);
if PosCounter = 3 then
Players.WriteConsole('[3] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: Not found, Map''s best time: +'+ShowTime(Timer - TempTime), $F4A460);
if PosCounter > 3 then
Players.WriteConsole('['+IntToStr(PosCounter)+'] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: Not found, Map''s best time: +'+ShowTime(Timer - TempTime), COLOR_1);
if _LoggedIn[i] then
DB_Update(DB_ID, 'COMMIT;')
else begin
DB_FinishQuery(DB_ID);
DB_Update(DB_ID, 'ROLLBACK;');
Players.WriteConsole('Player '+Players[i].Name+' isn''t logged in - score wasn''t recorded', COLOR_1);
end;
end else
if Timer >= TempTime2 then
Players.WriteConsole(ShowTime(Timer)+', Time was slower than '+Players[i].Name+'''s best by: '+ShowTime(Timer - TempTime2), COLOR_1)
else begin
DB_FinishQuery(DB_ID);
DB_Update(DB_ID, 'BEGIN TRANSACTION;');
if Not DB_Update(DB_ID, 'DROP TABLE '''+_ScoreId+''';') then
WriteLn('RunModeError35: '+DB_Error);
if Not DB_Update(DB_ID, 'DELETE FROM Scores WHERE Account = '''+EscapeApostrophe(Players[i].Name)+''' AND Map = '''+EscapeApostrophe(Game.CurrentMap)+''';') then //Del score
WriteLn('RunModeError36: '+DB_Error);
if Not DB_Update(DB_ID, 'INSERT INTO Scores(Account, Map, Date, Time) VALUES('''+EscapeApostrophe(Players[i].Name)+''', '''+EscapeApostrophe(Game.CurrentMap)+''', '+FloatToStr(Now)+', '+FloatToStr(Timer)+');') then //Add score
WriteLn('RunModeError37: '+DB_Error)
else begin
if Not DB_Query(DB_ID, 'SELECT last_insert_rowid();') then
WriteLn('RunModeError38: '+DB_Error)
else begin
DB_NextRow(DB_ID);
if Not DB_Update(DB_ID, 'CREATE TABLE '''+DB_GetString(DB_ID, 0)+'''(Id INTEGER PRIMARY KEY, PosX Double, PosY Double);') then begin
WriteLn('RunModeError39: '+DB_Error);
Players.WriteConsole('RunModeError40: '+DB_Error, $FF0000);
end else
begin
for j := 0 to High(_Record[i]) do
if Not DB_Update(DB_ID, 'INSERT INTO '''+DB_GetString(DB_ID, 0)+'''(PosX, PosY) VALUES('+FloatToStr(_Record[i][j].X)+', '+FloatToStr(_Record[i][j].Y)+');') then
WriteLn('RunModeError41: '+DB_Error);
end;
end;
end;
if Not DB_Query(DB_ID, 'SELECT Account FROM Scores WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''' ORDER BY Time, Date;') then //Find position
WriteLn('RunModeError42: '+DB_Error)
else
While DB_NextRow(DB_ID) Do begin
Inc(PosCounter, 1);
if Players[i].Name = String(DB_GetString(DB_ID, 0)) then
break;
end;
if PosCounter = 1 then
Players.WriteConsole('[1] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: -'+ShowTime(Timer - TempTime2)+', Map''s best time: -'+ShowTime(Timer - TempTime), $FFD700);
if PosCounter = 2 then
Players.WriteConsole('[2] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: -'+ShowTime(Timer - TempTime2)+', Map''s best time: +'+ShowTime(Timer - TempTime), $C0C0C0);
if PosCounter = 3 then
Players.WriteConsole('[3] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: -'+ShowTime(Timer - TempTime2)+', Map''s best time: +'+ShowTime(Timer - TempTime), $F4A460);
if PosCounter > 3 then
Players.WriteConsole('['+IntToStr(PosCounter)+'] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: -'+ShowTime(Timer - TempTime2)+', Map''s best time: +'+ShowTime(Timer - TempTime), COLOR_1);
if _LoggedIn[i] then
DB_Update(DB_ID, 'COMMIT;')
else begin
DB_FinishQuery(DB_ID);
DB_Update(DB_ID, 'ROLLBACK;');
Players.WriteConsole('Player '+Players[i].Name+' isn''t logged in - score wasn''t recorded', COLOR_1);
end;
end;
end;
end else
begin //If account wasn't found
TempTime := MapBestTime(Game.CurrentMap);
if TempTime = -1 then
Players.WriteConsole('[1] First score by '+Players[i].Name+': '+ShowTime(Timer), $FFD700)
else begin
DB_Update(DB_ID, 'BEGIN TRANSACTION;');
if Not DB_Update(DB_ID, 'INSERT INTO Scores(Account, Map, Date, Time) VALUES('''+EscapeApostrophe(Players[i].Name)+''', '''+EscapeApostrophe(Game.CurrentMap)+''', '+FloatToStr(Now)+', '+FloatToStr(Timer)+');') then //Add score
WriteLn('RunModeError43: '+DB_Error);
if Not DB_Query(DB_ID, 'SELECT Account FROM Scores WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''' ORDER BY Time, Date;') then //Find position
WriteLn('RunModeError44: '+DB_Error)
else
While DB_NextRow(DB_ID) Do begin
Inc(PosCounter, 1);
if Players[i].Name = String(DB_GetString(DB_ID, 0)) then
break;
end;
if PosCounter = 1 then
Players.WriteConsole('[1] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: Not found, Map''s best time: -'+ShowTime(Timer - TempTime), $FFD700);
if PosCounter = 2 then
Players.WriteConsole('[2] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: Not found, Map''s best time: +'+ShowTime(Timer - TempTime), $C0C0C0);
if PosCounter = 3 then
Players.WriteConsole('[3] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: Not found, Map''s best time: +'+ShowTime(Timer - TempTime), $F4A460);
if PosCounter > 3 then
Players.WriteConsole('['+IntToStr(PosCounter)+'] '+ShowTime(Timer)+', '+Players[i].Name+'''s best time: Not found, Map''s best time: +'+ShowTime(Timer - TempTime), COLOR_1);
DB_FinishQuery(DB_ID);
DB_Update(DB_ID, 'ROLLBACK;');
end;
Players.WriteConsole('Unregistered nickname: '+Players[i].Name+' - score wasn''t recorded', COLOR_1);
end;
DB_FinishQuery(DB_ID);
end;
Players[i].Damage(i, 150);
Timer := 0;
end;
if _FlightMode[i] then begin
Players[i].SetVelocity(0, 0);
if Players[i].KeyJetpack then begin
Players[i].Move(Players[i].MouseAimX, Players[i].MouseAimY);
_LastPosX[i] := Players[i].MouseAimX;
_LastPosY[i] := Players[i].MouseAimY;
end else
Players[i].Move(_LastPosX[i], _LastPosY[i]);
end;
if Ticks mod 3 = 0 then
if (Players[i].KeyReload) and (_RKill[i]) and (not _EditMode) and (not _FlightMode[i]) and (not _GodMode[i]) then
if length(_CheckPoint) <= 1 then
Players[i].BigText(5, 'Checkpoints error', 120, $FF0000, 0.1, 320, 300)
else
Players[i].Damage(i, 150);
//1 SEC INTERVAL LOOP
if Ticks mod 60 = 0 then begin
if _FlightMode[i] then
Players[i].BigText(9, 'Flight', 120, COLOR_1, 0.1, 320, 150);
if _GodMode[i] then
Players[i].BigText(8, 'God', 120, COLOR_1, 0.1, 320, 180);
if _EditMode then
Players[i].BigText(7, 'EditMode', 120, COLOR_1, 0.1, 320, 210);
if (not _LoggedIn[i]) and (Players[i].Team <> 5) then
Players[i].BigText(4, 'Not logged in', 120, $FF0000, 0.1, 320, 240);
if (Players[i].Alive) and (not _EditMode) and (not _FlightMode[i]) and (not _GodMode[i]) then
if _CheckPointPassed[i] = 0 then
Players[i].BigText(6, 'Press "Reload Key" to start', 120, COLOR_1, 0.1, 320, 270);
end;
//END OF 1 SEC INTERVAL LOOP
end;
if Ticks mod(3600*3) = 0 then
Players.WriteConsole('!help - All you want to know, our Discord: https://discord.gg/Jr8CFQu', Random(0, 16777215+1));
if Ticks mod(3600*40) = 0 then
Players.WriteConsole('Official Soldat Discord: https://discord.gg/v9t82C9', Random(0, 16777215+1));
if Ticks mod(3600*12) = 0 then begin
Players.WriteConsole('Want to optimize your run & improve your time? Type !rme for more info', $c53159);
end;
if Ticks mod(216000*USED_IP_TIME) = 0 then begin
_UsedIP.Clear;
{$IFDEF RUN_MODE_DEBUG}
WriteLn('RunMode: _UsedIP.Clear');
{$ENDIF}
end;
end;
function OnAdminCommand(Player: TActivePlayer; Command: string): boolean;
var
i: Integer;
StrToIntConv, StrToIntConv2: Integer;
TimeStart: TDateTime;
Ini: TIniFile;
TempStrL: TStringList;
TempX, TempY: Single;
begin
Result := False;
if Command = '/recountallstats' then begin
Players.WriteConsole('Recounting medals...', COLOR_1);
TimeStart := Now;
RecountAllStats;
Players.WriteConsole('Done in '+ShowTime(Now - TimeStart), COLOR_1);
Players.WriteConsole('Generating elite list...', COLOR_2);
TimeStart := Now;
GenerateEliteList;
Players.WriteConsole('Done in '+ShowTime(Now - TimeStart), COLOR_2);
end;
if Player <> nil then begin//In-Game Admin
if Command = '/admcmds' then begin
Player.WriteConsole('Commands for admins 1/2:', $FFFF00);
Player.WriteConsole('RunMode:', COLOR_1);
Player.WriteConsole('/recountallstats - Recounts all medals and creates new elite list', COLOR_2);
Player.WriteConsole('/delacc <name> - Deletes certain account and it''s replays', COLOR_2);
Player.WriteConsole('/delid <id> - Deletes certain score and it''s replay', COLOR_2);
Player.WriteConsole('/emode - Enable/Disable editing mode for checkpoints', COLOR_2);
Player.WriteConsole('/fmode - Enable/Disable flight mode (Enables god mode)', COLOR_2);
Player.WriteConsole('/gmode - Enable/Disable god mode (Disables flight mode)', COLOR_2);
Player.WriteConsole('/swap <cp1> <cp2> - Swaps checkpoints'' position', COLOR_2);
Player.WriteConsole('/cpadd - Creates new checkpoint', COLOR_2);
Player.WriteConsole('/cpdel - Deletes last checkpoint', COLOR_2);
Player.WriteConsole('/cplaps <amount> - Sets amount of laps', COLOR_2);
Player.WriteConsole('/cpsave - Saves current checkpoints'' setting', COLOR_2);
Player.WriteConsole('/replay <id> - Replays certain score', COLOR_2);
Player.WriteConsole('/replay2 <id> <id> - Replays two scores at the same time', COLOR_2);
Player.WriteConsole('/replaystop - Stops all replays', COLOR_2);
Player.WriteConsole('PlayersDB:', COLOR_1);
Player.WriteConsole('/checkid <playerid(1-32)> - Check all nicks and entries for certain hwid', COLOR_2);
Player.WriteConsole('/checknick <nick> - Check all hwids and entries for certain nick', COLOR_2);
Player.WriteConsole('/checkhw <hwid> - Check all nicks and entries for certain hwid', COLOR_2);
Player.WriteConsole('/admcmds2 - Commands for admins 2/2', $FFFF00);
end;
if Command = '/admcmds2' then begin
Player.WriteConsole('Commands for admins 2/2:', $FFFF00);
Player.WriteConsole('MapListReader:', COLOR_1);
Player.WriteConsole('/createsortedmaplist - Create sorted MapList if current one is outdated', COLOR_2);
Player.WriteConsole('/addmap <map name> - Add map to MapList (Default Soldat command)', COLOR_2);
Player.WriteConsole('/delmap <map name> - Remove map from MapList (Default Soldat command)', COLOR_2);
Player.WriteConsole('MapListRandomizer:', COLOR_1);
Player.WriteConsole('/mlrand - Randomizes MapList', COLOR_2);
end;
if (Copy(Command, 1, 8) = '/delacc ') and (Copy(Command, 9, Length(Command)) <> nil) then
if DB_Query(DB_ID, 'SELECT Name FROM Accounts WHERE Name = '''+EscapeApostrophe(Copy(Command, 9, Length(Command)))+''' LIMIT 1;') then begin
if DB_NextRow(DB_ID) then begin
for i := 1 to 32 do
if (Players[i].Active) and (Players[i].Name = Copy(Command, 9, Length(Command))) then
_LoggedIn[i] := FALSE;
DB_Update(DB_ID, 'BEGIN TRANSACTION;');
TempStrL := File.CreateStringList;
if Not DB_Query(DB_ID, 'SELECT Id FROM Scores WHERE Account = '''+EscapeApostrophe(Copy(Command, 9, Length(Command)))+''';') then
Player.WriteConsole('RunModeError45: '+DB_Error, COLOR_1)
else
While DB_NextRow(DB_ID) Do
TempStrL.Append(DB_GetString(DB_ID, 0));
DB_FinishQuery(DB_ID);
for i := 0 to TempStrL.Count-1 do
if Not DB_Update(DB_ID, 'DROP TABLE '''+TempStrL[i]+''';') then
Player.WriteConsole('RunModeError46: '+DB_Error, COLOR_1);
TempStrL.Free;
if Not DB_Update(DB_ID, 'DELETE FROM Scores WHERE Account = '''+EscapeApostrophe(Copy(Command, 9, Length(Command)))+''';') then
Player.WriteConsole('RunModeError47: '+DB_Error, COLOR_1);
if Not DB_Update(DB_ID, 'DELETE FROM Accounts WHERE Name = '''+EscapeApostrophe(Copy(Command, 9, Length(Command)))+''';') then
Player.WriteConsole('RunModeError48: '+DB_Error, COLOR_1);
DB_Update(DB_ID, 'COMMIT;');
Player.WriteConsole('Account "'+Copy(Command, 9, Length(Command))+'" has been deleted', COLOR_1);
end else
Player.WriteConsole('Account "'+Copy(Command, 9, Length(Command))+'" doesn''t exists', COLOR_1);
DB_FinishQuery(DB_ID);
end else
Player.WriteConsole('RunModeError49: '+DB_Error, COLOR_1);
if (Copy(Command, 1, 7) = '/delid ') and (Copy(Command, 8, Length(Command)) <> nil) then begin
if Not DB_Update(DB_ID, 'DELETE FROM Scores WHERE Id = '''+EscapeApostrophe(Copy(Command, 8, Length(Command)))+''';') then
Player.WriteConsole('RunModeError50: '+DB_Error, COLOR_1)
else
Player.WriteConsole('Score with Id '+Copy(Command, 8, Length(Command))+' has been deleted', COLOR_1);
if Not DB_Update(DB_ID, 'DROP TABLE '''+EscapeApostrophe(Copy(Command, 8, Length(Command)))+''';') then
Player.WriteConsole('RunModeError51: '+DB_Error, COLOR_1)
else
Player.WriteConsole('Replay with Id '+Copy(Command, 8, Length(Command))+' has been deleted', COLOR_1);
end;
if Command = '/fmode' then begin
_LapsPassed[Player.ID] := 0;
_CheckPointPassed[Player.ID] := 0;
SetLength(_Record[Player.ID], 0);
if _FlightMode[Player.ID] then begin
_FlightMode[Player.ID] := False;
Player.WriteConsole('Flight mode has been disabled', COLOR_1);
end else
begin
_GodMode[Player.ID] := True;
_FlightMode[Player.ID] := True;
_LastPosX[Player.ID] := Player.X;
_LastPosY[Player.ID] := Player.Y;
Player.WriteConsole('Flight mode has been enabled', COLOR_1);
end;
end;
if Command = '/gmode' then begin
_LapsPassed[Player.ID] := 0;
_CheckPointPassed[Player.ID] := 0;
if _GodMode[Player.ID] then begin
_FlightMode[Player.ID] := False;
_GodMode[Player.ID] := False;
Player.WriteConsole('God mode has been disabled', COLOR_1);
end else
begin
_GodMode[Player.ID] := True;
Player.WriteConsole('God mode has been enabled', COLOR_1);
end;
end;
if Command = '/emode' then begin
for i := 1 to 32 do begin
_LapsPassed[i] := 0;
_CheckPointPassed[i] := 0;
end;
if _EditMode then begin
_EditMode := False;
Players.WriteConsole('Editing mode has been disabled', COLOR_1);
end else
begin
_EditMode := True;
Players.WriteConsole('Editing mode has been enabled', COLOR_1);
end;
end;
if (Copy(Command, 1, 6) = '/swap ') or (Command = '/swap') then
if Copy(Command, 7, length(Command)) <> nil then begin
Try
StrToIntConv := StrToInt(GetPiece(Command, ' ', 1));
StrToIntConv2 := StrToInt(GetPiece(Command, ' ', 2));
if (StrToIntConv <= length(_CheckPoint)) and (StrToIntConv2 <= length(_CheckPoint)) and (StrToIntConv > 0) and (StrToIntConv2 > 0) then begin
TempX := _CheckPoint[StrToIntConv-1].X;
TempY := _CheckPoint[StrToIntConv-1].Y;
_CheckPoint[StrToIntConv-1].X := _CheckPoint[StrToIntConv2-1].X;
_CheckPoint[StrToIntConv-1].Y := _CheckPoint[StrToIntConv2-1].Y;
_CheckPoint[StrToIntConv2-1].X := TempX;
_CheckPoint[StrToIntConv2-1].Y := TempY;
Player.WriteConsole('Checkpoints "'+GetPiece(Command, ' ', 1)+'" and "'+GetPiece(Command, ' ', 2)+'" have been swapped', COLOR_1);
end else
Player.WriteConsole('Out of bounds', COLOR_1);
Except
Player.WriteConsole('Invalid parameters', COLOR_1);
end;
end else
Player.WriteConsole('Lack of parameters for command "/swap <cp1> <cp2>"', COLOR_2);
if Command = '/cpadd' then begin
for i := 1 to 32 do begin
_LapsPassed[i] := 0;
_CheckPointPassed[i] := 0;
end;
SetLength(_CheckPoint, Length(_CheckPoint)+1);
_CheckPoint[High(_CheckPoint)].X := Player.X;
_CheckPoint[High(_CheckPoint)].Y := Player.Y;
end;
if Command = '/cpdel' then
if High(_CheckPoint) <> -1 then begin
for i := 1 to 32 do begin
_LapsPassed[i] := 0;
_CheckPointPassed[i] := 0;
end;
SetLength(_CheckPoint, High(_CheckPoint));
end else
Player.WriteConsole('All checkpoints has been deleted', $FF0000);
if (Copy(Command, 1, 8) = '/cplaps ') and (Length(Command)>8) then begin
Delete(Command, 1, 8);
try
StrToIntConv := StrToInt(Command);
except
Player.WriteConsole('Invalid integer', $FF0000);
exit;
end;
for i := 1 to 32 do begin
_LapsPassed[i] := 0;
_CheckPointPassed[i] := 0;
end;
_Laps := StrToIntConv;
end;
if Command = '/cpsave' then
if length(_CheckPoint) <= 1 then
Player.WriteConsole('Not enough checkpoints', $FF0000)
else begin
Ini := File.CreateINI('~/maps_config.ini');
Ini.CaseSensitive := True;
if Ini.SectionExists(Game.CurrentMap) then
Ini.EraseSection(Game.CurrentMap);
for i := 0 to High(_CheckPoint) do begin
Ini.WriteFloat(Game.CurrentMap, IntToStr(i)+'X', _CheckPoint[i].X);
Ini.WriteFloat(Game.CurrentMap, IntToStr(i)+'Y', _CheckPoint[i].Y);
end;
Ini.WriteInteger(Game.CurrentMap, 'Laps', _Laps);
Ini.Free;
Player.WriteConsole('Checkpoints'' setting saved', $00FF00);
end;
if (Copy(Command, 1, 8) = '/replay ') and (Length(Command)>8) then begin
Delete(Command, 1, 8);
Players.WriteConsole('Loading replay '+Command+'...', COLOR_1);
if Not DB_Query(DB_ID, 'SELECT PosX, PosY FROM '''+EscapeApostrophe(Command)+''';') then
Players.WriteConsole('RunModeError52: '+DB_Error, COLOR_1)
else begin
SetLength(_Replay, 0);
_ReplayTime := 0;
While DB_NextRow(DB_ID) Do begin
SetLength(_Replay, Length(_Replay)+1);
_Replay[High(_Replay)].X := DB_GetDouble(DB_ID, 0);
_Replay[High(_Replay)].Y := DB_GetDouble(DB_ID, 1);
end;
if Length(_Replay) > 0 then begin
DB_FinishQuery(DB_ID);
if Not DB_Query(DB_ID, 'SELECT * FROM (SELECT 1+(SELECT count(*) FROM Scores a WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''' AND (a.Time < b.Time OR (a.Time = b.Time AND a.Date < b.Date))) AS Position, Time, Date, Id, Account FROM Scores b WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''') WHERE Id = '''+EscapeApostrophe(Command)+''' LIMIT 1;') then
WriteLn('RunModeError112: '+DB_Error)
else
if Not DB_NextRow(DB_ID) then begin
Players.WriteConsole('Score for current map with ID '+Command+' not found', COLOR_2);
_ReplayInfo := 'Wrong replay ID for current map';
end else
_ReplayInfo := '['+DB_GetString(DB_ID, 0)+'] '+ShowTime(DB_GetDouble(DB_ID, 1))+' by '+DB_GetString(DB_ID, 4)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 2))+' ['+DB_GetString(DB_ID, 3)+']';
Players.WriteConsole('Replay loaded', COLOR_1);
_WorldTextLoop := 200;
end else
Players.WriteConsole('Empty replay', COLOR_1);
end;
DB_FinishQuery(DB_ID);
end;
if (Copy(Command, 1, 9) = '/replay2 ') and (Length(Command)>9) then begin
Delete(Command, 1, 9);
Players.WriteConsole('Loading replays '+GetPiece(Command, ' ', 0)+'(red), '+GetPiece(Command, ' ', 1)+'(blue)...', COLOR_1);
if Not DB_Query(DB_ID, 'SELECT PosX, PosY FROM '''+EscapeApostrophe(GetPiece(Command, ' ', 0))+''';') then
Players.WriteConsole('RunModeError111: '+DB_Error, COLOR_1)
else begin
SetLength(_Replay, 0);
_ReplayTime := 0;
While DB_NextRow(DB_ID) Do begin
SetLength(_Replay, Length(_Replay)+1);
_Replay[High(_Replay)].X := DB_GetDouble(DB_ID, 0);
_Replay[High(_Replay)].Y := DB_GetDouble(DB_ID, 1);
end;
if Length(_Replay) > 0 then begin
DB_FinishQuery(DB_ID);
if Not DB_Query(DB_ID, 'SELECT * FROM (SELECT 1+(SELECT count(*) FROM Scores a WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''' AND (a.Time < b.Time OR (a.Time = b.Time AND a.Date < b.Date))) AS Position, Time, Date, Id, Account FROM Scores b WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''') WHERE Id = '''+EscapeApostrophe(GetPiece(Command, ' ', 0))+''' LIMIT 1;') then
WriteLn('RunModeError112: '+DB_Error)
else
if Not DB_NextRow(DB_ID) then begin
Players.WriteConsole('Score for current map with ID '+GetPiece(Command, ' ', 0)+' not found', COLOR_2);
_ReplayInfo := 'Wrong replay ID for current map';
end else
_ReplayInfo := '['+DB_GetString(DB_ID, 0)+'] '+ShowTime(DB_GetDouble(DB_ID, 1))+' by '+DB_GetString(DB_ID, 4)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 2))+' ['+DB_GetString(DB_ID, 3)+']';
Players.WriteConsole('Replay loaded', COLOR_1);
_WorldTextLoop := 200;
end else
Players.WriteConsole('Empty replay', COLOR_1);
end;
DB_FinishQuery(DB_ID);
if Not DB_Query(DB_ID, 'SELECT PosX, PosY FROM '''+EscapeApostrophe(GetPiece(Command, ' ', 1))+''';') then
Players.WriteConsole('RunModeError112: '+DB_Error, COLOR_1)
else begin
SetLength(_Replay2, 0);
_ReplayTime2 := 0;
While DB_NextRow(DB_ID) Do begin
SetLength(_Replay2, Length(_Replay2)+1);
_Replay2[High(_Replay2)].X := DB_GetDouble(DB_ID, 0);
_Replay2[High(_Replay2)].Y := DB_GetDouble(DB_ID, 1);
end;
if Length(_Replay2) > 0 then begin
DB_FinishQuery(DB_ID);
if Not DB_Query(DB_ID, 'SELECT * FROM (SELECT 1+(SELECT count(*) FROM Scores a WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''' AND (a.Time < b.Time OR (a.Time = b.Time AND a.Date < b.Date))) AS Position, Time, Date, Id, Account FROM Scores b WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''') WHERE Id = '''+EscapeApostrophe(GetPiece(Command, ' ', 1))+''' LIMIT 1;') then
WriteLn('RunModeError113: '+DB_Error)
else
if Not DB_NextRow(DB_ID) then begin
Players.WriteConsole('Score for current map with ID '+GetPiece(Command, ' ', 1)+' not found', COLOR_2);
_ReplayInfo2 := 'Wrong replay ID for current map';
end else
_ReplayInfo2 := '['+DB_GetString(DB_ID, 0)+'] '+ShowTime(DB_GetDouble(DB_ID, 1))+' by '+DB_GetString(DB_ID, 4)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 2))+' ['+DB_GetString(DB_ID, 3)+']';
Players.WriteConsole('Replay2 loaded', COLOR_1);
_WorldTextLoop2 := 150;
end else
Players.WriteConsole('Empty replay2', COLOR_1);
end;
DB_FinishQuery(DB_ID);
end;
if Command = '/replaystop' then begin
SetLength(_Replay, 0);
_ReplayTime := 0;
SetLength(_Replay2, 0);
_ReplayTime2 := 0;
Players.WriteConsole('All Replays stopped', COLOR_1);
end;
//TEST ZONE
if Command = '/lastscores' then begin
Player.WriteConsole('Last 20 scores', COLOR_1);
if Not DB_Query(DB_ID, 'SELECT Account, Map, Date, Time FROM Scores ORDER BY Date DESC LIMIT 20;') then
WriteLn('RunModeError53: '+DB_Error)
else
While DB_NextRow(DB_ID) Do
Player.WriteConsole('Map: '+DB_GetString(DB_ID, 1)+', Time: '+FloatToStr(DB_GetDouble(DB_ID, 3))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 2)), COLOR_2);
DB_FinishQuery(DB_ID);
end;
if (Copy(Command, 1, 8) = '/last30 ') and (Copy(Command, 9, Length(Command)) <> nil) then begin
Player.WriteConsole(Copy(Command, 9, Length(Command))+'''s last 30 scores', COLOR_1);
if Not DB_Query(DB_ID, 'SELECT Map, Date, Time FROM Scores WHERE Account = '''+EscapeApostrophe(Copy(Command, 9, Length(Command)))+''' ORDER BY Date DESC LIMIT 30;') then
WriteLn('RunModeError61: '+DB_Error)
else
While DB_NextRow(DB_ID) Do
Player.WriteConsole('Map: '+DB_GetString(DB_ID, 0)+', Time: '+ShowTime(DB_GetDouble(DB_ID, 2))+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1)), COLOR_2);
DB_FinishQuery(DB_ID);
end;
if Command = '/disttest' then begin
Players.WorldText(100, '.', 180, $FF0000, 0.15, Player.X, Player.Y);
Players.WorldText(101, '.', 180, $00FF00, 0.15, Player.X+300, Player.Y);
end;
if Command = '/test4' then begin
if Not DB_Query(DB_ID, 'SELECT Account, Map, Date, Time FROM Scores WHERE Time < 1.0/86400;') then
WriteLn('RunModeError59: '+DB_Error)
else
While DB_NextRow(DB_ID) Do
WriteLn('Map: '+DB_GetString(DB_ID, 1)+', Time: '+ShowTime(DB_GetDouble(DB_ID, 3))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 2)));
DB_FinishQuery(DB_ID);
end;
{if Command = '/changenick' then begin
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Name = ''~>2Fast|`HaSte.|'' WHERE Name = ''bp.Energy'';') then
Player.WriteConsole('RunModeError54: '+DB_Error, COLOR_1);
if Not DB_Update(DB_ID, 'UPDATE Scores SET Account = ''~>2Fast|`HaSte.|'' WHERE Account = ''bp.Energy'';') then
Player.WriteConsole('RunModeError55: '+DB_Error, COLOR_1);
end;}
{if Command = '/changemap' then begin
if Not DB_Update(DB_ID, 'UPDATE Scores SET Map = ''s1_claustro'' WHERE Map = ''l1_claustro'';') then
Player.WriteConsole('RunModeError56: '+DB_Error, COLOR_1);
end;}
{if Command = '/delbugtime' then begin
if Not DB_Update(DB_ID, 'DELETE FROM Scores WHERE Time < 1.0/86400;') then
Player.WriteConsole('RunModeError57: '+DB_Error, COLOR_1);
end;}
{if Command = '/delall' then begin
if Not DB_Update(DB_ID, 'DELETE FROM Scores;') then
Player.WriteConsole('RunModeError58: '+DB_Error, COLOR_1);
end;}
{if Command = '/query123' then begin
DatabaseUpdate(DB_ID, 'ALTER TABLE Accounts ADD COLUMN Email TEXT;');
DatabaseUpdate(DB_ID, 'ALTER TABLE Accounts ADD COLUMN Bookmarks TEXT;');
DatabaseUpdate(DB_ID, 'ALTER TABLE Accounts ADD COLUMN PremiumExpiry DOUBLE;');
end;}
{if Command = '/delaero' then begin
if Not DB_Update(DB_ID, 'DELETE FROM Scores WHERE Map = ''Aero'';') then
Player.WriteConsole('RunModeError60: '+DB_Error, COLOR_1);
end;}
end else
begin//TCP Admin
if (Copy(Command, 1, 8) = '/delacc ') and (Copy(Command, 9, Length(Command)) <> nil) then
if DB_Query(DB_ID, 'SELECT Name FROM Accounts WHERE Name = '''+EscapeApostrophe(Copy(Command, 9, Length(Command)))+''' LIMIT 1;') then begin
if DB_NextRow(DB_ID) then begin
for i := 1 to 32 do
if (Players[i].Active) and (Players[i].Name = Copy(Command, 9, Length(Command))) then
_LoggedIn[i] := FALSE;
DB_Update(DB_ID, 'BEGIN TRANSACTION;');
TempStrL := File.CreateStringList;
if Not DB_Query(DB_ID, 'SELECT Id FROM Scores WHERE Account = '''+EscapeApostrophe(Copy(Command, 9, Length(Command)))+''';') then
WriteLn('RunModeError62: '+DB_Error)
else
While DB_NextRow(DB_ID) Do
TempStrL.Append(DB_GetString(DB_ID, 0));
DB_FinishQuery(DB_ID);
for i := 0 to TempStrL.Count-1 do
if Not DB_Update(DB_ID, 'DROP TABLE '''+TempStrL[i]+''';') then
WriteLn('RunModeError63: '+DB_Error);
TempStrL.Free;
if Not DB_Update(DB_ID, 'DELETE FROM Scores WHERE Account = '''+EscapeApostrophe(Copy(Command, 9, Length(Command)))+''';') then
WriteLn('RunModeError64: '+DB_Error);
if Not DB_Update(DB_ID, 'DELETE FROM Accounts WHERE Name = '''+EscapeApostrophe(Copy(Command, 9, Length(Command)))+''';') then
WriteLn('RunModeError65: '+DB_Error);
DB_Update(DB_ID, 'COMMIT;');
WriteLn('Account "'+Copy(Command, 9, Length(Command))+'" has been deleted');
end else
WriteLn('Account "'+Copy(Command, 9, Length(Command))+'" doesn''t exists');
DB_FinishQuery(DB_ID);
end else
WriteLn('RunModeError66: '+DB_Error);
if (Copy(Command, 1, 7) = '/delid ') and (Copy(Command, 8, Length(Command)) <> nil) then begin
if Not DB_Update(DB_ID, 'DELETE FROM Scores WHERE Id = '''+EscapeApostrophe(Copy(Command, 8, Length(Command)))+''';') then
WriteLn('RunModeError67: '+DB_Error)
else
WriteLn('Score with Id '+Copy(Command, 8, Length(Command))+' has been deleted');
if Not DB_Update(DB_ID, 'DROP TABLE '''+EscapeApostrophe(Copy(Command, 8, Length(Command)))+''';') then
WriteLn('RunModeError68: '+DB_Error)
else
WriteLn('Replay with Id '+Copy(Command, 8, Length(Command))+' has been deleted');
end;
end;
end;
function OnPlayerCommand(Player: TActivePlayer; Command: String): Boolean;
var
TempNumber: Byte;
MailTemplate, Bookmarks: TStringList;
GeneratedCode, TempString: String;
TempPChar: PChar;
PosCounter: Integer;
begin
Result := False;
if Command = '/timer' then
if _ShowTimer[Player.ID] then
_ShowTimer[Player.ID] := FALSE
else
_ShowTimer[Player.ID] := TRUE;
if Command = '/ron' then begin
_RKill[Player.ID] := TRUE;
Player.WriteConsole('"R" kill enabled', COLOR_1);
end;
if Command = '/roff' then begin
_RKill[Player.ID] := FALSE;
Player.WriteConsole('"R" kill disabled', COLOR_1);
end;
if (Copy(Command, 1, 9) = '/account ') and (Copy(Command, 10, Length(Command)) <> nil) then
if Not DB_Query(DB_ID, 'SELECT Name FROM Accounts WHERE Name = '''+EscapeApostrophe(Player.Name)+''' LIMIT 1;') then
WriteLn('RunModeError69: '+DB_Error)
else begin
if Not DB_NextRow(DB_ID) then begin
if Not DB_Update(DB_ID, 'INSERT INTO Accounts(Name, Password, Hwid, Date) VALUES('''+EscapeApostrophe(Player.Name)+''', '''+EscapeApostrophe(Copy(Command, 10, Length(Command)))+''', '''+EscapeApostrophe(Player.HWID)+''', '+FloatToStr(Now)+');') then
WriteLn('RunModeError70: '+DB_Error)
else begin
Player.WriteConsole('Account successfully created, remember your nickname and password!', COLOR_1);
Player.WriteConsole('Now login for the first time with command /login <password>', COLOR_1);
end;
end else
Player.WriteConsole('Account with that nickname already exists', COLOR_1);
DB_FinishQuery(DB_ID);
end;
if (Copy(Command, 1, 7) = '/login ') and (Copy(Command, 8, Length(Command)) <> nil) then
if Not DB_Query(DB_ID, 'SELECT Password FROM Accounts WHERE Name = '''+EscapeApostrophe(Player.Name)+''' LIMIT 1;') then
WriteLn('RunModeError71: '+DB_Error)
else begin
if Not DB_NextRow(DB_ID) then
Player.WriteConsole('Account with that nickname doesn''t exists', COLOR_1)
else
if String(DB_GetString(DB_ID, 0)) = Copy(Command, 8, Length(Command)) then begin
Player.WriteConsole('You have successfully logged in!', COLOR_1);
_LoggedIn[Player.ID] := TRUE;
end else
Player.WriteConsole('Wrong password', COLOR_1);
DB_FinishQuery(DB_ID);
end;
if Command = '/logout' then begin
_LoggedIn[Player.ID] := FALSE;
Player.WriteConsole('You have logged out', COLOR_1);
end;
if (Copy(Command, 1, 7) = '/thief ') or (Command = '/thief') then
if Copy(Command, 8, length(Command)) <> nil then begin
Try
TempNumber := StrToInt(GetPiece(Command, ' ', 1));
if (TempNumber > 0) and (TempNumber < 33) then begin
if TempNumber <> Player.ID then begin
if Players[TempNumber].Active then begin
if TempNumber > 9 then begin
if Not DB_Query(DB_ID, 'SELECT Password FROM Accounts WHERE Name = '''+EscapeApostrophe(Players[TempNumber].Name)+''' LIMIT 1;') then
WriteLn('RunModeError72: '+DB_Error)
else begin
if DB_NextRow(DB_ID) then begin
if String(DB_GetString(DB_ID, 0)) = Copy(Command, 11, Length(Command)) then
Players[TempNumber].Ban(1, 'You were banned for 1min due to occupying registered nickname')
else
Player.WriteConsole('"'+Copy(Command, 11, Length(Command))+'" is wrong password', COLOR_1);
end else
Player.WriteConsole('Account with nickname "'+Players[TempNumber].Name+'" doesn''t exists', COLOR_1);
DB_FinishQuery(DB_ID);
end;
end else
if Not DB_Query(DB_ID, 'SELECT Password FROM Accounts WHERE Name = '''+EscapeApostrophe(Players[TempNumber].Name)+''' LIMIT 1;') then
WriteLn('RunModeError73: '+DB_Error)
else begin
if DB_NextRow(DB_ID) then begin
if String(DB_GetString(DB_ID, 0)) = Copy(Command, 10, Length(Command)) then
Players[TempNumber].Ban(1, 'You were banned for 1min due to occupying registered nickname')
else
Player.WriteConsole('"'+Copy(Command, 10, Length(Command))+'" is wrong password', COLOR_1);
end else
Player.WriteConsole('Account with nickname "'+Players[TempNumber].Name+'" doesn''t exists', COLOR_1);
DB_FinishQuery(DB_ID);
end;
end else
Player.WriteConsole('Player with id "'+IntToStr(TempNumber)+'" doesn''t exists', COLOR_1);
end else
Player.WriteConsole('You can''t kick yourself', COLOR_1);
end else
Player.WriteConsole('ID has to be from 1 to 32', COLOR_1);
Except
Player.WriteConsole('"'+GetPiece(Command, ' ', 1)+'" is invalid integer', COLOR_1);
end;
end else
Player.WriteConsole('If you want to kick nickname thief you have to type his id(/+F1) and account password (/thief <id> <password>)', COLOR_2);
if Command = '/settings' then begin
if Not DB_Query(DB_ID, 'SELECT Date, Hwid, AutoLoginHwid FROM Accounts WHERE Name = '''+EscapeApostrophe(Player.Name)+''' LIMIT 1;') then
WriteLn('RunModeError74: '+DB_Error)
else
if Not DB_NextRow(DB_ID) then
Player.WriteConsole('Unregistered nickname', COLOR_2)
else
if _LoggedIn[Player.ID] then begin
Player.WriteConsole(Player.Name+'''s account settings:', COLOR_1);
Player.WriteConsole('Created: '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 0)), COLOR_2);
Player.WriteConsole('Original machine: '+DB_GetString(DB_ID, 1), COLOR_2);
Player.WriteConsole('Auto login machine: '+DB_GetString(DB_ID, 2), COLOR_2);
end else
Player.WriteConsole('You''re not logged in', COLOR_2);
DB_FinishQuery(DB_ID);
end;
if (Copy(Command, 1, 9) = '/addmail ') or (Command = '/addmail') then
if ExecRegExpr('^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$', Copy(Command, 10, length(Command))) then begin
if Not DB_Query(DB_ID, 'SELECT Email FROM Accounts WHERE Name = '''+EscapeApostrophe(Player.Name)+''' LIMIT 1;') then
WriteLn('RunModeError75: '+DB_Error)
else
if Not DB_NextRow(DB_ID) then
Player.WriteConsole('Unregistered nickname', COLOR_2)
else
if _LoggedIn[Player.ID] then begin
if Not DB_Query(DB_ID, 'SELECT Email FROM Accounts WHERE Email = '''+EscapeApostrophe(Copy(Command, 10, length(Command)))+''' LIMIT 1;') then
WriteLn('RunModeError75: '+DB_Error)
else
if Not DB_NextRow(DB_ID) then begin
if _UsedIP.IndexOf(Player.IP) <> -1 then
Player.WriteConsole('You can send only 1 e-mail every '+IntToStr(USED_IP_TIME)+iif(USED_IP_TIME > 1, ' hours', ' hour')+' for 1 IP', COLOR_2)
else
if not File.Exists(PATH_TO_FILES+'mail.txt') then begin
GeneratedCode := MD5(FloatToStr(Now));
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Email = '''+EscapeApostrophe(GeneratedCode+' '+Copy(Command, 10, length(Command)))+''' WHERE Name = '''+EscapeApostrophe(Player.Name)+''';') then
WriteLn('RunModeError96: '+DB_Error)
else begin
MailTemplate := File.CreateStringList;
MailTemplate.Append('To: '+Copy(Command, 10, length(Command)));
MailTemplate.Append('Subject: Midgard e-mail confirmation');
MailTemplate.Append('');
MailTemplate.Append('Hello!');
MailTemplate.Append('');
MailTemplate.Append('Please confirm your e-mail by entering this command on our server:');
MailTemplate.Append('/confirmemail '+GeneratedCode);
MailTemplate.Append('');
MailTemplate.Append('Details');
MailTemplate.Append('Player Name: '+Player.Name);
MailTemplate.Append('Player IP: '+Player.IP);
MailTemplate.Append('');
MailTemplate.Append('Best regards');
MailTemplate.Append('Midgard Team');
MailTemplate.SaveToFile(PATH_TO_FILES+'mail.txt');
MailTemplate.Free;
Player.WriteConsole('Confirmation code has been sent to your mailbox', $4B7575);
_UsedIP.Append(Player.IP);
end;
end else Player.WriteConsole('Post office is busy, please wait at least 1min...', $FF0000);
end else Player.WriteConsole('This e-mail is already confirmed', $FF0000);
end else
Player.WriteConsole('You''re not logged in', COLOR_2);
DB_FinishQuery(DB_ID);
end else Player.WriteConsole('Wrong e-mail format', $FF0000);
if (Copy(Command, 1, 14) = '/confirmemail ') or (Command = '/confirmemail') then
if Copy(Command, 15, length(Command)) <> nil then begin
if Not DB_Query(DB_ID, 'SELECT Email FROM Accounts WHERE Name = '''+EscapeApostrophe(Player.Name)+''' LIMIT 1;') then
WriteLn('RunModeError75: '+DB_Error)
else
if Not DB_NextRow(DB_ID) then
Player.WriteConsole('Unregistered nickname', COLOR_2)
else
if _LoggedIn[Player.ID] then begin
TempString := DB_GetString(DB_ID, 0);
if TempString <> nil then begin
if not ExecRegExpr('^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$', TempString) then begin
if Copy(TempString, 1, 32) = Copy(Command, 15, Length(Command)) then begin
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Email = '''+EscapeApostrophe(Copy(TempString, 34, Length(TempString)))+''' WHERE Name = '''+EscapeApostrophe(Player.Name)+''';') then
WriteLn('RunModeError76: '+DB_Error)
else
Player.WriteConsole('E-mail confirmation successful', COLOR_1);
end else Player.WriteConsole('Invalid code', COLOR_2);
end else Player.WriteConsole('Your e-mail is already confirmed', COLOR_2);
end else Player.WriteConsole('You have no e-mail to be confirmed', COLOR_2);
end else Player.WriteConsole('You''re not logged in', COLOR_2);
DB_FinishQuery(DB_ID);
end else Player.WriteConsole('You have to enter the code that has been sent to your mailbox (/confirmemail <code>)', $FF0000);
if (Copy(Command, 1, 12) = '/passremind ') or (Command = '/passremind') then
if Copy(Command, 13, length(Command)) <> nil then begin
if Not DB_Query(DB_ID, 'SELECT Password, Email FROM Accounts WHERE Name = '''+EscapeApostrophe(Player.Name)+''' LIMIT 1;') then
WriteLn('RunModeError75: '+DB_Error)
else
if Not DB_NextRow(DB_ID) then
Player.WriteConsole('Unregistered nickname', COLOR_2)
else begin
TempString := DB_GetString(DB_ID, 1);
if ExecRegExpr('^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$', TempString) then begin
if Copy(Command, 13, length(Command)) = TempString then begin
if _UsedIP.IndexOf(Player.IP) = -1 then begin
MailTemplate := File.CreateStringList;
MailTemplate.Append('To: '+TempString);
MailTemplate.Append('Subject: Midgard password reminder');
MailTemplate.Append('');
MailTemplate.Append('Hello!');
MailTemplate.Append('');
MailTemplate.Append('Your password: '+DB_GetString(DB_ID, 0));
MailTemplate.Append('');
MailTemplate.Append('Best regards');
MailTemplate.Append('Midgard Team');
MailTemplate.SaveToFile(PATH_TO_FILES+'mail.txt');
MailTemplate.Free;
Player.WriteConsole('Password has been sent to your mailbox', $4B7575);
_UsedIP.Append(Player.IP);
end else Player.WriteConsole('You can send only 1 e-mail every '+IntToStr(USED_IP_TIME)+iif(USED_IP_TIME > 1, ' hours', ' hour')+' for 1 IP', COLOR_2);
end else Player.WriteConsole('Wrong e-mail', $FF0000);
end else Player.WriteConsole('You have no confirmed e-mail', COLOR_2);
end;
DB_FinishQuery(DB_ID);
end else Player.WriteConsole('You have to enter the e-mail assigned to this account (/passremind <e-mail>)', $FF0000);
if Command = '/maildel' then begin
if Not DB_Query(DB_ID, 'SELECT Email FROM Accounts WHERE Name = '''+EscapeApostrophe(Player.Name)+''' LIMIT 1;') then
WriteLn('RunModeError77: '+DB_Error)
else
if Not DB_NextRow(DB_ID) then
Player.WriteConsole('Unregistered nickname', COLOR_2)
else
if _LoggedIn[Player.ID] then begin
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Email = '''' WHERE Name = '''+EscapeApostrophe(Player.Name)+''';') then
WriteLn('RunModeError78: '+DB_Error)
else
Player.WriteConsole('You''ve deleted your e-mail', COLOR_1);
end else
Player.WriteConsole('You''re not logged in', COLOR_2);
DB_FinishQuery(DB_ID);
end;
if Command = '/aladd' then begin
if Not DB_Query(DB_ID, 'SELECT Name FROM Accounts WHERE Name = '''+EscapeApostrophe(Player.Name)+''' LIMIT 1;') then
WriteLn('RunModeError75: '+DB_Error)
else
if Not DB_NextRow(DB_ID) then
Player.WriteConsole('Unregistered nickname', COLOR_2)
else
if _LoggedIn[Player.ID] then begin
if Not DB_Update(DB_ID, 'UPDATE Accounts SET AutoLoginHwid = '''+EscapeApostrophe(Player.HWID)+''' WHERE Name = '''+EscapeApostrophe(Player.Name)+''';') then
WriteLn('RunModeError76: '+DB_Error)
else
Player.WriteConsole('You''ve set this machine "'+Player.HWID+'" for auto login', COLOR_1);
end else
Player.WriteConsole('You''re not logged in', COLOR_2);
DB_FinishQuery(DB_ID);
end;
if Command = '/aldel' then begin
if Not DB_Query(DB_ID, 'SELECT AutoLoginHwid FROM Accounts WHERE Name = '''+EscapeApostrophe(Player.Name)+''' LIMIT 1;') then
WriteLn('RunModeError77: '+DB_Error)
else
if Not DB_NextRow(DB_ID) then
Player.WriteConsole('Unregistered nickname', COLOR_2)
else
if _LoggedIn[Player.ID] then begin
if Not DB_Update(DB_ID, 'UPDATE Accounts SET AutoLoginHwid = '''' WHERE Name = '''+EscapeApostrophe(Player.Name)+''';') then
WriteLn('RunModeError78: '+DB_Error)
else
Player.WriteConsole('You''ve deleted machine "'+DB_GetString(DB_ID, 0)+'" for auto login', COLOR_1);
end else
Player.WriteConsole('You''re not logged in', COLOR_2);
DB_FinishQuery(DB_ID);
end;
if Command = '/bmadd' then begin
if Not DB_Query(DB_ID, 'SELECT Bookmarks FROM Accounts WHERE Name = '''+EscapeApostrophe(Player.Name)+''' LIMIT 1;') then
WriteLn('RunModeError75: '+DB_Error)
else
if Not DB_NextRow(DB_ID) then
Player.WriteConsole('Unregistered nickname', COLOR_2)
else
if _LoggedIn[Player.ID] then begin
TempPChar := DB_GetString(DB_ID, 0);
Bookmarks := File.CreateStringList;
Bookmarks.SetText(TempPChar);
if Bookmarks.Count < 10 then begin
Bookmarks.Append(Game.CurrentMap);
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Bookmarks = '''+EscapeApostrophe(Bookmarks.GetText)+''' WHERE Name = '''+EscapeApostrophe(Player.Name)+''';') then
WriteLn('RunModeError76: '+DB_Error)
else
Player.WriteConsole('Added map "'+Game.CurrentMap+'" to bookmarks', COLOR_1);
end else
Player.WriteConsole('Bookmarks limit reached', COLOR_2);
Bookmarks.Free;
end else
Player.WriteConsole('You''re not logged in', COLOR_2);
DB_FinishQuery(DB_ID);
end;
if Command = '/bmdel' then begin
if Not DB_Query(DB_ID, 'SELECT Bookmarks FROM Accounts WHERE Name = '''+EscapeApostrophe(Player.Name)+''' LIMIT 1;') then
WriteLn('RunModeError75: '+DB_Error)
else
if Not DB_NextRow(DB_ID) then
Player.WriteConsole('Unregistered nickname', COLOR_2)
else
if _LoggedIn[Player.ID] then begin
TempPChar := DB_GetString(DB_ID, 0);
if TempPChar <> nil then begin
Bookmarks := File.CreateStringList;
Bookmarks.SetText(TempPChar);
TempString := Bookmarks[Bookmarks.Count-1];
Bookmarks.Delete(Bookmarks.Count-1);
if Not DB_Update(DB_ID, 'UPDATE Accounts SET Bookmarks = '''+EscapeApostrophe(Bookmarks.GetText)+''' WHERE Name = '''+EscapeApostrophe(Player.Name)+''';') then
WriteLn('RunModeError76: '+DB_Error)
else
Player.WriteConsole('Deleted map "'+TempString+'" from bookmarks', COLOR_1);
Bookmarks.Free;
end else
Player.WriteConsole('Bookmarks are already cleared', COLOR_2);
end else
Player.WriteConsole('You''re not logged in', COLOR_2);
DB_FinishQuery(DB_ID);
end;
if Command = '/bmlist' then begin
if Not DB_Query(DB_ID, 'SELECT Bookmarks FROM Accounts WHERE Name = '''+EscapeApostrophe(Player.Name)+''' LIMIT 1;') then
WriteLn('RunModeError75: '+DB_Error)
else
if Not DB_NextRow(DB_ID) then
Player.WriteConsole('Unregistered nickname', COLOR_2)
else
if _LoggedIn[Player.ID] then begin
TempPChar := DB_GetString(DB_ID, 0);
Bookmarks := File.CreateStringList;
Bookmarks.SetText(TempPChar);
Player.WriteConsole('Your bookmarks:', COLOR_1);
for PosCounter := 0 to Bookmarks.Count-1 do
Player.WriteConsole(Bookmarks[PosCounter], COLOR_2);
Bookmarks.Free;
end else
Player.WriteConsole('You''re not logged in', COLOR_2);
DB_FinishQuery(DB_ID);
end;
end;
procedure OnPlayerSpeak(Player: TActivePlayer; Text: String);
var
PosCounter, j: Integer;
TempString: String;
TopName, TopAmount: TStringList;
begin
if Copy(Text, 1, 1) = '/' then
Player.WriteConsole('DO NOT TYPE "/" COMMANDS IN CHAT CONSOLE, PRESS "/" KEY TO ENABLE COMMANDS CONSOLE', $FF0000);
if Text = '!help' then begin
Player.WriteConsole('Welcome to Run Mode!', COLOR_1);
Player.WriteConsole('First of all, You have to make an account with command /account <password>,', COLOR_2);
Player.WriteConsole('otherwise Your scores won''t be recorded.', COLOR_2);
Player.WriteConsole('Please read !rules and !commands.', COLOR_2);
Player.WriteConsole('Medals are recounted on map change.', COLOR_2);
end;
if Text = '!commands' then begin
Player.WriteConsole('Run Mode commands 1/2:', COLOR_1);
Player.WriteConsole('!whois - Shows connected admins', COLOR_2);
Player.WriteConsole('!admin/nick - Call connected TCP admin', COLOR_2);
Player.WriteConsole('!track <nickname> - Check ping of certain player', COLOR_2);
Player.WriteConsole('!v - Start vote for next map', COLOR_2);
Player.WriteConsole('!ultv - Ultimate Vote commands', COLOR_2);
Player.WriteConsole('!elite - Shows 20 best players', COLOR_2);
Player.WriteConsole('!top <map name> - Shows 3 best scores of certain map', COLOR_2);
Player.WriteConsole('!top10|20 <map name> - Shows 10|20 best scores of certain map', COLOR_2);
Player.WriteConsole('!scores - Shows online players'' scores', COLOR_2);
Player.WriteConsole('!score <nickname> - Shows certain player''s score on current map', COLOR_2);
Player.WriteConsole('!last10|20scores - Shows last 10|20 scores', COLOR_2);
Player.WriteConsole('!last10|20 <nickname> - Shows last 10|20 scores of certain player', COLOR_2);
Player.WriteConsole('!mlr - MapListReader commands', COLOR_2);
Player.WriteConsole('!player <nickname> - Shows stats of certain player', COLOR_2);
Player.WriteConsole('!report <text> - Sends an e-mail to Midgard Admins', COLOR_2);
Player.WriteConsole('!mcommands - E-mail commands', COLOR_2);
Player.WriteConsole('!commands2 - Run Mode commands 2/2', COLOR_2);
Player.WriteConsole('/admcmds - Commands for admins 1/2', $FFFF00);
Player.WriteConsole('/admcmds2 - Commands for admins 2/2', $FFFF00);
Player.WriteConsole('!rme - Essential resource to optimize your runs & improve your times', $c53159);
end;
if Text = '!commands2' then begin
Player.WriteConsole('Run Mode commands 2/2:', COLOR_1);
Player.WriteConsole('/settings - Shows your account settings', COLOR_2);
Player.WriteConsole('/aladd - Set your machine to auto login', COLOR_2);
Player.WriteConsole('/aldel - Delete machine for auto login', COLOR_2);
Player.WriteConsole('/timer - Enable/Disable timer', COLOR_2);
Player.WriteConsole('/ron - Make "Reload Key" to reset the timer (Default)', COLOR_2);
Player.WriteConsole('/roff - Disable "Reload Key" function', COLOR_2);
Player.WriteConsole('/account <password> - Create an account', COLOR_2);
Player.WriteConsole('/login <password> - Login to your account', COLOR_2);
Player.WriteConsole('/logout - Logout from your account', COLOR_2);
Player.WriteConsole('/thief <id> <password> - Kick the player who''s taking your nickname', COLOR_2);
end;
if Text = '!rme' then begin
Player.WriteConsole('Visit the Runmode Movement Encyclopedia: https://bit.ly/2XLin0c', $c53159);
Player.WriteConsole('If you have any suggestions/questions, contact rusty via Discord @rusty#6917', $c53159);
end;
if Text = '!mcommands' then begin
Player.WriteConsole('E-mail commands:', COLOR_1);
Player.WriteConsole('/addmail <e-mail> - Adds e-mail for your account', COLOR_2);
Player.WriteConsole('/confirmemail <code> - Confirms your e-mail', COLOR_2);
Player.WriteConsole('/passremind <e-mail> - Reminds your password', COLOR_2);
Player.WriteConsole('/maildel - Deletes your e-mail', COLOR_2);
end;
if Text = '!ultv' then begin
Player.WriteConsole('Ultimate Vote commands:', COLOR_1);
Player.WriteConsole('!map - Shows previous, current and next map name', COLOR_2);
Player.WriteConsole('/votemap <mapname> - Starts vote for certain map', COLOR_2);
Player.WriteConsole('/votekick <playerid> - Starts vote to ban certain player for 1 hour', COLOR_2);
Player.WriteConsole('/voteres - Starts vote to restart current map', COLOR_2);
Player.WriteConsole('/voteprev - Starts vote for previous map', COLOR_2);
Player.WriteConsole('/votenext - Disabled, use !v instead', COLOR_2);
Player.WriteConsole('Type /yes to accept or /no to reject the vote', COLOR_2);
end;
if Text = '!mlr' then begin
Player.WriteConsole('MapListReader commands:', COLOR_1);
Player.WriteConsole('/maplist - Show MapList', COLOR_2);
Player.WriteConsole('/smaplist - Show sorted MapList', COLOR_2);
Player.WriteConsole('/searchmap <pattern> - Show all maps containing searched pattern', COLOR_2);
Player.WriteConsole('/showmapid - Show map index from MapList in SearchResult, do it before searching', COLOR_2);
Player.WriteConsole('/page <number> - Change page to <number>, type "/page 0" to close', COLOR_2);
Player.WriteConsole('You can also hold "Crouch"(forward) or "Jump"(back) key to change page', COLOR_2);
end;
{if Text = '!rules' then begin
Player.WriteConsole('Run Mode rules:', COLOR_1);
Player.WriteConsole('DO NOT troll.', COLOR_2);
Player.WriteConsole('DO NOT call admins without a reason.', COLOR_2);
Player.WriteConsole('DO NOT spam.', COLOR_2);
Player.WriteConsole('DO NOT cheat.', COLOR_2);
Player.WriteConsole('DO NOT verbal abuse other players, don''t be racist.', COLOR_2);
Player.WriteConsole('Have fun and good luck!', COLOR_2);
end;}
if Text = '!player' then begin
Players.WriteConsole(Player.Name+'''s stats', COLOR_1);
if Not DB_Query(DB_ID, 'SELECT Gold, Silver, Bronze, NoMedal, Points FROM Accounts WHERE Name = '''+EscapeApostrophe(Player.Name)+''' LIMIT 1;') then
WriteLn('RunModeError79: '+DB_Error)
else
if Not DB_NextRow(DB_ID) then
Players.WriteConsole('Unregistered nickname', COLOR_2)
else begin
Players.WriteConsole('Scores: '+IntToStr(DB_GetLong(DB_ID, 0)+DB_GetLong(DB_ID, 1)+DB_GetLong(DB_ID, 2)+DB_GetLong(DB_ID, 3)), COLOR_2);
Players.WriteConsole('Points: '+DB_GetString(DB_ID, 4), COLOR_2);
Players.WriteConsole('Gold: '+DB_GetString(DB_ID, 0), $FFD700);
Players.WriteConsole('Silver: '+DB_GetString(DB_ID, 1), $C0C0C0);
Players.WriteConsole('Bronze: '+DB_GetString(DB_ID, 2), $F4A460);
Players.WriteConsole('NoMedal: '+DB_GetString(DB_ID, 3), COLOR_2);
end;
DB_FinishQuery(DB_ID);
end;
if (Copy(Text, 1, 8) = '!player ') and (Copy(Text, 9, Length(Text)) <> nil) then begin
Players.WriteConsole(Copy(Text, 9, Length(Text))+'''s stats', COLOR_1);
if Not DB_Query(DB_ID, 'SELECT Gold, Silver, Bronze, NoMedal, Points FROM Accounts WHERE Name = '''+EscapeApostrophe(Copy(Text, 9, Length(Text)))+''' LIMIT 1;') then
WriteLn('RunModeError80: '+DB_Error)
else
if Not DB_NextRow(DB_ID) then
Players.WriteConsole('Unregistered nickname', COLOR_2)
else begin
Players.WriteConsole('Scores: '+IntToStr(DB_GetLong(DB_ID, 0)+DB_GetLong(DB_ID, 1)+DB_GetLong(DB_ID, 2)+DB_GetLong(DB_ID, 3)), COLOR_2);
Players.WriteConsole('Points: '+DB_GetString(DB_ID, 4), COLOR_2);
Players.WriteConsole('Gold: '+DB_GetString(DB_ID, 0), $FFD700);
Players.WriteConsole('Silver: '+DB_GetString(DB_ID, 1), $C0C0C0);
Players.WriteConsole('Bronze: '+DB_GetString(DB_ID, 2), $F4A460);
Players.WriteConsole('NoMedal: '+DB_GetString(DB_ID, 3), COLOR_2);
end;
DB_FinishQuery(DB_ID);
end;
if Text = '!scores' then begin
TopName := File.CreateStringList;
TopAmount := File.CreateStringList;
Player.WriteConsole('Online players'' scores', COLOR_1);
for PosCounter := 1 to 32 do
if Players[PosCounter].Active then begin
//Does not work, sqlite ver. too old :( ? if Not DB_Query(DB_ID, 'SELECT * FROM (SELECT ROW_NUMBER () OVER (ORDER BY Time, Date) Position, Time, Date, Id FROM Scores WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''') AS ScoresResultSet WHERE Account = '''+EscapeApostrophe(Player.Name)+''' LIMIT 1;') then
if Not DB_Query(DB_ID, 'SELECT * FROM (SELECT 1+(SELECT count(*) FROM Scores a WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''' AND (a.Time < b.Time OR (a.Time = b.Time AND a.Date < b.Date))) AS Position, Time, Date, Id, Account FROM Scores b WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''') WHERE Account = '''+EscapeApostrophe(Players[PosCounter].Name)+''' LIMIT 1;') then
WriteLn('RunModeError110: '+DB_Error)
else
if DB_NextRow(DB_ID) then begin
TopName.Append(ShowTime(DB_GetDouble(DB_ID, 1))+' by '+Players[PosCounter].Name+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 2))+' ['+DB_GetString(DB_ID, 3)+']');
TopAmount.Append(DB_GetString(DB_ID, 0));
for j := TopName.Count-1 downto 1 do
if StrToInt(TopAmount[j]) < StrToInt(TopAmount[j-1]) then begin
TopName.Exchange(j-1, j);
TopAmount.Exchange(j-1, j);
end else break;
end;
DB_FinishQuery(DB_ID);
end;
for PosCounter := 0 to TopName.Count-1 do
case StrToInt(TopAmount[PosCounter]) of
1 : Player.WriteConsole('[1] '+TopName[PosCounter], $FFD700);
2 : Player.WriteConsole('[2] '+TopName[PosCounter], $C0C0C0);
3 : Player.WriteConsole('[3] '+TopName[PosCounter], $F4A460);
else Player.WriteConsole('['+TopAmount[PosCounter]+'] '+TopName[PosCounter], COLOR_1);
end;
TopName.Free;
TopAmount.Free;
end;
if Text = '!score' then begin
Players.WriteConsole(Player.Name+'''s score', COLOR_1);
//Does not work, sqlite ver. too old :( ? if Not DB_Query(DB_ID, 'SELECT * FROM (SELECT ROW_NUMBER () OVER (ORDER BY Time, Date) Position, Time, Date, Id FROM Scores WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''') AS ScoresResultSet WHERE Account = '''+EscapeApostrophe(Player.Name)+''' LIMIT 1;') then
if Not DB_Query(DB_ID, 'SELECT * FROM (SELECT 1+(SELECT count(*) FROM Scores a WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''' AND (a.Time < b.Time OR (a.Time = b.Time AND a.Date < b.Date))) AS Position, Time, Date, Id, Account FROM Scores b WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''') WHERE Account = '''+EscapeApostrophe(Player.Name)+''' LIMIT 1;') then
WriteLn('RunModeError108: '+DB_Error)
else
if Not DB_NextRow(DB_ID) then
Players.WriteConsole('Score not found', COLOR_2)
else
case DB_GetLong(DB_ID, 0) of
1 : Players.WriteConsole('[1] '+ShowTime(DB_GetDouble(DB_ID, 1))+' by '+Player.Name+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 2))+' ['+DB_GetString(DB_ID, 3)+']', $FFD700);
2 : Players.WriteConsole('[2] '+ShowTime(DB_GetDouble(DB_ID, 1))+' by '+Player.Name+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 2))+' ['+DB_GetString(DB_ID, 3)+']', $C0C0C0);
3 : Players.WriteConsole('[3] '+ShowTime(DB_GetDouble(DB_ID, 1))+' by '+Player.Name+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 2))+' ['+DB_GetString(DB_ID, 3)+']', $F4A460);
else Players.WriteConsole('['+DB_GetString(DB_ID, 0)+'] '+ShowTime(DB_GetDouble(DB_ID, 1))+' by '+Player.Name+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 2))+' ['+DB_GetString(DB_ID, 3)+']', COLOR_1);
end;
DB_FinishQuery(DB_ID);
end;
if (Copy(Text, 1, 7) = '!score ') and (Copy(Text, 8, Length(Text)) <> nil) then begin
TempString := Copy(Text, 8, Length(Text));
Players.WriteConsole(TempString+'''s score', COLOR_1);
//Does not work, sqlite ver. too old :( ? if Not DB_Query(DB_ID, 'SELECT * FROM (SELECT ROW_NUMBER () OVER (ORDER BY Time, Date) Position, Time, Date, Id FROM Scores WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''') AS ScoresResultSet WHERE Account = '''+EscapeApostrophe(Player.Name)+''' LIMIT 1;') then
if Not DB_Query(DB_ID, 'SELECT * FROM (SELECT 1+(SELECT count(*) FROM Scores a WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''' AND (a.Time < b.Time OR (a.Time = b.Time AND a.Date < b.Date))) AS Position, Time, Date, Id, Account FROM Scores b WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''') WHERE Account = '''+EscapeApostrophe(TempString)+''' LIMIT 1;') then
WriteLn('RunModeError109: '+DB_Error)
else
if Not DB_NextRow(DB_ID) then
Players.WriteConsole('Score not found', COLOR_2)
else
case DB_GetLong(DB_ID, 0) of
1 : Players.WriteConsole('[1] '+ShowTime(DB_GetDouble(DB_ID, 1))+' by '+TempString+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 2))+' ['+DB_GetString(DB_ID, 3)+']', $FFD700);
2 : Players.WriteConsole('[2] '+ShowTime(DB_GetDouble(DB_ID, 1))+' by '+TempString+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 2))+' ['+DB_GetString(DB_ID, 3)+']', $C0C0C0);
3 : Players.WriteConsole('[3] '+ShowTime(DB_GetDouble(DB_ID, 1))+' by '+TempString+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 2))+' ['+DB_GetString(DB_ID, 3)+']', $F4A460);
else Players.WriteConsole('['+DB_GetString(DB_ID, 0)+'] '+ShowTime(DB_GetDouble(DB_ID, 1))+' by '+TempString+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 2))+' ['+DB_GetString(DB_ID, 3)+']', COLOR_1);
end;
DB_FinishQuery(DB_ID);
end;
if Text = '!top' then begin
Players.WriteConsole(Game.CurrentMap+' TOP3', COLOR_1);
if Not DB_Query(DB_ID, 'SELECT Account, Date, Time, Id FROM Scores WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''' ORDER BY Time, Date LIMIT 3;') then
WriteLn('RunModeError81: '+DB_Error)
else begin
While DB_NextRow(DB_ID) Do begin
Inc(PosCounter, 1);
if PosCounter = 1 then
Players.WriteConsole('[1] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', $FFD700);
if PosCounter = 2 then
Players.WriteConsole('[2] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', $C0C0C0);
if PosCounter = 3 then
Players.WriteConsole('[3] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', $F4A460);
end;
DB_FinishQuery(DB_ID);
end;
end;
if (Copy(Text, 1, 5) = '!top ') and (Copy(Text, 6, Length(Text)) <> nil) then begin
Players.WriteConsole(Copy(Text, 6, Length(Text))+' TOP3', COLOR_1);
if Not DB_Query(DB_ID, 'SELECT Account, Date, Time, Id FROM Scores WHERE Map = '''+EscapeApostrophe(Copy(Text, 6, Length(Text)))+''' ORDER BY Time, Date LIMIT 3;') then
WriteLn('RunModeError82: '+DB_Error)
else begin
While DB_NextRow(DB_ID) Do begin
Inc(PosCounter, 1);
if PosCounter = 1 then
Players.WriteConsole('[1] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', $FFD700);
if PosCounter = 2 then
Players.WriteConsole('[2] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', $C0C0C0);
if PosCounter = 3 then
Players.WriteConsole('[3] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', $F4A460);
end;
DB_FinishQuery(DB_ID);
end;
end;
if Text = '!top10' then begin
Player.WriteConsole(Game.CurrentMap+' TOP10', COLOR_1);
if Not DB_Query(DB_ID, 'SELECT Account, Date, Time, Id FROM Scores WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''' ORDER BY Time, Date LIMIT 10;') then
WriteLn('RunModeError83: '+DB_Error)
else begin
While DB_NextRow(DB_ID) Do begin
Inc(PosCounter, 1);
if PosCounter = 1 then
Player.WriteConsole('[1] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', $FFD700);
if PosCounter = 2 then
Player.WriteConsole('[2] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', $C0C0C0);
if PosCounter = 3 then
Player.WriteConsole('[3] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', $F4A460);
if PosCounter > 3 then
Player.WriteConsole('['+IntToStr(PosCounter)+'] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', COLOR_1);
end;
DB_FinishQuery(DB_ID);
end;
end;
if (Copy(Text, 1, 7) = '!top10 ') and (Copy(Text, 8, Length(Text)) <> nil) then begin
Player.WriteConsole(Copy(Text, 8, Length(Text))+' TOP10', COLOR_1);
if Not DB_Query(DB_ID, 'SELECT Account, Date, Time, Id FROM Scores WHERE Map = '''+EscapeApostrophe(Copy(Text, 8, Length(Text)))+''' ORDER BY Time, Date LIMIT 10;') then
WriteLn('RunModeError84: '+DB_Error)
else begin
While DB_NextRow(DB_ID) Do begin
Inc(PosCounter, 1);
if PosCounter = 1 then
Player.WriteConsole('[1] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', $FFD700);
if PosCounter = 2 then
Player.WriteConsole('[2] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', $C0C0C0);
if PosCounter = 3 then
Player.WriteConsole('[3] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', $F4A460);
if PosCounter > 3 then
Player.WriteConsole('['+IntToStr(PosCounter)+'] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', COLOR_1);
end;
DB_FinishQuery(DB_ID);
end;
end;
if Text = '!top20' then begin
Player.WriteConsole(Game.CurrentMap+' TOP20', COLOR_1);
if Not DB_Query(DB_ID, 'SELECT Account, Date, Time, Id FROM Scores WHERE Map = '''+EscapeApostrophe(Game.CurrentMap)+''' ORDER BY Time, Date LIMIT 20;') then
WriteLn('RunModeError83: '+DB_Error)
else begin
While DB_NextRow(DB_ID) Do begin
Inc(PosCounter, 1);
if PosCounter = 1 then
Player.WriteConsole('[1] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', $FFD700);
if PosCounter = 2 then
Player.WriteConsole('[2] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', $C0C0C0);
if PosCounter = 3 then
Player.WriteConsole('[3] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', $F4A460);
if PosCounter > 3 then
Player.WriteConsole('['+IntToStr(PosCounter)+'] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', COLOR_1);
end;
DB_FinishQuery(DB_ID);
end;
end;
if (Copy(Text, 1, 7) = '!top20 ') and (Copy(Text, 8, Length(Text)) <> nil) then begin
Player.WriteConsole(Copy(Text, 8, Length(Text))+' TOP20', COLOR_1);
if Not DB_Query(DB_ID, 'SELECT Account, Date, Time, Id FROM Scores WHERE Map = '''+EscapeApostrophe(Copy(Text, 8, Length(Text)))+''' ORDER BY Time, Date LIMIT 20;') then
WriteLn('RunModeError84: '+DB_Error)
else begin
While DB_NextRow(DB_ID) Do begin
Inc(PosCounter, 1);
if PosCounter = 1 then
Player.WriteConsole('[1] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', $FFD700);
if PosCounter = 2 then
Player.WriteConsole('[2] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', $C0C0C0);
if PosCounter = 3 then
Player.WriteConsole('[3] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', $F4A460);
if PosCounter > 3 then
Player.WriteConsole('['+IntToStr(PosCounter)+'] '+ShowTime(DB_GetDouble(DB_ID, 2))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1))+' ['+DB_GetString(DB_ID, 3)+']', COLOR_1);
end;
DB_FinishQuery(DB_ID);
end;
end;
if Text = '!last10scores' then begin
Player.WriteConsole('Last 10 scores', COLOR_1);
if Not DB_Query(DB_ID, 'SELECT Account, Map, Date, Time FROM Scores ORDER BY Date DESC LIMIT 10;') then
WriteLn('RunModeError85: '+DB_Error)
else
While DB_NextRow(DB_ID) Do
Player.WriteConsole('Map: '+DB_GetString(DB_ID, 1)+', Time: '+ShowTime(DB_GetDouble(DB_ID, 3))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 2)), COLOR_2);
DB_FinishQuery(DB_ID);
end;
if Text = '!last20scores' then begin
Player.WriteConsole('Last 20 scores', COLOR_1);
if Not DB_Query(DB_ID, 'SELECT Account, Map, Date, Time FROM Scores ORDER BY Date DESC LIMIT 20;') then
WriteLn('RunModeError85: '+DB_Error)
else
While DB_NextRow(DB_ID) Do
Player.WriteConsole('Map: '+DB_GetString(DB_ID, 1)+', Time: '+ShowTime(DB_GetDouble(DB_ID, 3))+' by '+DB_GetString(DB_ID, 0)+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 2)), COLOR_2);
DB_FinishQuery(DB_ID);
end;
{$IFDEF CLIMB}
if Text = '!elite' then begin
Player.WriteConsole('Points: Gold-12, Silver-6, Bronze-3, NoMedal-1', COLOR_1);
for PosCounter := 0 to _EliteList.Count-1 do
Player.WriteConsole(_EliteList[PosCounter], COLOR_2);
end;
{$ELSE}
if Text = '!elite' then begin
Player.WriteConsole('Points: Gold-25, Silver-20, Bronze-15, UpTo10th-10, 7, 5, 4, 3, 2, 1', COLOR_1);
for PosCounter := 0 to _EliteList.Count-1 do
Player.WriteConsole(_EliteList[PosCounter], COLOR_2);
end;
{$ENDIF}
if Text = '!last10' then begin
Player.WriteConsole(Player.Name+'''s last 10 scores', COLOR_1);
if Not DB_Query(DB_ID, 'SELECT Map, Date, Time FROM Scores WHERE Account = '''+EscapeApostrophe(Player.Name)+''' ORDER BY Date DESC LIMIT 10;') then
WriteLn('RunModeError86: '+DB_Error)
else
While DB_NextRow(DB_ID) Do
Player.WriteConsole('Map: '+DB_GetString(DB_ID, 0)+', Time: '+ShowTime(DB_GetDouble(DB_ID, 2))+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1)), COLOR_2);
DB_FinishQuery(DB_ID);
end;
if (Copy(Text, 1, 8) = '!last10 ') and (Copy(Text, 9, Length(Text)) <> nil) then begin
Player.WriteConsole(Copy(Text, 9, Length(Text))+'''s last 10 scores', COLOR_1);
if Not DB_Query(DB_ID, 'SELECT Map, Date, Time FROM Scores WHERE Account = '''+EscapeApostrophe(Copy(Text, 9, Length(Text)))+''' ORDER BY Date DESC LIMIT 10;') then
WriteLn('RunModeError87: '+DB_Error)
else
While DB_NextRow(DB_ID) Do
Player.WriteConsole('Map: '+DB_GetString(DB_ID, 0)+', Time: '+ShowTime(DB_GetDouble(DB_ID, 2))+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1)), COLOR_2);
DB_FinishQuery(DB_ID);
end;
if Text = '!last20' then begin
Player.WriteConsole(Player.Name+'''s last 20 scores', COLOR_1);
if Not DB_Query(DB_ID, 'SELECT Map, Date, Time FROM Scores WHERE Account = '''+EscapeApostrophe(Player.Name)+''' ORDER BY Date DESC LIMIT 20;') then
WriteLn('RunModeError86: '+DB_Error)
else
While DB_NextRow(DB_ID) Do
Player.WriteConsole('Map: '+DB_GetString(DB_ID, 0)+', Time: '+ShowTime(DB_GetDouble(DB_ID, 2))+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1)), COLOR_2);
DB_FinishQuery(DB_ID);
end;
if (Copy(Text, 1, 8) = '!last20 ') and (Copy(Text, 9, Length(Text)) <> nil) then begin
Player.WriteConsole(Copy(Text, 9, Length(Text))+'''s last 20 scores', COLOR_1);
if Not DB_Query(DB_ID, 'SELECT Map, Date, Time FROM Scores WHERE Account = '''+EscapeApostrophe(Copy(Text, 9, Length(Text)))+''' ORDER BY Date DESC LIMIT 20;') then
WriteLn('RunModeError87: '+DB_Error)
else
While DB_NextRow(DB_ID) Do
Player.WriteConsole('Map: '+DB_GetString(DB_ID, 0)+', Time: '+ShowTime(DB_GetDouble(DB_ID, 2))+' on '+FormatDateTime('yyyy.mm.dd hh:nn:ss', DB_GetDouble(DB_ID, 1)), COLOR_2);
DB_FinishQuery(DB_ID);
end;
end;
procedure OnJoin(Player: TActivePlayer; Team: TTeam);
begin
if Not DB_Query(DB_ID, 'SELECT AutoLoginHwid FROM Accounts WHERE Name = '''+EscapeApostrophe(Player.Name)+''' LIMIT 1;') then
WriteLn('RunModeError88: '+DB_Error)
else begin
if DB_NextRow(DB_ID) then begin
if String(DB_GetString(DB_ID, 0)) = Player.HWID then begin
Player.WriteConsole('Auto login machine - logged in', COLOR_1);
_LoggedIn[Player.ID] := TRUE;
end else
Player.WriteConsole('Account with that nickname already exists, type /login <password> to login', COLOR_1);
end else
begin
Player.WriteConsole('Welcome, Account with your nickname wasn''t found', COLOR_2);
Player.WriteConsole('Register it in order to save your scores, type /account <password>', COLOR_2);
Player.WriteConsole('Hold "Reload Key" to start running', $00FF00);
Player.WriteConsole('Read !help for more informations', COLOR_1);
end;
DB_FinishQuery(DB_ID);
end;
Player.WriteConsole('Remember to disable weapons'' menu to start faster (Tab key)', Random(0, 16777215+1));
end;
procedure OnJoinSpec(Player: TActivePlayer; Team: TTeam);
begin
SetLength(_Record[Player.ID], 0);
_JustDied[Player.ID] := False;
end;
procedure OnLeave(Player: TActivePlayer; Kicked: Boolean);
begin
_ShowTimer[Player.ID] := FALSE;
_LoggedIn[Player.ID] := FALSE;
SetLength(_Record[Player.ID], 0);
_JustDied[Player.ID] := False;
_GodMode[Player.ID] := False;
_FlightMode[Player.ID] := False;
end;
procedure OnBeforeMapChange(Next: String);
var
TimeStart: TDateTime;
i: Byte;
begin
for i := 1 to 32 do begin
_LapsPassed[i] := 0;
_CheckPointPassed[i] := 0;
end;
SetLength(_CheckPoint, 0);
_Laps := 0;
//Stop Replays
SetLength(_Replay, 0);
_ReplayTime := 0;
SetLength(_Replay2, 0);
_ReplayTime2 := 0;
Players.WriteConsole('Recounting medals...', COLOR_1);
TimeStart := Now;
RecountAllStats;
Players.WriteConsole('Done in '+ShowTime(Now - TimeStart), COLOR_1);
Players.WriteConsole('Generating elite list...', COLOR_2);
TimeStart := Now;
GenerateEliteList;
Players.WriteConsole('Done in '+ShowTime(Now - TimeStart), COLOR_2);
end;
procedure OnAfterMapChange(Next: string);
var
Ini: TIniFile;
TempStrL: TStringList;
i: Integer;
SpawnATeam, SpawnAFlag, SpawnBFlag: Boolean;
begin
Ini := File.CreateINI('~/maps_config.ini');
Ini.CaseSensitive := True;
if Ini.SectionExists(Game.CurrentMap) then begin
Players.WriteConsole('Map''s checkpoints found - loading...', COLOR_1);
TempStrL := File.CreateStringList;
Ini.ReadSection(Game.CurrentMap, TempStrL);
SetLength(_CheckPoint, (TempStrL.Count-1)/2);
for i := 0 to High(_CheckPoint) do begin
_CheckPoint[i].X := Ini.ReadFloat(Game.CurrentMap, IntToStr(i)+'X', 0);
_CheckPoint[i].Y := Ini.ReadFloat(Game.CurrentMap, IntToStr(i)+'Y', 0);
end;
_Laps := Ini.ReadInteger(Game.CurrentMap, 'Laps', 0);
if _Laps < 1 then
Players.WriteConsole('Checkpoints loaded - Sprint', COLOR_2)
else
Players.WriteConsole('Checkpoints loaded - Circuit', COLOR_2);
TempStrL.Free;
end else
begin
Players.WriteConsole('Map''s checkpoints not found', COLOR_1);
Players.WriteConsole('Trying to load default from alpha team and flags spawn points...', COLOR_1);
SetLength(_CheckPoint, 3);
for i := 1 to 255 do begin
if not Map.Spawns[i].Active then
break;
if (Map.Spawns[i].Style = 1) and (not SpawnATeam) then begin
SpawnATeam := True;
_CheckPoint[0].X := Map.Spawns[i].X;
_CheckPoint[0].Y := Map.Spawns[i].Y;
end;
if (Map.Spawns[i].Style = 6) and (not SpawnBFlag) then begin
SpawnBFlag := True;
_CheckPoint[1].X := Map.Spawns[i].X;
_CheckPoint[1].Y := Map.Spawns[i].Y;
end;
if (Map.Spawns[i].Style = 5) and (not SpawnAFlag) then begin
SpawnAFlag := True;
_CheckPoint[2].X := Map.Spawns[i].X;
_CheckPoint[2].Y := Map.Spawns[i].Y;
end;
end;
if not SpawnATeam then
Players.WriteConsole('Alpha Team spawn is missing', COLOR_1);
if not SpawnBFlag then
Players.WriteConsole('Bravo Flag spawn is missing', COLOR_1);
if not SpawnAFlag then
Players.WriteConsole('Alpha Flag spawn is missing', COLOR_1);
if SpawnATeam and SpawnBFlag and SpawnAFlag then begin
_Laps := 0;
Players.WriteConsole('Default checkpoints loaded - Sprint', COLOR_2);
end else
SetLength(_CheckPoint, 0);
end;
Ini.Free;
end;
function OnDamage(Shooter, Victim: TActivePlayer; Damage: Single; BulletId: Byte): Single;
begin
if (BulletId = 255) or (Shooter.ID = Victim.ID) then
Result := Damage
else
Result := 0;
if _GodMode[Victim.ID] then begin
if Damage*-1 = Abs(Damage) then
Result := Damage
else
Result := 0;
if Victim.Health - Damage <= 0 then begin
Victim.BigText(8, 'God', 120, $FF0000, 0.12, 320, 180);
Victim.Health := 150;
end;
end;
end;
procedure OnKill(Killer, Victim: TActivePlayer; BulletId: Byte);
begin
_JustDied[Victim.ID] := True;
end;
function OnBeforeRespawn(Player: TActivePlayer): TVector;
begin
if length(_CheckPoint) > 1 then begin
Result.X := _CheckPoint[0].X;
Result.Y := _CheckPoint[0].Y;
end;
end;
procedure OnAfterRespawn(Player: TActivePlayer);
begin
if length(_CheckPoint) > 1 then begin
if _JustDied[Player.ID] then begin
SetLength(_Record[Player.ID], 1);
_Record[Player.ID][0].X := Player.X;
_Record[Player.ID][0].Y := Player.Y;
_LapsPassed[Player.ID] := 0;
_CheckPointPassed[Player.ID] := 1;
_Timer[Player.ID] := Now;
{$IFDEF RUN_MODE_DEBUG}
_PingRespawn[Player.ID] := Player.Ping;
{$ENDIF}
_JustDied[Player.ID] := False;
end else
begin
SetLength(_Record[Player.ID], 0);
_LapsPassed[Player.ID] := 0;
_CheckPointPassed[Player.ID] := 0;
end;
end else
Player.BigText(5, 'Checkpoints error', 120, $FF0000, 0.1, 320, 300);
end;
procedure Init;
var
i: Byte;
DBFile: TFileStream;
Query: String;
begin
if not File.Exists(DB_NAME) then begin
DBFile := File.CreateFileStream;
DBFile.SaveToFile(DB_NAME);
DBFile.Free;
WriteLn('Database "'+DB_NAME+'" has been created');
if DatabaseOpen(DB_ID, DB_NAME, '', '', DB_Plugin_SQLite) then begin
Query := 'CREATE TABLE Accounts(Id INTEGER PRIMARY KEY,';
Query := Query+'Name TEXT,';
Query := Query+'Password TEXT,';
Query := Query+'Hwid TEXT,';
Query := Query+'Date DOUBLE,';
Query := Query+'Gold INTEGER DEFAULT 0,';
Query := Query+'Silver INTEGER DEFAULT 0,';
Query := Query+'Bronze INTEGER DEFAULT 0,';
Query := Query+'NoMedal INTEGER DEFAULT 0,';
Query := Query+'AutoLoginHwid TEXT,';
Query := Query+'Points INTEGER DEFAULT 0,';
Query := Query+'Email TEXT,';
Query := Query+'Bookmarks TEXT,';
Query := Query+'PremiumExpiry DOUBLE);';
DatabaseUpdate(DB_ID, Query);
DatabaseUpdate(DB_ID, 'CREATE TABLE Scores(Id INTEGER PRIMARY KEY, Account TEXT, Map TEXT, Date DOUBLE, Time DOUBLE);');
end;
end else
DatabaseOpen(DB_ID, DB_NAME, '', '', DB_Plugin_SQLite);
_UsedIP := File.CreateStringList;
//RecountAllStats;
_EliteList := File.CreateStringList;
GenerateEliteList;
for i := 1 to 32 do begin
_RKill[i] := TRUE;
Players[i].Team := 5;
Players[i].OnCommand := @OnPlayerCommand;
Players[i].OnSpeak := @OnPlayerSpeak;
Players[i].OnDamage := @OnDamage;
Players[i].OnKill := @OnKill;
Players[i].OnBeforeRespawn := @OnBeforeRespawn;
Players[i].OnAfterRespawn := @OnAfterRespawn;
end;
Game.OnAdminCommand := @OnAdminCommand;
Game.Teams[5].OnJoin := @OnJoinSpec;
Game.OnJoin := @OnJoin;
Game.OnLeave := @OnLeave;
Game.OnClockTick := @Clock;
Game.TickThreshold := 1;
Map.OnBeforeMapChange := @OnBeforeMapChange;
Map.OnAfterMapChange := @OnAfterMapChange;
end;
begin
Init;
Players.WriteConsole('Run Mode v3(1.7.1.1) by Savage', Random(0, 16777215+1));
end.
| 43.39743 | 390 | 0.643423 |
85c45079c59a9b2ccd8233f8d41435a8b690c238
| 1,992 |
pas
|
Pascal
|
Trysil/Data/FireDAC/Trysil.Data.FireDAC.pas
|
lminuti/Trysil
|
773b65746c8574790fe18bceb8eef8003c00f430
|
[
"BSD-3-Clause"
] | 1 |
2022-01-12T06:48:47.000Z
|
2022-01-12T06:48:47.000Z
|
Trysil/Data/FireDAC/Trysil.Data.FireDAC.pas
|
lminuti/Trysil
|
773b65746c8574790fe18bceb8eef8003c00f430
|
[
"BSD-3-Clause"
] | null | null | null |
Trysil/Data/FireDAC/Trysil.Data.FireDAC.pas
|
lminuti/Trysil
|
773b65746c8574790fe18bceb8eef8003c00f430
|
[
"BSD-3-Clause"
] | null | null | null |
(*
Trysil
Copyright © David Lastrucci
All rights reserved
Trysil - Operation ORM (World War II)
http://codenames.info/operation/orm/
*)
unit Trysil.Data.FireDAC;
interface
uses
System.Classes,
System.SysUtils,
FireDAC.UI.Intf,
FireDAC.Comp.Client,
Trysil.Data.FireDAC.Common;
type
{ TTDataFireDACConnectionPool }
TTDataFireDACConnectionPool = class
strict private
class var FInstance: TTDataFireDACConnectionPool;
class constructor ClassCreate;
class destructor ClassDestroy;
strict private
FManager: TFDManager;
public
constructor Create;
destructor Destroy; override;
procedure AfterConstruction; override;
procedure RegisterConnection(
const AName: String;
const ADriver: String;
const AParameters: TStrings);
class property Instance: TTDataFireDACConnectionPool read FInstance;
end;
implementation
{ TTDataFireDACConnectionPool }
class constructor TTDataFireDACConnectionPool.ClassCreate;
begin
FInstance := TTDataFireDACConnectionPool.Create;
end;
class destructor TTDataFireDACConnectionPool.ClassDestroy;
begin
FInstance.Free;
end;
constructor TTDataFireDACConnectionPool.Create;
begin
inherited Create;
FManager := TFDManager.Create(nil);
end;
destructor TTDataFireDACConnectionPool.Destroy;
begin
FManager.Free;
inherited Destroy;
end;
procedure TTDataFireDACConnectionPool.AfterConstruction;
begin
inherited AfterConstruction;
FManager.WaitCursor := TFDGUIxScreenCursor.gcrNone;
FManager.Open;
end;
procedure TTDataFireDACConnectionPool.RegisterConnection(
const AName: String;
const ADriver: String;
const AParameters: TStrings);
var
LParameters: TStrings;
begin
LParameters := TStringList.Create;
try
LParameters.Add('Pooled=True');
LParameters.Add(Format('DriverID=%s', [ADriver]));
LParameters.AddStrings(AParameters);
FManager.AddConnectionDef(AName, ADriver, LParameters);
finally
LParameters.Free;
end;
end;
end.
| 19.529412 | 72 | 0.768072 |
851209b6cc352a25faf653de305141a23a21eb8a
| 1,004 |
pas
|
Pascal
|
CodeForces.com/regular_rounds/#283/C.pas
|
mstrechen/cp
|
ffac439840a71f70580a0ef197e47479e167a0eb
|
[
"MIT"
] | null | null | null |
CodeForces.com/regular_rounds/#283/C.pas
|
mstrechen/cp
|
ffac439840a71f70580a0ef197e47479e167a0eb
|
[
"MIT"
] | null | null | null |
CodeForces.com/regular_rounds/#283/C.pas
|
mstrechen/cp
|
ffac439840a71f70580a0ef197e47479e167a0eb
|
[
"MIT"
] | null | null | null |
type star=array[1..100] of string;
hsar=array[1..100] of boolean;
var n,m:longint;
a:star;
b:hsar;
i,j:longint;
num:longint;
function ok(a:star; b:hsar; k,n:longint):boolean;
var lol:boolean;
i:longint;
begin
i:=2;
lol:=true;
while (i<=n) and lol do begin
if (a[i][k]<a[i-1][k]) and b[i] then lol:=false; inc(i); end;
ok:=lol;
end;
procedure mkhs(a:star; n,k:longint; var b:hsar);
var i:longint;
begin
for i:=2 to n do if a[i][k]=a[i-1][k] then b[i]:=true
else b[i]:=false;
end;
BEGIN
fillchar(b, sizeof(b),true);
num:=0;
readln(n,m);
for i:=1 to n do readln(a[i]);
i:=1;
while i<=m do
begin
if not ok(a,b,i,n) then
inc(num)
else
mkhs(a,n,i,b);
inc(i);
end;
write(num);
END.
| 24.487805 | 78 | 0.434263 |
f11a31e99dc27a73a90af14b6b817228c1aa99f6
| 34,370 |
dfm
|
Pascal
|
Source/frmUnitTests.dfm
|
hadi-f90/pyscripter
|
9db397754e77f238b00426234f64e334c9323349
|
[
"MIT"
] | 1 |
2018-09-07T09:35:23.000Z
|
2018-09-07T09:35:23.000Z
|
Source/frmUnitTests.dfm
|
hadi-f90/pyscripter
|
9db397754e77f238b00426234f64e334c9323349
|
[
"MIT"
] | null | null | null |
Source/frmUnitTests.dfm
|
hadi-f90/pyscripter
|
9db397754e77f238b00426234f64e334c9323349
|
[
"MIT"
] | null | null | null |
inherited UnitTestWindow: TUnitTestWindow
HelpContext = 467
Caption = 'Unit Tests'
ClientHeight = 451
ClientWidth = 262
Icon.Data = {
0000010001001010000001002000680400001600000028000000100000002000
0000010020000000000040040000000000000000000000000000000000000000
0000000000060D00004E3C1603802A1104740000002C00000000000000000000
0000000000000000001E250F036C3D1904830F00005B0000000E000000000000
000048120083FF6F1EE9FF8E3FEAFFAF6AEBB47A57CD00000028000000250000
002400000015A7714DBDFFB471EBFF9143EAFF7521EA5519009B000000050000
0028F16E24E1F97122E2ED7A35DBEE9A5EDCFFC896E2344040B4001626EB0011
23DF2A2B2B96FFCA9AE2EE9E64DCED7F39DBF77123DFFB7528EA020000420600
003CFF9144ECE66A22E4EA7A36DCED985CDAFFB78DDB72B8C0F600DBFFFF00CA
FFFF64AABCF4FFBD90DBED9C61DBEA7F3BDCE36921E2FF9448F20F0000560000
000BB36635C1FFAE6AFDDF7936E0F1975AD9EAB790E09CA59CFD000B11FF0009
11FF909E9AFBF2BD96DDEE9C5FD9DC7E3BE1FFA962F8C07541D3000000190000
00000000001EAE724CBEFFC590FED49A67E7D8AE8AE7B8A798FF1A2C2AFF0F21
1FFFB4A296FEDEB596E5D09C6AE8FFC18BFBB37A58CC0000002C000000000000
00000000000000000010966243B0FED4AAFCB5B39CF8CDDFD8FF62F5F7FF53E9
F5FFC5DBDBFFB8B4A0F5FFD3A2F6A07152C10000001B00000000000000000000
000000000000000000000000000EAE7855B7E9E6D4FFB4D5DBFF94EAFBFF7EDE
F7FFACD5DEFFEDE3CAFABD8864C7000000190000000000000000000000000000
000C0000002D00000A560000003D00020967B7B8B8FAE5FEF2FF33C5EEFF25C0
EEFFDEFEF7FFC8C5C0FB00060E780000044700000D5C000000310000000C0000
002600000035000000240000093E00000B500009197CC0D0D5FD77E3F9FF6EDF
FEFFCDD8DBFE000B167E00000647000000330000001E00000B310000001E0000
0000000000000000000000000000000000120005318102305CB73DB7FFFF41C0
FFFF063C6EC9000023820000000F000000000000000000000000000000000000
0000000000000000002E0000116000052A7D0000003600174AAB00B5FFFF00A7
FFFF00113CA90000023B0004267300000D590000002F00000000000000000000
00000000001900000E53000000180000000900000005021135CA2478B3FF236F
AAFF000924B700000002000000090000001600000E5400000017000000000000
000000000430000000180000000000000000000000000000001C0000167C0000
117B000000190000000000000000000000000000001B0000002C000000000000
0000000000040000000100000000000000000000000000000030000000230000
0026000000310000000000000000000000000000000100000004000000000000
0000000000000000000000000000000000000000051400000021000000000000
000000000022000000150000000000000000000000000000000000000000C3C1
00008001000000000000000000000000000080010000C0030000E00700000000
000000000000F00F0000C00300008C3100009C390000FC3F0000F99F0000}
ExplicitWidth = 278
ExplicitHeight = 490
PixelsPerInch = 96
TextHeight = 13
inherited BGPanel: TPanel
Width = 262
Height = 451
ExplicitWidth = 262
ExplicitHeight = 451
inherited FGPanel: TPanel
Width = 258
Height = 447
ExplicitWidth = 258
ExplicitHeight = 447
object ExplorerDock: TSpTBXDock
Left = 0
Top = 0
Width = 258
Height = 26
AllowDrag = False
DoubleBuffered = True
object ExplorerToolbar: TSpTBXToolbar
Left = 0
Top = 0
Align = alTop
AutoResize = False
DockMode = dmCannotFloat
FullSize = True
Images = vilImages
TabOrder = 0
Caption = 'ExplorerToolbar'
Customizable = False
object tbiRefresh: TSpTBXItem
Action = actRefresh
end
object tbiClearAll: TSpTBXItem
Action = actClearAll
end
object TBXSeparatorItem2: TSpTBXSeparatorItem
end
object tbiRun: TSpTBXItem
Action = actRun
end
object tbiStop: TSpTBXItem
Action = actStop
end
object TBXSeparatorItem1: TSpTBXSeparatorItem
end
object tbiSelectAll: TSpTBXItem
Action = actSelectAll
end
object tbiDeselectAll: TSpTBXItem
Action = actDeselectAll
end
object tbiSelectFailed: TSpTBXItem
Action = actSelectFailed
end
object TBXSeparatorItem7: TSpTBXSeparatorItem
end
object tbiCollapseAll: TSpTBXItem
Action = actCollapseAll
end
object tbiExpandAll: TSpTBXItem
Action = actExpandAll
end
end
end
object SpTBXSplitter1: TSpTBXSplitter
Left = 0
Top = 269
Width = 258
Height = 5
Cursor = crSizeNS
Align = alBottom
ParentColor = False
MinSize = 1
end
object Panel1: TPanel
Left = 0
Top = 26
Width = 258
Height = 243
Align = alClient
TabOrder = 1
object UnitTests: TVirtualStringTree
Left = 1
Top = 1
Width = 256
Height = 241
Align = alClient
BorderStyle = bsNone
Header.AutoSizeIndex = -1
Header.MainColumn = -1
Header.Options = [hoColumnResize, hoDrag]
HintMode = hmHint
Images = vilRunImages
IncrementalSearch = isAll
ParentShowHint = False
ShowHint = True
TabOrder = 0
TreeOptions.MiscOptions = [toCheckSupport, toFullRepaintOnResize, toInitOnSave, toWheelPanning]
TreeOptions.PaintOptions = [toHideFocusRect, toHideSelection, toHotTrack, toShowButtons, toShowDropmark, toShowRoot, toShowTreeLines, toShowVertGridLines, toThemeAware, toUseBlendedImages, toUseBlendedSelection]
TreeOptions.StringOptions = [toAutoAcceptEditChange]
OnChange = UnitTestsChange
OnChecked = UnitTestsChecked
OnDblClick = UnitTestsDblClick
OnGetText = UnitTestsGetText
OnGetImageIndex = UnitTestsGetImageIndex
OnGetHint = UnitTestsGetHint
OnInitChildren = UnitTestsInitChildren
OnInitNode = UnitTestsInitNode
Columns = <>
end
end
object Panel2: TPanel
Left = 0
Top = 274
Width = 258
Height = 173
Align = alBottom
TabOrder = 2
DesignSize = (
258
173)
object Bevel1: TBevel
Left = 8
Top = 58
Width = 242
Height = 5
Anchors = [akLeft, akTop, akRight]
Shape = bsTopLine
end
object Label2: TLabel
Left = 7
Top = 62
Width = 73
Height = 13
Caption = 'Error Message:'
Color = clNone
ParentColor = False
Transparent = True
end
object ModuleName: TLabel
Left = 7
Top = 1
Width = 88
Height = 13
Caption = 'No Module Loaded'
Font.Charset = DEFAULT_CHARSET
Font.Color = clBtnText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
Transparent = True
end
object lbFoundTests: TLabel
Left = 172
Top = 1
Width = 66
Height = 13
Alignment = taRightJustify
Anchors = [akTop, akRight]
Caption = 'Found 0 tests'
Font.Charset = DEFAULT_CHARSET
Font.Color = clBtnText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
Transparent = True
end
object lblRunTests: TLabel
Left = 7
Top = 19
Width = 55
Height = 13
Caption = 'Run 0 tests'
Font.Charset = DEFAULT_CHARSET
Font.Color = clBtnText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
Transparent = True
end
object lblFailures: TLabel
Left = 7
Top = 37
Width = 96
Height = 13
Caption = 'Failures/Errors : 0/0'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clBtnText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
ParentColor = False
ParentFont = False
Transparent = True
end
object SpTBXPanel1: TPanel
Left = 1
Top = 85
Width = 256
Height = 87
Align = alBottom
Anchors = [akLeft, akTop, akRight, akBottom]
TabOrder = 0
object ErrorText: TRichEdit
Left = 1
Top = 1
Width = 254
Height = 85
Align = alClient
BorderStyle = bsNone
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Shell Dlg 2'
Font.Style = []
Constraints.MinHeight = 10
ParentFont = False
PlainText = True
ReadOnly = True
ScrollBars = ssBoth
TabOrder = 0
Zoom = 100
end
end
end
end
end
inherited DockClient: TJvDockClient
TopDock = False
BottomDock = False
Top = 48
end
object DialogActions: TActionList
Images = vilImages
Left = 152
Top = 48
object actRefresh: TAction
Category = 'Commands'
Caption = '&Refresh'
Hint = 'Refresh tests|Extract tests from active module'
ImageIndex = 3
ImageName = 'Item40'
OnExecute = actRefreshExecute
end
object actRun: TAction
Category = 'Commands'
Caption = '&Run'
Hint = 'Run selected tests'
ImageIndex = 5
ImageName = 'Item52'
OnExecute = actRunExecute
end
object actStop: TAction
Category = 'Commands'
Caption = '&Stop'
Hint = 'Stop Testing'
ImageIndex = 4
ImageName = 'Item41'
OnExecute = actStopExecute
end
object actSelectAll: TAction
Category = 'TestTree'
Caption = 'Select &All'
Hint = 'Select all tests'
ImageIndex = 6
ImageName = 'Item105'
OnExecute = actSelectAllExecute
end
object actDeselectAll: TAction
Category = 'TestTree'
Caption = '&Deselect All'
Hint = 'Deselect all tests'
ImageIndex = 7
ImageName = 'Item106'
OnExecute = actDeselectAllExecute
end
object actSelectFailed: TAction
Category = 'TestTree'
Caption = 'Select Fai&led'
Hint = 'Select all failed tests'
ImageIndex = 8
ImageName = 'Item107'
OnExecute = actSelectFailedExecute
end
object actExpandAll: TAction
Category = 'TestTree'
Caption = 'Ex&pand All'
Hint = 'Expand all test nodes'
ImageIndex = 1
ImageName = 'Item29'
OnExecute = actExpandAllExecute
end
object actCollapseAll: TAction
Category = 'TestTree'
Caption = '&Collapse All'
Hint = 'Collapse all test nodes'
ImageIndex = 2
ImageName = 'Item30'
OnExecute = actCollapseAllExecute
end
object actClearAll: TAction
Category = 'Commands'
Caption = '&Clear All'
Hint = 'Clear all tests'
ImageIndex = 0
ImageName = 'Item15'
OnExecute = actClearAllExecute
end
end
object icRunImages: TImageCollection
Images = <
item
Name = 'UnitTests\Item1'
SourceImages = <
item
Image.Data = {
89504E470D0A1A0A0000000D49484452000000100000001008060000001FF3FF
61000000524944415478DA63FCFFFF3F032580717019F0E8D1A398AB57AF3AE0
D3A0ADADBD5F4E4E6E295603B66FDF3EC7C6C626199F01478E1C99EBE9E99932
6AC0F035009890A28109C9119F017813123960E00D00006F7B7FE192F60CCF00
00000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000018000000180806000000E0773D
F80000005F4944415478DA63FCFFFF3F032D01E3A80583D382FEFEFE1D5FBE7C
1127C5202121A1A7D9D9D93E4459D0DCDC7CBEA0A0C080140B264C9870A1B6B6
D670D482510B462D18B5805A164C9D3A75CBBB77EFA449B180A4C28E9A60D482
81B700007AF8B7D1B079C78D0000000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000020000000200806000000737A7A
F4000000974944415478DA63FCFFFF3FC34002C651078C3A60D03A0028CEFCE7
CF1F794A2D606262FAC9CCCCFC946407FCFDFB57CAD4D4F4B69696D6374A1C70
EDDA35AE3367CE28021DF28A64076464649CEBEBEB13A7C4014545452F67CC98
61040C8567A30E1875C0A803461D30EA8051078C3A606839E0DFBF7F62262626
F707AC41020D0569A043D8297100D94D327A8151078C3A60C01D0000790A47D0
A3691BD70000000049454E44AE426082}
end>
end
item
Name = 'UnitTests\Item2'
SourceImages = <
item
Image.Data = {
89504E470D0A1A0A0000000D49484452000000100000001008060000001FF3FF
61000000534944415478DA63FCFFFF3F032580717019F0FCF9AB98FBF73F38E0
D3A0A424B85F4242742956038E1DBB35C7DA5A2D199F01478FDE9A6B65A59632
6AC0F035E0C58BD7D1F7EEBD77C46700DE84440E18780300BA3F7FE197CD8EC5
0000000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000018000000180806000000E0773D
F80000005E4944415478DA63FCFFFF3F032D01E3A80583D38233676EEDF8F081
4D9C148304047E3D353151F321CA823D7B1E9C7775553020C582DDBB1F5C7071
51301CB560D482510B462DA09605C0C26E0BB0B09326C502920A3B6A82510B06
DE02001DFFB7D127B34C0F0000000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000020000000200806000000737A7A
F4000000964944415478DA63FCFFFF3FC34002C651078C3A60D03A0028CEFCF7
EF5F798A2D6064FCC9CCCCFC946407002D977AFFFEE7ED5BB77E7CA3C4016A6A
1C5C42421C8A4C4C4CAF4876C09123EFCF3938888853E2800307DEBCB4B11134
0286C2B351078C3A60D401A30E1875C0A803461D30B41CF0EFDF3FB177EF7EDC
1FB006093414A481F2EC943880EC2619BDC0A803461D30E00E000014D247D02F
AC847B0000000049454E44AE426082}
end>
end
item
Name = 'UnitTests\Item3'
SourceImages = <
item
Image.Data = {
89504E470D0A1A0A0000000D49484452000000100000001008060000001FF3FF
61000000534944415478DA63FCFFFF3F032580717019F0FCD5F398FB1FEE3BE0
D3A024A8B45F4254622956038EDD3A36C75ACD3A199F01476F1D9D6BA5669532
6AC0F035E0C5EB17D1F7DEDF73C46700DE84440E18780300BA3F7FE1F94D2B7C
0000000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000018000000180806000000E0773D
F80000005E4944415478DA63FCFFFF3F032D01E3A80583D38233B7CEECF8C0F6
419C1483047E093C355133F121CA823D0FF69C7755703520C582DD0F765F7051
70311CB560D482510B462DA09605C0C26E0BB0B09326C502920A3B6A82510B06
DE02001DFFB7D1A0CE8D2D0000000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000020000000200806000000737A7A
F4000000964944415478DA63FCFFFF3FC34002C651078C3A60D03A0028CEFCF7
EF5F798A2D6064FCC9CCCCFC946407002D977AFFF3FDED5B3F6E7DA3C4016A1C
6A5C421C428A4C4C4CAF4876C091F747CE3988388853E280036F0EBCB411B431
0286C2B351078C3A60D401A30E1875C0A803461D30B41CF0EFDF3FB1773FDEDD
1FB006093414A481F2EC943880EC2619BDC0A803461D30E00E000014D247D0E2
F430C30000000049454E44AE426082}
end>
end
item
Name = 'UnitTests\Item4'
SourceImages = <
item
Image.Data = {
89504E470D0A1A0A0000000D49484452000000100000001008060000001FF3FF
61000001DE4944415478DA63FCFFFF3F032580119F01AB572F9A77E3C645B59A
9A1E174646C61F2419B07EFDB259BF7F5747686A3EE7DEB021F3444D4D1FC890
EF441900D31C16F68017C4BF7C99FD1F2E43300C00399B89A93E243818A21906
2E5CE0FCBB654BE6F19A9A5E5B9C06C0340705423503A560D21B36CA7EFDFDA7
694D787842025603D6AF5B36EBC7FBEA086F674CCDDBF60135B3566D8A8BCF88
C21906BB776FEBB975BC2839C0E1A600035423486AF729D9AFD72FB9DDE3F8C6
C350B3A22B848D8DED164E2FECDFB7ABE3CCD6FC745F831B0220E1C3D765BFDE
7DE47E4F60B7B412DF6B51EE8F7E4FAF16AFAA0F656767BF8E331041869CDE98
9FCECFFE95F5C24FF7FBEC071825532FE50B33323032FC03C2A3013BAE24AECC
0B86B9046B34EEDABEA56FF39E6D4E6BE233543EB1B07196452CFA507BB94588
898109E8BBFF0C0B4AA7EC49ECCA75C569C09EE3C75BA379780A5EE9EA7281F8
725BB67E2D9A7AE169CE8E72B5E51173CE472C4E096061617984D580EB376F65
04DD7BDEFB56439F8B11282572EBEAD7E982ACBD36A6265397B7CC9E1B5E959C
09D4FC04671800F9ECBD7316AE5B2164ECC5FDFED9F77A75EE894EB636950C38
00562F00C538DBA6CEDE6867AC7FDCD6D2BC9E010FC0999980E24CC074FF8F81
000000FFA106F0F77649CE0000000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000018000000180806000000E0773D
F8000003164944415478DA63FCFFFF3F032D01232916FCFCF953F3CD9B375AD2
D2D26BA96EC18F1F3FB43D3DED0FFDFDFB9163E6CC75259A9A5AD3A96601D0E5
1A5E5EF6472A2A2E0A1918FC608C8BD3F9DCD9B9A4564F4F7F22C516201BEEEA
FA831124F6FA350303B196E0B5009BE13040AC25382DC06738299660B50018A1
3A1E1EB687EAEB2F0B383AFEC46A380CAC59C3F9BFBF5FE7C391232785191919
FF13B400E6F2F2D28B42CE8E482EFF0F465002421F3AC2FEBFA955F7C38E9D87
ED3938382E13F401D8704FFB23451917851C6C7E30FE47320CC51220387A82FD
7FFB64DD0F3B77E1361CC382AACAD2C3FF3ECFB12A49FBC0043309C58350F6B1
73ECFF7B66AB7F0A700E3C51D4521F000C9A1F4459F0E7CF1F593F1FD793FE96
67C5BC6C3E33630B9A9397D9FF4F5CA9FE499747ED35CB417E25890CA1A35593
3BDD81967C272A92C19678BB9EF4D43B2BE66E8C6AC9999BECFFA76F53FFA4CF
ABF15A729F960A3B0317C347D6D77F39D3188EE1B2046B2A0259E20BB4C45DED
AC98AB01C492B377D8FFCFD8ABFE59F3AFDC179F73F1521C0CDC404B21F035EB
D3BFAF331F1D2999D0EC811E5C38F301B225423CBF98661ED0FC24666AFBFAC3
915BD2797762998C3FDBB2FF6740C047ACF7FE9E4E3B70AC7872138A4FF0E664
A02572404B4E7CFCF4814B1C68F886A62615063E3E065713BFEF8DB70A992DBF
3AB321ABBFC37AF5EFAED2CD7BB25A2B3C88B20004BE7EFD6A1C5D51B162636B
2BD87030F8F78FC1CDCCFF5BCDAD5C66DBCF6EEC602120ECB6A87894B1BD3A96
5F80FF105116FCFDFB5722AEBE7ECFB2B2326DB8E150A0B568D1BBC0BDE71F7A
6CF552B77AEBCC85CD70BC16FCFBF74F34A1BA76DF96A41C9DFFDCBC0C8CD0A4
042A0C9436AF7ED76FA835D1DADCBC79F984392BAE2C3B6555B1A7278A8F9FFF
3051A9086A8150664DFD9EBD4E91864CBC02F0B42A7160D3BB3607C389361616
4DE014FCFF3F23D0A7B22C2C2C8FB099833788809608E654D6EE3DA3EE6DC8C2
27C8C07B61F7BB3A6FB389D69610C389010423196889484E45EDAE9B7FB8149B
429DFB49319C280B6096DCB97B37404D55750E2986136D012500008713D4E0EA
1F74C00000000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000020000000200806000000737A7A
F40000042B4944415478DA63FCFFFF3FC34002C621EB00A03EC6952B57CE5CB0
608EF7E6CDDB6D595959EFD1CD0120CB972F5F36BBB5B5264E5DFD17E3972FAA
6FB66EDD6D4D8E23487600C8F2B56BD74CABAF2F4B5EB2E409AB8ECE1F86E464
A9DFCF9E29BFDBBE7D2FC8117769E60074CB0D0DFF80C57FFF6620DB11443B00
97E53040AE2388720021CB2971044107106B39B98EC0EB00586A6F69A98A5FBA
F4190B21CB61E0E74F0686A828A93F5FBF6ABEDABE7DB71C2323E35F921D809C
D588F13932B8708199212646F6776565F3E2E8E8986492430039D817CE7DC26A
A00FB5FC3FB21A744D10EACA556686F814D9DF25A50DCB6263E39280BEFF4792
03E096D79525CF99FC84555FFB0FC2FCFF9816223BE6EA0D66869402D9DFA544
5A8ED501DBB76FEB292ACCCA9FD9F9944557E30F8685B81C72E526334366B5EC
EFA4B8F49D45E5E5FEC4588ED501E7CF9F2F0A0AF2EFEA287EC9EC60F68B389F
DF6166C86F97FDED6EE97AF1F2F6FDEAA5D37AE7B805F81591E500103873E64C
696868507B53C64B667BA35F787D7FF3213343D144D9DF1ED6EE179EEDBBA5AC
72CF5AE891ECF98F011D31CB03A22232C97200DC112141ED75312F996DF47F61
F5FDAD27CC0C157321963FDF775B59EB9EA310D048B0FC1DD9E31FFD897004DE
7200E688CAA097CCD6DABF50E46E3F6366A85906B4DCC6E3C2BB7D0F959DEF45
0931323041DD09812764B77C74E908043A223C932C07E07204CC720B6BC7EB57
176FD2EEF8B59A998D8103C572187BBDDCEC0FEE1343E6BB05F81691E5007447
8809FE055BEEE4EA7BE1F0FFFFCAEF0424F82C7AB732747F5FC6C2CAC08E6239
0C2E90EDF9A8DF61BDDC2F2A2C932C0780C0F1E3C7ABA322C31BD9D998FEBB7B
F99F3BF4F79FCA85FE7E2106161606B9EAC6BF36FDFBFECFFBBE83859D8113AB
FE76B9A20FD6B3BCA7DBB93B5791E500982396AF5CE17718C9721890A969FC6B
DBB7FBFFFCEFBB311CF197E10F438542E2FBE4CD15351A3ADAD3C876C0E973E7
CA52972C29BFD8DD2DC4C0CC8C212F5755FFC766D2C1FFF3BE6E678539E21FD0
FA2AA5E47751ABF25BF58C0DFBC88E8233E7CE95A6012D3FDFD52D0CB1FC3F22
5B82E83FBF19F48B0ADF5759DBAE3DD0B83CA0F7D632117660C2C46739D10EB8
70E95241EAF499B5376BDB85185998E11633C24AA6BF7F19D45A6BDE4D4F4D6A
373634EC79FAF871589747D164B66FECAC491B2BEA34F574A6E0329B980609B3
BDBBE7B37BC5CD624C320A48964353FB9F3F0CD2939BDECD2ACA69D0D5D1990C
D3F7ECC99390AF5FBE0AAA6AA8CFC6673E5121F0E7CF1F79FF98D843F77D32E4
98A5E5A13E075A0EF4B9C092EE77130AD2C13E272A2EC97100CC110191B1875E
DA27C8B189CB31FCFFF797816DF3A477BDC599645B4E9203A08E50003AE2E04B
DB5839EE531B28B69C640780C0AF5FBF549C3DBC8F4D9BD4DF8C1CE774730008
00F570031B1C5F29B59C6C07501300002818B7DF4184F1050000000049454E44
AE426082}
end>
end
item
Name = 'UnitTests\Item5'
SourceImages = <
item
Image.Data = {
89504E470D0A1A0A0000000D49484452000000100000001008060000001FF3FF
61000000534944415478DA63FCFFFF3F032580717019F0EAF9F3980FF7EF3BE0
D320A8A4B45F5442622956036E1D3B3647CDDA3A199F01B78E1E9DAB66659532
6AC0F035E0F58B17D1EFEFDD73C46700DE84440E18780300BA3F7FE121D6554A
0000000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000018000000180806000000E0773D
F80000005E4944415478DA63FCFFFF3F032D01E3A80583D3825B67CEEC60FBF0
419C14837E09083C553331F121CA82077BF69C5770753520C58207BB775F5070
71311CB560D482510B462DA09605C0C26E0BB0B09326C502920A3B6A82510B06
DE02001DFFB7D1D1D578620000000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000020000000200806000000737A7A
F4000000964944415478DA63FCFFFF3FC34002C651078C3A60D03A0028CEFCF7
EF5F798A2D6064FCC9CCCCFC946407002D97FAF9FEFDED1FB76E7DA3C4011C6A
6A5C1C42428A4C4C4CAF4876C0FB2347CE8938388853E28037070EBC14B4B131
0286C2B351078C3A60D401A30E1875C0A803461D30B41CF0EFDF3FB11FEFDEDD
1FB006093414A481F2EC943880EC2619BDC0A803461D30E00E000014D247D065
45168F0000000049454E44AE426082}
end>
end
item
Name = 'UnitTests\Item6'
SourceImages = <
item
Image.Data = {
89504E470D0A1A0A0000000D49484452000000100000001008060000001FF3FF
61000002494944415478DA63FCFFFF3F030C00D92CAF5EDC8B1297545EC44024
60841900D27CFB4CFB1A19A93ED7A76F272F54D58BCC22DA002066BE7DB6638D
9246A30F0BCF4F96EFAF05BF3F793A6189AA415C1A4103FEFDFB07B4B9659DB2
76B31733D76F6698C49B2BBA2FF8D44E3BB1B1B15F07F1EF5F3953F2E1D47A0F
83C4163F4646C66F70036E1C6FDA2425D6ECC5C00AD40CF20D107F7AADFD9249
624D8DA48CC61C88E6D3A55C5B4BAB45D9BFF15FE2B43DA29FD6E30934E40BD8
809BE7564D667F9399C4F0FF2D1748F3BFBFC2DFCFBF8ABDF4E09DEC176565E5
3B9CAFAF29E9BDDB6D2AC1F14D00A4E1EF9F3F0CD734F3E7E87AC6A6C2C3E0D6
B93593FEDEC848666213FCFE4DB271CB7F4E8DA7A74F9FB63692E57BA870AA27
4894E5330FC869FFFEFE67B8241DB24F3FB9DD17E60D782CDCBEB0BE9F5744EB
8A848CFADC4F9F3E39ECD9B327C6D7D7B7FD566FF47AED675B74FFFD6360B8A4
9E74443F6732DCF928062003980141414129BF7EFD52BBDD1DBEF6B790D22BFD
8C1E5FE40024CA0010FFCF9F3FB2CCCCCC9F569E38D1166E61510134E4334906
00D5B0D6EDD9B3B1D5D2D223E3D8B1A3535D5DBD81867CC267807D6161E14C3B
3BBBAB7FFFFF679AFFEF9FD9D1A828C9FF1C1C8C0C7FFF3214EDDEBDAFD7C3C3
19A701A064FDFEFD7BF7BF7FFFB2B59E38593AC7D4D682818D8D9111A854EECE
F577ABC485AAB5151466E03400C920B6E6AD3B372CE553F764666461107CF7E0
DD6C3D996A2D45C51978C300CD108ED64DDBD7EDFBC86231C556B50A59335106
C00C79FDEEBD9398B0D03674390050B939F0F945A1020000000049454E44AE42
6082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000018000000180806000000E0773D
F8000003794944415478DA63FCFFFF3F0336F0E7CF1F79161696870C1402466C
16BC7BF33488F196C3AC375CCD2B550D22B2A96AC1FBB7CFFDFFDE7799256274
4DECE36DB90FAFBE35AF56358C4BA38A05C886333041C43EDEA4CC12B805A060
F9F7C07D9A88F15571064654451F6FCA7E7CFDB36F918A5E481EBA01EF5FBFF4
E1171239CDC4CCFC12A705F80C07819FCF797F3EBA9F7158D5AACB1559FCE9BD
9B295FE725B67D65177DA75FB5CE1E9B258CEFDE3CF3FF73DB65168FE235B1FF
20C3612106A4419EFBF389F7E7AB37E94754ACBA3C1919197FC3343EBB7F2BE9
CBBCE47635D1DF627F7EFF66B8FC45EA965ECD06076666E6E728163CDB67F688
5DE094EC5F06888130C3C1D44FDE9F1FFFA51E55B5EEF1C065384C0C6CC93799
9B7A55EB1C912D61FCFDFBB7FCB3832EFB187E1C54FAF30F61382B23D3FFB75F
15BF2F3EE5F5EEF59B0F82121212CF40E2F23FEE72BBF13DE35415FB2F881E1C
F75FFDFBC09EBCA4584A516D1E4A1C8032D5D37D2EFB7E3E3FA8F4FB0F03033B
37F7AF3F022E8FFEC9B5CE7BF6ECB9FEBE7DFB5C626363BBDEDD38692A76B4C7
4355E43F0F240C19E05E7EF88DF7DD2FBFAEC9AAA60E0D585311D08B4ACF0E38
EFF9FFF19CF40FD1B4A36A76BDEEA06079FAF4695C474747EDE4C99355CF4C2D
38A07D7FA52D27CB7F26B80940FD0FFE8BBDFB133665A28A897D13CE640AB3E4
EE8525D56A260919B03047B600A896FDECF4E2ED9A9766DA7133FD6606BB9C5D
E1DDAFA85940973B363060018CB8CA22785244B200E2E0FFECE7A615EED0383F
CDF60D97ECC75FB173701A4E9605504B38CF4ECEDD296015BA075BB0506C0132
B8F3F87142E6DEBD55DB63625C80A5EF23AA5A70F7C993B8E04B973A2EBABA4A
BAAC5B777B5B5090072B2BEB3DAA580037DCCB4B122C00CC68D82C2168C1F3E7
CFA32C2C2CE67B7878BC8589DDE3E1E13CE6E0C0FBCDD7971945F1CF9F0C9E2B
56DCD8161FAF49B40540798E870F1FC6FEFDFB9705C43F75FF8179F5E72F814F
DCBDF818FF831540CAC77FFF19F4F6EE78BAD9CE26435C58780BD1162083BFFF
FE899BCE5B74E1859D9F04DCE0FF2043FE31C85F38F474BD9B439A98B0F03692
E2001D9CBF75AB20F7D4B5CA4F9206628C20D3812E177A7AFAE90A1F970C7111
84CBC9B6006CC9CD5B0585872F57FEE6D314E3FC78F1E9D24037AC86936D0108
9CBB79AB3067F7C1920D9141A9E8C142150B4000A8570058667DC0A706003D10
15EF63EDF90E0000000049454E44AE426082}
end
item
Image.Data = {
89504E470D0A1A0A0000000D4948445200000020000000200806000000737A7A
F40000047D4944415478DAC5956D4C1B651CC0EFB8BE494B5B5A4B670F2896A1
31050965C29C9B0B2306B761C56C98980D5C115C4C5C48FC32BF6830247E32F1
8B43A60667C822224B3663DC5871C39641A92201716313182DD71747D96869AF
F4E5AEDE95DEB8762D655B8BFFE4E9DD3D2FFDFD9EE7FFDC3D60281402FECF00
930910ED421CC77810C440B65C00C771B16DE8150307B00AF83B27763359AC5B
5B2640CEDCA2DF6F9016EA140CDE2AE3DE44D112AF72722F8BCDBE9E76013A9C
097B99E13A27184A87C40302F1E0F7DBD220112540E6DCAAAF19916EBF56100B
A74BDC9D7CD6C1AF4CBC27508FBB92EC9AC9E519372D406D3812CE90F9180947
E000E01E93BA9D39DA0F6179C9A9D866B7CBB97BB6ADEA1C08E0A0A2EDB7433C
BE409F54805C7644B7DF20C9D729A09CC8CCA98509ADDF9270EFCD3CA723B3F3
7461F1819389E0C5B91939E4F37524B828FFE8CA5BFC6CD1AF0905300CCBB6EA
6A46F94F5E2B0078D1F0104D822CF8BFB0EBAEE0ABCE647088B1B68058309854
02F4FB7CCF78868B46B127CCC22018038EC0C96AA60F76DD136F1E4E45328970
0A56BD68997BA454EBF3CD88FD58F4D293703E93850FDF7EC179F59F0A97DD6E
DF46849DC160F8C96ED9FE3B9C8381A16CA542C88398F1B70E62F7A04B2F7EF0
43E96B9AA6B802648425864BB54EFB8C78D51769248A44CA0BDC40EB671C50ED
A4C3E178BAB7B7B7A2BEBEDE2891486E630EB3A4E8F7CF7695140A391004452F
5BE4625BC6508BE20D7DF93BEDB5200806130A44495867C4BE00008865794E77
EEFA86B3582C1AB95CDE6532993452A97470AA55F94789D02B8658113846DFBD
447F0FCB632F3E32A83AF6F1EB041C03E2C4031F22AFD7B3031D79BE1F087858
CB7057073DE77401994CD63DF65DFBF9A7C6BBAA60E60A37FA750901B6200FB5
288F0E95B77C7A30DECC130A50120EDBCD3D790AD5E7F47ABA000CC36788B1D0
D81942C2D85105030EEE9A00010745A8A5AC39293CA140A2881508E32809C317
5530BEC8B54162D4A26AD9143C250294C49FDF7E72813FD2B9D7B5F3B84ED5D4
A64E94F3B408501276D36CC336796137095FB0DBDFCC954A2F12F72B5B22408F
81F1F1F6A6E9E9133BFC7EF3B9C6C697369248B9C0D58989B666B3F9C45C6DAD
083299F03A9D6EEAC786863D84842BED02743800AE7DD7A1F9F90D251E5A203F
3FBFABAFAFEF172E976BA5B7FDBCB050FEBD48F49CA3AE8E43C1A980E6E670B5
5EFF77BC743C94008AA215ADADAD171004C9A4D7CF1614B0E7F6ED6361870F83
B1F070ACAC00653D3D56A346B38B38434C8F2C4006D13F93286CEA593B3E7EF2
7DD3C2BB96AA9A6C120ED28E7090F809A128A0BC741ED11D3D7280C3E1FCF558
29888D6597EBE5B2B33D3FAD561F1280E1A32B74FFF826AF98D703E48FF65B74
C71A5E25E053F1FEE3B10488B1E097DA81EE537750355EA0CA5A9F7D08C002AB
80F8D6207245D31877E62911A0243A2F6BBBBF36AFA8D922651639FB40D007B0
170DC840F3DB1BC253224097F866DEA58604DBB3588BA3C8404B7278CA042889
8EFECB674FDF98AE36BE77BC3A51CED32640491045949191B1B4D93129157894
F80F322AF0DFEC0C0ADE0000000049454E44AE426082}
end>
end>
Left = 16
Top = 112
end
object vilRunImages: TVirtualImageList
DisabledGrayscale = False
DisabledSuffix = '_Disabled'
Images = <
item
CollectionIndex = 0
CollectionName = 'UnitTests\Item1'
Disabled = False
Name = 'Item1'
end
item
CollectionIndex = 1
CollectionName = 'UnitTests\Item2'
Disabled = False
Name = 'Item2'
end
item
CollectionIndex = 2
CollectionName = 'UnitTests\Item3'
Disabled = False
Name = 'Item3'
end
item
CollectionIndex = 3
CollectionName = 'UnitTests\Item4'
Disabled = False
Name = 'Item4'
end
item
CollectionIndex = 4
CollectionName = 'UnitTests\Item5'
Disabled = False
Name = 'Item5'
end
item
CollectionIndex = 5
CollectionName = 'UnitTests\Item6'
Disabled = False
Name = 'Item6'
end>
ImageCollection = icRunImages
Left = 88
Top = 112
end
object vilImages: TVirtualImageList
DisabledGrayscale = False
DisabledSuffix = '_Disabled'
Images = <
item
CollectionIndex = 14
CollectionName = 'Item15'
Disabled = False
Name = 'Item15'
end
item
CollectionIndex = 28
CollectionName = 'Item29'
Disabled = False
Name = 'Item29'
end
item
CollectionIndex = 29
CollectionName = 'Item30'
Disabled = False
Name = 'Item30'
end
item
CollectionIndex = 39
CollectionName = 'Item40'
Disabled = False
Name = 'Item40'
end
item
CollectionIndex = 40
CollectionName = 'Item41'
Disabled = False
Name = 'Item41'
end
item
CollectionIndex = 51
CollectionName = 'Item52'
Disabled = False
Name = 'Item52'
end
item
CollectionIndex = 104
CollectionName = 'Item105'
Disabled = False
Name = 'Item105'
end
item
CollectionIndex = 105
CollectionName = 'Item106'
Disabled = False
Name = 'Item106'
end
item
CollectionIndex = 106
CollectionName = 'Item107'
Disabled = False
Name = 'Item107'
end>
ImageCollection = CommandsDataModule.icImages
Left = 152
Top = 112
end
end
| 43.727735 | 222 | 0.688449 |
f1cb5e749c93c467c4b70092a3eebb5e0404a0e2
| 163,108 |
dfm
|
Pascal
|
Financeiro/uFin2003.dfm
|
jpwerka/SistemaSFG
|
76ce689a455280d3b637aec0a0b759a64032f037
|
[
"MIT"
] | 1 |
2021-11-24T13:21:18.000Z
|
2021-11-24T13:21:18.000Z
|
Financeiro/uFin2003.dfm
|
jpwerka/SistemaSFG
|
76ce689a455280d3b637aec0a0b759a64032f037
|
[
"MIT"
] | null | null | null |
Financeiro/uFin2003.dfm
|
jpwerka/SistemaSFG
|
76ce689a455280d3b637aec0a0b759a64032f037
|
[
"MIT"
] | null | null | null |
inherited Fin2003: TFin2003
Caption = 'An'#225'lise de Contas '#224' Pagar'
OldCreateOrder = True
PixelsPerInch = 96
TextHeight = 13
inherited Bevel1: TBevel
Top = 0
end
inherited HeaderPanel: TPanel
Top = 2
Caption = 'An'#225'lise Contas '#224' Pagar'
end
inherited BodyPanel: TPanel
Left = 0
Width = 774
object OleAnalise: TOleContainer
Left = 0
Top = 0
Width = 774
Height = 465
Align = alClient
Ctl3D = True
ParentCtl3D = False
TabOrder = 0
Data = {
42444F430100000000160100D0CF11E0A1B11AE1000000000000000000000000
000000003E000300FEFF09000600000000000000000000000200000001000000
00000000001000000200000001000000FEFFFFFF000000000000000016000000
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFDFFFFFF13000000FEFFFFFF1400000005000000
060000000700000008000000090000000A0000000B0000000C0000000D000000
0E0000000F000000100000001100000012000000FEFFFFFF8800000015000000
89000000FDFFFFFF18000000190000001A0000001B0000001C0000001D000000
1E0000001F000000200000002100000022000000230000002400000025000000
260000002700000028000000290000002A0000002B0000002C0000002D000000
2E0000002F000000300000003100000032000000330000003400000035000000
360000003700000038000000390000003A0000003B0000003C0000003D000000
3E0000003F000000400000004100000042000000430000004400000045000000
460000004700000048000000490000004A0000004B0000004C0000004D000000
4E0000004F000000500000005100000052000000530000005400000055000000
560000005700000058000000590000005A0000005B0000005C0000005D000000
5E0000005F000000600000006100000062000000630000006400000065000000
660000006700000068000000690000006A0000006B0000006C0000006D000000
6E0000006F000000700000007100000072000000730000007400000075000000
760000007700000078000000790000007A0000007B0000007C0000007D000000
7E0000007F0000008000000052006F006F007400200045006E00740072007900
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000016000500FFFFFFFFFFFFFFFF0200000020080200
00000000C00000000000004600000000000000000000000070E8368C0DDFCD01
03000000400700000000000001004F006C006500000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000A000201FFFFFFFFFFFFFFFFFFFFFFFF00000000
0000000000000000000000000000000000000000000000000000000000000000
000000001400000000000000010043006F006D0070004F0062006A0000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000120002010100000004000000FFFFFFFF00000000
0000000000000000000000000000000000000000000000000000000000000000
010000006F0000000000000057006F0072006B0062006F006F006B0000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000012000201FFFFFFFFFFFFFFFFFFFFFFFF00000000
0000000000000000000000000000000000000000000000000000000000000000
04000000B51C000000000000FEFFFFFF02000000FEFFFFFF0400000005000000
060000000700000008000000090000000A0000000B0000000C0000000D000000
0E0000000F0000001000000011000000120000001300000014000000FEFFFFFF
1600000017000000FEFFFFFF190000001A0000001B0000001C000000FEFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFF0100000200000000000000000000000000000000
5800200043006F006E00740072006F006C007300000042006F0072006C006100
6E00640020006400620045000100FEFF030A0000FFFFFFFF2008020000000000
C00000000000004623000000506C616E696C686120646F204D6963726F736F66
74204F666669636520457863656C00060000004269666638000E000000457863
656C2E53686565742E3800F439B2710000000000000000000000000065006E00
74007300000042006F007200C6002A00000000000100220076020D000D000000
01001500004A61636B736F6E205061747269636B205765726B6122010C00BAE7
BF427410E44000000000C700200080040000000000000000000000000F000063
6F645F636F6E74615F7061676172BB0102000000C7001F008104000000000500
0000000005000E0000636F645F666F726E656365646F72BB0102000000CD0005
000200003133CD0005000200003135CD0005000200003130CD00040001000039
CF000000C7001F0081040000000005000000000005000E000064656E5F666F72
6E656365646F72BB0102000000CD000F000C0000436173612056616C64756761
CD001B001800004B616666656573747562652053616C6120646520436166E9CD
002B002800004D656C6F20636F6D657263696F206520446973747269627569E7
E36F2064652047E173204C7409081000000605009A20CD07C9C0000006030000
E1000200B004C10002000000E20000005C0070001500004A61636B736F6E2050
61747269636B205765726B612020202020202020202020202020202020202020
2020202020202020202020202020202020202020202020202020202020202020
2020202020202020202020202020202020202020202020202020202020202020
2020202042000200B004610102000000C00100003D010400010002009C000200
0E00DE000800F404000007000005190002000000120002000000130002000000
AF0102000000BC01020000003D00120000002D005B4AF8253900010000000100
58024000020000008D00020000002200020000000E0002000100B70102000000
DA000200000031001A00C8000000FF7F90010000000000C90501410072006900
61006C0031001A00C8000000FF7F90010000000000C905014100720069006100
6C0031001A00C8000000FF7F90010000000000C9050141007200690061006C00
31001A00C8000000FF7F90010000000000C9050141007200690061006C003100
1A00C8000000FF7F90010000000000C9050141007200690061006C0031001A00
C8000100FF7FBC020000000000C9050141007200690061006C0031001A00C800
01003300BC020000000000C9050141007200690061006C0031001A00B4000100
3300BC020000000000C9050141007200690061006C0031001A00C80001001200
BC020000000000C9050141007200690061006C0031001C00A0000000FF7F9001
0000000200C906015400610068006F006D0061001E04200005001B0000225224
2022232C2323305F293B5C282252242022232C2323305C291E04250006002000
002252242022232C2323305F293B5B5265645D5C282252242022232C2323305C
291E04260007002100002252242022232C2323302E30305F293B5C2822522420
22232C2323302E30305C291E042B0008002600002252242022232C2323302E30
305F293B5B5265645D5C282252242022232C2323302E30305C291E043D002A00
3800005F2822522420222A20232C2323305F293B5F2822522420222A205C2823
2C2323305C293B5F2822522420222A20222D225F293B5F28405F291E042E0029
002900005F282A20232C2323305F293B5F282A205C28232C2323305C293B5F28
2A20222D225F293B5F28405F291E0445002C004000005F2822522420222A2023
2C2323302E30305F293B5F2822522420222A205C28232C2323302E30305C293B
5F2822522420222A20222D223F3F5F293B5F28405F291E0436002B003100005F
282A20232C2323302E30305F293B5F282A205C28232C2323302E30305C293B5F
282A20222D223F3F5F293B5F28405F291E041600A4001100002253696D223B22
53696D223B224EE36F221E042600A500210000225665726461646569726F223B
225665726461646569726F223B2246616C736F221E042200A6001D0000224174
69766172223B22417469766172223B22446573617469766172221E045D00A700
2C00015B002400AC202D0032005D005C00200023002C002300230030002E0030
0030005F0029003B005B005200650064005D005C0028005B002400AC202D0032
005D005C00200023002C002300230030002E00300030005C0029001E040F00A8
000A000064642F6D6D2F79797979E000140000000000F5FF2000000000000000
00000000C020E000140001000000F5FF200000F40000000000000000C020E000
140001000000F5FF200000F40000000000000000C020E000140002000000F5FF
200000F40000000000000000C020E000140002000000F5FF200000F400000000
00000000C020E000140000000000F5FF200000F40000000000000000C020E000
140000000000F5FF200000F40000000000000000C020E000140000000000F5FF
200000F40000000000000000C020E000140000000000F5FF200000F400000000
00000000C020E000140000000000F5FF200000F40000000000000000C020E000
140000000000F5FF200000F40000000000000000C020E000140000000000F5FF
200000F40000000000000000C020E000140000000000F5FF200000F400000000
00000000C020E000140000000000F5FF200000F40000000000000000C020E000
140000000000F5FF200000F40000000000000000C020E0001400000000000100
200000000000000000000000C020E000140005002C00F5FF200000F800000000
00000000C020E000140005002A00F5FF200000F80000000000000000C020E000
140005000900F5FF200000F80000000000000000C020E000140005002B00F5FF
200000F80000000000000000C020E000140005002900F5FF200000F800000000
00000000C020E00014000900000001002200007800220000970B0000C020E000
1400000000000100200000700001000017000000C020E000140000000E000100
200000740001000017000000C020E00014000000000001002000002011110804
08040000C020E0001400060000000100200000280101400008000000C020E000
1400060000000100200000280001000008000000C020E0001400080000000100
2200007801010800080000040820E00014000800000001002200007800010000
080000040820E00014000800000001002200007810010004080000040820E000
14000000A8000100200000240101400008000000C020E0001400000000000100
200000200101080008000000C020E00014000000000001002200003401010800
08000000C020E000140000002C000100220000340001000008000000C020E000
140000002C000100220000341001000408000000C020E00014000700A8000100
2000006C01110800080400040820E00014000700000001002000006801114100
080400040820E00014000700000001002200007C01110800080400040820E000
140007002C0001002200007C00110000080400040820E000140007002C000100
2200007C10110004080400040820E00014000000000001002000002011110804
08040000C06093020400108004FF93020400118007FF93020400008000FF9302
0400128005FF93020400138003FF93020400148006FFD50002000100E3000200
01005100100000000100000C060000024461646F730064080C00640800000300
01000000000064081C00640800000302000000000000FFFFFFFF0200BAE7BF42
7410E440000064080C006408000003FF00000000000060010200010085000D00
AB0B0000000005004461646F7385001E00940E000000001600416EE16C697365
20436F6E74617320E02050616761728C00040037003700C1010800C101000022
BE0100EB005A000F0000F052000000000006F018000000010800000200000007
00000001000000010000000700000033000BF012000000BF0008000800810141
000008C0014000000840001EF1100000000D0000080C00000817000008F70000
10FC008F01230000001C0000000F0000636F645F636F6E74615F70616761720E
0000636F645F666F726E656365646F720E000064656E5F666F726E656365646F
720D0000646174615F636164617374726F030000616E6F0300006D65730C0000
6965735F736974756163616F0C000064656E5F736974756163616F0F00006465
6E5F666F726D615F706167746F0B000076616C6F725F746F74616C0A00007661
6C6F725F7061676F100000636F645F63656E74726F5F637573746F0F0000636F
645F706C616E6F5F636F6E746111000043F36469676F20466F726E656365646F
72060000285475646F2916000044656E6F6D696E61E7E36F20466F726E656365
646F72030000416E6F0300004DEA730B0000506C616E6F20436F6E74610C0000
43656E74726F20437573746F0D00004461746120436164617374726F08000053
69747561E7E36F0B0000466F726D6120506167746F0900004EBA20436F6E7461
730B000056616C6F7220546F74616C0A000056616C6F72205061676F07000028
76617A696F290B0000546F74616C20676572616CFF0022000800E10900000C00
00004F0A00007A000000D70A000002010000350B000060010000630815006308
000000000000000000001500000002000000020A00000009081000000610009A
20CD07C9C00000060300000D00020001000C00020064000F0002000100110002
00000010000800FCA9F1D24D62503F5F00020001002A00020000002B00020000
00820002000100800008000000000000000000250204000000FF0081000200C1
041400000015000000830002000000840002000000A10022000000FF00010001
000100040015000000E98DC5FCFD7EDF3FE98DC5FCFD7EDF3F5F665500020008
007D000C0000000000B6100F00060004007D000C0001000100490F0F00060004
007D000C000200020092240F00060004007D000C0003000300DB0D0F00060004
007D000C000400040000050F00060004007D000C0005000500B6040F00060004
007D000C0006000600240C0F00060004007D000C0007000700240D0F00060004
007D000C000800080000110F00060004007D000C0009000900920A0F00060004
007D000C000A000A00240B0F00060004007D000C000B000B00DB100F00060004
007D000C000C000C0092100F000600040000020E00000000000200000000000D
00000008021000000000000D000E010000000040010F2008021000010000000D
00FF000000000000010F00FD000A0000000000150000000000FD000A00000001
00150001000000FD000A0000000200150002000000FD000A0000000300150003
000000FD000A0000000400150004000000FD000A0000000500150005000000FD
000A0000000600150006000000FD000A0000000700150007000000FD000A0000
000800150008000000FD000A0000000900150009000000FD000A0000000A0015
000A000000FD000A0000000B0015000B000000FD000A0000000C0015000C0000
00BE002000010000001600160016001700160016001600160016001600160016
0016000C00D7000800020100001400B6003E021200B600000000004000000000
000000000000001D000F00030000010000000100000000000101EF0006000000
3700000062081400620800000000000000000000140000000C0000000A000000
09081000000610009A20CD07C9C00000060300000D00020001000C0002006400
0F000200010011000200000010000800FCA9F1D24D62503F5F00020001002A00
020000002B000200000082000200010080000800000000000000000025020400
0000FF0081000200C1041400000015000000830002000000840002000000A100
220009006400010001000100020058025802E98DC5FCFD7EDF3FE98DC5FCFD7E
DF3F01005500020008007D000C0000000000B6100F00020002007D000C000100
0200000F0F00060002007D000C000300030092160F00020002007D000C000400
0500490E0F00060002007D000C000600080049130F00060002007D000C000900
1600DB120F00020002007D000C001700170024100F00060002007D000C001800
18006D160F00060002007D000C0019001900921A0F000600020000020E000100
00000800000000000600000008021000010000000600FF000000000000010F00
08021000020000000600FF000000000000010F0008021000030000000600FF00
0000000000010F0008021000050000000600FF000000000000010F0008021000
060000000600FF000000000000010F0008021000070000000600FF0000000000
00010F00FD000A000100000028000D000000FD000A000100010018000E000000
01020600010002000F00FD000A000100030028000F000000FD000A0001000400
18000E00000001020600010005000F00FD000A0002000000280010000000FD00
0A000200010018000E00000001020600020002000F00FD000A00020003002800
11000000FD000A000200040018000E00000001020600020005000F00FD000A00
03000000280012000000FD000A000300010018000E0000000102060003000200
0F00FD000A0003000300280013000000FD000A000300040018000E0000000102
0600030005000F00FD000A0005000000190014000000FD000A00050001001A00
15000000FD000A00050002001A0016000000FD000A00050003001B0017000000
FD000A00050004001C0018000000FD000A00050005001D0019000000FD000A00
060000001E001A000000FD000A00060001001F001A000000FD000A0006000200
1F001A000000BE000C00060003002000210022000500FD000A00070000002300
1B000000BE00100007000100240024002500260027000500D70010000C020000
64004C004C004C0054003A00EC00A4000F0002F040020000100008F008000000
07000000060400000F0003F0280200000F0004F028000000010009F010000000
0000000000000000000000000000000002000AF0080000000004000005000000
0F0004F04C000000920C0AF00800000001040000000A000033000BF012000000
7F0004010401BF0008000800BF0300000200000010F012000000010001000000
010000000200000002000000000011F0000000005D0046001500120014000100
016100000000F8059D01000000000C0014000000000000000000640001000A00
0000100001001300EE1F0000000000000101000002000800000000000000EC00
54000F0004F04C000000920C0AF00800000002040000000A000033000BF01200
00007F0004010401BF0008000800BF0300000200000010F01200000001000400
0000010000000500000002000000000011F0000000005D004600150012001400
0200016100000000C0069D01000000000C001400000000000000000064000100
0A000000100001001300EE1F0000000000000101000002000800000000000000
EC0054000F0004F04C000000920C0AF00800000003040000000A000033000BF0
120000007F0004010401BF0008000800BF0300000200000010F0120000000100
01000000020000000200000003000000000011F0000000005D00460015001200
1400030001610000000038079D01000000000C00140000000000000000006400
01000A000000100001001300EE1F000000000000010100000200080000000000
0000EC0054000F0004F04C000000920C0AF00800000004040000000A00003300
0BF0120000007F0004010401BF0008000800BF0300000200000010F012000000
010004000000020000000500000003000000000011F0000000005D0046001500
120014000400016100000000B0079D01000000000C0014000000000000000000
640001000A000000100001001300EE1F00000000000001010000020008000000
00000000EC0054000F0004F04C000000920C0AF00800000005040000000A0000
33000BF0120000007F0004010401BF0008000800BF0300000200000010F01200
0000010001000000030000000200000004000000000011F0000000005D004600
150012001400050001610000000028089D01000000000C001400000000000000
0000640001000A000000100001001300EE1F0000000000000101000002000800
000000000000EC0054000F0004F04C000000920C0AF00800000006040000000A
000033000BF0120000007F0004010401BF0008000800BF0300000200000010F0
12000000010004000000030000000500000004000000000011F0000000005D00
46001500120014000600016100000000A0089D01000000000C00140000000000
00000000640001000A000000100001001300EE1F000000000000010100000200
0800000000000000B00047000500070000000500050006000300000000000200
00000D00030001000600030002000300FB0301001400050000616E616C697365
5F636F6E7461735F7061676172004461646F73B100160008000000000000000B
0000436F6E7461205061676172000114001E14000AFFFFFFFF0000FFFF000000
0000000000B1001C00040000000000050011000043F36469676F20466F726E65
6365646F72B2000800000010000000FFFFB2000800000010000100FFFFB20008
00000010000200FFFFB2000800000010000300FFFFB2000800000000000400FF
FF000114001E14000AFFFFFFFF0000FFFF0000000000000000B1002100040000
000000050016000044656E6F6D696E61E7E36F20466F726E656365646F72B200
0800000010000000FFFFB2000800000010000100FFFFB2000800000010000200
FFFFB2000800000010000300FFFFB2000800000000000400FFFF000114001E14
000AFFFFFFFF0000FFFF0000000000000000B100180001000000000009000D00
004461746120436164617374726FB2000800000010000000FFFFB20008000000
10000100FFFFB2000800000010000200FFFFB2000800000010000300FFFFB200
0800000010000400FFFFB2000800000010000500FFFFB2000800000010000600
FFFFB2000800000010000700FFFFB2000800000000000800FFFF000114001E14
000AFFFFFFFFA800FFFF0000000000000000B1000E0004000000000002000300
00416E6FB2000800000010000000FFFFB2000800000000000100FFFF00011400
1E14000AFFFFFFFF0000FFFF0000000000000000B1000E000400000000000300
0300004DEA73B2000800000010000000FFFFB2000800000010000100FFFFB200
0800000000000200FFFF000114001E14000AFFFFFFFF0000FFFF000000000000
0000B100190000000000000000000E00005369676C61205369747561E7E36F00
0114001E14000AFFFFFFFF0000FFFF0000000000000000B10013000100000000
0004000800005369747561E7E36FB2000800000010000000FFFFB20008000000
10000100FFFFB2000800000010000200FFFFB2000800000000000300FFFF0001
14001E14000AFFFFFFFF0000FFFF0000000000000000B1001600010000000000
04000B0000466F726D6120506167746FB2000800000010000000FFFFB2000800
000010000100FFFFB2000800000010000200FFFFB2000800000000000300FFFF
000114001E14000AFFFFFFFF0000FFFF0000000000000000B100160008000000
000000000B000056616C6F7220546F74616C000114001E14000AFFFFFFFF0000
FFFF0000000000000000B100150008000000000000000A000056616C6F722050
61676F000114001E14000AFFFFFFFF0000FFFF0000000000000000B100170004
000000000003000C000043656E74726F20437573746FB2000800000000000000
FFFFB2000800000010000100FFFFB2000800000010000200FFFF000114001E14
000AFFFFFFFF0000FFFF0000000000000000B100160004000000000006000B00
00506C616E6F20436F6E7461B2000800000010000000FFFFB200080000001000
0100FFFFB2000800000000000200FFFFB2000800000010000300FFFFB2000800
000010000400FFFFB2000800000010000500FFFF000114001E14000AFFFFFFFF
0000FFFF0000000000000000B4000600030007000800B4000200FEFFB6002400
0100FD7F01000200FD7F02000400FD7F03000500FD7F04000C00FD7F05000B00
FD7F0600C50018000000010000000000000000000900004EBA20436F6E746173
C5002200090000000000000000002C00130000536F6D612064652056616C6F72
20546F74616CC50021000A0000000000000000002C00120000536F6D61206465
2056616C6F72205061676FB5001C00000000000300000008000300030000000D
000100004A000000000000B5001E000000000001000010000000000000010002
10010000000000010004100200F10018000000FFFFFFFFFFFF00000300020005
024F00FFFFFFFFFFFF0208290002080000010003000000000002001000140000
616E616C6973655F636F6E7461735F7061676172001410081100100800000000
000020000000131000000064082300640800000000140000000000140000616E
616C6973655F636F6E7461735F706167617264080C0064080000000201410000
000064080C006408000000FF0000000000003E021200B6060000000040000000
00000000000000001D000F00030900050000000100090009000505EF00060000
003700000062081400620800000000000000000000140000000B0000000A0000
00616C6F7220546F74616CC50021000A0000000000000000002C00120000536F
6D612064652056616C6F72205061676FB5001C00000000000300000008000300
030000000D000100004A000000000000B5001E00000000000100001000000000
000001000210010000000000010004100200F10018000000FFFFFFFFFFFF0000
0300020005024F00FFFFFFFFFFFF020829000208000001000300000000000200
1000140000616E616C6973655F636F6E7461735F706167617200141008110010
0800000000000020000000131000000064082300640800000000140000000000
140000616E616C6973655F636F6E7461735F706167617264080C006408000000
0201410000000064080C006408000000FF0000000000003E021200B606000000
004000000000000000000000001D000F00030900050000000100090009000505
EF00060000003700000062085F00530058005F00440042005F00430055005200
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000001600010003000000070000000500000000000000
0000000000000000000000000000000070E8368C0DDFCD0170E8368C0DDFCD01
0000000000000000000000003000300030003100000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000A000201FFFFFFFFFFFFFFFFFFFFFFFF00000000
0000000000000000000000000000000000000000000000000000000000000000
030000005D0400000000000002004F006C006500500072006500730030003000
3000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000018000200FFFFFFFFFFFFFFFFFFFFFFFF00000000
0000000000000000000000000000000000000000000000000000000000000000
1700000020E10000000000000500530075006D006D0061007200790049006E00
66006F0072006D006100740069006F006E000000000000000000000000000000
000000000000000000000000280002010600000008000000FFFFFFFF00000000
0000000000000000000000000000000000000000000000000000000000000000
15000000BC000000000000006461CD0021001E000046696F72656C6F20506567
6F7261726F20262046696C686F73204C746461CF000000C7001E00810D000000
0009000000000009000D0000646174615F636164617374726FBB0102000000CE
000800DC07050014000000CE000800DC07060005000000CE000800DC07060012
000000CE000800DC07060014000000CE000800DC07060015000000CE000800DC
07060017000000CE000800DC0705000D000000CE000800DC0705000E000000CF
000000C7001400E105000000000200000000000200030000616E6FBB01020000
00C90008000000000000709F40CF000000C7001400E105000000000300000000
0003000300006D6573BB0102000000C90008000000000000001440C900080000
00000000001840CF000000C7001D0080040000000000000000000000000C0000
6965735F736974756163616FBB0102000000C7001D0081040000000004000000
000004000C000064656E5F736974756163616FBB0102000000CD000C00090000
4C697175696461646FCD000B0008000050656E64656E7465CD000C0009000041
6E64616D656E746FCF000000C700200081040000000004000000000004000F00
0064656E5F666F726D615F706167746FBB0102000000CD000A00070000412056
69737461CD000900060000436865717565CD000C0009000050617263656C6164
6FCF000000C7001C0080040000000000000000000000000B000076616C6F725F
746F74616CBB0102000000C7001B0080040000000000000000000000000A0000
76616C6F725F7061676FBB0102000000C7002100810400000000030000000000
0300100000636F645F63656E74726F5F637573746FBB0102000000CF000000CD
000E000B00004F5045524143494F4E414CCD0011000E000041444D494E495354
52415449564FC700200081040000000006000000000006000F0000636F645F70
6C616E6F5F636F6E7461BB0102000000CD000C00090000322E312E30312E3034
CD000900060000322E312E3031CF000000CD0010000D0000322E312E30312E30
312E303035CD000C00090000322E312E30352E3031CD000C00090000322E312E
30312E30360A0000005F666F726D615F706167746FBB0102000000CD000A0007
000041205669737461CD0009FEFF000005010200000000000000000000000000
0000000001000000E0859FF2F94F6810AB9108002B27B3D9300000008C000000
0600000001000000380000000400000040000000080000004C0000000C000000
6C0000000D00000078000000130000008400000002000000E40400001E000000
04000000000000001E000000180000004A61636B736F6E205061747269636B20
5765726B610000004000000080612D74F053CD0140000000801D1168BD57CD01
030000000000000049564FC78100000082000000830000008400000085000000
8600000087000000FEFFFFFFFEFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF030000000400000001000000FFFFFFFF
0200000000000000E6460000290E0000DEE000000100090000036F7000000E00
1610000000001610000026060F002220574D46430100000000000100E7DC0000
00000600000000200000408F000040AF0000010000006C000000000000000000
0000AD020000880000000000000000000000FE4200000E10000020454D460000
010040AF0000EB0300000C000000000000000000000000000000000500002003
000040010000F000000000000000000000000000000000E2040080A903004600
00002C00000020000000454D462B014001001C000000100000000210C0DB0100
00006000000060000000460000005C00000050000000454D462B224004000C00
0000000000001E4009000C00000000000000244001000C000000000000003040
020010000000040000000000803F214007000C00000000000000044000000C00
000000000000180000000C00000000000000190000000C000000FFFFFF001400
00000C0000000D000000120000000C0000000200000021000000080000002200
00000C000000FFFFFFFF2100000008000000220000000C000000FFFFFFFF0A00
00001000000000000000000000002100000008000000190000000C000000FFFF
FF00180000000C00000000000000220000000C000000FFFFFFFF210000000800
0000190000000C000000FFFFFF00180000000C000000000000001E0000001800
00000000000000000000AE02000089000000220000000C000000FFFFFFFF2100
000008000000190000000C000000FFFFFF00180000000C000000000000001E00
0000180000000000000000000000AE02000089000000220000000C000000FFFF
FFFF2100000008000000190000000C000000FFFFFF00180000000C0000000000
00001E000000180000000100000001000000AE02000089000000270000001800
000001000000000000000000000000000000250000000C000000010000001900
00000C00000000000000140000000C0000000D000000120000000C0000000200
00004C000000640000004701000055000000AD02000066000000470100005500
000067010000120000002100F00000000000000000000000803F000000000000
00000000803F0000000000000000000000000000000000000000000000000000
0000000000004C000000640000000100000077000000AD020000880000000000
000077000000AE020000120000002100F00000000000000000000000803F0000
0000000000000000803F00000000000000000000000000000000000000000000
00000000000000000000520000007001000002000000F3FFFFFF000000000000
00000000000090010000000000000000000041007200690061006C0000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000013000A0000001894B000C8DB
1300DEB50030EADD1300C8DB13001A94B0001F000000000000000D000000B9B5
0030EADD1300C8DB13001894B0002000000064DD1300CFFC0030EADD13000500
00001894B0002000000012F60030E8DD13001894B00020000000D8DE1300E8DF
13002EF70030000000000000000070DF130000000000D98B367E88103C7E0F01
000048DC1300AC8D377E8B8D377E4700000070DF130000000000800000000100
00000000000018DC13006CDC1300000000000000000001000000FFFFFFFF24C1
01300000000000000000470000000000000032130A9500000000000000003213
0A950913017F1894B000F3FFFFFF000000006476000800000000250000000C00
00000200000027000000180000000300000000000000E0DFE300000000002500
00000C00000003000000180000000C000000E0DFE300190000000C000000FFFF
FF004C0000006400000002000000130000007300000020000000020000001300
0000720000000E0000002100F00000000000000000000000803F000000000000
00000000803F0000000000000000000000000000000000000000000000000000
00000000000027000000180000000400000000000000FFFFFF00000000002500
00000C00000004000000180000000C000000FFFFFF00260000001C0000000500
0000000000000000000000000000FFFFFF00250000000C000000050000001B00
0000100000000100000012000000360000001000000074000000120000002500
00000C000000070000804C000000640000000100000012000000730000001200
0000010000001200000073000000010000002100F00000000000000000000000
803F00000000000000000000803F000000000000000000000000000000000000
0000000000000000000000000000250000000C000000050000001B0000001000
0000010000001200000036000000100000000100000021000000250000000C00
0000070000804C00000064000000010000001200000001000000200000000100
000012000000010000000F0000002100F00000000000000000000000803F0000
0000000000000000803F00000000000000000000000000000000000000000000
00000000000000000000270000001800000006000000000000009D9DA1000000
0000250000000C00000006000000180000000C0000009D9DA100280000000C00
000005000000260000001C000000050000000000000000000000000000009D9D
A100250000000C000000050000001B0000001000000074000000120000003600
0000100000007400000022000000250000000C000000070000804C0000006400
0000740000001200000074000000210000007400000012000000010000001000
00002100F00000000000000000000000803F00000000000000000000803F0000
0000000000000000000000000000000000000000000000000000000000002500
00000C000000050000001B000000100000000100000021000000360000001000
00007500000021000000250000000C000000070000804C000000640000000100
0000210000007400000021000000010000002100000074000000010000002100
F00000000000000000000000803F00000000000000000000803F000000000000
0000000000000000000000000000000000000000000000000000250000000C00
000001000000180000000C00000000000000120000000C000000010000005400
0000B400000003000000120000006F00000021000000010000000000C8410000
F0410300000012000000110000004C000000000000000000000000000000FFFF
FFFFFFFFFFFF700000004300F3006400690067006F00200046006F0072006E00
65006300650064006F0072000000090000000700000007000000030000000700
0000070000000400000008000000070000000400000007000000070000000700
0000070000000700000007000000040000005400000070000000780000001200
00009B00000021000000010000000000C8410000F04178000000120000000600
00004C000000000000000000000000000000FFFFFFFFFFFFFFFF580000002800
5400750064006F00290004000000070000000700000007000000070000000400
0000250000000C00000003000000180000000C000000E0DFE300120000000C00
0000020000004C000000640000004901000013000000E3010000200000004901
0000130000009B0000000E0000002100F00000000000000000000000803F0000
0000000000000000803F00000000000000000000000000000000000000000000
00000000000000000000250000000C00000004000000180000000C000000FFFF
FF00280000000C00000005000000260000001C00000005000000000000000000
000000000000FFFFFF00250000000C000000050000001B000000100000004801
0000120000003600000010000000E401000012000000250000000C0000000700
00804C000000640000004801000012000000E301000012000000480100001200
00009C000000010000002100F00000000000000000000000803F000000000000
00000000803F0000000000000000000000000000000000000000000000000000
000000000000250000000C000000050000001B00000010000000480100001200
000036000000100000004801000021000000250000000C000000070000804C00
0000640000004801000012000000480100002000000048010000120000000100
00000F0000002100F00000000000000000000000803F00000000000000000000
803F000000000000000000000000000000000000000000000000000000000000
0000250000000C00000006000000180000000C0000009D9DA100280000000C00
000005000000260000001C000000050000000000000000000000000000009D9D
A100250000000C000000050000001B00000010000000E4010000120000003600
000010000000E401000022000000250000000C000000070000804C0000006400
0000E401000012000000E401000021000000E401000012000000010000001000
00002100F00000000000000000000000803F00000000000000000000803F0000
0000000000000000000000000000000000000000000000000000000000002500
00000C000000050000001B000000100000004801000021000000360000001000
0000E501000021000000250000000C000000070000804C000000640000004801
000021000000E40100002100000048010000210000009D000000010000002100
F00000000000000000000000803F00000000000000000000803F000000000000
0000000000000000000000000000000000000000000000000000250000000C00
000001000000180000000C00000000000000120000000C000000010000005400
0000D00000004A01000012000000DD01000021000000010000000000C8410000
F0414A01000012000000160000004C000000000000000000000000000000FFFF
FFFFFFFFFFFF78000000440065006E006F006D0069006E006100E700E3006F00
200046006F0072006E0065006300650064006F00720009000000070000000700
0000070000000B00000003000000070000000700000007000000070000000700
0000040000000800000007000000040000000700000007000000070000000700
00000700000007000000040000005400000070000000E8010000120000000B02
000021000000010000000000C8410000F041E801000012000000060000004C00
0000000000000000000000000000FFFFFFFFFFFFFFFF58000000280054007500
64006F0029000400000007000000070000000700000007000000040000002500
00000C00000003000000180000000C000000E0DFE300120000000C0000000200
00004C0000006400000002000000240000007300000031000000020000002400
0000720000000E0000002100F00000000000000000000000803F000000000000
00000000803F0000000000000000000000000000000000000000000000000000
000000000000250000000C00000004000000180000000C000000FFFFFF002800
00000C00000005000000260000001C0000000500000000000000000000000000
0000FFFFFF00250000000C000000050000001B00000010000000010000002300
000036000000100000007400000023000000250000000C000000070000804C00
0000640000000100000023000000730000002300000001000000230000007300
0000010000002100F00000000000000000000000803F00000000000000000000
803F000000000000000000000000000000000000000000000000000000000000
0000250000000C000000050000001B0000001000000001000000230000003600
0000100000000100000032000000250000000C000000070000804C0000006400
0000010000002300000001000000310000000100000023000000010000000F00
00002100F00000000000000000000000803F00000000000000000000803F0000
0000000000000000000000000000000000000000000000000000000000002500
00000C00000006000000180000000C0000009D9DA100280000000C0000000500
0000260000001C000000050000000000000000000000000000009D9DA1002500
00000C000000050000001B000000100000007400000023000000360000001000
00007400000033000000250000000C000000070000804C000000640000007400
0000230000007400000032000000740000002300000001000000100000002100
F00000000000000000000000803F00000000000000000000803F000000000000
0000000000000000000000000000000000000000000000000000250000000C00
0000050000001B00000010000000010000003200000036000000100000007500
000032000000250000000C000000070000804C00000064000000010000003200
00007400000032000000010000003200000074000000010000002100F0000000
0000000000000000803F00000000000000000000803F00000000000000000000
00000000000000000000000000000000000000000000250000000C0000000100
0000180000000C00000000000000120000000C00000001000000540000006000
000003000000230000001900000032000000010000000000C8410000F0410300
000023000000030000004C000000000000000000000000000000FFFFFFFFFFFF
FFFF5400000041006E006F000000090000000700000007000000540000007000
000078000000230000009B00000032000000010000000000C8410000F0417800
000023000000060000004C000000000000000000000000000000FFFFFFFFFFFF
FFFF5800000028005400750064006F0029000400000007000000070000000700
00000700000004000000250000000C00000003000000180000000C000000E0DF
E300120000000C000000020000004C000000640000004901000024000000E301
00003100000049010000240000009B0000000E0000002100F000000000000000
00000000803F00000000000000000000803F0000000000000000000000000000
000000000000000000000000000000000000250000000C000000040000001800
00000C000000FFFFFF00280000000C00000005000000260000001C0000000500
0000000000000000000000000000FFFFFF00250000000C000000050000001B00
00001000000048010000230000003600000010000000E4010000230000002500
00000C000000070000804C000000640000004801000023000000E30100002300
000048010000230000009C000000010000002100F00000000000000000000000
803F00000000000000000000803F000000000000000000000000000000000000
0000000000000000000000000000250000000C000000050000001B0000001000
0000480100002300000036000000100000004801000032000000250000000C00
0000070000804C00000064000000480100002300000048010000310000004801
000023000000010000000F0000002100F00000000000000000000000803F0000
0000000000000000803F00000000000000000000000000000000000000000000
00000000000000000000250000000C00000006000000180000000C0000009D9D
A100280000000C00000005000000260000001C00000005000000000000000000
0000000000009D9DA100250000000C000000050000001B00000010000000E401
0000230000003600000010000000E401000033000000250000000C0000000700
00804C00000064000000E401000023000000E401000032000000E40100002300
000001000000100000002100F00000000000000000000000803F000000000000
00000000803F0000000000000000000000000000000000000000000000000000
000000000000250000000C000000050000001B00000010000000480100003200
00003600000010000000E501000032000000250000000C000000070000804C00
0000640000004801000032000000E40100003200000048010000320000009D00
0000010000002100F00000000000000000000000803F00000000000000000000
803F000000000000000000000000000000000000000000000000000000000000
0000250000000C00000001000000180000000C00000000000000120000000C00
00000100000054000000600000004A0100002300000062010000320000000100
00000000C8410000F0414A01000023000000030000004C000000000000000000
000000000000FFFFFFFFFFFFFFFF540000004D00EA00730000000B0000000700
0000070000005400000070000000E8010000230000000B020000320000000100
00000000C8410000F041E801000023000000060000004C000000000000000000
000000000000FFFFFFFFFFFFFFFF5800000028005400750064006F0029000400
00000700000007000000070000000700000004000000250000000C0000000300
0000180000000C000000E0DFE300120000000C000000020000004C0000006400
0000020000003500000073000000420000000200000035000000720000000E00
00002100F00000000000000000000000803F00000000000000000000803F0000
0000000000000000000000000000000000000000000000000000000000002500
00000C00000004000000180000000C000000FFFFFF00280000000C0000000500
0000260000001C00000005000000000000000000000000000000FFFFFF002500
00000C000000050000001B000000100000000100000034000000360000001000
00007400000034000000250000000C000000070000804C000000640000000100
0000340000007300000034000000010000003400000073000000010000002100
F00000000000000000000000803F00000000000000000000803F000000000000
0000000000000000000000000000000000000000000000000000250000000C00
0000050000001B00000010000000010000003400000036000000100000000100
000043000000250000000C000000070000804C00000064000000010000003400
000001000000420000000100000034000000010000000F0000002100F0000000
0000000000000000803F00000000000000000000803F00000000000000000000
00000000000000000000000000000000000000000000250000000C0000000600
0000180000000C0000009D9DA100280000000C00000005000000260000001C00
0000050000000000000000000000000000009D9DA100250000000C0000000500
00001B0000001000000074000000340000003600000010000000740000004400
0000250000000C000000070000804C0000006400000074000000340000007400
000043000000740000003400000001000000100000002100F000000000000000
00000000803F00000000000000000000803F0000000000000000000000000000
000000000000000000000000000000000000250000000C000000050000001B00
0000100000000100000043000000360000001000000075000000430000002500
00000C000000070000804C000000640000000100000043000000740000004300
0000010000004300000074000000010000002100F00000000000000000000000
803F00000000000000000000803F000000000000000000000000000000000000
0000000000000000000000000000250000000C00000001000000180000000C00
000000000000120000000C000000010000005400000090000000030000003400
00004900000043000000010000000000C8410000F04103000000340000000B00
00004C000000000000000000000000000000FFFFFFFFFFFFFFFF640000005000
6C0061006E006F00200043006F006E0074006100000009000000030000000700
0000070000000700000004000000090000000700000007000000040000000700
0000540000007000000078000000340000009B00000043000000010000000000
C8410000F0417800000034000000060000004C00000000000000000000000000
0000FFFFFFFFFFFFFFFF5800000028005400750064006F002900040000000700
000007000000070000000700000004000000250000000C000000030000001800
00000C000000E0DFE300120000000C000000020000004C000000640000004901
000035000000E30100004200000049010000350000009B0000000E0000002100
F00000000000000000000000803F00000000000000000000803F000000000000
0000000000000000000000000000000000000000000000000000250000000C00
000004000000180000000C000000FFFFFF00280000000C000000050000002600
00001C00000005000000000000000000000000000000FFFFFF00250000000C00
0000050000001B0000001000000048010000340000003600000010000000E401
000034000000250000000C000000070000804C00000064000000480100003400
0000E30100003400000048010000340000009C000000010000002100F0000000
0000000000000000803F00000000000000000000803F00000000000000000000
00000000000000000000000000000000000000000000250000000C0000000500
00001B0000001000000048010000340000003600000010000000480100004300
0000250000000C000000070000804C0000006400000048010000340000004801
0000420000004801000034000000010000000F0000002100F000000000000000
00000000803F00000000000000000000803F0000000000000000000000000000
000000000000000000000000000000000000250000000C000000060000001800
00000C0000009D9DA100280000000C00000005000000260000001C0000000500
00000000000000000000000000009D9DA100250000000C000000050000001B00
000010000000E4010000340000003600000010000000E4010000440000002500
00000C000000070000804C00000064000000E401000034000000E40100004300
0000E40100003400000001000000100000002100F00000000000000000000000
803F00000000000000000000803F000000000000000000000000000000000000
0000000000000000000000000000250000000C000000050000001B0000001000
000048010000430000003600000010000000E501000043000000250000000C00
0000070000804C000000640000004801000043000000E4010000430000004801
0000430000009D000000010000002100F00000000000000000000000803F0000
0000000000000000803F00000000000000000000000000000000000000000000
00000000000000000000250000000C00000001000000180000000C0000000000
0000120000000C0000000100000054000000940000004A010000340000009501
000043000000010000000000C8410000F0414A010000340000000C0000004C00
0000000000000000000000000000FFFFFFFF1610000026060F002220574D4643
01000000000001000000000000000600000000200000406F000040AF0000FFFF
FFFF64000000430065006E00740072006F00200043007500730074006F000900
0000070000000700000004000000040000000700000004000000090000000700
00000700000004000000070000005400000070000000E8010000340000000B02
000043000000010000000000C8410000F041E801000034000000060000004C00
0000000000000000000000000000FFFFFFFFFFFFFFFF58000000280054007500
64006F0029000400000007000000070000000700000007000000040000005200
00007001000007000000F3FFFFFF000000000000000000000000BC0200000000
00000000000041007200690061006C0000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000013000A0000001894B000C8DB1300DEB50030EADD1300C8DB
13001A94B0001F000000000000000D000000B9B50030EADD1300C8DB13001894
B0002000000064DD1300CFFC0030EADD1300050000001894B0002000000012F6
0030E8DD13001894B00020000000D8DE1300E8DF13002EF70030000000000000
000070DF130000000000D98B367E88103C7E0F01000048DC1300AC8D377E8B8D
377E4700000070DF13000000000080000000010000000000000018DC13006CDC
1300000000000000000001000000FFFFFFFF24C1013000000000000000004700
00000000000032130A95000000000000000032130A950913017F1894B000F3FF
FFFF000000006476000800000000250000000C00000007000000540000009C00
000003000000560000005B00000065000000010000000000C8410000F0410300
0000560000000D0000004C000000000000000000000000000000FFFFFFFFFFFF
FFFF680000004400610074006100200043006100640061007300740072006F00
0000090000000800000004000000080000000400000009000000080000000800
00000800000006000000040000000500000008000000540000007C0000007800
000056000000AF00000065000000010000000000C8410000F041780000005600
0000080000004C000000000000000000000000000000FFFFFFFFFFFFFFFF5C00
000053006900740075006100E700E3006F000900000004000000040000000800
0000080000000700000008000000080000005400000090000000E10000005600
00003201000065000000010000000000C8410000F041E1000000560000000B00
00004C000000000000000000000000000000FFFFFFFFFFFFFFFF640000004600
6F0072006D006100200050006100670074006F00000008000000080000000500
00000C0000000800000004000000090000000800000008000000040000000800
0000520000007001000008000000F4FFFFFF000000000000000000000000BC02
0000000000000000000041007200690061006C00000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000013000A0000007495B000A0751300DEB50030C277
1300A07513007695B0001F000000DB120A150C000000B9B50030C2771300A075
13007495B000200000003C771300CFFC0030C2771300050000007495B0002000
000012F60030C07713007495B0002000000000000000607A13002EF700300000
0001000000005400610000006F006D006100F0751300C14F1C5B3C111F5B5C76
130068868C001876130020571C5BB0878C00FC858C0034868C00D8858C007900
000011000000000000000000000001000000D7521C5B24C10130000000000000
00000479130000000000E60E0A0100000000DB120A15E60E0A010913017F7495
B0005C7613007C94377E6476000800000000250000000C000000080000001800
00000C000000FFCC000054000000840000007B01000057000000B10100006500
0000010000000000C8410000F0417B01000057000000090000004C0000000000
00000000000000000000FFFFFFFFFFFFFFFF600000004E00BA00200043006F00
6E00740061007300000008000000040000000300000008000000070000000700
00000400000007000000070000005400000090000000F8010000570000003502
000065000000010000000000C8410000F041F9010000570000000B0000004C00
0000000000000000000000000000FFFFFFFFFFFFFFFF64000000560061006C00
6F007200200054006F00740061006C0000000800000007000000030000000700
0000050000000300000007000000070000000400000007000000030000005400
0000880000005C020000570000009A02000065000000010000000000C8410000
F0415D020000570000000A0000004C000000000000000000000000000000FFFF
FFFFFFFFFFFF60000000560061006C006F00720020005000610067006F000800
0000070000000300000007000000050000000300000008000000070000000700
000007000000180000000C00000000000000250000000C000000020000005400
00007800000003000000670000002700000076000000010000000000C8410000
F0410300000067000000070000004C000000000000000000000000000000FFFF
FFFFFFFFFFFF5C0000002800760061007A0069006F0029000000040000000500
0000070000000700000003000000070000000400000054000000780000007800
0000670000009C00000076000000010000000000C8410000F041780000006700
0000070000004C000000000000000000000000000000FFFFFFFFFFFFFFFF5C00
00002800760061007A0069006F00290000000400000005000000070000000700
00000300000007000000040000005400000078000000E1000000670000000501
000076000000010000000000C8410000F041E100000067000000070000004C00
0000000000000000000000000000FFFFFFFFFFFFFFFF5C000000280076006100
7A0069006F002900000004000000050000000700000007000000030000000700
000004000000520000007001000009000000F3FFFFFF00000000000000000000
0000BC020000000000000000000041007200690061006C000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000013000A0000009094B000A0751300DEB5
0030C2771300A07513009294B0001F000000DB120A150D000000B9B50030C277
1300A07513009094B000200000003C771300CFFC0030C2771300050000009094
B0002000000012F60030C07713009094B0002000000000000000607A13002EF7
003000000001000000005400610000006F006D006100F0751300C14F1C5B3C11
1F5B5C76130068868C001876130020571C5BB0878C00FC858C0034868C00D885
8C007900000011000000000000000000000001000000D7521C5B24C101300000
0000000000000479130000000000E60E0A0000000000DB120A15E60E0A000913
017F9094B0005C7613007C94377E6476000800000000250000000C0000000900
0000180000000C000000FFCC0000540000009000000003000000780000004700
000087000000010000000000C8410000F04103000000780000000B0000004C00
0000000000000000000000000000FFFFFFFFFFFFFFFF6400000054006F007400
61006C00200067006500720061006C0000000800000008000000040000000800
0000040000000400000008000000080000000500000008000000040000001800
00000C00000000000000250000000C00000000000080250000000C0000000D00
0080220000000C000000FFFFFFFF2100000008000000250000000C0000000900
0000250000000C00000001000000190000000C000000FFFFFF00180000000C00
0000000000001E000000180000000000000000000000AE020000890000002700
0000180000000A00000000000000C0C0C00000000000250000000C0000000A00
0000280000000C00000001000000180000000C000000C0C0C000190000000C00
0000C0C0C000140000000C0000000D000000120000000C000000020000002800
00000C00000005000000260000001C0000000500000000000000000000000000
0000C0C0C000250000000C000000050000001B00000010000000000000000000
000036000000100000000000000011000000250000000C000000070000804C00
0000640000000000000000000000000000001000000000000000000000000100
0000110000002100F00000000000000000000000803F00000000000000000000
803F000000000000000000000000000000000000000000000000000000000000
0000250000000C000000050000001B0000001000000075000000000000003600
0000100000007500000011000000250000000C000000070000804C0000006400
0000750000000000000075000000100000007500000000000000010000001100
00002100F00000000000000000000000803F00000000000000000000803F0000
0000000000000000000000000000000000000000000000000000000000002700
00001800000001000000000000000000000000000000250000000C0000000100
0000180000000C00000000000000190000000C000000FFFFFF00280000000C00
000005000000260000001C000000050000000000000000000000000000000000
0000250000000C000000050000001B0000001000000001000000110000003600
000010000000DF00000011000000250000000C000000070000804C0000006400
00000100000011000000DE000000110000000100000011000000DE0000000100
00002100F00000000000000000000000803F00000000000000000000803F0000
0000000000000000000000000000000000000000000000000000000000002500
00000C0000000A000000280000000C00000001000000180000000C000000C0C0
C000190000000C000000C0C0C000280000000C00000005000000260000001C00
000005000000000000000000000000000000C0C0C000250000000C0000000500
00001B00000010000000DE000000000000003600000010000000DE0000001100
0000250000000C000000070000804C00000064000000DE00000000000000DE00
000010000000DE0000000000000001000000110000002100F000000000000000
00000000803F00000000000000000000803F0000000000000000000000000000
000000000000000000000000000000000000250000000C000000050000001B00
000010000000DF00000011000000360000001000000047010000110000002500
00000C000000070000804C00000064000000DF00000011000000460100001100
0000DF0000001100000068000000010000002100F00000000000000000000000
803F00000000000000000000803F000000000000000000000000000000000000
0000000000000000000000000000250000000C000000050000001B0000001000
0000470100000000000036000000100000004701000011000000250000000C00
0000070000804C00000064000000470100000000000047010000100000004701
00000000000001000000110000002100F00000000000000000000000803F0000
0000000000000000803F00000000000000000000000000000000000000000000
00000000000000000000250000000C000000050000001B00000010000000E501
0000000000003600000010000000E501000011000000250000000C0000000700
00804C00000064000000E501000000000000E501000010000000E50100000000
000001000000110000002100F00000000000000000000000803F000000000000
00000000803F0000000000000000000000000000000000000000000000000000
0000000000002700000018000000010000000000000000000000000000002500
00000C00000001000000180000000C00000000000000190000000C000000FFFF
FF00280000000C00000005000000260000001C00000005000000000000000000
00000000000000000000250000000C000000050000001B000000100000004801
00001100000036000000100000004A02000011000000250000000C0000000700
00804C0000006400000048010000110000004902000011000000480100001100
000002010000010000002100F00000000000000000000000803F000000000000
00000000803F0000000000000000000000000000000000000000000000000000
000000000000250000000C0000000A000000280000000C000000010000001800
00000C000000C0C0C000190000000C000000C0C0C000280000000C0000000500
0000260000001C00000005000000000000000000000000000000C0C0C0002500
00000C000000050000001B000000100000004902000000000000360000001000
00004902000011000000250000000C000000070000804C000000640000004902
0000000000004902000010000000490200000000000001000000110000002100
F00000000000000000000000803F00000000000000000000803F000000000000
0000000000000000000000000000000000000000000000000000270000001800
000001000000000000000000000000000000250000000C000000010000001800
00000C00000000000000190000000C000000FFFFFF00280000000C0000000500
0000260000001C00000005000000000000000000000000000000000000002500
00000C000000050000001B000000100000000100000022000000360000001000
0000DF00000022000000250000000C000000070000804C000000640000000100
000022000000DE000000220000000100000022000000DE000000010000002100
F00000000000000000000000803F00000000000000000000803F000000000000
0000000000000000000000000000000000000000000000000000250000000C00
00000A000000280000000C00000001000000180000000C000000C0C0C0001900
00000C000000C0C0C000280000000C00000005000000260000001C0000000500
0000000000000000000000000000C0C0C000250000000C000000050000001B00
000010000000DF00000022000000360000001000000047010000220000002500
00000C000000070000804C00000064000000DF00000022000000460100002200
0000DF0000002200000068000000010000002100F00000000000000000000000
803F00000000000000000000803F000000000000000000000000000000000000
0000000000000000000000000000270000001800000001000000000000000000
000000000000250000000C00000001000000180000000C000000000000001900
00000C000000FFFFFF00280000000C00000005000000260000001C0000000500
000000000000000000000000000000000000250000000C000000050000001B00
000010000000480100002200000036000000100000004A020000220000002500
00000C000000070000804C000000640000004801000022000000490200002200
0000480100002200000002010000010000002100F00000000000000000000000
803F00000000000000000000803F000000000000000000000000000000000000
0000000000000000000000000000250000000C000000050000001B0000001000
000001000000330000003600000010000000DF00000033000000250000000C00
0000070000804C000000640000000100000033000000DE000000330000000100
000033000000DE000000010000002100F00000000000000000000000803F0000
0000000000000000803F00000000000000000000000000000000000000000000
00000000000000000000250000000C0000000A000000280000000C0000000100
0000180000000C000000C0C0C000190000000C000000C0C0C000280000000C00
000005000000260000001C00000005000000000000000000000000000000C0C0
C000250000000C000000050000001B00000010000000DF000000330000003600
0000100000004701000033000000250000000C000000070000804C0000006400
0000DF000000330000004601000033000000DF00000033000000680000000100
00002100F00000000000000000000000803F00000000000000000000803F0000
0000000000000000000000000000000000000000000000000000000000002700
00001800000001000000000000000000000000000000250000000C0000000100
0000180000000C00000000000000190000000C000000FFFFFF00280000000C00
000005000000260000001C000000050000000000000000000000000000000000
0000250000000C000000050000001B0000001000000048010000330000003600
0000100000004A02000033000000250000000C000000070000804C0000006400
0000480100003300000049020000330000004801000033000000020100000100
00002100F00000000000000000000000803F00000000000000000000803F0000
0000000000000000000000000000000000000000000000000000000000002500
00000C000000050000001B000000100000000000000011000000360000001000
00000000000045000000250000000C000000070000804C000000640000000000
0000110000000000000044000000000000001100000001000000340000002100
F00000000000000000000000803F00000000000000000000803F000000000000
0000000000000000000000000000000000000000000000000000250000000C00
0000050000001B00000010000000750000001200000036000000100000007500
000045000000250000000C000000070000804C00000064000000750000001200
00007500000044000000750000001200000001000000330000002100F0000000
0000000000000000803F00000000000000000000803F00000000000000000000
00000000000000000000000000000000000000000000250000000C0000000500
00001B0000001000000001000000440000003600000010000000DF0000004400
0000250000000C000000070000804C000000640000000100000044000000DE00
0000440000000100000044000000DE000000010000002100F000000000000000
00000000803F00000000000000000000803F0000000000000000000000000000
000000000000000000000000000000000000250000000C000000050000001B00
000010000000DE000000120000003600000010000000DE000000450000002500
00000C000000070000804C00000064000000DE00000012000000DE0000004400
0000DE0000001200000001000000330000002100F00000000000000000000000
803F00000000000000000000803F000000000000000000000000000000000000
0000000000000000000000000000250000000C0000000A000000280000000C00
000001000000180000000C000000C0C0C000190000000C000000C0C0C0002800
00000C00000005000000260000001C0000000500000000000000000000000000
0000C0C0C000250000000C000000050000001B00000010000000DF0000004400
000036000000100000004701000044000000250000000C000000070000804C00
000064000000DF000000440000004601000044000000DF000000440000006800
0000010000002100F00000000000000000000000803F00000000000000000000
803F000000000000000000000000000000000000000000000000000000000000
0000270000001800000001000000000000000000000000000000250000000C00
000001000000180000000C00000000000000190000000C000000FFFFFF002800
00000C00000005000000260000001C0000000500000000000000000000000000
000000000000250000000C000000050000001B00000010000000470100001100
000036000000100000004701000045000000250000000C000000070000804C00
0000640000004701000011000000470100004400000047010000110000000100
0000340000002100F00000000000000000000000803F00000000000000000000
803F000000000000000000000000000000000000000000000000000000000000
0000250000000C000000050000001B00000010000000E5010000120000003600
000010000000E501000045000000250000000C000000070000804C0000006400
0000E501000012000000E501000044000000E501000012000000010000003300
00002100F00000000000000000000000803F00000000000000000000803F0000
0000000000000000000000000000000000000000000000000000000000002500
00000C000000050000001B000000100000004801000044000000360000001000
00004A02000044000000250000000C000000070000804C000000640000004801
0000440000004902000044000000480100004400000002010000010000002100
F00000000000000000000000803F00000000000000000000803F000000000000
0000000000000000000000000000000000000000000000000000250000000C00
0000050000001B00000010000000490200001200000036000000100000004902
000045000000250000000C000000070000804C00000064000000490200001200
00004902000044000000490200001200000001000000330000002100F0000000
0000000000000000803F00000000000000000000803F00000000000000000000
00000000000000000000000000000000000000000000250000000C0000000A00
0000280000000C00000001000000180000000C000000C0C0C000190000000C00
0000C0C0C000280000000C00000005000000260000001C000000050000000000
00000000000000000000C0C0C000250000000C000000050000001B0000001000
0000000000004500000036000000100000000000000055000000250000000C00
0000070000804C00000064000000000000004500000000000000540000000000
00004500000001000000100000002100F00000000000000000000000803F0000
0000000000000000803F00000000000000000000000000000000000000000000
00000000000000000000250000000C000000050000001B000000100000007500
00004500000036000000100000007500000055000000250000000C0000000700
00804C0000006400000075000000450000007500000054000000750000004500
000001000000100000002100F00000000000000000000000803F000000000000
00000000803F0000000000000000000000000000000000000000000000000000
000000000000250000000C000000050000001B00000010000000DE0000001610
000026060F002220574D46430100000000000100000000000000060000000020
0000404F000040AF0000450000003600000010000000DE000000550000002500
00000C000000070000804C00000064000000DE00000045000000DE0000005400
0000DE0000004500000001000000100000002100F00000000000000000000000
803F00000000000000000000803F000000000000000000000000000000000000
0000000000000000000000000000250000000C000000050000001B0000001000
0000470100004500000036000000100000004701000055000000250000000C00
0000070000804C00000064000000470100004500000047010000540000004701
00004500000001000000100000002100F00000000000000000000000803F0000
0000000000000000803F00000000000000000000000000000000000000000000
00000000000000000000250000000C000000050000001B00000010000000E501
0000450000003600000010000000E501000055000000250000000C0000000700
00804C00000064000000E501000045000000E501000054000000E50100004500
000001000000100000002100F00000000000000000000000803F000000000000
00000000803F0000000000000000000000000000000000000000000000000000
000000000000250000000C000000050000001B00000010000000490200004500
000036000000100000004902000055000000250000000C000000070000804C00
0000640000004902000045000000490200005400000049020000450000000100
0000100000002100F00000000000000000000000803F00000000000000000000
803F000000000000000000000000000000000000000000000000000000000000
0000270000001800000001000000000000000000000000000000250000000C00
000001000000180000000C00000000000000190000000C000000FFFFFF002800
00000C00000005000000260000001C0000000500000000000000000000000000
000000000000250000000C000000050000001B00000010000000000000005500
00003600000010000000AE02000055000000250000000C000000070000804C00
0000640000000000000055000000AD020000550000000000000055000000AE02
0000010000002100F00000000000000000000000803F00000000000000000000
803F000000000000000000000000000000000000000000000000000000000000
0000250000000C0000000A000000280000000C00000001000000180000000C00
0000C0C0C000190000000C000000C0C0C000280000000C000000050000002600
00001C00000005000000000000000000000000000000C0C0C000250000000C00
0000050000001B00000010000000AD020000000000003600000010000000AD02
000055000000250000000C000000070000804C00000064000000AD0200000000
0000AD02000054000000AD0200000000000001000000550000002100F0000000
0000000000000000803F00000000000000000000803F00000000000000000000
0000000000000000000000000000000000000000000027000000180000000100
0000000000000000000000000000250000000C00000001000000180000000C00
000000000000190000000C000000FFFFFF00280000000C000000050000002600
00001C0000000500000000000000000000000000000000000000250000000C00
0000050000001B00000010000000000000005600000036000000100000000000
000066000000250000000C000000070000804C00000064000000000000005600
00000000000065000000000000005600000001000000100000002100F0000000
0000000000000000803F00000000000000000000803F00000000000000000000
0000000000000000000000000000000000000000000027000000180000000B00
0000000000000000000000000000250000000C0000000B000000280000000C00
000001000000250000000C000000050000001B00000010000000000000006600
00003600000010000000AE02000066000000250000000C000000070000804C00
0000640000000000000066000000AD020000660000000000000066000000AE02
0000010000002100F00000000000000000000000803F00000000000000000000
803F000000000000000000000000000000000000000000000000000000000000
0000270000001800000001000000000000000000000000000000250000000C00
000001000000280000000C0000000B000000250000000C000000050000001B00
0000100000000000000067000000360000001000000000000000770000002500
00000C000000070000804C000000640000000000000067000000000000007600
0000000000006700000001000000100000002100F00000000000000000000000
803F00000000000000000000803F000000000000000000000000000000000000
000000000000000000000000000027000000180000000B000000000000000000
000000000000250000000C0000000B000000280000000C000000010000002500
00000C000000050000001B000000100000007500000067000000360000001000
00007500000078000000250000000C000000070000804C000000640000007500
0000670000007500000077000000750000006700000001000000110000002100
F00000000000000000000000803F00000000000000000000803F000000000000
0000000000000000000000000000000000000000000000000000250000000C00
0000050000001B00000010000000DE000000670000003600000010000000DE00
000078000000250000000C000000070000804C00000064000000DE0000006700
0000DE00000077000000DE0000006700000001000000110000002100F0000000
0000000000000000803F00000000000000000000803F00000000000000000000
00000000000000000000000000000000000000000000250000000C0000000500
00001B0000001000000001000000770000003600000010000000AE0200007700
0000250000000C000000070000804C000000640000000100000077000000AD02
0000770000000100000077000000AD020000010000002100F000000000000000
00000000803F00000000000000000000803F0000000000000000000000000000
000000000000000000000000000000000000250000000C000000050000001B00
0000100000000000000077000000360000001000000000000000890000002500
00000C000000070000804C000000640000000000000077000000000000008800
0000000000007700000001000000120000002100F00000000000000000000000
803F00000000000000000000803F000000000000000000000000000000000000
0000000000000000000000000000250000000C000000050000001B0000001000
0000470100005600000036000000100000004701000089000000250000000C00
0000070000804C00000064000000470100005600000047010000880000004701
00005600000001000000330000002100F00000000000000000000000803F0000
0000000000000000803F00000000000000000000000000000000000000000000
00000000000000000000250000000C000000050000001B000000100000000100
0000880000003600000010000000AE02000088000000250000000C0000000700
00804C000000640000000100000088000000AD02000088000000010000008800
0000AD020000010000002100F00000000000000000000000803F000000000000
00000000803F0000000000000000000000000000000000000000000000000000
000000000000250000000C000000050000001B00000010000000AD0200005600
00003600000010000000AD02000089000000250000000C000000070000804C00
000064000000AD02000056000000AD02000088000000AD020000560000000100
0000330000002100F00000000000000000000000803F00000000000000000000
803F000000000000000000000000000000000000000000000000000000000000
0000250000000C0000000A000000280000000C0000000B000000180000000C00
0000C0C0C000190000000C000000C0C0C000280000000C000000050000002600
00001C00000005000000000000000000000000000000C0C0C000250000000C00
0000050000001B00000010000000000000008900000036000000100000000000
00008A000000250000000C000000070000804C00000064000000000000000000
0000FFFFFFFFFFFFFFFF000000008900000001000000010000002100F0000000
0000000000000000803F00000000000000000000803F00000000000000000000
00000000000000000000000000000000000000000000250000000C0000000500
00001B0000001000000075000000890000003600000010000000750000008A00
0000250000000C000000070000804C000000640000000000000000000000FFFF
FFFFFFFFFFFF750000008900000001000000010000002100F000000000000000
00000000803F00000000000000000000803F0000000000000000000000000000
000000000000000000000000000000000000250000000C000000050000001B00
000010000000DE000000890000003600000010000000DE0000008A0000002500
00000C000000070000804C000000640000000000000000000000FFFFFFFFFFFF
FFFFDE0000008900000001000000010000002100F00000000000000000000000
803F00000000000000000000803F000000000000000000000000000000000000
0000000000000000000000000000250000000C000000050000001B0000001000
000047010000890000003600000010000000470100008A000000250000000C00
0000070000804C000000640000000000000000000000FFFFFFFFFFFFFFFF4701
00008900000001000000010000002100F00000000000000000000000803F0000
0000000000000000803F00000000000000000000000000000000000000000000
00000000000000000000250000000C000000050000001B00000010000000E501
0000890000003600000010000000E50100008A000000250000000C0000000700
00804C000000640000000000000000000000FFFFFFFFFFFFFFFFE50100008900
000001000000010000002100F00000000000000000000000803F000000000000
00000000803F0000000000000000000000000000000000000000000000000000
000000000000250000000C000000050000001B00000010000000490200008900
00003600000010000000490200008A000000250000000C000000070000804C00
0000640000000000000000000000FFFFFFFFFFFFFFFF49020000890000000100
0000010000002100F00000000000000000000000803F00000000000000000000
803F000000000000000000000000000000000000000000000000000000000000
0000250000000C000000050000001B00000010000000AD020000890000003600
000010000000AD0200008A000000250000000C000000070000804C0000006400
00000000000000000000FFFFFFFFFFFFFFFFAD02000089000000010000000100
00002100F00000000000000000000000803F00000000000000000000803F0000
0000000000000000000000000000000000000000000000000000000000002500
00000C000000050000001B000000100000000000000000000000360000001000
0000AF02000000000000250000000C000000070000804C000000640000000000
000000000000AD020000000000000000000000000000AF020000010000002100
F00000000000000000000000803F00000000000000000000803F000000000000
0000000000000000000000000000000000000000000000000000250000000C00
0000050000001B000000100000004A020000110000003600000010000000AF02
000011000000250000000C000000070000804C000000640000004A0200001100
0000AD020000110000004A0200001100000065000000010000002100F0000000
0000000000000000803F00000000000000000000803F00000000000000000000
00000000000000000000000000000000000000000000250000000C0000000500
00001B000000100000004A020000220000003600000010000000AF0200002200
0000250000000C000000070000804C000000640000004A02000022000000AD02
0000220000004A0200002200000065000000010000002100F000000000000000
00000000803F00000000000000000000803F0000000000000000000000000000
000000000000000000000000000000000000250000000C000000050000001B00
0000100000004A020000330000003600000010000000AF020000330000002500
00000C000000070000804C000000640000004A02000033000000AD0200003300
00004A0200003300000065000000010000002100F00000000000000000000000
803F00000000000000000000803F000000000000000000000000000000000000
0000000000000000000000000000250000000C000000050000001B0000001000
00004A020000440000003600000010000000AF02000044000000250000000C00
0000070000804C000000640000004A02000044000000AD020000440000004A02
00004400000065000000010000002100F00000000000000000000000803F0000
0000000000000000803F00000000000000000000000000000000000000000000
00000000000000000000250000000C000000050000001B00000010000000AE02
0000550000003600000010000000AF02000055000000250000000C0000000700
00804C000000640000000000000000000000FFFFFFFFFFFFFFFFAE0200005500
000001000000010000002100F00000000000000000000000803F000000000000
00000000803F0000000000000000000000000000000000000000000000000000
000000000000250000000C000000050000001B00000010000000AE0200006600
00003600000010000000AF02000066000000250000000C000000070000804C00
0000640000000000000000000000FFFFFFFFFFFFFFFFAE020000660000000100
0000010000002100F00000000000000000000000803F00000000000000000000
803F000000000000000000000000000000000000000000000000000000000000
0000250000000C000000050000001B00000010000000AE020000770000003600
000010000000AF02000077000000250000000C000000070000804C0000006400
00000000000000000000FFFFFFFFFFFFFFFFAE02000077000000010000000100
00002100F00000000000000000000000803F00000000000000000000803F0000
0000000000000000000000000000000000000000000000000000000000002500
00000C000000050000001B00000010000000AE02000088000000360000001000
0000AF02000088000000250000000C000000070000804C000000640000000000
000000000000FFFFFFFFFFFFFFFFAE0200008800000001000000010000002100
F00000000000000000000000803F00000000000000000000803F000000000000
0000000000000000000000000000000000000000000000000000250000000C00
000004000080250000000C0000000D000080220000000C000000FFFFFFFF2100
000008000000250000000C00000009000000190000000C000000C0C0C0001800
00000C000000C0C0C0001E000000180000000100000001000000AE0200008900
0000250000000C0000000400008027000000180000000B00000000000000FFFF
FF0000000000250000000C0000000B000000180000000C000000FFFFFF001900
00000C00000000000000140000000C0000000D000000120000000C0000000200
00004C0000006400000065000000560000007500000066000000650000005600
000011000000110000002100F00000000000000000000000803F000000000000
00000000803F0000000000000000000000000000000000000000000000000000
0000000000001E00000018000000650000005600000076000000670000007200
0000440600006500000056000000750000006600000064000000550000001300
0000130000000000FF0100000000000000000000803F00000000000000000000
803F0000000000000000FFFFFF00000000006C00000034000000A0000000A405
000013000000130000002800000013000000130000000100200003000000A405
0000000000000000000000000000000000000000FF0000FF0000FF0000000A0A
0A0A2E2E2E2E6262626287878787979797979C9C9C9C9D9D9D9D9D9D9D9D9D9D
9D9DC2C2C2C2C2C2C2C2C2C2C2C29D9D9D9D9D9D9D9DA0A0A0A0A7A7A7A7ADAD
ADADA1A1A1A12A2A2A2A0304040844494A508A765AD9805321FB743C00FF743C
00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C
00FF743C00FF7C4B14FD927959EAAAAFAFB492929292080A0C14886D4CE39371
4AFFC3BDB2FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFC5C6C0FF906E48FF8F7655E87D7D
7D7D0B0E101B7C4B14FDCAC7BFFFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFBDBDB6FF7C4B14FD595959590C0F111D743C00FFFFFFFFFFDFCCCDFFDFCC
CDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCC
CDFFDFCCCDFFDFCCCDFFDFCCCDFFFFFFFFFF743C00FF3F3F3F3F0C0F111D743C
00FFFFFFFFFFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1
D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFFFFFFFFF743C
00FF383838380C0F111D743C00FFFFFFFFFFE7D7D6FFE7D7D6FFE7D7D6FFE7D7
D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7
D6FFE7D7D6FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFFFFFFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFFFFFFFFF743C00FF373737370C0F
111D743C00FFFFFFFFFFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFFFFF
FFFF743C00FF373737370C0F111D743C00FFFFFFFFFFF5EBE9FFF5EBE9FFF5EB
E9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EB
E9FFF5EBE9FFF5EBE9FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFF
FFFFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7
F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFFFFFFFF743C00FF3737
37370C0F111D743C00FFFFFFFFFFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFC
F8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFC
F8FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFFFFFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFFFFFFFF743C00FF373737370C0F111D743C
00FFFFFFFFFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFFFFFFFF743C
00FF353535350C10121F743C00FFFFFFFFFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFFFFFFFF743C00FF2C2C2C2C0C0F111D805321FBDCCEBFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDBCEBFFF805321FB0C0C0C0C0C0F
111D857054D6A27D55FFDDCFC0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE8DFD5FFA27D
55FF856F54D502030306090B0D174A515461857054D6805321FB743C00FF743C
00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C
00FF743C00FF7C4B14FD886E4DE3484F515C0406070C02030306090B0D170C10
121F0D1113210D1113210D1113210D1113210D1113210D11132113191C301319
1C3013191C300D1113210D1113210D1113210C10121F0C0F111D090B0D170203
03064B0000004000000030000000050000002000000001000000010000001000
00000100000001000000AE020000890000000100000001000000AE0200008900
0000250000000C00000000000080250000000C00000004000080180000000C00
000000000000280000000C00000005000000260000001C000000050000000000
0000000000000000000000000000250000000C000000050000001B0000001000
00006A0000005D0000003600000010000000710000005D000000250000000C00
0000070000804C000000640000006A0000005D000000700000005D0000006A00
00005D00000007000000010000002100F00000000000000000000000803F0000
0000000000000000803F00000000000000000000000000000000000000000000
00000000000000000000250000000C000000050000001B000000100000006B00
00005E0000003600000010000000700000005E000000250000000C0000000700
00804C000000640000006B0000005E0000006F0000005E0000006B0000005E00
000005000000010000002100F00000000000000000000000803F000000000000
00000000803F0000000000000000000000000000000000000000000000000000
000000000000250000000C000000050000001B000000100000006C0000005F00
000036000000100000006F0000005F000000250000000C000000070000804C00
0000640000006C0000005F0000006E0000005F0000006C0000005F0000000300
0000010000002100F00000000000000000000000803F00000000000000000000
803F000000000000000000000000000000000000000000000000000000000000
0000250000000C000000050000001B000000100000006D000000600000003600
0000100000006E00000060000000250000000C000000070000804C0000006400
00006D000000600000006D000000600000006D00000060000000010000000100
00002100F00000000000000000000000803F00000000000000000000803F0000
0000000000000000000000000000000000000000000000000000000000002500
00000C000000040000801610000026060F002220574D46430100000000000100
0000000000000600000000200000402F000040AF0000250000000C0000000400
0080250000000C0000000B000000180000000C000000FFFFFF004C0000006400
0000CE00000056000000DE00000066000000CE00000056000000110000001100
00002100F00000000000000000000000803F00000000000000000000803F0000
0000000000000000000000000000000000000000000000000000000000001E00
000018000000CE00000056000000DF000000670000007200000044060000CE00
000056000000DE00000066000000CD0000005500000013000000130000000000
FF0100000000000000000000803F00000000000000000000803F000000000000
0000FFFFFF00000000006C00000034000000A0000000A4050000130000001300
00002800000013000000130000000100200003000000A4050000000000000000
000000000000000000000000FF0000FF0000FF0000000A0A0A0A2E2E2E2E6262
626287878787979797979C9C9C9C9D9D9D9D9D9D9D9D9D9D9D9DC2C2C2C2C2C2
C2C2C2C2C2C29D9D9D9D9D9D9D9DA0A0A0A0A7A7A7A7ADADADADA1A1A1A12A2A
2A2A0304040844494A508A765AD9805321FB743C00FF743C00FF743C00FF743C
00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF7C4B
14FD927959EAAAAFAFB492929292080A0C14886D4CE393714AFFC3BDB2FFD7C5
C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFD7C5C6FFD7C5C6FFC5C6C0FF906E48FF8F7655E87D7D7D7D0B0E101B7C4B
14FDCAC7BFFFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFBDBDB6FF7C4B
14FD595959590C0F111D743C00FFFFFFFFFFDFCCCDFFDFCCCDFFDFCCCDFFDFCC
CDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCC
CDFFDFCCCDFFFFFFFFFF743C00FF3F3F3F3F0C0F111D743C00FFFFFFFFFFE4D1
D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1
D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFFFFFFFFF743C00FF383838380C0F
111D743C00FFFFFFFFFFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7
D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFFFFF
FFFF743C00FF373737370C0F111D743C00FFFFFFFFFFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFF
FFFFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFFFFFFFFF743C00FF3737
37370C0F111D743C00FFFFFFFFFFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EB
E9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EB
E9FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFFFFFFFDF7F6FFFDF7
F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7
F6FFFDF7F6FFFDF7F6FFFDF7F6FFFFFFFFFF743C00FF373737370C0F111D743C
00FFFFFFFFFFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFC
F8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFFFFFFFF743C
00FF373737370C0F111D743C00FFFFFFFFFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFFFFFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFFFFFFFF743C00FF353535350C10
121F743C00FFFFFFFFFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFFFF
FFFF743C00FF2C2C2C2C0C0F111D805321FBDCCEBFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFDBCEBFFF805321FB0C0C0C0C0C0F111D857054D6A27D
55FFDDCFC0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE8DFD5FFA27D55FF856F54D50203
0306090B0D174A515461857054D6805321FB743C00FF743C00FF743C00FF743C
00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF7C4B
14FD886E4DE3484F515C0406070C02030306090B0D170C10121F0D1113210D11
13210D1113210D1113210D1113210D11132113191C3013191C3013191C300D11
13210D1113210D1113210C10121F0C0F111D090B0D17020303064B0000004000
0000300000000500000020000000010000000100000010000000010000000100
0000AE020000890000000100000001000000AE02000089000000250000000C00
000000000080250000000C00000004000080180000000C000000000000002500
00000C000000050000001B00000010000000D30000005D000000360000001000
0000DA0000005D000000250000000C000000070000804C00000064000000D300
00005D000000D90000005D000000D30000005D00000007000000010000002100
F00000000000000000000000803F00000000000000000000803F000000000000
0000000000000000000000000000000000000000000000000000250000000C00
0000050000001B00000010000000D40000005E0000003600000010000000D900
00005E000000250000000C000000070000804C00000064000000D40000005E00
0000D80000005E000000D40000005E00000005000000010000002100F0000000
0000000000000000803F00000000000000000000803F00000000000000000000
00000000000000000000000000000000000000000000250000000C0000000500
00001B00000010000000D50000005F0000003600000010000000D80000005F00
0000250000000C000000070000804C00000064000000D50000005F000000D700
00005F000000D50000005F00000003000000010000002100F000000000000000
00000000803F00000000000000000000803F0000000000000000000000000000
000000000000000000000000000000000000250000000C000000050000001B00
000010000000D6000000600000003600000010000000D7000000600000002500
00000C000000070000804C00000064000000D600000060000000D60000006000
0000D60000006000000001000000010000002100F00000000000000000000000
803F00000000000000000000803F000000000000000000000000000000000000
0000000000000000000000000000250000000C00000004000080250000000C00
000004000080250000000C0000000B000000180000000C000000FFFFFF004C00
0000640000003701000056000000470100006600000037010000560000001100
0000110000002100F00000000000000000000000803F00000000000000000000
803F000000000000000000000000000000000000000000000000000000000000
00001E0000001800000037010000560000004801000067000000720000004406
0000370100005600000047010000660000003601000055000000130000001300
00000000FF0100000000000000000000803F00000000000000000000803F0000
000000000000FFFFFF00000000006C00000034000000A0000000A40500001300
0000130000002800000013000000130000000100200003000000A40500000000
00000000000000000000000000000000FF0000FF0000FF0000000A0A0A0A2E2E
2E2E6262626287878787979797979C9C9C9C9D9D9D9D9D9D9D9D9D9D9D9DC2C2
C2C2C2C2C2C2C2C2C2C29D9D9D9D9D9D9D9DA0A0A0A0A7A7A7A7ADADADADA1A1
A1A12A2A2A2A0304040844494A508A765AD9805321FB743C00FF743C00FF743C
00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C
00FF7C4B14FD927959EAAAAFAFB492929292080A0C14886D4CE393714AFFC3BD
B2FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFD7C5C6FFD7C5C6FFD7C5C6FFC5C6C0FF906E48FF8F7655E87D7D7D7D0B0E
101B7C4B14FDCAC7BFFFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFBDBD
B6FF7C4B14FD595959590C0F111D743C00FFFFFFFFFFDFCCCDFFDFCCCDFFDFCC
CDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCC
CDFFDFCCCDFFDFCCCDFFFFFFFFFF743C00FF3F3F3F3F0C0F111D743C00FFFFFF
FFFFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1
D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFFFFFFFFF743C00FF3838
38380C0F111D743C00FFFFFFFFFFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7
D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7
D6FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFFFFFFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFFFFFFFFF743C00FF373737370C0F111D743C
00FFFFFFFFFFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFFFFFFFFF743C
00FF373737370C0F111D743C00FFFFFFFFFFF5EBE9FFF5EBE9FFF5EBE9FFF5EB
E9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EB
E9FFF5EBE9FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFFFFFFFDF7
F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7
F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFFFFFFFF743C00FF373737370C0F
111D743C00FFFFFFFFFFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFC
F8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFFFF
FFFF743C00FF373737370C0F111D743C00FFFFFFFFFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFF
FFFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFFFFFFFF743C00FF3535
35350C10121F743C00FFFFFFFFFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFFFFFFFF743C00FF2C2C2C2C0C0F111D805321FBDCCEBFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFDBCEBFFF805321FB0C0C0C0C0C0F111D8570
54D6A27D55FFDDCFC0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE8DFD5FFA27D55FF856F
54D502030306090B0D174A515461857054D6805321FB743C00FF743C00FF743C
00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C
00FF7C4B14FD886E4DE3484F515C0406070C02030306090B0D170C10121F0D11
13210D1113210D1113210D1113210D1113210D11132113191C3013191C301319
1C300D1113210D1113210D1113210C10121F0C0F111D090B0D17020303064B00
0000400000003000000005000000200000000100000001000000100000000100
000001000000AE020000890000000100000001000000AE020000890000002500
00000C00000000000080250000000C00000004000080180000000C0000000000
0000250000000C000000050000001B000000100000003C0100005D0000003600
000010000000430100005D000000250000000C000000070000804C0000006400
00003C0100005D000000420100005D0000003C0100005D000000070000000100
00002100F00000000000000000000000803F00000000000000000000803F0000
0000000000000000000000000000000000000000000000000000000000002500
00000C000000050000001B000000100000003D0100005E000000360000001000
0000420100005E000000250000000C000000070000804C000000640000003D01
00005E000000410100005E0000003D0100005E00000005000000010000002100
F00000000000000000000000803F00000000000000000000803F000000000000
0000000000000000000000000000000000000000000000000000250000000C00
0000050000001B000000100000003E0100005F00000036000000100000004101
00005F000000250000000C000000070000804C000000640000003E0100005F00
0000400100005F0000003E0100005F00000003000000010000002100F0000000
0000000000000000803F00000000000000000000803F00000000000000000000
00000000000000000000000000000000000000000000250000000C0000000500
00001B000000100000003F010000600000003600000010000000400100006000
0000250000000C000000070000804C000000640000003F010000600000003F01
0000600000003F0100006000000001000000010000002100F000000000000000
00000000803F00000000000000000000803F0000000000000000000000000000
000000000000000000000000000000000000250000000C000000040000802500
00000C00000004000080250000000C0000000B000000180000000C000000FFFF
FF004C00000064000000CE00000012000000DE00000022000000CE0000001200
000011000000110000002100F00000000000000000000000803F000000000000
00000000803F0000000000000000000000000000000000000000000000000000
0000000000001E00000018000000CE00000012000000DF000000230000007200
000044060000CE00000012000000DE00000022000000CD000000110000001300
0000130000000000FF0100000000000000000000803F00000000000000000000
803F0000000000000000FFFFFF00000000006C00000034000000A0000000A405
000013000000130000002800000013000000130000000100200003000000A405
0000000000000000000000000000000000000000FF0000FF0000FF0000000A0A
0A0A2E2E2E2E6262626287878787979797979C9C9C9C9D9D9D9D9D9D9D9D9D9D
9D9DC2C2C2C2C2C2C2C2C2C2C2C29D9D9D9D9D9D9D9DA0A0A0A0A7A7A7A7ADAD
ADADA1A1A1A12A2A2A2A0304040844494A508A765AD9805321FB743C00FF743C
00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C
00FF743C00FF7C4B14FD927959EAAAAFAFB492929292080A0C14886D4CE39371
4AFFC3BDB2FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFC5C6C0FF906E48FF8F7655E87D7D
7D7D0B0E101B7C4B14FDCAC7BFFFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFBDBDB6FF7C4B14FD595959590C0F111D743C00FFFFFFFFFFDFCCCDFFDFCC
CDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCC
CDFFDFCCCDFFDFCCCDFFDFCCCDFFFFFFFFFF743C00FF3F3F3F3F0C0F111D743C
00FFFFFFFFFFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1
D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFFFFFFFFF743C
00FF383838380C0F111D743C00FFFFFFFFFFE7D7D6FFE7D7D6FFE7D7D6FFE7D7
D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7
D6FFE7D7D6FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFFFFFFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFFFFFFFFF743C00FF373737370C0F
111D743C00FFFFFFFFFFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFFFFF
FFFF743C00FF373737370C0F111D743C00FFFFFFFFFFF5EBE9FFF5EBE9FFF5EB
E9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EB
E9FFF5EBE9FFF5EBE9FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFF
FFFFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7
F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFFFFFFFF743C00FF3737
37370C0F111D743C00FFFFFFFFFFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFC
F8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFC
F8FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFFFFFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFFFFFFFF743C00FF373737370C0F111D743C
00FFFFFFFFFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFFFFFFFF743C
00FF353535350C10121F743C00FFFFFFFFFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFFFFFFFF743C00FF2C2C2C2C0C0F111D805321FBDCCEBFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDBCEBFFF805321FB0C0C0C0C0C0F
111D857054D6A27D55FFDDCFC0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE8DFD5FFA27D
55FF856F54D502030306090B0D174A515461857054D6805321FB743C00FF743C
00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C
00FF743C00FF7C4B14FD886E4DE3484F515C0406070C02030306090B0D170C10
121F0D1113210D1113210D1113210D1113210D1113210D11132113191C301319
1C3013191C300D1113210D1113210D1113210C10121F0C0F111D090B0D170203
03064B0000004000000030000000050000002000000001000000010000001000
00000100000001000000AE020000890000000100000001000000AE0200008900
0000250000000C00000000000080250000000C00000004000080180000000C00
000000000000250000000C000000050000001B00000010000000D30000001900
00003600000010000000DA00000019000000250000000C000000070000804C00
000064000000D300000019000000D900000019000000D3000000190000000700
0000010000002100F00000000000000000000000803F00000000000000000000
803F000000000000000000000000000000000000000000000000000000000000
0000250000000C000000050000001B00000010000000D40000001A0000003600
000010000000D90000001A000000250000000C000000070000804C0000006400
0000D40000001A000000D80000001A000000D40000001A000000050000000100
00002100F00000000000000000000000803F00000000000000000000803F0000
0000000000000000000000000000000000000000000000000000000000002500
00000C000000050000001B00000010000000D50000001B000000360000001000
0000D80000001B000000250000000C000000070000804C00000064000000D500
00001B000000D70000001B000000D50000001B00000003000000010000002100
F00000000000000000000000803F00000000000000000000803F000000000000
0000000000000000000000000000000000000000000000000000250000000C00
0000050000001B00000010000000D60000001C0000003600000010000000D700
00001C000000250000000C000000070000804C00000064000000D60000001C00
0000D60000001C000000D60000001C00000001000000010000002100F0000000
0000000000000000803F00000000000000000000803F00000000000000000000
00000000000000000000000000000000000000000000250000000C0000000400
0080250000000C00000004000080250000000C0000000B000000180000000C00
0000FFFFFF004C00000064000000390200001200000049020000220000003902
00001200000011000000110000002100F00000000000000000000000803F0000
0000000000000000803F00000000000000000000000000000000000000000000
000000000000000000001E0000001800000039020000120000004A0200002300
0000720000004406000039020000120000004902000022000000380200001100
000013000000130000000000FF0100000000000000000000803F000000000000
00000000803F0000000000000000FFFFFF00000000006C00000034000000A000
0000A40500001300000013000000280000001300000013000000010020000300
0000A4050000000000000000000000000000000000000000FF0000FF0000FF00
00000A0A0A0A2E2E2E2E6262626287878787979797979C9C9C9C9D9D9D9D9D9D
9D9D9D9D9D9DC2C2C2C2C2C2C2C2C2C2C2C29D9D9D9D9D9D9D9DA0A0A0A0A7A7
A7A7ADADADADA1A1A1A12A2A2A2A0304040844494A508A765AD9805321FB743C
00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C
00FF743C00FF743C00FF7C4B14FD927959EAAAAFAFB492929292080A0C14886D
4CE393714AFFC3BDB2FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFC5C6C0FF906E48FF8F76
55E87D7D7D7D0B0E101B7C4B14FDCAC7BFFFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFD7C5C6FFBDBDB6FF7C4B14FD595959590C0F111D743C00FFFFFFFFFFDFCC
CDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCC
CDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFFFFFFFFF1610000026060F002220
574D464301000000000001000000000000000600000000200000400F000040AF
0000743C00FF3F3F3F3F0C0F111D743C00FFFFFFFFFFE4D1D2FFE4D1D2FFE4D1
D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1
D2FFE4D1D2FFE4D1D2FFFFFFFFFF743C00FF383838380C0F111D743C00FFFFFF
FFFFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7
D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFFFFFFFFF743C00FF3737
37370C0F111D743C00FFFFFFFFFFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFFFFFFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFFFFFFFFF743C00FF373737370C0F111D743C
00FFFFFFFFFFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EB
E9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFFFFFFFFF743C
00FF373737370C0F111D743C00FFFFFFFFFFFDF7F6FFFDF7F6FFFDF7F6FFFDF7
F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7
F6FFFDF7F6FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFFFFFFFDFC
F8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFC
F8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFFFFFFFF743C00FF373737370C0F
111D743C00FFFFFFFFFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFFFF
FFFF743C00FF373737370C0F111D743C00FFFFFFFFFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFFFFFFFF743C00FF353535350C10121F743C00FFFFFF
FFFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFFFFFFFF743C00FF2C2C
2C2C0C0F111D805321FBDCCEBFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFDBCEBFFF805321FB0C0C0C0C0C0F111D857054D6A27D55FFDDCFC0FFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFE8DFD5FFA27D55FF856F54D502030306090B0D174A51
5461857054D6805321FB743C00FF743C00FF743C00FF743C00FF743C00FF743C
00FF743C00FF743C00FF743C00FF743C00FF743C00FF7C4B14FD886E4DE3484F
515C0406070C02030306090B0D170C10121F0D1113210D1113210D1113210D11
13210D1113210D11132113191C3013191C3013191C300D1113210D1113210D11
13210C10121F0C0F111D090B0D17020303064B00000040000000300000000500
0000200000000100000001000000100000000100000001000000AE0200008900
00000100000001000000AE02000089000000250000000C000000000000802500
00000C00000004000080180000000C00000000000000250000000C0000000500
00001B000000100000003E020000190000003600000010000000450200001900
0000250000000C000000070000804C000000640000003E020000190000004402
0000190000003E0200001900000007000000010000002100F000000000000000
00000000803F00000000000000000000803F0000000000000000000000000000
000000000000000000000000000000000000250000000C000000050000001B00
0000100000003F0200001A0000003600000010000000440200001A0000002500
00000C000000070000804C000000640000003F0200001A000000430200001A00
00003F0200001A00000005000000010000002100F00000000000000000000000
803F00000000000000000000803F000000000000000000000000000000000000
0000000000000000000000000000250000000C000000050000001B0000001000
0000400200001B0000003600000010000000430200001B000000250000000C00
0000070000804C00000064000000400200001B000000420200001B0000004002
00001B00000003000000010000002100F00000000000000000000000803F0000
0000000000000000803F00000000000000000000000000000000000000000000
00000000000000000000250000000C000000050000001B000000100000004102
00001C0000003600000010000000420200001C000000250000000C0000000700
00804C00000064000000410200001C000000410200001C000000410200001C00
000001000000010000002100F00000000000000000000000803F000000000000
00000000803F0000000000000000000000000000000000000000000000000000
000000000000250000000C00000004000080250000000C000000040000802500
00000C0000000B000000180000000C000000FFFFFF004C00000064000000CE00
000023000000DE00000033000000CE0000002300000011000000110000002100
F00000000000000000000000803F00000000000000000000803F000000000000
00000000000000000000000000000000000000000000000000001E0000001800
0000CE00000023000000DF000000340000007200000044060000CE0000002300
0000DE00000033000000CD0000002200000013000000130000000000FF010000
0000000000000000803F00000000000000000000803F0000000000000000FFFF
FF00000000006C00000034000000A0000000A405000013000000130000002800
000013000000130000000100200003000000A405000000000000000000000000
0000000000000000FF0000FF0000FF0000000A0A0A0A2E2E2E2E626262628787
8787979797979C9C9C9C9D9D9D9D9D9D9D9D9D9D9D9DC2C2C2C2C2C2C2C2C2C2
C2C29D9D9D9D9D9D9D9DA0A0A0A0A7A7A7A7ADADADADA1A1A1A12A2A2A2A0304
040844494A508A765AD9805321FB743C00FF743C00FF743C00FF743C00FF743C
00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF7C4B14FD9279
59EAAAAFAFB492929292080A0C14886D4CE393714AFFC3BDB2FFD7C5C6FFD7C5
C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFD7C5C6FFC5C6C0FF906E48FF8F7655E87D7D7D7D0B0E101B7C4B14FDCAC7
BFFFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFBDBDB6FF7C4B14FD5959
59590C0F111D743C00FFFFFFFFFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCC
CDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCC
CDFFFFFFFFFF743C00FF3F3F3F3F0C0F111D743C00FFFFFFFFFFE4D1D2FFE4D1
D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1
D2FFE4D1D2FFE4D1D2FFE4D1D2FFFFFFFFFF743C00FF383838380C0F111D743C
00FFFFFFFFFFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7
D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFFFFFFFFF743C
00FF373737370C0F111D743C00FFFFFFFFFFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFFFFFFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFFFFFFFFF743C00FF373737370C0F
111D743C00FFFFFFFFFFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EB
E9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFFFFF
FFFF743C00FF373737370C0F111D743C00FFFFFFFFFFFDF7F6FFFDF7F6FFFDF7
F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7
F6FFFDF7F6FFFDF7F6FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFF
FFFFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFC
F8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFFFFFFFF743C00FF3737
37370C0F111D743C00FFFFFFFFFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFFFFFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFFFFFFFF743C00FF353535350C10121F743C
00FFFFFFFFFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFFFFFFFF743C
00FF2C2C2C2C0C0F111D805321FBDCCEBFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFDBCEBFFF805321FB0C0C0C0C0C0F111D857054D6A27D55FFDDCF
C0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFE8DFD5FFA27D55FF856F54D502030306090B
0D174A515461857054D6805321FB743C00FF743C00FF743C00FF743C00FF743C
00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF7C4B14FD886E
4DE3484F515C0406070C02030306090B0D170C10121F0D1113210D1113210D11
13210D1113210D1113210D11132113191C3013191C3013191C300D1113210D11
13210D1113210C10121F0C0F111D090B0D17020303064B000000400000003000
000005000000200000000100000001000000100000000100000001000000AE02
0000890000000100000001000000AE02000089000000250000000C0000000000
0080250000000C00000004000080180000000C00000000000000250000000C00
0000050000001B00000010000000D30000002A0000003600000010000000DA00
00002A000000250000000C000000070000804C00000064000000D30000002A00
0000D90000002A000000D30000002A00000007000000010000002100F0000000
0000000000000000803F00000000000000000000803F00000000000000000000
00000000000000000000000000000000000000000000250000000C0000000500
00001B00000010000000D40000002B0000003600000010000000D90000002B00
0000250000000C000000070000804C00000064000000D40000002B000000D800
00002B000000D40000002B00000005000000010000002100F000000000000000
00000000803F00000000000000000000803F0000000000000000000000000000
000000000000000000000000000000000000250000000C000000050000001B00
000010000000D50000002C0000003600000010000000D80000002C0000002500
00000C000000070000804C00000064000000D50000002C000000D70000002C00
0000D50000002C00000003000000010000002100F00000000000000000000000
803F00000000000000000000803F000000000000000000000000000000000000
0000000000000000000000000000250000000C000000050000001B0000001000
0000D60000002D0000003600000010000000D70000002D000000250000000C00
0000070000804C00000064000000D60000002D000000D60000002D000000D600
00002D00000001000000010000002100F00000000000000000000000803F0000
0000000000000000803F00000000000000000000000000000000000000000000
00000000000000000000250000000C00000004000080250000000C0000000400
0080250000000C0000000B000000180000000C000000FFFFFF004C0000006400
0000390200002300000049020000330000003902000023000000110000001100
00002100F00000000000000000000000803F00000000000000000000803F0000
0000000000000000000000000000000000000000000000000000000000001E00
00001800000039020000230000004A0200003400000072000000440600003902
0000230000004902000033000000380200002200000013000000130000000000
FF0100000000000000000000803F00000000000000000000803F000000000000
0000FFFFFF00000000006C00000034000000A0000000A4050000130000001300
00002800000013000000130000000100200003000000A4050000000000000000
000000000000000000000000FF0000FF0000FF0000000A0A0A0A2E2E2E2E6262
626287878787979797979C9C9C9C9D9D9D9D9D9D9D9D9D9D9D9DC2C2C2C2C2C2
C2C2C2C2C2C29D9D9D9D9D9D9D9DA0A0A0A0A7A7A7A7ADADADADA1A1A1A12A2A
2A2A0304040844494A508A765AD9805321FB743C00FF743C00FF743C00FF743C
00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF7C4B
14FD927959EAAAAFAFB492929292080A0C14886D4CE393714AFFC3BDB2FFD7C5
C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFD7C5C6FFD7C5C6FFC5C6C0FF906E48FF8F7655E87D7D7D7D0B0E101B7C4B
14FDCAC7BFFFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFBDBDB6FF7C4B
14FD595959590C0F111D743C00FFFFFFFFFFDFCCCDFFDFCCCDFFDFCCCDFFDFCC
CDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCC
CDFFDFCCCDFFFFFFFFFF743C00FF3F3F3F3F0C0F111D743C00FFFFFFFFFFE4D1
D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1
D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFFFFFFFFF743C00FF383838380C0F
111D743C00FFFFFFFFFFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7
D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFFFFF
FFFF743C00FF373737370C0F111D743C00FFFFFFFFFFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFF
FFFFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFFFFFFFFF743C00FF3737
37370C0F111D743C00FFFFFFFFFFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EB
E9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EB
E9FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFFFFFFFDF7F6FFFDF7
F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7
F6FFFDF7F6FFFDF7F6FFFDF7F6FFFFFFFFFF743C00FF373737370C0F111D743C
00FFFFFFFFFFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFC
F8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFFFFFFFF743C
00FF373737370C0F111D743C00FFFFFFFFFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFFFFFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFFFFFFFF743C00FF353535350C10
121F743C00FFFFFFFFFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFFFF
FFFF743C00FF2C2C2C2C0C0F111D805321FBDCCEBFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFDBCEBFFF805321FB0C0C0C0C0C0F111D857054D6A27D
55FFDDCFC0FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE8DFD5FFA27D55FF856F54D50203
0306090B0D174A515461857054D6805321FB743C00FF743C00FF743C00FF743C
00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF7C4B
14FD886E4DE3484F515C0406070C02030306090B0D170C10121F0D1113210D11
13210D1113210D1113210D1113210D11132113191C3013191C3013191C300D11
13210D1113210D1113210C10121F0C0F111D090B0D17020303064B0000004000
0000300000000500000020000000010000000100000010000000010000000100
0000AE020000890000000100000001000000AE02000089000000250000000C00
000000000080250000000C00000004000080180000000C000000000000002500
00000C000000050000001B000000100000003E0200002A000000360000001000
0000450200002A000000250000000C000000070000804C000000640000003E02
00002A000000440200002A0000003E0200002A00000007000000010000002100
F00000000000000000000000803F00000000000000000000803F000000000000
0000000000000000000000000000000000000000000000000000250000000C00
0000050000001B000000100000003F0200002B00000036000000100000004402
00002B000000250000000C000000070000804C000000640000003F0200002B00
0000430200002B0000003F0200002B00000005000000010000002100F0000000
0000000000000000803F00000000000000000000803F00000000000000000000
00000000000000000000000000000000000000000000250000000C0000000500
00001B00000010000000400200002C0000003600000010000000430200002C00
0000250000000C000000070000804C00000064000000400200002C0000004202
00002C000000400200002C00000003000000010000002100F000000000000000
00000000803F00000000000000000000803F0000000000000000000000000000
000000000000000000000000000000000000250000000C000000050000001B00
000010000000410200002D0000003600000010000000420200002D0000002500
00000C000000070000804C00000064000000410200002D000000410200002D00
0000410200002D00000001000000010000002100F00000000000000000000000
803F00000000000000000000803F000000000000000000000000000000000000
0000000000000000000000000000250000000C00000004000080250000000C00
000004000080250000000C0000000B000000180000000C000000FFFFFF004C00
000064000000CE00000034000000DE00000044000000CE000000340000001100
0000110000002100F00000000000000000000000803F00000000000000000000
803F000000000000000000000000000000000000000000000000000000000000
00001E00000018000000CE00000034000000DF00000045000000720000004406
0000CE00000034000000DE00000044000000CD00000033000000130000001300
00000000FF0100000000000000000000803F00000000000000000000803F0000
000000000000FFFFFF00000000006C00000034000000A0000000A40500001300
0000130000002800000013000000130000000100200003000000A40500000000
00000000000000000000000000000000FF0000FF0000FF0000000A0A0A0A2E2E
2E2E6262626287878787979797979C9C9C9C9D9D9D9D9D9D9D9D9D9D9D9DC2C2
C2C2C2C2C2C2C2C2C2C29D9D9D9D9D9D9D9DA0A0A0A0A7A7A7A7ADADADADA1A1
A1A12A2A2A2A0304040844494A508A765AD9805321FB743C00FF743C00FF743C
00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C
00FF7C4B14FD927959EAAAAFAFB492929292080A0C14886D4CE393714AFFC3BD
B2FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFD7C5C6FFD7C5C6FFD7C5C6FFC5C6C0FF906E48FF8F7655E87D7D7D7D0B0E
101B7C4B14FDCAC7BFFFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFBDBD
B6FF7C4B14FD595959590C0F111D743C00FFFFFFFFFFDFCCCDFFDFCCCDFFDFCC
CDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCC
CDFFDFCCCDFFDFCCCDFFFFFFFFFF743C00FF3F3F3F3F0C0F111D743C00FFFFFF
FFFFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1
D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFFFFFFFFF743C00FF3838
38380C0F111D743C00FFFFFFFFFFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7
D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7
D6FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFFFFFFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFFFFFFFFF743C00FF373737370C0F111D743C
00FFFFFFFFFFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFFFFFFFFF743C
00FF373737370C0F111D743C00FFFFFFFFFFF5EBE9FFF5EBE9FFF5EBE9FFF5EB
E9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EB
E9FFF5EBE9FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFFFFFFFDF7
F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7
F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFFFFFFFF743C00FF373737370C0F
111D743C00FFFFFFFFFFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFC
F8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFFFF
FFFF743C00FF373737370C0F111D743C00FFFFFFFFFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFF
FFFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFFFFFFFF743C00FF3535
3535B607000026060F00620F574D464301000000000001000000000000000600
0000400F00000000000040AF00000C10121F743C00FFFFFFFFFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFFFFFFFF743C00FF2C2C2C2C0C0F111D8053
21FBDCCEBFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDBCEBFFF8053
21FB0C0C0C0C0C0F111D857054D6A27D55FFDDCFC0FFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFE8DFD5FFA27D55FF856F54D502030306090B0D174A515461857054D68053
21FB743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C
00FF743C00FF743C00FF743C00FF7C4B14FD886E4DE3484F515C0406070C0203
0306090B0D170C10121F0D1113210D1113210D1113210D1113210D1113210D11
132113191C3013191C3013191C300D1113210D1113210D1113210C10121F0C0F
111D090B0D17020303064B000000400000003000000005000000200000000100
000001000000100000000100000001000000AE02000089000000010000000100
0000AE02000089000000250000000C00000000000080250000000C0000000400
0080180000000C00000000000000250000000C000000050000001B0000001000
0000D30000003B0000003600000010000000DA0000003B000000250000000C00
0000070000804C00000064000000D30000003B000000D90000003B000000D300
00003B00000007000000010000002100F00000000000000000000000803F0000
0000000000000000803F00000000000000000000000000000000000000000000
00000000000000000000250000000C000000050000001B00000010000000D400
00003C0000003600000010000000D90000003C000000250000000C0000000700
00804C00000064000000D40000003C000000D80000003C000000D40000003C00
000005000000010000002100F00000000000000000000000803F000000000000
00000000803F0000000000000000000000000000000000000000000000000000
000000000000250000000C000000050000001B00000010000000D50000003D00
00003600000010000000D80000003D000000250000000C000000070000804C00
000064000000D50000003D000000D70000003D000000D50000003D0000000300
0000010000002100F00000000000000000000000803F00000000000000000000
803F000000000000000000000000000000000000000000000000000000000000
0000250000000C000000050000001B00000010000000D60000003E0000003600
000010000000D70000003E000000250000000C000000070000804C0000006400
0000D60000003E000000D60000003E000000D60000003E000000010000000100
00002100F00000000000000000000000803F00000000000000000000803F0000
0000000000000000000000000000000000000000000000000000000000002500
00000C00000004000080250000000C00000004000080250000000C0000000B00
0000180000000C000000FFFFFF004C0000006400000039020000340000004902
000044000000390200003400000011000000110000002100F000000000000000
00000000803F00000000000000000000803F0000000000000000000000000000
0000000000000000000000000000000000001E00000018000000390200003400
00004A0200004500000072000000440600003902000034000000490200004400
0000380200003300000013000000130000000000FF0100000000000000000000
803F00000000000000000000803F0000000000000000FFFFFF00000000006C00
000034000000A0000000A4050000130000001300000028000000130000001300
00000100200003000000A4050000000000000000000000000000000000000000
FF0000FF0000FF0000000A0A0A0A2E2E2E2E6262626287878787979797979C9C
9C9C9D9D9D9D9D9D9D9D9D9D9D9DC2C2C2C2C2C2C2C2C2C2C2C29D9D9D9D9D9D
9D9DA0A0A0A0A7A7A7A7ADADADADA1A1A1A12A2A2A2A0304040844494A508A76
5AD9805321FB743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C
00FF743C00FF743C00FF743C00FF743C00FF7C4B14FD927959EAAAAFAFB49292
9292080A0C14886D4CE393714AFFC3BDB2FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFC5C6
C0FF906E48FF8F7655E87D7D7D7D0B0E101B7C4B14FDCAC7BFFFD7C5C6FFD7C5
C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5C6FFD7C5
C6FFD7C5C6FFD7C5C6FFD7C5C6FFBDBDB6FF7C4B14FD595959590C0F111D743C
00FFFFFFFFFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCC
CDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFDFCCCDFFFFFFFFFF743C
00FF3F3F3F3F0C0F111D743C00FFFFFFFFFFE4D1D2FFE4D1D2FFE4D1D2FFE4D1
D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1D2FFE4D1
D2FFE4D1D2FFFFFFFFFF743C00FF383838380C0F111D743C00FFFFFFFFFFE7D7
D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7
D6FFE7D7D6FFE7D7D6FFE7D7D6FFE7D7D6FFFFFFFFFF743C00FF373737370C0F
111D743C00FFFFFFFFFFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFFFFF
FFFF743C00FF373737370C0F111D743C00FFFFFFFFFFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DAD9FFE7DA
D9FFE7DAD9FFE7DAD9FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFF
FFFFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EB
E9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFF5EBE9FFFFFFFFFF743C00FF3737
37370C0F111D743C00FFFFFFFFFFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7
F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7F6FFFDF7
F6FFFFFFFFFF743C00FF373737370C0F111D743C00FFFFFFFFFFFDFCF8FFFDFC
F8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFCF8FFFDFC
F8FFFDFCF8FFFDFCF8FFFDFCF8FFFFFFFFFF743C00FF373737370C0F111D743C
00FFFFFFFFFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFFFFFFFF743C
00FF373737370C0F111D743C00FFFFFFFFFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFFFFFFFF743C00FF353535350C10121F743C00FFFFFFFFFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFD
FDFFFDFDFDFFFDFDFDFFFDFDFDFFFDFDFDFFFFFFFFFF743C00FF2C2C2C2C0C0F
111D805321FBDCCEBFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDBCE
BFFF805321FB0C0C0C0C0C0F111D857054D6A27D55FFDDCFC0FFFFFFFFFFFFFF
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
FFFFFFFFFFFFE8DFD5FFA27D55FF856F54D502030306090B0D174A5154618570
54D6805321FB743C00FF743C00FF743C00FF743C00FF743C00FF743C00FF743C
00FF743C00FF743C00FF743C00FF743C00FF7C4B14FD886E4DE3484F515C0406
070C02030306090B0D170C10121F0D1113210D1113210D1113210D1113210D11
13210D11132113191C3013191C3013191C300D1113210D1113210D1113210C10
121F0C0F111D090B0D17020303064B0000004000000030000000050000002000
00000100000001000000100000000100000001000000AE020000890000000100
000001000000AE02000089000000250000000C00000000000080250000000C00
000004000080180000000C00000000000000250000000C000000050000001B00
0000100000003E0200003B0000003600000010000000450200003B0000002500
00000C000000070000804C000000640000003E0200003B000000440200003B00
00003E0200003B00000007000000010000002100F00000000000000000000000
803F00000000000000000000803F000000000000000000000000000000000000
0000000000000000000000000000250000000C000000050000001B0000001000
00003F0200003C0000003600000010000000440200003C000000250000000C00
0000070000804C000000640000003F0200003C000000430200003C0000003F02
00003C00000005000000010000002100F00000000000000000000000803F0000
0000000000000000803F00000000000000000000000000000000000000000000
00000000000000000000250000000C000000050000001B000000100000004002
00003D0000003600000010000000430200003D000000250000000C0000000700
00804C00000064000000400200003D000000420200003D000000400200003D00
000003000000010000002100F00000000000000000000000803F000000000000
00000000803F0000000000000000000000000000000000000000000000000000
000000000000250000000C000000050000001B00000010000000410200003E00
00003600000010000000420200003E000000250000000C000000070000804C00
000064000000410200003E000000410200003E000000410200003E0000000100
0000010000002100F00000000000000000000000803F00000000000000000000
803F000000000000000000000000000000000000000000000000000000000000
0000250000000C000000040000801E000000180000000100000001000000AE02
000089000000140000000C0000000D000000300000000C0000000F0000800D00
00001000000000000000000000004B0000004000000030000000050000002000
00000100000001000000100000000100000001000000AE020000890000000100
000001000000AE02000089000000180000000C00000000000000190000000C00
000000000000250000000C00000004000080250000000C000000090000002200
00000C000000FFFFFFFF460000003400000028000000454D462B2A4000002400
0000180000000000803F00000080000000800000803F00000080000000804600
00001C00000010000000454D462B024000000C000000000000000E0000001400
00000000000010000000140000000400000003010800050000000B0200000000
050000000C028900AE0205000000090200000000050000000102FFFFFF000400
000004010D000400000002010200030000001E00040000002701FFFF03000000
1E00040000002701FFFF030000001E00050000000102FFFFFF00050000000902
00000000040000002701FFFF030000001E00050000000102FFFFFF0005000000
090200000000040000002C0100000700000016048900AE020000000004000000
2701FFFF030000001E00050000000102FFFFFF00050000000902000000000400
00002C0100000700000016048900AE0200000000040000002701FFFF03000000
1E00050000000102FFFFFF0005000000090200000000040000002C0100000700
000016048900AE020100010007000000FC020000000000000000040000002D01
0000050000000102000000000400000004010D0004000000020102000C000000
40092100F00000000000000012006701550047010C00000040092100F0000000
000000001200AE02770000001C000000FB02F3FF000000000000900100000000
00000000417269616C0000000000000000000000000000000000000000000000
00000000040000002D01010007000000FC020000E0DFE3000000040000002D01
0200050000000902E0DFE300050000000102FFFFFF000C00000040092100F000
0000000000000E0072001300020007000000FC020000FFFFFF00000004000000
2D010300050000000902FFFFFF0008000000FA02000000000000FFFFFF000400
00002D010400050000001402120001000500000013021200740008000000FA02
00000000000000000000040000002D0105000C00000040092100F00000000000
00000100730012000100040000002D0104000500000014021200010005000000
130221000100040000002D0105000C00000040092100F0000000000000000F00
01001200010007000000FC0200009D9DA1000000040000002D01060005000000
09029D9DA10004000000F001040008000000FA020000000000009D9DA1000400
00002D0104000500000014021200740005000000130222007400040000002D01
05000C00000040092100F0000000000000001000010012007400040000002D01
04000500000014022100010005000000130221007500040000002D0105000C00
000040092100F0000000000000000100740021000100040000002D0100000500
0000090200000000040000000201010021000000320A120003001100000043F3
6469676F20466F726E656365646F726309000700070003000700070004000800
07000400070007000700070007000700040010000000320A1200780006000000
285475646F29040007000700070007000400040000002D010200050000000902
E0DFE30004000000020102000C00000040092100F0000000000000000E009B00
13004901040000002D010300050000000902FFFFFF0004000000F00104000800
0000FA02000000000000FFFFFF00040000002D01040005000000140212004801
0500000013021200E401040000002D0105000C00000040092100F00000000000
000001009C0012004801040000002D0104000500000014021200480105000000
130221004801040000002D0105000C00000040092100F0000000000000000F00
010012004801040000002D0106000500000009029D9DA10004000000F0010400
08000000FA020000000000009D9DA100040000002D0104000500000014021200
E4010500000013022200E401040000002D0105000C00000040092100F0000000
00000000100001001200E401040000002D010400050000001402210048010500
000013022100E501040000002D0105000C00000040092100F000000000000000
01009D0021004801040000002D01000005000000090200000000040000000201
010028000000320A12004A011600000044656E6F6D696E61E7E36F20466F726E
656365646F7209000700070007000B0003000700070007000700070004000800
07000400070007000700070007000700040010000000320A1200E80106000000
285475646F29040007000700070007000400040000002D010200050000000902
E0DFE30004000000020102000C00000040092100F0000000000000000E007200
24000200040000002D010300050000000902FFFFFF0004000000F00104000800
0000FA02000000000000FFFFFF00040000002D01040005000000140223000100
05000000130223007400040000002D0105000C00000040092100F00000000000
00000100730023000100040000002D0104000500000014022300010005000000
130232000100040000002D0105000C00000040092100F0000000000000000F00
010023000100040000002D0106000500000009029D9DA10004000000F0010400
08000000FA020000000000009D9DA100040000002D0104000500000014022300
740005000000130233007400040000002D0105000C00000040092100F0000000
000000001000010023007400040000002D010400050000001402320001000500
0000130232007500040000002D0105000C00000040092100F000000000000000
0100740032000100040000002D01000005000000090200000000040000000201
01000C000000320A2300030003000000416E6F0009000700070010000000320A
2300780006000000285475646F29040007000700070007000400040000002D01
0200050000000902E0DFE30004000000020102000C00000040092100F0000000
000000000E009B0024004901040000002D010300050000000902FFFFFF000400
0000F001040008000000FA02000000000000FFFFFF00040000002D0104000500
00001402230048010500000013022300E401040000002D0105000C0000004009
2100F00000000000000001009C0023004801040000002D010400050000001402
2300480105000000130232004801040000002D0105000C00000040092100F000
0000000000000F00010023004801040000002D0106000500000009029D9DA100
04000000F001040008000000FA020000000000009D9DA100040000002D010400
0500000014022300E4010500000013023300E401040000002D0105000C000000
40092100F000000000000000100001002300E401040000002D01040005000000
1402320048010500000013023200E501040000002D0105000C00000040092100
F00000000000000001009D0032004801040000002D0100000500000009020000
000004000000020101000C000000320A23004A01030000004DEA73000B000700
070010000000320A2300E80106000000285475646F2904000700070007000700
0400040000002D010200050000000902E0DFE30004000000020102000C000000
40092100F0000000000000000E00720035000200040000002D01030005000000
0902FFFFFF0004000000F001040008000000FA02000000000000FFFFFF000400
00002D0104000500000014023400010005000000130234007400040000002D01
05000C00000040092100F0000000000000000100730034000100040000002D01
04000500000014023400010005000000130243000100040000002D0105000C00
000040092100F0000000000000000F00010034000100040000002D0106000500
000009029D9DA10004000000F001040008000000FA020000000000009D9DA100
040000002D010400050000001402340074000500000013024400740004000000
2D0105000C00000040092100F000000000000000100001003400740004000000
2D0104000500000014024300010005000000130243007500040000002D010500
0C00000040092100F0000000000000000100740043000100040000002D010000
05000000090200000000040000000201010018000000320A340003000B000000
506C616E6F20436F6E7461720900030007000700070004000900070007000400
070010000000320A3400780006000000285475646F2904000700070007000700
0400040000002D010200050000000902E0DFE30004000000020102000C000000
40092100F0000000000000000E009B0035004901040000002D01030005000000
0902FFFFFF0004000000F001040008000000FA02000000000000FFFFFF000400
00002D010400050000001402340048010500000013023400E401040000002D01
05000C00000040092100F00000000000000001009C0034004801040000002D01
04000500000014023400480105000000130243004801040000002D0105000C00
000040092100F0000000000000000F00010034004801040000002D0106000500
000009029D9DA10004000000F001040008000000FA020000000000009D9DA100
040000002D0104000500000014023400E4010500000013024400E40104000000
2D0105000C00000040092100F000000000000000100001003400E40104000000
2D010400050000001402430048010500000013024300E501040000002D010500
0C00000040092100F00000000000000001009D0043004801040000002D010000
05000000090200000000040000000201010019000000320A34004A010C000000
43656E74726F20437573746F0900070007000400040007000400090007000700
0400070010000000320A3400E80106000000285475646F290400070007000700
070004001C000000FB02F3FF000000000000BC02000000000000000041726961
6C00000000000000000000000000000000000000000000000000000004000000
2D0107001B000000320A560003000D0000004461746120436164617374726F00
090008000400080004000900080008000800060004000500080013000000320A
56007800080000005369747561E7E36F09000400040008000800070008000800
18000000320A5600E1000B000000466F726D6120506167746F72080008000500
0C0008000400090008000800040008001C000000FB02F4FF000000000000BC02
0000000000000000417269616C00000000000000000000000000000000000000
0000000000000000040000002D010800050000000902FFCC000015000000320A
57007B01090000004EBA20436F6E746173740800040003000800070007000400
0700070018000000320A5700F9010B00000056616C6F7220546F74616C720800
070003000700050003000700070004000700030016000000320A57005D020A00
000056616C6F72205061676F0800070003000700050003000800070007000700
05000000090200000000040000002D01010012000000320A6700030007000000
2876617A696F296F040005000700070003000700040012000000320A67007800
070000002876617A696F296F040005000700070003000700040012000000320A
6700E100070000002876617A696F296F04000500070007000300070004001C00
0000FB02F3FF000000000000BC020000000000000000417269616C0000000000
00000000000000000000000000000000000000000000040000002D0109000500
00000902FFCC000018000000320A780003000B000000546F74616C2067657261
6C72080008000400080004000400080008000500080004000500000009020000
000007000000FC020000FFFFFF000000040000002D010A001C000000FB021000
070000000000BC02000000000102022253797374656D00000000000000000000
00000000000000000000000000000000040000002D010B00040000002701FFFF
030000001E00040000002D010900040000002D010000050000000102FFFFFF00
05000000090200000000040000002C0100000700000016048900AE0200000000
07000000FC020000C0C0C0000000040000002D010C0004000000F00100000500
00000902C0C0C000050000000102C0C0C0000400000004010D00040000000201
020004000000F001040008000000FA02000000000000C0C0C000040000002D01
00000500000014020000000005000000130211000000040000002D0105000C00
000040092100F0000000000000001100010000000000040000002D0100000500
000014020000750005000000130211007500040000002D0105000C0000004009
2100F000000000000000110001000000750007000000FC020000000000000000
040000002D01040005000000090200000000050000000102FFFFFF0004000000
F001000008000000FA0200000000000000000000040000002D01000005000000
1402110001000500000013021100DF00040000002D0105000C00000040092100
F0000000000000000100DE0011000100040000002D010C0004000000F0010400
050000000902C0C0C000050000000102C0C0C00004000000F001000008000000
FA02000000000000C0C0C000040000002D0100000500000014020000DE000500
000013021100DE00040000002D0105000C00000040092100F000000000000000
110001000000DE00040000002D0100000500000014021100DF00050000001302
11004701040000002D0105000C00000040092100F00000000000000001006800
1100DF00040000002D0100000500000014020000470105000000130211004701
040000002D0105000C00000040092100F0000000000000001100010000004701
040000002D0100000500000014020000E5010500000013021100E50104000000
2D0105000C00000040092100F000000000000000110001000000E50107000000
FC020000000000000000040000002D0104000500000009020000000005000000
0102FFFFFF0004000000F001000008000000FA02000000000000000000000400
00002D0100000500000014021100480105000000130211004A02040000002D01
05000C00000040092100F0000000000000000100020111004801040000002D01
0C0004000000F0010400050000000902C0C0C000050000000102C0C0C0000400
0000F001000008000000FA02000000000000C0C0C000040000002D0100000500
000014020000490205000000130211004902040000002D0105000C0000004009
2100F000000000000000110001000000490207000000FC020000000000000000
040000002D01040005000000090200000000050000000102FFFFFF0004000000
F001000008000000FA0200000000000000000000040000002D01000005000000
1402220001000500000013022200DF00040000002D0105000C00000040092100
F0000000000000000100DE0022000100040000002D010C0004000000F0010400
050000000902C0C0C000050000000102C0C0C00004000000F001000008000000
FA02000000000000C0C0C000040000002D010000050000001302220047010400
00002D0105000C00000040092100F000000000000000010068002200DF000700
0000FC020000000000000000040000002D010400050000000902000000000500
00000102FFFFFF0004000000F001000008000000FA0200000000000000000000
040000002D0100000500000014022200480105000000130222004A0204000000
2D0105000C00000040092100F000000000000000010002012200480104000000
2D010000050000001402330001000500000013023300DF00040000002D010500
0C00000040092100F0000000000000000100DE0033000100040000002D010C00
04000000F0010400050000000902C0C0C000050000000102C0C0C00004000000
F001000008000000FA02000000000000C0C0C000040000002D01000005000000
130233004701040000002D0105000C00000040092100F0000000000000000100
68003300DF0007000000FC020000000000000000040000002D01040005000000
090200000000050000000102FFFFFF0004000000F001000008000000FA020000
0000000000000000040000002D01000005000000140233004801050000001302
33004A02040000002D0105000C00000040092100F00000000000000001000201
33004801040000002D0100000500000014021100000005000000130245000000
040000002D0105000C00000040092100F0000000000000003400010011000000
040000002D010000050000001402120075000500000013024500750004000000
2D0105000C00000040092100F000000000000000330001001200750004000000
2D010000050000001402440001000500000013024400DF00040000002D010500
0C00000040092100F0000000000000000100DE0044000100040000002D010000
0500000014021200DE000500000013024500DE00040000002D0105000C000000
40092100F000000000000000330001001200DE00040000002D010C0004000000
F0010400050000000902C0C0C000050000000102C0C0C00004000000F0010000
08000000FA02000000000000C0C0C000040000002D0100000500000014024400
DF0005000000130244004701040000002D0105000C00000040092100F0000000
00000000010068004400DF0007000000FC020000000000000000040000002D01
040005000000090200000000050000000102FFFFFF0004000000F00100000800
0000FA0200000000000000000000040000002D01000005000000140211004701
05000000130245004701040000002D0105000C00000040092100F00000000000
00003400010011004701040000002D0100000500000014021200E50105000000
13024500E501040000002D0105000C00000040092100F0000000000000003300
01001200E501040000002D010000050000001402440048010500000013024400
4A02040000002D0105000C00000040092100F000000000000000010002014400
4801040000002D01000005000000140212004902050000001302450049020400
00002D0105000C00000040092100F00000000000000033000100120049020400
00002D010C0004000000F0010400050000000902C0C0C000050000000102C0C0
C00004000000F001000008000000FA02000000000000C0C0C000040000002D01
00000500000014024500000005000000130255000000040000002D0105000C00
000040092100F0000000000000001000010045000000040000002D0100000500
000014024500750005000000130255007500040000002D0105000C0000004009
2100F0000000000000001000010045007500040000002D010000050000001402
4500DE000500000013025500DE00040000002D0105000C00000040092100F000
000000000000100001004500DE00040000002D01000005000000140245004701
05000000130255004701040000002D0105000C00000040092100F00000000000
00001000010045004701040000002D0100000500000014024500E50105000000
13025500E501040000002D0105000C00000040092100F0000000000000001000
01004500E501040000002D010000050000001402450049020500000013025500
4902040000002D0105000C00000040092100F000000000000000100001004500
490207000000FC020000000000000000040000002D0104000500000009020000
0000050000000102FFFFFF0004000000F001000008000000FA02000000000000
00000000040000002D010000050000001402550000000500000013025500AE02
040000002D0105000C00000040092100F0000000000000000100AE0255000000
040000002D010C0004000000F0010400050000000902C0C0C000050000000102
C0C0C00004000000F001000008000000FA02000000000000C0C0C00004000000
2D0100000500000014020000AD020500000013025500AD02040000002D010500
0C00000040092100F000000000000000550001000000AD0207000000FC020000
000000000000040000002D01040005000000090200000000050000000102FFFF
FF0004000000F001000008000000FA0200000000000000000000040000002D01
00000500000014025600000005000000130266000000040000002D0105000C00
000040092100F000000000000000100001005600000007000000FC0200000000
00000000040000002D010D0004000000F0010400040000002D01000005000000
13026600AE02040000002D0105000C00000040092100F0000000000000000100
AE026600000007000000FC020000000000000000040000002D01040004000000
F0010D00040000002D0100000500000014026700000005000000130277000000
040000002D0105000C00000040092100F0000000000000001000010067000000
07000000FC020000000000000000040000002D010D0004000000F00104000400
00002D0100000500000014026700750005000000130278007500040000002D01
05000C00000040092100F0000000000000001100010067007500040000002D01
00000500000014026700DE000500000013027800DE00040000002D0105000C00
000040092100F000000000000000110001006700DE00040000002D0100000500
00001402770001000500000013027700AE02040000002D0105000C0000004009
2100F0000000000000000100AD0277000100040000002D010000050000001402
7700000005000000130289000000040000002D0105000C00000040092100F000
0000000000001200010077000000040000002D01000005000000140256004701
05000000130289004701040000002D0105000C00000040092100F00000000000
00003300010056004701040000002D0100000500000014028800010005000000
13028800AE02040000002D0105000C00000040092100F0000000000000000100
AD0288000100040000002D0100000500000014025600AD020500000013028900
AD02040000002D0105000C00000040092100F000000000000000330001005600
AD02040000002D010C0004000000F0010D00050000000902C0C0C00005000000
0102C0C0C00004000000F001000008000000FA02000000000000C0C0C0000400
00002D010000050000001402890000000500000013028A000000040000002D01
05000C00000040092100F0000000000000000100010089000000040000002D01
0000050000001402890075000500000013028A007500040000002D0105000C00
000040092100F0000000000000000100010089007500040000002D0100000500
000014028900DE000500000013028A00DE00040000002D0105000C0000004009
2100F000000000000000010001008900DE00040000002D010000050000001402
890047010500000013028A004701040000002D0105000C00000040092100F000
0000000000000100010089004701040000002D0100000500000014028900E501
0500000013028A00E501040000002D0105000C00000040092100F00000000000
0000010001008900E501040000002D0100000500000014028900490205000000
13028A004902040000002D0105000C00000040092100F0000000000000000100
010089004902040000002D0100000500000014028900AD020500000013028A00
AD02040000002D0105000C00000040092100F000000000000000010001008900
AD02040000002D010000050000001402000000000500000013020000AF020400
00002D0105000C00000040092100F0000000000000000100AF02000000000400
00002D01000005000000140211004A020500000013021100AF02040000002D01
05000C00000040092100F0000000000000000100650011004A02040000002D01
000005000000140222004A020500000013022200AF02040000002D0105000C00
000040092100F0000000000000000100650022004A02040000002D0100000500
0000140233004A020500000013023300AF02040000002D0105000C0000004009
2100F0000000000000000100650033004A02040000002D010000050000001402
44004A020500000013024400AF02040000002D0105000C00000040092100F000
0000000000000100650044004A02040000002D0100000500000014025500AE02
0500000013025500AF02040000002D0105000C00000040092100F00000000000
0000010001005500AE02040000002D0100000500000014026600AE0205000000
13026600AF02040000002D0105000C00000040092100F0000000000000000100
01006600AE02040000002D0100000500000014027700AE020500000013027700
AF02040000002D0105000C00000040092100F000000000000000010001007700
AE02040000002D0100000500000014028800AE020500000013028800AF020400
00002D0105000C00000040092100F000000000000000010001008800AE020700
0000FC020000000000000000040000002D010400040000002D010B0004000000
2701FFFF030000001E00040000002D010900050000000102C0C0C00005000000
0902C0C0C000040000002C0100000700000016048900AE020100010004000000
2D01040007000000FC020000FFFFFF000000040000002D010D00050000000902
FFFFFF00050000000102000000000400000004010D0004000000020102000C00
000040092100F0000000000000001100110056006500040000002C0100000700
000016046700760056006500040000002C0100000700000016048900AE020100
0100040000002D010A00040000002D0104000500000009020000000004000000
F001000008000000FA0200000000000000000000040000002D01000005000000
14025D006A000500000013025D007100040000002D0105000C00000040092100
F000000000000000010007005D006A00040000002D0100000500000014025E00
6B000500000013025E007000040000002D0105000C00000040092100F0000000
00000000010005005E006B00040000002D0100000500000014025F006C000500
000013025F006F00040000002D0105000C00000040092100F000000000000000
010003005F006C00040000002D01000005000000140260006D00050000001302
60006E00040000002D0105000C00000040092100F00000000000000001000100
60006D00040000002D010400040000002D010400040000002D010D0005000000
0902FFFFFF000C00000040092100F000000000000000110011005600CE000400
00002C0100000700000016046700DF005600CE00040000002C01000007000000
16048900AE0201000100040000002D010A00040000002D010400050000000902
00000000040000002D0100000500000014025D00D3000500000013025D00DA00
040000002D0105000C00000040092100F000000000000000010007005D00D300
040000002D0100000500000014025E00D4000500000013025E00D90004000000
2D0105000C00000040092100F000000000000000010005005E00D40004000000
2D0100000500000014025F00D5000500000013025F00D800040000002D010500
0C00000040092100F000000000000000010003005F00D500040000002D010000
0500000014026000D6000500000013026000D700040000002D0105000C000000
40092100F000000000000000010001006000D600040000002D01040004000000
2D010400040000002D010D00050000000902FFFFFF000C00000040092100F000
0000000000001100110056003701040000002C01000007000000160467004801
56003701040000002C0100000700000016048900AE0201000100040000002D01
0A00040000002D01040005000000090200000000040000002D01000005000000
14025D003C010500000013025D004301040000002D0105000C00000040092100
F000000000000000010007005D003C01040000002D0100000500000014025E00
3D010500000013025E004201040000002D0105000C00000040092100F0000000
00000000010005005E003D01040000002D0100000500000014025F003E010500
000013025F004101040000002D0105000C00000040092100F000000000000000
010003005F003E01040000002D01000005000000140260003F01050000001302
60004001040000002D0105000C00000040092100F00000000000000001000100
60003F01040000002D010400040000002D010400040000002D010D0005000000
0902FFFFFF000C00000040092100F000000000000000110011001200CE000400
00002C0100000700000016042300DF001200CE00040000002C01000007000000
16048900AE0201000100040000002D010A00040000002D010400050000000902
00000000040000002D0100000500000014021900D3000500000013021900DA00
040000002D0105000C00000040092100F000000000000000010007001900D300
040000002D0100000500000014021A00D4000500000013021A00D90004000000
2D0105000C00000040092100F000000000000000010005001A00D40004000000
2D0100000500000014021B00D5000500000013021B00D800040000002D010500
0C00000040092100F000000000000000010003001B00D500040000002D010000
0500000014021C00D6000500000013021C00D700040000002D0105000C000000
40092100F000000000000000010001001C00D600040000002D01040004000000
2D010400040000002D010D00050000000902FFFFFF000C00000040092100F000
0000000000001100110012003902040000002C01000007000000160423004A02
12003902040000002C0100000700000016048900AE0201000100040000002D01
0A00040000002D01040005000000090200000000040000002D01000005000000
140219003E0205000000130219004502040000002D0105000C00000040092100
F0000000000000000100070019003E02040000002D0100000500000014021A00
3F020500000013021A004402040000002D0105000C00000040092100F0000000
00000000010005001A003F02040000002D0100000500000014021B0040020500
000013021B004302040000002D0105000C00000040092100F000000000000000
010003001B004002040000002D0100000500000014021C004102050000001302
1C004202040000002D0105000C00000040092100F00000000000000001000100
1C004102040000002D010400040000002D010400040000002D010D0005000000
0902FFFFFF000C00000040092100F000000000000000110011002300CE000400
00002C0100000700000016043400DF002300CE00040000002C01000007000000
16048900AE0201000100040000002D010A00040000002D010400050000000902
00000000040000002D0100000500000014022A00D3000500000013022A00DA00
040000002D0105000C00000040092100F000000000000000010007002A00D300
040000002D0100000500000014022B00D4000500000013022B00D90004000000
2D0105000C00000040092100F000000000000000010005002B00D40004000000
2D0100000500000014022C00D5000500000013022C00D800040000002D010500
0C00000040092100F000000000000000010003002C00D500040000002D010000
0500000014022D00D6000500000013022D00D700040000002D0105000C000000
40092100F000000000000000010001002D00D600040000002D01040004000000
2D010400040000002D010D00050000000902FFFFFF000C00000040092100F000
0000000000001100110023003902040000002C01000007000000160434004A02
23003902040000002C0100000700000016048900AE0201000100040000002D01
0A00040000002D01040005000000090200000000040000002D01000005000000
14022A003E020500000013022A004502040000002D0105000C00000040092100
F000000000000000010007002A003E02040000002D0100000500000014022B00
3F020500000013022B004402040000002D0105000C00000040092100F0000000
00000000010005002B003F02040000002D0100000500000014022C0040020500
000013022C004302040000002D0105000C00000040092100F000000000000000
010003002C004002040000002D0100000500000014022D004102050000001302
2D004202040000002D0105000C00000040092100F00000000000000001000100
2D004102040000002D010400040000002D010400040000002D010D0005000000
0902FFFFFF000C00000040092100F000000000000000110011003400CE000400
00002C0100000700000016044500DF003400CE00040000002C01000007000000
16048900AE0201000100040000002D010A00040000002D010400050000000902
00000000040000002D0100000500000014023B00D3000500000013023B00DA00
040000002D0105000C00000040092100F000000000000000010007003B00D300
040000002D0100000500000014023C00D4000500000013023C00D90004000000
2D0105000C00000040092100F000000000000000010005003C00D40004000000
2D0100000500000014023D00D5000500000013023D00D800040000002D010500
0C00000040092100F000000000000000010003003D00D500040000002D010000
0500000014023E00D6000500000013023E00D700040000002D0105000C000000
40092100F000000000000000010001003E00D600040000002D01040004000000
2D010400040000002D010D00050000000902FFFFFF000C00000040092100F000
0000000000001100110034003902040000002C01000007000000160445004A02
34003902040000002C0100000700000016048900AE0201000100040000002D01
0A00040000002D01040005000000090200000000040000002D01000005000000
14023B003E020500000013023B004502040000002D0105000C00000040092100
F000000000000000010007003B003E02040000002D0100000500000014023C00
3F020500000013023C004402040000002D0105000C00000040092100F0000000
00000000010005003C003F02040000002D0100000500000014023D0040020500
000013023D004302040000002D0105000C00000040092100F000000000000000
010003003D004002040000002D0100000500000014023E004102050000001302
3E004202040000002D0105000C00000040092100F00000000000000001000100
3E004102040000002D010400040000002C0100000700000016048900AE020100
01000400000004010D00040000002C0100000700000016048900AE0201000100
0500000009020000000005000000010200000000040000002D01040004000000
2D010900040000002701FFFF0300000000000000000000000000000000000000
000000004E414E49000000000000002D0100000500000014023B003E02050000
0013023B004502040000002D0105000C00000040092100F00000000000000001
0007003B003E02040000002D0100000500000014023C003F020500000013023C
004402040000002D0105000C00000040092100F000000000000000010005003C
003F02040000002D0100000500000014023D0040020500000013023D00430204
0000002D0105000C00000040092100F000000000000000010003003D00400204
0000002D0100000500000014023E0041020500000013023E004202040000002D
0105000C00000040092100F0050044006F00630075006D0065006E0074005300
75006D006D0061007200790049006E0066006F0072006D006100740069006F00
6E000000000000000000000038000200FFFFFFFFFFFFFFFFFFFFFFFF00000000
0000000000000000000000000000000000000000000000000000000000000000
180000000C010000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF00000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF00000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF00000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000FEFF000005010200000000000000000000000000
000000000100000002D5CDD59C2E1B10939708002B2CF9AE30000000DC000000
0900000001000000500000000F0000005800000017000000640000000B000000
6C0000001000000074000000130000007C00000016000000840000000D000000
8C0000000C000000B900000002000000E40400001E0000000400000000000000
030000000F270B000B000000000000000B000000000000000B00000000000000
0B000000000000001E10000002000000060000004461646F730017000000416E
E16C69736520436F6E74617320E0205061676172000C100000020000001E0000
000A000000506C616E696C686173000300000002000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
00000000000000FFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000FEFF000005010200000000000000000000000000000000000100000002
D5CDD59C2E1B10939708002B2CF9AE30000000DC000000090000000100000050
0000000F0000005800000017000000640000000B0000006C0000001000000074
000000130000007C00000016000000840000000D0000008C0000000C000000B9
00000002000000E40400001E}
end
end
inherited MargemEsq: TPanel
Width = 0
Visible = False
end
inherited MargemDir: TPanel
Left = 774
Width = 0
Visible = False
end
end
| 72.076005 | 72 | 0.8755 |
f1d54ff9aeecc0e80cb71f57ef9a6acedbe5d870
| 10,860 |
pas
|
Pascal
|
frmTag.pas
|
trejder/delphi-mp3-toolbox
|
cee04b38834511cb95d22e8c84f504e84ca4b5c3
|
[
"MIT"
] | null | null | null |
frmTag.pas
|
trejder/delphi-mp3-toolbox
|
cee04b38834511cb95d22e8c84f504e84ca4b5c3
|
[
"MIT"
] | null | null | null |
frmTag.pas
|
trejder/delphi-mp3-toolbox
|
cee04b38834511cb95d22e8c84f504e84ca4b5c3
|
[
"MIT"
] | null | null | null |
unit frmTag;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComCtrls, CheckLst, ExtCtrls, Buttons, MPGTools;
type
TTagForm = class(TForm)
btnOK: TButton;
btnCancel: TButton;
lblFolder: TLabel;
lblMainInfo: TLabel;
lblInfo: TLabel;
pnlMode: TPanel;
fList: TListView;
gbParameters: TGroupBox;
lblTime: TLabel;
Bevel2: TBevel;
eTitle: TEdit;
eAuthor: TEdit;
eComment: TEdit;
eYear: TEdit;
eLength: TEdit;
eGenreList: TComboBox;
eAlbum: TEdit;
eTrack: TEdit;
btnGetID3Tag: TBitBtn;
pnlCount: TPanel;
btnSelectAll: TBitBtn;
btnDeselectAll: TBitBtn;
btnChange: TBitBtn;
btnClearAll: TBitBtn;
btnCloseAndEdit: TBitBtn;
chbTitle: TCheckBox;
chbAuthor: TCheckBox;
chbGenreList: TCheckBox;
chbAlbum: TCheckBox;
chbComment: TCheckBox;
chbYear: TCheckBox;
chbTrack: TCheckBox;
lblCheckWarning: TLabel;
lblListWarning: TLabel;
Label1: TLabel;
chbTrackNum: TCheckBox;
chbNameNum: TCheckBox;
chbAddBrackets: TCheckBox;
procedure UpdateFields;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure btnCancelClick(Sender: TObject);
procedure fListClick(Sender: TObject);
procedure btnSelectAllClick(Sender: TObject);
procedure btnChangeClick(Sender: TObject);
procedure btnDeselectAllClick(Sender: TObject);
procedure btnCloseAndEditClick(Sender: TObject);
procedure btnOKClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure fListDblClick(Sender: TObject);
procedure btnGetID3TagClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure btnClearAllClick(Sender: TObject);
procedure CheckBoxClick(Sender: TObject);
private
{ Private declarations }
public
function GetListItemIndexByCaption(Caption: String): Integer;
end;
var
TagForm: TTagForm;
implementation
uses frmMain, pasProcs;
{$R *.DFM}
procedure TTagForm.UpdateFields();
var
I, a, iChecked, iTotal: Integer;
Temp: TComponent;
bAtLeastOneChecked: Boolean;
begin
if pnlMode.Caption<>'Result' then
begin
iChecked := 0;
iTotal := fList.Items.Count;
for a:=0 to iTotal-1 do if fList.Items[a].Checked then Inc(iChecked);
lblFolder.Caption:='Selected folder: '+MainForm.lbFiles.Directory;
lblInfo.Caption:='All items on the list: '+IntToStr(iTotal)+'. Items selected for ID3Tag changing: '+IntToStr(iChecked)+'. Number of items, which ID3Tags will not be changed: '+IntToStr(iTotal-iChecked)+'.';
lblMainInfo.Caption:='This tool can be used for batch-changing values in ID3Tags of many files in one time. Select files, which ID3Tags should be changed, set parameters and start by clicking on "Start" button.';
btnSelectAll.Show;
btnDeselectAll.Show;
btnChange.Show;
btnCancel.Show;
bAtLeastOneChecked := False;
for I := TagForm.ComponentCount - 1 downto 0 do
begin
Temp := TagForm.Components[I];
if Temp.Tag = 9 then
begin
if (Temp as TCheckBox).Checked then
begin
bAtLeastOneChecked := True;
end;
end;
end;
lblCheckWarning.Visible := not bAtLeastOneChecked;
lblListWarning.Visible := not (iChecked <> 0);
btnOK.Enabled := bAtLeastOneChecked;
if (iChecked <> 0) and bAtLeastOneChecked then btnOK.Enabled := True else btnOK.Enabled := False;
end
else
begin
iChecked:=0;
iTotal:=fList.Items.Count;
for a:=0 to iTotal-1 do if fList.Items[a].Checked then Inc(iChecked);
lblFolder.Caption:='Selected folder: '+MainForm.lbFiles.Directory;
lblMainInfo.Caption:='Following list contains results of batch ID3Tag changing. Checked items has their ID3Tag changed. Unchecked itmes are files, which ID3Tag was not changed (due to various reasons).';
btnOK.Caption:='Close window';
if iTotal=iChecked then
lblInfo.Caption:='Names of all '+IntToStr(iTotal)+' files were changed.'
else
lblInfo.Caption:='Out of total number of '+IntToStr(iTotal)+' files, batch name change was successful for '+IntToStr(iChecked)+' files. Names of remaining '+IntToStr(iTotal-iChecked)+' files were not changed (due to various reasons).';
btnSelectAll.Hide;
btnDeselectAll.Hide;
btnChange.Hide;
btnCancel.Hide;
end;
pnlCount.Caption := IntToStr(iChecked);
end;
procedure TTagForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
MainForm.lblStatus.Caption:='Ready...';
MainForm.lblProgress.Caption:='0%';
MainForm.pbStatus.Position:=0;
end;
procedure TTagForm.btnCancelClick(Sender: TObject);
begin
Tag:=2;
Close;
end;
procedure TTagForm.fListClick(Sender: TObject);
begin
UpdateFields();
end;
procedure TTagForm.btnSelectAllClick(Sender: TObject);
var
a: Integer;
begin
for a:=0 to fList.Items.Count-1 do fList.Items[a].Checked := True;
UpdateFields();
end;
procedure TTagForm.btnDeselectAllClick(Sender: TObject);
var
a: Integer;
begin
for a:=0 to fList.Items.Count-1 do fList.Items[a].Checked := False;
UpdateFields();
end;
procedure TTagForm.btnChangeClick(Sender: TObject);
var
a: Integer;
begin
for a:=0 to fList.Items.Count-1 do fList.Items[a].Checked := not fList.Items[a].Checked;
UpdateFields();
end;
procedure TTagForm.btnCloseAndEditClick(Sender: TObject);
begin
if fList.Selected = nil then
begin
exit;
end;
MainForm.lbFiles.ItemIndex := fList.Selected.Index;
MainForm.lbFilesChange(self);
MainForm.pcMain.ActivePageIndex := 0;
MainForm.pcMainChange(self);
Tag := 2;
Close;
end;
procedure TTagForm.btnOKClick(Sender: TObject);
begin
if pnlMode.Caption <> 'Result' then if Application.MessageBox('ID3Tags of all selected files will be replaced with values entered to fields below list. Continue?'+chr(13)+''+chr(13)+'Note, that once started, this process cannot be stopped or reversed!','Confirm...',MB_YESNO+MB_ICONQUESTION+MB_DEFBUTTON2) = IDNO then exit;
Tag := 1;
Close;
end;
procedure TTagForm.FormShow(Sender: TObject);
begin
Tag := 2;
end;
procedure TTagForm.fListDblClick(Sender: TObject);
begin
if fList.Selected = nil then exit;
btnGetID3TagClick(self);
end;
function TTagForm.GetListItemIndexByCaption(Caption: String): Integer;
var
a: Integer;
begin
Result := -1;
for a := 0 to fList.Items.Count - 1 do
begin
if fList.Items[a].Caption = Caption then Result := a;
end;
end;
procedure TTagForm.btnGetID3TagClick(Sender: TObject);
var
mp3: TMPEGAudio;
begin
if fList.Selected = nil then exit;
mp3 := TMPEGAudio.Create;
mp3.FileName := MainForm.lbFiles.Items[fList.Selected.Index];
eTitle.Text := ClearWrongTag(mp3.Title);
eAuthor.Text:=ClearWrongTag(mp3.Artist);
eYear.Text:=ClearWrongTag(mp3.Year);
eAlbum.Text:=ClearWrongTag(mp3.Album);
if mp3.Genre > MaxStyles then
eGenreList.ItemIndex := eGenreList.Items.Count-1
else
eGenreList.ItemIndex := mp3.Genre;
eComment.Text:=ClearWrongTag(mp3.Comment);
eTrack.Text:=IntToStr(mp3.Track);
if mp3.Duration < 3600 then
eLength.Text := FormatDateTime('nn:ss', mp3.DurationTime) + ' (' + IntToStr (mp3.Duration) + ' sec.)'
else
eLength.Text := FormatDateTime('hh:nn:ss', mp3.DurationTime) + ' (' + IntToStr (mp3.Duration) + ' sec.)';
mp3.Free;
end;
procedure TTagForm.FormCreate(Sender: TObject);
var
a: Integer;
begin
for a := 0 to MaxStyles do eGenreList.Items.Add(MusicStyle[a]);
eGenreList.Items.Add('(unknown)');
btnClearAllClick(self);
end;
procedure TTagForm.btnClearAllClick(Sender: TObject);
begin
eTitle.Text := '';
eAuthor.Text := '';
eYear.Text := '';
eAlbum.Text := '';
eGenreList.ItemIndex := eGenreList.Items.Count-1;
eComment.Text := '';
eTrack.Text := '';
eLength.Text := '00:00 (0 sec.)';
end;
procedure TTagForm.CheckBoxClick(Sender: TObject);
var
sName: String;
Temp: TComponent;
I: Integer;
begin
sName := 'e' + Copy((Sender as TCheckBox).Name, 4, Length((Sender as TCheckBox).Name));
for I := TagForm.ComponentCount - 1 downto 0 do
begin
Temp := TagForm.Components[I];
if Temp.Name = sName then
begin
if (Temp is TEdit) then
begin
(Temp as TEdit).Enabled := (Sender as TCheckBox).Checked;
(Temp as TEdit).ReadOnly := not (Sender as TCheckBox).Checked;
if (Sender as TCheckBox).Checked then
begin
(Temp as TEdit).Color := clWindow;
(Temp as TEdit).SetFocus;
(Temp as TEdit).SelectAll;
end
else (Temp as TEdit).Color := clBtnFace;
end;
if (Temp is TComboBox) then
begin
(Temp as TComboBox).Enabled := (Sender as TCheckBox).Checked;
if (Sender as TCheckBox).Checked then
begin
(Temp as TComboBox).Color := clWindow;
(Temp as TComboBox).SetFocus;
end
else (Temp as TComboBox).Color := clBtnFace;
end;
end;
end;
chbTrackNum.Enabled := chbTrack.Checked;
chbAddBrackets.Enabled := chbNameNum.Checked and chbTitle.Checked;
chbNameNum.Enabled := chbTitle.Checked;
UpdateFields();
end;
end.
| 32.130178 | 331 | 0.587201 |
859ec3fb35cba0755fbac4471e2dd23068d155fa
| 3,807 |
pas
|
Pascal
|
engine/Projects/ThundaxTDPETests/lib/Math/Testtdpe.lib.math.pas
|
jomael/thundax-delphi-physics-engine
|
a86f38cdaba1f00c5ef5296a8ae67b816a59448e
|
[
"MIT"
] | 56 |
2015-03-15T10:22:50.000Z
|
2022-02-22T11:58:08.000Z
|
engine/Projects/ThundaxTDPETests/lib/Math/Testtdpe.lib.math.pas
|
jomael/thundax-delphi-physics-engine
|
a86f38cdaba1f00c5ef5296a8ae67b816a59448e
|
[
"MIT"
] | 2 |
2016-07-10T07:57:05.000Z
|
2019-10-14T15:49:06.000Z
|
engine/Projects/ThundaxTDPETests/lib/Math/Testtdpe.lib.math.pas
|
jomael/thundax-delphi-physics-engine
|
a86f38cdaba1f00c5ef5296a8ae67b816a59448e
|
[
"MIT"
] | 18 |
2015-07-17T19:24:39.000Z
|
2022-01-20T05:40:46.000Z
|
(*
* Copyright (c) 2010-2012 Thundax Delphi Physics Engine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of 'TDPE' nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*)
unit Testtdpe.lib.math;
{
Delphi DUnit Test Case
----------------------
This unit contains a skeleton test case class generated by the Test Case Wizard.
Modify the generated code to correctly setup and call the methods from the unit
being tested.
}
interface
uses
TestFramework, Types, math, tdpe.lib.math;
type
// Test methods for class TMathHelper
TestTMathHelper = class(TTestCase)
strict private
FMathHelper: TMathHelper;
public
procedure SetUp; override;
procedure TearDown; override;
published
procedure TestCompare;
end;
implementation
procedure TestTMathHelper.SetUp;
begin
FMathHelper := TMathHelper.Create;
end;
procedure TestTMathHelper.TearDown;
begin
FMathHelper.Free;
FMathHelper := nil;
end;
procedure TestTMathHelper.TestCompare;
var
ReturnValue: Boolean;
MethodComp: string;
Value2: Double;
Value1: Double;
begin
Value1 := 10;
Value2 := 10;
MethodComp := '=';
ReturnValue := FMathHelper.Compare(Value1, Value2, MethodComp);
CheckTrue(ReturnValue, 'Wrong value, expected true but was false');
Value1 := 10;
Value2 := 12;
MethodComp := '<';
ReturnValue := FMathHelper.Compare(Value1, Value2, MethodComp);
CheckTrue(ReturnValue, 'Wrong value, expected true but was false');
Value1 := 12;
Value2 := 10;
MethodComp := '>';
ReturnValue := FMathHelper.Compare(Value1, Value2, MethodComp);
CheckTrue(ReturnValue, 'Wrong value, expected true but was false');
Value1 := 10;
Value2 := 12;
MethodComp := '<=';
ReturnValue := FMathHelper.Compare(Value1, Value2, MethodComp);
CheckTrue(ReturnValue, 'Wrong value, expected true but was false');
Value1 := 12;
Value2 := 10;
MethodComp := '>=';
ReturnValue := FMathHelper.Compare(Value1, Value2, MethodComp);
CheckTrue(ReturnValue, 'Wrong value, expected true but was false');
Value1 := 12;
Value2 := 7;
MethodComp := '<>';
ReturnValue := FMathHelper.Compare(Value1, Value2, MethodComp);
CheckTrue(ReturnValue, 'Wrong value, expected true but was false');
end;
initialization
RegisterTest(TestTMathHelper.Suite);
end.
| 30.95122 | 83 | 0.710008 |
834f061524c7936228e298405668ec2fd6db365f
| 489 |
dfm
|
Pascal
|
form_main.dfm
|
kangu/delphi-couchdb
|
7a015569959ad02882de072c91a6f702d37456b5
|
[
"Apache-2.0"
] | 5 |
2016-01-22T20:35:11.000Z
|
2019-11-13T14:28:59.000Z
|
form_main.dfm
|
kangu/delphi-couchdb
|
7a015569959ad02882de072c91a6f702d37456b5
|
[
"Apache-2.0"
] | null | null | null |
form_main.dfm
|
kangu/delphi-couchdb
|
7a015569959ad02882de072c91a6f702d37456b5
|
[
"Apache-2.0"
] | null | null | null |
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 272
ClientWidth = 595
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object btn1: TButton
Left = 200
Top = 88
Width = 225
Height = 65
Caption = 'btn1'
TabOrder = 0
OnClick = btn1Click
end
end
| 18.807692 | 33 | 0.605317 |
8513d0c98d0cbd8719352ca9c1ab7a83c966d09f
| 34,990 |
pas
|
Pascal
|
Libraries/SynEdit/Source/SynHighlighterPython.pas
|
Patiencer/Concepts
|
e63910643b2401815dd4f6b19fbdf0cd7d443392
|
[
"Apache-2.0"
] | 19 |
2018-10-22T23:45:31.000Z
|
2021-05-16T00:06:49.000Z
|
Components/SynEdit/Source/SynHighlighterPython.pas
|
AlekId/DelphiAST-1
|
7df228bc75c36741e6627605d877146be062d96b
|
[
"Apache-2.0"
] | 16 |
2019-02-02T19:54:54.000Z
|
2019-02-28T05:22:36.000Z
|
SynEdit-master/Source/SynHighlighterPython.pas
|
suwermave/soulengine
|
767d18b53fa882b1a9d797761e5165cfb58c47ad
|
[
"FTL"
] | 6 |
2018-08-30T05:16:21.000Z
|
2021-05-12T20:25:43.000Z
|
{-------------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: SynHighlighterPython.pas, released 2000-06-23.
The Original Code is based on the odPySyn.pas file from the
mwEdit component suite by Martin Waldenburg and other developers, the Initial
Author of this file is Olivier Deckmyn.
Portions created by M.Utku Karatas and Dennis Chuah.
Unicode translation by Maël Hörz.
All Rights Reserved.
Contributors to the SynEdit and mwEdit projects are listed in the
Contributors.txt file.
Alternatively, the contents of this file may be used under the terms of the
GNU General Public License Version 2 or later (the "GPL"), in which case
the provisions of the GPL are applicable instead of those above.
If you wish to allow use of your version of this file only under the terms
of the GPL and not to allow others to use your version of this file
under the MPL, indicate your decision by deleting the provisions above and
replace them with the notice and other provisions required by the GPL.
If you do not delete the provisions above, a recipient may use your version
of this file under either the MPL or the GPL.
$Id: SynHighlighterPython.pas,v 1.18.2.7 2008/09/14 16:25:02 maelh Exp $
You may retrieve the latest version of this file at the SynEdit home page,
located at http://SynEdit.SourceForge.net
Known Issues:
-------------------------------------------------------------------------------}
{
@abstract(A Python language highlighter for SynEdit)
@author(Olivier Deckmyn, converted to SynEdit by David Muir <dhmn@dmsoftware.co.uk>)
@created(unknown, converted to SynEdit on 2000-06-23)
@lastmod(2003-02-13)
The SynHighlighterPython implements a highlighter for Python for the SynEdit projects.
}
{$IFNDEF QSYNHIGHLIGHTERPYTHON}
unit SynHighlighterPython;
{$ENDIF}
{$I SynEdit.Inc}
interface
uses
{$IFDEF SYN_CLX}
QGraphics,
QSynEditHighlighter,
QSynEditTypes,
QSynUnicode,
{$ELSE}
Graphics,
SynEditHighlighter,
SynEditTypes,
SynUnicode,
{$ENDIF}
{$IFDEF SYN_CodeFolding}
SynEditCodeFolding,
SynRegExpr,
{$ENDIF}
SysUtils,
Classes;
const
ALPHA_CHARS = ['_', 'a'..'z', 'A'..'Z'];
type
TtkTokenKind = (tkComment, tkIdentifier, tkKey, tkNull, tkNumber, tkSpace,
tkString, tkSymbol, tkNonKeyword, tkTrippleQuotedString,
tkSystemDefined, tkHex, tkOct, tkFloat, tkUnknown);
TRangeState = (rsANil, rsComment, rsUnknown, rsMultilineString, rsMultilineString2,
rsMultilineString3 //this is to indicate if a string is made multiline by backslash char at line end (as in C++ highlighter)
);
type
{$IFDEF SYN_CodeFolding}
TSynPythonSyn = class(TSynCustomCodeFoldingHighlighter)
{$ELSE}
TSynPythonSyn = class(TSynCustomHighLighter)
{$ENDIF}
private
FStringStarter: WideChar; // used only for rsMultilineString3 stuff
FRange: TRangeState;
FTokenID: TtkTokenKind;
FKeywords: TUnicodeStringList;
FStringAttri: TSynHighlighterAttributes;
FDocStringAttri: TSynHighlighterAttributes;
FNumberAttri: TSynHighlighterAttributes;
FHexAttri: TSynHighlighterAttributes;
FOctalAttri: TSynHighlighterAttributes;
FFloatAttri: TSynHighlighterAttributes;
FKeyAttri: TSynHighlighterAttributes;
FNonKeyAttri: TSynHighlighterAttributes;
FSystemAttri: TSynHighlighterAttributes;
FSymbolAttri: TSynHighlighterAttributes;
FCommentAttri: TSynHighlighterAttributes;
FIdentifierAttri: TSynHighlighterAttributes;
FSpaceAttri: TSynHighlighterAttributes;
FErrorAttri: TSynHighlighterAttributes;
{$IFDEF SYN_CodeFolding}
BlockOpenerRE : TRegExpr;
{$ENDIF}
function IdentKind(MayBe: PWideChar): TtkTokenKind;
procedure SymbolProc;
procedure CRProc;
procedure CommentProc;
procedure GreaterProc;
procedure IdentProc;
procedure LFProc;
procedure LowerProc;
procedure NullProc;
procedure NumberProc;
procedure SpaceProc;
procedure PreStringProc;
procedure UnicodeStringProc;
procedure StringProc;
procedure String2Proc;
procedure StringEndProc(EndChar: WideChar);
procedure UnknownProc;
protected
function GetSampleSource: UnicodeString; override;
function IsFilterStored: Boolean; override;
function GetKeywordIdentifiers: TUnicodeStringList;
property Keywords: TUnicodeStringList read FKeywords;
property TokenID: TtkTokenKind read FTokenID;
public
class function GetLanguageName: string; override;
class function GetFriendlyLanguageName: UnicodeString; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function GetDefaultAttribute(Index: Integer): TSynHighlighterAttributes;
override;
function GetEol: Boolean; override;
function GetRange: Pointer; override;
function GetTokenID: TtkTokenKind;
function GetTokenAttribute: TSynHighlighterAttributes; override;
function GetTokenKind: Integer; override;
procedure Next; override;
procedure SetRange(Value: Pointer); override;
procedure ResetRange; override;
{$IFDEF SYN_CodeFolding}
procedure InitFoldRanges(FoldRanges : TSynFoldRanges); override;
procedure ScanForFoldRanges(FoldRanges: TSynFoldRanges;
LinesToScan: TStrings; FromLine: Integer; ToLine: Integer); override;
{$ENDIF}
published
property CommentAttri: TSynHighlighterAttributes read FCommentAttri
write FCommentAttri;
property IdentifierAttri: TSynHighlighterAttributes read FIdentifierAttri
write FIdentifierAttri;
property KeyAttri: TSynHighlighterAttributes read FKeyAttri write FKeyAttri;
property NonKeyAttri: TSynHighlighterAttributes read FNonKeyAttri
write FNonKeyAttri;
property SystemAttri: TSynHighlighterAttributes read FSystemAttri
write FSystemAttri;
property NumberAttri: TSynHighlighterAttributes read FNumberAttri
write FNumberAttri;
property HexAttri: TSynHighlighterAttributes read FHexAttri
write FHexAttri;
property OctalAttri: TSynHighlighterAttributes read FOctalAttri
write FOctalAttri;
property FloatAttri: TSynHighlighterAttributes read FFloatAttri
write FFloatAttri;
property SpaceAttri: TSynHighlighterAttributes read FSpaceAttri
write FSpaceAttri;
property StringAttri: TSynHighlighterAttributes read FStringAttri
write FStringAttri;
property DocStringAttri: TSynHighlighterAttributes read FDocStringAttri
write FDocStringAttri;
property SymbolAttri: TSynHighlighterAttributes read FSymbolAttri
write FSymbolAttri;
property ErrorAttri: TSynHighlighterAttributes read FErrorAttri
write FErrorAttri;
end;
implementation
uses
{$IFDEF SYN_CLX}
QSynEditStrConst;
{$ELSE}
SynEditStrConst;
{$ENDIF}
var
GlobalKeywords: TUnicodeStringList;
function TSynPythonSyn.GetKeywordIdentifiers: TUnicodeStringList;
const
// No need to localise keywords!
// List of keywords
KEYWORDCOUNT = 32;
KEYWORDS: array [1..KEYWORDCOUNT] of UnicodeString =
(
'and',
'as',
'assert',
'break',
'class',
'continue',
'def',
'del',
'elif',
'else',
'except',
'exec',
'finally',
'for',
'from',
'global',
'if',
'import',
'in',
'is',
'lambda',
'nonlocal',
'not',
'or',
'pass',
'print',
'raise',
'return',
'try',
'while',
'with',
'yield'
);
// List of non-keyword identifiers
NONKEYWORDCOUNT = 65;
NONKEYWORDS: array [1..NONKEYWORDCOUNT] of UnicodeString =
(
'__future__',
'__import__',
'abs',
'apply',
'buffer',
'callable',
'chr',
'cmp',
'coerce',
'compile',
'complex',
'delattr',
'dict',
'dir',
'divmod',
'eval',
'execfile',
'False',
'file',
'filter',
'float',
'getattr',
'globals',
'hasattr',
'hash',
'help',
'hex',
'id',
'input',
'int',
'intern',
'isinstance',
'issubclass',
'iter',
'len',
'list',
'locals',
'long',
'None',
'NotImplemented',
'map',
'max',
'min',
'oct',
'open',
'ord',
'pow',
'range',
'raw_input',
'reduce',
'reload',
'repr',
'round',
'self',
'setattr',
'slice',
'str',
'True',
'tuple',
'type',
'unichr',
'unicode',
'vars',
'xrange',
'zip'
);
var
f: Integer;
begin
if not Assigned (GlobalKeywords) then
begin
// Create the string list of keywords - only once
GlobalKeywords := TUnicodeStringList.Create;
for f := 1 to KEYWORDCOUNT do
GlobalKeywords.AddObject(KEYWORDS[f], Pointer(Ord(tkKey)));
for f := 1 to NONKEYWORDCOUNT do
GlobalKeywords.AddObject(NONKEYWORDS[f], Pointer(Ord(tkNonKeyword)));
end; // if
Result := GlobalKeywords;
end;
function TSynPythonSyn.IdentKind(MayBe: PWideChar): TtkTokenKind;
var
i: Integer;
temp: PWideChar;
s: UnicodeString;
begin
// Extract the identifier out - it is assumed to terminate in a
// non-alphanumeric character
FToIdent := MayBe;
temp := MayBe;
while IsIdentChar(temp^) do
Inc(temp);
FStringLen := temp - FToIdent;
// Check to see if it is a keyword
SetString(s, FToIdent, FStringLen);
if FKeywords.Find(s, i) then
begin
// TUnicodeStringList is not case sensitive!
if s <> FKeywords[i] then
i := -1;
end
else
i := -1;
if i <> -1 then
Result := TtkTokenKind(FKeywords.Objects[i])
// Check if it is a system identifier (__*__)
else if (FStringLen >= 5) and
(MayBe[0] = '_') and (MayBe[1] = '_') and (MayBe[2] <> '_') and
(MayBe[FStringLen - 1] = '_') and (MayBe[FStringLen - 2] = '_') and
(MayBe[FStringLen - 3] <> '_') then
Result := tkSystemDefined
// Check for names of class and functions - not optimal
else if ( (WideCompareStr(Trim(Copy(FLine, 0, Length(FLine) - Length(FToIdent))), 'def')=0) or (WideCompareStr(Trim(Copy(FLine, 0, Length(FLine) - Length(FToIdent))), 'class')=0) ) then
Result := tkSystemDefined
// Else, hey, it is an ordinary run-of-the-mill identifier!
else
Result := tkIdentifier;
end;
constructor TSynPythonSyn.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FCaseSensitive := True;
FKeywords := TUnicodeStringList.Create;
FKeywords.Sorted := True;
FKeywords.Duplicates := dupError;
FKeywords.Assign (GetKeywordIdentifiers);
if not FKeywords.Sorted then
FKeywords.Sort;
{$IFDEF SYN_CodeFolding}
BlockOpenerRE := TRegExpr.Create;
BlockOpenerRE.Expression := // ':\s*(#.*)?$';
'^(def|class|while|for|if|else|elif|try|except|with'+
'|(async[ \t]+def)|(async[ \t]+with)|(async[ \t]+for))\b';
{$ENDIF}
FRange := rsUnknown;
FCommentAttri := TSynHighlighterAttributes.Create(SYNS_AttrComment, SYNS_FriendlyAttrComment);
FCommentAttri.Foreground := clGray;
FCommentAttri.Style := [fsItalic];
AddAttribute(FCommentAttri);
FIdentifierAttri := TSynHighlighterAttributes.Create(SYNS_AttrIdentifier, SYNS_FriendlyAttrIdentifier);
AddAttribute(FIdentifierAttri);
FKeyAttri := TSynHighlighterAttributes.Create(SYNS_AttrReservedWord, SYNS_FriendlyAttrReservedWord);
FKeyAttri.Style := [fsBold];
AddAttribute(FKeyAttri);
FNonKeyAttri := TSynHighlighterAttributes.Create (SYNS_AttrNonReservedKeyword, SYNS_FriendlyAttrNonReservedKeyword);
FNonKeyAttri.Foreground := clNavy;
FNonKeyAttri.Style := [fsBold];
AddAttribute (FNonKeyAttri);
FSystemAttri := TSynHighlighterAttributes.Create (SYNS_AttrSystem, SYNS_FriendlyAttrSystem);
FSystemAttri.Style := [fsBold];
AddAttribute (FSystemAttri);
FNumberAttri := TSynHighlighterAttributes.Create(SYNS_AttrNumber, SYNS_FriendlyAttrNumber);
FNumberAttri.Foreground := clBlue;
AddAttribute(FNumberAttri);
FHexAttri := TSynHighlighterAttributes.Create(SYNS_AttrHexadecimal, SYNS_FriendlyAttrHexadecimal);
FHexAttri.Foreground := clBlue;
AddAttribute(FHexAttri);
FOctalAttri := TSynHighlighterAttributes.Create(SYNS_AttrOctal, SYNS_FriendlyAttrOctal);
FOctalAttri.Foreground := clBlue;
AddAttribute(FOctalAttri);
FFloatAttri := TSynHighlighterAttributes.Create(SYNS_AttrFloat, SYNS_FriendlyAttrFloat);
FFloatAttri.Foreground := clBlue;
AddAttribute(FFloatAttri);
FSpaceAttri := TSynHighlighterAttributes.Create(SYNS_AttrSpace, SYNS_FriendlyAttrSpace);
AddAttribute(FSpaceAttri);
FStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrString, SYNS_FriendlyAttrString);
FStringAttri.Foreground := clBlue;
AddAttribute(FStringAttri);
FDocStringAttri := TSynHighlighterAttributes.Create(SYNS_AttrDocumentation, SYNS_FriendlyAttrDocumentation);
FDocStringAttri.Foreground := clTeal;
AddAttribute(FDocStringAttri);
FSymbolAttri := TSynHighlighterAttributes.Create(SYNS_AttrSymbol, SYNS_FriendlyAttrSymbol);
AddAttribute(FSymbolAttri);
FErrorAttri := TSynHighlighterAttributes.Create(SYNS_AttrSyntaxError, SYNS_FriendlyAttrSyntaxError);
FErrorAttri.Foreground := clRed;
AddAttribute(FErrorAttri);
SetAttributesOnChange(DefHighlightChange);
FDefaultFilter := SYNS_FilterPython;
end; { Create }
destructor TSynPythonSyn.Destroy;
begin
{$IFDEF SYN_CodeFolding}
BlockOpenerRE.Free;
{$ENDIF}
FKeywords.Free;
inherited;
end;
procedure TSynPythonSyn.SymbolProc;
begin
Inc(Run);
FTokenID := tkSymbol;
end;
procedure TSynPythonSyn.CRProc;
begin
FTokenID := tkSpace;
case FLine[Run + 1] of
#10: Inc(Run, 2);
else
Inc(Run);
end;
end;
procedure TSynPythonSyn.CommentProc;
begin
FTokenID := tkComment;
Inc(Run);
while not IsLineEnd(Run) do
Inc(Run);
end;
procedure TSynPythonSyn.GreaterProc;
begin
case FLine[Run + 1] of
'=': begin
Inc(Run, 2);
FTokenID := tkSymbol;
end;
else begin
Inc(Run);
FTokenID := tkSymbol;
end;
end;
end;
procedure TSynPythonSyn.IdentProc;
begin
FTokenID := IdentKind((FLine + Run));
Inc(Run, FStringLen);
end;
procedure TSynPythonSyn.LFProc;
begin
FTokenID := tkSpace;
Inc(Run);
end;
procedure TSynPythonSyn.LowerProc;
begin
case FLine[Run + 1] of
'=': begin
Inc(Run, 2);
FTokenID := tkSymbol;
end;
'>': begin
Inc(Run, 2);
FTokenID := tkSymbol;
end
else begin
Inc(Run);
FTokenID := tkSymbol;
end;
end;
end;
procedure TSynPythonSyn.NullProc;
begin
FTokenID := tkNull;
Inc(Run);
end;
procedure TSynPythonSyn.NumberProc;
type
TNumberState =
(
nsStart,
nsDotFound,
nsFloatNeeded,
nsHex,
nsOct,
nsExpFound
);
var
temp: WideChar;
State: TNumberState;
function CheckSpecialCases: Boolean;
begin
case temp of
// Look for dot (.)
'.': begin
// .45
if CharInSet(FLine[Run], ['0'..'9']) then
begin
Inc (Run);
FTokenID := tkFloat;
State := nsDotFound;
// Non-number dot
end else begin
// Ellipsis
if (FLine[Run] = '.') and (FLine[Run+1] = '.') then
Inc (Run, 2);
FTokenID := tkSymbol;
Result := False;
Exit;
end; // if
end; // DOT
// Look for zero (0)
'0': begin
temp := FLine[Run];
// 0x123ABC
if CharInSet(temp, ['x', 'X']) then begin
Inc (Run);
FTokenID := tkHex;
State := nsHex;
// 0.45
end else if temp = '.' then begin
Inc (Run);
State := nsDotFound;
FTokenID := tkFloat;
end else if CharInSet(temp, ['0'..'9']) then begin
Inc (Run);
// 0123 or 0123.45
if CharInSet(temp, ['0'..'7']) then begin
FTokenID := tkOct;
State := nsOct;
// 0899.45
end else begin
FTokenID := tkFloat;
State := nsFloatNeeded;
end; // if
end; // if
end; // ZERO
end; // case
Result := True;
end; // CheckSpecialCases
function HandleBadNumber: Boolean;
begin
Result := False;
FTokenID := tkUnknown;
// Ignore all tokens till end of "number"
while IsIdentChar(FLine[Run]) or (FLine[Run] = '.') do
Inc (Run);
end; // HandleBadNumber
function HandleExponent: Boolean;
begin
State := nsExpFound;
FTokenID := tkFloat;
// Skip e[+/-]
if CharInSet(FLine[Run+1], ['+', '-']) then
Inc (Run);
// Invalid token : 1.0e
if not CharInSet(FLine[Run+1], ['0'..'9']) then begin
Inc (Run);
Result := HandleBadNumber;
Exit;
end; // if
Result := True;
end; // HandleExponent
function HandleDot: Boolean;
begin
// Check for ellipsis
Result := (FLine[Run+1] <> '.') or (FLine[Run+2] <> '.');
if Result then begin
State := nsDotFound;
FTokenID := tkFloat;
end; // if
end; // HandleDot
function CheckStart: Boolean;
begin
// 1234
if CharInSet(temp, ['0'..'9']) then begin
Result := True;
//123e4
end else if CharInSet(temp, ['e', 'E']) then begin
Result := HandleExponent;
// 123.45j
end else if CharInSet(temp, ['j', 'J']) then begin
Inc (Run);
FTokenID := tkFloat;
Result := False;
// 123.45
end else if temp = '.' then begin
Result := HandleDot;
// Error!
end else if IsIdentChar(temp) then begin
Result := HandleBadNumber;
// End of number
end else begin
Result := False;
end; // if
end; // CheckStart
function CheckDotFound: Boolean;
begin
// 1.0e4
if CharInSet(temp, ['e', 'E']) then begin
Result := HandleExponent;
// 123.45
end else if CharInSet(temp, ['0'..'9']) then begin
Result := True;
// 123.45j
end else if CharInSet(temp, ['j', 'J']) then begin
Inc (Run);
Result := False;
// 123.45.45: Error!
end else if temp = '.' then begin
Result := False;
if HandleDot then
HandleBadNumber;
// Error!
end else if IsIdentChar(temp) then begin
Result := HandleBadNumber;
// End of number
end else begin
Result := False;
end; // if
end; // CheckDotFound
function CheckFloatNeeded: Boolean;
begin
// 091.0e4
if CharInSet(temp, ['e', 'E']) then begin
Result := HandleExponent;
// 0912345
end else if CharInSet(temp, ['0'..'9']) then begin
Result := True;
// 09123.45
end else if temp = '.' then begin
Result := HandleDot or HandleBadNumber; // Bad octal
// 09123.45j
end else if CharInSet(temp, ['j', 'J']) then begin
Inc (Run);
Result := False;
// End of number (error: Bad oct number) 0912345
end else begin
Result := HandleBadNumber;
end;
end; // CheckFloatNeeded
function CheckHex: Boolean;
begin
// 0x123ABC
if CharInSet(temp, ['a'..'f', 'A'..'F', '0'..'9']) then
begin
Result := True;
// 0x123ABCL
end else if CharInSet(temp, ['l', 'L']) then begin
Inc (Run);
Result := False;
// 0x123.45: Error!
end else if temp = '.' then begin
Result := False;
if HandleDot then
HandleBadNumber;
// Error!
end else if IsIdentChar(temp) then begin
Result := HandleBadNumber;
// End of number
end else begin
Result := False;
end; // if
end; // CheckHex
function CheckOct: Boolean;
begin
// 012345
if CharInSet(temp, ['0'..'9']) then begin
if not CharInSet(temp, ['0'..'7']) then begin
State := nsFloatNeeded;
FTokenID := tkFloat;
end; // if
Result := True;
// 012345L
end else if CharInSet(temp, ['l', 'L']) then begin
Inc (Run);
Result := False;
// 0123e4
end else if CharInSet(temp, ['e', 'E']) then begin
Result := HandleExponent;
// 0123j
end else if CharInSet(temp, ['j', 'J']) then begin
Inc (Run);
FTokenID := tkFloat;
Result := False;
// 0123.45
end else if temp = '.' then begin
Result := HandleDot;
// Error!
end else if IsIdentChar(temp) then begin
Result := HandleBadNumber;
// End of number
end else begin
Result := False;
end; // if
end; // CheckOct
function CheckExpFound: Boolean;
begin
// 1e+123
if CharInSet(temp, ['0'..'9']) then begin
Result := True;
// 1e+123j
end else if CharInSet(temp, ['j', 'J']) then begin
Inc (Run);
Result := False;
// 1e4.5: Error!
end else if temp = '.' then begin
Result := False;
if HandleDot then
HandleBadNumber;
// Error!
end else if IsIdentChar(temp) then begin
Result := HandleBadNumber;
// End of number
end else begin
Result := False;
end; // if
end; // CheckExpFound
begin
State := nsStart;
FTokenID := tkNumber;
temp := FLine[Run];
Inc (Run);
// Special cases
if not CheckSpecialCases then
Exit;
// Use a state machine to parse numbers
while True do begin
temp := FLine[Run];
case State of
nsStart:
if not CheckStart then Exit;
nsDotFound:
if not CheckDotFound then Exit;
nsFloatNeeded:
if not CheckFloatNeeded then Exit;
nsHex:
if not CheckHex then Exit;
nsOct:
if not CheckOct then Exit;
nsExpFound:
if not CheckExpFound then Exit;
end; // case
Inc (Run);
end; // while
end;
procedure TSynPythonSyn.SpaceProc;
begin
Inc(Run);
FTokenID := tkSpace;
while (FLine[Run] <= #32) and not IsLineEnd(Run) do Inc(Run);
end;
procedure TSynPythonSyn.String2Proc;
var
BackslashCount: Integer;
begin
FTokenID := tkString;
if (FLine[Run + 1] = '"') and (FLine[Run + 2] = '"') then
begin
FTokenID := tkTrippleQuotedString;
Inc(Run, 3);
FRange := rsMultilineString2;
while FLine[Run] <> #0 do
begin
case FLine[Run] of
'\':
begin
{ If we're looking at a backslash, and the following character is an
end quote, and it's preceeded by an odd number of backslashes, then
it shouldn't mark the end of the string. If it's preceeded by an
even number, then it should. !!!THIS RULE DOESNT APPLY IN RAW STRINGS}
if FLine[Run + 1] = '"' then
begin
BackslashCount := 1;
while ((Run > BackslashCount) and (FLine[Run - BackslashCount] = '\')) do
BackslashCount := BackslashCount + 1;
if (BackslashCount mod 2 = 1) then Inc(Run)
end;
Inc(Run);
end;// '\':
'"':
if (FLine[Run + 1] = '"') and (FLine[Run + 2] = '"') then begin
FRange := rsUnknown;
Inc(Run, 3);
Exit;
end else
Inc(Run);
#10: Exit;
#13: Exit;
else
Inc(Run);
end;
end;
end
else //if short string
repeat
case FLine[Run] of
#0, #10, #13:
begin
if FLine[Run-1] = '\' then
begin
FStringStarter := '"';
FRange := rsMultilineString3;
end;
Break;
end;
{The same backslash stuff above...}
'\':
begin
if FLine[Run + 1] = '"' then
begin
BackslashCount := 1;
while ((Run > BackslashCount) and (FLine[Run - BackslashCount] = '\')) do
BackslashCount := BackslashCount + 1;
if (BackslashCount mod 2 = 1) then Inc(Run)
end;
Inc(Run);
end;// '\':
else Inc(Run);
end; //case
until (FLine[Run] = '"');
if FLine[Run] <> #0 then Inc(Run);
end;
procedure TSynPythonSyn.PreStringProc;
var
temp: WideChar;
begin
// Handle python raw strings
// r""
temp := FLine[Run + 1];
if temp = '''' then
begin
Inc (Run);
StringProc;
end
else if temp = '"' then
begin
Inc (Run);
String2Proc;
end
else
begin
// If not followed by quote char, must be ident
IdentProc;
end; // if
end;
procedure TSynPythonSyn.UnicodeStringProc;
begin
// Handle python raw and unicode strings
// Valid syntax: u"", or ur""
if CharInSet(FLine[Run + 1], ['r', 'R']) and
CharInSet(FLine[Run + 2], ['''', '"']) then
begin
// for ur, Remove the "u" and...
Inc (Run);
end;
// delegate to raw strings
PreStringProc;
end;
procedure TSynPythonSyn.StringProc;
var
FBackslashCount: Integer;
begin
FTokenID := tkString;
if (FLine[Run + 1] = #39) and (FLine[Run + 2] = #39) then begin
FTokenID := tkTrippleQuotedString;
Inc(Run, 3);
FRange:=rsMultilineString;
while FLine[Run] <> #0 do begin
case FLine[Run] of
'\': begin
{ If we're looking at a backslash, and the following character is an
end quote, and it's preceeded by an odd number of backslashes, then
it shouldn't mark the end of the string. If it's preceeded by an
even number, then it should. !!!THIS RULE DOESNT APPLY IN RAW STRINGS}
if FLine[Run + 1] = #39 then
begin
FBackslashCount := 1;
while ((Run > FBackslashCount) and (FLine[Run - FBackslashCount] = '\')) do
FBackslashCount := FBackslashCount + 1;
if (FBackslashCount mod 2 = 1) then Inc(Run)
end;
Inc(Run);
end;// '\':
#39:
if (FLine[Run + 1] = #39) and (FLine[Run + 2] = #39) then begin
FRange := rsUnknown;
Inc(Run, 3);
Exit;
end else
Inc(Run);
#10: Exit;
#13: Exit;
else
Inc(Run);
end;
end;
end
else //if short string
repeat
case FLine[Run] of
#0, #10, #13 : begin
if FLine[Run-1] = '\' then begin
FStringStarter := #39;
FRange := rsMultilineString3;
end;
Break;
end;
{The same backslash stuff above...}
'\':
begin
if FLine[Run + 1] = #39 then
begin
FBackslashCount := 1;
while ((Run > FBackslashCount) and (FLine[Run - FBackslashCount] = '\')) do
FBackslashCount := FBackslashCount + 1;
if (FBackslashCount mod 2 = 1) then Inc(Run)
end;
Inc(Run);
end;// '\':
else Inc(Run);
end; //case
until (FLine[Run] = #39);
if FLine[Run] <> #0 then Inc(Run);
end;
procedure TSynPythonSyn.StringEndProc(EndChar: WideChar);
var
BackslashCount: Integer;
begin
if FRange = rsMultilineString3 then
FTokenID := tkString
else
FTokenID := tkTrippleQuotedString;
case FLine[Run] of
#0:
begin
NullProc;
Exit;
end;
#10:
begin
LFProc;
Exit;
end;
#13:
begin
CRProc;
Exit;
end;
end;
if FRange = rsMultilineString3 then begin
repeat
if FLine[Run]=FStringStarter then begin
Inc(Run);
FRange:=rsUnknown;
Exit;
end else if FLine[Run]='\' then ; {The same backslash stuff above...}
begin
if FLine[Run + 1] = FStringStarter then
begin
BackslashCount := 1;
while ((Run > BackslashCount) and (FLine[Run - BackslashCount] = '\')) do
BackslashCount := BackslashCount + 1;
if (BackslashCount mod 2 = 1) then Inc(Run);
end;
end;// if FLine[Run]...
Inc(Run);
until IsLineEnd(Run);
if FLine[Run-1]<>'\' then begin
FRange:=rsUnknown;
Exit;
end;
end else
repeat
if FLine[Run] = '\' then
begin
if FLine[Run + 1] = EndChar then
begin
BackslashCount := 1;
while ((Run > BackslashCount) and (FLine[Run - BackslashCount] = '\')) do
BackslashCount := BackslashCount + 1;
if (BackslashCount mod 2 = 1) then Inc(Run, 2);
end;
end;// if FLine[Run]...
if (FLine[Run]=EndChar) and (FLine[Run+1]=EndChar) and (FLine[Run+2]=EndChar) then begin
Inc(Run,3);
FRange:=rsUnknown;
Exit;
end;
Inc(Run);
until IsLineEnd(Run);
end;
procedure TSynPythonSyn.UnknownProc;
begin
Inc(Run);
FTokenID := tkUnknown;
end;
procedure TSynPythonSyn.Next;
begin
FTokenPos := Run;
case FRange of
rsMultilineString:
StringEndProc(#39);
rsMultilineString2:
StringEndProc('"');
rsMultilineString3:
StringEndProc(FStringStarter);
else
case FLine[Run] of
'&', '}', '{', ':', ',', ']', '[', '*', '`',
'^', ')', '(', ';', '/', '=', '-', '+', '!', '\',
'%', '|', '~' :
SymbolProc;
#13: CRProc;
'#': CommentProc;
'>': GreaterProc;
'A'..'Q', 'S', 'T', 'V'..'Z', 'a'..'q', 's', 't', 'v'..'z', '_': IdentProc;
#10: LFProc;
'<': LowerProc;
#0: NullProc;
'.', '0'..'9': NumberProc;
#1..#9, #11, #12, #14..#32: SpaceProc;
'r', 'R': PreStringProc;
'u', 'U': UnicodeStringProc;
'''': StringProc;
'"': String2Proc;
else UnknownProc;
end;
end;
inherited;
end;
function TSynPythonSyn.GetDefaultAttribute(Index: Integer): TSynHighlighterAttributes;
begin
case Index of
SYN_ATTR_COMMENT: Result := FCommentAttri;
SYN_ATTR_KEYWORD: Result := FKeyAttri;
SYN_ATTR_WHITESPACE: Result := FSpaceAttri;
SYN_ATTR_SYMBOL: Result := FSymbolAttri;
else
Result := nil;
end;
end;
function TSynPythonSyn.GetEol: Boolean;
begin
Result := Run = FLineLen + 1;
end;
function TSynPythonSyn.GetRange: Pointer;
begin
Result := Pointer(FRange);
end;
function TSynPythonSyn.GetTokenID: TtkTokenKind;
begin
Result := FTokenID;
end;
function TSynPythonSyn.GetTokenAttribute: TSynHighlighterAttributes;
begin
case FTokenID of
tkComment: Result := FCommentAttri;
tkIdentifier: Result := FIdentifierAttri;
tkKey: Result := FKeyAttri;
tkNonKeyword: Result := FNonKeyAttri;
tkSystemDefined: Result := FSystemAttri;
tkNumber: Result := FNumberAttri;
tkHex: Result := FHexAttri;
tkOct: Result := FOctalAttri;
tkFloat: Result := FFloatAttri;
tkSpace: Result := FSpaceAttri;
tkString: Result := FStringAttri;
tkTrippleQuotedString: Result := FDocStringAttri;
tkSymbol: Result := FSymbolAttri;
tkUnknown: Result := FErrorAttri;
else
Result := nil;
end;
end;
function TSynPythonSyn.GetTokenKind: Integer;
begin
Result := Ord(FTokenID);
end;
procedure TSynPythonSyn.ResetRange;
begin
FRange := rsUnknown;
end;
{$IFDEF SYN_CodeFolding}
procedure TSynPythonSyn.InitFoldRanges(FoldRanges: TSynFoldRanges);
begin
inherited;
FoldRanges.CodeFoldingMode := cfmIndentation;
end;
procedure TSynPythonSyn.ScanForFoldRanges(FoldRanges: TSynFoldRanges;
LinesToScan: TStrings; FromLine, ToLine: Integer);
var
CurLine: string;
LeftTrimmedLine : string;
Line: Integer;
Indent : Integer;
TabW : integer;
FoldType : integer;
const
MultiLineStringFoldType = 2;
ClassDefType = 3;
FunctionDefType = 4;
function IsMultiLineString(Line : integer; Range : TRangeState; Fold : Boolean): Boolean;
begin
Result := True;
if TRangeState(GetLineRange(LinesToScan, Line)) = Range then
begin
if (TRangeState(GetLineRange(LinesToScan, Line - 1)) <> Range) and Fold then
FoldRanges.StartFoldRange(Line + 1, MultiLineStringFoldType)
else
FoldRanges.NoFoldInfo(Line + 1);
end
else if (TRangeState(GetLineRange(LinesToScan, Line - 1)) = Range) and Fold then
begin
FoldRanges.StopFoldRange(Line + 1, MultiLineStringFoldType);
end else
Result := False;
end;
function FoldRegion(Line: Integer): Boolean;
begin
Result := False;
if Uppercase(Copy(LeftTrimmedLine, 1, 7)) = '#REGION' then
begin
FoldRanges.StartFoldRange(Line + 1, FoldRegionType);
Result := True;
end
else if Uppercase(Copy(LeftTrimmedLine, 1, 10)) = '#ENDREGION' then
begin
FoldRanges.StopFoldRange(Line + 1, FoldRegionType);
Result := True;
end;
end;
function LeftSpaces: Integer;
var
p: PWideChar;
begin
p := PWideChar(CurLine);
if Assigned(p) then
begin
Result := 0;
while (p^ >= #1) and (p^ <= #32) do
begin
if (p^ = #9) then
Inc(Result, TabW)
else
Inc(Result);
Inc(p);
end;
end
else
Result := 0;
end;
begin
// Deal with multiline strings
for Line := FromLine to ToLine do begin
if IsMultiLineString(Line, rsMultilineString, True) or
IsMultiLineString(Line, rsMultilineString2, True) or
IsMultiLineString(Line, rsMultilineString3, False)
then
Continue;
// Find Fold regions
CurLine := LinesToScan[Line];
LeftTrimmedLine := TrimLeft(CurLine);
// Skip empty lines
if LeftTrimmedLine = '' then begin
FoldRanges.NoFoldInfo(Line + 1);
Continue;
end;
// Find Fold regions
if FoldRegion(Line) then
Continue;
TabW := TabWidth(LinesToScan);
Indent := LeftSpaces;
// find fold openers
if BlockOpenerRE.Exec(LeftTrimmedLine) then
begin
if BlockOpenerRE.Match[1] = 'class' then
FoldType := ClassDefType
else if Pos('def', BlockOpenerRE.Match[1]) >= 1 then
FoldType := FunctionDefType
else
FoldType := 1;
FoldRanges.StartFoldRange(Line + 1, FoldType, Indent);
Continue;
end;
FoldRanges.StopFoldRange(Line + 1, 1, Indent)
end;
end;
{$ENDIF}
procedure TSynPythonSyn.SetRange(Value: Pointer);
begin
FRange := TRangeState(Value);
end;
function TSynPythonSyn.IsFilterStored: Boolean;
begin
Result := FDefaultFilter <> SYNS_FilterPython;
end;
class function TSynPythonSyn.GetLanguageName: string;
begin
Result := SYNS_LangPython;
end;
function TSynPythonSyn.GetSampleSource: UnicodeString;
begin
Result :=
'#!/usr/local/bin/python'#13#10 +
'import string, sys'#13#10 +
'""" If no arguments were given, print a helpful message """'#13#10 +
'if len(sys.argv)==1:'#13#10 +
' print ''Usage: celsius temp1 temp2 ...'''#13#10 +
' sys.exit(0)';
end;
class function TSynPythonSyn.GetFriendlyLanguageName: UnicodeString;
begin
Result := SYNS_FriendlyLangPython;
end;
initialization
{$IFNDEF SYN_CPPB_1}
RegisterPlaceableHighlighter(TSynPythonSyn);
{$ENDIF}
finalization
GlobalKeywords.Free;
end.
| 25.956973 | 189 | 0.630123 |
8340defdc6a02837e487845e3bc065da1ab01c57
| 2,733 |
pas
|
Pascal
|
LogViewer.Receivers.FileSystem.Settings.pas
|
jomael/LogViewer
|
81588885711c66ed4aca2f378e5bbfe68120045b
|
[
"Apache-2.0"
] | 38 |
2016-04-19T04:05:31.000Z
|
2022-03-16T12:34:52.000Z
|
LogViewer.Receivers.FileSystem.Settings.pas
|
jomael/LogViewer
|
81588885711c66ed4aca2f378e5bbfe68120045b
|
[
"Apache-2.0"
] | 4 |
2018-01-04T12:12:49.000Z
|
2021-03-09T16:38:55.000Z
|
LogViewer.Receivers.FileSystem.Settings.pas
|
jomael/LogViewer
|
81588885711c66ed4aca2f378e5bbfe68120045b
|
[
"Apache-2.0"
] | 12 |
2016-08-29T20:34:52.000Z
|
2022-01-06T00:23:46.000Z
|
{
Copyright (C) 2013-2021 Tim Sinaeve tim.sinaeve@gmail.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
}
unit LogViewer.Receivers.FileSystem.Settings;
interface
uses
System.Classes,
Spring;
type
TFileSystemSettings = class(TPersistent)
private
FOnChanged : Event<TNotifyEvent>;
FEnabled : Boolean;
FPathNames : TStrings;
protected
{$REGION 'property access methods'}
function GetPathNames: TStrings;
function GetEnabled: Boolean;
procedure SetEnabled(const Value: Boolean);
function GetOnChanged: IEvent<TNotifyEvent>;
{$ENDREGION}
procedure Changed;
public
procedure AfterConstruction; override;
destructor Destroy; override;
procedure Assign(Source: TPersistent); override;
property OnChanged: IEvent<TNotifyEvent>
read GetOnChanged;
published
property Enabled: Boolean
read GetEnabled write SetEnabled;
property PathNames: TStrings
read GetPathNames;
end;
implementation
{$REGION 'construction and destruction'}
procedure TFileSystemSettings.AfterConstruction;
begin
inherited AfterConstruction;
FPathNames := TStringList.Create;
end;
destructor TFileSystemSettings.Destroy;
begin
FPathNames.Free;
inherited Destroy;
end;
{$ENDREGION}
{$REGION 'property access methods'}
function TFileSystemSettings.GetEnabled: Boolean;
begin
Result := FEnabled;
end;
procedure TFileSystemSettings.SetEnabled(const Value: Boolean);
begin
if Value <> Enabled then
begin
FEnabled := Value;
Changed;
end;
end;
function TFileSystemSettings.GetOnChanged: IEvent<TNotifyEvent>;
begin
Result := FOnChanged;
end;
function TFileSystemSettings.GetPathNames: TStrings;
begin
Result := FPathNames;
end;
{$ENDREGION}
{$REGION 'protected methods'}
procedure TFileSystemSettings.Changed;
begin
FOnChanged.Invoke(Self);
end;
{$ENDREGION}
{$REGION 'public methods'}
procedure TFileSystemSettings.Assign(Source: TPersistent);
var
LSettings: TFileSystemSettings;
begin
if Source is TFileSystemSettings then
begin
LSettings := TFileSystemSettings(Source);
Enabled := LSettings.Enabled;
FPathNames.Assign(LSettings.PathNames);
end
else
inherited Assign(Source);
end;
{$ENDREGION}
end.
| 21.690476 | 74 | 0.753019 |
85d6569b24d74e38a7785d20468b77a62c597844
| 14,069 |
pas
|
Pascal
|
windows/src/ext/jedi/jvcl/tests/archive/jvcl/source/JvPresrDsn.pas
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 219 |
2017-06-21T03:37:03.000Z
|
2022-03-27T12:09:28.000Z
|
windows/src/ext/jedi/jvcl/tests/archive/jvcl/source/JvPresrDsn.pas
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 4,451 |
2017-05-29T02:52:06.000Z
|
2022-03-31T23:53:23.000Z
|
windows/src/ext/jedi/jvcl/tests/archive/jvcl/source/JvPresrDsn.pas
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 72 |
2017-05-26T04:08:37.000Z
|
2022-03-03T10:26:20.000Z
|
{-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: JvPresrDsn.PAS, released on 2002-07-04.
The Initial Developers of the Original Code are: Fedor Koshevnikov, Igor Pavluk and Serge Korolev
Copyright (c) 1997, 1998 Fedor Koshevnikov, Igor Pavluk and Serge Korolev
Copyright (c) 2001,2002 SGB Software
All Rights Reserved.
Last Modified: 2002-07-04
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.sourceforge.net
Known Issues:
-----------------------------------------------------------------------------}
{$I JVCL.INC}
unit JvPresrDsn;
interface
uses
SysUtils, Classes, Controls, Forms, StdCtrls,
Buttons, ExtCtrls, Consts,
{$IFDEF COMPILER6_UP}
RTLConsts, DesignIntf, VCLEditors, DesignEditors,
{$ELSE}
DsgnIntf,
{$ENDIF}
JvVCLUtils, JvxCtrls, JvPlacemnt, JvProps, JvListBox, JvCtrls;
type
{$IFNDEF COMPILER4_UP}
IDesigner = TDesigner;
{$ENDIF}
TJvFormPropsDlg = class(TForm)
Bevel1: TBevel;
Label30: TLabel;
Label31: TLabel;
Label2: TLabel;
UpBtn: TSpeedButton;
DownBtn: TSpeedButton;
FormBox: TGroupBox;
ActiveCtrlBox: TCheckBox;
PositionBox: TCheckBox;
StateBox: TCheckBox;
AddButton: TButton;
DeleteButton: TButton;
ClearButton: TButton;
OkBtn: TButton;
CancelBtn: TButton;
ComponentsList: TJvListBox;
PropertiesList: TJvListBox;
StoredList: TJvListBox;
procedure AddButtonClick(Sender: TObject);
procedure ClearButtonClick(Sender: TObject);
procedure ListClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure DeleteButtonClick(Sender: TObject);
procedure StoredListClick(Sender: TObject);
procedure UpBtnClick(Sender: TObject);
procedure DownBtnClick(Sender: TObject);
procedure StoredListDragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
procedure StoredListDragDrop(Sender, Source: TObject; X, Y: Integer);
procedure PropertiesListDblClick(Sender: TObject);
private
FCompOwner: TComponent;
FDesigner: IDesigner;
procedure ListToIndex(List: TCustomListBox; Idx: Integer);
procedure UpdateCurrent;
procedure DeleteProp(I: Integer);
function FindProp(const CompName, PropName: string; var IdxComp,
IdxProp: Integer): Boolean;
procedure ClearLists;
procedure CheckAddItem(const CompName, PropName: string);
procedure AddItem(IdxComp, IdxProp: Integer; AUpdate: Boolean);
procedure BuildLists(StoredProps: TStrings);
procedure CheckButtons;
procedure SetStoredList(AList: TStrings);
end;
TJvFormStorageEditor = class(TComponentEditor)
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
TJvStoredPropsProperty = class(TClassProperty)
public
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure Edit; override;
end;
function ShowStorageDesigner(ACompOwner: TComponent; ADesigner: IDesigner;
AStoredList: TStrings; var Options: TPlacementOptions): Boolean;
implementation
{$IFDEF WIN32}
uses
TypInfo,
JvBoxProcs, JvxDConst;
{$ELSE}
uses
WinTypes, WinProcs, TypInfo,
JvStr16, JvBoxProcs, JvxDConst;
{$ENDIF}
{$R *.DFM}
{$IFDEF WIN32}
{$D-}
{$ENDIF}
//=== TJvFormStorageEditor ===================================================
procedure TJvFormStorageEditor.ExecuteVerb(Index: Integer);
var
Storage: TJvFormStorage;
Opt: TPlacementOptions;
begin
Storage := Component as TJvFormStorage;
if Index = 0 then
begin
Opt := Storage.Options;
if ShowStorageDesigner(TComponent(Storage.Owner), Designer,
Storage.StoredProps, Opt) then
begin
Storage.Options := Opt;
{$IFDEF WIN32}
Storage.SetNotification;
{$ENDIF}
end;
end;
end;
function TJvFormStorageEditor.GetVerb(Index: Integer): string;
begin
case Index of
0:
Result := srStorageDesigner;
else
Result := '';
end;
end;
function TJvFormStorageEditor.GetVerbCount: Integer;
begin
Result := 1;
end;
//=== TJvStoredPropsProperty =================================================
function TJvStoredPropsProperty.GetAttributes: TPropertyAttributes;
begin
Result := inherited GetAttributes + [paDialog] - [paSubProperties];
end;
function TJvStoredPropsProperty.GetValue: string;
begin
if TStrings(GetOrdValue).Count > 0 then
Result := inherited GetValue
else
Result := ResStr(srNone);
end;
procedure TJvStoredPropsProperty.Edit;
var
Storage: TJvFormStorage;
Opt: TPlacementOptions;
begin
Storage := GetComponent(0) as TJvFormStorage;
Opt := Storage.Options;
if ShowStorageDesigner(Storage.Owner as TComponent, Designer,
Storage.StoredProps, Opt) then
begin
Storage.Options := Opt;
{$IFDEF WIN32}
Storage.SetNotification;
{$ENDIF}
end;
end;
function ShowStorageDesigner(ACompOwner: TComponent; ADesigner: IDesigner;
AStoredList: TStrings; var Options: TPlacementOptions): Boolean;
begin
with TJvFormPropsDlg.Create(Application) do
try
FCompOwner := ACompOwner;
FDesigner := ADesigner;
Screen.Cursor := crHourGlass;
try
UpdateStoredList(ACompOwner, AStoredList, False);
SetStoredList(AStoredList);
ActiveCtrlBox.Checked := fpActiveControl in Options;
PositionBox.Checked := fpPosition in Options;
StateBox.Checked := fpState in Options;
finally
Screen.Cursor := crDefault;
end;
Result := ShowModal = mrOk;
if Result then
begin
AStoredList.Assign(StoredList.Items);
Options := [];
if ActiveCtrlBox.Checked then
Include(Options, fpActiveControl);
if PositionBox.Checked then
Include(Options, fpPosition);
if StateBox.Checked then
Include(Options, fpState);
end;
finally
Free;
end;
end;
//=== TJvFormPropsDlg ========================================================
procedure TJvFormPropsDlg.ListToIndex(List: TCustomListBox; Idx: Integer);
procedure SetItemIndex(Index: Integer);
begin
if TJvListBox(List).MultiSelect then
TJvListBox(List).Selected[Index] := True;
List.ItemIndex := Index;
end;
begin
if Idx < List.Items.Count then
SetItemIndex(Idx)
else
if Idx - 1 < List.Items.Count then
SetItemIndex(Idx - 1)
else
if List.Items.Count > 0 then
SetItemIndex(0);
end;
procedure TJvFormPropsDlg.UpdateCurrent;
var
IdxProp: Integer;
List: TStrings;
begin
IdxProp := PropertiesList.ItemIndex;
if IdxProp < 0 then
IdxProp := 0;
if ComponentsList.Items.Count <= 0 then
begin
PropertiesList.Clear;
Exit;
end;
if ComponentsList.ItemIndex < 0 then
ComponentsList.ItemIndex := 0;
List := TStrings(ComponentsList.Items.Objects[ComponentsList.ItemIndex]);
if List.Count > 0 then
PropertiesList.Items := List
else
PropertiesList.Clear;
ListToIndex(PropertiesList, IdxProp);
CheckButtons;
end;
procedure TJvFormPropsDlg.DeleteProp(I: Integer);
var
CompName, PropName: string;
IdxComp, IdxProp, Idx: Integer;
StrList: TStringList;
begin
Idx := StoredList.ItemIndex;
if ParseStoredItem(StoredList.Items[I], CompName, PropName) then
begin
StoredList.Items.Delete(I);
if FDesigner <> nil then
FDesigner.Modified;
ListToIndex(StoredList, Idx);
{I := ComponentsList.ItemIndex;}
if not FindProp(CompName, PropName, IdxComp, IdxProp) then
begin
if IdxComp < 0 then
begin
StrList := TStringList.Create;
try
StrList.Add(PropName);
ComponentsList.Items.AddObject(CompName, StrList);
ComponentsList.ItemIndex := ComponentsList.Items.IndexOf(CompName);
except
StrList.Free;
raise;
end;
end
else
begin
TStrings(ComponentsList.Items.Objects[IdxComp]).Add(PropName);
end;
UpdateCurrent;
end;
end;
end;
function TJvFormPropsDlg.FindProp(const CompName, PropName: string;
var IdxComp, IdxProp: Integer): Boolean;
begin
Result := False;
IdxComp := ComponentsList.Items.IndexOf(CompName);
if IdxComp >= 0 then
begin
IdxProp := TStrings(ComponentsList.Items.Objects[IdxComp]).IndexOf(PropName);
if IdxProp >= 0 then
Result := True;
end;
end;
procedure TJvFormPropsDlg.ClearLists;
var
I: Integer;
begin
for I := 0 to ComponentsList.Items.Count - 1 do
begin
ComponentsList.Items.Objects[I].Free;
end;
ComponentsList.Items.Clear;
ComponentsList.Clear;
PropertiesList.Clear;
StoredList.Clear;
end;
procedure TJvFormPropsDlg.AddItem(IdxComp, IdxProp: Integer; AUpdate: Boolean);
var
Idx: Integer;
StrList: TStringList;
CompName, PropName: string;
Component: TComponent;
begin
CompName := ComponentsList.Items[IdxComp];
Component := FCompOwner.FindComponent(CompName);
if Component = nil then
Exit;
StrList := TStringList(ComponentsList.Items.Objects[IdxComp]);
PropName := StrList[IdxProp];
StrList.Delete(IdxProp);
if StrList.Count = 0 then
begin
Idx := ComponentsList.ItemIndex;
StrList.Free;
ComponentsList.Items.Delete(IdxComp);
ListToIndex(ComponentsList, Idx);
end;
StoredList.Items.AddObject(CreateStoredItem(CompName, PropName), Component);
if FDesigner <> nil then
FDesigner.Modified;
StoredList.ItemIndex := StoredList.Items.Count - 1;
if AUpdate then
UpdateCurrent;
end;
procedure TJvFormPropsDlg.CheckAddItem(const CompName, PropName: string);
var
IdxComp, IdxProp: Integer;
begin
if FindProp(CompName, PropName, IdxComp, IdxProp) then
AddItem(IdxComp, IdxProp, True);
end;
procedure TJvFormPropsDlg.BuildLists(StoredProps: TStrings);
var
I, J: Integer;
C: TComponent;
List: TJvPropInfoList;
StrList: TStrings;
CompName, PropName: string;
begin
ClearLists;
if FCompOwner <> nil then
begin
for I := 0 to FCompOwner.ComponentCount - 1 do
begin
C := FCompOwner.Components[I];
if (C is TJvFormPlacement) or (C.Name = '') then
Continue;
List := TJvPropInfoList.Create(C, tkProperties);
try
StrList := TStringList.Create;
try
TStringList(StrList).Sorted := True;
for J := 0 to List.Count - 1 do
StrList.Add(List.Items[J]^.Name);
ComponentsList.Items.AddObject(C.Name, StrList);
except
StrList.Free;
raise;
end;
finally
List.Free;
end;
end;
if StoredProps <> nil then
begin
for I := 0 to StoredProps.Count - 1 do
begin
if ParseStoredItem(StoredProps[I], CompName, PropName) then
CheckAddItem(CompName, PropName);
end;
ListToIndex(StoredList, 0);
end;
end
else
StoredList.Items.Clear;
UpdateCurrent;
end;
procedure TJvFormPropsDlg.SetStoredList(AList: TStrings);
begin
BuildLists(AList);
if ComponentsList.Items.Count > 0 then
ComponentsList.ItemIndex := 0;
CheckButtons;
end;
procedure TJvFormPropsDlg.CheckButtons;
var
Enable: Boolean;
begin
AddButton.Enabled := (ComponentsList.ItemIndex >= 0) and
(PropertiesList.ItemIndex >= 0);
Enable := (StoredList.Items.Count > 0) and
(StoredList.ItemIndex >= 0);
DeleteButton.Enabled := Enable;
ClearButton.Enabled := Enable;
UpBtn.Enabled := Enable and (StoredList.ItemIndex > 0);
DownBtn.Enabled := Enable and (StoredList.ItemIndex < StoredList.Items.Count - 1);
end;
procedure TJvFormPropsDlg.AddButtonClick(Sender: TObject);
var
I: Integer;
begin
if PropertiesList.SelCount > 0 then
begin
for I := PropertiesList.Items.Count - 1 downto 0 do
begin
if PropertiesList.Selected[I] then
AddItem(ComponentsList.ItemIndex, I, False);
end;
UpdateCurrent;
end
else
AddItem(ComponentsList.ItemIndex, PropertiesList.ItemIndex, True);
CheckButtons;
end;
procedure TJvFormPropsDlg.ClearButtonClick(Sender: TObject);
begin
if StoredList.Items.Count > 0 then
begin
SetStoredList(nil);
if FDesigner <> nil then
FDesigner.Modified;
end;
end;
procedure TJvFormPropsDlg.DeleteButtonClick(Sender: TObject);
begin
DeleteProp(StoredList.ItemIndex);
end;
procedure TJvFormPropsDlg.ListClick(Sender: TObject);
begin
if Sender = ComponentsList then
UpdateCurrent
else
CheckButtons;
end;
procedure TJvFormPropsDlg.FormDestroy(Sender: TObject);
begin
ClearLists;
end;
procedure TJvFormPropsDlg.StoredListClick(Sender: TObject);
begin
CheckButtons;
end;
procedure TJvFormPropsDlg.UpBtnClick(Sender: TObject);
begin
BoxMoveFocusedItem(StoredList, StoredList.ItemIndex - 1);
if FDesigner <> nil then
FDesigner.Modified;
CheckButtons;
end;
procedure TJvFormPropsDlg.DownBtnClick(Sender: TObject);
begin
BoxMoveFocusedItem(StoredList, StoredList.ItemIndex + 1);
if FDesigner <> nil then
FDesigner.Modified;
CheckButtons;
end;
procedure TJvFormPropsDlg.StoredListDragOver(Sender, Source: TObject; X,
Y: Integer; State: TDragState; var Accept: Boolean);
begin
BoxDragOver(StoredList, Source, X, Y, State, Accept, StoredList.Sorted);
CheckButtons;
end;
procedure TJvFormPropsDlg.StoredListDragDrop(Sender, Source: TObject; X,
Y: Integer);
begin
BoxMoveFocusedItem(StoredList, StoredList.ItemAtPos(Point(X, Y), True));
if FDesigner <> nil then
FDesigner.Modified;
CheckButtons;
end;
procedure TJvFormPropsDlg.PropertiesListDblClick(Sender: TObject);
begin
if AddButton.Enabled then
AddButtonClick(nil);
end;
end.
| 26.150558 | 97 | 0.701756 |
f19c6a06ce6006a8a2856a0609627ac970d7c30a
| 637 |
pas
|
Pascal
|
src/Libs/Protocol/Implementations/SCGI/Exceptions/EInvalidScgiBodyImpl.pas
|
atkins126/fano
|
472679437cb42637b0527dda8255ec52a3e1e953
|
[
"MIT"
] | null | null | null |
src/Libs/Protocol/Implementations/SCGI/Exceptions/EInvalidScgiBodyImpl.pas
|
atkins126/fano
|
472679437cb42637b0527dda8255ec52a3e1e953
|
[
"MIT"
] | null | null | null |
src/Libs/Protocol/Implementations/SCGI/Exceptions/EInvalidScgiBodyImpl.pas
|
atkins126/fano
|
472679437cb42637b0527dda8255ec52a3e1e953
|
[
"MIT"
] | null | null | null |
{*!
* Fano Web Framework (https://fanoframework.github.io)
*
* @link https://github.com/fanoframework/fano
* @copyright Copyright (c) 2018 - 2020 Zamrony P. Juhara
* @license https://github.com/fanoframework/fano/blob/master/LICENSE (MIT)
*}
unit EInvalidScgiBodyImpl;
interface
{$MODE OBJFPC}
uses
sysutils;
type
(*!------------------------------------------------
* Exception that is raised when SCGI body invalid
*
* @author Zamrony P. Juhara <zamronypj@yahoo.com>
*-----------------------------------------------*)
EInvalidScgiBody = class(Exception)
end;
implementation
end.
| 20.548387 | 77 | 0.568289 |
85968168409931bee934fafcb552fbcb2a13b16e
| 6,644 |
pas
|
Pascal
|
sources/MVCFramework.SQLGenerators.MSSQL.pas
|
andreaciotti/delphimvcframework
|
e356e3fd5734f3a46348303a8a10820e212fdfda
|
[
"Apache-2.0"
] | 1 |
2021-09-08T12:47:24.000Z
|
2021-09-08T12:47:24.000Z
|
sources/MVCFramework.SQLGenerators.MSSQL.pas
|
andreaciotti/delphimvcframework
|
e356e3fd5734f3a46348303a8a10820e212fdfda
|
[
"Apache-2.0"
] | null | null | null |
sources/MVCFramework.SQLGenerators.MSSQL.pas
|
andreaciotti/delphimvcframework
|
e356e3fd5734f3a46348303a8a10820e212fdfda
|
[
"Apache-2.0"
] | 1 |
2021-09-08T12:47:25.000Z
|
2021-09-08T12:47:25.000Z
|
// *************************************************************************** }
//
// Delphi MVC Framework
//
// Copyright (c) 2010-2020 Daniele Teti and the DMVCFramework Team
//
// https://github.com/danieleteti/delphimvcframework
//
// ***************************************************************************
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ***************************************************************************
unit MVCFramework.SQLGenerators.MSSQL;
interface
uses
FireDAC.Phys.MSSQLDef,
FireDAC.Phys.MSSQL,
System.Rtti,
System.Generics.Collections,
MVCFramework.RQL.Parser,
MVCFramework.ActiveRecord,
MVCFramework.Commons;
type
TMVCSQLGeneratorMSSQL = class(TMVCSQLGenerator)
protected
function GetCompilerClass: TRQLCompilerClass; override;
public
function CreateSelectSQL(
const TableName: string;
const Map: TFieldsMap;
const PKFieldName: string;
const PKOptions: TMVCActiveRecordFieldOptions): string; override;
function CreateInsertSQL(
const TableName: string;
const Map: TFieldsMap;
const PKFieldName: string;
const PKOptions: TMVCActiveRecordFieldOptions): string; override;
function CreateUpdateSQL(
const TableName: string;
const Map: TFieldsMap;
const PKFieldName: string;
const PKOptions: TMVCActiveRecordFieldOptions): string; override;
function CreateDeleteSQL(
const TableName: string;
const Map: TFieldsMap;
const PKFieldName: string;
const PKOptions: TMVCActiveRecordFieldOptions): string; override;
function CreateSelectByPKSQL(
const TableName: string;
const Map: TFieldsMap; const PKFieldName: string;
const PKOptions: TMVCActiveRecordFieldOptions): string; override;
function CreateSQLWhereByRQL(
const RQL: string; const Mapping: TMVCFieldsMapping;
const UseArtificialLimit: Boolean = True;
const UseFilterOnly: Boolean = False): string; override;
function CreateSelectCount(
const TableName: string): string; override;
function CreateDeleteAllSQL(
const TableName: string): string; override;
end;
implementation
uses
System.SysUtils,
MVCFramework.RQL.AST2MSSQL;
function TMVCSQLGeneratorMSSQL.CreateInsertSQL(const TableName: string; const Map: TFieldsMap;
const PKFieldName: string; const PKOptions: TMVCActiveRecordFieldOptions): string;
var
lKeyValue: TPair<TRttiField, TFieldInfo>;
lSB: TStringBuilder;
lPKInInsert: Boolean;
begin
lPKInInsert := (not PKFieldName.IsEmpty) and (not(TMVCActiveRecordFieldOption.foAutoGenerated in PKOptions));
lSB := TStringBuilder.Create;
try
lSB.Append('INSERT INTO ' + TableName + '(');
if lPKInInsert then
begin
lSB.Append(PKFieldName + ',');
end;
for lKeyValue in Map do
begin
if lKeyValue.Value.Writeable then
begin
lSB.Append(lKeyValue.Value.FieldName + ',');
end;
end;
lSB.Remove(lSB.Length - 1, 1);
lSB.Append(') values (');
if lPKInInsert then
begin
lSB.Append(':' + PKFieldName + ',');
end;
for lKeyValue in Map do
begin
if lKeyValue.Value.Writeable then
begin
lSB.Append(':' + lKeyValue.Value.FieldName + ',');
end;
end;
lSB.Remove(lSB.Length - 1, 1);
lSB.Append(')');
if TMVCActiveRecordFieldOption.foAutoGenerated in PKOptions then
begin
lSB.Append(';SELECT SCOPE_IDENTITY() as ' + PKFieldName);
end;
Result := lSB.ToString;
finally
lSB.Free;
end;
end;
function TMVCSQLGeneratorMSSQL.CreateSelectByPKSQL(
const TableName: string;
const Map: TFieldsMap; const PKFieldName: string;
const PKOptions: TMVCActiveRecordFieldOptions): string;
begin
Result := CreateSelectSQL(TableName, Map, PKFieldName, PKOptions) + ' WHERE ' +
PKFieldName + '= :' + PKFieldName; // IntToStr(PrimaryKeyValue);
end;
function TMVCSQLGeneratorMSSQL.CreateSelectCount(
const TableName: string): string;
begin
Result := 'SELECT count(*) FROM ' + TableName;
end;
function TMVCSQLGeneratorMSSQL.CreateSelectSQL(const TableName: string;
const Map: TFieldsMap; const PKFieldName: string;
const PKOptions: TMVCActiveRecordFieldOptions): string;
begin
Result := 'SELECT ' + TableFieldsDelimited(Map, PKFieldName, ',') + ' FROM ' + TableName;
end;
function TMVCSQLGeneratorMSSQL.CreateSQLWhereByRQL(
const RQL: string; const Mapping: TMVCFieldsMapping;
const UseArtificialLimit: Boolean;
const UseFilterOnly: Boolean): string;
var
lMSSQLCompiler: TRQLMSSQLCompiler;
begin
lMSSQLCompiler := TRQLMSSQLCompiler.Create(Mapping);
try
GetRQLParser.Execute(RQL, Result, lMSSQLCompiler, UseArtificialLimit, UseFilterOnly);
finally
lMSSQLCompiler.Free;
end;
end;
function TMVCSQLGeneratorMSSQL.CreateUpdateSQL(const TableName: string; const Map: TFieldsMap;
const PKFieldName: string; const PKOptions: TMVCActiveRecordFieldOptions): string;
var
lKeyValue: TPair<TRttiField, TFieldInfo>;
begin
Result := 'UPDATE ' + TableName + ' SET ';
for lKeyValue in Map do
begin
if lKeyValue.Value.Writeable then
begin
Result := Result + lKeyValue.Value.FieldName + ' = :' + lKeyValue.Value.FieldName + ',';
end;
end;
Result[Length(Result)] := ' ';
if not PKFieldName.IsEmpty then
begin
Result := Result + ' where ' + PKFieldName + '= :' + PKFieldName;
end;
end;
function TMVCSQLGeneratorMSSQL.GetCompilerClass: TRQLCompilerClass;
begin
Result := TRQLMSSQLCompiler;
end;
function TMVCSQLGeneratorMSSQL.CreateDeleteAllSQL(
const TableName: string): string;
begin
Result := 'DELETE FROM ' + TableName;
end;
function TMVCSQLGeneratorMSSQL.CreateDeleteSQL(
const TableName: string;
const Map: TFieldsMap;
const PKFieldName: string;
const PKOptions: TMVCActiveRecordFieldOptions): string;
begin
Result := 'DELETE FROM ' + TableName + ' WHERE ' + PKFieldName + '=:' + PKFieldName;
end;
initialization
TMVCSQLGeneratorRegistry.Instance.RegisterSQLGenerator('mssql', TMVCSQLGeneratorMSSQL);
finalization
TMVCSQLGeneratorRegistry.Instance.UnRegisterSQLGenerator('mssql');
end.
| 30.617512 | 111 | 0.701535 |
f1ef4299a96685e33ec6b8db00f597f72fbdcbef
| 11,578 |
dfm
|
Pascal
|
Samples/MDITabSet/MainForm.dfm
|
atkins126/DTF
|
20566d154b297916ce78aec64c0e547e7510ed55
|
[
"MIT"
] | 3 |
2020-11-12T17:47:19.000Z
|
2021-07-21T12:31:41.000Z
|
Samples/MDITabSet/MainForm.dfm
|
atkins126/DTF
|
20566d154b297916ce78aec64c0e547e7510ed55
|
[
"MIT"
] | 1 |
2021-04-21T14:43:57.000Z
|
2021-04-21T14:43:57.000Z
|
Samples/MDITabSet/MainForm.dfm
|
atkins126/DTF
|
20566d154b297916ce78aec64c0e547e7510ed55
|
[
"MIT"
] | 1 |
2021-01-26T06:36:34.000Z
|
2021-01-26T06:36:34.000Z
|
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 463
ClientWidth = 752
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
Menu = MainMenu1
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object TabSet: TTabSet
Left = 0
Top = 442
Width = 752
Height = 21
Align = alBottom
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OnChange = TabSetChange
OnMouseUp = TabSetMouseUp
end
object ToolBar1: TToolBar
Left = 0
Top = 0
Width = 752
Height = 29
Caption = 'ToolBar1'
Images = ImageList1
TabOrder = 1
object ToolButton1: TToolButton
Left = 0
Top = 0
Caption = 'ToolButton1'
ImageIndex = 0
OnClick = ToolButton1Click
end
end
object MainMenu1: TMainMenu
Left = 368
Top = 240
object Files1: TMenuItem
Caption = '&Files'
object NewSubForm1: TMenuItem
Caption = '&New SubForm'
OnClick = NewSubForm1Click
end
object N2: TMenuItem
Caption = '-'
end
object Closeform1: TMenuItem
Caption = '&Close form'
OnClick = Closeform1Click
end
object Closeall1: TMenuItem
Caption = 'Close al&l'
OnClick = Closeall1Click
end
end
end
object ImageList1: TImageList
Left = 168
Top = 64
Bitmap = {
494C010101000800040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000400000001000000001002000000000000010
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF000000000000000000FFFFFF00FFFFFF00FFFFFF000000000000000000FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF0000000000000000000000000000000000000000000000000000000000FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0000000000FFFFFF0000000000000000000000000000000000FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF0000000000FFFFFF00FFFFFF00FFFFFF0000000000FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF000000
00000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFFFF00000000000000
0000FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF000000
0000000000000000000000000000FFFFFF000000000000000000000000000000
000000000000FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00000000000000000000000000FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00000000000000000000000000FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF000000000000000000FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFF
FF00FFFFFF00FFFFFF00FFFFFF00FFFFFF000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000424D3E000000000000003E000000
2800000040000000100000000100010000000000800000000000000000000000
000000000000000000000000FFFFFF0000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
000000000000}
end
object PopupMenu1: TPopupMenu
Left = 136
Top = 280
object C1: TMenuItem
Caption = #45803#44592'(&C)'
OnClick = C1Click
end
object N1: TMenuItem
Caption = #47784#46160' '#45803#44592
OnClick = N1Click
end
end
end
| 51.230088 | 70 | 0.854552 |
f1e06d11991b959d7633cb37eaff0235468c7ae5
| 879 |
pas
|
Pascal
|
Test/SimpleScripts/oop.pas
|
skolkman/dwscript
|
b9f99d4b8187defac3f3713e2ae0f7b83b63d516
|
[
"Condor-1.1"
] | 79 |
2015-03-18T10:46:13.000Z
|
2022-03-17T18:05:11.000Z
|
Test/SimpleScripts/oop.pas
|
skolkman/dwscript
|
b9f99d4b8187defac3f3713e2ae0f7b83b63d516
|
[
"Condor-1.1"
] | 6 |
2016-03-29T14:39:00.000Z
|
2020-09-14T10:04:14.000Z
|
Test/SimpleScripts/oop.pas
|
skolkman/dwscript
|
b9f99d4b8187defac3f3713e2ae0f7b83b63d516
|
[
"Condor-1.1"
] | 25 |
2016-05-04T13:11:38.000Z
|
2021-09-29T13:34:31.000Z
|
{
Demo: Object Orientated Programming (OOP)
}
type
AClass = class
s, t: string;
procedure P(param: string); virtual;
function Q: string;
end;
type
BClass = class(AClass)
u, v: string;
procedure P(param: string); override;
function Q: string;
end;
procedure AClass.P;
begin
PrintLn('AClass.P(' + param + ')');
end;
function AClass.Q: string;
begin
Result := 'AClass.Q: Static method';
end;
procedure BClass.P;
begin
PrintLn('BClass.P(' + param + ')');
inherited P(param);
end;
function BClass.Q: string;
begin
Result := 'BClass.Q: Static method';
inherited P('inh');
end;
var o: AClass;
o := BClass.Create;
PrintLn('--- Virtual methods');
o.P('Hello World!');
BClass(o).P('Hello World!');
PrintLn('');
PrintLn('--- Static methods');
PrintLn(o.Q);
PrintLn(BClass(o).Q);
| 15.981818 | 42 | 0.598407 |
85d00770bc79a014ec7807c9f2135d1e5b016bd0
| 6,658 |
pas
|
Pascal
|
CryptoLib/src/Crypto/Generators/ClpECKeyPairGenerator.pas
|
stlcours/CryptoLib4Pascal
|
82344d4a4b74422559fa693466ca04652e42cf8b
|
[
"MIT"
] | 2 |
2019-07-09T10:06:53.000Z
|
2021-08-15T18:19:31.000Z
|
CryptoLib/src/Crypto/Generators/ClpECKeyPairGenerator.pas
|
stlcours/CryptoLib4Pascal
|
82344d4a4b74422559fa693466ca04652e42cf8b
|
[
"MIT"
] | null | null | null |
CryptoLib/src/Crypto/Generators/ClpECKeyPairGenerator.pas
|
stlcours/CryptoLib4Pascal
|
82344d4a4b74422559fa693466ca04652e42cf8b
|
[
"MIT"
] | null | null | null |
{ *********************************************************************************** }
{ * CryptoLib Library * }
{ * Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe * }
{ * Github Repository <https://github.com/Xor-el> * }
{ * Distributed under the MIT software license, see the accompanying file LICENSE * }
{ * or visit http://www.opensource.org/licenses/mit-license.php. * }
{ * Acknowledgements: * }
{ * * }
{ * Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring * }
{ * development of this library * }
{ * ******************************************************************************* * }
(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
unit ClpECKeyPairGenerator;
{$I ..\..\Include\CryptoLib.inc}
interface
uses
SysUtils,
ClpBigInteger,
ClpBits,
ClpCryptoLibTypes,
ClpECKeyParameters,
ClpECAlgorithms,
ClpIECKeyPairGenerator,
ClpIAsn1Objects,
ClpIKeyGenerationParameters,
ClpIECKeyGenerationParameters,
ClpECDomainParameters,
ClpIECDomainParameters,
ClpIECC,
ClpIFixedPointCombMultiplier,
ClpSecObjectIdentifiers,
ClpCustomNamedCurves,
ClpECNamedCurveTable,
ClpX9ObjectIdentifiers,
ClpIX9ECParameters,
ClpAsymmetricCipherKeyPair,
ClpIAsymmetricCipherKeyPair,
ClpECPublicKeyParameters,
ClpIECPublicKeyParameters,
ClpECPrivateKeyParameters,
ClpIECPrivateKeyParameters,
ClpFixedPointCombMultiplier,
ClpSecureRandom,
ClpISecureRandom,
ClpIAsymmetricCipherKeyPairGenerator;
resourcestring
SAlgorithmNil = 'Algorithm Cannot be Empty';
SInvalidKeySize = 'Unknown Key Size "%d"';
type
TECKeyPairGenerator = class sealed(TInterfacedObject, IECKeyPairGenerator,
IAsymmetricCipherKeyPairGenerator)
strict private
var
Falgorithm: String;
Fparameters: IECDomainParameters;
FpublicKeyParamSet: IDerObjectIdentifier;
Frandom: ISecureRandom;
strict protected
function CreateBasePointMultiplier(): IECMultiplier; virtual;
public
constructor Create(); overload;
constructor Create(const algorithm: String); overload;
procedure Init(const parameters: IKeyGenerationParameters);
// /**
// * Given the domain parameters this routine generates an EC key
// * pair in accordance with X9.62 section 5.2.1 pages 26, 27.
// */
function GenerateKeyPair(): IAsymmetricCipherKeyPair;
class function FindECCurveByOid(const oid: IDerObjectIdentifier)
: IX9ECParameters; static;
class function GetCorrespondingPublicKey(const privKey
: IECPrivateKeyParameters): IECPublicKeyParameters; static;
end;
implementation
{ TECKeyPairGenerator }
constructor TECKeyPairGenerator.Create;
begin
Create('EC');
end;
constructor TECKeyPairGenerator.Create(const algorithm: String);
begin
if (algorithm = '') then
raise EArgumentNilCryptoLibException.CreateRes(@SAlgorithmNil);
Falgorithm := TECKeyParameters.VerifyAlgorithmName(algorithm);
end;
function TECKeyPairGenerator.CreateBasePointMultiplier: IECMultiplier;
begin
result := TFixedPointCombMultiplier.Create();
end;
class function TECKeyPairGenerator.FindECCurveByOid
(const oid: IDerObjectIdentifier): IX9ECParameters;
var
ecP: IX9ECParameters;
begin
// TODO ECGost3410NamedCurves support (returns ECDomainParameters though)
ecP := TCustomNamedCurves.GetByOid(oid);
if (ecP = Nil) then
begin
ecP := TECNamedCurveTable.GetByOid(oid);
end;
result := ecP;
end;
function TECKeyPairGenerator.GenerateKeyPair: IAsymmetricCipherKeyPair;
var
n, d: TBigInteger;
minWeight: Int32;
q: IECPoint;
begin
n := Fparameters.n;
minWeight := TBits.Asr32(n.BitLength, 2);
while (true) do
begin
d := TBigInteger.Create(n.BitLength, Frandom);
if ((d.CompareTo(TBigInteger.Two) < 0) or (d.CompareTo(n) >= 0)) then
continue;
if (TWNafUtilities.GetNafWeight(d) < minWeight) then
begin
continue;
end;
break;
end;
q := CreateBasePointMultiplier().Multiply(Fparameters.G, d);
if (FpublicKeyParamSet <> Nil) then
begin
result := TAsymmetricCipherKeyPair.Create
(TECPublicKeyParameters.Create(Falgorithm, q, FpublicKeyParamSet)
as IECPublicKeyParameters, TECPrivateKeyParameters.Create(Falgorithm, d,
FpublicKeyParamSet) as IECPrivateKeyParameters);
Exit;
end;
result := TAsymmetricCipherKeyPair.Create
(TECPublicKeyParameters.Create(Falgorithm, q, Fparameters)
as IECPublicKeyParameters, TECPrivateKeyParameters.Create(Falgorithm, d,
Fparameters) as IECPrivateKeyParameters);
end;
class function TECKeyPairGenerator.GetCorrespondingPublicKey
(const privKey: IECPrivateKeyParameters): IECPublicKeyParameters;
var
ec: IECDomainParameters;
q: IECPoint;
begin
ec := privKey.parameters;
q := (TFixedPointCombMultiplier.Create() as IFixedPointCombMultiplier)
.Multiply(ec.G, privKey.d);
if (privKey.publicKeyParamSet <> Nil) then
begin
result := TECPublicKeyParameters.Create(privKey.AlgorithmName, q,
privKey.publicKeyParamSet);
Exit;
end;
result := TECPublicKeyParameters.Create(privKey.AlgorithmName, q, ec);
end;
procedure TECKeyPairGenerator.Init(const parameters: IKeyGenerationParameters);
var
ecP: IECKeyGenerationParameters;
ecps: IX9ECParameters;
oid: IDerObjectIdentifier;
begin
if (Supports(parameters, IECKeyGenerationParameters, ecP)) then
begin
FpublicKeyParamSet := ecP.publicKeyParamSet;
Fparameters := ecP.DomainParameters;
end
else
begin
case parameters.Strength of
192:
oid := TX9ObjectIdentifiers.Prime192v1;
224:
oid := TSecObjectIdentifiers.SecP224r1;
239:
oid := TX9ObjectIdentifiers.Prime239v1;
256:
oid := TX9ObjectIdentifiers.Prime256v1;
384:
oid := TSecObjectIdentifiers.SecP384r1;
521:
oid := TSecObjectIdentifiers.SecP521r1;
else
raise EInvalidParameterCryptoLibException.CreateResFmt(@SInvalidKeySize,
[parameters.Strength]);
end;
ecps := FindECCurveByOid(oid);
FpublicKeyParamSet := oid;
Fparameters := TECDomainParameters.Create(ecps.Curve, ecps.G, ecps.n,
ecps.H, ecps.GetSeed());
end;
Frandom := parameters.random;
if (Frandom = Nil) then
begin
Frandom := TSecureRandom.Create();
end;
end;
end.
| 27.512397 | 87 | 0.673325 |
8318bda1d8bfd746cee520ee7c1e043de8b28f5e
| 4,385 |
dpr
|
Pascal
|
Test/XE7/TestProjectX.dpr
|
sauravmohapatra/delphi-leakcheck
|
9c4964d4e504a17e8820364d907cdb6703045dcf
|
[
"Apache-2.0"
] | 25 |
2017-10-11T14:52:00.000Z
|
2021-12-02T05:38:56.000Z
|
Test/XE7/TestProjectX.dpr
|
sauravmohapatra/delphi-leakcheck
|
9c4964d4e504a17e8820364d907cdb6703045dcf
|
[
"Apache-2.0"
] | null | null | null |
Test/XE7/TestProjectX.dpr
|
sauravmohapatra/delphi-leakcheck
|
9c4964d4e504a17e8820364d907cdb6703045dcf
|
[
"Apache-2.0"
] | 10 |
2017-06-05T13:48:42.000Z
|
2021-12-02T05:38:58.000Z
|
{***************************************************************************}
{ }
{ LeakCheck for Delphi }
{ }
{ Copyright (c) 2015 Honza Rames }
{ }
{ https://bitbucket.org/shadow_cs/delphi-leakcheck }
{ }
{***************************************************************************}
{ }
{ Licensed under the Apache License, Version 2.0 (the "License"); }
{ you may not use this file except in compliance with the License. }
{ You may obtain a copy of the License at }
{ }
{ http://www.apache.org/licenses/LICENSE-2.0 }
{ }
{ Unless required by applicable law or agreed to in writing, software }
{ distributed under the License is distributed on an "AS IS" BASIS, }
{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }
{ See the License for the specific language governing permissions and }
{ limitations under the License. }
{ }
{***************************************************************************}
program TestProjectX;
// Make sure to have DUnitX in your global search path or point DUNITX_DIR
// environmental variable to DUnitX base source directory.
// Note that in order to run this project you have to have the updated DUnitX
// framework that supports extended leak checking.
uses
{$IFDEF WIN32}
FastMM4,
{$ENDIF }
LeakCheck in '..\..\Source\LeakCheck.pas',
System.StartUpCopy,
LeakCheck.Utils in '..\..\Source\LeakCheck.Utils.pas',
FMX.Forms,
DUnitX.TestFramework,
DUnitX.IoC,
TestInsight.DUnitX,
Posix.Proc in '..\..\External\Backtrace\Source\Posix.Proc.pas',
LeakCheck.TestForm in '..\LeakCheck.TestForm.pas' {frmLeakCheckTest},
LeakCheck.TestDUnitX in '..\LeakCheck.TestDUnitX.pas',
LeakCheck.Collections in '..\..\Source\LeakCheck.Collections.pas',
LeakCheck.Cycle in '..\..\Source\LeakCheck.Cycle.pas',
LeakCheck.Cycle.Utils in '..\..\Source\LeakCheck.Cycle.Utils.pas',
DUnitX.MemoryLeakMonitor.LeakCheck in '..\..\External\DUnitX\DUnitX.MemoryLeakMonitor.LeakCheck.pas',
DUnitX.MemoryLeakMonitor.LeakCheckCycle in '..\..\External\DUnitX\DUnitX.MemoryLeakMonitor.LeakCheckCycle.pas',
{$IFDEF MSWINDOWS}
{$IFDEF CPUX32}
LeakCheck.Trace.DbgHelp in '..\..\Source\LeakCheck.Trace.DbgHelp.pas',
{$ENDIF }
LeakCheck.Trace.WinApi in '..\..\Source\LeakCheck.Trace.WinApi.pas',
LeakCheck.Trace.Jcl in '..\..\Source\LeakCheck.Trace.Jcl.pas',
LeakCheck.MapFile in '..\..\Source\LeakCheck.MapFile.pas',
LeakCheck.Trace.Map in '..\..\Source\LeakCheck.Trace.Map.pas',
{$ENDIF }
{$IFDEF POSIX}
LeakCheck.Trace.Backtrace in '..\..\Source\LeakCheck.Trace.Backtrace.pas',
{$ENDIF }
LeakCheck.TestCycle in '..\LeakCheck.TestCycle.pas';
{$R *.res}
procedure Run;
begin
ReportMemoryLeaksOnShutdown := True;
{$IFDEF MSWINDOWS}
{$IFDEF CPUX64}
TLeakCheck.GetStackTraceProc := WinApiStackTrace;
{$ELSE}
TLeakCheck.GetStackTraceProc := JclRawStackTrace;
{$ENDIF}
TLeakCheck.GetStackTraceFormatterProc := MapStackTraceFormatter;
{$ENDIF}
{$IFDEF POSIX}
TLeakCheck.GetStackTraceProc := BacktraceStackTrace;
TLeakCheck.GetStackTraceFormatterProc := PosixProcStackTraceFormatter;
{$ENDIF}
TDUnitX.RegisterTestFixture(TTestCycle);
TDUnitX.RegisterTestFixture(TTestLeaksWithACycle);
TDUnitX.RegisterTestFixture(TTestIgnoreGraphSimple);
TDUnitX.RegisterTestFixture(TTestIgnoreGraphComplex);
TDUnitXIoC.DefaultContainer.RegisterType<IMemoryLeakMonitor>(
function : IMemoryLeakMonitor
begin
result := TDUnitXLeakCheckGraphMemoryLeakMonitor.Create;
end);
RunRegisteredTests;
end;
begin
Run;
end.
| 43.85 | 113 | 0.557583 |
853c78acbb72292462796f70cfe64b4cd0c20c9c
| 180 |
pas
|
Pascal
|
toolchain/pascompl/test/reject/iso7185prt0030.pas
|
besm6/mesm6
|
308b524c78a65e5aaba15b5b9e37f3fd83fc2c53
|
[
"MIT"
] | 37 |
2019-03-12T17:19:46.000Z
|
2022-02-04T00:25:55.000Z
|
toolchain/pascompl/test/reject/iso7185prt0030.pas
|
besm6/mesm6
|
308b524c78a65e5aaba15b5b9e37f3fd83fc2c53
|
[
"MIT"
] | 13 |
2019-03-05T06:10:14.000Z
|
2020-11-30T09:30:52.000Z
|
toolchain/pascompl/test/reject/iso7185prt0030.pas
|
besm6/mesm6
|
308b524c78a65e5aaba15b5b9e37f3fd83fc2c53
|
[
"MIT"
] | 4 |
2019-03-23T15:51:56.000Z
|
2020-07-28T22:34:42.000Z
|
{
PRT test 30: Missing semicolon in type
}
program iso7185prt0030;
type integer = char
five = integer;
var i: integer;
a: five;
begin
i := 'a';
a := 1
end.
| 9 | 38 | 0.588889 |
85bc0ffc4ef7b9d8e8a8b89cf3304e602a0b24fd
| 387 |
dfm
|
Pascal
|
Delphi/ETS/BootStrap/MainForm/UChild.dfm
|
ets-ddui/ets
|
d90e6f7dc1e72e78e6430d6a0a0174b93cde9dc3
|
[
"MIT"
] | null | null | null |
Delphi/ETS/BootStrap/MainForm/UChild.dfm
|
ets-ddui/ets
|
d90e6f7dc1e72e78e6430d6a0a0174b93cde9dc3
|
[
"MIT"
] | null | null | null |
Delphi/ETS/BootStrap/MainForm/UChild.dfm
|
ets-ddui/ets
|
d90e6f7dc1e72e78e6430d6a0a0174b93cde9dc3
|
[
"MIT"
] | 1 |
2021-11-30T02:52:30.000Z
|
2021-11-30T02:52:30.000Z
|
object FrmChild: TFrmChild
Left = 0
Top = 0
Width = 596
Height = 414
object BlMain: TDUIButtonList
Left = 0
Top = 0
Width = 596
Height = 30
Align = alTop
TextAlign = alClient
OnChanging = BlMainChanging
end
object PnlMain: TDUIPanel
Left = 0
Top = 30
Width = 596
Height = 384
Align = alClient
end
end
| 16.826087 | 32 | 0.573643 |
f1ea6a61c338ad1735b45c91c1cf80b454542002
| 2,582 |
pas
|
Pascal
|
tests/Json/Tests.VirtualDto.JSON.pas
|
sonjli/FidoLib
|
d86c5bdf97e13cd2317ace207a6494da6cfe92f3
|
[
"MIT"
] | null | null | null |
tests/Json/Tests.VirtualDto.JSON.pas
|
sonjli/FidoLib
|
d86c5bdf97e13cd2317ace207a6494da6cfe92f3
|
[
"MIT"
] | null | null | null |
tests/Json/Tests.VirtualDto.JSON.pas
|
sonjli/FidoLib
|
d86c5bdf97e13cd2317ace207a6494da6cfe92f3
|
[
"MIT"
] | null | null | null |
unit Tests.VirtualDTO.JSON;
interface
uses
DUnitX.TestFramework,
System.Json,
System.SysUtils,
System.DateUtils,
System.TypInfo,
Spring,
Spring.Collections,
Fido.Testing.Mock.Utils,
Fido.JSON.Marshalling;
type
TMediaType = (mtLP, mtCassette, mtCD, mtOnline);
ISinger = interface(IInvokable)
['{DC5320BB-1338-4745-B958-8A0BBD74DAB5}']
function Id: Integer;
function Name: string;
end;
IAuthor = interface(IInvokable)
['{2E7D194B-E2F4-4859-9330-8410164B4995}']
function Id: Integer;
function Name: string;
end;
ISong = interface(IInvokable)
['{8B681FE2-3C64-4D58-9DF6-0E9561B17E03}']
function Id: Integer;
function Guid: TGuid;
function Title: string;
function IsGood: Boolean;
function ReleaseDate: Nullable<TDateTime>;
function RetirementDate: Nullable<TDateTime>;
function Price: Currency;
function Author: IAuthor;
function Years: IReadOnlyList<Integer>;
function Singers: IReadOnlyList<ISinger>;
function Media: TMediaType;
end;
[TestFixture]
TVirtualDtoJSONTests = class(TObject)
public
[Test]
procedure TryCreateObjectWorksWithAString;
end;
implementation
{ TVirtualDtoJSONTests }
procedure TVirtualDtoJSONTests.TryCreateObjectWorksWithAString;
var
Json: string;
Song: ISong;
begin
Json := '{"Id":1,"Guid":"F76CD4D4-35E1-4C66-A30A-37C050C0B324","Title":"My Title","IsGood":false,"ReleaseDate":"2021-09-29T22:15:30.579Z","Price":"15.95","Author":{"Id":2,"Name":"Author name"},' +
'"Years":[2001,2002],"Singers":[{"Id":3,"Name":"First singer"},{"Id":4,"Name":"Second singer"}],"Media":2}';
Song := TJSONVirtualDto.Create(TypeInfo(ISong), Json) as ISong;
Assert.AreEqual(1, Song.Id);
Assert.AreEqual(StringToGuid('{F76CD4D4-35E1-4C66-A30A-37C050C0B324}'), Song.Guid);
Assert.AreEqual('My Title', Song.Title);
Assert.AreEqual(False, Song.IsGood);
Assert.AreEqual(ISO8601ToDate('2021-09-29T22:15:30.579Z'), Song.ReleaseDate.Value);
Assert.AreEqual(False, Song.RetirementDate.HasValue);
Assert.AreEqual<Currency>(15.95, Song.Price);
Assert.AreEqual('Author name', song.Author.Name);
Assert.AreEqual(2, song.Author.Id);
Assert.AreEqual(3, song.Singers[0].Id);
Assert.AreEqual('First singer', song.Singers[0].Name);
Assert.AreEqual(4, song.Singers[1].Id);
Assert.AreEqual('Second singer', song.Singers[1].Name);
Assert.AreEqual(2001, song.Years[0]);
Assert.AreEqual(2002, song.Years[1]);
Assert.AreEqual(mtCD, song.Media);
end;
initialization
TDUnitX.RegisterTestFixture(TVirtualDtoJSONTests);
end.
| 27.178947 | 198 | 0.71495 |
f1e13f192d174be39e8439de20a8db862e26803a
| 12,674 |
pas
|
Pascal
|
source/ALAndroidNativeView.pas
|
jonahzheng/alcinoe
|
be21f1d6b9e22aa3d75faed4027097c1f444ee6f
|
[
"Apache-2.0"
] | 1 |
2022-01-26T04:32:57.000Z
|
2022-01-26T04:32:57.000Z
|
source/ALAndroidNativeView.pas
|
jonahzheng/alcinoe
|
be21f1d6b9e22aa3d75faed4027097c1f444ee6f
|
[
"Apache-2.0"
] | null | null | null |
source/ALAndroidNativeView.pas
|
jonahzheng/alcinoe
|
be21f1d6b9e22aa3d75faed4027097c1f444ee6f
|
[
"Apache-2.0"
] | null | null | null |
unit ALAndroidNativeView;
{$IF CompilerVersion > 34} // sydney
{$MESSAGE WARN 'Check if FMX.Presentation.Android.pas was not updated and adjust the IFDEF'}
{$ENDIF}
interface
{$SCOPEDENUMS ON}
uses
System.Classes,
System.Types,
Androidapi.JNI.GraphicsContentViewText,
Androidapi.JNIBridge,
Androidapi.JNI.Widget,
FMX.Types,
FMX.Forms,
FMX.Controls,
FMX.ZOrder.Android;
type
{*************************************}
TALAndroidFocusChangedListener = class;
{**************************}
TALAndroidNativeView = class
private
[Weak] FControl: TControl;
[Weak] FForm: TCommonCustomForm;
FView: JView;
FLayout: JViewGroup;
FSize: TSizeF;
FVisible: Boolean;
FFocusChangedListener: TALAndroidFocusChangedListener;
function GetZOrderManager: TAndroidZOrderManager;
protected
procedure SetSize(const ASize: TSizeF); virtual;
procedure UpdateVisible;
protected
//procedure PMGetNativeObject(var AMessage: TDispatchMessageWithValue<IInterface>); message PM_GET_NATIVE_OBJECT;
procedure SetAbsoluteEnabled(const value: Boolean); //procedure PMSetAbsoluteEnabled(var AMessage: TDispatchMessageWithValue<Boolean>); message PM_SET_ABSOLUTE_ENABLED;
procedure SetVisible(const Value: Boolean); // procedure PMSetVisible(var AMessage: TDispatchMessageWithValue<Boolean>); message PM_SET_VISIBLE;
//procedure PMGetVisible(var AMessage: TDispatchMessageWithValue<Boolean>); message PM_GET_VISIBLE;
procedure SetAlpha(const Value: Single); // procedure PMSetAlpha(var AMessage: TDispatchMessageWithValue<Single>); message PM_SET_ABSOLUTE_OPACITY;
//procedure PMGetAlpha(var AMessage: TDispatchMessageWithValue<Single>); message PM_GET_ABSOLUTE_OPACITY;
//procedure PMSetSize(var AMessage: TDispatchMessageWithValue<TSizeF>); message PM_SET_SIZE;
//procedure PMGetSize(var AMessage: TDispatchMessageWithValue<TSizeF>); message PM_GET_SIZE;
//procedure PMIsFocused(var AMessage: TDispatchMessageWithValue<Boolean>); message PM_IS_FOCUSED;
//procedure PMDoExit(var AMessage: TDispatchMessage); message PM_DO_EXIT;
//procedure PMDoEnter(var AMessage: TDispatchMessage); message PM_DO_ENTER;
//procedure PMResetFocus(var AMessage: TDispatchMessage); message PM_RESET_FOCUS;
procedure SetClipChildren(const Value: Boolean); // procedure PMSetClipChildren(var AMessage: TDispatchMessageWithValue<Boolean>); message PM_SET_CLIP_CHILDREN;
procedure AncestorVisibleChanged; // procedure PMAncestorVisibleChanged(var AMessage: TDispatchMessageWithValue<Boolean>); message PM_ANCESSTOR_VISIBLE_CHANGED;
//procedure PMAncestorPresentationLoaded(var AMessage: TDispatchMessageWithValue<Boolean>); message PM_ANCESTOR_PRESENTATION_LOADED;
//procedure PMAncestorPresentationUnloading(var AMessage: TDispatchMessageWithValue<TFmxObject>); message PM_ANCESTOR_PRESENTATION_UNLOADING;
//procedure PMUnload(var AMessage: TDispatchMessage); message PM_UNLOAD;
//procedure PMRefreshParent(var AMessage: TDispatchMessage); message PM_REFRESH_PARENT;
//procedure PMAbsoluteChanged(var AMessage: TDispatchMessage); message PM_ABSOLUTE_CHANGED;
function PointInObjectLocal(X: Single; Y: Single): Boolean; //procedure PMPointInObject(var AMessage: TDispatchMessageWithValue<TPointInObjectLocalInfo>); message PM_POINT_IN_OBJECT_LOCAL;
procedure ChangeOrder; // PMChangeOrder(var AMessage: TDispatchMessage); message PM_CHANGE_ORDER;
procedure RootChanged(const aRoot: IRoot); // procedure PMRootChanged(var AMessage: TDispatchMessageWithValue<IRoot>); message PM_ROOT_CHANGED;
protected
function GetView<T: JView>: T; overload;
procedure UpdateFrame;
procedure RefreshNativeParent; virtual;
function CreateView: JView; virtual;
function CreateLayout: JViewGroup; virtual;
procedure InitView; virtual;
public
constructor Create; overload; virtual;
constructor Create(const AControl: TControl); overload; virtual;
destructor Destroy; override;
function HasZOrderManager: Boolean;
procedure SetFocus; virtual;
procedure ResetFocus; virtual;
property Form: TCommonCustomForm read FForm;
property ZOrderManager: TAndroidZOrderManager read GetZOrderManager;
public
property Control: TControl read FControl;
property Size: TSizeF read FSize write SetSize;
property Layout: JViewGroup read FLayout;
property View: JView read FView;
property Visible: Boolean read FVisible;
end;
TALAndroidNativeViewClass = class of TALAndroidNativeView;
{********************************************}
TALAndroidBaseViewListener = class(TJavaLocal)
private
[Weak] FView: TALAndroidNativeView;
public
constructor Create(const AView: TALAndroidNativeView);
property View: TALAndroidNativeView read FView;
end;
{*********************************************************************************************}
TALAndroidFocusChangedListener = class(TALAndroidBaseViewListener, JView_OnFocusChangeListener)
public
procedure onFocusChange(view: JView; hasFocus: Boolean); cdecl;
end;
var
{********************************}
ALVirtualKeyboardVisible: Boolean;
implementation
uses
System.SysUtils,
Androidapi.Helpers,
Androidapi.JNI.App,
FMX.Platform,
FMX.Platform.Android,
FMX.Consts,
ALString,
ALCommon;
{****************************************************************}
constructor TALAndroidNativeView.Create(const AControl: TControl);
begin
FControl := AControl;
Create;
RefreshNativeParent;
end;
{*****************************************************}
function TALAndroidNativeView.CreateLayout: JViewGroup;
begin
Result := TJRelativeLayout.JavaClass.init(TAndroidHelper.Context)
end;
{**********************************************}
function TALAndroidNativeView.CreateView: JView;
begin
Result := TJView.JavaClass.init(TAndroidHelper.Activity);
end;
{**************************************}
constructor TALAndroidNativeView.Create;
var LayoutParams: JRelativeLayout_LayoutParams;
begin
inherited;
FLayout := CreateLayout;
FView := CreateView;
FView.setClipToOutline(False);
FFocusChangedListener := TALAndroidFocusChangedListener.Create(Self);
View.setOnFocusChangeListener(FFocusChangedListener);
{ Tree view structure }
LayoutParams := TJRelativeLayout_LayoutParams.JavaClass.init(TJViewGroup_LayoutParams.JavaClass.MATCH_PARENT, TJViewGroup_LayoutParams.JavaClass.MATCH_PARENT);
FLayout.addView(FView, LayoutParams);
InitView;
FVisible := True;
end;
{**************************************}
destructor TALAndroidNativeView.Destroy;
begin
if HasZOrderManager then ZOrderManager.RemoveLink(Control);
View.setOnFocusChangeListener(nil); // << https://quality.embarcadero.com/browse/RSP-24666
ALFreeAndNil(FFocusChangedListener);
inherited;
end;
{******************************************}
function TALAndroidNativeView.GetView<T>: T;
begin
Result := T(FView);
end;
{********************************************************************}
function TALAndroidNativeView.GetZOrderManager: TAndroidZOrderManager;
begin
if Form <> nil then Result := WindowHandleToPlatform(Form.Handle).ZOrderManager
else Result := nil;
end;
{******************************************************}
function TALAndroidNativeView.HasZOrderManager: Boolean;
begin
Result := (Form <> nil) and (Form.Handle <> nil);
end;
{**************************************}
procedure TALAndroidNativeView.InitView;
begin
end;
{****************************************************}
procedure TALAndroidNativeView.AncestorVisibleChanged;
begin
UpdateVisible;
end;
{*****************************************}
procedure TALAndroidNativeView.ChangeOrder;
begin
if ZOrderManager <> nil then
ZOrderManager.UpdateOrder(Control);
end;
{******************************************************************************}
function TALAndroidNativeView.PointInObjectLocal(X: Single; Y: Single): Boolean;
var HitTestPoint: TPointF;
begin
HitTestPoint := TPointF.Create(x,y);
Result := Control.LocalRect.Contains(HitTestPoint);
end;
{*************************************************************}
procedure TALAndroidNativeView.RootChanged(const aRoot: IRoot);
begin
// Changing root for native control means changing ZOrderManager, because one form owns ZOrderManager.
// So we need to remove itself from old one and add to new one.
if HasZOrderManager then ZOrderManager.RemoveLink(Control);
if aRoot is TCommonCustomForm then FForm := TCommonCustomForm(aRoot)
else FForm := nil;
if HasZOrderManager then ZOrderManager.AddOrSetLink(Control, Layout, nil);
RefreshNativeParent;
end;
{**********************************************************************}
procedure TALAndroidNativeView.SetAbsoluteEnabled(const value: Boolean);
begin
FView.setEnabled(value);
end;
{***********************************************************}
procedure TALAndroidNativeView.SetAlpha(const Value: Single);
begin
FView.setAlpha(Value);
end;
{*******************************************************************}
procedure TALAndroidNativeView.SetClipChildren(const Value: Boolean);
begin
FLayout.setClipToPadding(Value);
FLayout.setClipToOutline(Value);
FLayout.setClipChildren(Value);
end;
{**************************************************************}
procedure TALAndroidNativeView.SetVisible(const Value: Boolean);
begin
FVisible := Value;
UpdateVisible;
end;
{*************************************************}
procedure TALAndroidNativeView.RefreshNativeParent;
begin
if HasZOrderManager then
ZOrderManager.UpdateOrderAndBounds(Control);
end;
{****************************************}
procedure TALAndroidNativeView.ResetFocus;
begin
FView.clearFocus;
end;
{**************************************}
procedure TALAndroidNativeView.SetFocus;
begin
FView.requestFocus;
end;
{**********************************************************}
procedure TALAndroidNativeView.SetSize(const ASize: TSizeF);
begin
FSize := ASize;
UpdateFrame;
end;
{*****************************************}
procedure TALAndroidNativeView.UpdateFrame;
begin
if ZOrderManager <> nil then
// UpdateBounds instead of UpdateOrderAndBounds because else everytime
// we will move the edit we will loose the focus and this is problematic
// if we for exemple move the edit from the bottom to the top to let some
// place to show the virtual keyboard
ZOrderManager.UpdateBounds(Control);
end;
{*******************************************}
procedure TALAndroidNativeView.UpdateVisible;
begin
if not Visible or not Control.ParentedVisible then Layout.setVisibility(TJView.JavaClass.GONE)
else if ZOrderManager = nil then Layout.setVisibility(TJView.JavaClass.VISIBLE)
else ZOrderManager.UpdateOrderAndBounds(Control);
end;
{*******************************************************************************}
constructor TALAndroidBaseViewListener.Create(const AView: TALAndroidNativeView);
begin
if AView = nil then
raise EArgumentNilException.CreateFmt(SWrongParameter, ['AView']);
inherited Create;
FView := AView;
end;
{*************************************************************************************}
procedure TALAndroidFocusChangedListener.onFocusChange(view: JView; hasFocus: Boolean);
begin
{$IF defined(DEBUG)}
ALLog('TALAndroidFocusChangedListener.onFocusChange', 'control.parent.name: ' + self.view.Control.parent.Name + // control is TALAndroidEdit and Control.parent is TalEdit
' - hasFocus: ' + ALBoolToStrU(hasFocus) +
' - control.IsFocused: ' + ALBoolToStrU(self.View.Control.IsFocused) +
' - ThreadID: ' + alIntToStrU(TThread.Current.ThreadID) + '/' + alIntToStrU(MainThreadID), TalLogType.VERBOSE);
{$ENDIF}
// Since view can get focus without us, we synchronize native focus and fmx focus. For example, when user makes a tap
// on Input control, control request focus itself and we can get the situation with two focused controls native and
// styled Edit.
if hasFocus and not self.View.Control.IsFocused then self.View.Control.SetFocus
else if not hasFocus and self.View.Control.IsFocused then self.View.Control.ResetFocus;
end;
end.
| 38.174699 | 193 | 0.655121 |
83f655371c011cf079c1b76605a64b010ce22a67
| 12,714 |
pas
|
Pascal
|
better_collections.pas
|
adaloveless/commonx
|
ed37b239e925119c7ceb3ac7949eefb0259c7f77
|
[
"MIT"
] | 48 |
2018-11-19T22:13:00.000Z
|
2021-11-02T17:25:41.000Z
|
better_collections.pas
|
adaloveless/commonx
|
ed37b239e925119c7ceb3ac7949eefb0259c7f77
|
[
"MIT"
] | 6 |
2018-11-24T17:15:29.000Z
|
2019-05-15T14:59:56.000Z
|
better_collections.pas
|
adaloveless/commonx
|
ed37b239e925119c7ceb3ac7949eefb0259c7f77
|
[
"MIT"
] | 12 |
2018-11-20T15:15:44.000Z
|
2021-09-14T10:12:43.000Z
|
unit better_collections;
{$MESSAGE '*******************COMPILING Better_Collections.pas'}
{$INCLUDE DelphiDefs.inc}
{$IFDEF MSWINDOWS}
{$DEFINE USE_FAST_LIST}
{$ENDIF}
{$DEFINE DEBUG_ITEMS}
{$D-}
interface
uses
debug, generics.collections.fixed, systemx, sharedobject, typex, betterobject, classes,
{$IFDEF USE_FAST_LIST}
fastlist,
{$ENDIF}
sysutils;
type
{$IFDEF USE_FAST_LIST}
TBetterList<T: class> = class(TFastList<T>)
{$ELSE}
TBetterList<T: class> = class(TList<T>)
{$ENDIF}
private
function GetLast: T;
public
constructor Create;
function Has(obj: T): boolean;
procedure ClearandFree;
procedure Replace(old, nu: T);
procedure BetterRemove(obj: T);
procedure AddList(list: TBetterList<T>);
property Last: T read GetLast;
end;
TBetterStack<T: class> = class(TStack<T>)
private
function GetTop: T;
public
property Top: T read GetTop;
end;
TSharedList<T: class> = class(TSharedObject)
private
FOwnsObjects: boolean;
function GEtItem(idx: nativeint): T;
procedure SetItem(idx: nativeint; const Value: T);
protected
FList: TBetterList<T>;
FVolatileCount: ni;
function GetCount: nativeint;virtual;
public
RestrictedtoThreadID: int64;
constructor Create;override;
destructor Destroy;override;
function Add(obj: T): nativeint;virtual;
procedure AddList(l: TSharedList<T>);virtual;
procedure Delete(idx: nativeint);virtual;
procedure Remove(obj: T);virtual;
procedure BetterRemove(obj: T);
procedure Insert(idx: ni; obj: T);virtual;
property Count: nativeint read GetCount;
function IndexOf(obj: T): nativeint;virtual;
function Has(obj: T): boolean;virtual;
property Items[idx: nativeint]: T read GEtItem write SetItem;default;
procedure Clear;
procedure FreeAndClear;
property VOlatileCount: ni read FVolatileCount;
property OwnsObjects: boolean read FOwnsObjects write FOwnsObjects;
end;
TSharedStringList = class(TSharedObject)
strict private
FList: TStringList;
private
function GetItem(idx: ni): string;
procedure Setitem(idx: ni; const Value: string);
function GetText: string;
procedure SetText(const Value: string);
public
property Text: string read GetText write SetText;
procedure Add(s: string);
procedure Remove(s: string);
property Items[idx: ni]: string read GetItem write Setitem;default;
procedure Delete(i: ni);
function IndexOf(s: string): ni;
end;
TStringObjectList<T_OBJECTTYPE: class> = class(TBetterObject)
strict private
FItems: TStringlist;
private
FTakeOwnership: boolean;
FDuplicates: TDuplicates;
function GetItem(sKey: string): T_OBJECTTYPE;
procedure SetItem(sKey: string; const Value: T_OBJECTTYPE);
function GetKey(idx: ni): string;
function GetItemByIndex(idx: ni): T_ObjectType;
public
enable_debug: boolean;
procedure Add(sKey: string; obj: T_OBJECTTYPE);
procedure Clear;
procedure Delete(i: ni);
procedure Remove(o: T_OBJECTTYPE);
function IndexOfKey(sKey: string): ni;
function IndexOfObject(o: T_OBJECTTYPE): ni;
function Count: ni;
procedure Init; override;
constructor Create; override;
destructor Destroy; override;
property Items[sKey: string]: T_OBJECTTYPE read GetItem write SetItem;default;
property ItemsByIndex[idx: ni]: T_ObjectType read GetItemByIndex;
property Keys[idx: ni]: string read GetKey;
property TakeOwnership: boolean read FTakeOwnership write FTakeOwnership;
property Duplicates: TDuplicates read FDuplicates write FDuplicates;
procedure DebugItems;
end;
implementation
{$IFDEF DEBUG_ITEMS}
uses
JSONHelpers;
{$ENDIF}
{ TBetterList<T> }
procedure TBetterList<T>.AddList(list: TBetterList<T>);
var
t: ni;
begin
for t := 0 to list.count-1 do begin
self.Add(list[t]);
end;
end;
procedure TBetterList<T>.BetterRemove(obj: T);
var
t: ni;
begin
for t:= count-1 downto 0 do begin
if items[t] = obj then
delete(t);
end;
end;
procedure TBetterList<T>.ClearandFree;
var
o: T;
begin
while count > 0 do begin
o := items[0];
remove(items[0]);
o.free;
o := nil;
end;
end;
constructor TBetterList<T>.Create;
begin
inherited;
end;
function TBetterList<T>.GetLast: T;
begin
result := self[self.count-1];
end;
function TBetterList<T>.Has(obj: T): boolean;
begin
result := IndexOf(obj) >= 0;
end;
procedure TBetterList<T>.Replace(old, nu: T);
var
t: ni;
begin
for t:= 0 to count-1 do begin
if Self.Items[t] = old then
self.items[t] := nu;
end;
end;
{ TSharedList<T> }
{$MESSAGE '*******************1 COMPILING Better_Collections.pas'}
function TSharedList<T>.Add(obj: T): nativeint;
begin
if (RestrictedtoThreadID <> 0) and (TThread.CurrentThread.ThreadID <> RestrictedToThreadID) then
{$IFDEF STRICT_THREAD_ENFORCEMENT}
raise Ecritical.create(self.ClassName+' is restricted to thread #'+RestrictedToThreadID.ToString+' but you are accessing it from #'+TThread.CurrentThread.ThreadID.tostring);
{$ELSE}
Debug.Log(CLR_ERR+self.ClassName+' is restricted to thread #'+RestrictedToThreadID.ToString+' but you are accessing it from #'+TThread.CurrentThread.ThreadID.tostring);
{$ENDIF}
Lock;
try
result := FList.add(obj);
FVolatileCount := FList.count;
finally
Unlock;
end;
end;
{$MESSAGE '*******************2 COMPILING Better_Collections.pas'}
procedure TSharedList<T>.AddList(l: TSharedList<T>);
var
x: nativeint;
begin
if (RestrictedtoThreadID <> 0) and (TThread.CurrentThread.ThreadID <> RestrictedToThreadID) then
raise Ecritical.create(self.ClassName+' is restricted to thread #'+RestrictedToThreadID.ToString+' but you are accessing it from #'+TThread.CurrentThread.ThreadID.tostring);
l.Lock;
try
Lock;
try
for x := 0 to l.count-1 do begin
self.Add(l[x]);
end;
finally
Unlock;
end;
finally
l.Unlock;
end;
end;
{$MESSAGE '*******************3 COMPILING Better_Collections.pas'}
procedure TSharedList<T>.BetterRemove(obj: T);
begin
Remove(obj);
end;
{$MESSAGE '*******************4 COMPILING Better_Collections.pas'}
procedure TSharedList<T>.Clear;
begin
Lock;
try
FList.Clear;
FVolatileCount := FList.count;
finally
Unlock;
end;
end;
{$MESSAGE '*******************5 COMPILING Better_Collections.pas'}
constructor TSharedList<T>.Create;
{$MESSAGE '*******************5.1 COMPILING Better_Collections.pas'}
begin
{$MESSAGE '*******************5.2 COMPILING Better_Collections.pas'}
inherited;
{$MESSAGE '*******************5.3 COMPILING Better_Collections.pas'}
FList := TBetterList<T>.create();
{$MESSAGE '*******************5.4 COMPILING Better_Collections.pas'}
end;
{$MESSAGE '*******************5 COMPILING Better_Collections.pas'}
{$MESSAGE '*******************6 COMPILING Better_Collections.pas'}
procedure TSharedList<T>.Delete(idx: nativeint);
begin
Lock;
try
FList.Delete(idx);
FVolatileCount := FList.count;
finally
Unlock;
end;
end;
{$MESSAGE '*******************7 COMPILING Better_Collections.pas'}
destructor TSharedList<T>.Destroy;
begin
if OwnsObjects then begin
while FList.count > 0 do begin
FList[FList.count].free;
FList.delete(FList.count);
end;
end;
FList.free;
FList := nil;
inherited;
end;
procedure TSharedList<T>.FreeAndClear;
begin
while count > 0 do begin
items[count-1].free;
delete(count-1);
end;
end;
{$MESSAGE '*******************8 COMPILING Better_Collections.pas'}
function TSharedList<T>.GetCount: nativeint;
begin
Lock;
try
result := FList.count;
finally
Unlock;
end;
end;
{$MESSAGE '*******************9 COMPILING Better_Collections.pas'}
function TSharedList<T>.GEtItem(idx: nativeint): T;
begin
lock;
try
result := FList[idx];
finally
Unlock;
end;
end;
function TSharedList<T>.Has(obj: T): boolean;
begin
result := IndexOf(obj) >=0;
end;
{$MESSAGE '*******************10 COMPILING Better_Collections.pas'}
function TSharedList<T>.IndexOf(obj: T): nativeint;
begin
Lock;
try
result := FList.IndexOf(obj);
finally
Unlock;
end;
end;
{$MESSAGE '*******************11 COMPILING Better_Collections.pas'}
procedure TSharedList<T>.Insert(idx: ni; obj: T);
begin
Lock;
try
FList.Insert(idx, obj);
FVolatileCount := FList.count;
finally
unlock;
end;
end;
{$MESSAGE '*******************12 COMPILING Better_Collections.pas'}
procedure TSharedList<T>.Remove(obj: T);
begin
Lock;
try
FList.BetterRemove(obj);
FVolatileCount := FList.count;
finally
Unlock;
end;
end;
{$MESSAGE '*******************13 COMPILING Better_Collections.pas'}
procedure TSharedList<T>.SetItem(idx: nativeint; const Value: T);
begin
lock;
try
FLIst[idx] := value;
finally
Unlock;
end;
end;
{ TBetterStack<T> }
function TBetterStack<T>.GetTop: T;
begin
result := Peek;
end;
{ TStringObjectList<T_OBJECTTYPE> }
procedure TStringObjectList<T_OBJECTTYPE>.Add(sKey: string; obj: T_OBJECTTYPE);
begin
case duplicates of
Tduplicates.dupIgnore: begin
if FItems.IndexOf(sKey) >=0 then begin
self[sKey] := obj;
exit;
end;
end;
Tduplicates.dupError: begin
raise ECritical.create(classname+' already has item with key '+sKey);
end;
end;
FItems.AddObject(sKey, obj);
DebugItems();
end;
procedure TStringObjectList<T_OBJECTTYPE>.Clear;
begin
if takeownership then begin
while count > 0 do begin
delete(count-1);
end;
end;
FItems.Clear;
end;
function TStringObjectList<T_OBJECTTYPE>.Count: ni;
begin
result := FItems.count;
end;
constructor TStringObjectList<T_OBJECTTYPE>.Create;
begin
inherited;
FItems := TStringList.create;
Fitems.CaseSensitive := true;
end;
procedure TStringObjectList<T_OBJECTTYPE>.DebugItems;
var
t: ni;
begin
{$IFDEF DEBUG_ITEMS}
if not enable_debug then
exit;
Debug.Log('----------------');
for t:= 0 to FItems.count-1 do begin
if FItems.Objects[t] is TJSON then begin
Debug.Log(FItems[t]+' = '+TJSON(FItems.Objects[t]).tojson);
end;
end;
{$ENDIF}
end;
procedure TStringObjectList<T_OBJECTTYPE>.Delete(i: ni);
begin
if takeownership then
FItems.objects[i].free;
FItems.Delete(i);
end;
destructor TStringObjectList<T_OBJECTTYPE>.Destroy;
begin
Clear;
FItems.free;
FItems := nil;
inherited;
end;
function TStringObjectList<T_OBJECTTYPE>.GetItem(sKey: string): T_OBJECTTYPE;
var
i: ni;
begin
i := IndexofKey(sKey);
result := nil;
if i >=0 then
result := T_OBJECTTYPE(FItems.Objects[i])
else
raise ECritical.create('no object named '+sKey+' was found in '+self.ClassName);
end;
function TStringObjectList<T_OBJECTTYPE>.GetItemByIndex(idx: ni): T_ObjectType;
begin
result := T_OBJECTTYPE(FItems.Objects[idx]);
end;
function TStringObjectList<T_OBJECTTYPE>.GetKey(idx: ni): string;
begin
result := FItems[idx];
end;
function TStringObjectList<T_OBJECTTYPE>.IndexOfKey(sKey: string): ni;
begin
result := FItems.IndexOf(sKey);
end;
function TStringObjectList<T_OBJECTTYPE>.IndexOfObject(o: T_OBJECTTYPE): ni;
begin
result := FItems.IndexOfObject(o);
end;
procedure TStringObjectList<T_OBJECTTYPE>.Init;
begin
inherited;
end;
procedure TStringObjectList<T_OBJECTTYPE>.Remove(o: T_OBJECTTYPE);
var
i: ni;
begin
i := FItems.IndexOfObject(o);
if i >=0 then begin
Delete(i);
end;
end;
procedure TStringObjectList<T_OBJECTTYPE>.SetItem(sKey: string;
const Value: T_OBJECTTYPE);
var
i: ni;
begin
i := Fitems.IndexOf(sKey);
if i >= 0 then
FItems.Objects[i] := value;
end;
{ TSharedStringList }
procedure TSharedStringList.Add(s: string);
var
l : ILock;
begin
l := self.LockI;
FList.add(s);
end;
procedure TSharedStringList.Delete(i: ni);
var
l: ILock;
begin
l := self.LockI;
FList.delete(i);
end;
function TSharedStringList.GetItem(idx: ni): string;
var
l: ILock;
begin
l := self.LockI;
result := FList[idx];
end;
function TSharedStringList.GetText: string;
var
l: ILock;
begin
l := self.LockI;
result := Flist.Text;
end;
function TSharedStringList.IndexOf(s: string): ni;
var
l: ILock;
begin
l := self.LockI;
result := Flist.IndexOf(s);
end;
procedure TSharedStringList.Remove(s: string);
var
l: ILock;
i: ni;
begin
l := self.LockI;
i := FList.IndexOf(s);
if i>=0 then
FList.delete(i);
end;
procedure TSharedStringList.Setitem(idx: ni; const Value: string);
var
l: ILock;
begin
l := self.LockI;
Flist[idx] := value;
end;
procedure TSharedStringList.SetText(const Value: string);
var
l: ILock;
begin
l := self.LockI;
Flist.Text := value;
end;
end.
| 20.74062 | 177 | 0.682161 |
85dceee66fb888e5a2e0176ea47d653e52969e8b
| 239 |
pas
|
Pascal
|
ProjectBuilder/Properties/Settings.Designer.pas
|
ProHolz/ElementsDelphiTools
|
dca0c4d6171428ea2671ace6d3bc5f68e6f147af
|
[
"MIT"
] | 5 |
2019-02-21T14:07:28.000Z
|
2021-04-21T18:59:59.000Z
|
ProjectBuilder/Properties/Settings.Designer.pas
|
ProHolz/ElementsDelphiTools
|
dca0c4d6171428ea2671ace6d3bc5f68e6f147af
|
[
"MIT"
] | 1 |
2019-03-04T12:27:59.000Z
|
2019-03-04T12:27:59.000Z
|
ProjectBuilder/Properties/Settings.Designer.pas
|
ProHolz/ElementsDelphiTools
|
dca0c4d6171428ea2671ace6d3bc5f68e6f147af
|
[
"MIT"
] | 4 |
2019-09-07T12:48:54.000Z
|
2021-04-23T13:34:34.000Z
|
namespace ProjectBuilder;
interface
{ The .Designer.pas file will be automatically generated when the parent file changes.
You can also right-click the parent file and select 'Run Custom Tool' to update it now. }
implementation
end.
| 23.9 | 91 | 0.782427 |
f1daaa5ae11ce465df3c9a45c11008b43511ba7d
| 1,458 |
dpr
|
Pascal
|
windows/src/ext/jedi/jcl/jcl/packages/d19/JclSIMDViewExpertDLL.dpr
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 219 |
2017-06-21T03:37:03.000Z
|
2022-03-27T12:09:28.000Z
|
windows/src/ext/jedi/jcl/jcl/packages/d19/JclSIMDViewExpertDLL.dpr
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 4,451 |
2017-05-29T02:52:06.000Z
|
2022-03-31T23:53:23.000Z
|
windows/src/ext/jedi/jcl/jcl/packages/d19/JclSIMDViewExpertDLL.dpr
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 72 |
2017-05-26T04:08:37.000Z
|
2022-03-03T10:26:20.000Z
|
Library JclSIMDViewExpertDLL;
{
-----------------------------------------------------------------------------
DO NOT EDIT THIS FILE, IT IS GENERATED BY THE PACKAGE GENERATOR
ALWAYS EDIT THE RELATED XML FILE (JclSIMDViewExpertDLL-L.xml)
Last generated: 01-09-2015 20:38:08 UTC
-----------------------------------------------------------------------------
}
{$R *.res}
{$ALIGN 8}
{$ASSERTIONS ON}
{$BOOLEVAL OFF}
{$DEBUGINFO OFF}
{$EXTENDEDSYNTAX ON}
{$IMPORTEDDATA ON}
{$IOCHECKS ON}
{$LOCALSYMBOLS OFF}
{$LONGSTRINGS ON}
{$OPENSTRINGS ON}
{$OPTIMIZATION ON}
{$OVERFLOWCHECKS OFF}
{$RANGECHECKS OFF}
{$REFERENCEINFO OFF}
{$SAFEDIVIDE OFF}
{$STACKFRAMES OFF}
{$TYPEDADDRESS OFF}
{$VARSTRINGCHECKS ON}
{$WRITEABLECONST ON}
{$MINENUMSIZE 1}
{$IMAGEBASE $58080000}
{$DESCRIPTION 'JCL Debug Window of XMM registers'}
{$LIBSUFFIX '190'}
{$IMPLICITBUILD OFF}
{$DEFINE BCB}
{$DEFINE WIN32}
{$DEFINE CONDITIONALEXPRESSIONS}
{$DEFINE VER260}
{$DEFINE RELEASE}
uses
ToolsAPI,
JclSIMDViewForm in '..\..\experts\debug\simdview\JclSIMDViewForm.pas' {JclSIMDViewFrm},
JclSIMDView in '..\..\experts\debug\simdview\JclSIMDView.pas' ,
JclSIMDUtils in '..\..\experts\debug\simdview\JclSIMDUtils.pas' ,
JclSIMDModifyForm in '..\..\experts\debug\simdview\JclSIMDModifyForm.pas' {JclSIMDModifyFrm},
JclSIMDCpuInfo in '..\..\experts\debug\simdview\JclSIMDCpuInfo.pas' {JclFormCpuInfo}
;
exports
JCLWizardInit name WizardEntryPoint;
end.
| 26.035714 | 95 | 0.652949 |
6abe959bcc22a7559b21a2defcd9f3bcce6c5d95
| 3,134 |
pas
|
Pascal
|
delphi/0449.pas
|
nickelsworth/swag
|
7c21c0da2291fc249b9dc5cfe121a7672a4ffc08
|
[
"BSD-2-Clause"
] | 11 |
2015-12-12T05:13:15.000Z
|
2020-10-14T13:32:08.000Z
|
delphi/0449.pas
|
nickelsworth/swag
|
7c21c0da2291fc249b9dc5cfe121a7672a4ffc08
|
[
"BSD-2-Clause"
] | null | null | null |
delphi/0449.pas
|
nickelsworth/swag
|
7c21c0da2291fc249b9dc5cfe121a7672a4ffc08
|
[
"BSD-2-Clause"
] | 8 |
2017-05-05T05:24:01.000Z
|
2021-07-03T20:30:09.000Z
|
'Joe C. Hecht' <jhecht@wpo.borland.com>
Below are some code snippets to change the printer settings.
Wherever the changes are made, you could instead examine the printer
settings. See the documentation for ExtDeviceMode and the TDEVMODE
structure as well the printer escape GETSETPAPERBINS and GetDeviceCaps().
*********************************************
One way to change printer settings at the start of a print job is to
change the printers devicemode.
Example:
--------------------------------------------------------------------------------
var
Device : array[0..255] of char;
Driver : array[0..255] of char;
Port : array[0..255] of char;
hDMode : THandle;
PDMode : PDEVMODE;
begin
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(Device, Driver, Port, hDMode);
if hDMode <> 0 then begin
pDMode := GlobalLock(hDMode);
if pDMode <> nil then begin
pDMode^.dmFields := pDMode^.dmFields or DM_COPIES;
pDMode^.dmCopies := 5;
GlobalUnlock(hDMode);
end;
GlobalFree(hDMode);
end;
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.BeginDoc;
Printer.Canvas.TextOut(100,100, 'Test 1');
Printer.EndDoc;
--------------------------------------------------------------------------------
Another way is to change TPrinter. This will enable you to change
settings in mid job. You must make the change >>>between<<< pages.
To do this:
Before every startpage() command in printers.pas in the Source\VCL
directory add something like:
--------------------------------------------------------------------------------
DevMode.dmPaperSize:=DMPAPER_LEGAL
{any other devicemode settings go here}
Windows.ResetDc(dc,Devmode^);
--------------------------------------------------------------------------------
This will reset the pagesize. you can look up DEVMODE in the help to
find other paper sizes.
You will need to rebuild the vcl source for this to work, by adding the
path to the VCL source directory to the beginning of the library
path s tatement under tools..options.. library...libaray path.
Quit Delphi then do a build all.
Another quick note...
When changing printers, be aware that fontsizes may not always scale
properly. To ensure proper scaling set the PixelsPerInch property of
the font.
Here are two examples:
--------------------------------------------------------------------------------
uses Printers;
var
MyFile: TextFile;
begin
AssignPrn(MyFile);
Rewrite(MyFile);
Printer.Canvas.Font.Name := 'Courier New';
Printer.Canvas.Font.Style := [fsBold];
Printer.Canvas.Font.PixelsPerInch:=
GetDeviceCaps(Printer.Canvas.Handle, LOGPIXELSY);
Writeln(MyFile, 'Print this text');
System.CloseFile(MyFile);
end;
uses Printers;
begin
Printer.BeginDoc;
Printer.Canvas.Font.Name := 'Courier New';
Printer.Canvas.Font.Style := [fsBold];
Printer.Canvas.Font.PixelsPerInch:=
GetDeviceCaps(Printer.Canvas.Handle, LOGPIXELSY);
Printer.Canvas.Textout(10, 10, 'Print this text');
Printer.EndDoc;
end;
| 28.234234 | 81 | 0.609445 |
f1df7d7e60c61c9e3c0bb5300aa0543e9fdca3e3
| 1,956 |
dfm
|
Pascal
|
Components/JVCL/examples/JvTranslator/JvTranslatorMainFormU.dfm
|
sabatex/Delphi
|
0efbe6eb38bf8aa2bf269d1866741266e90b9cbf
|
[
"MIT"
] | null | null | null |
Components/JVCL/examples/JvTranslator/JvTranslatorMainFormU.dfm
|
sabatex/Delphi
|
0efbe6eb38bf8aa2bf269d1866741266e90b9cbf
|
[
"MIT"
] | null | null | null |
Components/JVCL/examples/JvTranslator/JvTranslatorMainFormU.dfm
|
sabatex/Delphi
|
0efbe6eb38bf8aa2bf269d1866741266e90b9cbf
|
[
"MIT"
] | 1 |
2019-12-24T08:39:18.000Z
|
2019-12-24T08:39:18.000Z
|
object JvTranslatorMainForm: TJvTranslatorMainForm
Left = 368
Top = 147
Width = 449
Height = 403
Caption = 'JvTranslator'
Color = clBtnFace
Constraints.MinHeight = 230
Constraints.MinWidth = 345
DefaultMonitor = dmDesktop
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
Position = poDesktopCenter
Scaled = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 142
Top = 20
Width = 51
Height = 13
Caption = 'Some Text'
end
object TreeView1: TTreeView
Left = 8
Top = 16
Width = 123
Height = 341
Anchors = [akLeft, akTop, akBottom]
Indent = 19
TabOrder = 0
Items.Data = {
030000001E0000000000000000000000FFFFFFFFFFFFFFFF0000000000000000
054974656D311E0000000000000000000000FFFFFFFFFFFFFFFF000000000000
0000054974656D321E0000000000000000000000FFFFFFFFFFFFFFFF00000000
00000000054974656D33}
end
object CheckBox1: TCheckBox
Left = 140
Top = 40
Width = 97
Height = 17
Caption = 'Again some text'
TabOrder = 1
end
object Button1: TButton
Left = 355
Top = 301
Width = 75
Height = 25
Anchors = [akRight, akBottom]
Caption = 'French'
TabOrder = 2
OnClick = Button1Click
end
object Button2: TButton
Left = 355
Top = 331
Width = 75
Height = 25
Anchors = [akRight, akBottom]
Caption = 'English'
TabOrder = 3
OnClick = Button2Click
end
object Button3: TButton
Left = 140
Top = 70
Width = 75
Height = 25
Caption = 'Push me'
TabOrder = 4
OnClick = Button3Click
end
object JvTranslator1: TJvTranslator
Left = 232
Top = 8
end
object Variables: TJvTranslatorStrings
Left = 296
Top = 8
end
object JvTranslator2: TJvTranslator
Left = 264
Top = 8
end
end
| 21.032258 | 70 | 0.66002 |
8574cef35e868fe38b68bc792d83cfd2a3f70c36
| 601 |
pas
|
Pascal
|
base/vr_base.pas
|
vrode0x/fp_laz
|
82cbb391ed06a72a72fa260767f7732bc609f322
|
[
"MIT"
] | null | null | null |
base/vr_base.pas
|
vrode0x/fp_laz
|
82cbb391ed06a72a72fa260767f7732bc609f322
|
[
"MIT"
] | null | null | null |
base/vr_base.pas
|
vrode0x/fp_laz
|
82cbb391ed06a72a72fa260767f7732bc609f322
|
[
"MIT"
] | null | null | null |
{ This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install the package.
}
unit vr_base;
{$warn 5023 off : no warning about unused units}
interface
uses
vr_classes, vr_ctrl_utils, vr_fpclasses, vr_fpg, vr_globals, vr_intfs,
vr_json_conf, vr_JsonRpc, vr_JsonRpcClasses, vr_JsonUtils, vr_process,
vr_promise, vr_SysUtils, vr_timer, vr_transport, vr_types, vr_utils,
vr_variant, vr_WideStrings, vr_WinAPI, vr_xml_utils, vr_zipper,
wb_mobile_app, windows_compat, vr_app_utils, fp_laz_version;
implementation
end.
| 30.05 | 74 | 0.763727 |
83d5fede4495a2869e7419787ab29dfe854fc1d7
| 7,516 |
pas
|
Pascal
|
MyJobThreadSafeManager.pas
|
mickyvac/fc-measure
|
0b6db36af01f25479a956138cfceddd02a88d14d
|
[
"MIT"
] | null | null | null |
MyJobThreadSafeManager.pas
|
mickyvac/fc-measure
|
0b6db36af01f25479a956138cfceddd02a88d14d
|
[
"MIT"
] | null | null | null |
MyJobThreadSafeManager.pas
|
mickyvac/fc-measure
|
0b6db36af01f25479a956138cfceddd02a88d14d
|
[
"MIT"
] | null | null | null |
unit MyJobThreadSafeManager;
{ shold provide thread safe, milisecond resoluted scheduler with more clever handling than standard timer }
{ timed event object contains reference to procedure which to call, it is executed using synchornize by default
or thread internal-thread-safe handler should be provided
implemented is double direction linked list of record-objects}
interface
uses
Classes, SysUtils, StdCtrls, Dialogs, DateUtils, SyncObjs,
Myutils, MyParseUtils, Logger, ConfigManager,
MyThreadUtils, loggerThreadsafe, ExtCtrls;
Const
CMaxTimeEvents = 10000;
type
TJobType = ( CJDirectCmdStr );
TJobResult = ( CJNotProcessed, CJOK, CJError, CJNotHandled);
TJobThreadSafe = class; //forward declaration
TJobNotifyMethod = procedure ( job: TJobThreadSafe ) of object;
TGeneralNotifyMethod = procedure ( ptr: Pointer ) of object; //ptr to payload object - the function has to convert the argument to necessary object type
TJobThreadSafe = class (TMyLockableObject)
public
constructor Create( jobtype: TJobType; OnDoneThreadSafe: TJobNotifyMethod; OnDoneInMainThread: TGeneralNotifyMethod );
destructor Destroy; override;
destructor SmartDestroy;
public
procedure FinishJob; //call after assigning a result (in descendant) and all manipulation - marks as finished and calls OnDone Methods
//procedure OnDoneInMainThread; //must be executed in context of main thread
private
fType: TJobType;
fOnDoneThreadSafe: TJobNotifyMethod;
//fOnDoneUsingSynchronize: TJobNotifyMethod; //synchronize
fOnDoneInMainThread: TGeneralNotifyMethod;
fFinished: boolean;
fResultCode: TJobResult;
private
function fIsFinished(): boolean;
function getResultCode(): TJobResult;
procedure setResultCode (jr: TJobResult);
public
property IsFinsihed: boolean read fIsFinished;
property ResultCode: TJobResult read getResultCode write setResultCode;
end;
TJobDirectCommand = class (TJobThreadSafe)
public
constructor Create(OnDoneThreadSafe: TJobNotifyMethod; OnDoneInMainThread: TGeneralNotifyMethod);
destructor Destroy; override;
public
Cmd: string;
Reply: string;
elapsedMS: longword;
ReplyHandler: TLogProcedureThreadSafe;
end;
//------------
TJobRec = class (TObject)
public
constructor Create(methodToCall: TGeneralNotifyMethod; argument: TObject);
destructor Destroy; override;
public
fmethodToCall: TGeneralNotifyMethod;
farg: TObject;
end;
TJobManagerThreadSafe = class (TObject)
public
constructor Create();
destructor Destroy; override;
public
procedure AddJobReport(methodToCall: TGeneralNotifyMethod; argument: Pointer);
private
fJQ: TMVQueueThreadSafe; //object queue
fTimer: TTimer;
public
procedure fOnTimer(Sender: Tobject);
end;
Var
MainJobManager: TJobManagerThreadSafe; //!!!!!!!!!!!!!!!
//*********************************
implementation
Uses Windows;
constructor TJobThreadSafe.Create( jobtype: TJobType; OnDoneThreadSafe: TJobNotifyMethod; OnDoneInMainThread: TGeneralNotifyMethod );
begin
inherited Create;
fType := jobtype;
fOnDoneThreadSafe := OnDoneThreadSafe;
fOnDoneInMainThread := OnDoneInMainThread;
fFinished := false;
fResultCode := CJNotProcessed;
end;
destructor TJobThreadSafe.Destroy;
begin
inherited;
end;
destructor TJobThreadSafe.SmartDestroy;
begin
//TODO!!!!!!!!!!!!!!!
end;
procedure TJobThreadSafe.FinishJob; //call after assigning a result (in descendant) and all manipulation - marks as finished and calls OnDone Methods
begin
//!! must not lock as handling methods using self (and locking self) will be called;
fFinished := true;
//run ondonethredsafe immediately
if Assigned( fOnDoneThreadSafe) then fOnDoneThreadSafe( self ); //this
//check if requested immediate call using synchronize (as main thread - must check, if actuall thread is not the maintherad)
{ if Assigned( fOnDoneUsingSynchronize) then
begin
if GetCurrentThreadId = MainThreadID then
begin
fOnDoneUsingSynchronize( self );
end
else
begin
Synchronize(
procedure
begin
fOnDoneUsingSynchronize( self );
end
);
end;
end;
}
//schedule running OnDOneInMaint thres
if Assigned( fOnDoneInMainThread ) then MainJobManager.AddJobReport( fOnDoneInMainThread, self );
end;
function TJobThreadSafe.fIsFinished(): boolean;
begin
Lock;
try
begin
Result := fFinished;
end;
finally
Unlock;
end;
end;
function TJobThreadSafe.getResultCode(): TJobResult;
begin
Lock;
try
begin
Result := fResultCode;
end;
finally
Unlock;
end;
end;
procedure TJobThreadSafe.setResultCode (jr: TJobResult);
begin
Lock;
try
begin
fResultCode := jr;
end;
finally
Unlock;
end;
end;
//-----------------------
constructor TJobDirectCommand.Create(OnDoneThreadSafe: TJobNotifyMethod; OnDoneInMainThread: TGeneralNotifyMethod);
begin
inherited Create(CJDirectCmdStr, OnDoneThreadSafe, OnDoneInMainThread);
Cmd := '';
Reply := '';
end;
destructor TJobDirectCommand.Destroy;
begin
inherited;
end;
//-----------------------
constructor TJobRec.Create(methodToCall: TGeneralNotifyMethod; argument: TObject);
begin
inherited Create();
fmethodToCall := methodToCall;
farg := argument;
end;
destructor TJobRec.Destroy;
begin
inherited;
end;
//-----------------------
constructor TJobManagerThreadSafe.Create();
begin
inherited Create;
fTimer := TTimer.Create( nil );
fTimer.Enabled := false;
fTimer.Interval := 500;
fTimer.OnTimer := fOnTimer;
//
fJQ := TMVQueueThreadSafe.Create;
end;
destructor TJobManagerThreadSafe.Destroy;
begin
fTimer.enabled := false;
//!!!!!!! fuck Ttimer, there can still be waiting unprossed timer events
MyDestroyAndNil( fTimer );
fJQ.Clear; //forget about eny remaining job finich events
MyDestroyAndNil( fJQ );
inherited;
end;
procedure TJobManagerThreadSafe.AddJobReport(methodToCall: TGeneralNotifyMethod; argument: Pointer);
Var
jr: TJobRec;
begin
jr := TJobRec.Create(methodToCall, argument);
fJQ.Add( jr );
end;
procedure TJobManagerThreadSafe.fOnTimer(Sender: Tobject);
Var
j: TJobThreadSafe;
olde: boolean;
p: pointer;
jr: TJobRec;
begin
olde := fTimer.Enabled;
if not olde then exit;
fTimer.Enabled := false;
while fJQ.Count>0 do
begin
jr := TJobRec( fJQ.Pop );
if jr<>nil then
begin
if Assigned( jr.fmethodToCall) then jr.fmethodToCall( TObject( jr.farg) );
jr.Destroy;
end;
end;
fTimer.Enabled := olde;
end;
initialization
MainJobManager := TJobManagerThreadSafe.Create; //!!!!!!!!!!!!!!!
MainJobManager.fTimer.Enabled := true;
finalization
if MainJobManager<>nil then MainJobManager.fTimer.Enabled := false;
MyDestroyAndNil( MainJobManager ); //!!!!!!!!!!!!!!!
end.
| 23.709779 | 155 | 0.661389 |
f1a7d33274489303b9af049e92598fdb3cfb7f16
| 1,659 |
pas
|
Pascal
|
design/source/dttctrls.pas
|
pascaldragon/Pas2JS_Widget
|
42984d7e5d8bbcfd0d0c64f90cd4a1b60319ac90
|
[
"MIT"
] | 26 |
2020-05-09T13:07:34.000Z
|
2022-02-20T04:29:17.000Z
|
design/source/dttctrls.pas
|
GuvaCode/Pas2JS_Widget
|
bd817df72f052c10c35b6fde0a26b0609b59bdfd
|
[
"MIT"
] | 24 |
2020-12-10T16:45:05.000Z
|
2022-03-23T21:51:34.000Z
|
design/source/dttctrls.pas
|
GuvaCode/Pas2JS_Widget
|
bd817df72f052c10c35b6fde0a26b0609b59bdfd
|
[
"MIT"
] | 6 |
2020-06-27T03:02:12.000Z
|
2022-01-10T12:54:34.000Z
|
{
MIT License
Copyright (c) 2018 Hélio S. Ribeiro and Anderson J. Gado da Silva
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
}
unit DttCtrls;
{$mode objfpc}{$H+}
interface
uses
Classes,
SysUtils,
Graphics,
Controls,
StdCtrls;
type
{ TCustomDateTimeEdit }
TCustomDateTimeEdit = class(TCustomEdit)
protected
procedure DoEnter; override;
procedure DoExit; override;
end;
implementation
{ TCustomDateTimeEdit }
procedure TCustomDateTimeEdit.DoEnter;
begin
inherited DoEnter;
RealSetText(RealGetText);
end;
procedure TCustomDateTimeEdit.DoExit;
begin
inherited DoExit;
RealSetText(RealGetText);
end;
end.
| 25.921875 | 80 | 0.767932 |
aae34b15e8c13d4572e711cd7a297ff6505f3e0f
| 37,640 |
dfm
|
Pascal
|
UDlgMsg.dfm
|
nikchis/smartnote
|
5bb8f7b5397565008f49426f2201a244ba6227c0
|
[
"MIT"
] | null | null | null |
UDlgMsg.dfm
|
nikchis/smartnote
|
5bb8f7b5397565008f49426f2201a244ba6227c0
|
[
"MIT"
] | null | null | null |
UDlgMsg.dfm
|
nikchis/smartnote
|
5bb8f7b5397565008f49426f2201a244ba6227c0
|
[
"MIT"
] | null | null | null |
object FormMsg: TFormMsg
Left = 0
Top = 0
BorderIcons = [biSystemMenu]
Caption = 'Message'
ClientHeight = 164
ClientWidth = 384
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -12
Font.Name = 'Arial'
Font.Style = []
OldCreateOrder = False
Position = poScreenCenter
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 15
object dxLayoutControl: TdxLayoutControl
Left = 0
Top = 0
Width = 384
Height = 164
Align = alClient
TabOrder = 0
LayoutLookAndFeel = DMMain.dxLayoutSkinLookAndFeel
ExplicitHeight = 158
object ImageError: TImage
Left = 10000
Top = 10000
Width = 68
Height = 68
Center = True
Picture.Data = {
0B546478504E47496D61676589504E470D0A1A0A0000000D4948445200000040
000000400806000000AA6971DE0000000467414D410000B18E7CFB5193000000
206348524D0000870F00008C0F0000FD520000814000007D790000E98B00003C
E5000019CC733C857700000A396943435050686F746F73686F70204943432070
726F66696C65000048C79D96775454D71687CFBD777AA1CD30025286DEBBC000
D27B935E456198196028030E3334B121A2021145449A224850C480D150245644
B1101454B007240828311845542C6F46D68BAEACBCF7F2F2FBE3AC6FEDB3F7B9
FBECBDCF5A170092A72F9797064B0190CA13F0833C9CE911915174EC0080011E
608029004C5646BA5FB07B0810C9CBCD859E2172025F0401F07A58BC0270D3D0
33804E07FF9FA459E97C81E89800119BB339192C11178838254B902EB6CF8A98
1A972C66182566BE284111CB893961910D3EFB2CB2A398D9A93CB688C539A7B3
53D962EE15F1B64C2147C488AF880B33B99C2C11DF12B1468A30952BE237E2D8
540E33030014496C1770588922361131891F12E422E2E500E048095F71DC572C
E0640BC49772494BCFE173131205741D962EDDD4DA9A41F7E464A5700402C300
262B99C967D35DD252D399BC1C0016EFFC5932E2DAD24545B634B5B6B4343433
32FDAA50FF75F36F4ADCDB457A19F8B96710ADFF8BEDAFFCD21A0060CC896AB3
F38B2DAE0A80CE2D00C8DDFB62D3380080A4A86F1DD7BFBA0F4D3C2F890241BA
8DB1715656961197C3321217F40FFD4F87BFA1AFBE67243EEE8FF2D05D39F14C
618A802EAE1B2B2D254DC8A767A433591CBAE19F87F81F07FE751E06419C780E
9FC313458489A68CCB4B10B59BC7E60AB8693C3A97F79F9AF80FC3FEA4C5B916
89D2F81150638C80D4752A407EED07280A1120D1FBC55DFFA36FBEF830207E79
E12A938B73FFEF37FD67C1A5E225839BF039CE252884CE12F23317F7C4CF12A0
010148022A9007CA401DE800436006AC802D70046EC01BF88310100956031648
04A9800FB2401ED8040A4131D809F6806A50071A41336805C741273805CE834B
E01AB8016E83FB60144C80676016BC060B10046121324481E421154813D287CC
2006640FB941BE50101409C54209100F124279D066A8182A83AAA17AA819FA1E
3A099D87AE4083D05D680C9A867E87DEC1084C82A9B012AC051BC30CD809F681
43E0557002BC06CE850BE01D7025DC001F853BE0F3F035F8363C0A3F83E71080
10111AA28A18220CC405F147A29078848FAC478A900AA4016945BA913EE42632
8ACC206F51181405454719A26C519EA850140BB506B51E5582AA461D4675A07A
51375163A859D4473419AD88D647DBA0BDD011E8047416BA105D816E42B7A32F
A26FA327D0AF31180C0DA38DB1C2786222314998B59812CC3E4C1BE61C661033
8E99C362B1F2587DAC1DD61FCBC40AB085D82AEC51EC59EC107602FB0647C4A9
E0CC70EEB8281C0F978FABC01DC19DC10DE126710B7829BC26DE06EF8F67E373
F0A5F8467C37FE3A7E02BF4090266813EC08218424C2264225A1957091F080F0
924824AA11AD8981442E7123B192788C789938467C4B9221E9915C48D1242169
07E910E91CE92EE925994CD6223B92A3C802F20E7233F902F911F98D0445C248
C24B822DB141A246A2436248E2B9245E5253D24972B564AE6485E409C9EB9233
5278292D291729A6D47AA91AA99352235273D2146953697FE954E912E923D257
A4A764B0325A326E326C99029983321764C62908459DE242615136531A291729
13540C559BEA454DA21653BFA30E506765656497C986C966CBD6C89E961DA521
342D9A172D85564A3B4E1BA6BD5BA2B4C4690967C9F625AD4B8696CCCB2D9573
94E3C815C9B5C9DD967B274F9777934F96DF25DF29FF5001A5A0A710A890A5B0
5FE1A2C2CC52EA52DBA5ACA5454B8F2FBDA7082BEA290629AE553CA8D8AF38A7
A4ACE4A194AE54A57441694699A6ECA89CA45CAE7C46795A85A262AFC2552957
39ABF2942E4B77A2A7D02BE9BDF4595545554F55A16ABDEA80EA829AB65AA85A
BE5A9BDA4375823A433D5EBD5CBD477D564345C34F234FA345E39E265E93A199
A8B957B34F735E4B5B2B5C6BAB56A7D694B69CB69776AE768BF6031DB28E83CE
1A9D069D5BBA185D866EB2EE3EDD1B7AB09E855EA25E8DDE757D58DF529FABBF
4F7FD0006D606DC0336830183124193A19661AB6188E19D18C7C8DF28D3A8D9E
1B6B184719EF32EE33FE6862619262D26872DF54C6D4DB34DFB4DBF477333D33
96598DD92D73B2B9BBF906F32EF317CBF4977196ED5F76C78262E167B1D5A2C7
E283A59525DFB2D572DA4AC32AD6AAD66A84416504304A1897ADD1D6CED61BAC
4F59BFB5B1B411D81CB7F9CDD6D036D9F688EDD472EDE59CE58DCBC7EDD4EC98
76F576A3F674FB58FB03F6A30EAA0E4C870687C78EEA8E6CC726C749275DA724
A7A34ECF9D4D9CF9CEEDCEF32E362EEB5CCEB922AE1EAE45AE036E326EA16ED5
6E8FDCD5DC13DC5BDC673D2C3CD67A9CF3447BFA78EEF21CF152F26279357BCD
7A5B79AFF3EEF521F904FB54FB3CF6D5F3E5FB76FBC17EDE7EBBFD1EACD05CC1
5BD1E90FFCBDFC77FB3F0CD00E5813F06320263020B026F0499069505E505F30
253826F848F0EB10E790D290FBA13AA1C2D09E30C9B0E8B0E6B0F970D7F0B2F0
D108E3887511D7221522B9915D51D8A8B0A8A6A8B9956E2BF7AC9C88B6882E8C
1E5EA5BD2A7BD595D50AAB53569F8E918C61C69C8845C786C71E897DCFF46736
30E7E2BCE26AE366592EACBDAC676C4776397B9A63C729E34CC6DBC597C54F25
D825EC4E984E7448AC489CE1BA70ABB92F923C93EA92E693FD930F257F4A094F
694BC5A5C6A69EE4C9F09279BD69CA69D96983E9FAE985E9A36B6CD6EC5933CB
F7E137654019AB32BA0454D1CF54BF5047B8453896699F5993F9262B2CEB44B6
74362FBB3F472F677BCE64AE7BEEB76B516B596B7BF254F336E58DAD735A57BF
1E5A1FB7BE6783FA86820D131B3D361EDE44D894BCE9A77C93FCB2FC579BC337
771728156C2C18DFE2B1A5A550A2905F38B2D5766BDD36D436EEB681EDE6DBAB
B67F2C62175D2D3629AE287E5FC22AB9FA8DE93795DF7CDA11BF63A0D4B274FF
4ECC4EDECEE15D0EBB0E974997E5968DEFF6DBDD514E2F2F2A7FB52766CF958A
6515757B097B857B472B7D2BBBAA34AA7656BDAF4EACBE5DE35CD356AB58BBBD
767E1F7BDFD07EC7FDAD754A75C575EF0E700FDCA9F7A8EF68D06AA838883998
79F049635863DFB78C6F9B9B149A8A9B3E1CE21D1A3D1C74B8B7D9AAB9F988E2
91D216B845D8327D34FAE88DEF5CBFEB6A356CAD6FA3B5151F03C784C79E7E1F
FBFDF0719FE33D2718275A7FD0FCA1B69DD25ED40175E474CC7626768E764576
0D9EF43ED9D36DDBDDFEA3D18F874EA99EAA392D7BBAF40CE14CC1994F6773CF
CE9D4B3F37733EE1FC784F4CCFFD0B11176EF506F60E5CF4B978F992FBA50B7D
4E7D672FDB5D3E75C5E6CAC9AB8CAB9DD72CAF75F45BF4B7FF64F153FB80E540
C775ABEB5D37AC6F740F2E1F3C33E43074FEA6EBCD4BB7BC6E5DBBBDE2F6E070
E8F09D91E891D13BEC3B537753EEBEB897796FE1FEC607E807450FA51E563C52
7CD4F0B3EECF6DA396A3A7C75CC7FA1F073FBE3FCE1A7FF64BC62FEF270A9E90
9F544CAA4C364F994D9D9A769FBEF174E5D38967E9CF16660A7F95FEB5F6B9CE
F31F7E73FCAD7F366276E205FFC5A7DF4B5ECABF3CF46AD9AB9EB980B947AF53
5F2FCC17BD917F73F82DE36DDFBBF077930B59EFB1EF2B3FE87EE8FEE8F3F1C1
A7D44F9FFE050398F3FCBAC4E8D3000000097048597300000B0C00000B0C013F
4022C80000054D49444154785EED5A7B6C5365146FC4187C26C8188F3DD9082A
881B7B804682F80889CC3D00A36EB238C22459348A932D28098948DC86262AE2
06841840E40F484463D0C8303E70F818333870116659DBADEDBABEBBAE5DB7B6
3FCFF7B52BE9EACA5D4B5D1FF726BFB4BD3DF77E3DBFEFF79D73EEF92AE9912C
40224392C8CE33DF450244058831400C82621648E438206681449E7DB10E100B
21B112144B61310B885920AC67812C5C95A44E297A24D96155B2612C812CA857
95C3651EBC06A3054E9D29A270D118BE314D16F4DDBB9A08089D843008C8C4C0
86D7616B3D0BD95D3990CF2C44EFFC55306C6B82A1AE2122D0D73741316B19E4
498590DD9983E1F64EA81FA92002B242564178043C5F8BA153676809A4D10FC8
8432B708913E64B72FE10EB3A5673FD701F5CAF26820209DFF88FF8F806C4E7A
D411A02A28C5D0C9D350E59740B56CAD3F96AF83EAA1A703CF8FB7FBAFCF0FAE
87B2A00C8E8E4B7CB9B1351F9D041496C1B2E730944BD640B7691B7455751E6C
AC87A6AC86CB76A0E255E8AADF108ECDDBA15C5A42D7CE85ED4C1B11901BDD04
983F380463434B402818ED96432A4986F5E817B07DFB23E1076168FD19DACAAD
44400A6CDF9D8B1102DEDE1B40C048D73FDE60C9EA8679934406D9A7C73E0152
4912DC94C7277B981AF6799640EC2B2015B269F7A0E7E685E8991604549D2A92
0BA1A298A2482AA0353F9FC78F382060364CEF34C3D2721496E64F0360FEF808
CCEF7F8261CAEFEE613B1C17BAE0760CC37EB61DF21979B09D6645572C04C109
63C01CE8EB9A60DCD50CE3CEBDFE78EB23580F9FE4AB435BB185667C0E64372D
A4C0391BDAAA7AB82C568C5CBCCC2BC0A84E833C0B4C48402A7A3356A237EBD1
0028D256D04CFF0EED865A1EF1752FEF2082F6C0F4DE014E064BABECF0548251
5C070423402A9905A75441B21E21893B02E0B23BB8F39E47F44CC8C8D1C183C7
E95C067D4EF51070C703B14B00ABDE582D2095CC1C87BBA198918BD12B526FAA
5C40AF99183CF239E4B72EE684B06B9DBD6A8A05F9B14B0073DEDEDA06C7A52B
70D07AF6435737DC4E179F69E6B08C3285AE660757824711E9B1A30053E3FEC0
4A90A4CFE4AD7EAC129A273705E2891760FFE93CF4AFECE4B3CDE4AF7B713B27
80A540C3D686D88801960F0FF1BC2DBBED7E3FC8A72FF2768E52381181980BD9
F4C5701A8DD0BFB68BAF7B45F272BE140CF5BB3142F277FCF267146681AF5AB9
636CA6FA16AD86CB6886FDD70EC21F81F8ED02ECC140F9DF414B61EC70AAB4BE
F78ECEBFE11EB24376CB7DDE7E400AEC6DED53DC0FA8A8A547D48BE85F53054D
4935FA8B49DA4F6D8486BD860A763DBB5F11A194EEC35ED9673ACFC6E163B0B1
E8FDC86529D42BA6B221F2EC96C996F537DC5EF5F03353D8114A7802CAA34101
CF4D95022857D3939D92DA60CABC1261585A4CEB77334CBBF7C3D4D8E20F3AA7
7EBC92BA3FC5C2EEC5C6CC5F4BE932BCBFF884D1151E1B98B5A485221D03EB6A
268C03CABC52BA172B7B85DE2FF476F8D88ED80D20E07A33C00A99342FE60527
20BFD4DB29F2D887D3EF17BAE517610232A159FFD2B55CFE5737A5B5EA0915D0
975304B7CBE9FB5E4984449A848812C0FA78967D9FF91C32371E403FDB4E1BD0
C3D9A7F6834BABE73B4BB653DFFBEC8D6FBEEB7D12BC9ECA42FF3EC204A46054
A1F239347CBE13D6135FC37AEC4B0C8E033B673DF10D1537577DF6AC0DCE4814
2AE750EC224840363DBAE6C2651D82536BF0C0401BA76C03351874468FAD8EA0
D2C432014C96AC7313CEF6390B84A1CB5BC8B5115440647FB810E784D8880408
61299E6D4405C4F3EC0AF14D54801096E2D94654403CCFAE10DF44050861299E
6D4405C4F3EC0AF14D54801096E2D926E115F02FD9BBE8971922C57800000000
49454E44AE426082}
Transparent = True
Visible = False
end
object ImageInfo: TImage
Left = 10000
Top = 10000
Width = 68
Height = 68
Center = True
Picture.Data = {
0B546478504E47496D61676589504E470D0A1A0A0000000D4948445200000040
000000400806000000AA6971DE0000000467414D410000B18E7CFB5193000000
206348524D0000870F00008C0F0000FD520000814000007D790000E98B00003C
E5000019CC733C857700000A396943435050686F746F73686F70204943432070
726F66696C65000048C79D96775454D71687CFBD777AA1CD30025286DEBBC000
D27B935E456198196028030E3334B121A2021145449A224850C480D150245644
B1101454B007240828311845542C6F46D68BAEACBCF7F2F2FBE3AC6FEDB3F7B9
FBECBDCF5A170092A72F9797064B0190CA13F0833C9CE911915174EC0080011E
608029004C5646BA5FB07B0810C9CBCD859E2172025F0401F07A58BC0270D3D0
33804E07FF9FA459E97C81E89800119BB339192C11178838254B902EB6CF8A98
1A972C66182566BE284111CB893961910D3EFB2CB2A398D9A93CB688C539A7B3
53D962EE15F1B64C2147C488AF880B33B99C2C11DF12B1468A30952BE237E2D8
540E33030014496C1770588922361131891F12E422E2E500E048095F71DC572C
E0640BC49772494BCFE173131205741D962EDDD4DA9A41F7E464A5700402C300
262B99C967D35DD252D399BC1C0016EFFC5932E2DAD24545B634B5B6B4343433
32FDAA50FF75F36F4ADCDB457A19F8B96710ADFF8BEDAFFCD21A0060CC896AB3
F38B2DAE0A80CE2D00C8DDFB62D3380080A4A86F1DD7BFBA0F4D3C2F890241BA
8DB1715656961197C3321217F40FFD4F87BFA1AFBE67243EEE8FF2D05D39F14C
618A802EAE1B2B2D254DC8A767A433591CBAE19F87F81F07FE751E06419C780E
9FC313458489A68CCB4B10B59BC7E60AB8693C3A97F79F9AF80FC3FEA4C5B916
89D2F81150638C80D4752A407EED07280A1120D1FBC55DFFA36FBEF830207E79
E12A938B73FFEF37FD67C1A5E225839BF039CE252884CE12F23317F7C4CF12A0
010148022A9007CA401DE800436006AC802D70046EC01BF88310100956031648
04A9800FB2401ED8040A4131D809F6806A50071A41336805C741273805CE834B
E01AB8016E83FB60144C80676016BC060B10046121324481E421154813D287CC
2006640FB941BE50101409C54209100F124279D066A8182A83AAA17AA819FA1E
3A099D87AE4083D05D680C9A867E87DEC1084C82A9B012AC051BC30CD809F681
43E0557002BC06CE850BE01D7025DC001F853BE0F3F035F8363C0A3F83E71080
10111AA28A18220CC405F147A29078848FAC478A900AA4016945BA913EE42632
8ACC206F51181405454719A26C519EA850140BB506B51E5582AA461D4675A07A
51375163A859D4473419AD88D647DBA0BDD011E8047416BA105D816E42B7A32F
A26FA327D0AF31180C0DA38DB1C2786222314998B59812CC3E4C1BE61C661033
8E99C362B1F2587DAC1DD61FCBC40AB085D82AEC51EC59EC107602FB0647C4A9
E0CC70EEB8281C0F978FABC01DC19DC10DE126710B7829BC26DE06EF8F67E373
F0A5F8467C37FE3A7E02BF4090266813EC08218424C2264225A1957091F080F0
924824AA11AD8981442E7123B192788C789938467C4B9221E9915C48D1242169
07E910E91CE92EE925994CD6223B92A3C802F20E7233F902F911F98D0445C248
C24B822DB141A246A2436248E2B9245E5253D24972B564AE6485E409C9EB9233
5278292D291729A6D47AA91AA99352235273D2146953697FE954E912E923D257
A4A764B0325A326E326C99029983321764C62908459DE242615136531A291729
13540C559BEA454DA21653BFA30E506765656497C986C966CBD6C89E961DA521
342D9A172D85564A3B4E1BA6BD5BA2B4C4690967C9F625AD4B8696CCCB2D9573
94E3C815C9B5C9DD967B274F9777934F96DF25DF29FF5001A5A0A710A890A5B0
5FE1A2C2CC52EA52DBA5ACA5454B8F2FBDA7082BEA290629AE553CA8D8AF38A7
A4ACE4A194AE54A57441694699A6ECA89CA45CAE7C46795A85A262AFC2552957
39ABF2942E4B77A2A7D02BE9BDF4595545554F55A16ABDEA80EA829AB65AA85A
BE5A9BDA4375823A433D5EBD5CBD477D564345C34F234FA345E39E265E93A199
A8B957B34F735E4B5B2B5C6BAB56A7D694B69CB69776AE768BF6031DB28E83CE
1A9D069D5BBA185D866EB2EE3EDD1B7AB09E855EA25E8DDE757D58DF529FABBF
4F7FD0006D606DC0336830183124193A19661AB6188E19D18C7C8DF28D3A8D9E
1B6B184719EF32EE33FE6862619262D26872DF54C6D4DB34DFB4DBF477333D33
96598DD92D73B2B9BBF906F32EF317CBF4977196ED5F76C78262E167B1D5A2C7
E283A59525DFB2D572DA4AC32AD6AAD66A84416504304A1897ADD1D6CED61BAC
4F59BFB5B1B411D81CB7F9CDD6D036D9F688EDD472EDE59CE58DCBC7EDD4EC98
76F576A3F674FB58FB03F6A30EAA0E4C870687C78EEA8E6CC726C749275DA724
A7A34ECF9D4D9CF9CEEDCEF32E362EEB5CCEB922AE1EAE45AE036E326EA16ED5
6E8FDCD5DC13DC5BDC673D2C3CD67A9CF3447BFA78EEF21CF152F26279357BCD
7A5B79AFF3EEF521F904FB54FB3CF6D5F3E5FB76FBC17EDE7EBBFD1EACD05CC1
5BD1E90FFCBDFC77FB3F0CD00E5813F06320263020B026F0499069505E505F30
253826F848F0EB10E790D290FBA13AA1C2D09E30C9B0E8B0E6B0F970D7F0B2F0
D108E3887511D7221522B9915D51D8A8B0A8A6A8B9956E2BF7AC9C88B6882E8C
1E5EA5BD2A7BD595D50AAB53569F8E918C61C69C8845C786C71E897DCFF46736
30E7E2BCE26AE366592EACBDAC676C4776397B9A63C729E34CC6DBC597C54F25
D825EC4E984E7448AC489CE1BA70ABB92F923C93EA92E693FD930F257F4A094F
694BC5A5C6A69EE4C9F09279BD69CA69D96983E9FAE985E9A36B6CD6EC5933CB
F7E137654019AB32BA0454D1CF54BF5047B8453896699F5993F9262B2CEB44B6
74362FBB3F472F677BCE64AE7BEEB76B516B596B7BF254F336E58DAD735A57BF
1E5A1FB7BE6783FA86820D131B3D361EDE44D894BCE9A77C93FCB2FC579BC337
771728156C2C18DFE2B1A5A550A2905F38B2D5766BDD36D436EEB681EDE6DBAB
B67F2C62175D2D3629AE287E5FC22AB9FA8DE93795DF7CDA11BF63A0D4B274FF
4ECC4EDECEE15D0EBB0E974997E5968DEFF6DBDD514E2F2F2A7FB52766CF958A
6515757B097B857B472B7D2BBBAA34AA7656BDAF4EACBE5DE35CD356AB58BBBD
767E1F7BDFD07EC7FDAD754A75C575EF0E700FDCA9F7A8EF68D06AA838883998
79F049635863DFB78C6F9B9B149A8A9B3E1CE21D1A3D1C74B8B7D9AAB9F988E2
91D216B845D8327D34FAE88DEF5CBFEB6A356CAD6FA3B5151F03C784C79E7E1F
FBFDF0719FE33D2718275A7FD0FCA1B69DD25ED40175E474CC7626768E764576
0D9EF43ED9D36DDBDDFEA3D18F874EA99EAA392D7BBAF40CE14CC1994F6773CF
CE9D4B3F37733EE1FC784F4CCFFD0B11176EF506F60E5CF4B978F992FBA50B7D
4E7D672FDB5D3E75C5E6CAC9AB8CAB9DD72CAF75F45BF4B7FF64F153FB80E540
C775ABEB5D37AC6F740F2E1F3C33E43074FEA6EBCD4BB7BC6E5DBBBDE2F6E070
E8F09D91E891D13BEC3B537753EEBEB897796FE1FEC607E807450FA51E563C52
7CD4F0B3EECF6DA396A3A7C75CC7FA1F073FBE3FCE1A7FF64BC62FEF270A9E90
9F544CAA4C364F994D9D9A769FBEF174E5D38967E9CF16660A7F95FEB5F6B9CE
F31F7E73FCAD7F366276E205FFC5A7DF4B5ECABF3CF46AD9AB9EB980B947AF53
5F2FCC17BD917F73F82DE36DDFBBF077930B59EFB1EF2B3FE87EE8FEE8F3F1C1
A7D44F9FFE050398F3FCBAC4E8D3000000097048597300000B0C00000B0C013F
4022C80000081249444154785EED5A5B4F554714EE3F90835A68C5F4A17DD1DF
508D4D6D4C1A1F5468116BD5149AAAD51A4D1B888AADA5B6B16A35DEAA05A3A6
B51453AD8D1C2E45D408520481A3110423207247B128E8E1EAEAFA66339B9303
B267DF88C633C94E0867EF356BBE59976FD69A575E5B9C4D2FF3F3CACBBC78AC
3D0440C802423120140443596022E340446C164DFD70EC07BF4DA42E139205B0
A8293159E459E4A5697139F46EE2658ADF554E6BF75FA3B507871FFE3B617739
CDE5DFA2E272C5BB93F99B8900C4953418C981158B0E8BCEA4F737FF4B87BDF5
74BBB58754476D5B0FA566D5D3FCE462F2B00CC8824C37ACC37100A0ECB4B86C
DA7AA29A3ABAFA47ADB9B3BB8F4A6F3D206F711BA55F68120FFE2EA97940F71F
F58D7AFFDEC37EDA965E43D33FCA1156E134088E01204CFD032F7DF35B35F50D
3CD517D2DFFF94322E36D38A9D65F4D68A3C0A5BE8A5F06836F1A007FF0B63D3
7F73791E2DDB5146E9E79BC8CFDFCA3130F894527EAFE1F8E175D4351C01008B
79E7AB426ABCE7D715AE6FEFA1D5FB7DF42A2B8CDF11F822638DCD18EFE05DF1
0D03BA728F8F6A5B46DCA7A5B357C40A00E68435D806C0C33BBAF9D84D7DE18F
FD83B46A9F8F7733532CC4AE929011B630933EDDEDA3EEC703FA3C29EC6293D8
62ECCAB7054058741665B00FCB71967D398A7D758A030B0F5E188098B6249BFE
2A68D6E73B5DD0429E984C5B205806C0C33BEC2D69D395494CABE49D3AEB5AB4
0620C8049863DDA11BFABC79E51DEC0ED641B0040094483F7F575762F1F7A5C2
67ED9AA3EAF7982B26A524C0129A993B9CB534BF6900C2D9EC371DADD2278FE3
C54F99C0C54B90306774CA155D8F6F392658098CA60040AA9BFD65A13E69525A
95E59D97915E6608D5DD0F7C0FDFAE3F3CE20EC80E66D9A3290026C778A9BE5D
4B755925ADC21FAD288E9D5AB9A782FE2C68A293979A44DE07FDB5220B3A9CBE
AC05C6A6FBBD22759A91A30C00185EF2712DDD3DF60F096666859E82CDA566D7
8F627C3B4EDE1294D78CF2F25D30CF473D5A8ADCC664C98C1C65005EE7497AFB
87C4246B0E5CB39CEA4074C61AFDCC1EADF83040803B25FC5421C40E3263442A
560552090020BA6578F71B98ED81E4A84E10FCDEB30080E25601C01CE14C966E
B73C316D054A00842FCAA2D64EEDA0B2F6E0755B0C0F71E4447EE3282338E4AD
3365BA631125D0660C1CA03C9CAD5436C9100044D5794945C3E645A6A3EC584A
C0A2361FABA2C2CA4EBA74E33E81443971D24300EC1B3E40CDDF52ACA4AB2100
50F6C0DF75028053852D96D3DE583B0693C7E3C49901F2911671BCC648CDBEA3
04AA2100E19C9EAA1BBA85D084DD158E282B3800031BF83801026420A562D471
514525B51A0210199BA3FBEB8CF8734A47DAF17C0F4A26A5DDA023B977282D47
7B8EE636500297C9EC8280B48C7A821C514B720DE3C0B8004470CA9ABDE19290
D7FD644014335402CB78EFC0E42F5CBF372A081E513459A3F951549195A5B949
C6CC705C00B023CB874DCA57DB45700723058C7E0700F9151DA300F8856B804E
0442C847790D63F55E9FA1551902F039576C31FEB9DA6E2B4F4B60DC060081D0
5BDC2A74FE8E0F4846ACD0100094AE314E5F7626034C040032136CCF30A6D721
008C22F69A17D8055037B4ED02CB7FD4F2EA8B14044B8783E02ABB4110079759
EBB534D8E3772E0DBA99059006D17CC1401BCEA840624884220288D0CC847CDB
44C8CD20880D43F3450EF4228DD2B22100C8FD95771E0A999F7115C72E5B7313
00E8B66267B9D015CD1447A83082C8BE33B58EA54237010007C8B8A81D860E33
B1320A80B00E430B800FC1973086B8201469B387EF2600B000F42231D09536F2
7F2500F0124CA9990B8E18EB0ED92B88B8050016BF7AAF46DA3ABAFAB835EF50
410400C8020684373210764A626E01009DEADBB48A357A042AE6AF6C013292FA
FBB4A2E8173F5FB75C14750300F42265396C808BABE8211A457FF9BB610C902F
4EE560B871B823F4A47788DEF8D85A591C005C1CEB38CCF5012BA741D400A296
E4F0717D506CCED65FD577DFB405A00959D7AA555E73AF7690C742632402A96A
5799A83227735B1DCFD7FCF782AD57948256F0CEA23182AE34C6DD0E3F9BBEB9
23BBB20560621448DEDE502026C3C0BD002B350280001F950FAC4B2562072F1E
692F31B552D7670E5FD2302BC71400A2F0C8CAA28A2BC7B2ED658E154A55FD56
04665E7CECB6525D0F74ADD0B83523C3B40B48E1E0DBC7CF35E8932FDD7ED591
6289AAF2D8F958EE4ACB71922BC156DCD13200F81069E74C91567991EEE059C0
172414EE01A92E34F83DC886CF270558A0B7B48D798AF54E95691708546A129B
DCF1BC114BC8296BE7EC906B39458E070C52DDF4A539947965E4560AAEE7A812
9E67C9B6058064898181085C013C01BB62F7E004F9E29214CB426D1217B0E4D8
74F4269BBDB9883F1608B601908171D6FA02AA0FB80D8A5E3D6833CE0E56AFC9
21A2AFE19A6403A73739EEF2FD84397C49C3A92B398E00A0A5C82C0AE71B5B20
4B7E264A72E00085822A8ED233E3F3B58B921C44032F4B8A1619FF0FBFCDF824
9FE2B90375AAB0995BDDBA18EA65CB027798CCFD3FB3A96E3CD7720C003989C6
C1B9F9C94034F1A5C6E0D1CD95255F5D9728B3A3D788077F57D4FE478FB8F912
3C5A1EF409A284FB09AAFCDE4C90751C80402026F1CDADF7128B682FD713AA1A
B4A28ACAA86E7C281AB2F33616B1FF6B84C9CA6D1415205C03404E2EAFCBC3C4
458D915B6DB8379CCC16F2C31F35FCDC623A5C25E8F16C6699E845E25D2CDA49
53772D0BA8A01CF88EBC0B0CFA1B488511ED41B5CDCAB3FBBEEB16605741B7BF
0F01E036C2CFBBFC90053CEF3BE4B67E210B701BE1E75DFEFF30ED525FF3E899
290000000049454E44AE426082}
Transparent = True
Visible = False
end
object ImageQuestion: TImage
Left = 23
Top = 23
Width = 68
Height = 68
Center = True
Picture.Data = {
0B546478504E47496D61676589504E470D0A1A0A0000000D4948445200000040
000000400806000000AA6971DE0000000467414D410000B18E7CFB5193000000
206348524D0000870F00008C0F0000FD520000814000007D790000E98B00003C
E5000019CC733C857700000A396943435050686F746F73686F70204943432070
726F66696C65000048C79D96775454D71687CFBD777AA1CD30025286DEBBC000
D27B935E456198196028030E3334B121A2021145449A224850C480D150245644
B1101454B007240828311845542C6F46D68BAEACBCF7F2F2FBE3AC6FEDB3F7B9
FBECBDCF5A170092A72F9797064B0190CA13F0833C9CE911915174EC0080011E
608029004C5646BA5FB07B0810C9CBCD859E2172025F0401F07A58BC0270D3D0
33804E07FF9FA459E97C81E89800119BB339192C11178838254B902EB6CF8A98
1A972C66182566BE284111CB893961910D3EFB2CB2A398D9A93CB688C539A7B3
53D962EE15F1B64C2147C488AF880B33B99C2C11DF12B1468A30952BE237E2D8
540E33030014496C1770588922361131891F12E422E2E500E048095F71DC572C
E0640BC49772494BCFE173131205741D962EDDD4DA9A41F7E464A5700402C300
262B99C967D35DD252D399BC1C0016EFFC5932E2DAD24545B634B5B6B4343433
32FDAA50FF75F36F4ADCDB457A19F8B96710ADFF8BEDAFFCD21A0060CC896AB3
F38B2DAE0A80CE2D00C8DDFB62D3380080A4A86F1DD7BFBA0F4D3C2F890241BA
8DB1715656961197C3321217F40FFD4F87BFA1AFBE67243EEE8FF2D05D39F14C
618A802EAE1B2B2D254DC8A767A433591CBAE19F87F81F07FE751E06419C780E
9FC313458489A68CCB4B10B59BC7E60AB8693C3A97F79F9AF80FC3FEA4C5B916
89D2F81150638C80D4752A407EED07280A1120D1FBC55DFFA36FBEF830207E79
E12A938B73FFEF37FD67C1A5E225839BF039CE252884CE12F23317F7C4CF12A0
010148022A9007CA401DE800436006AC802D70046EC01BF88310100956031648
04A9800FB2401ED8040A4131D809F6806A50071A41336805C741273805CE834B
E01AB8016E83FB60144C80676016BC060B10046121324481E421154813D287CC
2006640FB941BE50101409C54209100F124279D066A8182A83AAA17AA819FA1E
3A099D87AE4083D05D680C9A867E87DEC1084C82A9B012AC051BC30CD809F681
43E0557002BC06CE850BE01D7025DC001F853BE0F3F035F8363C0A3F83E71080
10111AA28A18220CC405F147A29078848FAC478A900AA4016945BA913EE42632
8ACC206F51181405454719A26C519EA850140BB506B51E5582AA461D4675A07A
51375163A859D4473419AD88D647DBA0BDD011E8047416BA105D816E42B7A32F
A26FA327D0AF31180C0DA38DB1C2786222314998B59812CC3E4C1BE61C661033
8E99C362B1F2587DAC1DD61FCBC40AB085D82AEC51EC59EC107602FB0647C4A9
E0CC70EEB8281C0F978FABC01DC19DC10DE126710B7829BC26DE06EF8F67E373
F0A5F8467C37FE3A7E02BF4090266813EC08218424C2264225A1957091F080F0
924824AA11AD8981442E7123B192788C789938467C4B9221E9915C48D1242169
07E910E91CE92EE925994CD6223B92A3C802F20E7233F902F911F98D0445C248
C24B822DB141A246A2436248E2B9245E5253D24972B564AE6485E409C9EB9233
5278292D291729A6D47AA91AA99352235273D2146953697FE954E912E923D257
A4A764B0325A326E326C99029983321764C62908459DE242615136531A291729
13540C559BEA454DA21653BFA30E506765656497C986C966CBD6C89E961DA521
342D9A172D85564A3B4E1BA6BD5BA2B4C4690967C9F625AD4B8696CCCB2D9573
94E3C815C9B5C9DD967B274F9777934F96DF25DF29FF5001A5A0A710A890A5B0
5FE1A2C2CC52EA52DBA5ACA5454B8F2FBDA7082BEA290629AE553CA8D8AF38A7
A4ACE4A194AE54A57441694699A6ECA89CA45CAE7C46795A85A262AFC2552957
39ABF2942E4B77A2A7D02BE9BDF4595545554F55A16ABDEA80EA829AB65AA85A
BE5A9BDA4375823A433D5EBD5CBD477D564345C34F234FA345E39E265E93A199
A8B957B34F735E4B5B2B5C6BAB56A7D694B69CB69776AE768BF6031DB28E83CE
1A9D069D5BBA185D866EB2EE3EDD1B7AB09E855EA25E8DDE757D58DF529FABBF
4F7FD0006D606DC0336830183124193A19661AB6188E19D18C7C8DF28D3A8D9E
1B6B184719EF32EE33FE6862619262D26872DF54C6D4DB34DFB4DBF477333D33
96598DD92D73B2B9BBF906F32EF317CBF4977196ED5F76C78262E167B1D5A2C7
E283A59525DFB2D572DA4AC32AD6AAD66A84416504304A1897ADD1D6CED61BAC
4F59BFB5B1B411D81CB7F9CDD6D036D9F688EDD472EDE59CE58DCBC7EDD4EC98
76F576A3F674FB58FB03F6A30EAA0E4C870687C78EEA8E6CC726C749275DA724
A7A34ECF9D4D9CF9CEEDCEF32E362EEB5CCEB922AE1EAE45AE036E326EA16ED5
6E8FDCD5DC13DC5BDC673D2C3CD67A9CF3447BFA78EEF21CF152F26279357BCD
7A5B79AFF3EEF521F904FB54FB3CF6D5F3E5FB76FBC17EDE7EBBFD1EACD05CC1
5BD1E90FFCBDFC77FB3F0CD00E5813F06320263020B026F0499069505E505F30
253826F848F0EB10E790D290FBA13AA1C2D09E30C9B0E8B0E6B0F970D7F0B2F0
D108E3887511D7221522B9915D51D8A8B0A8A6A8B9956E2BF7AC9C88B6882E8C
1E5EA5BD2A7BD595D50AAB53569F8E918C61C69C8845C786C71E897DCFF46736
30E7E2BCE26AE366592EACBDAC676C4776397B9A63C729E34CC6DBC597C54F25
D825EC4E984E7448AC489CE1BA70ABB92F923C93EA92E693FD930F257F4A094F
694BC5A5C6A69EE4C9F09279BD69CA69D96983E9FAE985E9A36B6CD6EC5933CB
F7E137654019AB32BA0454D1CF54BF5047B8453896699F5993F9262B2CEB44B6
74362FBB3F472F677BCE64AE7BEEB76B516B596B7BF254F336E58DAD735A57BF
1E5A1FB7BE6783FA86820D131B3D361EDE44D894BCE9A77C93FCB2FC579BC337
771728156C2C18DFE2B1A5A550A2905F38B2D5766BDD36D436EEB681EDE6DBAB
B67F2C62175D2D3629AE287E5FC22AB9FA8DE93795DF7CDA11BF63A0D4B274FF
4ECC4EDECEE15D0EBB0E974997E5968DEFF6DBDD514E2F2F2A7FB52766CF958A
6515757B097B857B472B7D2BBBAA34AA7656BDAF4EACBE5DE35CD356AB58BBBD
767E1F7BDFD07EC7FDAD754A75C575EF0E700FDCA9F7A8EF68D06AA838883998
79F049635863DFB78C6F9B9B149A8A9B3E1CE21D1A3D1C74B8B7D9AAB9F988E2
91D216B845D8327D34FAE88DEF5CBFEB6A356CAD6FA3B5151F03C784C79E7E1F
FBFDF0719FE33D2718275A7FD0FCA1B69DD25ED40175E474CC7626768E764576
0D9EF43ED9D36DDBDDFEA3D18F874EA99EAA392D7BBAF40CE14CC1994F6773CF
CE9D4B3F37733EE1FC784F4CCFFD0B11176EF506F60E5CF4B978F992FBA50B7D
4E7D672FDB5D3E75C5E6CAC9AB8CAB9DD72CAF75F45BF4B7FF64F153FB80E540
C775ABEB5D37AC6F740F2E1F3C33E43074FEA6EBCD4BB7BC6E5DBBBDE2F6E070
E8F09D91E891D13BEC3B537753EEBEB897796FE1FEC607E807450FA51E563C52
7CD4F0B3EECF6DA396A3A7C75CC7FA1F073FBE3FCE1A7FF64BC62FEF270A9E90
9F544CAA4C364F994D9D9A769FBEF174E5D38967E9CF16660A7F95FEB5F6B9CE
F31F7E73FCAD7F366276E205FFC5A7DF4B5ECABF3CF46AD9AB9EB980B947AF53
5F2FCC17BD917F73F82DE36DDFBBF077930B59EFB1EF2B3FE87EE8FEE8F3F1C1
A7D44F9FFE050398F3FCBAC4E8D3000000097048597300000B0C00000B0C013F
4022C8000007AE49444154785EED5B696C155514E6A7C405A828C81F16451208
C84F43C485E03F4005299A082A014A852020AB0A46833F558422826CEE124C14
E842292D7441D6AE74A1DA42A105A42B7D2CEDA32DC7F39DF76E195EDE327367
5EAB766E32E1B56FE6CEBDDFF9CE77964B7B3DF65A4A055F0D3DF4AAE8C51BF7
F0453DF4F2000058BFA702D0E002E032C0750157035C1174A3801B06DD3CC04D
847AA80E745D263870460AF57F3589FABC9C48F74FD91FF4C277B807F7769141
A20FC0A3B1C9F4C04BFBA9DFD4441A3D2F9DA6AF3B491FEE2AA584BDE768F37E
DF95B0EF1CADF9B64CBE1B1D97C1F726C9338F4C4F8E3610D10360006F1C961E
3AEB202D4828A42385F5D4D67E87D4C0A75BADED72DDFD2D513BDF9359544F0B
3715D2B0370FCA1C00314A8C880E007D5E49141AAFF8A6982E37B4C89EEB9ABD
F4437A35CDDF50401396E788A59F782B4DAED171E9F402FF2EEECB02FAFED045
AABDE69567AE34B6D2AAED25B279CC1905109C0700167B7E5936E5FED9249B38
73BE99E67E914F4366FAACA9DC01BE0E8AE3C267B808BEC33D83F9DE399FE753
E1B9669923BFE21A4D589123DF0D743667710E00581C0B9CBB3E9FBC6D77A8E5
76072D6706880658A4B1F199A55BCED02D6FBBB80FD82320382792CE0180852D
DB5A2C162BBDE0A1718B33A9F7E47D042DD0A52E9EC51C4F2FCA142661ACDC56
2280EACE19F09C7D00063125C5F24C738CE3658DF4388BD7431CD2422D121654
D4C7BF912C8AF008313D5AD220EF88F733C10110EC03D097C5E9D9F7B2A9D5DB
41656C796CBE2FFB3380095CA00A8931D3927CE2C76171C4EC34EACF203CC8FE
1F0A08CC85D03874562A155779E8765B8708A903C2680F8001339299E2292252
F0D3718BB3C4F2C1368F7B07CF4C95F096915F47F51C15BCAC130D1E2FE514D7
D33B1B0BE96116C350210F73626EB8C3CD96762A62978020DA713174C36CF504
417D081DC6EA1D25E2AFC1368F8582297BB22E75E60157383C565CBE2120A8B1
2DA58A62D8D2E194BEF7E4BB5AF3FECE52713F1BAEA00F002C35842D8A585D76
F13A0D60BF0E650D6C28665A229D2A6FA2D4D357E9C55547850D835E3F4063E6
67D0AE83173A4188FDF464586A8349D08DE2AA66C91786B136D84894F40180CF
C66F2C302D4AD8ECB44F4E085010352C1A80C1B7A109A7FD79C3D6E4AA885645
BEA04477D15745923F68B2401F00501A296BE3F5DBA6ADD08F370A0B1A170B97
81EB6C3FE063C1CF876B4410C36D48B10FD925220340D44C90F400000547CD4D
E784A78376675EB21597A1FC881A2AC47DF45D99A9F9900BFC98512D09D2184E
ABFB4F4FD261811E00083FA033060A1D1B14A4FB26EDEBA47313B3E929D604A4
C691280D96A076C09801DD08937784994B0F00A0BF7A47A9BC7CE2CAA392C747
5A70B0EFA1E093D61C23CFCD36990BA13012FDD53C31FC4E1450186BB994D68C
067A00E0651BF656CACBC7C61F3665B140BFC746A7AC3D4ECDFECDA347608549
489E505176702DBD93A388667AAC0F001A19D08011B30F596E5C40B49E599225
02AA7208AB450E7468386793373829FA35FB9269E638520B60B1BA0040F4A0E2
7F9436CAE6D7FF5649BD590722D503812E6404604F7700B0E1773D1740284422
84F1372751A81DCC885E2000F7B8406A17BB804F044B6413D88C1511443E1FBB
EE943C9BF7D7352984AC5A1F6040045110758B08220C4EF58741143756C40BFE
8FEE0EC64DEE07229FD0697E4244E7FBC3602C3753352B433D11C48247FA1321
1438561418D61EFC46AAC4F0773717D1282E89757279E8D04F9C3522114234E8
D2440814442A7CA4B08E90BCA07B6B6513AA7D06F1B3F29CD201950AA3A4CEE9
8E54180B3152700127305612116C00200C7F3B4D0A21AB4914DE15C7BD470CB8
A0D9E429C87BF45C00136113A032DADEE535E1CB61E38B5101A2BD7580CB623C
BB685311B3C93C0828A6F0EE12EE3E5D6D6A95B97458E45F933E0098C0D808FD
809B13A11A224600E03A93D71E13EB611471EB1B2C305BCDA121B2629BAF0983
33032BCC739401984C592397C3592B7776C62FCD0ED91233FA2F9A1869B9B5D2
4C59CC42886A30921BA89618DA6E384D2AA86CF6356102CAEB48F3389209DE63
515E3CD25AF404CBABAF8B5F876A8A7682E08FFD4F9AD4006C1E73226942CB1D
603FC7872F9AA1CF08B63D17C086545B7CF6677942CB53DCD90108E1DAE28A3D
66E33FE6C2E6D172C798C70208EA07EB3F763903D40BB1A0259BCFC802CF3213
C62FCD124DB02150D232C31C386481E53170F862D3EF9D658002002286858109
2D7C46804A1122A562BE596B633EDC8BB9E0DFE83A83F2980F7D40AB55630446
D87781C017608110C313677D7485E5D0E840B2848C31D2E128EE416843A688CE
2F061AA6F079072DAF58E03C002A4B047D71B0595D7B4B3681DA7F77660D2DE4
161A0AA8B1F119722A840B6DB089FC3B2454BF707ADBE0F1F5096AEA5B840160
910382172CD24407001139FFA9B0CAFB0FE5D50A958DA3852307DCC53840F5F4
823A39FF5347EA364F7FC285D8E801608CFB485591008D9C934E533F3E2127BC
5F279D1746E0DAC29FA117A830511D22E4C155EC08A8C968107D008C2289DA1F
54162DE00BC0E0523FE33BE90F38FB9F20BA9701262D1131138CD23C5DC78028
6DC02E702E00B68EC7FFA556B5C20A97012E0398C6EE5F8CFC0F7CD98ADF47A7
1AFC8F82E88AA02B824CDD1EFFC7D33DFACFE7FF01FABBDE2A5776AF85000000
0049454E44AE426082}
Transparent = True
end
object cxButton1: TcxButton
Left = 145
Top = 109
Width = 77
Height = 30
Caption = 'OK'
ModalResult = 1
TabOrder = 1
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Tahoma'
Font.Style = []
ParentFont = False
end
object cxMemo: TcxMemo
Left = 109
Top = 11
Lines.Strings = (
'cxMemo')
ParentFont = False
Properties.ReadOnly = True
Style.Font.Charset = DEFAULT_CHARSET
Style.Font.Color = clWindowText
Style.Font.Height = -12
Style.Font.Name = 'Arial'
Style.Font.Style = []
Style.HotTrack = False
Style.IsFontAssigned = True
TabOrder = 0
Height = 96
Width = 255
end
object cxButtonYes: TcxButton
Left = 11
Top = 145
Width = 75
Height = 30
Caption = 'YES'
ModalResult = 6
TabOrder = 2
OnClick = cxButtonYesClick
end
object cxButtonNo: TcxButton
Left = 281
Top = 145
Width = 75
Height = 30
Caption = 'NO'
ModalResult = 7
TabOrder = 3
end
object dxLayoutControlGroup_Root: TdxLayoutGroup
AlignHorz = ahClient
AlignVert = avClient
CaptionOptions.Visible = False
ButtonOptions.Buttons = <>
Hidden = True
ShowBorder = False
Index = -1
end
object dxLayoutControlGroup4: TdxLayoutGroup
Parent = dxLayoutControlGroup_Root
AlignVert = avClient
CaptionOptions.Text = 'New Group'
ButtonOptions.Buttons = <>
Hidden = True
LayoutDirection = ldHorizontal
ShowBorder = False
Index = 0
end
object dxLayoutControlItemOk: TdxLayoutItem
Parent = dxLayoutControlGroup_Root
AlignHorz = ahCenter
AlignVert = avBottom
CaptionOptions.Text = 'New Item'
CaptionOptions.Visible = False
Control = cxButton1
ControlOptions.ShowBorder = False
Index = 1
end
object dxLayoutControlItem4: TdxLayoutItem
Parent = dxLayoutControlGroup4
AlignHorz = ahClient
AlignVert = avClient
CaptionOptions.Text = 'New Item'
CaptionOptions.Visible = False
Control = cxMemo
ControlOptions.ShowBorder = False
Index = 1
end
object dxLayoutControlGroupTab: TdxLayoutGroup
Parent = dxLayoutControlGroup4
CaptionOptions.Text = 'New Group'
ButtonOptions.Buttons = <>
Hidden = True
ItemIndex = 2
LayoutDirection = ldTabbed
ShowBorder = False
TabbedOptions.HideTabs = True
Index = 0
end
object dxLayoutControlItemError: TdxLayoutItem
Parent = dxLayoutControlGroupTab
AlignHorz = ahCenter
AlignVert = avCenter
CaptionOptions.Text = 'Error'
CaptionOptions.Visible = False
Control = ImageError
ControlOptions.ShowBorder = False
Index = 1
end
object dxLayoutControlItemInfo: TdxLayoutItem
Parent = dxLayoutControlGroupTab
AlignHorz = ahCenter
AlignVert = avCenter
CaptionOptions.Text = 'Info'
CaptionOptions.Visible = False
Control = ImageInfo
ControlOptions.ShowBorder = False
Index = 0
end
object dxLayoutControlGroupYesNo: TdxLayoutGroup
Parent = dxLayoutControlGroup_Root
AlignHorz = ahClient
AlignVert = avBottom
CaptionOptions.Text = 'New Group'
ButtonOptions.Buttons = <>
Hidden = True
LayoutDirection = ldHorizontal
ShowBorder = False
Index = 2
end
object dxLayoutControlItem1: TdxLayoutItem
Parent = dxLayoutControlGroupYesNo
AlignHorz = ahLeft
CaptionOptions.Text = 'New Item'
CaptionOptions.Visible = False
Control = cxButtonYes
ControlOptions.ShowBorder = False
Index = 0
end
object dxLayoutControlItem3: TdxLayoutItem
Parent = dxLayoutControlGroupYesNo
AlignHorz = ahRight
CaptionOptions.Text = 'New Item'
CaptionOptions.Visible = False
Control = cxButtonNo
ControlOptions.ShowBorder = False
Index = 1
end
object dxLayoutControlItemQuestion: TdxLayoutItem
Parent = dxLayoutControlGroupTab
AlignHorz = ahCenter
AlignVert = avCenter
CaptionOptions.Text = 'Question'
CaptionOptions.Visible = False
Control = ImageQuestion
ControlOptions.ShowBorder = False
Index = 2
end
end
end
| 57.81874 | 73 | 0.824362 |
f19ef222216f1968b3fbbd2bdba22ed3caa0ef20
| 296 |
dpr
|
Pascal
|
samples/SimpleSample.dpr
|
MurilloLazzaretti/worker-delphi-wrapper
|
e756361069d859d83cf1378ecbd914bd07dbd20d
|
[
"MIT"
] | 1 |
2021-05-17T16:32:11.000Z
|
2021-05-17T16:32:11.000Z
|
samples/SimpleSample.dpr
|
MurilloLazzaretti/worker-delphi-wrapper
|
e756361069d859d83cf1378ecbd914bd07dbd20d
|
[
"MIT"
] | null | null | null |
samples/SimpleSample.dpr
|
MurilloLazzaretti/worker-delphi-wrapper
|
e756361069d859d83cf1378ecbd914bd07dbd20d
|
[
"MIT"
] | 1 |
2021-03-18T03:44:20.000Z
|
2021-03-18T03:44:20.000Z
|
program SimpleSample;
uses
Vcl.Forms,
uMain in 'uMain.pas' {Form2},
WorkerWrapper.Core in '..\src\WorkerWrapper.Core.pas';
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm2, Form2);
Application.Run;
end.
| 18.5 | 57 | 0.689189 |
6a0bdc01bfc5a664402252c93e7a8f40fd54cebd
| 68,549 |
pas
|
Pascal
|
contrib/mORMot/SynZipFiles.pas
|
Razor12911/xtool
|
4797195ad310e8f6dc2eae8eb86fe14683f77cf0
|
[
"MIT"
] | 11 |
2022-01-17T22:05:37.000Z
|
2022-02-23T19:18:19.000Z
|
contrib/mORMot/SynZipFiles.pas
|
Razor12911/xtool
|
4797195ad310e8f6dc2eae8eb86fe14683f77cf0
|
[
"MIT"
] | null | null | null |
contrib/mORMot/SynZipFiles.pas
|
Razor12911/xtool
|
4797195ad310e8f6dc2eae8eb86fe14683f77cf0
|
[
"MIT"
] | null | null | null |
/// high-level access to .zip archive file compression
// - this unit is a part of the freeware Synopse framework,
// licensed under a MPL/GPL/LGPL tri-license; version 1.18
unit SynZipFiles;
(*
This file is part of Synopse framework.
Synopse framework. Copyright (C) 2022 Arnaud Bouchez
Synopse Informatique - https://synopse.info
*** BEGIN LICENSE BLOCK *****
Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.
The Original Code is Synopse framework.
The Initial Developer of the Original Code is Arnaud Bouchez.
Portions created by the Initial Developer are Copyright (C) 2022
the Initial Developer. All Rights Reserved.
Contributor(s):
Alternatively, the contents of this file may be used under the terms of
either the GNU General Public License Version 2 or later (the "GPL"), or
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****
*)
interface
{$I Synopse.inc} // define HASINLINE CPU32 CPU64
uses
{$ifdef MSWINDOWS}
Windows,
// USEPDF: under Windows: get ZLib 1.2.3 functions from libpdf.dll
{$ifdef USEPDF}pdf,{$endif}
{$else}
{$ifdef FPC}
SynFPCLinux,
{$endif}
{$ifdef KYLIX3}
Types,
{$endif}
{$endif}
SynCommons,
Classes,
SysUtils,
SynZip;
{
Proprietary compression/encryption adding to standard zip files
- the .zip file structure is 100% compatible with standard
- data is stored uncompressed, but passed via TSynCompressionAlgo class
- algorithms are ID-identified (from 1 to 15)
- algorithm registration is made with SynCompressionAlgos.AlgoRegister
- ID is stored in unused 7..10 bits of "flags" zip entry (cf. PKware appnote)
- TSynCompressionAlgo is called by 64KB chunks or once for whole data
- inherit from TSynCompressionAlgoBuf to simply handle 64KB chunks
- Synopse has registered several TSynCompressionAlgo IDs:
1=SynLZ-chunked 2=SynLZ-whole
3=LzoAsm-chunked 4=LzoAsm-whole
5=Bz2-chunked
6=AES-chunked 7=AES+Zip-chunked 8=AES+SynLz-chunked
so you can use 9..15 for your own purpose
- most of this unit functions are TSynCompressionAlgo aware
}
type
TZipException = class(Exception);
TSynCompressionAlgo = class
protected
fDestStream: TStream;
public
/// initialize compression into OutStream
procedure CompressInit(OutStream: TStream); virtual;
/// compress InP[InLen] into OutStream + update CRC, return compressed length
function Compress(InP: pointer; InLen: cardinal; CRC: PCardinal): cardinal; virtual; abstract;
/// called once at the end for compression flush, return compressed length
// (default implementation: just do nothing)
function CompressFinish: cardinal; virtual;
/// return uncompressed length of InP[InLen] for proper mem allocation
function UnCompressedLength(InP: pointer; InLen: cardinal): cardinal; virtual; abstract;
/// uncompress InP[InLen] into OutP, return uncompressed length (called once for decompression)
function UnCompress(InP: pointer; InLen: cardinal; OutP: pointer): cardinal; virtual; abstract;
end;
TSynCompressionAlgoClass = class of TSynCompressionAlgo;
{$ifdef USERECORDWITHMETHODS}TSynCompressionAlgos = record
{$else}TSynCompressionAlgos = object{$endif}
public
Values: array of record
ID, WholeID: integer;
func: TSynCompressionAlgoClass;
end;
procedure AlgoRegister(aAlgo: TSynCompressionAlgoClass; aID,aWholeID: integer);
function Algo(aID: integer): TSynCompressionAlgoClass;
function WholeAlgoID(aID: integer): integer;
end;
/// template class for 64KB chunked (not whole) algorithm (SynLZ, LZO...)
// which forces storing as uncompressed if compression ratio has no gain
TSynCompressionAlgoBuf = class(TSynCompressionAlgo)
protected
// fast tmp buffer (size=worse case with 64KB chunk)
fCompressBuf: PAnsiChar;
function AlgoCompress(src: PAnsiChar; size: integer; dst: PAnsiChar): integer; virtual; abstract;
function AlgoCompressLength(size: integer): integer; virtual; abstract;
function AlgoUnCompress(src: PAnsiChar; size: integer; dst: PAnsiChar): integer; virtual; abstract;
function AlgoUnCompressLength(src: PAnsiChar; size: integer): integer; virtual; abstract;
public
/// initialize compression into OutStream
procedure CompressInit(OutStream: TStream); override;
/// free fCompressBuf memory if allocated
destructor Destroy; override;
/// compress InP[InLen] into OutStream + update CRC, return compressed length
function Compress(InP: pointer; InLen: cardinal; CRC: PCardinal): cardinal; override;
/// return uncompressed length of InP[InLen] for proper mem allocation
function UnCompressedLength(InP: pointer; InLen: cardinal): cardinal; override;
/// uncompress InP[InLen] into OutP, return uncompressed length
function UnCompress(InP: pointer; InLen: cardinal; OutP: pointer): cardinal; override;
end;
/// template class for whole algorithm (SynLZ, LZO...)
// which forces storing as uncompressed if compression ratio has no gain
TSynCompressionAlgoWhole = class(TSynCompressionAlgo)
protected
function AlgoCompress(src: PAnsiChar; size: integer; dst: PAnsiChar): integer; virtual; abstract;
function AlgoCompressLength(size: integer): integer; virtual; abstract;
function AlgoUnCompress(src: PAnsiChar; size: integer; dst: PAnsiChar): integer; virtual; abstract;
function AlgoUnCompressLength(src: PAnsiChar; size: integer): integer; virtual; abstract;
public
/// compress InP[InLen] into OutStream + update CRC, return compressed length
function Compress(InP: pointer; InLen: cardinal; CRC: PCardinal): cardinal; override;
/// return uncompressed length of InP[InLen] for proper mem allocation
function UnCompressedLength(InP: pointer; InLen: cardinal): cardinal; override;
/// uncompress InP[InLen] into OutP, return uncompressed length
function UnCompress(InP: pointer; InLen: cardinal; OutP: pointer): cardinal; override;
end;
TZipCompressor = class(TStream)
private
fInitialized: Boolean;
fDestStream: TStream;
fStrm: TZStream;
fAlgorithm: TSynCompressionAlgo;
fAlgorithmStream: THeapMemoryStream;
fAlgorithmID: integer; // =0 if not Assigned(fAlgorithm)
fCRC: Cardinal;
fBlobDataHeaderPosition: Int64;
fBufferIn, fBufferOut: array[word] of byte; // two 64kb buffers
procedure Finish;
function FlushBufferOut: integer;
function InFlateDeflate: boolean; // return true if error
function GetSizeIn: cardinal;
function GetSizeOut: cardinal;
public
constructor Create(outStream: TStream; CompressionLevel: Integer;
Algorithm: integer=0);
constructor CreateAsBlobData(outStream: TStream; CompressionLevel: Integer;
Algorithm: integer=0);
destructor Destroy; override;
function Read(var Buffer; Count: Longint): Longint; override;
function Write(const Buffer; Count: Longint): Longint; override;
function WriteOnce(const Buffer; Count: Longint): Longint;
function Seek(Offset: Longint; Origin: Word): Longint; override;
property SizeIn: cardinal read GetSizeIn;
property SizeOut: cardinal read GetSizeOut;
property CRC: cardinal read fCRC;
end;
TGzWriter = class(TZipCompressor)
private
outFile: TStream;
outFileToBeFree: boolean;
public
constructor Create(const aFileName: TFileName); overload;
constructor Create(const aDestStream: TStream); overload;
// use Write() to add some data
destructor Destroy; override;
end;
PZipEntry = ^TZipEntry;
TZipEntry = {$ifdef UNICODE} record {$else} object {$endif}
ZipName: RawUTF8;
Header: TFileHeader; // as stored in standard .zip file
function SameAs(const aEntry: TZipEntry): boolean;
// test if algo is registered, perform crc32 check and create one instance
function AlgoCreate(data: pointer; const FileName: TFileName): TSynCompressionAlgo;
function LocalHeader(ZipStart: PAnsiChar): PLocalFileHeader;
function LocalDataPosition(ZipStart: PAnsiChar): PtrUInt;
end;
TZipCommon = class
private
fCount: integer;
fFileName: TFileName;
public
Entry: array of TZipEntry;
constructor Create(const aFileName: TFileName);
destructor Destroy; override;
function ZipNameIndexOf(const aZipName: RawUTF8): integer;
property Count: integer read fCount;
property FileName: TFileName read fFileName;
end;
// used to transfert Blob Data from/to Client without compress/uncompress:
{$A-}
PBlobData = ^TBlobData;
{$ifdef USERECORDWITHMETHODS}TBlobData = record
{$else}TBlobData = object{$endif}
private
// test if algo is registered, perform crc32 check and create one instance
function AlgoCreate(data: pointer): TSynCompressionAlgo;
public
dataSize, // always used
dataFullSize, dataCRC: cardinal; // used only if AlreadyCompressed
dataMethod: byte; // 0=stored 8=inflate >=16: AlgoID=dataMethod shr 4
databuf: AnsiChar;
function AlgoID: cardinal;
procedure SetFrom(const FileInfo: TFileInfo);
// uncompress if necessary:
function Expand: RawByteString;
// do freemem() if dataMethod<>0; no direct AES since may be mapped
function ExpandBuf(out destSize: cardinal): pointer;
procedure ExpandStream(Stream: TStream);
function Next: PAnsiChar; // points to next bloc
end;
{$A8}
const
BLOBDATA_HEADSIZE = sizeof(TBlobData)-sizeof(AnsiChar); // databuf: AnsiChar
type
TZipReader = class(TZipCommon)
protected
fMap: TMemoryMap;
public
constructor Create(const aFileName: TFileName);
destructor Destroy; override;
procedure Clear; // force Count=0
function GetData(aIndex: integer; aStream: TStream=nil; CheckCRC: boolean=false;
asBlobDataStored: boolean=false; withAlgoDataLen: boolean=false): PAnsiChar;
function GetString(aIndex: integer): RawByteString;
function GetBuffer(aIndex: integer; out Dest: PAnsiChar): integer;
function GetBlobData(aIndex: integer): RawByteString; overload; // PBlobData(result)
procedure GetBlobData(aIndex: integer; aStream: TStream); overload; // TBlobData->aStream
procedure DeleteLastEntry; // don't use inside TZipValues: already done in Create
procedure SaveToStream(aStream: TStream); // save uncompressed to stream
function SameAs(aReader: TZipReader): boolean;
property Map: TMemoryMap read fMap;
end;
TZipWriter = class(TZipCommon)
private
outFile: TFileStream;
fNow: integer;
fDestFileName: TFileName;
function AddEntry(const aZipName: RawUTF8; FileAge: integer = 0): PZipEntry;
public
Zip: TZipCompressor;
forceFileAge: integer; // <>0 -> will be used in Destroy to dest file
constructor Create(const aFileName: TFileName); overload;
constructor Create(AppendTo: TZipReader; ReCreate: boolean=false); overload;
constructor Create(fromStream: TStream; const DestFilename: TFileName=''); overload;
// restore after TZipReader.SaveToStream()
destructor Destroy; override;
/// this Creates a TZipCompressor -> user Zip.Write() to send data:
// if CompressionLevel<0: direct copy
procedure ZipCreate(const aZipName: RawUTF8; CompressionLevel: integer;
FileAge: integer = 0; Algorithm: integer=0);
/// compression finish, fileInfo update+save, Zip.Free;
// after ZipCreate: let aIndex=-1 will update Entry[Count]+inc(fCount)
procedure ZipClose(aIndex: integer=-1);
procedure Add(const aZipName: RawUTF8; data: PAnsiChar; dataSize: cardinal;
CompressionLevel: integer; dataCRC: pCardinal=nil;
FileAge: integer = 0; Algorithm: integer=0); overload;
procedure Add(const aZipName: RawUTF8; p: PBlobData); overload;
procedure Add(aReader: TZipReader; aReaderIndex: integer); overload;
procedure AddFile(const aFileName: TFileName; const aZipName: RawUTF8;
CompressionLevel: integer; Algorithm: integer=0);
function LastCRC32Added: cardinal;
end;
// TZip handles ZIP standard files on disk
TZip = class
private
FileQueue: TStringList;
SomeDeleted: boolean;
public
Reader: TZipReader;
Writer: TZipWriter;
constructor Create(const aFileName: TFileName);
destructor Destroy; override;
function FileName: TFileName;
function MarkDeleted(aReaderIndex: integer): boolean; virtual; // before any ZipCreate
function MarkDeletedBefore(aDate: TDateTime; aBackup: TZip=nil): boolean;
procedure BeginWriter; virtual;
function ZipCreate(const aZipName: RawUTF8; CompressionLevel: integer;
Algorithm: integer=0): TZipCompressor;
// use Zip.Write() to send data before ZipClose
procedure ZipClose;
function AddBuf(const aZipName: RawUTF8; CompressionLevel: integer;
data: pointer; dataSize: cardinal; Algorithm: integer=0): boolean;
function AddToFileQueue(const aFileName: TFileName;
const aZipName: RawUTF8): boolean; // flushed at Destroy
function SameAs(aZip: TZip): boolean;
function FileQueueCount: integer;
end;
TZipValues = class(TZip)
// store some Values[] in a .zip file (TBlob, TBlobDiff, TDC4...)
protected // all this must be overrided according to Values[]:
procedure LoadValues(data: PAnsiChar); virtual; abstract;
// SetLength(Values,Count+10); move(data,Values[0],Count*sizeof(Values[0]));
procedure SaveValues(Zip: TZipCompressor); virtual; abstract;
public
Count: integer;
modified: boolean;
constructor Create(const aFileName: TFileName); // make Reader.Create
destructor Destroy; override;
function GetValue(aReaderIndex: integer; aStream: TStream=nil): PAnsiChar;
procedure CopyValue(source, dest: integer); virtual; abstract;
// Values[dest] := Values[source];
procedure BeginWriter; override;
function MarkDeleted(aReaderIndex: integer): boolean; override; // before any AddValue
end;
var
BlobDataNull: TBlobData;
SynCompressionAlgos: TSynCompressionAlgos;
procedure CompressAsBlobData(const data; size: integer; aStream: TStream;
CompressionLevel: integer=6; Algorithm: integer=0);
// create a TBlobData in aStream - can use encryption with algo
// 7=AES+Zip-chunked and 8=AES+SynLz-chunked
function GZRead(const aFileName: TFileName): RawByteString; overload;
function GZRead(gz: PAnsiChar; gzLen: integer): RawByteString; overload;
procedure GZRead(const aFileName: TFileName; aStream: TStream; StoreLen: boolean); overload;
// direct uncompress .gz file into string or TStream
implementation
const // TZipException messages:
sZlibInternalError = 'zlib: Internal error';
sIncorrectZipFormatN = 'Incorrect zip format in file %s: %s';
sZipAlgoIDNUnknownN = 'Algo ID %d unknown for %s';
sZipCrcErrorNN = 'crc32 checksum error for %s in %s';
{ TZipCommon }
constructor TZipCommon.Create(const aFileName: TFileName);
begin
fFileName := aFileName;
end;
destructor TZipCommon.Destroy;
begin
Finalize(Entry);
inherited;
end;
function TZipCommon.ZipNameIndexOf(const aZipName: RawUTF8): integer;
begin
for result := 0 to Count-1 do
if SameTextU(Entry[result].ZipName,aZipName) then
exit;
result := -1;
end;
{ TZipReader }
procedure TZipReader.Clear;
begin
fCount := 0;
Map.UnMap;
end;
constructor TZipReader.Create(const aFileName: TFileName);
var i: integer;
lhr: ^TLastHeader;
H: ^TFileHeader;
tmp: WinAnsiString;
LastHeaderPosition: integer;
procedure Error(const msg: string);
begin
// MessageBox(0,pointer(fFileName),'Incorrect format',MB_ICONERROR);
Map.UnMap;
fCount := 0;
raise TZipException.CreateFmt(sIncorrectZipFormatN,[fFileName,msg]);
end;
begin
// 1. open aFileName
inherited; // fFileName := aFileName;
Map.Map(fFileName);
if Map.Buffer=nil then exit;
// 2. find last header, in order to reach the TFileHeader entries
if Map.Size<sizeof(lhr^) then begin
Error('file too small');
exit;
end;
lhr := @Map.Buffer[Map.Size-sizeof(lhr^)];
with lhr^ do begin
if signature<>$06054b50 then begin
Error('missing trailing signature');
exit;
end;
fCount := thisFiles;
SetLength(Entry,Count);
LastHeaderPosition := headerOffset;
end;
// 3. read all TFileHeader entries and fill Entry[] with its values
H := @Map.Buffer[LastHeaderPosition];
for i := 0 to Count-1 do
with H^ do begin
if signature<>$02014b50 then begin
Error('missing local signature');
break;
end;
if (fileInfo.flags and (1 shl 3)<>0) or // crc+sizes in "data descriptor"
(fileInfo.zzipSize=0) or (fileInfo.zfullSize=0) then begin
Error('unexpected "data descriptor"');
break; // not handled yet: use SynZip's TZipRead to access this archive
end;
with Entry[i] do begin
{$ifdef MSWINDOWS}
if FileInfo.GetUTF8FileName then
SetString(ZipName,PAnsiChar(H)+sizeof(H^),fileInfo.nameLen) else begin
SetLength(tmp,fileInfo.nameLen); // convert from DOS/OEM into WinAnsi
OemToCharBuffA(PAnsiChar(H)+sizeof(H^),pointer(tmp),fileInfo.nameLen);
ZipName := WinAnsiToUtf8(tmp);
end;
{$else}
SetString(ZipName,PAnsiChar(H)+sizeof(H^),fileInfo.nameLen);
{$endif}
ZipName := StringReplaceChars(ZipName,'/','\');
Header := H^;
end; // next entry is after the ZipNname and some extra/comment
inc(PByte(H),sizeof(H^)+fileInfo.nameLen+fileInfo.extraLen+commentLen);
end;
end;
procedure TZipReader.DeleteLastEntry;
// don't use inside TZipValues: already done in TZipValues.Create
begin
if Count<=0 then
exit;
dec(fCount);
end;
destructor TZipReader.Destroy;
begin
Map.UnMap;
inherited;
end;
function TZipReader.GetBlobData(aIndex: integer): RawByteString;
begin
result := '';
if (self=nil) or (cardinal(aIndex)>=cardinal(Count)) or (Map.Buffer=nil) then
exit;
with Entry[aIndex], LocalHeader(Map.Buffer)^ do
if not Header.IsFolder then begin
SetLength(result,fileInfo.zzipSize+BLOBDATA_HEADSIZE);
with PBlobData(result)^ do begin
SetFrom(fileInfo);
move(LocalData^,databuf,datasize);
end;
end;
end;
procedure TZipReader.GetBlobData(aIndex: integer; aStream: TStream);
// put TBlobData in aStream
var blob: TBlobData;
begin
if (self=nil) or (aIndex<0) or (aIndex>=Count) or (Map.Buffer=nil) then
aStream.WriteBuffer(BlobDataNull,BLOBDATA_HEADSIZE) else
with Entry[aIndex], LocalHeader(Map.Buffer)^ do begin
blob.SetFrom(fileInfo);
aStream.WriteBuffer(blob,BLOBDATA_HEADSIZE);
aStream.WriteBuffer(LocalData^,blob.dataSize);
end;
end;
function TZipReader.GetBuffer(aIndex: integer; out Dest: PAnsiChar): integer;
begin
result := 0;
Dest := nil;
if (self=nil) or (aIndex<0) or (aIndex>=Count) or (Map.Buffer=nil) then
exit;
with Entry[aIndex], LocalHeader(Map.Buffer)^, fileInfo do
if not Header.IsFolder then begin
result := zfullSize;
if AlgoID<>0 then begin
with AlgoCreate(LocalData,FileName) do // crc32+algo object create
try // algo registered (no TZipException raised) -> uncompress
result := UnCompressedLength(LocalData,zfullsize);
Getmem(Dest,result);
UnCompress(LocalData,zfullsize,Dest); // direct uncompress into Dest
finally
Free;
end;
exit;
end;
Getmem(Dest,zfullSize);
if zfullSize>0 then
case zzipMethod of
0: move(LocalData^,Dest^,result); // stored = direct copy
8: if (UnCompressMem(LocalData,Dest,zzipSize,zfullSize)<>integer(zfullSize)) or
(crc32(0,Dest,zfullSize)<>zcrc32) then begin
Freemem(Dest);
Dest := nil;
raise TZipException.CreateFmt(sZipCrcErrorNN,[Entry[aIndex].ZipName,FileName]);
end;
end;
end;
end;
function TZipReader.GetData(aIndex: integer; aStream: TStream=nil;
CheckCRC: boolean=false; asBlobDataStored: boolean=false; withAlgoDataLen: boolean=false): PAnsiChar;
// aStream=nil -> return bulk memory data position in mapped file
// aStream<>nil -> uncompress and un-algo into aStream; CheckCRC=true -> force check CRC
// asBlobDataStored=true -> PBlobData stored format into aStream
// withAlgoDataLen=true -> unCompressed algo length stored into aStream
var CRC: cardinal;
CRCP: PCardinal;
Blob: TBlobData;
tmp: PAnsiChar;
L: cardinal;
begin
result := nil;
if (self=nil) or (aIndex<0) or (aIndex>=Count) or (Map.Buffer=nil) then
exit;
with Entry[aIndex], LocalHeader(Map.Buffer)^ do
if not Header.IsFolder then begin
result := LocalData;
if aStream=nil then
exit; // no decompress to stream: only get result PAnsiChar [and DataLen^]
if fileInfo.AlgoID<>0 then begin // bits 7..10 are used for algo
// un-algo specific uncompression
L := GetBuffer(aIndex,tmp); // uncompress with algo (always check crc)
if tmp<>nil then
try
if asBlobDataStored then begin // algo: add uncompressed data header
Blob.dataSize := L;
Blob.dataFullSize := L;
Blob.dataCRC := crc32(0,tmp,L);
Blob.dataMethod := fileInfo.AlgoID shl 4; // 0=stored + AlgoID
aStream.WriteBuffer(Blob,BLOBDATA_HEADSIZE);
end else
if withAlgoDataLen then
aStream.WriteBuffer(L,4);
aStream.WriteBuffer(tmp^,L); // write uncompressed
finally
freemem(tmp);
end;
end else begin // standard zip format
if asBlobDataStored then begin
Blob.dataSize := FileInfo.zfullSize;
Blob.dataFullSize := FileInfo.zfullSize;
Blob.dataCRC := FileInfo.zcrc32;
Blob.dataMethod := 0; // stored, since will be uncompressed below
aStream.WriteBuffer(Blob,BLOBDATA_HEADSIZE);
end;
case fileInfo.zzipMethod of
0: begin
aStream.WriteBuffer(result^,fileInfo.zfullSize); // stored = direct copy
if CheckCRC then
CRC := crc32(0,result,fileInfo.zfullSize);
end;
8: begin // deflate
if CheckCRC then
CRCP := @CRC else CRCP := nil;
if UnCompressStream(result,fileInfo.zzipSize,aStream,CRCP)
<>fileInfo.zfullSize then result := nil;
end;
end; // case fileInfo.zzipMethod of
if CheckCRC and (CRC<>fileInfo.zcrc32) then
result := nil;
end;
end;
end;
function TZipReader.GetString(aIndex: integer): RawByteString;
begin
result := '';
if (self=nil) or (aIndex<0) or (aIndex>=Count) or (Map.Buffer=nil) then
exit;
with Entry[aIndex], LocalHeader(Map.Buffer)^, fileInfo do
if not Header.IsFolder then begin
if AlgoID<>0 then begin // special algo
with AlgoCreate(LocalData,FileName) do // crc32+algo object create
try // algo registered (no TZipException raised) -> uncompress
SetLength(result,UnCompressedLength(LocalData,zfullsize));
if UnCompress(LocalData,zfullsize,pointer(result))<> // direct uncompress into string
cardinal(length(result)) then
raise TZipException.CreateFmt(sZipCrcErrorNN,[Entry[aIndex].ZipName,FileName]);
finally
Free;
end;
end else // no algo: normal .zip file
case zzipMethod of
0: SetString(result,LocalData,zfullSize); // stored = direct copy
8: begin // deflate:
SetLength(result,zfullSize);
if (UnCompressMem(LocalData,pointer(result),zzipSize,zfullSize)<>integer(zfullSize)) or
(crc32(0,pointer(result),zfullSize)<>zcrc32) then
raise TZipException.CreateFmt(sZipCrcErrorNN,[Entry[aIndex].ZipName,FileName]);
end;
end;
end;
end;
function TZipReader.SameAs(aReader: TZipReader): boolean;
var i: integer;
begin
result := self=aReader; if result then exit;
if (self=nil) or (aReader=nil) or (Count<>aReader.Count) then
exit;
for i := 0 to Count-1 do
if not Entry[i].SameAs(aReader.Entry[i]) then
exit;
for i := 0 to Count-1 do
with Entry[i], LocalHeader(Map.Buffer)^ do
if not Header.IsFolder then
if not Comparemem(LocalData,
aReader.Entry[i].LocalHeader(aReader.Map.Buffer).LocalData,fileInfo.zzipSize) then
exit;
result := true;
end;
procedure TZipReader.SaveToStream(aStream: TStream);
var i: integer;
L: cardinal;
aName: RawUTF8;
begin
aName := StringToUTF8(ExtractFileName(fFileName));
// 1. write global params
L := length(aName);
aStream.WriteBuffer(L,1);
aStream.WriteBuffer(aName[1],L); // UTF-8 encoded file name
aStream.WriteBuffer(fCount,4);
// 2. write Entry[].ZipName
for i := 0 to Count-1 do
with Entry[i] do begin
assert(not Header.IsFolder,'empty folders streaming is not implemented');
aStream.WriteBuffer(Header.fileInfo,sizeof(Header.fileInfo));
aStream.WriteBuffer(pointer(ZipName)^,Header.fileInfo.NameLen);
end;
// 3. write all uncompressed data
for i := 0 to Count-1 do
with Entry[i] do // withAlgoDataLen=true: algo -> uncompressed length stored
GetData(i,aStream,false,false,true); // deflate and un-algo if necessary
end;
{ TZip }
function TZip.AddBuf(const aZipName: RawUTF8; CompressionLevel: integer;
data: pointer; dataSize: cardinal; Algorithm: integer=0): boolean;
var Z: TZipCompressor;
begin
if self=nil then begin
result := false;
exit;
end;
if dataSize<512 then
CompressionLevel := -1; // force store if too small
Z := ZipCreate(aZipName,CompressionLevel,Algorithm); // Z=Writer.Zip
result := Z<>nil;
if not result then exit;
Z.WriteOnce(data^,dataSize);
ZipClose;
end;
function TZip.AddToFileQueue(const aFileName: TFileName; const aZipName: RawUTF8): boolean;
// flushed at Destroy
var i: integer;
begin
result := false;
if self=nil then exit;
if Writer=nil then begin
i := Reader.ZipNameIndexOf(aZipName);
if i>=0 then
MarkDeleted(i);
end else
if Writer.ZipNameIndexOf(aZipName)>=0 then
exit;
if FileQueue=nil then
FileQueue := TStringList.Create;
FileQueue.Values[aFileName] := UTF8ToString(aZipName);
result := true;
end;
procedure TZip.BeginWriter;
begin
if (self<>nil) and (Writer=nil) then
Writer := TZipWriter.Create(Reader); // append Reader, recreate=false
end;
constructor TZip.Create(const aFileName: TFileName);
begin
Reader := TZipReader.Create(aFileName);
// Writer will be created as necessary
end;
function GetValueFromIndex(List: TStrings; Index: Integer): string;
begin // not defined before Delphi 7
if Index >= 0 then
Result := Copy(List[Index],Length(List.Names[Index])+2,MaxInt) else
Result := '';
end;
destructor TZip.Destroy;
var i, method: integer;
zipName: TFileName;
begin
ZipClose; // close pending Writer.Zip if any
if SomeDeleted and (Writer=nil) and
((FileQueue=nil) or (FileQueue.Count=0)) then
BeginWriter else
if FileQueue<>nil then
for i := 0 to FileQueue.Count-1 do begin
zipName := GetValueFromIndex(FileQueue,i);
if zipName='' then
continue;
if GetFileNameExtIndex(zipName,'zip,jpg,jpeg,gz,bz2,bZ,7z,gif,bj,bjt')>=0 then
method := -1 else // store already compressed file
method := 6; // normal deflate compression
if Writer=nil then
BeginWriter;
Writer.AddFile(FileQueue.Names[i],StringToUTF8(zipName),method);
end;
FreeAndNil(FileQueue);
FreeAndNil(Reader);
FreeAndNil(Writer);
inherited;
end;
function TZip.FileName: TFileName;
begin
if (self=nil) or (Reader=nil) then
result := '' else
result := Reader.fFileName;
end;
function TZip.FileQueueCount: integer;
begin
if FileQueue=nil then
result := 0 else
result := FileQueue.Count;
end;
function TZip.MarkDeleted(aReaderIndex: integer): boolean;
begin
result := (self<>nil)and(Writer=nil)and(aReaderIndex>=0)and(aReaderIndex<Reader.Count);
if not result then
exit;
SomeDeleted := true;
//if aReaderIndex=Reader.Count-1 then Reader.DeleteLastEntry else !TZipValues use signature!
Reader.Entry[aReaderIndex].Header.signature := 0; // just signature = 0 to delete
end;
{$ifndef MSWINDOWS}
function DateTimeToFileDateWindows(DateTime: TDateTime): Integer;
var
Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
DecodeDate(DateTime, Year, Month, Day);
if (Year < 1980) or (Year > 2107) then
Result := 0 else begin
DecodeTime(DateTime, Hour, Min, Sec, MSec);
LongRec(Result).Lo := (Sec shr 1) or (Min shl 5) or (Hour shl 11);
LongRec(Result).Hi := Day or (Month shl 5) or ((Year - 1980) shl 9);
end;
end;
function NowToFileDateWindows: Integer;
begin
result := DateTimeToFileDateWindows(Now);
end;
{$endif}
function TZip.MarkDeletedBefore(aDate: TDateTime; aBackup: TZip=nil): boolean;
var dt, i: integer;
begin
result := false;
if (self=nil) or (Writer<>nil) then
exit;
dt := {$ifdef MSWINDOWS}DateTimeToFileDate{$else}DateTimeToFileDateWindows{$endif}(aDate);
for i := 0 to Reader.Count-1 do
with Reader.Entry[i].Header do
if (signature<>0) and (fileInfo.zlastMod<dt) then begin
if aBackup<>nil then begin
aBackup.BeginWriter;
aBackup.Writer.Add(Reader,i);
end;
MarkDeleted(i);
result := true;
end;
end;
function TZip.SameAs(aZip: TZip): boolean;
begin
result := self=aZip;
if result then
exit;
if (self=nil) or (aZip=nil) then
exit;
assert(Writer=nil);
if Writer<>nil then
exit;
result := Reader.SameAs(aZip.Reader);
end;
procedure TZip.ZipClose;
begin
if (self=nil) or (Writer=nil) then exit;
Writer.ZipClose;
end;
function TZip.ZipCreate(const aZipName: RawUTF8; CompressionLevel: integer;
Algorithm: integer=0): TZipCompressor;
// use TZipCompressor.Write() to send data - CompressionLevel<0 -> force store
var i: integer;
ZipName: string;
begin
result := nil;
if self=nil then exit;
if Writer=nil then begin
i := Reader.ZipNameIndexOf(aZipName);
if (i>=0) then
MarkDeleted(i);
end else
if Writer.ZipNameIndexOf(aZipName)>=0 then
exit;
if FileQueue<>nil then begin
ZipName := UTF8ToString(aZipName);
for i := 0 to FileQueue.Count-1 do
if GetValueFromIndex(FileQueue,i)=ZipName then begin
FileQueue.Delete(i);
break;
end;
end;
BeginWriter;
if Writer.Zip<>nil then
exit;
Writer.ZipCreate(aZipName,CompressionLevel,0,Algorithm);
result := Writer.Zip;
end;
{ TCompressorDecompressor }
constructor TZipCompressor.Create(outStream: TStream; CompressionLevel, Algorithm: Integer);
var Algo: TSynCompressionAlgoClass;
begin
fDestStream := outStream;
fBlobDataHeaderPosition := -1; // not AsBlobData
StreamInit(FStrm);
FStrm.next_out := @FBufferOut;
FStrm.avail_out := SizeOf(FBufferOut);
FStrm.next_in := @FBufferIn;
if Algorithm<>0 then begin
Algo := SynCompressionAlgos.Algo(Algorithm);
if not Assigned(Algo) then // unknown algo -> error
raise TZipException.CreateFmt(sZipAlgoIDNUnknownN,[Algorithm,ClassName]);
fAlgorithm := Algo.Create;
fAlgorithmID := Algorithm;
fAlgorithm.CompressInit(fDestStream);
if SynCompressionAlgos.WholeAlgoID(Algorithm)=Algorithm then
// whole algo = not a 64KB chunked algo
fAlgorithmStream := THeapMemoryStream.Create; // create temp buffer
end else begin
if CompressionLevel>=0 then // FInitialized=false -> direct copy to FDestStream
fInitialized := Check(deflateInit2_(FStrm, CompressionLevel, Z_DEFLATED,
-MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY,ZLIB_VERSION, sizeof(FStrm)),
[Z_OK])=Z_OK; // -MAX_WBITS -> no zLib header => .zip compatible !
end;
end;
constructor TZipCompressor.CreateAsBlobData(outStream: TStream;
CompressionLevel, Algorithm: Integer);
begin
Create(outStream,CompressionLevel,Algorithm);
fBlobDataHeaderPosition := outStream.Seek(0,soCurrent);
outStream.WriteBuffer(FBufferOut,BLOBDATA_HEADSIZE); // save Bulk header
end;
destructor TZipCompressor.Destroy;
var p: Int64;
blob: TBlobData;
begin
if FInitialized then begin
FStrm.next_out := nil;
FStrm.avail_out := 0;
deflateEnd(FStrm);
end else begin
FreeAndNil(fAlgorithmStream);
FreeAndNil(fAlgorithm);
end;
if fBlobDataHeaderPosition>=0 then begin // CreateAsBlobData() -> update header
p := fDestStream.Seek(0,soCurrent);
with blob do begin
dataFullSize := SizeIn;
dataSize := p-fBlobDataHeaderPosition-BLOBDATA_HEADSIZE;
assert(dataSize=SizeOut);
dataCRC := CRC;
// dataMethod: 0=stored 8=inflate >16: AlgoID=dataMethod shr 4
if FInitialized then
dataMethod := 8 else
dataMethod := fAlgorithmID shl 4; // stored + AlgoID
end;
fDestStream.Seek(fBlobDataHeaderPosition,soBeginning);
fDestStream.WriteBuffer(blob,BLOBDATA_HEADSIZE);
fDestStream.Seek(p,soBeginning);
end;
inherited;
end;
procedure TZipCompressor.Finish;
begin
if (self=nil) then exit;
if assigned(fAlgorithm) then begin
if assigned(fAlgorithmStream) then begin
fAlgorithmStream.WriteBuffer(fBufferIn,fStrm.avail_in); // write pending data
fStrm.total_in := fAlgorithm.Compress( // compress whole data at once
fAlgorithmStream.Memory,fAlgorithmStream.Seek(0,soCurrent),@fCRC);
end else
if FStrm.avail_in>0 then
inc(fStrm.total_in,fAlgorithm.Compress(@fBufferIn,FStrm.avail_in,@fCRC));
inc(fStrm.total_in,fAlgorithm.CompressFinish); // finish compression
fStrm.total_out := fStrm.total_in; // .zip file compression mode = stored
exit;
end;
if not FInitialized then
exit;
while FStrm.avail_in > 0 do begin // compress pending data
if InFlateDeflate then
raise TZipException.Create(SZlibInternalError);
if FStrm.avail_out = 0 then
FlushBufferOut;
end;
FStrm.next_in := nil;
FStrm.avail_in := 0;
while (Check(deflate(FStrm, Z_FINISH), [Z_OK, Z_STREAM_END]) <> Z_STREAM_END) and
(FStrm.avail_out = 0) do
FlushBufferOut;
FlushBufferOut;
end;
function TZipCompressor.FlushBufferOut: integer;
begin
Result := 0;
if not FInitialized then
exit;
if FStrm.avail_out < SizeOf(FBufferOut) then begin
Result := SizeOf(FBufferOut) - FStrm.avail_out;
FDestStream.WriteBuffer(FBufferOut, Result);
FStrm.next_out := @FBufferOut;
FStrm.avail_out := SizeOf(FBufferOut);
end;
end;
function TZipCompressor.GetSizeIn: cardinal;
begin
result := FStrm.total_in;
end;
function TZipCompressor.GetSizeOut: cardinal;
begin
result := FStrm.total_out;
end;
function TZipCompressor.InFlateDeflate: boolean;
begin
Result := Check(deflate(FStrm, Z_NO_FLUSH), [Z_OK])<>Z_OK;
end;
function TZipCompressor.Read(var Buffer; Count: Longint): Longint;
begin
assert(false);
result := 0;
end;
function TZipCompressor.Seek(Offset: Longint; Origin: Word): Longint;
begin
if not FInitialized then // CompressionLevel<0: direct copy to
result := 0 else
if (Offset = 0) and (Origin = soFromCurrent) then // for TStream.Position
if assigned(fAlgorithmStream) then
Result := fAlgorithmStream.Seek(0,soFromCurrent) else
Result := FStrm.total_in else begin
Result := 0;
assert((Offset = 0) and (Origin = soFromBeginning) and (FStrm.total_in = 0));
end;
end;
function TZipCompressor.Write(const Buffer; Count: integer): integer;
begin
if self<>nil then begin
result := Count;
if FInitialized then begin
if Count=0 then exit;
fCRC := crc32(fCRC,@Buffer,Count);
if cardinal(Count)+FStrm.avail_in>sizeof(fBufferIn)-1 then begin
while FStrm.avail_in > 0 do begin
if InflateDeflate then
raise TZipException.Create(SZlibInternalError);
if FStrm.avail_out = 0 then
FlushBufferOut;
end;
FStrm.avail_in := 0;
FStrm.next_in := @fBufferIn;
end;
if Count<sizeof(fBufferIn) then begin
move(Buffer,fBufferIn[FStrm.avail_in],Count);
inc(FStrm.avail_in,Count);
end else begin
FStrm.avail_in := Count;
FStrm.next_in := @Buffer;
while FStrm.avail_in > 0 do begin
if InFlateDeflate then
raise TZipException.Create(SZlibInternalError);
if FStrm.avail_out = 0 then
FlushBufferOut;
end;
FStrm.avail_in := 0;
FStrm.next_in := @fBufferIn;
end;
end else begin // if not FIinitialized: CompressionLevel<0: direct copy to
if Count=0 then exit;
if Assigned(fAlgorithmStream) then begin
// algo -> copy into fAlgorithmStream by fBufferIn[] chunks
if cardinal(Count)+FStrm.avail_in>sizeof(fBufferIn)-1 then begin
fAlgorithmStream.WriteBuffer(fBufferIn,fStrm.avail_in); // flush buffer
FStrm.avail_in := 0;
FStrm.next_in := @fBufferIn;
end;
if Count<sizeof(fBufferIn) then begin // small block -> in fBufferIn[]
move(Buffer,fBufferIn[FStrm.avail_in],Count);
inc(FStrm.avail_in,Count);
end else
fAlgorithmStream.WriteBuffer(Buffer,Count); // big block -> direct store
end else
if Assigned(fAlgorithm) then begin
// algo without fAlgorithmStream -> direct compress in fBufferIn[] chunks
FStrm.next_out := @Buffer;
repeat
FStrm.avail_out := sizeof(fBufferIn)-FStrm.avail_in;
if cardinal(Count)<=FStrm.avail_out then begin // count fit in fBufferIn[]
move(FStrm.next_out^,fBufferIn[FStrm.avail_in],Count); // -> copy bytes
inc(FStrm.avail_in,Count);
break;
end else begin // Count too big for fBufferIn[] -> compress chunk
if FStrm.avail_in=0 then begin // direct compress from buffer
inc(fStrm.total_in,fAlgorithm.Compress(FStrm.next_out,sizeof(fBufferIn),@fCRC));
inc(FStrm.next_out,sizeof(fBufferIn));
dec(Count,sizeof(fBufferIn));
end else begin // compress with data already in fBufferIn[]
move(FStrm.next_out,fBufferIn[FStrm.avail_in],FStrm.avail_out);
inc(fStrm.total_in,fAlgorithm.Compress(@fBufferIn,sizeof(fBufferIn),@fCRC));
FStrm.avail_in := 0;
FStrm.next_in := @fBufferIn;
inc(FStrm.next_out,FStrm.avail_out);
dec(Count,FStrm.avail_out);
end;
end;
until Count=0;
end else begin
// normal store -> direct copy to fDestStream
inc(FStrm.total_in,Count);
inc(FStrm.total_out,Count);
fCRC := crc32(fCRC,@Buffer,Count);
fDestStream.WriteBuffer(Buffer,Count);
end;
end;
end else
result := 0; // self=nil
end;
function TZipCompressor.WriteOnce(const Buffer; Count: Integer): Longint;
// same as Write, but optimized for one call of Write()
begin
if Count=0 then
result := Count else
if Assigned(fAlgorithmStream) then begin // whole: avoid fAlgorithmStream use
FreeAndNil(fAlgorithmStream); // very fast, since memory already allocated=0
result := fAlgorithm.Compress(@Buffer,Count,@fCRC)+fAlgorithm.CompressFinish;
fStrm.total_in := result;
end else
result := Write(Buffer,Count);
end;
{ TGzWriter }
constructor TGzWriter.Create(const aFileName: TFileName);
begin
if FileExists(aFilename) then begin
Create(TFileStream.Create(aFileName,fmOpenWrite));
outFile.Size := outFile.Position;
end else
Create(TFileStream.Create(aFileName,fmCreate));
outFileToBeFree := true;
end;
constructor TGzWriter.Create(const aDestStream: TStream);
const gzheader : array [0..2] of cardinal = ($88B1F,0,0);
begin
outFile := aDestStream;
outFile.WriteBuffer(gzHeader,10);
inherited Create(outFile, 6);
end;
destructor TGzWriter.Destroy;
begin
Finish;
outFile.WriteBuffer(CRC,4);
outFile.WriteBuffer(FStrm.total_in,4);
if outFileToBeFree then
FreeAndNil(outFile);
inherited;
end;
function GZRead(const aFileName: TFileName): RawByteString; overload;
var Map: TMemoryMap;
begin
if not Map.Map(aFileName) then
result := '' else
try
result := SynZipFiles.GzRead(pointer(Map.Buffer),Map.Size);
finally
Map.UnMap;
end;
end;
function GZRead(gz: PAnsiChar; gzLen: integer): RawByteString; overload;
var Len: integer;
begin
if PCardinal(gz)^<>$88B1F then
SetString(result,gz,gzLen) else begin
Len := pInteger(@gz[gzLen-4])^;
assert(Len>=0);
SetString(result,nil,Len);
UnCompressMem(@gz[10],pointer(result),gzLen-18,Len);
end;
end;
procedure GZRead(const aFileName: TFileName; aStream: TStream; StoreLen: boolean); overload;
// just add an ungz file contents, storing len:Integer first if StoreLen=true
var Map: TMemoryMap;
Len: integer;
begin
if not Map.Map(aFileName) then begin
if StoreLen then
aStream.WriteBuffer(Map.Buffer,4); // no file -> store len=0
end else
try
if PCardinal(Map.Buffer)^<>$88B1F then begin
if StoreLen then
aStream.WriteBuffer(Map.Size,4);
aStream.WriteBuffer(Map.Buffer^,Map.Size); // not a .gz -> store as is
end else begin
Len := pInteger(@Map.Buffer[Map.Size-4])^; // .gz -> uncompress
assert(Len>=0);
if StoreLen then
aStream.WriteBuffer(Len,4);
UnCompressStream(@Map.Buffer[10],Map.Size-18,aStream,nil);
end;
finally
Map.UnMap;
end;
end;
{ TZipWriter }
constructor TZipWriter.Create(AppendTo: TZipReader; ReCreate: boolean=false);
procedure InitTmp;
begin
fDestFileName := AppendTo.fFileName;
fFileName := ChangeFileExt(fDestFileName,'.tmp');
outFile := TFileStream.Create(fFileName,fmCreate);
end;
var i, firstDeleted: integer;
posi: PtrUInt;
begin
fNow := {$ifdef MSWINDOWS}DateTimeToFileDate{$else}DateTimeToFileDateWindows{$endif}(Now);
if AppendTo=nil then
exit;
SetLength(Entry,AppendTo.Count+32);
if ReCreate then begin // force full file recreate from AppendTo data
InitTmp;
// don't call AppendTo.Map.UnMap since we will need to read the data!
exit; // all the data will be copied from AppendTo.Map manually by caller
end;
firstDeleted := -1;
for i := 0 to AppendTo.Count-1 do
if AppendTo.Entry[i].Header.signature<>0 then begin // file not deleted
Entry[Count] := AppendTo.Entry[i]; // -> add Entry[]
inc(fCount);
end else // file deleted
if firstDeleted<0 then // -> update first deleted index
firstDeleted := i;
if (Count=0) then begin
// nothing to read from old file -> just reopen
AppendTo.Map.UnMap;
fFileName := AppendTo.fFileName;
DeleteFile(fFileName); // avoid win32 bug if filesize=0
outFile := TFileStream.Create(fFileName,fmCreate);
end else
if (Count=AppendTo.Count) or (firstDeleted=AppendTo.Count-1) then begin
// no delete or only the last one: append to end of file
fFileName := AppendTo.fFileName;
if AppendTo.Map.Buffer=nil then // AppendTo file doesn't exists
outFile := TFileStream.Create(fFileName,fmCreate) // new void file
else begin // AppendTo file exists
with AppendTo.Entry[Count-1] do
posi := LocalDataPosition(AppendTo.Map.Buffer)+Header.fileInfo.zzipSize;
AppendTo.Map.UnMap; // outFile seek to end of AppendTo file data
outFile := TFileStream.Create(fFileName,fmOpenReadWrite);
outFile.Position := posi;
end;
end else begin
// some deleted: copy entries from mapped file to .tmp file
InitTmp;
fCount := 0; // recreate Entry[] in Add(AppendTo,i) below
for i := 0 to AppendTo.Count-1 do
if AppendTo.Entry[i].Header.signature<>0 then
Add(AppendTo,i); // add not deleted entries
AppendTo.Map.UnMap; // we won't use AppendTo any more
end;
end;
constructor TZipWriter.Create(fromStream: TStream; const DestFileName: TFileName='');
// used to restore data uncompressed+bz-compressed with TZipReader.SaveToStream()
var i, sign: integer;
L, srcLen: cardinal;
src: pointer; // temporary buffer for CompressMem
aAlgo, wAlgo: integer;
fromMemory: PAnsiChar;
begin
fNow := {$ifdef MSWINDOWS}DateTimeToFileDate{$else}DateTimeToFileDateWindows{$endif}(Now);
// 1. read global params
L := 0;
fromStream.Read(L,1);
if DestFileName<>'' then begin
fFileName := DestFileName;
fromStream.Seek(L,soCurrent); // ignore file name stored in fromStream
end else begin
SetLength(fFileName,L);
fromStream.Read(fFileName[1],L); // fromStream -> dest file name
end;
fromStream.Read(fCount,4);
// 2. read Entry[]
SetLength(Entry,fCount);
for i := 0 to Count-1 do
with Entry[i] do begin
Header.Init; // signature, madeBy, extFileAttr init
fromStream.Read(Header.FileInfo,sizeof(Header.fileInfo));
SetLength(ZipName,Header.FileInfo.nameLen);
fromStream.Read(ZipName[1],Header.FileInfo.nameLen);
end;
// 3. read and recompress all data
outFile := TFileStream.Create(fFileName,fmCreate);
if fromStream.InheritsFrom(TMemoryStream) then
fromMemory := PAnsiChar(TMemoryStream(fromStream).Memory)+
fromStream.Seek(0,soCurrent) else
fromMemory := nil;
srcLen := 0;
src := nil;
for i := 0 to Count-1 do
with Entry[i],Header.fileInfo do begin
Header.localHeadOff := outFile.Position; // position can change, as we recompress
sign := $04034b50; outFile.WriteBuffer(sign,4); // write .zip fileinfo signature
aAlgo := AlgoID;
if (aAlgo<>0) or (zzipMethod=8) then begin // reuse same compression/algo
// special ZipCreate(), without AddEntry():
if aAlgo<>0 then begin // reuse same algo
wAlgo := SynCompressionAlgos.WholeAlgoID(aAlgo); // whole algo is prefered here
if wAlgo<>0 then begin
aAlgo := wAlgo;
Header.fileInfo.SetAlgoID(aAlgo); // update Header.fileInfo.flags
end;
end;
Zip := TZipCompressor.Create(outFile, 6, aAlgo);
outFile.WriteBuffer(neededVersion,sizeof(Header.fileInfo)); // save bulk fileInfo
outFile.WriteBuffer(ZipName[1],nameLen);
if fromMemory<>nil then begin
Zip.WriteOnce(fromMemory[4],pInteger(fromMemory)^); // direct recompress using algo
L := pInteger(fromMemory)^+4;
inc(fromMemory,L); // jump uncompressed data
fromStream.Seek(L,soCurrent); // synchronize fromStream position
end else begin
fromStream.Read(L,4); // SaveStream(..,withAlgoDataLen=true)
if L>srcLen then begin
if srcLen<>0 then
Freemem(src); // Freemem+Getmem is better than Reallocmem (no move)
srcLen := succ(L shr 12) shl 12; // 4KB size boundary
Getmem(src,srcLen);
end;
fromStream.Read(src^,L); // read uncompressed data
Zip.WriteOnce(src^,L); // recompress using algo
end;
ZipClose(i); // fileInfo update+Zip.Free; aIndex>=0 -> no inc(fCount)
end else begin
assert(zzipMethod=0);
zzipSize := zfullSize;
outFile.WriteBuffer(neededVersion,sizeof(Header.fileInfo)); // save new fileInfo
outFile.WriteBuffer(ZipName[1],nameLen);
outFile.CopyFrom(fromStream,zzipSize);
end;
end;
end;
constructor TZipWriter.Create(const aFileName: TFileName);
begin
fNow := {$ifdef MSWINDOWS}DateTimeToFileDate{$else}DateTimeToFileDateWindows{$endif}(Now);
SetLength(Entry,100);
fFileName := aFileName;
outFile := TFileStream.Create(fFileName,fmCreate);
end;
destructor TZipWriter.Destroy;
var i: integer;
lhr: TLastHeader;
begin
if not Assigned(outFile) then begin // an error occured during outfile creation
inherited; // -> just free memory and leave
exit;
end;
// 1. prepare last header
with lhr do begin
signature := $06054b50;
thisDisk := 0;
headerDisk := 0;
thisFiles := Count;
totalFiles := Count;
headerSize := 0;
headerOffset := outFile.seek(0,soCurrent); // position of file entries
commentLen := 0;
end;
// 2. write file entries from Entry[]
for i := 0 to Count-1 do
with Entry[i] do begin
inc(lhr.headerSize, sizeOf(TFileHeader)+length(ZipName));
outFile.WriteBuffer(Header,sizeof(TFileHeader));
outFile.WriteBuffer(ZipName[1],length(ZipName));
end;
// 3. write last header
outFile.WriteBuffer(lhr,sizeof(lhr));
// 4. truncate and close file
{$ifdef KYLIX3}
ftruncate(outFile.Handle, outFile.seek(0,soFromCurrent));
{$else}
SetEndOfFile(outFile.Handle);
{$endif}
if forceFileAge<>0 then
FileSetDate(outFile.Handle,forceFileAge);
outFile.Free;
// 5. if we worked on a .tmp file (recreated from a TZipReader) -> make it new
if fDestFileName<>'' then begin
if not DeleteFile(fDestFileName) then begin
SleepHiRes(100);
if not DeleteFile(fDestFileName) then assert(false); end;
RenameFile(fFileName,fDestFileName); // '.tmp' -> '.bjt' ou '.zip'
end;
// 6. free memory: Finalize(Entry)
inherited;
end;
procedure TZipWriter.AddFile(const aFileName: TFileName; const aZipName: RawUTF8;
CompressionLevel: integer; Algorithm: integer=0);
// direct compress or store of a file content, using memory mapped file
var Map: TMemoryMap;
begin
if not Map.Map(aFileName) then exit;
if Map.Size<64 then
CompressionLevel := -1; // store if too small
ZipCreate(aZipName,CompressionLevel,0,Algorithm); // initialize Zip object
Entry[Count].Header.fileInfo.zlastMod :=
{$ifdef MSWINDOWS}FileGetDate(Map.FileHandle){$else}
DateTimeToFileDateWindows(FileDateToDateTime(FileGetDate(Map.FileHandle))){$endif};
Zip.WriteOnce(Map.Buffer^,Map.Size);
Map.UnMap;
ZipClose;
end;
procedure TZipWriter.Add(const aZipName: RawUTF8;
data: PAnsiChar; dataSize: cardinal; CompressionLevel: integer;
dataCRC: pCardinal=nil; FileAge: integer = 0; Algorithm: integer=0);
begin
if (self<>nil) and (aZipName<>'') then
if (CompressionLevel<0) and (Algorithm=0) then
with AddEntry(aZipName,FileAge)^.Header,FileInfo do begin
zzipSize := dataSize;
zfullSize := dataSize;
if dataCRC<>nil then
zcrc32 := dataCRC^ else
zcrc32 := crc32(0,data,dataSize);
outFile.WriteBuffer(fileInfo,sizeof(fileInfo));
outFile.WriteBuffer(aZipName[1],length(aZipName));
outFile.WriteBuffer(data^,dataSize);
inc(fCount);
end else begin
ZipCreate(aZipName,CompressionLevel,FileAge,Algorithm);
Zip.WriteOnce(data^,dataSize);
ZipClose; // fileInfo update+save, Zip.Free, inc(Count)
end;
end;
procedure TZipWriter.Add(const aZipName: RawUTF8; p: PBlobData);
begin
with AddEntry(aZipName)^.Header,FileInfo do begin
if p^.AlgoID=0 then begin
zzipMethod := p^.dataMethod;
zzipSize := p^.dataSize;
zfullSize := p^.dataFullSize;
zcrc32 := p^.dataCRC;
end else
if Assigned(SynCompressionAlgos.Algo(p^.AlgoID)) then
SetAlgoID(p^.AlgoID) else
raise TZipException.CreateFmt(sZipAlgoIDNUnknownN,[p^.AlgoID,aZipName]);
outFile.WriteBuffer(fileInfo,sizeof(fileInfo));
outFile.WriteBuffer(aZipName[1],length(aZipName));
outFile.WriteBuffer(p^.databuf,p^.dataSize);
inc(fCount);
end;
end;
procedure TZipWriter.Add(aReader: TZipReader; aReaderIndex: integer);
// this copy directly from a TZipReader
var sign: integer;
E: PZipEntry;
begin
if (aReader=nil) or (aReaderIndex<0) or (aReaderIndex>=aReader.Count) then
exit;
if Count=length(Entry) then
SetLength(Entry,Count+100);
with Entry[Count] do begin
E := @aReader.Entry[aReaderIndex];
ZipName := E^.ZipName; // may be different after delete or new
Header := E^.Header; // direct whole header copy
with Header do begin // update Entry[Count]:
fileInfo.nameLen := length(ZipName); // recalc length, as may be updated
localHeadOff := outFile.Position; // only changed data = position in file
sign := $04034b50; outFile.Write(sign,4);
outFile.WriteBuffer(fileInfo,sizeof(fileInfo)); // save new fileInfo
outFile.WriteBuffer(ZipName[1],fileInfo.nameLen); // append file name
outFile.WriteBuffer(E^.LocalHeader(aReader.Map.Buffer).LocalData^,fileInfo.zzipSize); // data copy
end;
end;
inc(fCount);
end;
procedure TZipWriter.ZipClose(aIndex: integer=-1);
// compression finish, fileInfo update+save, Zip.Free
// after ZipCreate: aIndex=-1 -> update Entry[Count] + inc(Count)
// in TZipWriter.Create(fromStream..): aIndex>=0 -> update Entry[aIndex] only
var p: cardinal;
i: integer;
begin
if Zip=nil then exit;
Zip.Finish;
if aIndex<0 then
i := Count else
i := aIndex;
with Entry[i] do begin
Header.fileInfo.zcrc32 := Zip.CRC;
Header.fileInfo.zfullSize := Zip.SizeIn; // if algo -> SizeIn=SizeOut
if Zip.FInitialized then
Header.fileInfo.zzipSize := Zip.SizeOut else
Header.fileInfo.zzipSize := Header.fileInfo.zfullSize;
p := outFile.Seek(0,soCurrent);
outFile.Seek(Header.localHeadOff+sizeof(dword),soBeginning);
outFile.WriteBuffer(Header.fileInfo,sizeof(Header.fileInfo)); // save updated fileInfo
outFile.Seek(p,soBeginning);
end;
FreeAndNil(Zip);
if aIndex<0 then
inc(fCount);
end;
procedure TZipWriter.ZipCreate(const aZipName: RawUTF8;
CompressionLevel: integer; FileAge: integer = 0; Algorithm: integer=0);
begin
assert(Zip=nil);
with AddEntry(aZipName,FileAge)^.Header do begin
if Algorithm>0 then
fileInfo.SetAlgoID(Algorithm) else
if CompressionLevel>=0 then
fileInfo.zzipMethod := 8;
Zip := TZipCompressor.Create(outFile, CompressionLevel,Algorithm);
outFile.WriteBuffer(fileInfo,sizeof(fileInfo)); // save bulk fileInfo
outFile.WriteBuffer(aZipName[1],length(aZipName));
// now the caller will use Zip.Write to compress data into outFile
// and will end compression with ZipClose
end;
end;
function TZipWriter.AddEntry(const aZipName: RawUTF8; FileAge: integer = 0): PZipEntry;
var sign: integer;
tmp: WinAnsiString;
begin
if Count=length(Entry) then
SetLength(Entry,Count+100);
result := @Entry[Count];
with result^ do begin
Header.Init; // signature, madeBy, extFileAttr, fileInfo.neededVersion init
{$ifdef MSWINDOWS}
if IsWinAnsiU(pointer(aZipName)) then begin
// Win-Ansi code page -> encode as DOS/OEM charset (old format)
tmp := Utf8ToWinAnsi(aZipName);
SetLength(ZipName,length(tmp));
CharToOemBuffA(pointer(tmp),pointer(ZipName),length(tmp));
end else
{$endif} // Linux will use only UTF-8 encoding
begin
ZipName := aZipName;
Header.fileInfo.SetUTF8FileName; // mark file name is UTF-8 encoded
end;
with Header do begin
localHeadOff := outFile.Position;
with fileInfo do begin
if FileAge=0 then
zlastMod := fNow else
zlastMod := FileAge;
nameLen := length(ZipName);
end;
end;
end;
sign := $04034b50; outFile.WriteBuffer(sign,sizeof(dword));
end;
function TZipWriter.LastCRC32Added: cardinal;
begin
if Count>0 then
result := Entry[Count-1].Header.fileInfo.zcrc32 else
result := 0;
end;
{ TZipValues }
procedure TZipValues.BeginWriter;
var i: integer;
begin
if Writer<>nil then exit;
Modified := true;
Count := 0;
for i := 0 to Reader.Count-1 do // update Values[] with MarkDeleted
if Reader.Entry[i].Header.signature<>0 then begin
CopyValue(i,Count);
inc(Count);
end;
inherited BeginWriter; // Writer := TZipWriter.Create(Reader) = calc MarkDeleted
assert(Writer.Count=Count);
end;
constructor TZipValues.Create(const aFileName: TFileName);
var n: integer;
begin
inherited Create(aFileName); // Reader := TZipReader.Create
n := Reader.Count-1; // '-index-' must be last Entry[n] -> otherwise gap in Values[]
if n=0 then
Reader.Clear; // must contains at least: Values[0] + '-index-'
if n<1 then exit;
with Reader.Entry[n] do // read Values[] from last Entry[]:
if (ZipName='-index-') and (Header.fileInfo.zzipMethod=0) then begin
Count := n;
LoadValues(LocalHeader(Reader.Map.Buffer).LocalData);
Reader.DeleteLastEntry; // ignore '-index-' from now
end else begin
Count := 0;
Assert(false,'wrong file format for '+FileName);
end;
end;
destructor TZipValues.Destroy;
begin
if Modified and (Count>0) then begin
BeginWriter; // will truncate to the last block
with Writer do begin
ZipCreate('-index-',-1);
SaveValues(Zip);
ZipClose;
end;
end;
inherited;
end;
function TZipValues.GetValue(aReaderIndex: integer; aStream: TStream): PAnsiChar;
begin
if Writer<>nil then
result := nil else
result := Reader.GetData(aReaderIndex,aStream);
end;
function TZipValues.MarkDeleted(aReaderIndex: integer): boolean;
begin
if aReaderIndex<0 then begin
result := false;
exit;
end;
Modified := true;
result := inherited MarkDeleted(aReaderIndex);
end;
{ TBlobData }
procedure CompressAsBlobData(const data; size: integer; aStream: TStream;
CompressionLevel: integer=6; Algorithm: integer=0);
// create a TBlobData in aStream (encryption algo: 6=AES 7=AES+Zip 8=AES+SynLz)
begin
with TZipCompressor.CreateAsBlobData(aStream,CompressionLevel,Algorithm) do
try
Write(data,size);
Finish;
finally
Free;
end;
end;
{ use algo 6=AES 7=AES+Zip-chunked 8=AES+SynLz-chunked
function CompressAsBlobData(data: PAnsiChar; size: integer;
AESKey: pointer=nil; AESKeySize: integer=0): string;
// optional AES-encrypt AFTER compression -> 0% ZIP compatible but security safe
begin
SetLength(result,sizeof(TBlobData)+(size*11)div 10+12);
with PBlobData(pointer(result))^ do begin
dataFullSize := size;
dataCRC := crc32(0,data,size);
dataSize := CompressMem(data,@dataBuf,size,length(result)-sizeof(TBlobData));
if dataSize>=dataFullSize then begin // compress only if efficient
dataMethod := 0; // store
dataSize := dataFullSize;
if (AESKey<>nil) and (AESKeySize>0) then
AES(AESKey^,AESKeySize,data,@databuf,dataSize,true) else
move(data^,databuf,dataSize);
end else begin
dataMethod := 8;
if (AESKey<>nil) and (AESKeySize>0) then
AES(AESKey^,AESKeySize,@databuf,@databuf,dataSize,true);
end;
SetLength(result,dataSize+BLOBDATA_HEADSIZE);
end;
end;}
function TBlobData.AlgoCreate(data: pointer): TSynCompressionAlgo;
// test if algo is registered, perform crc32 check and create one instance
var Algo: TSynCompressionAlgoClass;
begin
if DataMethod<15 then
result := nil else begin
Algo := SynCompressionAlgos.Algo(AlgoID); // registered?
if not Assigned(Algo) then // error: unregistered algo
raise TZipException.CreateFmt(sZipAlgoIDNUnknownN,[
AlgoID,'TBlobData']);
if crc32(0,data,dataFullSize)<>dataCRC then // always check integrity
raise TZipException.CreateFmt(sZipCrcErrorNN,[IntToStr(AlgoID),'TBlobData']);
result := Algo.Create; // create algo instance
end;
end;
function TBlobData.AlgoID: cardinal;
begin
// 0=stored 8=inflate >=16: AlgoID=dataMethod shr 4
result := (dataMethod shr 4) and 15;
end;
function TBlobData.Expand: RawByteString;
begin
case DataMethod of // 0=stored 8=inflate >16: AlgoID=dataMethod shr 4
16..31:
with AlgoCreate(@dataBuf) do // crc32+algo object create
try
SetString(result,nil,UnCompressedLength(@dataBuf,dataFullSize));
UnCompress(@dataBuf,dataFullSize,pointer(result));
finally
Free;
end;
8: begin
SetString(result,nil,dataFullSize);
if (UnCompressMem(
@dataBuf,pointer(result),dataSize,dataFullSize)<>integer(dataFullSize)) or
(crc32(0,pointer(result),dataFullSize)<>dataCRC) then begin
assert(false);
result := '';
end;
end;
0: if dataSize=0 then
result := '' else
SetString(result,PAnsiChar(@dataBuf),dataSize);
else begin
assert(false); // impossible dataMethod -> probably bad PBlobData
result := '';
end;
end;
end;
function TBlobData.ExpandBuf(out destSize: cardinal): pointer;
// uncompress and alloc memory if necessary (i.e. DataMethod<>0);
// no direct AES since may be mapped and DataMethod=0
begin
case DataMethod of // 0=stored 8=inflate >16: AlgoID=dataMethod shr 4
16..31:
with AlgoCreate(@dataBuf) do // crc32+algo object create
try
destsize := UnCompressedLength(@dataBuf,dataFullSize);
Getmem(result,destSize);
UnCompress(@dataBuf,dataFullSize,result);
finally
Free;
end;
0: result := @dataBuf;
8: begin
GetMem(result,dataFullSize);
if (UnCompressMem(@dataBuf,result,dataSize,dataFullSize)<>integer(dataFullSize)) or
(crc32(0,result,dataFullSize)<>dataCRC) then begin
Freemem(result);
assert(false);
result := nil;
end;
end;
else begin
assert(false); // impossible dataMethod -> probably bad PBlobData
result := nil;
end;
end;
end;
procedure TBlobData.ExpandStream(Stream: TStream);
var tmp: RawByteString;
begin
case DataMethod of
16..31: begin
tmp := Expand;
Stream.WriteBuffer(pointer(tmp)^,length(tmp));
end;
0: Stream.WriteBuffer(dataBuf,dataFullsize);
8: UnCompressStream(@dataBuf,dataSize,Stream,nil);
else assert(false);
end;
end;
function TBlobData.Next: PAnsiChar;
{$ifdef PUREPASCAL}
begin
result := PAnsiChar(@databuf)+dataSize;
end;
{$else} {$ifdef FPC} nostackframe; assembler; {$endif}
asm
lea ecx,[eax+TBlobData.databuf]
mov eax,[eax].TBlobData.datasize
add eax,ecx
end;
{$endif}
procedure TBlobData.SetFrom(const FileInfo: TFileInfo);
begin
dataSize := FileInfo.zzipsize;
dataFullSize := FileInfo.zfullSize;
dataCRC := FileInfo.zcrc32;
// dataMethod: 0=stored 8=inflate >16: AlgoID=dataMethod shr 4
if FileInfo.AlgoID<>0 then
dataMethod := FileInfo.AlgoID shl 4 else // stored + AlgoID
dataMethod := FileInfo.zzipMethod;
end;
{ TZipEntry }
function TZipEntry.AlgoCreate(data: pointer; const FileName: TFileName): TSynCompressionAlgo;
// test if algo is registered, perform crc32 check and create one instance
var Algo: TSynCompressionAlgoClass;
begin
if Header.fileInfo.AlgoID=0 then
result := nil else begin
Algo := SynCompressionAlgos.Algo(Header.fileInfo.AlgoID); // registered?
if not Assigned(Algo) then // error: unregistered algo
raise TZipException.CreateFmt(sZipAlgoIDNUnknownN,[
Header.fileInfo.AlgoID,ZipName]);
if crc32(0,data,Header.fileInfo.zfullSize)<>
Header.fileInfo.zcrc32 then // always check integrity
raise TZipException.CreateFmt(sZipCrcErrorNN,[ZipName,FileName]);
result := Algo.Create; // create algo instance
end;
end;
function TZipEntry.SameAs(const aEntry: TZipEntry): boolean;
begin
result := (ZipName=aEntry.ZipName) and
Header.fileInfo.SameAs(@aEntry.Header.fileInfo);
end;
function TZipEntry.LocalHeader(ZipStart: PAnsiChar): PLocalFileHeader;
begin
result := @ZipStart[Header.localHeadOff];
end;
function TZipEntry.LocalDataPosition(ZipStart: PAnsiChar): PtrUInt;
begin
with LocalHeader(ZipStart)^ do
result := PtrUInt(LocalData)-PtrUInt(ZipStart);
end;
{ TSynCompressionAlgos }
function TSynCompressionAlgos.Algo(aID: integer): TSynCompressionAlgoClass;
var i: integer;
begin
for i := 0 to length(Values)-1 do
with Values[i] do
if ID=aID then begin
result := func;
exit;
end;
result := nil;
end;
procedure TSynCompressionAlgos.AlgoRegister(aAlgo: TSynCompressionAlgoClass;
aID, aWholeID: integer);
var L: integer;
begin
if not Assigned(aAlgo) then
exit;
aID := aID and 15;
if (aID=0) or Assigned(Algo(aID)) then exit;
L := length(Values);
SetLength(Values,L+1);
with Values[L] do begin
ID := aID;
WholeID := aWholeID;
func := aAlgo;
end;
end;
function TSynCompressionAlgos.WholeAlgoID(aID: integer): integer;
var i: integer;
begin
for i := 0 to length(Values)-1 do
with Values[i] do
if ID=aID then begin
result := WholeID;
exit;
end;
result := 0;
end;
{ TSynCompressionAlgo }
function TSynCompressionAlgo.CompressFinish: cardinal;
begin
result := 0; // default implementation: just do nothing
end;
procedure TSynCompressionAlgo.CompressInit(OutStream: TStream);
begin
fDestStream := OutStream;
end;
{ TSynCompressionAlgoBuf }
function TSynCompressionAlgoBuf.Compress(InP: pointer; InLen: cardinal;
CRC: PCardinal): cardinal;
begin
if InLen=0 then begin
result := 0;
exit;
end;
assert(InLen<=65536); // // fCompressBuf[] size if fixed
result := AlgoCompress(InP,InLen,fCompressBuf+3); // compress InP[InLen]
if result+128>InLen then begin // compression was not effective -> store
pWord(fCompressBuf)^ := 0; // fCompressBuf[0..2] = 0 = no compression
pInteger(@fCompressBuf[2])^ := (InLen-1)shl 8; // [3..4]=uncompressed len-1
move(InP^,fCompressBuf[5],InLen); // store after uncompressed len
result := InLen+5;
end else begin // compression was effective -> store compressed chunk len
pWord(fCompressBuf)^ := result; // fCompressBuf[0..2] = chunk len
fCompressBuf[2] := AnsiChar(result shr 16);
inc(result,3);
end;
fDestStream.WriteBuffer(fCompressBuf^,result);
if CRC<>nil then
CRC^ := crc32(CRC^,fCompressBuf,result);
end;
procedure TSynCompressionAlgoBuf.CompressInit(OutStream: TStream);
begin
inherited; // fDestSteram := OutStream
// size = worse case with 64KB chunk
Getmem(fCompressBuf,AlgoCompressLength(65536)); // = 73744 for SynLZ, e.g.
end;
destructor TSynCompressionAlgoBuf.Destroy;
begin
Freemem(fCompressBuf);
inherited;
end;
function TSynCompressionAlgoBuf.UnCompress(InP: pointer; InLen: cardinal;
OutP: pointer): cardinal;
var sP,sEnd, dP: PAnsiChar;
L: integer;
begin
sP := InP;
sEnd := sP+InLen;
dP := OutP;
while sP<sEnd do begin // -> uncompress InP[InLen] into PAnsiChar(OutStream)
L := PInteger(sP)^ and $ffffff;
if L=0 then begin // no compression
inc(sP,3);
L := pWord(sP)^+1;
inc(sP,2);
move(sP^,dP^,L);
inc(sP,L);
inc(dp,L);
end else begin // SynLZ compression
inc(dP,AlgoUnCompress(sP+3,L,dP));
inc(sP,L+3);
end;
end;
result := dp-PAnsiChar(OutP);
end;
function TSynCompressionAlgoBuf.UnCompressedLength(InP: pointer;
InLen: cardinal): cardinal;
var sP,sEnd: PAnsiChar;
L: integer;
begin
sP := InP;
sEnd := sP+InLen;
result := 0;
while sP<sEnd do begin // return uncompressed len
L := PInteger(sP)^ and $ffffff;
if L=0 then begin // no compression
L := pWord(sP+3)^+1;
inc(result,L);
inc(sP,L+5);
end else begin
inc(result,AlgoUnCompressLength(sP+3,InLen)); // very fast length calc
inc(sP,L+3);
end;
end
end;
{ TSynCompressionAlgoWhole }
function TSynCompressionAlgoWhole.Compress(InP: pointer; InLen: cardinal;
CRC: PCardinal): cardinal;
var tmp: PAnsiChar;
begin
getmem(tmp,AlgoCompressLength(InLen));
try
result := AlgoCompress(InP,InLen,tmp+1);
if result+128>InLen then begin // compression not effective
tmp[0] := #0; // mark stored
move(InP^,tmp[1],InLen);
result := InLen;
end else // compression was effective
tmp[0] := #1; // mark compressed
inc(result);
fDestStream.WriteBuffer(tmp^,result);
if CRC<>nil then
CRC^ := crc32(CRC^,tmp,result);
finally
freemem(tmp);
end;
end;
function TSynCompressionAlgoWhole.UnCompress(InP: pointer; InLen: cardinal;
OutP: pointer): cardinal;
var tmp: PAnsiChar absolute InP;
begin
case tmp[0] of
#0: begin
result := InLen-1;
move(tmp[1],OutP^,result);
end;
#1: result := AlgoUnCompress(tmp+1,InLen-1,OutP);
else result := 0;
end;
end;
function TSynCompressionAlgoWhole.UnCompressedLength(InP: pointer;
InLen: cardinal): cardinal;
var tmp: PAnsiChar absolute InP;
begin
case tmp[0] of
#0: result := InLen-1;
#1: result := AlgoUnCompressLength(tmp+1,InLen-1);
else result := 0;
end;
end;
end.
| 33.817958 | 104 | 0.701381 |
833d2d5ca42abb0952dcc14ddece42eb2b96d8ed
| 464 |
dpr
|
Pascal
|
Demos/MarshalSuper/Delphi/MarshalSuper.dpr
|
atkins126/SuperObject.Delphi
|
57f1c4c4153965f1459c0358ec0b0d3538367817
|
[
"Unlicense"
] | null | null | null |
Demos/MarshalSuper/Delphi/MarshalSuper.dpr
|
atkins126/SuperObject.Delphi
|
57f1c4c4153965f1459c0358ec0b0d3538367817
|
[
"Unlicense"
] | null | null | null |
Demos/MarshalSuper/Delphi/MarshalSuper.dpr
|
atkins126/SuperObject.Delphi
|
57f1c4c4153965f1459c0358ec0b0d3538367817
|
[
"Unlicense"
] | null | null | null |
program MarshalSuper;
uses
Vcl.Forms,
Unit1 in 'Unit1.pas' {Form1},
uMarshalSuper in '..\uMarshalSuper.pas',
supertypes in '..\..\..\supertypes.pas',
supertimezone in '..\..\..\supertimezone.pas',
superdate in '..\..\..\superdate.pas',
superobject in '..\..\..\superobject.pas';
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
| 23.2 | 49 | 0.644397 |
85c82deaf623d0dfd99e42cf582bcc0d1c5a609c
| 7,614 |
dfm
|
Pascal
|
Lab_2/Unit2.dfm
|
Alex-Kostukov/mpei_labs_1course_2sem
|
66c62faac13e34d834e8b0b166a304b513c8193c
|
[
"MIT"
] | null | null | null |
Lab_2/Unit2.dfm
|
Alex-Kostukov/mpei_labs_1course_2sem
|
66c62faac13e34d834e8b0b166a304b513c8193c
|
[
"MIT"
] | 1 |
2018-03-10T15:47:10.000Z
|
2018-03-12T19:34:51.000Z
|
Lab_2/Unit2.dfm
|
Alex-Kostukov/mpei_labs_1course_2sem
|
66c62faac13e34d834e8b0b166a304b513c8193c
|
[
"MIT"
] | null | null | null |
object Form2: TForm2
Left = 0
Top = 0
Caption = #1050#1086#1088#1077#1085#1100' '#1091#1088#1072#1074#1085#1077#1085#1080#1103
ClientHeight = 597
ClientWidth = 888
Color = clBtnFace
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Consolas'
Font.Style = []
OldCreateOrder = False
OnResize = FormResize
PixelsPerInch = 96
TextHeight = 13
object Image: TImage
Left = 8
Top = 160
Width = 873
Height = 273
end
object GroupBox1: TGroupBox
Left = 17
Top = 8
Width = 345
Height = 145
Caption = #1043#1088#1072#1092#1080#1082
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Consolas'
Font.Style = []
ParentFont = False
TabOrder = 0
object Label1: TLabel
Left = 16
Top = 27
Width = 140
Height = 15
Caption = #1053#1072#1095#1072#1083#1100#1085#1086#1077' '#1079#1085#1072#1095#1077#1085#1080#1077' X'
end
object Label2: TLabel
Left = 192
Top = 85
Width = 133
Height = 15
Caption = #1050#1086#1085#1077#1095#1085#1086#1077' '#1079#1085#1072#1095#1077#1085#1080#1077' Y'
end
object Label3: TLabel
Left = 16
Top = 85
Width = 140
Height = 15
Caption = #1053#1072#1095#1072#1083#1100#1085#1086#1077' '#1079#1085#1072#1095#1077#1085#1080#1077' Y'
end
object Label4: TLabel
Left = 192
Top = 27
Width = 133
Height = 15
Caption = #1050#1086#1085#1077#1095#1085#1086#1077' '#1079#1085#1072#1095#1077#1085#1080#1077' X'
end
object EditXs: TEdit
Left = 16
Top = 48
Width = 140
Height = 23
TabOrder = 0
end
object EditXe: TEdit
Left = 192
Top = 48
Width = 133
Height = 23
TabOrder = 1
end
object EditYs: TEdit
Left = 16
Top = 106
Width = 140
Height = 23
TabOrder = 2
end
object EditYe: TEdit
Left = 192
Top = 106
Width = 133
Height = 23
TabOrder = 3
end
end
object GroupBox3: TGroupBox
Left = 0
Top = 444
Width = 241
Height = 145
Caption = #1048#1089#1093#1086#1076#1085#1099#1077' '#1076#1072#1085#1085#1099#1077' '#1076#1083#1103' '#1087#1086#1080#1089#1082#1072' '#1082#1086#1088#1085#1103
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Consolas'
Font.Style = []
ParentFont = False
TabOrder = 1
object Label5: TLabel
Left = 16
Top = 27
Width = 91
Height = 15
Caption = #1051#1077#1074#1072#1103' '#1075#1088#1072#1085#1080#1094#1072
end
object Label6: TLabel
Left = 129
Top = 27
Width = 98
Height = 15
Caption = #1055#1088#1072#1074#1072#1103' '#1075#1088#1072#1085#1080#1094#1072
end
object Label7: TLabel
Left = 16
Top = 77
Width = 56
Height = 15
Caption = #1058#1086#1095#1085#1086#1089#1090#1100
end
object Label8: TLabel
Left = 129
Top = 77
Width = 77
Height = 15
Caption = #1050#1086#1101#1092#1092#1080#1094#1080#1077#1085#1090
end
object EditBorderLeft: TEdit
Left = 16
Top = 48
Width = 91
Height = 23
TabOrder = 0
end
object EditBorderRight: TEdit
Left = 129
Top = 48
Width = 98
Height = 23
TabOrder = 1
end
object EditEPS: TEdit
Left = 17
Top = 98
Width = 91
Height = 23
TabOrder = 2
end
object EditFactor: TEdit
Left = 129
Top = 98
Width = 98
Height = 23
TabOrder = 3
end
end
object GroupBox4: TGroupBox
Left = 255
Top = 440
Width = 618
Height = 145
Caption = #1056#1077#1079#1091#1083#1100#1090#1072#1090
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Consolas'
Font.Style = []
ParentFont = False
TabOrder = 2
object Label9: TLabel
Left = 11
Top = 48
Width = 42
Height = 15
Caption = #1050#1086#1088#1077#1085#1100
end
object Label10: TLabel
Left = 11
Top = 105
Width = 56
Height = 15
Caption = #1048#1090#1077#1088#1072#1094#1080#1080
end
object Label11: TLabel
Left = 88
Top = 23
Width = 91
Height = 15
Caption = #1052#1077#1090#1086#1076' '#1089#1077#1082#1091#1097#1080#1093
end
object Label12: TLabel
Left = 266
Top = 23
Width = 154
Height = 15
Caption = #1052#1077#1090#1086#1076' '#1087#1088#1086#1089#1090#1099#1093' '#1080#1090#1077#1088#1072#1094#1080#1081
end
object Label13: TLabel
Left = 440
Top = 23
Width = 91
Height = 15
Caption = #1052#1077#1090#1086#1076' '#1053#1100#1102#1090#1086#1085#1072
end
object EditItN: TEdit
Left = 264
Top = 104
Width = 160
Height = 23
TabOrder = 0
end
object EditN: TEdit
Left = 440
Top = 44
Width = 160
Height = 23
TabOrder = 1
end
object EditNn: TEdit
Left = 438
Top = 104
Width = 160
Height = 23
TabOrder = 2
end
object EditIt: TEdit
Left = 266
Top = 44
Width = 160
Height = 23
TabOrder = 3
end
object EditSecN: TEdit
Left = 88
Top = 104
Width = 160
Height = 23
TabOrder = 4
end
object EditSec: TEdit
Left = 88
Top = 44
Width = 160
Height = 23
TabOrder = 5
end
end
object RadioGroupFunction: TRadioGroup
Left = 368
Top = 8
Width = 185
Height = 145
Caption = #1060#1091#1085#1082#1094#1080#1103
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Consolas'
Font.Style = []
ItemIndex = 0
Items.Strings = (
#1042#1072#1088#1080#1072#1085#1090' '#8470' 26'
#1042#1072#1088#1080#1072#1085#1090' '#8470' 5'
#1042#1072#1088#1080#1072#1085#1090' '#8470' 13'
#1042#1072#1088#1080#1072#1085#1090' '#8470' 18')
ParentFont = False
TabOrder = 3
end
object ButtonGraph: TButton
Left = 576
Top = 25
Width = 297
Height = 36
Caption = #1043#1088#1072#1092#1080#1082
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Consolas'
Font.Style = []
ParentFont = False
TabOrder = 4
OnClick = ButtonGraphClick
end
object Button2: TButton
Left = 576
Top = 67
Width = 297
Height = 36
Caption = #1056#1077#1096#1077#1085#1080#1077
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Consolas'
Font.Style = []
ParentFont = False
TabOrder = 5
OnClick = Button2Click
end
object Button3: TButton
Left = 576
Top = 109
Width = 297
Height = 36
Caption = #1042#1099#1093#1086#1076
Font.Charset = ANSI_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Consolas'
Font.Style = []
ParentFont = False
TabOrder = 6
OnClick = Button3Click
end
end
| 23.79375 | 167 | 0.552666 |
f1a85d416ef131b83fb32cad2c31db9182ab0fc2
| 2,068 |
pas
|
Pascal
|
windows/src/ext/jedi/jvcl/tests/archive/jvcl132/source/JvObserverLabel.pas
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 219 |
2017-06-21T03:37:03.000Z
|
2022-03-27T12:09:28.000Z
|
windows/src/ext/jedi/jvcl/tests/archive/jvcl132/source/JvObserverLabel.pas
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 4,451 |
2017-05-29T02:52:06.000Z
|
2022-03-31T23:53:23.000Z
|
windows/src/ext/jedi/jvcl/tests/archive/jvcl132/source/JvObserverLabel.pas
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 72 |
2017-05-26T04:08:37.000Z
|
2022-03-03T10:26:20.000Z
|
{-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: JvAlignListbox.PAS, released on 2000-11-22.
The Initial Developer of the Original Code is Peter Below <100113.1101@compuserve.com>
Portions created by Peter Below are Copyright (C) 2000 Peter Below.
All Rights Reserved.
Contributor(s): ______________________________________.
Last Modified: 2000-mm-dd
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.sourceforge.net
Known Issues:
-----------------------------------------------------------------------------}
{$A+,B-,C+,D+,E-,F-,G+,H+,I+,J+,K-,L+,M-,N+,O+,P+,Q-,R-,S-,T-,U-,V+,W-,X+,Y+,Z1}
{$I JEDI.INC}
unit JvObserverLabel;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, JvObserverMessages, JVCLVer;
type
TJvObserverLabel = class(TLabel)
private
FAboutJVCL: TJVCLAboutInfo;
{ Private declarations }
procedure UMObservibleChanged(var msg: TUMObservibleChanged);
message UM_OBSERVIBLE_CHANGED;
published
{ Published declarations }
property AboutJVCL: TJVCLAboutInfo read FAboutJVCL write FAboutJVCL stored False;
end;
implementation
{ TJvObserverLabel }
procedure TJvObserverLabel.UMObservibleChanged(var msg: TUMObservibleChanged);
const
checkstrings: array[Boolean] of string = ('unchecked', 'checked');
begin
if msg.sender is TCheckbox then
with TCheckbox(msg.sender) do
Self.Caption := Format('Checkbox %s is %s',
[Name, Checkstrings[Checked]]);
end;
end.
| 32.825397 | 114 | 0.696325 |
83a18cc312b15a4b986e45a4f1d29b868871acbc
| 5,523 |
pas
|
Pascal
|
BufferedStream.pas
|
atkins126/mrmath
|
317630845b3b84c2c27245fdabd20827d620d5ae
|
[
"Apache-2.0"
] | 1 |
2019-11-13T01:43:13.000Z
|
2019-11-13T01:43:13.000Z
|
BufferedStream.pas
|
atkins126/mrmath
|
317630845b3b84c2c27245fdabd20827d620d5ae
|
[
"Apache-2.0"
] | null | null | null |
BufferedStream.pas
|
atkins126/mrmath
|
317630845b3b84c2c27245fdabd20827d620d5ae
|
[
"Apache-2.0"
] | 1 |
2019-07-09T09:40:32.000Z
|
2019-07-09T09:40:32.000Z
|
// ###################################################################
// #### This file is part of the mathematics library project, and is
// #### offered under the licence agreement described on
// #### http://www.mrsoft.org/
// ####
// #### Copyright:(c) 2011, Michael R. . All rights reserved.
// ####
// #### Unless required by applicable law or agreed to in writing, software
// #### distributed under the License is distributed on an "AS IS" BASIS,
// #### WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// #### See the License for the specific language governing permissions and
// #### limitations under the License.
// ###################################################################
unit BufferedStream;
// ###############################################
// #### Buffered stream reading
// ###############################################
interface
uses SysUtils, Classes;
// ###############################################
// #### Reads blockwise from stream
// This class speedups the access to files
// by reading blocksize bytes from it and handle the bytewise reading
// from a buffer
type
TBufferedStream = class(TStream)
private
fStream : TStream;
fBuffer : array of Byte;
fActPos : PByte;
fBytesLeft : integer;
fBlockSize: integer;
fStartPos : int64;
fBytesRead : int64;
fReadBlockSize : integer;
function InternalRead(var Buf; BufSize : integer) : integer;
public
function Read(var Buf; BufSize : integer) : integer; override;
function Write(const Buffer; Count: Longint): Longint; override;
function Seek(const Offset: Int64; Origin: TSeekOrigin): Int64; override;
property BlockSize : integer read fBlockSize;
constructor Create(Stream : TStream; aBlockSize : integer = 32768);
destructor Destroy; override;
end;
implementation
uses Math;
{ TBufferedStream }
constructor TBufferedStream.Create(Stream: TStream; aBlockSize : integer = 32768);
begin
inherited Create;
assert(Assigned(stream), 'Stream may not be nil');
assert(BlockSize > 0, 'Error Blocksize must be larger than 0');
fBlockSize := aBlockSize;
SetLength(fBuffer, aBlockSize);
fStream := Stream;
fActPos := @fBuffer[0];
fBytesLeft := 0;
fStartPos := Stream.Position;
fBytesRead := 0;
fReadBlockSize := 0;
end;
destructor TBufferedStream.Destroy;
begin
{$IF DEFINED(FPC) or (CompilerVersion <= 21)}
fStream.Seek(fStartPos + fBytesRead, soFromBeginning);
{$ELSE}
fStream.Seek(fStartPos + fBytesRead, soBeginning);
{$IFEND}
inherited;
end;
function TBufferedStream.InternalRead(var Buf; BufSize: integer) : integer;
var toBuf : PByte;
bytesToRead : integer;
begin
Result := 0;
toBuf := @Buf;
// #################################################
// #### Read from stream
while BufSize > fBytesLeft do
begin
// read a block of data
if fBytesLeft > 0 then
begin
Move(fActPos^, toBuf^, fBytesLeft);
inc(toBuf, fBytesLeft);
inc(fBytesRead, fBytesLeft);
inc(Result, fBytesLeft);
dec(BufSize, fBytesLeft);
fBytesLeft := 0;
end;
fActPos := @fBuffer[0];
fBytesLeft := fStream.Read(fBuffer[0], fBlockSize);
fReadBlockSize := fBytesLeft;
if fBytesLeft < fBlockSize then
break;
end;
// #################################################
// #### Read from the buffer
bytesToRead := Min(fBytesLeft, BufSize);
Move(fActPos^, toBuf^, bytesToRead);
inc(fActPos, bytesToRead);
inc(Result, bytesToRead);
inc(fBytesRead, bytesToRead);
dec(fBytesLeft, bytesToRead);
end;
function TBufferedStream.Read(var Buf; BufSize: integer): integer;
begin
Result := InternalRead(Buf, BufSize);
end;
function TBufferedStream.Seek(const Offset: Int64; Origin: TSeekOrigin): Int64;
var NewPosition : Int64;
actBlockStart : Int64;
begin
case origin of
soBeginning: NewPosition := Offset;
soCurrent: NewPosition := fBytesRead + Offset;
soEnd: NewPosition := fStream.Size + Offset;
else
NewPosition := 0;
end;
// check if the new position is within the actual buffer:
actBlockStart := fstream.Position - fReadBlockSize;
if (NewPosition >= actBlockStart) and (NewPosition < actBlockStart + fReadBlockSize) then
begin
Result := NewPosition;
fBytesRead := NewPosition - actBlockStart;
fBytesLeft := fReadBlockSize - (NewPosition - actBlockStart);
fActPos := @fBuffer[0];
inc(fActPos, fReadBlockSize - fBytesLeft);
end
else
begin
// clear and wait until the next block is read
fBytesRead := NewPosition;
fBytesLeft := 0;
{$IF DEFINED(FPC) or (CompilerVersion <= 21)}
Result := fStream.Seek(NewPosition, soFromBeginning);
{$ELSE}
Result := fStream.Seek(NewPosition, soBeginning);
{$IFEND}
fReadBlockSize := 0;
fActPos := @fBuffer[0];
end;
end;
function TBufferedStream.Write(const Buffer; Count: Integer): Longint;
begin
raise Exception.Create('Writes not implemented');
end;
end.
| 30.854749 | 95 | 0.57505 |
83546bd76fad0f1d78d6299898e031a083fe12cf
| 8,764 |
pas
|
Pascal
|
entities.pas
|
cyberfilth/ASCII-axe
|
a3b3082582bb0434134cda6c1f0b219eaa8eeee7
|
[
"MIT"
] | 10 |
2021-05-03T14:20:59.000Z
|
2022-01-16T17:58:41.000Z
|
entities.pas
|
richorr/ASCII-axe
|
02ddf5aa0e76235e6c2a350bdbd03439726579f0
|
[
"MIT"
] | 5 |
2021-05-15T19:53:49.000Z
|
2021-09-23T16:12:29.000Z
|
entities.pas
|
richorr/ASCII-axe
|
02ddf5aa0e76235e6c2a350bdbd03439726579f0
|
[
"MIT"
] | 3 |
2021-05-04T20:17:20.000Z
|
2022-01-21T22:57:36.000Z
|
(* Unit responsible for NPC stat, initialising enemies and utility functions *)
unit entities;
{$mode objfpc}{$H+}
{$ModeSwitch advancedrecords}
{$RANGECHECKS OFF}
interface
uses
SysUtils, globalUtils,
{ List of creatures }
cave_rat, giant_cave_rat, blood_bat, green_fungus, redcap_lesser, redcap_lesser_lobber;
type { NPC attitudes }
Tattitudes = (stateNeutral, stateHostile, stateEscape);
type {NPC factions / groups }
Tfactions = (redcapFaction, bluecapFaction, animalFaction, fungusFaction);
type
(* Store information about NPC's *)
{ Creature }
Creature = record
(* Unique ID *)
npcID: smallint;
(* Creature type *)
race: shortstring;
(* Description of creature *)
description: string;
(* health and position on game map *)
currentHP, maxHP, attack, defence, posX, posY, targetX, targetY,
xpReward, visionRange: smallint;
(* Weapon stats *)
weaponDice, weaponAdds: smallint;
(* Character used to represent NPC on game map *)
glyph: shortstring;
(* Colour of the glyph *)
glyphColour: shortstring;
(* Count of turns the entity will keep tracking the player when they're out of sight *)
moveCount: smallint;
(* Is the NPC in the players FoV *)
inView: boolean;
(* First time the player discovers the NPC *)
discovered: boolean;
(* Some entities block movement, i.e. barrels *)
blocks: boolean;
(* NPC faction *)
faction: Tfactions;
(* NPC finite state *)
state: Tattitudes;
(* Is a weapon equipped *)
weaponEquipped: boolean;
(* Is Armour equipped *)
armourEquipped: boolean;
(* Has the NPC been killed, to be removed at end of game loop *)
isDead: boolean;
(* status effects *)
stsDrunk, stsPoison: boolean;
(* status timers *)
tmrDrunk, tmrPoison: smallint;
(* The procedure that allows each NPC to take a turn *)
procedure entityTakeTurn(i: smallint);
end;
var
entityList: array of Creature;
npcAmount, listLength: byte;
(* Add player to list of creatures on the map *)
procedure spawnPlayer;
(* Handle death of NPC's *)
procedure killEntity(id: smallint);
(* Update NPCs X, Y coordinates *)
procedure moveNPC(id, newX, newY: smallint);
(* Get creature currentHP at coordinates *)
function getCreatureHP(x, y: smallint): smallint;
(* Get creature maxHP at coordinates *)
function getCreatureMaxHP(x, y: smallint): smallint;
(* Get creature ID at coordinates *)
function getCreatureID(x, y: smallint): smallint;
(* Get creature name at coordinates *)
function getCreatureName(x, y: smallint): shortstring;
(* Check if creature is visible at coordinates *)
function isCreatureVisible(x, y: smallint): boolean;
(* Ensure all NPC's are correctly occupying tiles *)
procedure occupyUpdate;
(* Update the map display to show all NPC's *)
procedure redrawMapDisplay(id: byte);
(* Clear list of NPC's *)
procedure newFloorNPCs;
(* Count all living NPC's *)
function countLivingEntities: byte;
(* Call Creatures.takeTurn procedure *)
procedure NPCgameLoop;
implementation
uses
player, map, ui;
procedure spawnPlayer;
begin
npcAmount := 1;
(* initialise array *)
SetLength(entityList, 0);
(* Add the player to Entity list *)
player.createPlayer;
end;
procedure killEntity(id: smallint);
var
i, amount, r, c: smallint;
fungusSpawnAttempts: byte;
begin
fungusSpawnAttempts := 0;
entityList[id].isDead := True;
entityList[id].glyph := '%';
entityList[id].blocks := False;
map.unoccupy(entityList[id].posX, entityList[id].posY);
{ Green Fungus }
if (entityList[id].race = 'Green Fungus') then
(* Attempt to spread spores *)
(* Limit the number of attempts to find a space *)
if (fungusSpawnAttempts < 3) then
begin
begin
(* Set a random number of spores *)
amount := randomRange(0, 3);
if (amount > 0) then
begin
for i := 1 to amount do
begin
(* Choose a space to place the fungus *)
r := globalutils.randomRange(entityList[id].posY - 4,
entityList[id].posY + 4);
c := globalutils.randomRange(entityList[id].posX - 4,
entityList[id].posX + 4);
(* choose a location that is not a wall or occupied *)
if (maparea[r][c].Blocks <> True) and (maparea[r][c].Occupied <> True) and
(withinBounds(c, r) = True) then
begin
Inc(npcAmount);
green_fungus.createGreenFungus(npcAmount, c, r);
end;
end;
ui.writeBufferedMessages;
ui.bufferMessage('The fungus releases spores into the air');
end;
Inc(fungusSpawnAttempts);
end;
end; // does this need to be moved to before the Inc()...
{ End of Green Fungus death }
end;
procedure moveNPC(id, newX, newY: smallint);
begin
(* mark tile as unoccupied *)
map.unoccupy(entityList[id].posX, entityList[id].posY);
(* update new position *)
if (map.isOccupied(newX, newY) = True) and (getCreatureID(newX, newY) <> id) then
begin
newX := entityList[id].posX;
newY := entityList[id].posY;
end;
entityList[id].posX := newX;
entityList[id].posY := newY;
(* Check if NPC in players FoV *)
if (map.canSee(newX, newY) = True) then
begin
entityList[id].inView := True;
if (entityList[id].discovered = False) then
begin
ui.displayMessage('You see ' + entityList[id].description);
entityList[id].discovered := True;
end;
(* Draw to map display *)
map.mapDisplay[newY, newX].GlyphColour := entityList[id].glyphColour;
map.mapDisplay[newY, newX].Glyph := entityList[id].glyph;
end
else
entityList[id].inView := False;
(* mark tile as occupied *)
map.occupy(newX, newY);
end;
function getCreatureHP(x, y: smallint): smallint;
var
i: smallint;
begin
Result := 0;
for i := 0 to npcAmount do
begin
if (entityList[i].posX = x) and (entityList[i].posY = y) then
Result := entityList[i].currentHP;
end;
end;
function getCreatureMaxHP(x, y: smallint): smallint;
var
i: smallint;
begin
Result := 0;
for i := 0 to npcAmount do
begin
if (entityList[i].posX = x) and (entityList[i].posY = y) then
Result := entityList[i].maxHP;
end;
end;
function getCreatureID(x, y: smallint): smallint;
var
i: smallint;
begin
Result := 0;
// initialise variable
for i := 0 to npcAmount do
begin
if (entityList[i].posX = x) and (entityList[i].posY = y) then
Result := i;
end;
end;
function getCreatureName(x, y: smallint): shortstring;
var
i: smallint;
begin
Result := '';
for i := 0 to npcAmount do
begin
if (entityList[i].posX = x) and (entityList[i].posY = y) then
Result := entityList[i].race;
end;
end;
function isCreatureVisible(x, y: smallint): boolean;
var
i: smallint;
begin
Result := False;
for i := 0 to npcAmount do
if (entityList[i].posX = x) and (entityList[i].posY = y) then
if (entityList[i].inView = True) and (entityList[i].glyph <> '%') then
Result := True;
end;
procedure occupyUpdate;
var
i: smallint;
begin
for i := 1 to npcAmount do
if (entityList[i].isDead = False) then
map.occupy(entityList[i].posX, entityList[i].posY);
end;
procedure redrawMapDisplay(id: byte);
begin
(* Redrawing NPC directly to map display as looping through
entity list in the camera unit wasn't working *)
if (entityList[id].isDead = False) and (entityList[id].inView = True) then
begin
map.mapDisplay[entityList[id].posY, entityList[id].posX].GlyphColour :=
entityList[id].glyphColour;
map.mapDisplay[entityList[id].posY, entityList[id].posX].Glyph :=
entityList[id].glyph;
end;
end;
procedure newFloorNPCs;
begin
(* Clear the current NPC amount *)
npcAmount := 1;
SetLength(entityList, 1);
end;
function countLivingEntities: byte;
var
i, Count: byte;
begin
Count := 0;
for i := 1 to npcAmount do
if (entityList[i].isDead = False) then
Inc(Count);
Result := Count;
end;
procedure NPCgameLoop;
var
i: smallint;
begin
for i := 1 to npcAmount do
if (entityList[i].glyph <> '%') then
entityList[i].entityTakeTurn(i);
end;
{ Creature }
procedure Creature.entityTakeTurn(i: smallint);
begin
if (entityList[i].race = 'Cave Rat') then
cave_rat.takeTurn(i)
else if (entityList[i].race = 'Giant Rat') then
giant_cave_rat.takeTurn(i)
else if (entityList[i].race = 'Blood Bat') then
blood_bat.takeTurn(i)
else if (entityList[i].race = 'Green Fungus') then
green_fungus.takeTurn(i)
else if (entityList[i].race = 'Hob') then
redcap_lesser.takeTurn(i)
else if (entityList[i].race = 'Hob lobber') then
redcap_lesser_lobber.takeTurn(i);
occupyUpdate;
end;
end.
| 26.719512 | 91 | 0.661228 |
6acdabfd9eef0e412705eb27493d578f86f53c1b
| 5,456 |
pas
|
Pascal
|
libraries/cryptolib4pascal/ClpBsiObjectIdentifiers.pas
|
OHLChain/techplayground
|
1f70d7dc7f3d8e10ba3b459faa1d9ffbb4fd6034
|
[
"MIT"
] | null | null | null |
libraries/cryptolib4pascal/ClpBsiObjectIdentifiers.pas
|
OHLChain/techplayground
|
1f70d7dc7f3d8e10ba3b459faa1d9ffbb4fd6034
|
[
"MIT"
] | null | null | null |
libraries/cryptolib4pascal/ClpBsiObjectIdentifiers.pas
|
OHLChain/techplayground
|
1f70d7dc7f3d8e10ba3b459faa1d9ffbb4fd6034
|
[
"MIT"
] | 1 |
2022-01-15T14:07:50.000Z
|
2022-01-15T14:07:50.000Z
|
{ *********************************************************************************** }
{ * CryptoLib Library * }
{ * Copyright (c) 2018 - 20XX Ugochukwu Mmaduekwe * }
{ * Github Repository <https://github.com/Xor-el> * }
{ * Distributed under the MIT software license, see the accompanying file LICENSE * }
{ * or visit http://www.opensource.org/licenses/mit-license.php. * }
{ * Acknowledgements: * }
{ * * }
{ * Thanks to Sphere 10 Software (http://www.sphere10.com/) for sponsoring * }
{ * development of this library * }
{ * ******************************************************************************* * }
(* &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *)
unit ClpBsiObjectIdentifiers;
{$I CryptoLib.inc}
interface
uses
ClpAsn1Objects,
ClpIAsn1Objects;
type
TBsiObjectIdentifiers = class abstract(TObject)
strict private
/// <remarks>See https://www.bsi.bund.de/cae/servlet/contentblob/471398/publicationFile/30615/BSI-TR-03111_pdf.pdf</remarks>
class var
FIsBooted: Boolean;
Fbsi_de, Fid_ecc, Fecdsa_plain_signatures, Fecdsa_plain_SHA1,
Fecdsa_plain_SHA224, Fecdsa_plain_SHA256, Fecdsa_plain_SHA384,
Fecdsa_plain_SHA512, Fecdsa_plain_RIPEMD160: IDerObjectIdentifier;
class function Getbsi_de: IDerObjectIdentifier; static; inline;
class function Getecdsa_plain_RIPEMD160: IDerObjectIdentifier;
static; inline;
class function Getecdsa_plain_SHA1: IDerObjectIdentifier; static; inline;
class function Getecdsa_plain_SHA224: IDerObjectIdentifier; static; inline;
class function Getecdsa_plain_SHA256: IDerObjectIdentifier; static; inline;
class function Getecdsa_plain_SHA384: IDerObjectIdentifier; static; inline;
class function Getecdsa_plain_SHA512: IDerObjectIdentifier; static; inline;
class function Getecdsa_plain_signatures: IDerObjectIdentifier;
static; inline;
class function Getid_ecc: IDerObjectIdentifier; static; inline;
class constructor BsiObjectIdentifiers();
public
class property bsi_de: IDerObjectIdentifier read Getbsi_de;
class property id_ecc: IDerObjectIdentifier read Getid_ecc;
class property ecdsa_plain_signatures: IDerObjectIdentifier
read Getecdsa_plain_signatures;
class property ecdsa_plain_SHA1: IDerObjectIdentifier
read Getecdsa_plain_SHA1;
class property ecdsa_plain_SHA224: IDerObjectIdentifier
read Getecdsa_plain_SHA224;
class property ecdsa_plain_SHA256: IDerObjectIdentifier
read Getecdsa_plain_SHA256;
class property ecdsa_plain_SHA384: IDerObjectIdentifier
read Getecdsa_plain_SHA384;
class property ecdsa_plain_SHA512: IDerObjectIdentifier
read Getecdsa_plain_SHA512;
class property ecdsa_plain_RIPEMD160: IDerObjectIdentifier
read Getecdsa_plain_RIPEMD160;
class procedure Boot(); static;
end;
implementation
{ TBsiObjectIdentifiers }
class procedure TBsiObjectIdentifiers.Boot;
begin
if not FIsBooted then
begin
Fbsi_de := TDerObjectIdentifier.Create('0.4.0.127.0.7');
// /* 0.4.0.127.0.7.1.1 */
Fid_ecc := Fbsi_de.Branch('1.1');
// /* 0.4.0.127.0.7.1.1.4.1 */
Fecdsa_plain_signatures := Fid_ecc.Branch('4.1');
// /* 0.4.0.127.0.7.1.1.4.1.1 */
Fecdsa_plain_SHA1 := Fecdsa_plain_signatures.Branch('1');
// /* 0.4.0.127.0.7.1.1.4.1.2 */
Fecdsa_plain_SHA224 := Fecdsa_plain_signatures.Branch('2');
// /* 0.4.0.127.0.7.1.1.4.1.3 */
Fecdsa_plain_SHA256 := Fecdsa_plain_signatures.Branch('3');
// /* 0.4.0.127.0.7.1.1.4.1.4 */
Fecdsa_plain_SHA384 := Fecdsa_plain_signatures.Branch('4');
// /* 0.4.0.127.0.7.1.1.4.1.5 */
Fecdsa_plain_SHA512 := Fecdsa_plain_signatures.Branch('5');
// /* 0.4.0.127.0.7.1.1.4.1.6 */
Fecdsa_plain_RIPEMD160 := Fecdsa_plain_signatures.Branch('6');
FIsBooted := True;
end;
end;
class constructor TBsiObjectIdentifiers.BsiObjectIdentifiers;
begin
TBsiObjectIdentifiers.Boot;
end;
class function TBsiObjectIdentifiers.Getbsi_de: IDerObjectIdentifier;
begin
result := Fbsi_de;
end;
class function TBsiObjectIdentifiers.Getecdsa_plain_RIPEMD160
: IDerObjectIdentifier;
begin
result := Fecdsa_plain_RIPEMD160;
end;
class function TBsiObjectIdentifiers.Getecdsa_plain_SHA1: IDerObjectIdentifier;
begin
result := Fecdsa_plain_SHA1;
end;
class function TBsiObjectIdentifiers.Getecdsa_plain_SHA224
: IDerObjectIdentifier;
begin
result := Fecdsa_plain_SHA224;
end;
class function TBsiObjectIdentifiers.Getecdsa_plain_SHA256
: IDerObjectIdentifier;
begin
result := Fecdsa_plain_SHA256;
end;
class function TBsiObjectIdentifiers.Getecdsa_plain_SHA384
: IDerObjectIdentifier;
begin
result := Fecdsa_plain_SHA384;
end;
class function TBsiObjectIdentifiers.Getecdsa_plain_SHA512
: IDerObjectIdentifier;
begin
result := Fecdsa_plain_SHA512;
end;
class function TBsiObjectIdentifiers.Getecdsa_plain_signatures
: IDerObjectIdentifier;
begin
result := Fecdsa_plain_signatures;
end;
class function TBsiObjectIdentifiers.Getid_ecc: IDerObjectIdentifier;
begin
result := Fid_ecc;
end;
end.
| 31.537572 | 128 | 0.671554 |
f1c1d20c8d0b4ffa1fb9386302ea701f3ff4d94c
| 7,314 |
pas
|
Pascal
|
Gui/options.pas
|
kapkapas/deskew
|
0a9bbf952a73aedead4e2f62f29d4a9b38d42417
|
[
"MIT"
] | 1 |
2021-07-29T18:50:51.000Z
|
2021-07-29T18:50:51.000Z
|
Gui/options.pas
|
kapkapas/deskew
|
0a9bbf952a73aedead4e2f62f29d4a9b38d42417
|
[
"MIT"
] | null | null | null |
Gui/options.pas
|
kapkapas/deskew
|
0a9bbf952a73aedead4e2f62f29d4a9b38d42417
|
[
"MIT"
] | null | null | null |
unit Options;
interface
uses
Classes, SysUtils, ImagingTypes, IniFiles;
type
TForcedOutputFormat = (
fofNone,
fofBinary1,
fofGray8,
fofRgb24,
fofRgba32
);
TFileFormat = (
ffSameAsInput,
ffPng,
ffJpeg,
ffTiff,
ffBmp,
ffPsd,
ffTga,
ffJng,
ffPpm
);
{ TOptions }
TOptions = class
private
FFiles: TStrings;
function GetEffectiveExecutablePath: string;
function GetOutputFilePath(const InputFilePath: string): string;
public
// Basic options
DefaultOutputFileOptions: Boolean;
OutputFolder: string;
OutputFileFormat: TFileFormat;
BackgroundColor: TColor32;
// Advanced options
MaxAngle: Double;
ThresholdLevel: Integer;
ForcedOutputFormat: TForcedOutputFormat;
SkipAngle: Double;
JpegCompressionQuality: Integer;
TiffCompressionScheme: Integer;
DefaultExecutable: Boolean;
CustomExecutablePath: string;
constructor Create;
destructor Destroy; override;
procedure ToCmdLineParameters(AParams: TStrings; AFileIndex: Integer);
procedure SaveToIni(Ini: TIniFile);
procedure LoadFromIni(Ini: TIniFile);
procedure Reset;
property Files: TStrings read FFiles;
property EffectiveExecutablePath: string read GetEffectiveExecutablePath;
end;
implementation
uses
ImagingUtility, Utils;
const
DefaultBackgroundColor = $FFFFFFFF; // white
DefaultMaxAngle = 10.0;
DefaultSkipAngle = 0.01;
DefaultThresholdLevel = -1; // auto
DefaultJpegCompressionQuality = -1; // use imaginglib default
DefaultTiffCompressionScheme = -1; // use imaginglib default
DefaultOutputFileNamePrefix = 'deskewed-';
FileExts: array[TFileFormat] of string = (
'', // ffSameAsInput
'png', // ffPng
'jpg', // ffJpeg
'tif', // ffTiff
'bmp', // ffBmp
'psd', // ffPsd
'tga', // ffTga
'jng', // ffJng
'ppm' // ffPpm
);
FormatIds: array[TForcedOutputFormat] of string = (
'', // fofNone,
'b1', // fofBinary1
'g8', // fofGray8
'rgb24', // fofRgb24
'rgba32' // fofRgba32
);
IniSectionOptions = 'Options';
IniSectionAdvanced = 'Advanced';
{ TOptions }
constructor TOptions.Create;
begin
FFiles := TStringList.Create;
Reset;
end;
destructor TOptions.Destroy;
begin
FFiles.Free;
inherited Destroy;
end;
function TOptions.GetEffectiveExecutablePath: string;
begin
if DefaultExecutable then
Result := Utils.FindDeskewExePath
else
Result := CustomExecutablePath;
end;
function TOptions.GetOutputFilePath(const InputFilePath: string): string;
var
FileName: string;
begin
FileName := ExtractFileName(InputFilePath);
if DefaultOutputFileOptions then
begin
Result := ExtractFilePath(InputFilePath) + DefaultOutputFileNamePrefix + FileName;
end
else
begin
if OutputFileFormat <> ffSameAsInput then
FileName := ChangeFileExt(FileName, '.' + FileExts[OutputFileFormat]);
Result := IncludeTrailingPathDelimiter(OutputFolder) + FileName;
// Try to avoid overwriting existing file (in case in-folder = out-folder)
if FileExists(Result) then
Result := IncludeTrailingPathDelimiter(OutputFolder) + DefaultOutputFileNamePrefix + FileName;
end;
end;
procedure TOptions.ToCmdLineParameters(AParams: TStrings; AFileIndex: Integer);
function FloatToStrFmt(const F: Double): string;
begin
Result := Format('%.2f', [F], ImagingUtility.GetFormatSettingsForFloats);
end;
begin
Assert(AFileIndex < FFiles.Count);
AParams.Clear;
AParams.AddStrings(['-o', GetOutputFilePath(FFiles[AFileIndex])]);
if BackgroundColor <> $FF000000 then
AParams.AddStrings(['-b', IntToHex(BackgroundColor, 8)]);
// Advanced options
if not SameFloat(MaxAngle, DefaultMaxAngle, 0.1) then
AParams.AddStrings(['-a', FloatToStrFmt(MaxAngle)]);
if not SameFloat(SkipAngle, DefaultSkipAngle, 0.01) then
AParams.AddStrings(['-l', FloatToStrFmt(SkipAngle)]);
if ForcedOutputFormat <> fofNone then
AParams.AddStrings(['-f', FormatIds[ForcedOutputFormat]]);
{$IFDEF DEBUG}
AParams.AddStrings(['-s', 'p']);
{$ENDIF}
AParams.Add(FFiles[AFileIndex]);
end;
procedure TOptions.SaveToIni(Ini: TIniFile);
begin
Ini.WriteString(IniSectionOptions, 'DefaultOutputFileOptions', BoolToStr(DefaultOutputFileOptions, True));
Ini.WriteString(IniSectionOptions, 'OutputFolder', OutputFolder);
Ini.WriteString(IniSectionOptions, 'OutputFileFormat', TEnumUtils<TFileFormat>.EnumToStr(OutputFileFormat));
Ini.WriteString(IniSectionOptions, 'BackgroundColor', ColorToString(BackgroundColor));
Ini.WriteFloat(IniSectionAdvanced, 'MaxAngle', MaxAngle);
Ini.WriteInteger(IniSectionAdvanced, 'ThresholdLevel', ThresholdLevel);
Ini.WriteString(IniSectionAdvanced, 'ForcedOutputFormat', TEnumUtils<TForcedOutputFormat>.EnumToStr(ForcedOutputFormat));
Ini.WriteFloat(IniSectionAdvanced, 'SkipAngle', SkipAngle);
Ini.WriteInteger(IniSectionAdvanced, 'JpegCompressionQuality', JpegCompressionQuality);
Ini.WriteInteger(IniSectionAdvanced, 'TiffCompressionScheme', TiffCompressionScheme);
Ini.WriteString(IniSectionAdvanced, 'DefaultExecutable', BoolToStr(DefaultExecutable, True));
Ini.WriteString(IniSectionAdvanced, 'CustomExecutablePath', CustomExecutablePath);
end;
procedure TOptions.LoadFromIni(Ini: TIniFile);
begin
DefaultOutputFileOptions := StrToBoolDef(Ini.ReadString(IniSectionOptions, 'DefaultOutputFileOptions', ''), True);
OutputFolder := Ini.ReadString(IniSectionOptions, 'OutputFolder', '');
OutputFileFormat := TEnumUtils<TFileFormat>.StrToEnum(Ini.ReadString(IniSectionOptions, 'OutputFileFormat', ''));
BackgroundColor := StringToColorDef(Ini.ReadString(IniSectionOptions, 'BackgroundColor', ''), DefaultBackgroundColor);
MaxAngle := Ini.ReadFloat(IniSectionAdvanced, 'MaxAngle', DefaultMaxAngle);
ThresholdLevel := Ini.ReadInteger(IniSectionAdvanced, 'ThresholdLevel', DefaultThresholdLevel);
ForcedOutputFormat := TEnumUtils<TForcedOutputFormat>.StrToEnum(Ini.ReadString(IniSectionAdvanced, 'ForcedOutputFormat', ''));
SkipAngle := Ini.ReadFloat(IniSectionAdvanced, 'SkipAngle', DefaultSkipAngle);
JpegCompressionQuality := Ini.ReadInteger(IniSectionAdvanced, 'JpegCompressionQuality', DefaultJpegCompressionQuality);
TiffCompressionScheme := Ini.ReadInteger(IniSectionAdvanced, 'TiffCompressionScheme', DefaultTiffCompressionScheme);
DefaultExecutable := StrToBoolDef(Ini.ReadString(IniSectionAdvanced, 'DefaultExecutable', ''), True);
CustomExecutablePath := Ini.ReadString(IniSectionAdvanced, 'CustomExecutablePath', '');
end;
procedure TOptions.Reset;
begin
DefaultOutputFileOptions := True;
OutputFolder := '';
OutputFileFormat := ffSameAsInput;
BackgroundColor := DefaultBackgroundColor;
MaxAngle := DefaultMaxAngle;
ThresholdLevel := DefaultThresholdLevel;
ForcedOutputFormat := fofNone;
SkipAngle := DefaultSkipAngle;
JpegCompressionQuality := DefaultJpegCompressionQuality;
TiffCompressionScheme := DefaultTiffCompressionScheme;
DefaultExecutable := True;
CustomExecutablePath := '';
end;
end.
| 31.525862 | 129 | 0.724364 |
83defc8edea5d90820abfdc3cc7ca0796483ebb9
| 20,888 |
pas
|
Pascal
|
Source/JOSE/JOSE.Consumer.pas
|
viniciussanchez/delphi-jose-jwt
|
800efddd20fbbfae2a0711a1603c0882a15ca7d1
|
[
"Apache-2.0"
] | 2 |
2021-04-26T05:58:55.000Z
|
2021-09-24T11:58:02.000Z
|
Source/JOSE/JOSE.Consumer.pas
|
viniciussanchez/delphi-jose-jwt
|
800efddd20fbbfae2a0711a1603c0882a15ca7d1
|
[
"Apache-2.0"
] | null | null | null |
Source/JOSE/JOSE.Consumer.pas
|
viniciussanchez/delphi-jose-jwt
|
800efddd20fbbfae2a0711a1603c0882a15ca7d1
|
[
"Apache-2.0"
] | null | null | null |
{******************************************************************************}
{ }
{ Delphi JOSE Library }
{ Copyright (c) 2015-2021 Paolo Rossi }
{ https://github.com/paolo-rossi/delphi-jose-jwt }
{ }
{******************************************************************************}
{ }
{ Licensed under the Apache License, Version 2.0 (the "License"); }
{ you may not use this file except in compliance with the License. }
{ You may obtain a copy of the License at }
{ }
{ http://www.apache.org/licenses/LICENSE-2.0 }
{ }
{ Unless required by applicable law or agreed to in writing, software }
{ distributed under the License is distributed on an "AS IS" BASIS, }
{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }
{ See the License for the specific language governing permissions and }
{ limitations under the License. }
{ }
{******************************************************************************}
unit JOSE.Consumer;
{$IF DEFINED(FPC)}
{$MODE DELPHI}{$H+}
{$ENDIF}
interface
uses
{$IF DEFINED(FPC)}
SysUtils,
Classes,
{$ELSE}
System.SysUtils,
System.Generics.Collections,
System.Classes,
{$ENDIF}
JOSE.Types.Bytes,
JOSE.Core.Base,
JOSE.Core.Parts,
JOSE.Core.JWA,
JOSE.Core.JWK,
JOSE.Core.JWT,
JOSE.Core.JWS,
JOSE.Core.JWE,
JOSE.Context,
JOSE.Consumer.Validators;
type
/// <summary>
/// Base class for the Consumer Exceptions
/// </summary>
EInvalidJWTException = class(Exception)
public
procedure SetDetails(ADetails: TStrings);
end;
/// <summary>
/// JOSE Consumer interface to process and validate a JWT
/// </summary>
IJOSEConsumer = interface
['{A270E909-6D79-4FC1-B4F6-B9911EAB8D36}']
procedure Process(const ACompactToken: TJOSEBytes);
procedure ProcessContext(AContext: TJOSEContext);
procedure Validate(AContext: TJOSEContext);
end;
/// <summary>
/// Implementation of IJOSEConsumer interface
/// </summary>
TJOSEConsumer = class(TInterfacedObject, IJOSEConsumer)
private
FKey: TJOSEBytes;
FValidators: TJOSEValidatorArray;
FClaimsClass: TJWTClaimsClass;
FExpectedAlgorithms: TJOSEAlgorithms;
FRequireSignature: Boolean;
FRequireEncryption: Boolean;
FSkipSignatureVerification: Boolean;
FSkipVerificationKeyValidation: Boolean;
private
function SetKey(const AKey: TJOSEBytes): TJOSEConsumer;
function SetValidators(const AValidators: TJOSEValidatorArray): TJOSEConsumer;
function SetRequireSignature(ARequireSignature: Boolean): TJOSEConsumer;
function SetRequireEncryption(ARequireEncryption: Boolean): TJOSEConsumer;
function SetSkipSignatureVerification(ASkipSignatureVerification: Boolean): TJOSEConsumer;
function SetSkipVerificationKeyValidation(ASkipVerificationKeyValidation: Boolean): TJOSEConsumer;
function SetExpectedAlgorithms(AExpectedAlgorithms: TJOSEAlgorithms): TJOSEConsumer;
public
constructor Create(AClaimsClass: TJWTClaimsClass);
procedure Process(const ACompactToken: TJOSEBytes);
procedure ProcessContext(AContext: TJOSEContext);
procedure Validate(AContext: TJOSEContext);
end;
/// <summary>
/// Interface to configure a JOSEConsumer
/// </summary>
IJOSEConsumerBuilder = interface
['{8EC9CB4B-3233-493B-9366-F06CFFA81D99}']
// Custom Claim Class
function SetClaimsClass(AClaimsClass: TJWTClaimsClass): IJOSEConsumerBuilder;
// Key, Signature & Encryption verification
function SetEnableRequireEncryption: IJOSEConsumerBuilder;
function SetDisableRequireSignature: IJOSEConsumerBuilder;
function SetSkipSignatureVerification: IJOSEConsumerBuilder;
function SetSkipVerificationKeyValidation: IJOSEConsumerBuilder;
function SetVerificationKey(const AKey: TJOSEBytes): IJOSEConsumerBuilder;
function SetDecryptionKey(const AKey: TJOSEBytes): IJOSEConsumerBuilder;
function SetExpectedAlgorithms(AExpectedAlgorithms: TJOSEAlgorithms): IJOSEConsumerBuilder;
// String-based claims
function SetSkipDefaultAudienceValidation(): IJOSEConsumerBuilder;
function SetExpectedAudience(ARequireAudience: Boolean; const AExpectedAudience: TArray<string>): IJOSEConsumerBuilder;
function SetExpectedIssuer(ARequireIssuer: Boolean; const AExpectedIssuer: string): IJOSEConsumerBuilder;
function SetExpectedIssuers(ARequireIssuer: Boolean; const AExpectedIssuers: TArray<string>): IJOSEConsumerBuilder;
function SetRequireSubject: IJOSEConsumerBuilder;
function SetExpectedSubject(const ASubject: string): IJOSEConsumerBuilder;
function SetRequireJwtId: IJOSEConsumerBuilder;
function SetExpectedJwtId(const AJwtId: string): IJOSEConsumerBuilder;
// Date-based Claims
function SetRequireExpirationTime: IJOSEConsumerBuilder;
function SetRequireIssuedAt: IJOSEConsumerBuilder;
function SetRequireNotBefore: IJOSEConsumerBuilder;
function SetEvaluationTime(AEvaluationTime: TDateTime): IJOSEConsumerBuilder;
function SetAllowedClockSkew(AClockSkew: Integer; ATimeUnit: TJOSETimeUnit): IJOSEConsumerBuilder;
function SetMaxFutureValidity(AMaxFutureValidity: Integer; ATimeUnit: TJOSETimeUnit): IJOSEConsumerBuilder;
// External validators
function RegisterValidator(AValidator: TJOSEValidator): IJOSEConsumerBuilder;
// Validators skipping
function SetSkipAllValidators: IJOSEConsumerBuilder;
function SetSkipAllDefaultValidators: IJOSEConsumerBuilder;
function Build: IJOSEConsumer;
end;
/// <summary>
/// Used to create the appropriate TJOSEConsumer for the JWT processing needs.
/// Implements IJOSEConsumerBuilder interface
/// </summary>
TJOSEConsumerBuilder = class(TInterfacedObject, IJOSEConsumerBuilder)
private
FValidators: TJOSEValidatorArray;
FDateValidatorParams: TJOSEDateClaimsParams;
FDateValidator: TJOSEValidator;
FAudValidator: TJOSEValidator;
FIssValidator: TJOSEValidator;
FKey: TJOSEBytes;
FClaimsClass: TJWTClaimsClass;
FExpectedAlgorithms: TJOSEAlgorithms;
FDisableRequireSignature: Boolean;
FEnableRequireEncryption: Boolean;
FSkipVerificationKeyValidation: Boolean;
FRequireJwtId: Boolean;
FRequireSubject: Boolean;
FSkipAllDefaultValidators: Boolean;
FSkipAllValidators: Boolean;
FSkipDefaultAudienceValidation: Boolean;
FSkipSignatureVerification: Boolean;
FSubject: string;
FJwtId: string;
constructor Create;
procedure BuildValidators(const ADateParams: TJOSEDateClaimsParams);
public
class function NewConsumer: IJOSEConsumerBuilder;
destructor Destroy; override;
// Custom Claim Class
function SetClaimsClass(AClaimsClass: TJWTClaimsClass): IJOSEConsumerBuilder;
// Key, Signature & Encryption verification
function SetEnableRequireEncryption: IJOSEConsumerBuilder;
function SetDisableRequireSignature: IJOSEConsumerBuilder;
function SetSkipSignatureVerification: IJOSEConsumerBuilder;
function SetSkipVerificationKeyValidation: IJOSEConsumerBuilder;
function SetVerificationKey(const AKey: TJOSEBytes): IJOSEConsumerBuilder;
function SetDecryptionKey(const AKey: TJOSEBytes): IJOSEConsumerBuilder;
function SetExpectedAlgorithms(AExpectedAlgorithms: TJOSEAlgorithms): IJOSEConsumerBuilder;
// String-based claims
function SetSkipDefaultAudienceValidation(): IJOSEConsumerBuilder;
function SetExpectedAudience(ARequireAudience: Boolean; const AExpectedAudience: TArray<string>): IJOSEConsumerBuilder;
function SetExpectedIssuer(ARequireIssuer: Boolean; const AExpectedIssuer: string): IJOSEConsumerBuilder;
function SetExpectedIssuers(ARequireIssuer: Boolean; const AExpectedIssuers: TArray<string>): IJOSEConsumerBuilder;
function SetRequireSubject: IJOSEConsumerBuilder;
function SetExpectedSubject(const ASubject: string): IJOSEConsumerBuilder;
function SetRequireJwtId: IJOSEConsumerBuilder;
function SetExpectedJwtId(const AJwtId: string): IJOSEConsumerBuilder;
// Date-based Claims
function SetRequireExpirationTime: IJOSEConsumerBuilder;
function SetRequireIssuedAt: IJOSEConsumerBuilder;
function SetRequireNotBefore: IJOSEConsumerBuilder;
function SetEvaluationTime(AEvaluationTime: TDateTime): IJOSEConsumerBuilder;
function SetAllowedClockSkew(AClockSkew: Integer; ATimeUnit: TJOSETimeUnit): IJOSEConsumerBuilder;
function SetMaxFutureValidity(AMaxFutureValidity: Integer; ATimeUnit: TJOSETimeUnit): IJOSEConsumerBuilder;
// External validators
function RegisterValidator(AValidator: TJOSEValidator): IJOSEConsumerBuilder;
// Validators skipping
function SetSkipAllValidators: IJOSEConsumerBuilder;
function SetSkipAllDefaultValidators: IJOSEConsumerBuilder;
function Build: IJOSEConsumer;
end;
implementation
uses
{$IF DEFINED(FPC)}
Types,
StrUtils,
{$ELSE}
System.Types,
System.StrUtils,
{$ENDIF}
JOSE.Types.JSON;
function TJOSEConsumerBuilder.Build: IJOSEConsumer;
begin
if not Assigned(FClaimsClass) then
FClaimsClass := TJWTClaims;
BuildValidators(FDateValidatorParams);
Result := TJOSEConsumer.Create(FClaimsClass)
.SetKey(FKey)
.SetRequireSignature(not FDisableRequireSignature)
.SetRequireEncryption(FEnableRequireEncryption)
.SetSkipSignatureVerification(FSkipSignatureVerification)
.SetSkipVerificationKeyValidation(FSkipVerificationKeyValidation)
.SetExpectedAlgorithms(FExpectedAlgorithms)
.SetValidators(FValidators)
;
end;
procedure TJOSEConsumerBuilder.BuildValidators(const ADateParams: TJOSEDateClaimsParams);
begin
if not FSkipAllValidators then
begin
if not FSkipAllDefaultValidators then
begin
if not FSkipDefaultAudienceValidation then
begin
if not Assigned(FAudValidator) then
FAudValidator := TJOSEClaimsValidators.audValidator(TJOSEStringArray.Create, False);
FValidators.add(FAudValidator);
end;
if not Assigned(FIssValidator) then
FIssValidator := TJOSEClaimsValidators.issValidator('', False);
FValidators.Add(FIssValidator);
if not Assigned(FDateValidator) then
FDateValidator := TJOSEClaimsValidators.DateClaimsValidator(ADateParams);
FValidators.Add(FDateValidator);
if FSubject.IsEmpty then
FValidators.Add(TJOSEClaimsValidators.subValidator(FRequireSubject))
else
FValidators.Add(TJOSEClaimsValidators.subValidator(FSubject, FRequireSubject));
if FJwtId.IsEmpty then
FValidators.Add(TJOSEClaimsValidators.jtiValidator(FRequireJwtId))
else
FValidators.Add(TJOSEClaimsValidators.jtiValidator(FJwtId, FRequireJwtId));
end;
end;
end;
constructor TJOSEConsumerBuilder.Create;
begin
inherited;
FDateValidatorParams := TJOSEDateClaimsParams.New;
FExpectedAlgorithms := [TJOSEAlgorithmId.None,
TJOSEAlgorithmId.HS256, TJOSEAlgorithmId.HS384, TJOSEAlgorithmId.HS512,
TJOSEAlgorithmId.RS256, TJOSEAlgorithmId.RS384, TJOSEAlgorithmId.RS512,
TJOSEAlgorithmId.ES256, TJOSEAlgorithmId.ES384, TJOSEAlgorithmId.ES512,
TJOSEAlgorithmId.PS256, TJOSEAlgorithmId.PS384, TJOSEAlgorithmId.PS512];
end;
destructor TJOSEConsumerBuilder.Destroy;
begin
inherited;
end;
class function TJOSEConsumerBuilder.NewConsumer: IJOSEConsumerBuilder;
begin
Result := Self.Create;
end;
function TJOSEConsumerBuilder.RegisterValidator(AValidator: TJOSEValidator): IJOSEConsumerBuilder;
var
LLen: Integer;
begin
LLen := Length(FValidators);
SetLength(FValidators, LLen + 1);
FValidators[LLen] := AValidator;
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetAllowedClockSkew(AClockSkew: Integer;
ATimeUnit: TJOSETimeUnit): IJOSEConsumerBuilder;
begin
FDateValidatorParams.AllowedClockSkewSeconds := ATimeUnit.ToSeconds(AClockSkew);
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetClaimsClass(AClaimsClass: TJWTClaimsClass): IJOSEConsumerBuilder;
begin
FClaimsClass := AClaimsClass;
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetDecryptionKey(const AKey: TJOSEBytes): IJOSEConsumerBuilder;
begin
FKey := AKey;
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetDisableRequireSignature: IJOSEConsumerBuilder;
begin
FDisableRequireSignature := True;
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetEnableRequireEncryption: IJOSEConsumerBuilder;
begin
FEnableRequireEncryption := True;
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetEvaluationTime(AEvaluationTime: TDateTime): IJOSEConsumerBuilder;
begin
FDateValidatorParams.StaticEvaluationTime := AEvaluationTime;
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetExpectedAlgorithms(
AExpectedAlgorithms: TJOSEAlgorithms): IJOSEConsumerBuilder;
begin
FExpectedAlgorithms := AExpectedAlgorithms;
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetExpectedAudience(ARequireAudience: Boolean;
const AExpectedAudience: TArray<string>): IJOSEConsumerBuilder;
begin
FAudValidator := TJOSEClaimsValidators.audValidator(AExpectedAudience, ARequireAudience);
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetExpectedIssuer(ARequireIssuer: Boolean;
const AExpectedIssuer: string): IJOSEConsumerBuilder;
begin
FIssValidator := TJOSEClaimsValidators.issValidator(AExpectedIssuer, ARequireIssuer);
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetExpectedIssuers(ARequireIssuer: Boolean;
const AExpectedIssuers: TArray<string>): IJOSEConsumerBuilder;
begin
FIssValidator := TJOSEClaimsValidators.issValidator(AExpectedIssuers, ARequireIssuer);
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetExpectedJwtId(const AJwtId: string): IJOSEConsumerBuilder;
begin
FJwtId := AJwtId;
SetRequireJwtId;
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetExpectedSubject(const ASubject: string): IJOSEConsumerBuilder;
begin
FSubject := ASubject;
SetRequireSubject;
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetMaxFutureValidity(AMaxFutureValidity: Integer;
ATimeUnit: TJOSETimeUnit): IJOSEConsumerBuilder;
begin
FDateValidatorParams.MaxFutureValidityInMinutes := ATimeUnit.ToMinutes(AMaxFutureValidity);
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetSkipVerificationKeyValidation: IJOSEConsumerBuilder;
begin
FSkipVerificationKeyValidation := True;
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetRequireExpirationTime: IJOSEConsumerBuilder;
begin
FDateValidatorParams.RequireExp := True;
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetRequireIssuedAt: IJOSEConsumerBuilder;
begin
FDateValidatorParams.RequireIat := True;
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetRequireJwtId: IJOSEConsumerBuilder;
begin
FRequireJwtId := True;
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetRequireNotBefore: IJOSEConsumerBuilder;
begin
FDateValidatorParams.RequireNbf := True;
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetRequireSubject: IJOSEConsumerBuilder;
begin
FRequireSubject := True;
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetSkipAllDefaultValidators: IJOSEConsumerBuilder;
begin
FSkipAllDefaultValidators := True;
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetSkipAllValidators: IJOSEConsumerBuilder;
begin
FSkipAllValidators := True;
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetSkipDefaultAudienceValidation: IJOSEConsumerBuilder;
begin
FSkipDefaultAudienceValidation := True;
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetSkipSignatureVerification: IJOSEConsumerBuilder;
begin
FSkipSignatureVerification := True;
Result := Self as IJOSEConsumerBuilder;
end;
function TJOSEConsumerBuilder.SetVerificationKey(const AKey: TJOSEBytes): IJOSEConsumerBuilder;
begin
FKey := AKey;
Result := Self as IJOSEConsumerBuilder;
end;
{ TJOSEConsumer }
constructor TJOSEConsumer.Create(AClaimsClass: TJWTClaimsClass);
begin
FClaimsClass := AClaimsClass;
FRequireSignature := True;
end;
procedure TJOSEConsumer.Process(const ACompactToken: TJOSEBytes);
var
LContext: TJOSEContext;
begin
LContext := TJOSEContext.Create(ACompactToken, FClaimsClass);
try
ProcessContext(LContext);
finally
LContext.Free;
end;
end;
procedure TJOSEConsumer.ProcessContext(AContext: TJOSEContext);
var
LJWS: TJWS;
LHasSignature: Boolean;
//LJWE: TJWE;
begin
LHasSignature := False;
if AContext.GetJOSEObject is TJWS then
begin
LJWS := AContext.GetJOSEObject<TJWS>;
// JWS Signature Verification
if not FSkipSignatureVerification then
begin
if not (LJWS.HeaderAlgorithmId in FExpectedAlgorithms) then
raise EJOSEException.CreateFmt('JWS algorithm [%s] is not listed among those expected', [LJWS.HeaderAlgorithm]);
if FSkipVerificationKeyValidation then
LJWS.SkipKeyValidation := True;
LJWS.SetKey(Self.FKey);
if not LJWS.VerifySignature then
raise EJOSEException.Create('JWS signature is invalid: ' + LJWS.Signature);
end;
if LJWS.HeaderAlgorithm <> TJOSEAlgorithmId.None.AsString then
LHasSignature := True;
if FRequireSignature and not LHasSignature then
raise EJOSEException.Create('The JWT has no signature but the JWT Consumer is configured to require one');
end
else if AContext.GetJOSEObject is TJWE then
begin
end;
Validate(AContext);
end;
function TJOSEConsumer.SetExpectedAlgorithms(AExpectedAlgorithms: TJOSEAlgorithms): TJOSEConsumer;
begin
FExpectedAlgorithms := AExpectedAlgorithms;
Result := Self;
end;
function TJOSEConsumer.SetKey(const AKey: TJOSEBytes): TJOSEConsumer;
begin
FKey := AKey;
Result := Self;
end;
function TJOSEConsumer.SetSkipVerificationKeyValidation(ASkipVerificationKeyValidation: Boolean): TJOSEConsumer;
begin
FSkipVerificationKeyValidation := ASkipVerificationKeyValidation;
Result := Self;
end;
function TJOSEConsumer.SetRequireEncryption(ARequireEncryption: Boolean): TJOSEConsumer;
begin
FRequireEncryption := ARequireEncryption;
Result := Self;
end;
function TJOSEConsumer.SetRequireSignature(ARequireSignature: Boolean): TJOSEConsumer;
begin
FRequireSignature := ARequireSignature;
Result := Self;
end;
function TJOSEConsumer.SetSkipSignatureVerification(ASkipSignatureVerification: Boolean): TJOSEConsumer;
begin
FSkipSignatureVerification := ASkipSignatureVerification;
Result := Self;
end;
function TJOSEConsumer.SetValidators(const AValidators: TJOSEValidatorArray): TJOSEConsumer;
begin
FValidators := AValidators;
Result := Self;
end;
procedure TJOSEConsumer.Validate(AContext: TJOSEContext);
var
LValidator: TJOSEValidator;
LResult: string;
LIssues: TStringList;
LException: EInvalidJWTException;
begin
LIssues := TStringList.Create;
try
for LValidator in FValidators do
begin
LResult := LValidator(AContext);
if LResult.IsEmpty then
Continue;
LIssues.Add(LResult);
end;
if LIssues.Count > 0 then
begin
LException := EInvalidJWTException.CreateFmt(
'JWT (claims: %s) rejected due to invalid claims.',
[TJSONUtils.ToJSON(AContext.GetClaims.JSON)]);
LException.SetDetails(LIssues);
raise LException;
end;
finally
LIssues.Free;
end;
end;
{ EInvalidJWTException }
procedure EInvalidJWTException.SetDetails(ADetails: TStrings);
var
LDetails: TSTringList;
begin
if ADetails.Count > 0 then
begin
LDetails := TStringList.Create;
try
LDetails.Add(Message);
LDetails.Add('Validation errors:');
LDetails.AddStrings(ADetails);
Message := LDetails.Text;
finally
LDetails.Free;
end;
end;
end;
end.
| 34.355263 | 123 | 0.748947 |
f123495b4f1667e78e03d2a7ff221f4dcfae8234
| 34,685 |
pas
|
Pascal
|
src/RestClient.pas
|
monde-sistemas/delphi-rest-client-api
|
df074e7c806d984bdb05b51e42d9f270f0978697
|
[
"Apache-2.0"
] | 1 |
2018-07-15T17:52:10.000Z
|
2018-07-15T17:52:10.000Z
|
src/RestClient.pas
|
monde-sistemas/delphi-rest-client-api
|
df074e7c806d984bdb05b51e42d9f270f0978697
|
[
"Apache-2.0"
] | 2 |
2016-10-27T11:35:10.000Z
|
2017-01-18T13:58:18.000Z
|
src/RestClient.pas
|
monde-sistemas/delphi-rest-client-api
|
df074e7c806d984bdb05b51e42d9f270f0978697
|
[
"Apache-2.0"
] | 1 |
2016-01-29T13:48:49.000Z
|
2016-01-29T13:48:49.000Z
|
unit RestClient;
{$I DelphiRest.inc}
interface
uses Classes, SysUtils, HttpConnection,
RestUtils, RestJsonUtils,
{$IFDEF SUPPORTS_GENERICS}
Generics.Collections, Rtti, TypInfo,
{$ELSE}
Contnrs, OldRttiUnMarshal,
{$ENDIF}
DB, JsonListAdapter, RestException;
const
DEFAULT_COOKIE_VERSION = 1; {Cookies using the default version correspond to RFC 2109.}
type
TRequestMethod = (METHOD_GET, METHOD_POST, METHOD_PUT, METHOD_PATCH, METHOD_DELETE);
{$IFDEF SUPPORTS_ANONYMOUS_METHODS}
TRestResponseHandlerFunc = reference to procedure(ResponseContent: TStream);
{$ENDIF}
TRestResponseHandler = procedure (ResponseContent: TStream) of object;
TResource = class;
TCustomCreateConnection = procedure(Sender: TObject; AConnectionType: THttpConnectionType; out AConnection: IHttpConnection) of object;
TJsonListAdapter = class(TInterfacedObject, IJsonListAdapter)
private
FItemClass: TClass;
FWrappedList: TList;
public
function ItemClass: TClass;
function UnWrapList: TList;
constructor Create(AList: TList; AItemClass: TClass);
class function NewFrom(AList: TList; AItemClass: TClass): IJsonListAdapter;
end;
TRestClient = class;
TRestOnRequestEvent = procedure (ARestClient: TRestClient;
AResource: TResource; AMethod: TRequestMethod) of object;
TRestOnResponseEvent = procedure (ARestClient: TRestClient; ResponseCode: Integer; const ResponseContent: string) of object;
THTTPErrorEvent = procedure(ARestClient: TRestClient; AResource: TResource;
AMethod: TRequestMethod; AHTTPError: EHTTPError;
var ARetryMode: THTTPRetryMode) of object;
TRestClient = class(TComponent)
private
FHttpConnection: IHttpConnection;
{$IFDEF SUPPORTS_GENERICS}
FResources: TObjectList<TResource>;
{$ELSE}
FResources: TObjectList;
{$ENDIF}
FConnectionType: THttpConnectionType;
FEnabledCompression: Boolean;
FOnCustomCreateConnection: TCustomCreateConnection;
FTimeOut: TTimeOut;
FProxyCredentials: TProxyCredentials;
FLogin: String;
FOnAsyncRequestProcess: TAsyncRequestProcessEvent;
FPassword: String;
FOnError: THTTPErrorEvent;
FVerifyCert: boolean;
{$IFDEF SUPPORTS_ANONYMOUS_METHODS}
FTempHandler: TRestResponseHandlerFunc;
procedure DoRequestFunc(Method: TRequestMethod; ResourceRequest: TResource; AHandler: TRestResponseHandlerFunc);
procedure HandleAnonymousMethod(ResponseContent: TStream);
{$ENDIF}
function DoRequest(Method: TRequestMethod; ResourceRequest: TResource; AHandler: TRestResponseHandler = nil): String;overload;
function GetResponseCode: Integer;
procedure SetConnectionType(const Value: THttpConnectionType);
procedure RecreateConnection;
procedure CheckConnection;
procedure SetEnabledCompression(const Value: Boolean);
function DoCustomCreateConnection: IHttpConnection;
function GetOnError: THTTPErrorEvent;
procedure SetOnError(AErrorEvent: THTTPErrorEvent);
function GetResponseHeader(const Header: string): string;
procedure SetVerifyCertificate(AValue: boolean);
protected
procedure Loaded; override;
function ResponseCodeRaisesError(ResponseCode: Integer): Boolean; virtual;
function GetOnConnectionLost: THTTPConnectionLostEvent; virtual;
procedure SetOnConnectionLost(AConnectionLostEvent: THTTPConnectionLostEvent); virtual;
public
OnBeforeRequest: TRestOnRequestEvent;
OnAfterRequest: TRestOnRequestEvent;
OnResponse: TRestOnResponseEvent;
constructor Create(Owner: TComponent); override;
destructor Destroy; override;
property ResponseCode: Integer read GetResponseCode;
property ResponseHeader[const Header: string]: string read GetResponseHeader;
function Resource(URL: String): TResource;
function UnWrapConnection: IHttpConnection;
function SetCredentials(const ALogin, APassword: String): TRestClient;
property OnConnectionLost: THTTPConnectionLostEvent read GetOnConnectionLost write SetOnConnectionLost;
property OnError: THTTPErrorEvent read GetOnError write SetOnError;
property OnAsyncRequestProcess: TAsyncRequestProcessEvent read FOnAsyncRequestProcess write FOnAsyncRequestProcess;
published
property ConnectionType: THttpConnectionType read FConnectionType write SetConnectionType;
property EnabledCompression: Boolean read FEnabledCompression write SetEnabledCompression default True;
property VerifyCert: Boolean read FVerifyCert write SetVerifyCertificate default True;
property OnCustomCreateConnection: TCustomCreateConnection read FOnCustomCreateConnection write FOnCustomCreateConnection;
property TimeOut: TTimeOut read FTimeOut;
property ProxyCredentials: TProxyCredentials read FProxyCredentials;
end;
TCookie = class
private
FName: String;
FValue: String;
FVersion: Integer;
FPath: String;
FDomain: String;
public
property Name: String read FName;
property Value: String read FValue;
property Version: Integer read FVersion default DEFAULT_COOKIE_VERSION;
property Path: String read FPath;
property Domain: String read FDomain;
end;
TResource = class
private
FRestClient: TRestClient;
FURL: string;
FAcceptTypes: string;
FContent: TMemoryStream;
FContentTypes: string;
FHeaders: TStrings;
FAcceptedLanguages: string;
FAsync: Boolean;
constructor Create(RestClient: TRestClient; URL: string);
procedure SetContent(entity: TObject);
function EntityRequest(Entity: TObject; ResultClass: TClass; Method: TRequestMethod; AHandler: TRestResponseHandler = nil): TObject;
function ContentRequest(Content: TStream; Method: TRequestMethod; AHandler: TRestResponseHandler = nil): string; overload;
function ContentRequest(Content: TStream; ResultClass: TClass; Method: TRequestMethod; AHandler: TRestResponseHandler = nil): TObject; overload;
{$IFDEF SUPPORTS_GENERICS}
function ParseGenericResponse<T>(Response: string): T;
{$ENDIF}
public
destructor Destroy; override;
function GetAcceptTypes: string;
function GetURL: string;
function GetContent: TStream;
function GetContentTypes: string;
function GetHeaders: TStrings;
function GetAcceptedLanguages: string;
function GetAsync: Boolean;
function Accept(AcceptType: String): TResource;
function Async(const Value: Boolean = True): TResource;
function Authorization(Authorization: String): TResource;
function ContentType(ContentType: String): TResource;
function AcceptLanguage(Language: String): TResource;
function Header(Name: String; Value: string): TResource;
//function Cookie(Cookie: TCookie): TResource;
function Get: string;overload;
procedure Get(AHandler: TRestResponseHandler);overload;
function Get(EntityClass: TClass): TObject;overload;
function Post(Content: TStream): String;overload;
function Post(Content: string): String;overload;
procedure Post(Content: TStream; AHandler: TRestResponseHandler);overload;
function Post(Entity: TObject): TObject;overload;
function Post(Content: string; ResultClass: TClass): TObject;overload;
function Post(Content: TStream; ResultClass: TClass): TObject;overload;
function Post(Entity: TObject; ResultClass: TClass): TObject;overload;
function Put(Content: TStream): String;overload;
function Put(Content: string): string;overload;
procedure Put(Content: TStream; AHandler: TRestResponseHandler);overload;
function Put(Entity: TObject): TObject;overload;
function Put(Content: string; ResultClass: TClass): TObject;overload;
function Put(Content: TStream; ResultClass: TClass): TObject;overload;
function Put(Entity: TObject; ResultClass: TClass): TObject;overload;
function Patch(Content: TStream): String;overload;
function Patch(Content: string): string;overload;
procedure Patch(Content: TStream; AHandler: TRestResponseHandler);overload;
function Patch(Entity: TObject): TObject;overload;
function Patch(Content: string; ResultClass: TClass): TObject;overload;
function Patch(Content: TStream; ResultClass: TClass): TObject;overload;
function Patch(Entity: TObject; ResultClass: TClass): TObject;overload;
procedure Delete(); overload;
procedure Delete(Entity: TObject); overload;
function Delete(Content: string): string; overload;
function Delete(Content: TStream): string; overload;
{$IFDEF SUPPORTS_ANONYMOUS_METHODS}
procedure Get(AHandler: TRestResponseHandlerFunc);overload;
procedure Post(Content: TStream; AHandler: TRestResponseHandlerFunc);overload;
Procedure Post(Entity: TObject; AHandler: TRestResponseHandlerFunc);overload;
procedure Put(Content: TStream; AHandler: TRestResponseHandlerFunc);overload;
procedure Patch(Content: TStream; AHandler: TRestResponseHandlerFunc);overload;
{$ENDIF}
{$IFDEF SUPPORTS_GENERICS}
function Get<T>(): T;overload;
function Post<T>(Content: TObject): T; overload;
function Post<T>(Content: string): T; overload;
function Put<T>(Content: TObject): T; overload;
function Put<T>(Content: string): T; overload;
function Patch<T>(Content: TObject): T; overload;
function Patch<T>(Content: string): T; overload;
function Delete<T>(Content: TObject): T; overload;
function Delete<T>(Content: string): T; overload;
{$ELSE}
function Get(AListClass, AItemClass: TClass): TObject;overload;
function Post(Adapter: IJsonListAdapter): TObject;overload;
function Put(Adapter: IJsonListAdapter): TObject;overload;
function Patch(Adapter: IJsonListAdapter): TObject;overload;
{$ENDIF}
{$IFDEF USE_SUPER_OBJECT}
procedure GetAsDataSet(ADataSet: TDataSet);overload;
function GetAsDataSet(): TDataSet;overload;
function GetAsDataSet(const RootElement: String): TDataSet;overload;
{$ENDIF}
end;
{$IFDEF SUPPORTS_GENERICS}
TMultiPartFormAttachment = class
private
FFileName: string;
FMimeType: string;
FContent: TStringStream;
public
constructor Create(MimeType, FileName: string); overload;
constructor Create(Source: TStream; MimeType, FileName: string); overload;
constructor Create(FilePath, MimeType, FileName: string); overload;
destructor Destroy; override;
property Content: TStringStream read FContent write FContent;
property MimeType: string read FMimeType write FMimeType;
property FileName: string read FFileName write FFileName;
end;
TMultiPartFormData = class
private
FBoundary: string;
FContentType: string;
procedure AddFieldContent(Field: TRttiField; var Content: TStringList);
public
constructor Create;
function ContentAsString: string;
property ContentType: string read FContentType;
end;
{$ENDIF}
implementation
uses StrUtils, Math,
{$IFDEF USE_SUPER_OBJECT}
SuperObject, JsonToDataSetConverter,
{$ENDIF}
HttpConnectionFactory;
{ TRestClient }
constructor TRestClient.Create(Owner: TComponent);
begin
inherited;
{$IFDEF SUPPORTS_GENERICS}
FResources := TObjectList<TResource>.Create;
{$ELSE}
FResources := TObjectList.Create;
{$ENDIF}
FTimeOut := TTimeOut.Create(Self);
FTimeOut.Name := 'TimeOut';
FTimeOut.SetSubComponent(True);
FProxyCredentials := TProxyCredentials.Create(Self);
FProxyCredentials.Name := 'ProxyCredentials';
FProxyCredentials.SetSubComponent(True);
FLogin := '';
FPassword := '';
FEnabledCompression := True;
FVerifyCert := True;
end;
destructor TRestClient.Destroy;
begin
if FHttpConnection <> nil then
FHttpConnection.CancelRequest;
FResources.Free;
FHttpConnection := nil;
inherited;
end;
function TRestClient.DoCustomCreateConnection: IHttpConnection;
begin
if Assigned(FOnCustomCreateConnection) then
begin
FOnCustomCreateConnection(Self, FConnectionType, Result);
if Result = nil then
begin
raise ECustomCreateConnectionException.Create('HttpConnection not supplied by OnCustomCreateConnection');
end;
end
else
begin
raise EInvalidHttpConnectionConfiguration.Create('ConnectionType is set to Custom but OnCustomCreateConnection event is not implemented.');
end;
end;
function TRestClient.DoRequest(Method: TRequestMethod; ResourceRequest: TResource; AHandler: TRestResponseHandler): String;
const
AuthorizationHeader = 'Authorization';
var
vResponse: TStringStream;
vUrl: String;
vResponseString: string;
vRetryMode: THTTPRetryMode;
vHeaders: TStrings;
vEncodedCredentials: string;
vHttpError: EHTTPError;
begin
CheckConnection;
vResponse := TStringStream.Create('');
try
vHeaders := ResourceRequest.GetHeaders;
if (FLogin <> EmptyStr) and (vHeaders.IndexOfName(AuthorizationHeader) = -1) then
begin
vEncodedCredentials := TRestUtils.Base64Encode(Format('%s:%s', [FLogin, FPassword]));
vHeaders.Values[AuthorizationHeader] := 'Basic ' + vEncodedCredentials;
end;
FHttpConnection.SetAcceptTypes(ResourceRequest.GetAcceptTypes)
.SetContentTypes(ResourceRequest.GetContentTypes)
.SetHeaders(vHeaders)
.SetAcceptedLanguages(ResourceRequest.GetAcceptedLanguages)
.ConfigureTimeout(FTimeOut)
.ConfigureProxyCredentials(FProxyCredentials)
.SetAsync(ResourceRequest.GetAsync)
.SetOnAsyncRequestProcess(FOnAsyncRequestProcess);
vUrl := ResourceRequest.GetURL;
ResourceRequest.GetContent.Position := 0;
if assigned(OnBeforeRequest) then
OnBeforeRequest(self, ResourceRequest, Method);
ResourceRequest.GetContent.Position := 0;
case Method of
METHOD_GET: FHttpConnection.Get(vUrl, vResponse);
METHOD_POST: FHttpConnection.Post(vURL, ResourceRequest.GetContent, vResponse);
METHOD_PUT: FHttpConnection.Put(vURL, ResourceRequest.GetContent, vResponse);
METHOD_PATCH: FHttpConnection.Patch(vURL, ResourceRequest.GetContent, vResponse);
METHOD_DELETE: FHttpConnection.Delete(vUrl, ResourceRequest.GetContent, vResponse);
end;
if Assigned(AHandler) then
AHandler(vResponse)
else
begin
{$IFDEF UNICODE}
vResponseString := vResponse.DataString;
{$IFDEF NEXTGEN}
Result := TEncoding.UTF8.GetString(TEncoding.UTF8.GetBytes(vResponseString.ToCharArray), 0, vResponseString.Length);
{$ELSE}
Result := UTF8ToUnicodeString(RawByteString(vResponseString));
{$ENDIF}
{$ELSE}
vResponseString := vResponse.DataString;
Result := UTF8Decode(vResponse.DataString);
{$ENDIF}
if Assigned(OnResponse) then
OnResponse(Self, FHttpConnection.ResponseCode, Result);
end;
if ResponseCodeRaisesError(FHttpConnection.ResponseCode) then
begin
vRetryMode := hrmRaise;
if assigned(FOnError) then
begin
vHttpError := EHTTPError.Create(
format('HTTP Error: %d', [FHttpConnection.ResponseCode]),
Result,
FHTTPConnection.ResponseCode
);
try
FOnError(
self,
ResourceRequest,
Method,
vHttpError,
vRetryMode
);
finally
vHttpError.Free;
end;
end;
if vRetryMode = hrmRaise then
raise EHTTPError.Create(
format('HTTP Error: %d', [FHttpConnection.ResponseCode]),
Result,
FHttpConnection.ResponseCode
)
else if vRetryMode = hrmRetry then
result := DoRequest(Method, ResourceRequest, AHandler)
else
result := '';
end
else
if assigned(OnAfterRequest) then
OnAfterRequest(self, ResourceRequest, Method);
finally
vResponse.Free;
FResources.Remove(ResourceRequest);
end;
end;
{$IFDEF SUPPORTS_ANONYMOUS_METHODS}
procedure TRestClient.DoRequestFunc(Method: TRequestMethod; ResourceRequest: TResource; AHandler: TRestResponseHandlerFunc);
begin
FTempHandler := AHandler;
DoRequest(Method, ResourceRequest, HandleAnonymousMethod);
end;
procedure TRestClient.HandleAnonymousMethod(ResponseContent: TStream);
begin
FTempHandler(ResponseContent);
FTempHandler := nil;
end;
{$ENDIF}
function TRestClient.GetOnConnectionLost: THTTPConnectionLostEvent;
begin
result := FHttpConnection.OnConnectionLost;
end;
function TRestClient.GetOnError: THTTPErrorEvent;
begin
result := FOnError;
end;
function TRestClient.GetResponseCode: Integer;
begin
CheckConnection;
Result := FHttpConnection.ResponseCode;
end;
function TRestClient.GetResponseHeader(const Header: string): string;
begin
CheckConnection;
Result := FHttpConnection.ResponseHeader[Header];
end;
procedure TRestClient.RecreateConnection;
begin
if not (csDesigning in ComponentState) then
begin
if FConnectionType = hctCustom then
begin
FHttpConnection := DoCustomCreateConnection;
end
else
begin
FHttpConnection := THttpConnectionFactory.NewConnection(FConnectionType);
FHttpConnection.EnabledCompression := FEnabledCompression;
FHttpConnection.VerifyCert := FVerifyCert;
end;
end;
end;
procedure TRestClient.CheckConnection;
begin
if (FHttpConnection = nil) then
begin
raise EInactiveConnection.CreateFmt('%s: Connection is not active.', [Name]);
end;
end;
procedure TRestClient.Loaded;
begin
RecreateConnection;
end;
function TRestClient.Resource(URL: String): TResource;
begin
Result := TResource.Create(Self, URL);
FResources.Add(Result);
end;
function TRestClient.ResponseCodeRaisesError(ResponseCode: Integer): Boolean;
begin
Result := (ResponseCode >= TStatusCode.BAD_REQUEST.StatusCode);
end;
procedure TRestClient.SetVerifyCertificate(AValue: boolean);
begin
if FVerifyCert = AValue then
exit;
FVerifyCert := AValue;
if Assigned(FHttpConnection) then
begin
FHttpConnection.VerifyCert := FVerifyCert;
end;
end;
procedure TRestClient.SetConnectionType(const Value: THttpConnectionType);
begin
if (FConnectionType <> Value) then
begin
FConnectionType := Value;
RecreateConnection;
end;
end;
function TRestClient.SetCredentials(const ALogin, APassword: String): TRestClient;
begin
FLogin := ALogin;
FPassword := APassword;
Result := Self;
end;
procedure TRestClient.SetEnabledCompression(const Value: Boolean);
begin
if (FEnabledCompression <> Value) then
begin
FEnabledCompression := Value;
if Assigned(FHttpConnection) then
begin
FHttpConnection.EnabledCompression := FEnabledCompression;
end;
end;
end;
procedure TRestClient.SetOnConnectionLost(
AConnectionLostEvent: THTTPConnectionLostEvent);
begin
FHttpConnection.OnConnectionLost := AConnectionLostEvent;
end;
procedure TRestClient.SetOnError(AErrorEvent: THTTPErrorEvent);
begin
FOnError := AErrorEvent;
end;
function TRestClient.UnWrapConnection: IHttpConnection;
begin
Result := FHttpConnection;
end;
{ TResource }
function TResource.Accept(AcceptType: String): TResource;
begin
FAcceptTypes := FAcceptTypes + IfThen(FAcceptTypes <> EmptyStr,',') + AcceptType;
Result := Self;
end;
procedure TResource.Get(AHandler: TRestResponseHandler);
begin
FRestClient.DoRequest(METHOD_GET, Self, AHandler);
end;
procedure TResource.Post(Content: TStream; AHandler: TRestResponseHandler);
begin
ContentRequest(Content, METHOD_POST, AHandler)
end;
function TResource.Put(Content: string): string;
var
vStringStream: TStringStream;
begin
vStringStream := TStringStream.Create(Content, TEncoding.UTF8);
try
Result := Put(vStringStream);
finally
vStringStream.Free;
end;
end;
function TResource.Post(Content: string): String;
var
vStringStream: TStringStream;
begin
vStringStream := TStringStream.Create(Content, TEncoding.UTF8);
try
Result := Post(vStringStream);
finally
vStringStream.Free;
end;
end;
procedure TResource.Put(Content: TStream; AHandler: TRestResponseHandler);
begin
ContentRequest(Content, METHOD_PUT, AHandler);
end;
{$IFDEF SUPPORTS_ANONYMOUS_METHODS}
procedure TResource.Get(AHandler: TRestResponseHandlerFunc);
begin
FRestClient.DoRequestFunc(METHOD_GET, Self, AHandler);
end;
procedure TResource.Post(Entity: TObject; AHandler: TRestResponseHandlerFunc);
begin
SetContent(Entity);
FRestClient.DoRequestFunc(METHOD_POST, Self, AHandler);
end;
procedure TResource.Post(Content: TStream; AHandler: TRestResponseHandlerFunc);
begin
Content.Position := 0;
FContent.CopyFrom(Content, Content.Size);
FRestClient.DoRequestFunc(METHOD_POST, Self, AHandler);
end;
procedure TResource.Put(Content: TStream; AHandler: TRestResponseHandlerFunc);
begin
Content.Position := 0;
FContent.CopyFrom(Content, Content.Size);
FRestClient.DoRequestFunc(METHOD_PUT, Self, AHandler );
end;
procedure TResource.Patch(Content: TStream; AHandler: TRestResponseHandlerFunc);
begin
Content.Position := 0;
FContent.CopyFrom(Content, Content.Size);
FRestClient.DoRequestFunc(METHOD_PATCH, Self, AHandler );
end;
{$ENDIF}
function TResource.Get(EntityClass: TClass): TObject;
var
vResponse: string;
begin
vResponse := Self.Get;
Result := TJsonUtil.UnMarshal(EntityClass, vResponse);
end;
function TResource.GetAcceptedLanguages: string;
begin
Result := FAcceptedLanguages;
end;
function TResource.AcceptLanguage(Language: String): TResource;
begin
Result := Header('Accept-Language', Language);
end;
function TResource.Async(const Value: Boolean = True): TResource;
begin
FAsync := True;
Result := Self;
end;
function TResource.Authorization(Authorization: String): TResource;
begin
Result := Header('Authorization', Authorization);
end;
function TResource.ContentRequest(Content: TStream; Method: TRequestMethod;
AHandler: TRestResponseHandler): string;
begin
FContent.Clear;
if assigned(Content) then
begin
Content.Position := 0;
FContent.CopyFrom(Content, Content.Size);
end;
Result := FRestClient.DoRequest(Method, Self, AHandler);
end;
function TResource.ContentRequest(Content: TStream; ResultClass: TClass;
Method: TRequestMethod; AHandler: TRestResponseHandler): TObject;
var
vResponse: string;
begin
vResponse := ContentRequest(Content, Method, AHandler);
if Trim(vResponse) <> '' then
Result := TJsonUtil.UnMarshal(ResultClass, vResponse)
else
Result := nil;
end;
function TResource.ContentType(ContentType: String): TResource;
begin
FContentTypes := ContentType;
Result := Self;
end;
constructor TResource.Create(RestClient: TRestClient; URL: string);
begin
inherited Create;
FRestClient := RestClient;
FURL := URL;
FContent := TMemoryStream.Create;
FHeaders := TStringList.Create;
end;
procedure TResource.Delete();
begin
FRestClient.DoRequest(METHOD_DELETE, Self);
end;
procedure TResource.Delete(Entity: TObject);
begin
SetContent(Entity);
FRestClient.DoRequest(METHOD_DELETE, Self);
end;
function TResource.Delete(Content: string): string;
var
Stream: TStringStream;
begin
Stream := TStringStream.Create(Content, TEncoding.UTF8);
try
Result := Delete(Stream);
finally
Stream.Free;
end;
end;
function TResource.Delete(Content: TStream): string;
begin
Result := ContentRequest(Content, METHOD_DELETE);
end;
destructor TResource.Destroy;
begin
FRestClient.FResources.Extract(Self);
FContent.Free;
FHeaders.Free;
inherited;
end;
function TResource.EntityRequest(Entity: TObject; ResultClass: TClass; Method: TRequestMethod; AHandler: TRestResponseHandler = nil): TObject;
var
vResponse: string;
begin
if Entity <> nil then
SetContent(Entity);
vResponse := FRestClient.DoRequest(Method, Self, AHandler);
if Trim(vResponse) <> '' then
Result := TJsonUtil.UnMarshal(ResultClass, vResponse)
else
Result := nil;
end;
function TResource.Get: string;
begin
Result := FRestClient.DoRequest(METHOD_GET, Self);
end;
function TResource.GetAcceptTypes: string;
begin
Result := FAcceptTypes;
end;
function TResource.GetAsync: Boolean;
begin
Result := FAsync;
end;
function TResource.GetContent: TStream;
begin
Result := FContent;
end;
function TResource.GetContentTypes: string;
begin
Result := FContentTypes;
end;
function TResource.GetHeaders: TStrings;
begin
Result := FHeaders;
end;
function TResource.GetURL: string;
begin
Result := FURL;
end;
function TResource.Header(Name, Value: string): TResource;
begin
FHeaders.Add(Format('%s=%s', [Name, Value]));
Result := Self;
end;
function TResource.Post(Content: TStream): String;
begin
Result := ContentRequest(Content, METHOD_POST)
end;
{$IFDEF SUPPORTS_GENERICS}
function TResource.ParseGenericResponse<T>(Response: string): T;
begin
if Trim(Response).IsEmpty then
Exit(Default(T));
Result := TJsonUtil.UnMarshal<T>(Response);
end;
function TResource.Get<T>(): T;
begin
Result := ParseGenericResponse<T>(Self.Get);
end;
function TResource.Post<T>(Content: TObject): T;
begin
SetContent(Content);
Result := ParseGenericResponse<T>(FRestClient.DoRequest(METHOD_POST, Self));
end;
function TResource.Post<T>(Content: string): T;
begin
Result := ParseGenericResponse<T>(Post(Content));
end;
function TResource.Put<T>(Content: TObject): T;
begin
SetContent(Content);
Result := ParseGenericResponse<T>(FRestClient.DoRequest(METHOD_PUT, Self));
end;
function TResource.Put<T>(Content: string): T;
begin
Result := ParseGenericResponse<T>(Put(Content));
end;
function TResource.Patch<T>(Content: TObject): T;
begin
SetContent(Content);
Result := ParseGenericResponse<T>(FRestClient.DoRequest(METHOD_PATCH, Self));
end;
function TResource.Patch<T>(Content: string): T;
begin
Result := ParseGenericResponse<T>(Patch(Content));
end;
function TResource.Delete<T>(Content: TObject): T;
var
vResponse: string;
begin
SetContent(Content);
Result := ParseGenericResponse<T>(FRestClient.DoRequest(METHOD_DELETE, Self));
end;
function TResource.Delete<T>(Content: string): T;
begin
Result := ParseGenericResponse<T>(Delete(Content));
end;
{$ELSE}
function TResource.Get(AListClass, AItemClass: TClass): TObject;
var
vResponse: string;
begin
vResponse := Self.Get;
Result := TOldRttiUnMarshal.FromJsonArray(AListClass, AItemClass, vResponse);
end;
function TResource.Post(Adapter: IJsonListAdapter): TObject;
var
vResponse: string;
begin
if Adapter <> nil then
SetContent(Adapter.UnWrapList);
vResponse := FRestClient.DoRequest(METHOD_POST, Self);
if trim(vResponse) <> '' then
Result := TOldRttiUnMarshal.FromJsonArray(Adapter.UnWrapList.ClassType, Adapter.ItemClass, vResponse)
else
Result := nil;
end;
function TResource.Put(Adapter: IJsonListAdapter): TObject;
var
vResponse: string;
begin
if Adapter <> nil then
SetContent(Adapter.UnWrapList);
vResponse := FRestClient.DoRequest(METHOD_PUT, Self);
if trim(vResponse) <> '' then
Result := TOldRttiUnMarshal.FromJsonArray(Adapter.UnWrapList.ClassType, Adapter.ItemClass, vResponse)
else
Result := nil;
end;
function TResource.Patch(Adapter: IJsonListAdapter): TObject;
var
vResponse: string;
begin
if Adapter <> nil then
SetContent(Adapter.UnWrapList);
vResponse := FRestClient.DoRequest(METHOD_PATCH, Self);
if trim(vResponse) <> '' then
Result := TOldRttiUnMarshal.FromJsonArray(Adapter.UnWrapList.ClassType, Adapter.ItemClass, vResponse)
else
Result := nil;
end;
{$ENDIF}
{$IFDEF USE_SUPER_OBJECT}
function TResource.GetAsDataSet(const RootElement: String): TDataSet;
var
vJson: ISuperObject;
begin
if RootElement <> EmptyStr then begin
vJson := SuperObject.SO(Get);
Result := TJsonToDataSetConverter.CreateDataSetMetadata(vJson[RootElement]);
TJsonToDataSetConverter.UnMarshalToDataSet(Result, vJson[RootElement]);
end else begin
Result:=GetasDataSet();
end;
end;
function TResource.GetAsDataSet: TDataSet;
var
vJson: ISuperObject;
begin
vJson := SuperObject.SO(Get);
Result := TJsonToDataSetConverter.CreateDataSetMetadata(vJson);
TJsonToDataSetConverter.UnMarshalToDataSet(Result, vJson);
end;
procedure TResource.GetAsDataSet(ADataSet: TDataSet);
var
vJson: string;
begin
vJson := Self.Get;
TJsonToDataSetConverter.UnMarshalToDataSet(ADataSet, vJson);
end;
{$ENDIF}
procedure TResource.SetContent(entity: TObject);
var
vRawContent: string;
vStream: TStringStream;
{$IFDEF SUPPORTS_GENERICS}
vMultipartFormData: TMultipartFormData;
{$ENDIF}
begin
FContent.Clear;
if not Assigned(entity) then
Exit;
{$IFDEF SUPPORTS_GENERICS}
if entity is TMultipartFormData then
begin
vMultipartFormData := TMultipartFormData(entity);
vRawContent := vMultipartFormData.ContentAsString;
ContentType(vMultipartFormData.ContentType);
end
else
{$ENDIF}
vRawContent := TJsonUtil.Marshal(Entity);
vStream := TStringStream.Create(vRawContent, TEncoding.UTF8);
try
vStream.Position := 0;
FContent.CopyFrom(vStream, vStream.Size);
finally
vStream.Free;
end;
end;
function TResource.Put(Content: TStream): String;
begin
Result := ContentRequest(Content, METHOD_PUT);
end;
function TResource.Post(Entity: TObject): TObject;
begin
Result := Post(Entity, Entity.ClassType);
end;
function TResource.Post(Content: string; ResultClass: TClass): TObject;
var
vStringStream: TStringStream;
begin
vStringStream := TStringStream.Create(Content, TEncoding.UTF8);
try
Result := Post(vStringStream, ResultClass);
finally
vStringStream.Free;
end;
end;
function TResource.Post(Content: TStream; ResultClass: TClass): TObject;
begin
Result := ContentRequest(Content, ResultClass, METHOD_POST);
end;
function TResource.Post(Entity: TObject; ResultClass: TClass): TObject;
begin
Result := EntityRequest(Entity, ResultClass, METHOD_POST);
end;
function TResource.Put(Entity: TObject): TObject;
begin
Result := Put(Entity, Entity.ClassType);
end;
function TResource.Put(Content: string; ResultClass: TClass): TObject;
var
vStringStream: TStringStream;
begin
vStringStream := TStringStream.Create(Content, TEncoding.UTF8);
try
Result := Put(vStringStream, ResultClass);
finally
vStringStream.Free;
end;
end;
function TResource.Put(Content: TStream; ResultClass: TClass): TObject;
begin
Result := ContentRequest(Content, ResultClass, METHOD_PUT);
end;
function TResource.Put(Entity: TObject; ResultClass: TClass): TObject;
begin
Result := EntityRequest(Entity, ResultClass, METHOD_PUT);
end;
function TResource.Patch(Content: TStream): String;
begin
Result := ContentRequest(Content, METHOD_PATCH);
end;
procedure TResource.Patch(Content: TStream; AHandler: TRestResponseHandler);
begin
ContentRequest(Content, METHOD_PATCH, AHandler);
end;
function TResource.Patch(Entity: TObject): TObject;
begin
Result := Patch(Entity, Entity.ClassType);
end;
function TResource.Patch(Content: string; ResultClass: TClass): TObject;
var
vStringStream: TStringStream;
begin
vStringStream := TStringStream.Create(Content, TEncoding.UTF8);
try
Result := Patch(vStringStream, ResultClass);
finally
vStringStream.Free;
end;
end;
function TResource.Patch(Content: TStream; ResultClass: TClass): TObject;
begin
Result := ContentRequest(Content, ResultClass, METHOD_PATCH);
end;
function TResource.Patch(Entity: TObject; ResultClass: TClass): TObject;
begin
Result := EntityRequest(Entity, ResultClass, METHOD_PATCH);
end;
function TResource.Patch(Content: string): string;
var
vStringStream: TStringStream;
begin
vStringStream := TStringStream.Create(Content, TEncoding.UTF8);
try
Result := Patch(vStringStream);
finally
vStringStream.Free;
end;
end;
{ TJsonListAdapter }
function TJsonListAdapter.ItemClass: TClass;
begin
Result := FItemClass;
end;
function TJsonListAdapter.UnWrapList: TList;
begin
Result := FWrappedList;
end;
constructor TJsonListAdapter.Create(AList: TList; AItemClass: TClass);
begin
FWrappedList := AList;
FItemClass := AItemClass;
end;
class function TJsonListAdapter.NewFrom(AList: TList; AItemClass: TClass): IJsonListAdapter;
begin
Result := TJsonListAdapter.Create(AList, AItemClass);
end;
{ TMultiPartFormData }
{$IFDEF SUPPORTS_GENERICS}
procedure TMultiPartFormData.AddFieldContent(Field: TRttiField; var Content: TStringList);
const
FmtTextContent = 'Content-Disposition: form-data; name="%s"'+ sLineBreak+sLineBreak +'%s';
FmtFileContent = 'Content-Disposition: form-data; name="%s"; filename="%s"'+ sLineBreak +'Content-Type: %s'+ sLineBreak+sLineBreak+ '%s';
var
Attachment: TMultiPartFormAttachment;
begin
if Field.FieldType.TypeKind in [tkString, tkUString, tkWChar, tkLString, tkWString, tkInteger, tkChar, tkWChar] then
begin
Content.Add(Format(FmtTextContent, [Field.Name, Field.GetValue(Self).AsString]));
Exit;
end;
if Field.FieldType.Name.Equals(TMultiPartFormAttachment.ClassName) then
begin
Attachment := Field.GetValue(Self).AsType<TMultiPartFormAttachment>;
Content.Add(Format(FmtFileContent, [Field.Name, Attachment.FileName, Attachment.MimeType, Attachment.Content.DataString]));
end;
end;
function TMultiPartFormData.ContentAsString: string;
var
vField: TRttiField;
vContent: TStringList;
vBoundary: string;
vRttiContext: TRttiContext;
vRttiType: TRttiType;
begin
vBoundary := '--' + FBoundary;
vContent := TStringList.Create;
try
vContent.Add(vBoundary);
vRttiContext := TRttiContext.Create;
vRttiType := vRttiContext.GetType(Self.ClassType);
for vField in vRttiType.GetDeclaredFields do
begin
AddFieldContent(vField, vContent);
vContent.Add(vBoundary);
end;
vContent.Strings[Pred(vContent.Count)] := vBoundary + '--';
Result := vContent.Text;
finally
vContent.Free;
end;
end;
constructor TMultiPartFormData.Create;
const
FmtBoundary = 'boundary--%s';
FmtContentType = 'multipart/form-data; boundary=%s';
var
vGUID: TGUID;
begin
CreateGUID(vGUID);
FBoundary := Format(FmtBoundary, [GUIDToString(vGUID)]);
FContentType := Format(FmtContentType, [FBoundary]);
end;
constructor TMultiPartFormAttachment.Create(Source: TStream; MimeType, FileName: string);
begin
Create(MimeType, FileName);
FContent.LoadFromStream(Source);
end;
constructor TMultiPartFormAttachment.Create(FilePath, MimeType, FileName: string);
begin
Create(MimeType, FileName);
FContent.LoadFromFile(FilePath);
end;
constructor TMultiPartFormAttachment.Create(MimeType, FileName: string);
begin
FContent := TStringStream.Create;
FMimeType := MimeType;
FFileName := FileName;
end;
destructor TMultiPartFormAttachment.Destroy;
begin
FContent.Free;
inherited;
end;
{$ENDIF}
end.
| 27.792468 | 149 | 0.750641 |
83f1483fcab827796fa694dbcad5680b7a7e2efa
| 11,646 |
dfm
|
Pascal
|
windows/src/ext/jedi/jvcl/tests/restructured/examples/JvDialogs/fDialogs.dfm
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 219 |
2017-06-21T03:37:03.000Z
|
2022-03-27T12:09:28.000Z
|
windows/src/ext/jedi/jvcl/tests/restructured/examples/JvDialogs/fDialogs.dfm
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 4,451 |
2017-05-29T02:52:06.000Z
|
2022-03-31T23:53:23.000Z
|
windows/src/ext/jedi/jvcl/tests/restructured/examples/JvDialogs/fDialogs.dfm
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 72 |
2017-05-26T04:08:37.000Z
|
2022-03-03T10:26:20.000Z
|
object Form1: TForm1
Left = 223
Top = 158
Width = 744
Height = 638
Caption = 'Dialogs Demo'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object PageControl1: TPageControl
Left = 0
Top = 0
Width = 736
Height = 611
ActivePage = TabSheet1
Align = alClient
TabOrder = 0
object TabSheet1: TTabSheet
Caption = 'Windows Dialogs'
object Button1: TButton
Left = 6
Top = 4
Width = 115
Height = 25
Caption = 'Format Drive A:'
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 6
Top = 41
Width = 115
Height = 25
Caption = 'Find Files'
TabOrder = 1
OnClick = Button2Click
end
object Button4: TButton
Left = 6
Top = 124
Width = 115
Height = 25
Caption = 'Shell About'
TabOrder = 2
OnClick = Button4Click
end
object Button5: TButton
Left = 6
Top = 154
Width = 115
Height = 25
Caption = 'Select directory'
TabOrder = 3
OnClick = Button5Click
end
object Button8: TButton
Left = 6
Top = 229
Width = 115
Height = 25
Caption = 'Add a printer'
TabOrder = 4
OnClick = Button8Click
end
object Button9: TButton
Left = 6
Top = 266
Width = 115
Height = 25
Caption = 'Connect Network'
TabOrder = 5
OnClick = Button9Click
end
object Button10: TButton
Left = 6
Top = 304
Width = 115
Height = 25
Caption = 'Disconnect network'
TabOrder = 6
OnClick = Button10Click
end
object Button32: TButton
Left = 140
Top = 2
Width = 115
Height = 25
Caption = 'Open Dialog'
TabOrder = 7
OnClick = Button32Click
end
object Button33: TButton
Left = 140
Top = 35
Width = 115
Height = 25
Caption = 'Save Dialog'
TabOrder = 8
OnClick = Button33Click
end
object Button25: TButton
Left = 140
Top = 101
Width = 115
Height = 25
Caption = 'Add Hardware'
TabOrder = 9
OnClick = Button25Click
end
object Button24: TButton
Left = 140
Top = 68
Width = 115
Height = 25
Caption = 'Shutdown Dlg'
TabOrder = 10
OnClick = Button24Click
end
object Button26: TButton
Left = 140
Top = 134
Width = 115
Height = 25
Caption = 'Choose Icon'
TabOrder = 11
OnClick = Button26Click
end
object Button27: TButton
Left = 140
Top = 168
Width = 115
Height = 25
Caption = 'Run Dlg'
TabOrder = 12
OnClick = Button27Click
end
object Button28: TButton
Left = 140
Top = 201
Width = 115
Height = 25
Caption = 'Find Computer'
TabOrder = 13
OnClick = Button28Click
end
object Button29: TButton
Left = 140
Top = 234
Width = 115
Height = 25
Caption = 'Object Properties'
TabOrder = 14
OnClick = Button29Click
end
object Button30: TButton
Left = 140
Top = 267
Width = 115
Height = 25
Caption = 'Out Of Memory Dlg'
TabOrder = 15
OnClick = Button30Click
end
object Button31: TButton
Left = 140
Top = 301
Width = 115
Height = 25
Caption = 'Disk C:\ Full Dialog'
TabOrder = 16
OnClick = Button31Click
end
object Button36: TButton
Left = 268
Top = 109
Width = 115
Height = 25
Caption = 'Control Panel Dialog'
TabOrder = 17
OnClick = Button36Click
end
object Button37: TButton
Left = 268
Top = 37
Width = 115
Height = 25
Caption = 'New Shortcut Dialog'
TabOrder = 18
OnClick = Button37Click
end
object Button38: TButton
Left = 268
Top = 69
Width = 115
Height = 25
Caption = 'Applet Dialog'
TabOrder = 19
OnClick = Button38Click
end
object Button39: TButton
Left = 268
Top = 141
Width = 115
Height = 25
Caption = 'Favorites'
TabOrder = 20
OnClick = Button39Click
end
object Button40: TButton
Left = 268
Top = 5
Width = 115
Height = 25
Caption = 'OpenWith Dialog'
TabOrder = 21
OnClick = Button40Click
end
object Button3: TButton
Left = 6
Top = 71
Width = 115
Height = 25
Caption = 'Browse for folder'
TabOrder = 22
OnClick = Button3Click
end
object Button7: TButton
Left = 268
Top = 173
Width = 115
Height = 25
Caption = 'Page Setup'
TabOrder = 23
OnClick = Button7Click
end
object Button41: TButton
Left = 268
Top = 205
Width = 115
Height = 25
Caption = 'Page Setup Titled'
TabOrder = 24
OnClick = Button41Click
end
end
object TabSheet2: TTabSheet
Caption = 'Other Dialogs'
ImageIndex = 1
object Button11: TButton
Left = 10
Top = 12
Width = 115
Height = 25
Caption = 'Password'
TabOrder = 0
OnClick = Button11Click
end
object Button14: TButton
Left = 10
Top = 48
Width = 115
Height = 25
Caption = 'Exchange listboxes'
TabOrder = 1
OnClick = Button14Click
end
object Button16: TButton
Left = 10
Top = 83
Width = 115
Height = 25
Caption = 'Login'
TabOrder = 2
OnClick = Button16Click
end
object Button17: TButton
Left = 10
Top = 115
Width = 115
Height = 25
Caption = 'Serial'
TabOrder = 3
OnClick = Button17Click
end
object Button18: TButton
Left = 10
Top = 148
Width = 115
Height = 25
Caption = 'Calculator'
TabOrder = 4
OnClick = Button18Click
end
object Button19: TButton
Left = 10
Top = 181
Width = 115
Height = 25
Caption = 'Progress Dlg'
TabOrder = 5
OnClick = Button19Click
end
object Button20: TButton
Left = 10
Top = 215
Width = 115
Height = 25
Caption = 'Disk Prompt'
TabOrder = 6
OnClick = Button20Click
end
object Button21: TButton
Left = 138
Top = 78
Width = 115
Height = 25
Caption = 'Copy Error'
TabOrder = 7
OnClick = Button21Click
end
object Button22: TButton
Left = 138
Top = 10
Width = 115
Height = 25
Caption = 'Delete Error'
TabOrder = 8
OnClick = Button22Click
end
object Button23: TButton
Left = 140
Top = 43
Width = 115
Height = 25
Caption = 'Rename Error'
TabOrder = 9
OnClick = Button23Click
end
object Button34: TButton
Left = 486
Top = 374
Width = 115
Height = 25
Caption = 'Fatal exit'
TabOrder = 10
end
end
end
object JvFormatDrive1: TJvFormatDrive
FormatType = ftQuick
Capacity = dcDefault
Left = 104
Top = 474
end
object JvFindFiles1: TJvFindFilesDialog
SpecialFolder = sfRecycleBin
UseSpecialFolder = False
Left = 612
Top = 44
end
object JvBrowseFolder1: TJvBrowseFolder
RootDirectory = fdRootFolder
Left = 196
Top = 368
end
object JvSelectDirectory1: TJvSelectDirectory
Options = []
Left = 20
Top = 422
end
object JvConnectNetwork1: TJvConnectNetwork
Left = 110
Top = 422
end
object JvDisconnectNetwork1: TJvDisconnectNetwork
Left = 168
Top = 422
end
object JvPasswordForm1: TJvPasswordForm
Title = 'Enter password'
OkCaption = '&Ok'
CancelCaption = '&Cancel'
LabelCaption = 'Password'
PasswordChar = '*'
Left = 538
Top = 146
end
object JvExchListboxes1: TJvExchListboxes
FirstCaption = 'First Column'
SecondCaption = 'Second Column'
Title = 'Listbox Editor'
Left = 624
Top = 232
end
object JvLoginDlg1: TJvLoginDlg
FirstLabel = 'Username'
SecondLabel = 'Password'
Title = 'Enter login'
Left = 534
Top = 42
end
object JvSerialDlg1: TJvSerialDlg
FirstLabel = 'Name'
SecondLabel = 'Serial'
Title = 'Enter Serial'
Left = 614
Top = 102
end
object JvCalculator1: TJvCalculator
Title = 'Calculator'
Left = 462
Top = 298
end
object JvProgressDlg1: TJvProgressDlg
Text = 'Progress'
AutoTimeLeft = True
Left = 462
Top = 246
end
object JvDiskPrompt1: TJvDiskPrompt
Style = []
Left = 454
Top = 194
end
object JvCopyError1: TJvCopyError
Style = []
Left = 454
Top = 142
end
object JvDeleteError1: TJvDeleteError
Style = []
Left = 454
Top = 90
end
object JvRenameError1: TJvRenameError
Style = []
Left = 454
Top = 46
end
object JvShutdownDlg1: TJvExitWindowsDialog
Left = 16
Top = 366
end
object JvShellAboutDialog1: TJvShellAboutDialog
Left = 32
Top = 472
end
object JvAddHardwareDialog1: TJvAddHardwareDialog
Left = 88
Top = 368
end
object JvChooseIconDlg1: TJvChangeIconDialog
IconIndex = 0
Left = 180
Top = 478
end
object JvRunDlg1: TJvRunDialog
Left = 236
Top = 468
end
object JvFindComputerDlg1: TJvComputerNameDialog
Left = 36
Top = 538
end
object JvObjectPropertiesDlg1: TJvObjectPropertiesDialog
ObjectType = sdPathObject
Left = 108
Top = 534
end
object JvOutOfMemoryDlg1: TJvOutOfMemoryDialog
Left = 182
Top = 536
end
object JvOutOfSpaceDlg1: TJvDiskFullDialog
DriveChar = 'C'
Left = 258
Top = 532
end
object JvOpenDialog1: TJvOpenDialog2000
Left = 274
Top = 394
end
object JvSaveDialog1: TJvSaveDialog2000
Left = 292
Top = 482
end
object JvPageSetupDialog1: TJvPageSetupDialog
Left = 544
Top = 320
end
object JvPageSetupTitledDialog1: TJvPageSetupTitledDialog
Left = 616
Top = 288
end
object JvBrowseFolder2: TJvBrowseFolder
RootDirectory = fdRootFolder
Left = 616
Top = 336
end
object JvOrganizeFavoritesDialog1: TJvOrganizeFavoritesDialog
Left = 448
Top = 424
end
object JvControlPanelDialog1: TJvControlPanelDialog
Left = 536
Top = 416
end
object JvAppletDialog1: TJvAppletDialog
Left = 448
Top = 480
end
object JvNewLinkDialog1: TJvNewLinkDialog
DestinationFolder = 'C:\'
Left = 536
Top = 480
end
object JvOpenWithDialog1: TJvOpenWithDialog
Left = 632
Top = 424
end
object JvAddPrinterDialog1: TJvAddPrinterDialog
Left = 312
Top = 288
end
end
| 21.890977 | 63 | 0.554869 |
f19d15f76e2caf06a28fea9f7695723fde89fc53
| 2,209 |
dfm
|
Pascal
|
Catalogos/BateriaCapacitacionCursoTemaForm.dfm
|
alexismzt/SOFOM
|
57ca73e9f7fbb51521149ea7c0fdc409c22cc6f7
|
[
"Apache-2.0"
] | null | null | null |
Catalogos/BateriaCapacitacionCursoTemaForm.dfm
|
alexismzt/SOFOM
|
57ca73e9f7fbb51521149ea7c0fdc409c22cc6f7
|
[
"Apache-2.0"
] | 51 |
2018-07-25T15:39:25.000Z
|
2021-04-21T17:40:57.000Z
|
Catalogos/BateriaCapacitacionCursoTemaForm.dfm
|
alexismzt/SOFOM
|
57ca73e9f7fbb51521149ea7c0fdc409c22cc6f7
|
[
"Apache-2.0"
] | 1 |
2021-02-23T17:27:06.000Z
|
2021-02-23T17:27:06.000Z
|
inherited frmBateriaCapacitacionCursosTema: TfrmBateriaCapacitacionCursosTema
Caption = 'Bateria de Capacitacion - Cursos - Tema'
ClientHeight = 223
ClientWidth = 718
ExplicitWidth = 724
ExplicitHeight = 251
PixelsPerInch = 96
TextHeight = 13
inherited pcMain: TcxPageControl
Width = 718
Height = 182
ExplicitWidth = 718
ExplicitHeight = 233
ClientRectBottom = 180
ClientRectRight = 716
inherited tsGeneral: TcxTabSheet
ExplicitLeft = 2
ExplicitTop = 28
ExplicitWidth = 714
ExplicitHeight = 203
object Label2: TLabel
Left = 16
Top = 16
Width = 61
Height = 13
Caption = 'Identificador'
FocusControl = cxDBTextEdit1
end
object Label3: TLabel
Left = 16
Top = 56
Width = 54
Height = 13
Caption = 'Descripcion'
FocusControl = cxDBTextEdit2
end
object Label4: TLabel
Left = 16
Top = 96
Width = 59
Height = 13
Caption = 'Ponderacion'
FocusControl = cxDBSpinEdit1
end
object cxDBTextEdit1: TcxDBTextEdit
Left = 16
Top = 32
DataBinding.DataField = 'Identificador'
DataBinding.DataSource = DataSource
TabOrder = 0
Width = 121
end
object cxDBTextEdit2: TcxDBTextEdit
Left = 16
Top = 72
DataBinding.DataField = 'Descripcion'
DataBinding.DataSource = DataSource
TabOrder = 1
Width = 681
end
object cxDBSpinEdit1: TcxDBSpinEdit
Left = 16
Top = 112
DataBinding.DataField = 'Ponderacion'
DataBinding.DataSource = DataSource
TabOrder = 2
Width = 121
end
end
end
inherited pmlMain: TPanel
Top = 182
Width = 718
ExplicitTop = 233
ExplicitWidth = 718
inherited btnOk: TButton
Left = 555
ExplicitLeft = 555
end
inherited btnCancel: TButton
Left = 636
ExplicitLeft = 636
end
end
inherited cxImageList: TcxImageList
FormatVersion = 1
end
end
| 24.820225 | 78 | 0.578542 |
f10bc54c2fa3097d8aba97c40d112c96c2cc13cf
| 1,700 |
pas
|
Pascal
|
code/parameter/SQLParameter.pas
|
VencejoSoftware/ooSQL
|
fc93ca33d49b840f56e67edd2b022ae94406b2b2
|
[
"BSD-3-Clause"
] | 1 |
2022-01-04T02:17:36.000Z
|
2022-01-04T02:17:36.000Z
|
code/parameter/SQLParameter.pas
|
VencejoSoftware/ooSQL
|
fc93ca33d49b840f56e67edd2b022ae94406b2b2
|
[
"BSD-3-Clause"
] | null | null | null |
code/parameter/SQLParameter.pas
|
VencejoSoftware/ooSQL
|
fc93ca33d49b840f56e67edd2b022ae94406b2b2
|
[
"BSD-3-Clause"
] | 3 |
2019-11-21T02:57:33.000Z
|
2021-07-26T09:14:17.000Z
|
{$REGION 'documentation'}
{
Copyright (c) 2020, Vencejo Software
Distributed under the terms of the Modified BSD License
The full license is distributed with this software
}
{
SQL parameter syntax object
@created(21/12/2017)
@author Vencejo Software <www.vencejosoft.com>
}
{$ENDREGION}
unit SQLParameter;
interface
uses
Statement,
SQLParameterValue,
IterableList;
type
{$REGION 'documentation'}
{
@abstract(SQL parameter syntax object)
Object to resolve a SQL parameter syntax
@member(
Name Parameter name
@return(Text with parameter name)
)
@member(
IsNull Checks if the parameter value is assigned
@return(@true if the value is assigned, @false if not)
)
@member(
Value Parameter value object
@return(@link(ISQLParameterValue Parameter value object))
)
}
{$ENDREGION}
ISQLParameter = interface(IStatement)
['{B688AFED-8F67-4FEA-96C4-A1B9926AADCC}']
function Name: String;
function IsNull: Boolean;
function Value: ISQLParameterValue;
end;
{$REGION 'documentation'}
{
@abstract(SQL parameter list object)
List of parameters
}
{$ENDREGION}
ISQLParameterList = interface(IIterableList<ISQLParameter>)
['{9EC80759-A699-4AAA-9BF5-80F7ED186B94}']
end;
{$REGION 'documentation'}
{
@abstract(Implementation of @link(ISQLParameterList))
@member(
New Create a new @classname as interface
)
}
{$ENDREGION}
TSQLParameterList = class sealed(TIterableList<ISQLParameter>, ISQLParameterList)
public
class function New: ISQLParameterList;
end;
implementation
{ TSQLParameterList }
class function TSQLParameterList.New: ISQLParameterList;
begin
Result := TSQLParameterList.Create;
end;
end.
| 20.481928 | 83 | 0.734706 |
f1ee8e519f7ab44507bacb2df571110b40276490
| 10,682 |
pas
|
Pascal
|
DUnitX.Test.pas
|
bbrandt/DUnitX
|
63f8fd1c250eff866da5290ff55447970885c04e
|
[
"Apache-2.0"
] | 1 |
2021-07-24T16:42:48.000Z
|
2021-07-24T16:42:48.000Z
|
DUnitX.Test.pas
|
bbrandt/DUnitX
|
63f8fd1c250eff866da5290ff55447970885c04e
|
[
"Apache-2.0"
] | 1 |
2017-06-25T12:58:46.000Z
|
2017-06-25T13:05:30.000Z
|
DUnitX.Test.pas
|
bbrandt/DUnitX
|
63f8fd1c250eff866da5290ff55447970885c04e
|
[
"Apache-2.0"
] | 2 |
2018-03-11T00:08:35.000Z
|
2018-11-01T07:06:41.000Z
|
{***************************************************************************}
{ }
{ DUnitX }
{ }
{ Copyright (C) 2015 Vincent Parrett & Contributors }
{ }
{ vincent@finalbuilder.com }
{ http://www.finalbuilder.com }
{ }
{ }
{***************************************************************************}
{ }
{ Licensed under the Apache License, Version 2.0 (the "License"); }
{ you may not use this file except in compliance with the License. }
{ You may obtain a copy of the License at }
{ }
{ http://www.apache.org/licenses/LICENSE-2.0 }
{ }
{ Unless required by applicable law or agreed to in writing, software }
{ distributed under the License is distributed on an "AS IS" BASIS, }
{ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. }
{ See the License for the specific language governing permissions and }
{ limitations under the License. }
{ }
{***************************************************************************}
unit DUnitX.Test;
interface
{$I DUnitX.inc}
uses
{$IFDEF USE_NS}
System.Generics.Collections,
System.TimeSpan,
System.Rtti,
{$ELSE}
Generics.Collections,
TimeSpan,
Rtti,
{$ENDIF}
DUnitX.Types,
DUnitX.Extensibility,
DUnitX.InternalInterfaces,
DUnitX.WeakReference,
DUnitX.TestFramework;
type
TDUnitXTest = class(TWeakReferencedObject, ITest, ITestInfo, ISetTestResult, ITestExecute)
private
FName : string;
FMethodName : string;
FCategories : TList<string>;
FMethod : TTestMethod;
FFixture : IWeakReference<ITestFixture>;
FStartTime : TDateTime;
FEndTime : TDateTime;
FDuration : TTimeSpan;
FEnabled : boolean;
FIgnored : boolean;
FIgnoreReason : string;
FIgnoreMemoryLeaks : Boolean;
FMaxTime : cardinal; // milliseconds for timeout
FTimedOut : Boolean;
protected
//ITest
function GetName: string; virtual;
function GetMethodName : string;
function GetCategories : TList<string>;
function GetFullName : string;virtual;
function GetTestFixture: ITestFixture;
function GetTestMethod: TTestMethod;
function GetTestStartTime : TDateTime;
function GetTestEndTime : TDateTime;
function GetTestDuration: TTimeSpan;
function GetIgnoreMemoryLeaks() : Boolean;
procedure SetIgnoreMemoryLeaks(const AValue : Boolean);
function GetMaxTime: cardinal;
procedure SetMaxTime(const AValue: cardinal);
function GetTimedOut: Boolean;
procedure SetTimedOut(const AValue: Boolean);
//ITestInfo
function GetActive : boolean;
function ITestInfo.GetTestFixture = ITestInfo_GetTestFixture;
function ITestInfo_GetTestFixture: ITestFixtureInfo;
function GetEnabled: Boolean;
procedure SetEnabled(const value: Boolean);
function GetIgnored : boolean;
function GetIgnoreReason : string;
//ISetTestResult
procedure SetResult(const value: ITestResult);
//ITestExecute
procedure Execute(const context : ITestExecuteContext);virtual;
procedure UpdateInstance(const fixtureInstance : TObject);virtual;
public
constructor Create(const AFixture : ITestFixture; const AMethodName : string; const AName : string; const ACategory : string; const AMethod : TTestMethod; const AEnabled : boolean;
const AIgnored : boolean = false; const AIgnoreReason : string = ''; const AMaxTime : Cardinal = 0);
destructor Destroy;override;
end;
TDUnitXTestCase = class(TDUnitXTest, ITestExecute)
private
FCaseName : string;
FArgs : TValueArray;
FRttiMethod : TRttiMethod;
FInstance : TObject;
protected
function GetName: string; override;
procedure Execute(const context : ITestExecuteContext); override;
procedure UpdateInstance(const fixtureInstance : TObject);override;
public
constructor Create(const AInstance : TObject; const AFixture : ITestFixture; const AMethodName : string; const ACaseName : string; const AName : string; const ACategory : string; const AMethod : TRttiMethod;
const AEnabled : boolean; const AArgs : TValueArray);reintroduce;
destructor Destroy;override;
end;
implementation
uses
{$IFDEF USE_NS}
System.SysUtils,
System.Generics.Defaults,
{$ELSE}
SysUtils,
Generics.Defaults,
{$ENDIF}
{$IFDEF MSWINDOWS}
DUnitX.Timeout,
{$ENDIF}
DUnitX.Utils;
{ TDUnitXTest }
constructor TDUnitXTest.Create(const AFixture: ITestFixture; const AMethodName : string; const AName: string; const ACategory : string; const AMethod: TTestMethod; const AEnabled : boolean; const AIgnored : boolean; const AIgnoreReason : string; const AMaxTime : Cardinal);
var
categories : TArray<string>;
cat : string;
begin
inherited Create;
FFixture := TWeakReference<ITestFixture>.Create(AFixture);
FMethodName := AMethodName;
FName := AName;
FCategories := TList<string>.Create(TComparer<string>.Construct(
function(const Left, Right : string) : integer
begin
result := AnsiCompareText(Left,Right);
end));
if ACategory <> '' then
begin
categories := TStrUtils.SplitString(ACategory,',');
for cat in categories do
FCategories.Add(Trim(cat));
end;
FMethod := AMethod;
FEnabled := AEnabled;
FIgnored := AIgnored;
FIgnoreReason := AIgnoreReason;
FMaxTime := AMaxTime;
FTimedOut := false;
end;
destructor TDUnitXTest.Destroy;
begin
FCategories.Free;
inherited;
end;
procedure TDUnitXTest.Execute(const context : ITestExecuteContext);
{$IFDEF MSWINDOWS}
var
timeout : ITimeout;
{$ENDIF}
begin
FStartTime := Now();
try
{$IFDEF MSWINDOWS}
if FMaxTime > 0 then
timeout := InitialiseTimeOut( FMaxTime );
{$ENDIF}
FMethod();
finally
FEndTime := Now();
FDuration := TTimeSpan.Subtract(FEndTime,FStartTime);
end;
end;
function TDUnitXTest.GetActive: boolean;
begin
//TODO: Need to set the internal active state
result := True;
end;
function TDUnitXTest.GetCategories: TList<string>;
begin
result := FCategories;
end;
function TDUnitXTest.GetEnabled: Boolean;
begin
result := FEnabled;
end;
function TDUnitXTest.GetFullName: string;
begin
result := FFixture.Data.FullName + '.' + Self.GetName;
end;
function TDUnitXTest.GetIgnored: boolean;
begin
result := FIgnored;
end;
function TDUnitXTest.GetIgnoreMemoryLeaks: Boolean;
begin
Result := FIgnoreMemoryLeaks;
end;
function TDUnitXTest.GetIgnoreReason: string;
begin
result := FIgnoreReason;
end;
function TDUnitXTest.GetMethodName: string;
begin
result := FMethodName;
end;
function TDUnitXTest.GetName: string;
begin
result := FName;
end;
function TDUnitXTest.GetTestDuration: TTimeSpan;
begin
result := FDuration;
end;
function TDUnitXTest.GetTestEndTime: TDateTime;
begin
result := FEndTime;
end;
function TDUnitXTest.GetTestFixture: ITestFixture;
begin
if FFixture.IsAlive then
result := FFixture.Data
else
result := nil;
end;
function TDUnitXTest.GetTestMethod: TTestMethod;
begin
result := FMethod;
end;
function TDUnitXTest.GetTestStartTime: TDateTime;
begin
result := FStartTime;
end;
function TDUnitXTest.ITestInfo_GetTestFixture: ITestFixtureInfo;
begin
if FFixture.IsAlive then
result := FFixture.Data as ITestFixtureInfo
else
result := nil;
end;
procedure TDUnitXTest.SetEnabled(const value: Boolean);
begin
FEnabled := value;
end;
procedure TDUnitXTest.SetIgnoreMemoryLeaks(const AValue: Boolean);
begin
FIgnoreMemoryLeaks := AValue;
end;
function TDUnitXTest.GetMaxTime: cardinal;
begin
Result := FMaxTime;
end;
procedure TDUnitXTest.SetMaxTime(const AValue: cardinal);
begin
FMaxTime := AValue;
end;
function TDUnitXTest.GetTimedOut: Boolean;
begin
Result := FTimedOut;
end;
procedure TDUnitXTest.SetTimedOut(const AValue: Boolean);
begin
FTimedOut := AValue;
end;
procedure TDUnitXTest.UpdateInstance(const fixtureInstance: TObject);
begin
TMethod(FMethod).Data := fixtureInstance;
end;
procedure TDUnitXTest.SetResult(const value: ITestResult);
begin
//TODO : what was meant to happen here?? Is this called?
end;
{ TDUnitXTestCase }
constructor TDUnitXTestCase.Create(const AInstance : TObject; const AFixture : ITestFixture; const AMethodName : string; const ACaseName : string;
const AName : string; const ACategory : string; const AMethod : TRttiMethod; const AEnabled : boolean;
const AArgs : TValueArray);
var
len : integer;
index : integer;
parameters : TArray<TRttiParameter>;
tmp : TValue;
begin
inherited Create(AFixture, AMethodName, AName, ACategory, nil,AEnabled);
FInstance := AInstance;
FRttiMethod := AMethod;
FCaseName := ACaseName;
parameters := FRttiMethod.GetParameters();
//Work with the params as the limiter.
len := Length(parameters);
if len > 0 then
begin
//Only keep as many arguments as there are params
SetLength(FArgs, len);
for index := 0 to Pred(len) do
begin
if index <= high(AArgs) then
if AArgs[index].TryConvert(parameters[index].ParamType.Handle, tmp) then
FArgs[index] := tmp;
end;
end;
end;
destructor TDUnitXTestCase.Destroy;
begin
inherited;
end;
procedure TDUnitXTestCase.Execute(const context : ITestExecuteContext);
begin
FStartTime := Now();
try
FRttiMethod.Invoke(FInstance,FArgs);
finally
FEndTime := Now();
FDuration := TTimeSpan.Subtract(FEndTime,FStartTime);
end;
end;
function TDUnitXTestCase.GetName: string;
begin
Result := FName + '.' + FCaseName;
end;
procedure TDUnitXTestCase.UpdateInstance(const fixtureInstance: TObject);
begin
inherited;
FInstance := fixtureInstance;
end;
end.
| 27.890339 | 274 | 0.636398 |
8319075f46502b1af31e0f75cc0d80bfb1d51e44
| 3,336 |
pas
|
Pascal
|
tests/TestRedisValuesU.pas
|
lgadina/delphiredisclient
|
ec59c9f130a96b60b9e718e6733ff18a7b1ca06b
|
[
"Apache-2.0"
] | 235 |
2015-01-06T08:24:11.000Z
|
2022-03-17T22:28:39.000Z
|
tests/TestRedisValuesU.pas
|
lgadina/delphiredisclient
|
ec59c9f130a96b60b9e718e6733ff18a7b1ca06b
|
[
"Apache-2.0"
] | 23 |
2015-11-10T22:14:52.000Z
|
2022-03-11T15:06:57.000Z
|
tests/TestRedisValuesU.pas
|
lgadina/delphiredisclient
|
ec59c9f130a96b60b9e718e6733ff18a7b1ca06b
|
[
"Apache-2.0"
] | 113 |
2015-05-20T06:45:18.000Z
|
2022-02-18T21:52:52.000Z
|
// *************************************************************************** }
//
// Delphi REDIS Client
//
// Copyright (c) 2015-2021 Daniele Teti
//
// https://github.com/danieleteti/delphiredisclient
//
// ***************************************************************************
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// ***************************************************************************
unit TestRedisValuesU;
interface
uses TestFramework, Redis.Values, Redis.Commons;
type
// Test methods for Redis Values
TestRedisValues = class(TTestCase)
private
FIntValue: TRedisInteger;
FStrValue: TRedisString;
public
procedure SetUp; override;
procedure TearDown; override;
published
procedure TestIntegerHasValue10;
procedure TestIntegerHasValue20;
procedure TestIntegerEquals;
procedure TestIntegerAssignToInteger;
procedure TestIntegerAssignFromInteger;
procedure TestStringHasValue10;
procedure TestStringHasValue20;
procedure TestStringAssignToString;
procedure TestStringAssignFromString;
end;
implementation
uses
System.SysUtils;
procedure TestRedisValues.SetUp;
begin
inherited;
FIntValue.SetNull;
FStrValue.SetNull;
end;
procedure TestRedisValues.TearDown;
begin
inherited;
end;
procedure TestRedisValues.TestIntegerAssignFromInteger;
var
i: Integer;
begin
i := 123;
FIntValue := i;
CheckEquals(123, FIntValue);
end;
procedure TestRedisValues.TestIntegerAssignToInteger;
var
i: Integer;
begin
FIntValue := 123;
i := FIntValue;
CheckEquals(123, i);
end;
procedure TestRedisValues.TestIntegerEquals;
var
a, b: TRedisInteger;
begin
a := 123;
b := 123;
CheckTrue(a.Value = b.Value, 'Equals doesn''t work');
CheckFalse(a.Value <> b.Value, 'Equals doesn''t work');
end;
procedure TestRedisValues.TestIntegerHasValue10;
begin
CheckFalse(FIntValue.HasValue);
FIntValue := nil;
CheckFalse(FIntValue.HasValue);
FIntValue := 123;
CheckTrue(FIntValue.HasValue);
CheckEquals(123, FIntValue.Value);
end;
procedure TestRedisValues.TestIntegerHasValue20;
var
lValue: TRedisInteger;
begin
CheckFalse(lValue.HasValue);
end;
procedure TestRedisValues.TestStringAssignFromString;
var
s: string;
begin
s := 'abc';
FStrValue := s;
CheckEquals('abc', FStrValue);
end;
procedure TestRedisValues.TestStringAssignToString;
var
s: string;
begin
FStrValue := 'abc';
s := FStrValue;
CheckEquals('abc', s);
end;
procedure TestRedisValues.TestStringHasValue10;
begin
CheckFalse(FStrValue.HasValue);
FStrValue := 'abc';
CheckTrue(FStrValue.HasValue);
CheckEquals('abc', FStrValue.Value);
end;
procedure TestRedisValues.TestStringHasValue20;
var
lValue: TRedisString;
begin
CheckFalse(lValue.HasValue);
end;
initialization
RegisterTest(TestRedisValues.Suite);
end.
| 21.384615 | 80 | 0.70024 |
f17d5e8e25bb53a757110e8f9dceb45140385f4a
| 6,095 |
dpr
|
Pascal
|
data/pascal/c7a58b1af0e2e9d9c1d797d88210e15d_lion_lens.dpr
|
maxim5/code-inspector
|
14812dfbc7bac1d76c4d9e5be2cdf83fc1c391a1
|
[
"Apache-2.0"
] | 5 |
2018-01-03T06:43:07.000Z
|
2020-07-30T13:15:29.000Z
|
data/pascal/c7a58b1af0e2e9d9c1d797d88210e15d_lion_lens.dpr
|
maxim5/code-inspector
|
14812dfbc7bac1d76c4d9e5be2cdf83fc1c391a1
|
[
"Apache-2.0"
] | null | null | null |
data/pascal/c7a58b1af0e2e9d9c1d797d88210e15d_lion_lens.dpr
|
maxim5/code-inspector
|
14812dfbc7bac1d76c4d9e5be2cdf83fc1c391a1
|
[
"Apache-2.0"
] | 2 |
2019-11-04T02:54:49.000Z
|
2020-04-24T17:50:46.000Z
|
//
// AggPas 2.4 RM3 Demo application
// Note: Press F1 key on run to see more info about this demo
//
// Paths: src;src\ctrl;src\svg;src\util;src\platform\win;expat-wrap
//
program
lion_lens ;
{DEFINE AGG_GRAY8 }
{$DEFINE AGG_BGR24 }
{DEFINE AGG_RGB24 }
{DEFINE AGG_BGRA32 }
{DEFINE AGG_RGBA32 }
{DEFINE AGG_ARGB32 }
{DEFINE AGG_ABGR32 }
{DEFINE AGG_RGB565 }
{DEFINE AGG_RGB555 }
uses
agg_basics ,
agg_platform_support ,
agg_ctrl ,
agg_slider_ctrl ,
agg_rasterizer_scanline_aa ,
agg_scanline ,
agg_scanline_p ,
agg_renderer_base ,
agg_renderer_scanline ,
agg_render_scanlines ,
agg_path_storage ,
agg_bounding_rect ,
agg_trans_affine ,
agg_trans_warp_magnifier ,
agg_conv_transform ,
agg_conv_segmentator ,
parse_lion_
{$I pixel_formats.inc }
{$I agg_mode.inc }
const
flip_y = true;
var
g_rasterizer : rasterizer_scanline_aa;
g_scanline : scanline_p8;
g_path : path_storage;
g_colors : array[0..99 ] of aggclr;
g_path_idx : array[0..99 ] of unsigned;
g_npaths : unsigned;
g_x1 ,g_y1 ,g_x2 ,g_y2 ,
g_base_dx ,g_base_dy ,
g_angle ,g_scale ,
g_skew_x ,g_skew_y : double;
g_nclick : int;
type
the_application = object(platform_support )
m_magn_slider ,
m_radius_slider : slider_ctrl;
constructor Construct(format_ : pix_format_e; flip_y_ : boolean );
destructor Destruct;
procedure on_init; virtual;
procedure on_draw; virtual;
procedure on_mouse_move (x ,y : int; flags : unsigned ); virtual;
procedure on_mouse_button_down(x ,y : int; flags : unsigned ); virtual;
procedure on_key(x ,y : int; key ,flags : unsigned ); virtual;
end;
{ _PARSE_LION_ }
procedure _parse_lion_;
begin
g_npaths:=parse_lion(@g_path ,@g_colors ,@g_path_idx );
bounding_rect(@g_path ,@g_path_idx ,0 ,g_npaths ,@g_x1 ,@g_y1 ,@g_x2 ,@g_y2 );
g_base_dx:=(g_x2 - g_x1 ) / 2.0;
g_base_dy:=(g_y2 - g_y1 ) / 2.0;
end;
{ CONSTRUCT }
constructor the_application.Construct;
begin
inherited Construct(format_ ,flip_y_ );
m_magn_slider.Construct (5 ,5 ,495 ,12 ,not flip_y_ );
m_radius_slider.Construct(5 ,20 ,495 ,27 ,not flip_y_ );
_parse_lion_;
add_ctrl(@m_magn_slider );
m_magn_slider.no_transform;
m_magn_slider.range_(0.01 ,4.0 );
m_magn_slider.value_(3.0 );
m_magn_slider.label_('Scale=%3.2f' );
add_ctrl(@m_radius_slider );
m_radius_slider.no_transform;
m_radius_slider.range_(0.0 ,100.0 );
m_radius_slider.value_(70.0 );
m_radius_slider.label_('Radius=%3.2f' );
end;
{ DESTRUCT }
destructor the_application.Destruct;
begin
inherited Destruct;
m_magn_slider.Destruct;
m_radius_slider.Destruct;
end;
{ ON_INIT }
procedure the_application.on_init;
begin
g_x1:=200;
g_y1:=150;
end;
{ ON_DRAW }
procedure the_application.on_draw;
var
pixf : pixel_formats;
rb : renderer_base;
r : renderer_scanline_aa_solid;
rgba : aggclr;
lens : trans_warp_magnifier;
segm : conv_segmentator;
mtx : trans_affine;
tat : trans_affine_translation;
tar : trans_affine_rotation;
trans_mtx ,
trans_lens : conv_transform;
begin
// Initialize structures
pixfmt(pixf ,rbuf_window );
rb.Construct(@pixf );
r.Construct (@rb );
rgba.ConstrDbl(1 ,1 ,1 );
rb.clear (@rgba );
// Transform lion
lens.Construct;
lens.center (g_x1 ,g_y1 );
lens.magnification(m_magn_slider._value );
lens.radius (m_radius_slider._value / m_magn_slider._value );
segm.Construct(@g_path );
mtx.Construct;
tat.Construct(-g_base_dx ,-g_base_dy );
mtx.multiply (@tat );
tar.Construct(g_angle + pi );
mtx.multiply (@tar );
tat.Construct(_width / 2 ,_height / 2);
mtx.multiply (@tat );
trans_mtx.Construct (@segm ,@mtx );
trans_lens.Construct(@trans_mtx ,@lens );
render_all_paths(@g_rasterizer ,@g_scanline ,@r ,@trans_lens ,@g_colors ,@g_path_idx ,g_npaths );
// Render the controls
render_ctrl(@g_rasterizer ,@g_scanline ,@r ,@m_magn_slider );
render_ctrl(@g_rasterizer ,@g_scanline ,@r ,@m_radius_slider );
// Free
segm.Destruct;
end;
{ ON_MOUSE_MOVE }
procedure the_application.on_mouse_move;
begin
on_mouse_button_down(x ,y ,flags );
end;
{ ON_MOUSE_BUTTON_DOWN }
procedure the_application.on_mouse_button_down;
begin
if flags and mouse_left <> 0 then
begin
g_x1:=x;
g_y1:=y;
force_redraw;
end;
if flags and mouse_right <> 0 then
begin
g_x2:=x;
g_y2:=y;
force_redraw;
end;
end;
{ ON_KEY }
procedure the_application.on_key;
begin
if key = key_f1 then
message_(
'This example exhibits a non-linear transformer that "magnifies" vertices that fall '#13 +
'inside a circle and extends the rest (trans_warp_magnifier). Non-linear transformations '#13 +
'are tricky because straight lines become curves. To achieve the correct result we need '#13 +
'to divide long line segments into short ones. The example also demonstrates the use of '#13 +
'conv_segmentator that does this division job. The transformer can also shrink away '#13 +
'the image if the scaling value is less than 1.'#13#13 +
'How to play with:'#13#13 +
'Drag the center of the "lens" with the left mouse button and change the "Scale" and "Radius". '#13 +
'To watch for an amazing effect, set the scale to the minimum (0.01), decrease the radius '#13 +
'to about 1 and drag the "lens". You will see it behaves like a black hole consuming space '#13 +
'around it. Move the lens somewhere to the side of the window and change the radius. It looks '#13 +
'like changing the event horizon of the "black hole".' +
#13#13'Note: F2 key saves current "screenshot" file in this demo''s directory. ' );
end;
VAR
app : the_application;
BEGIN
// Rendering
g_rasterizer.Construct;
g_scanline.Construct;
g_path.Construct;
g_npaths:=0;
g_x1:=0;
g_y1:=0;
g_x2:=0;
g_y2:=0;
g_base_dx:=0;
g_base_dy:=0;
g_angle:=0;
g_scale:=1.0;
g_skew_x:=0;
g_skew_y:=0;
g_nclick:=0;
// App
app.Construct(pix_format ,flip_y );
app.caption_ ('AGG Example. Lion (F1-Help)' );
if app.init(500 ,600 ,window_resize ) then
app.run;
app.Destruct;
// Free
g_rasterizer.Destruct;
g_scanline.Destruct;
g_path.Destruct;
END.
| 20.802048 | 106 | 0.713536 |
f1a16f8e7494cd155f466790bba453eea251dfb8
| 764 |
lpr
|
Pascal
|
backup/Olympus_ImageSave.lpr
|
MSGEndo/OLYMPUSWIFI
|
f96259c12e534760524f8c7cb8b766b781ad5299
|
[
"MIT"
] | 6 |
2020-01-19T15:22:05.000Z
|
2020-03-17T03:30:38.000Z
|
backup/Olympus_ImageSave.lpr
|
MSGEndo/OLYMPUSWIFI
|
f96259c12e534760524f8c7cb8b766b781ad5299
|
[
"MIT"
] | 1 |
2020-01-09T08:54:17.000Z
|
2020-01-09T08:54:17.000Z
|
backup/Olympus_ImageSave.lpr
|
MSGEndo/OLYMPUSWIFI
|
f96259c12e534760524f8c7cb8b766b781ad5299
|
[
"MIT"
] | 1 |
2020-09-26T11:25:37.000Z
|
2020-09-26T11:25:37.000Z
|
program Olympus_ImageSave;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}
//{$IFDEF UseCThreads} // NB: On Linux, not Windows, there is a custom compiler setting -dUsecThreads which allows cThreads to be used
cthreads, // when this IFDEF is present. Seems unnecessary to complicate things -just dont have the IFDEF and if
//{$ENDIF} // dont want to use cThreads then take it out of the uses clause. Duh!
{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, runtimetypeinfocontrols, Olympus_ImageSave1, OlympusShare;
{$R *.res}
begin
RequireDerivedFormResource:=True;
Application.Scaled:=True;
Application.Initialize;
Application.CreateForm(TForm_Main, Form_Main);
Application.Run;
end.
| 31.833333 | 140 | 0.700262 |
f1a119e89e723c13e2523f999c5684211e8e3b1b
| 17,167 |
pas
|
Pascal
|
Apus.Engine.Graphics.pas
|
atkins126/ApusGameEngine
|
e89dbbf69263c3a6b4848c2c645398719c7e4050
|
[
"BSD-3-Clause"
] | null | null | null |
Apus.Engine.Graphics.pas
|
atkins126/ApusGameEngine
|
e89dbbf69263c3a6b4848c2c645398719c7e4050
|
[
"BSD-3-Clause"
] | null | null | null |
Apus.Engine.Graphics.pas
|
atkins126/ApusGameEngine
|
e89dbbf69263c3a6b4848c2c645398719c7e4050
|
[
"BSD-3-Clause"
] | null | null | null |
// Platform-independent implementation of the graphics APIs
//
// Copyright (C) 2021 Apus Software (ivan@apus-software.com)
// This file is licensed under the terms of BSD-3 license (see license.txt)
// This file is a part of the Apus Game Engine (http://apus-software.com/engine/)
unit Apus.Engine.Graphics;
interface
uses Types, Apus.Engine.Types, Apus.Engine.API;
type
IRenderDevice=interface
// Draw primitives
procedure Draw(primType:TPrimitiveType;primCount:integer;vertices:pointer;
vertexLayout:TVertexLayout);
// Draw indexed primitives
procedure DrawIndexed(primType:TPrimitiveType;vertices:pointer;indices:pointer;
vertexLayout:TVertexLayout;primCount:integer); overload;
// Ranged version
procedure DrawIndexed(primType:TPrimitiveType;vertices:pointer;indices:pointer;
vertexLayout:TVertexLayout; vrtStart,vrtCount:integer; indStart,primCount:integer); overload;
// Draw instanced indexed primitives
procedure DrawInstanced(primType:TPrimitiveType;vertices:pointer;indices:pointer;
vertexLayout:TVertexLayout;primCount,instances:integer);
// Работу с буферами нужно организовать как-то иначе.
// Нужен отдельный класс для буфера. Управлять ими должен resman.
(* // Draw primitives using built-in buffers
procedure DrawBuffer(primType,primCount,vrtStart:integer;
vertexBuf:TPainterBuffer;stride:integer); overload;
// Draw indexed primitives using built-in buffer
procedure DrawBuffer(primType:integer;vertexBuf,indBuf:TPainterBuffer;
stride:integer;vrtStart,vrtCount:integer; indStart,primCount:integer); overload; *)
procedure Reset; // Invalidate rendering settings
end;
TTransformationAPI=class(TInterfacedObject,ITransformation)
viewMatrix:T3DMatrix; // current view (camera) matrix
objMatrix:T3DMatrix; // current object (model) matrix
projMatrix:T3DMatrix; // current projection matrix
MVP:T3DMatrix; // combined matrix
constructor Create;
procedure DefaultView; virtual;
procedure Perspective(fov:single;zMin,zMax:double); overload; virtual;
procedure Perspective(xMin,xMax,yMin,yMax,zScreen,zMin,zMax:double); overload; virtual;
procedure Orthographic(scale,zMin,zMax:double); virtual;
procedure SetProjection(proj:T3DMatrix); virtual;
procedure SetView(view:T3DMatrix); virtual;
procedure SetCamera(origin,target,up:TPoint3;turnCW:double=0); virtual;
procedure SetObj(mat:T3DMatrix); overload; virtual;
procedure SetObj(oX,oY,oZ:single;scale:single=1;yaw:single=0;roll:single=0;pitch:single=0); overload; virtual;
procedure ResetObj; virtual;
function Update:boolean; // Сalculate combined matrix (if needed), returns true if matrix was changed
function GetMVPMatrix:T3DMatrix;
function GetProjMatrix:T3DMatrix;
function GetViewMatrix:T3DMatrix;
function GetObjMatrix:T3DMatrix;
function ITransformation.MVPMatrix = GetMVPMatrix;
function ITransformation.ProjMatrix = GetProjMatrix;
function ITransformation.ViewMatrix = GetViewMatrix;
function ITransformation.ObjMatrix = GetObjMatrix;
function Transform(source:TPoint3):TPoint3;
type
TMatrixType=(mtModelView,mtProjection);
protected
modified:boolean;
procedure CalcMVP;
end;
TClippingAPI=class(TInterfacedObject,IClipping)
constructor Create;
procedure Rect(r:TRect;combine:boolean=true); //< Set clipping rect (combine with previous or override), save previous
procedure Nothing; //< don't clip anything, save previous (the same as Apply() for the whole render target area)
procedure Restore; //< restore previous clipping rect
function Get:TRect; //< return current clipping rect
procedure Prepare; overload; //<
function Prepare(r:TRect):boolean; overload; //< return false if r doesn't intersect the current clipping rect (so no need to draw anything inside r)
function Prepare(x1,y1,x2,y2:NativeInt):boolean; overload; //< return false if r doesn't intersect the current clipping rect (so no need to draw anything inside r)
function Prepare(x1,y1,x2,y2:single):boolean; overload; //< return false if r doesn't intersect the current clipping rect (so no need to draw anything inside r)
procedure AssignActual(r:TRect); // set actual clipping area (from gfx API)
protected
clipRect:TRect; //< current requested clipping area (in virtual pixels), might be different from actual clipping area}
actualClip:TRect; //< real clipping area
stack:array[0..49] of TRect;
stackPos:integer;
end;
TRenderTargetAPI=class(TInterfacedObject,IRenderTarget)
constructor Create;
procedure Backbuffer; virtual;
procedure Texture(tex:TTexture); virtual;
procedure Push; virtual;
procedure Pop; virtual;
procedure Clear(color:cardinal;zbuf:single=0;stencil:integer=-1); virtual; abstract;
procedure Viewport(oX,oY,VPwidth,VPheight:integer;renderWidth:integer=0;renderHeight:integer=0); virtual;
procedure UseDepthBuffer(test:TDepthBufferTest;writeEnable:boolean=true); virtual;
procedure BlendMode(blend:TBlendingMode); virtual; abstract;
procedure Mask(rgb:boolean;alpha:boolean); virtual;
procedure UnMask; virtual;
function width:integer; // width of the current render target in virtual pixels
function height:integer; // height of the current render target in virtual pixels
function aspect:single; // width/height
procedure ClipVirtual(const r:TRect); //< Set clip rect in virtual pixels
procedure Clip(x,y,w,h:integer); virtual; abstract; //< Set actual clip rect defined in real pixels
procedure Resized(newWidth,newHeight:integer); virtual; abstract; // backbuffer size changed
protected
vPort:TRect; //< part of the backbuffer used for output (backbuffer only, RT-textures always use full surface)
renderWidth,renderHeight:integer; //< size in virtual pixels
realWidth,realHeight:integer; //< size of the whole target surface in real pixels
curBlend:TBlendingMode;
curTarget:TTexture;
// saved stack of render targets
stack:array[1..10] of TTexture;
stackVP:array[1..10] of TRect;
stackRW,stackRH:array[1..10] of integer;
stackCnt:integer;
// stack of saved masks
maskStack:array[0..9] of integer;
maskStackPos:integer;
curMask:integer;
procedure ApplyMask; virtual; abstract; //< Apply curMask
end;
var
renderDevice:IRenderDevice;
// APIs implementation
transformationAPI:TTransformationAPI;
clippingAPI:TClippingAPI;
renderTargetAPI:TRenderTargetAPI;
// Build vertex layout descriptor from fields offset (in bytes)
// Pass 0 for unused (absent) fields (except position - it is always used)
// Pass >=255 for position to use 2D position vectors
//function BuildVertexLayout(position,normal,color,uv1,uv2:integer):TVertexLayout;
implementation
uses Math, Apus.MyServis, Apus.Geom3D, Apus.Geom2D;
{ TTransformationsAPI }
procedure TTransformationAPI.CalcMVP;
var
tmp:T3DMatrix;
begin
MultMat4(objMatrix,viewMatrix,tmp);
MultMat4(tmp,projMatrix,MVP);
end;
constructor TTransformationAPI.Create;
begin
_AddRef;
Apus.Engine.API.transform:=self;
viewMatrix:=IdentMatrix4;
objMatrix:=IdentMatrix4;
projMatrix:=IdentMatrix4;
modified:=true;
end;
procedure TTransformationAPI.DefaultView;
var
w,h:integer;
begin
w:=renderTargetAPI.width;
h:=renderTargetAPI.height;
if (w=0) and (h=0) then exit;
projMatrix[0,0]:=2/w; projMatrix[1,0]:=0; projMatrix[2,0]:=0; projMatrix[3,0]:=-1+1/w;
if renderTargetAPI.curTarget<>nil then begin
projMatrix[0,1]:=0; projMatrix[1,1]:=2/h; projMatrix[2,1]:=0; projMatrix[3,1]:=-(1-1/h);
end else begin
projMatrix[0,1]:=0; projMatrix[1,1]:=-2/h; projMatrix[2,1]:=0; projMatrix[3,1]:=1-1/h;
end;
projMatrix[0,2]:=0; projMatrix[1,2]:=0; projMatrix[2,2]:=-1; projMatrix[3,2]:=0;
projMatrix[0,3]:=0; projMatrix[1,3]:=0; projMatrix[2,3]:=0; projMatrix[3,3]:=1;
viewMatrix:=IdentMatrix4;
objMatrix:=IdentMatrix4;
modified:=true;
//Update;
end;
function TTransformationAPI.GetMVPMatrix:T3DMatrix;
begin
if modified then CalcMVP;
result:=MVP;
end;
function TTransformationAPI.GetObjMatrix:T3DMatrix;
begin
result:=objMatrix;
end;
function TTransformationAPI.GetProjMatrix: T3DMatrix;
begin
result:=projMatrix;
end;
function TTransformationAPI.GetViewMatrix: T3DMatrix;
begin
result:=viewMatrix;
end;
procedure TTransformationAPI.Orthographic(scale, zMin, zMax: double);
var
w,h:integer;
begin
w:=renderTargetAPI.width;
h:=renderTargetAPI.height;
projMatrix[0,0]:=scale*2/w; projMatrix[1,0]:=0; projMatrix[2,0]:=0; projMatrix[3,0]:=0;
if renderTargetAPI.curTarget=nil then begin
projMatrix[0,1]:=0; projMatrix[1,1]:=-scale*2/h; projMatrix[2,1]:=0; projMatrix[3,1]:=0;
end else begin
projMatrix[0,1]:=0; projMatrix[1,1]:=scale*2/h; projMatrix[2,1]:=0; projMatrix[3,1]:=0;
end;
projMatrix[0,2]:=0; projMatrix[1,2]:=0; projMatrix[2,2]:=2/(zMax-zMin); projMatrix[3,2]:=-(zMax+zMin)/(zMax-zMin);
projMatrix[0,3]:=0; projMatrix[1,3]:=0; projMatrix[2,3]:=0; projMatrix[3,3]:=1;
modified:=true;
end;
procedure TTransformationAPI.Perspective(xMin, xMax, yMin, yMax, zScreen, zMin,
zMax: double);
var
A,B,C,D:single;
i:integer;
begin
A:=(xMax+xMin)/(xMax-xMin);
B:=(yMin+yMax)/(yMin-yMax);
C:=zMax/(zMax-zMin);
D:=zMax*zMin/(zMin-zMax);
projMatrix[0,0]:=2*zScreen/(xMax-xMin); projMatrix[1,0]:=0; projMatrix[2,0]:=A; projMatrix[3,0]:=0;
projMatrix[0,1]:=0; projMatrix[1,1]:=2*zScreen/(yMax-yMin); projMatrix[2,1]:=B; projMatrix[3,1]:=0;
projMatrix[0,2]:=0; projMatrix[1,2]:=0; projMatrix[2,2]:=C; projMatrix[3,2]:=D;
projMatrix[0,3]:=0; projMatrix[1,3]:=0; projMatrix[2,3]:=1; projMatrix[3,3]:=0;
if renderTargetAPI.curTarget=nil then // нужно переворачивать ось Y если только не рисуем в текстуру
for i:=0 to 3 do
projMatrix[i,1]:=-projMatrix[i,1];
modified:=true;
end;
procedure TTransformationAPI.Perspective(fov: single; zMin, zMax: double);
var
x,y,aspect:single;
begin
x:=tan(fov/2);
y:=x;
aspect:=renderTargetAPI.aspect;
if aspect>1 then y:=y/aspect
else x:=x*aspect;
Perspective(-x,x,-y,y,1,zMin,zMax);
end;
procedure TTransformationAPI.SetCamera(origin, target, up: TPoint3;
turnCW: double);
var
mat:TMatrix4;
v1,v2,v3:TVector3;
begin
v1:=Vector3(origin,target); // front
Normalize3(v1);
v2:=Vector3(origin,up);
v3:=CrossProduct3(v1,v2); // right
Normalize3(v3); // Right vector
v2:=CrossProduct3(v1,v3); // Down vector
mat[0,0]:=v3.x; mat[0,1]:=v3.y; mat[0,2]:=v3.z; mat[0,3]:=0;
mat[1,0]:=v2.x; mat[1,1]:=v2.y; mat[1,2]:=v2.z; mat[1,3]:=0;
mat[2,0]:=v1.x; mat[2,1]:=v1.y; mat[2,2]:=v1.z; mat[2,3]:=0;
mat[3,0]:=origin.x; mat[3,1]:=origin.y; mat[3,2]:=origin.z; mat[3,3]:=1;
SetView(mat);
end;
procedure TTransformationAPI.SetObj(oX, oY, oZ, scale, yaw, roll,
pitch: single);
var
m,m2:T3DMatrix;
i,j:integer;
begin
// rotation
if (yaw<>0) or (roll<>0) or (pitch<>0) then
m:=MatrixFromYawRollPitch4(yaw,roll,pitch)
else begin
if scale=1 then begin
// translation only
SetObj(TranslationMat4(ox,oy,oz));
exit;
end;
m:=IdentMatrix4;
end;
// scale
if scale<>1 then
for i:=0 to 2 do
for j:=0 to 2 do
m[i,j]:=m[i,j]*scale;
// position
MultMat4(m,TranslationMat4(ox,oy,oz),m2);
SetObj(m2);
end;
procedure TTransformationAPI.SetProjection(proj:T3DMatrix);
begin
projMatrix:=proj;
modified:=true;
end;
procedure TTransformationAPI.ResetObj;
begin
SetObj(IdentMatrix4);
end;
procedure TTransformationAPI.SetObj(mat:T3DMatrix);
begin
objMatrix:=mat;
modified:=true;
end;
procedure TTransformationAPI.SetView(view:T3DMatrix);
begin
// Original matrix is "Camera space->World space" but we need reverse transformation: "World->Camera"
Invert4Full(view,viewMatrix);
modified:=true;
end;
function TTransformationAPI.Transform(source: TPoint3): TPoint3;
var
x,y,z,t:double;
begin
CalcMVP;
x:=source.x*mvp[0,0]+source.y*mvp[1,0]+source.z*mvp[2,0]+mvp[3,0];
y:=source.x*mvp[0,1]+source.y*mvp[1,1]+source.z*mvp[2,1]+mvp[3,1];
z:=source.x*mvp[0,2]+source.y*mvp[1,2]+source.z*mvp[2,2]+mvp[3,2];
t:=source.x*mvp[0,3]+source.y*mvp[1,3]+source.z*mvp[2,3]+mvp[3,3];
if (t<>1) and (t<>0) then begin
x:=x/t; y:=y/t; z:=z/t;
end;
result.x:=x;
result.y:=y;
result.z:=z;
end;
function TTransformationAPI.Update:boolean;
begin
if not modified then exit(false);
CalcMVP;
modified:=false;
result:=true;
end;
{ TRenderTargetAPI }
function TRenderTargetAPI.aspect: single;
begin
if renderHeight>0 then result:=renderWidth/renderHeight
else result:=0;
end;
procedure TRenderTargetAPI.ClipVirtual(const r: TRect);
var
x,y,w,h:integer;
scaleX,scaleY:single;
begin
x:=vPort.Left;
y:=vPort.Top;
w:=vPort.Width;
h:=vPort.Height;
scaleX:=w/renderWidth;
scaleY:=h/renderHeight;
Clip(x+round(r.Left*scaleX),y+round(r.top*scaleY),
round(r.Width*scaleX),round(r.height*scaleY));
end;
constructor TRenderTargetAPI.Create;
begin
_AddRef;
curBlend:=blNone;
curTarget:=nil;
curMask:=15;
end;
procedure TRenderTargetAPI.Push;
begin
ASSERT(stackCnt<10);
inc(stackCnt);
stack[stackcnt]:=curTarget;
stackVP[stackCnt]:=vPort;
stackRW[stackCnt]:=renderWidth;
stackRH[stackCnt]:=renderHeight;
end;
procedure TRenderTargetAPI.Pop;
begin
ASSERT(stackCnt>0);
Texture(stack[stackcnt]);
with stackVP[stackCnt] do
Viewport(left,top,width,height,stackRW[stackCnt],stackRH[stackCnt]);
dec(stackCnt);
end;
function TRenderTargetAPI.height: integer;
begin
result:=renderHeight;
end;
function TRenderTargetAPI.width: integer;
begin
result:=renderWidth;
end;
procedure TRenderTargetAPI.Viewport(oX, oY, VPwidth, VPheight,
renderWidth, renderHeight: integer);
begin
if vpWidth<=0 then vpWidth:=realWidth;
if vpHeight<=0 then vpHeight:=realHeight;
vPort:=Rect(oX,oY,ox+vpWidth,oY+vpHeight);
if renderWidth<=0 then renderWidth:=vpWidth;
if renderHeight<=0 then renderHeight:=vpHeight;
self.renderWidth:=renderWidth;
self.renderHeight:=renderHeight;
transformationAPI.DefaultView;
end;
procedure TRenderTargetAPI.Mask(rgb, alpha: boolean);
var
mask:integer;
begin
ASSERT(maskStackPos<15);
mask:=0;
maskStack[maskStackPos]:=curmask;
inc(maskStackPos);
if rgb then mask:=mask+7;
if alpha then mask:=mask+8;
if curmask<>mask then begin
curMask:=mask;
ApplyMask;
end;
end;
procedure TRenderTargetAPI.UnMask;
var
mask:integer;
begin
ASSERT(maskStackPos>0);
dec(maskStackPos);
mask:=maskStack[maskStackPos];
if curmask<>mask then begin
curMask:=mask;
ApplyMask;
end;
end;
procedure TRenderTargetAPI.Backbuffer;
begin
curTarget:=nil;
end;
procedure TRenderTargetAPI.UseDepthBuffer(test: TDepthBufferTest;
writeEnable: boolean);
begin
end;
procedure TRenderTargetAPI.Texture(tex: TTexture);
begin
ASSERT(tex.HasFlag(tfRenderTarget));
curTarget:=tex;
end;
{ TClipping }
procedure TClippingAPI.Prepare;
begin
renderTargetAPI.ClipVirtual(clipRect);
actualClip:=clipRect;
end;
function TClippingAPI.Prepare(r:TRect):boolean;
var
outRect:TRect;
f1,f2:integer;
begin
f1:=IntersectRects(r,clipRect,outRect);
if f1=0 then exit(false);
result:=true;
// Adjust the clipping area if primitive can be partially clipped
if not EqualRect(clipRect,actualClip) then begin
f2:=IntersectRects(r,actualClip,outRect);
if (f1<>f2) or (f1>1) then begin
renderTargetAPI.ClipVirtual(clipRect);
actualClip:=clipRect;
end;
end;
end;
function TClippingAPI.Prepare(x1,y1,x2,y2:NativeInt):boolean;
begin
result:=Prepare(Types.Rect(x1,y1,x2,y2));
end;
function TClippingAPI.Prepare(x1,y1,x2,y2:single):boolean;
begin
result:=Prepare(Types.Rect(trunc(x1),trunc(y1),trunc(x2)+1,trunc(y2)+1));
end;
procedure TClippingAPI.AssignActual(r: TRect);
begin
actualClip:=r;
end;
constructor TClippingAPI.Create;
begin
_AddRef;
stackPos:=0;
clipRect:=types.Rect(-100000,-100000,100000,100000);
actualClip:=clipRect;
end;
function TClippingAPI.Get: TRect;
begin
result:=clipRect;
end;
procedure TClippingAPI.Nothing;
begin
Rect(types.Rect(-100000,-100000,100000,100000),false);
end;
procedure TClippingAPI.Rect(r: TRect; combine: boolean);
begin
ASSERT(stackPos<high(stack));
inc(stackPos);
stack[stackPos]:=clipRect;
if combine then begin
if IntersectRects(cliprect,r,cliprect)=0 then // no intersection
cliprect:=types.Rect(-1,-1,-1,-1);
end else
clipRect:=r;
end;
procedure TClippingAPI.Restore;
begin
ASSERT(stackPos>0);
clipRect:=stack[stackPos];
dec(stackPos);
end;
end.
| 30.710197 | 167 | 0.705481 |
f13fd712d8d7c42a906d50bbb3da92c29d1eb21d
| 4,768 |
pas
|
Pascal
|
trunk/SMARTSupport/SMARTSupport.Sandisk.pas
|
ebangin127/nstools
|
2a0bb4e6fd3688afd74afd4c7d69eeb46f096a99
|
[
"MIT"
] | 15 |
2016-02-12T14:55:53.000Z
|
2021-08-17T09:44:12.000Z
|
trunk/SMARTSupport/SMARTSupport.Sandisk.pas
|
ebangin127/nstools
|
2a0bb4e6fd3688afd74afd4c7d69eeb46f096a99
|
[
"MIT"
] | 1 |
2020-10-28T12:19:56.000Z
|
2020-10-28T12:19:56.000Z
|
trunk/SMARTSupport/SMARTSupport.Sandisk.pas
|
ebangin127/nstools
|
2a0bb4e6fd3688afd74afd4c7d69eeb46f096a99
|
[
"MIT"
] | 7 |
2016-08-21T23:57:47.000Z
|
2022-02-14T03:26:21.000Z
|
// Ported CrystalDiskInfo (The MIT License, http://crystalmark.info)
unit SMARTSupport.Sandisk;
interface
uses
BufferInterpreter, Device.SMART.List, SMARTSupport, Support;
type
TSandiskSMARTSupport = class(TSMARTSupport)
private
function ModelHasSandiskString(const Model: String): Boolean;
function SMARTHasSandiskCharacteristics(
const SMARTList: TSMARTValueList): Boolean;
function GetTotalWrite(const SMARTList: TSMARTValueList): TTotalWrite;
const
EntryID = $E8;
public
function IsThisStorageMine(
const IdentifyDevice: TIdentifyDeviceResult;
const SMARTList: TSMARTValueList): Boolean; override;
function GetTypeName: String; override;
function IsSSD: Boolean; override;
function IsInsufficientSMART: Boolean; override;
function GetSMARTInterpreted(
const SMARTList: TSMARTValueList): TSMARTInterpreted; override;
function IsWriteValueSupported(
const SMARTList: TSMARTValueList): Boolean; override;
protected
function ErrorCheckedGetLife(const SMARTList: TSMARTValueList): Integer;
override;
function InnerIsErrorAvailable(const SMARTList: TSMARTValueList):
Boolean; override;
function InnerIsCautionAvailable(const SMARTList: TSMARTValueList):
Boolean; override;
function InnerIsError(const SMARTList: TSMARTValueList): TSMARTErrorResult;
override;
function InnerIsCaution(const SMARTList: TSMARTValueList):
TSMARTErrorResult; override;
end;
implementation
{ TSandiskSMARTSupport }
function TSandiskSMARTSupport.GetTypeName: String;
begin
result := 'SmartSanDisk';
end;
function TSandiskSMARTSupport.IsInsufficientSMART: Boolean;
begin
result := false;
end;
function TSandiskSMARTSupport.IsSSD: Boolean;
begin
result := true;
end;
function TSandiskSMARTSupport.IsThisStorageMine(
const IdentifyDevice: TIdentifyDeviceResult;
const SMARTList: TSMARTValueList): Boolean;
begin
result :=
ModelHasSandiskString(IdentifyDevice.Model) and
SMARTHasSandiskCharacteristics(SMARTList);
end;
function TSandiskSMARTSupport.ModelHasSandiskString(const Model: String):
Boolean;
begin
result := Find('SanDisk', Model);
end;
function TSandiskSMARTSupport.SMARTHasSandiskCharacteristics(
const SMARTList: TSMARTValueList): Boolean;
const
TotalGBWritten = $E9;
begin
result := false;
try
SMARTList.GetIndexByID(TotalGBWritten);
except
on E: EEntryNotFound do
result := true;
else raise;
end;
end;
function TSandiskSMARTSupport.ErrorCheckedGetLife(
const SMARTList: TSMARTValueList): Integer;
begin
result := SMARTList[SMARTList.GetIndexByID($E8)].Current;
end;
function TSandiskSMARTSupport.InnerIsErrorAvailable(
const SMARTList: TSMARTValueList): Boolean;
begin
result := true;
end;
function TSandiskSMARTSupport.InnerIsCautionAvailable(
const SMARTList: TSMARTValueList): Boolean;
begin
result := IsEntryAvailable(EntryID, SMARTList);
end;
function TSandiskSMARTSupport.InnerIsError(
const SMARTList: TSMARTValueList): TSMARTErrorResult;
begin
result.Override := false;
result.Status :=
InnerCommonIsError(EntryID, SMARTList).Status;
end;
function TSandiskSMARTSupport.InnerIsCaution(
const SMARTList: TSMARTValueList): TSMARTErrorResult;
begin
result := InnerCommonIsCaution(EntryID, SMARTList, CommonLifeThreshold);
end;
function TSandiskSMARTSupport.IsWriteValueSupported(
const SMARTList: TSMARTValueList): Boolean;
const
WriteID = $F1;
begin
try
SMARTList.GetIndexByID(WriteID);
result := true;
except
result := false;
end;
end;
function TSandiskSMARTSupport.GetSMARTInterpreted(
const SMARTList: TSMARTValueList): TSMARTInterpreted;
const
ReadError = true;
EraseError = false;
UsedHourID = $09;
ThisErrorType = ReadError;
ErrorID = $BB;
ReplacedSectorsID = $05;
begin
FillChar(result, SizeOf(result), 0);
result.UsedHour := SMARTList.ExceptionFreeGetRAWByID(UsedHourID);
result.ReadEraseError.TrueReadErrorFalseEraseError := ReadError;
result.ReadEraseError.Value :=
SMARTList.ExceptionFreeGetRAWByID(ErrorID);
result.ReplacedSectors :=
SMARTList.ExceptionFreeGetRAWByID(ReplacedSectorsID);
result.TotalWrite := GetTotalWrite(SMARTList);
end;
function TSandiskSMARTSupport.GetTotalWrite(
const SMARTList: TSMARTValueList): TTotalWrite;
function LBAToMB(const SizeInLBA: Int64): UInt64;
begin
result := SizeInLBA shr 1;
end;
function GBToMB(const SizeInLBA: Int64): UInt64;
begin
result := SizeInLBA shl 10;
end;
const
HostWrite = true;
NANDWrite = false;
WriteID = $F1;
begin
result.InValue.TrueHostWriteFalseNANDWrite :=
HostWrite;
result.InValue.ValueInMiB :=
LBAToMB(SMARTList.ExceptionFreeGetRAWByID(WriteID));
end;
end.
| 26.342541 | 79 | 0.770134 |
83b15b375587b84b8834f491b125b98e54ad25bb
| 2,376 |
pas
|
Pascal
|
Packages/Order Entry Results Reporting/CPRS/CPRS-Chart/Orders/fOrdersComplete.pas
|
timmvt/VistA_tt
|
05694e3a98c026f682f99ca9eb701bdd1e82af28
|
[
"Apache-2.0"
] | 1 |
2015-11-03T14:56:42.000Z
|
2015-11-03T14:56:42.000Z
|
CPRSChart/OR_30_423_SRC/CPRS-chart/Orders/fOrdersComplete.pas
|
VHAINNOVATIONS/Transplant
|
a6c000a0df4f46a17330cec95ff25119fca1f472
|
[
"Apache-2.0"
] | null | null | null |
CPRSChart/OR_30_423_SRC/CPRS-chart/Orders/fOrdersComplete.pas
|
VHAINNOVATIONS/Transplant
|
a6c000a0df4f46a17330cec95ff25119fca1f472
|
[
"Apache-2.0"
] | null | null | null |
unit fOrdersComplete;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
fAutoSz, StdCtrls, ORFn, ORCtrls, VA508AccessibilityManager;
type
TfrmCompleteOrders = class(TfrmAutoSz)
Label1: TLabel;
lstOrders: TCaptionListBox;
cmdOK: TButton;
cmdCancel: TButton;
lblESCode: TLabel;
txtESCode: TCaptionEdit;
procedure FormCreate(Sender: TObject);
procedure cmdOKClick(Sender: TObject);
procedure cmdCancelClick(Sender: TObject);
private
OKPressed: Boolean;
ESCode: string;
end;
function ExecuteCompleteOrders(SelectedList: TList): Boolean;
implementation
{$R *.DFM}
uses Hash, rCore, rOrders;
function ExecuteCompleteOrders(SelectedList: TList): Boolean;
var
frmCompleteOrders: TfrmCompleteOrders;
i: Integer;
begin
Result := False;
if SelectedList.Count = 0 then Exit;
frmCompleteOrders := TfrmCompleteOrders.Create(Application);
try
ResizeFormToFont(TForm(frmCompleteOrders));
with SelectedList do for i := 0 to Count - 1 do
frmCompleteOrders.lstOrders.Items.Add(TOrder(Items[i]).Text);
frmCompleteOrders.ShowModal;
if frmCompleteOrders.OKPressed then
begin
with SelectedList do
for i := 0 to Count - 1 do CompleteOrder(TOrder(Items[i]), frmCompleteOrders.ESCode);
Result := True;
end;
finally
frmCompleteOrders.Release;
with SelectedList do for i := 0 to Count - 1 do UnlockOrder(TOrder(Items[i]).ID);
end;
end;
procedure TfrmCompleteOrders.FormCreate(Sender: TObject);
begin
inherited;
OKPressed := False;
end;
procedure TfrmCompleteOrders.cmdOKClick(Sender: TObject);
const
TX_NO_CODE = 'An electronic signature code must be entered to complete orders.';
TC_NO_CODE = 'Electronic Signature Code Required';
TX_BAD_CODE = 'The electronic signature code entered is not valid.';
TC_BAD_CODE = 'Invalid Electronic Signature Code';
begin
inherited;
if Length(txtESCode.Text) = 0 then
begin
InfoBox(TX_NO_CODE, TC_NO_CODE, MB_OK);
Exit;
end;
if not ValidESCode(txtESCode.Text) then
begin
InfoBox(TX_BAD_CODE, TC_BAD_CODE, MB_OK);
txtESCode.SetFocus;
txtESCode.SelectAll;
Exit;
end;
ESCode := Encrypt(txtESCode.Text);
OKPressed := True;
Close;
end;
procedure TfrmCompleteOrders.cmdCancelClick(Sender: TObject);
begin
inherited;
Close;
end;
end.
| 24.75 | 93 | 0.731481 |
8532b862c27c70f77c9415de055c78af1a6dc94a
| 6,478 |
pas
|
Pascal
|
Oxygene/Cooper/Android/WiktionarySimple/SimpleWikiHelper.pas
|
remobjects/ElementsSamples
|
744647f59424c18ccb06c0c776b2dcafdabb0513
|
[
"MIT"
] | 19 |
2016-04-09T12:40:27.000Z
|
2022-02-22T12:15:03.000Z
|
Oxygene/Cooper/Android/WiktionarySimple/SimpleWikiHelper.pas
|
remobjects/ElementsSamples
|
744647f59424c18ccb06c0c776b2dcafdabb0513
|
[
"MIT"
] | 3 |
2017-09-05T09:31:29.000Z
|
2019-09-11T04:49:27.000Z
|
Oxygene/Cooper/Android/WiktionarySimple/SimpleWikiHelper.pas
|
remobjects/ElementsSamples
|
744647f59424c18ccb06c0c776b2dcafdabb0513
|
[
"MIT"
] | 11 |
2016-12-29T19:30:39.000Z
|
2021-08-31T12:20:27.000Z
|
namespace com.example.android.simplewiktionary;
{*
* Copyright (C) 2007 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*}
interface
uses
org.json,
android.content,
android.content.pm,
android.net,
android.util,
java.io,
java.net;
type
/// <summary>
/// Helper methods to simplify talking with and parsing responses from a
/// lightweight Wiktionary API. Before making any requests, you should call
/// prepareUserAgent(Context) to generate a User-Agent string based on
/// your application package name and version.
/// </summary>
SimpleWikiHelper = public class
private
const TAG = 'SimpleWikiHelper';
// Partial URL to use when requesting the detailed entry for a specific
// Wiktionary page. Use String.format(String, Object...) to insert
// the desired page title after escaping it as needed.
const WIKTIONARY_PAGE =
'https://en.wiktionary.org/w/api.php?action=query&prop=revisions&titles=%s&' +
'rvprop=content&format=json%s';
// Partial URL to append to WIKTIONARY_PAGE when you want to expand
// any templates found on the requested page. This is useful when browsing
// full entries, but may use more network bandwidth.
const WIKTIONARY_EXPAND_TEMPLATES = '&rvexpandtemplates=true';
// StatusLine HTTP status code when no server error has occurred.
const HTTP_STATUS_OK = 200;
// Shared buffer used by getUrlContent(String) when reading results
// from an API request.
class var sBuffer: array of SByte := new SByte[512];
public
// Regular expression that splits "Word of the day" entry into word
// name, word type, and the first description bullet point.
const WORD_OF_DAY_REGEX = '(?s)\{\{wotd\|(.+?)\|(.+?)\|([^#\|]+).*?\}\}';
class method getPageContent(title: String; expandTemplates: Boolean): String;
protected
class method getUrlContent(url: String): String; locked;
end;
// Thrown when there were problems contacting the remote API server, either
// because of a network error, or the server returned a bad status code.
ApiException nested in SimpleWikiHelper = public class(Exception)
public
constructor(detailMessage: String; throwable: Throwable);
constructor(detailMessage: String);
end;
// Thrown when there were problems parsing the response to an API call,
// either because the response was empty, or it was malformed.
ParseException nested in SimpleWikiHelper = public class(Exception)
public
constructor(detailMessage: String; throwable: Throwable);
end;
implementation
/// <summary>
/// Read and return the content for a specific Wiktionary page. This makes a
/// lightweight API call, and trims out just the page content returned.
/// Because this call blocks until results are available, it should not be
/// run from a UI thread.
/// Throws ApiException If any connection or server error occurs.
/// Throws ParseException If there are problems parsing the response.
/// </summary>
/// <param name="title">The exact title of the Wiktionary page requested.</param>
/// <param name="expandTemplates">If true, expand any wiki templates found.</param>
/// <returns>Exact content of page.</returns>
class method SimpleWikiHelper.getPageContent(title: String; expandTemplates: Boolean): String;
begin
// Encode page title and expand templates if requested
var encodedTitle: String := android.net.Uri.encode(title);
var expandClause: String := if expandTemplates then WIKTIONARY_EXPAND_TEMPLATES else '';
// Query the API for content
var content: String := getUrlContent(String.format(WIKTIONARY_PAGE, encodedTitle, expandClause));
try
// Drill into the JSON response to find the content body
var response: JSONObject := new JSONObject(content);
var query: JSONObject := response.JSONObject['query'];
var pages: JSONObject := query.JSONObject['pages'];
var page: JSONObject := pages.JSONObject[String(pages.keys.next)];
var revisions: JSONArray := page.JSONArray['revisions'];
var revision: JSONObject := revisions.JSONObject[0];
exit revision.String['*'];
except
on e: JSONException do
raise new ParseException('Problem parsing API response', e)
end
end;
/// <summary>
/// Pull the raw text content of the given URL. This call blocks until the
/// operation has completed, and is synchronized because it uses a shared
/// buffer sBuffer.
/// Throws ApiException If any connection or server error occurs.
/// </summary>
/// <param name="url">The exact URL to request.</param>
/// <returns>The raw content returned by the server.</returns>
class method SimpleWikiHelper.getUrlContent(url: String): String;
begin
var _url := new URL(url);
var urlConnection: HttpURLConnection := HttpURLConnection(_url.openConnection());
urlConnection.connect();
try
var inputStream: InputStream := new BufferedInputStream(urlConnection.getInputStream());
var content: ByteArrayOutputStream := new ByteArrayOutputStream;
// Read response into a buffered stream
var readBytes: Integer := 0;
repeat
readBytes := inputStream.&read(sBuffer);
if readBytes <> -1 then
content.&write(sBuffer, 0, readBytes);
until readBytes = -1;
// Return result from buffered stream
exit new String(content.toByteArray);
except
on e: IOException do
raise new ApiException('Problem communicating with API', e)
finally
urlConnection.disconnect();
end;
end;
constructor SimpleWikiHelper.ApiException(detailMessage: String; throwable: Throwable);
begin
inherited
end;
constructor SimpleWikiHelper.ApiException(detailMessage: String);
begin
inherited
end;
constructor SimpleWikiHelper.ParseException(detailMessage: String; throwable: Throwable);
begin
inherited
end;
end.
| 39.987654 | 100 | 0.712257 |
854cd01cacee056a52784350c4f3f678c056a204
| 647 |
pas
|
Pascal
|
Test/SimpleScripts/dynamic_anonymous_record.pas
|
synapsea/DW-Script
|
b36c2e57f0285c217f8f0cae8e4e158d21127163
|
[
"Condor-1.1"
] | 1 |
2022-02-18T22:14:44.000Z
|
2022-02-18T22:14:44.000Z
|
Test/SimpleScripts/dynamic_anonymous_record.pas
|
synapsea/DW-Script
|
b36c2e57f0285c217f8f0cae8e4e158d21127163
|
[
"Condor-1.1"
] | null | null | null |
Test/SimpleScripts/dynamic_anonymous_record.pas
|
synapsea/DW-Script
|
b36c2e57f0285c217f8f0cae8e4e158d21127163
|
[
"Condor-1.1"
] | null | null | null |
var i : Integer;
i:=123;
function Get123 : array [1..3] of Integer;
begin
Result:=[1, 2, 3];
end;
var r :=
record
fi := i;
fi2 := i*2;
fis := '<'+IntToStr(i)+'>';
f123 := Get123;
property pi : Integer read fi;
function pis : string;
begin
Result:='['+IntToStr(pi)+']';
end;
end;
PrintLn(r.fi);
PrintLn(r.fi2);
PrintLn(r.fis);
PrintLn(r.pis);
PrintLn(r.f123[1]);
PrintLn(r.f123[2]);
PrintLn(r.f123[3]);
var r2 := r;
r.fi:=456;
PrintLn(r.pi);
PrintLn(r2.pi);
PrintLn(r2.fis);
PrintLn(r.pis);
PrintLn(r2.pis);
PrintLn(r2.f123[1]);
PrintLn(r2.f123[2]);
PrintLn(r2.f123[3]);
| 15.046512 | 42 | 0.55796 |
47137c668cd1224397a8df2941505945928cd81f
| 1,994 |
pas
|
Pascal
|
sources/chHash.CRC.CRC3.Reverse.pas
|
vampirsoft/CryptoHash
|
bd8eb1fc2f8c8b63c3cb52b47908b7fbadab4be4
|
[
"MIT"
] | null | null | null |
sources/chHash.CRC.CRC3.Reverse.pas
|
vampirsoft/CryptoHash
|
bd8eb1fc2f8c8b63c3cb52b47908b7fbadab4be4
|
[
"MIT"
] | null | null | null |
sources/chHash.CRC.CRC3.Reverse.pas
|
vampirsoft/CryptoHash
|
bd8eb1fc2f8c8b63c3cb52b47908b7fbadab4be4
|
[
"MIT"
] | 2 |
2020-08-30T18:22:38.000Z
|
2021-06-08T19:52:56.000Z
|
/////////////////////////////////////////////////////////////////////////////////
//*****************************************************************************//
//* Project : CryptoHash *//
//* Latest Source: https://github.com/vampirsoft/CryptoHash *//
//* Unit Name : CryptoHash.inc *//
//* Author : Сергей (LordVampir) Дворников *//
//* Copyright 2021 LordVampir (https://github.com/vampirsoft) *//
//* Licensed under MIT *//
//*****************************************************************************//
/////////////////////////////////////////////////////////////////////////////////
unit chHash.CRC.CRC3.Reverse;
{$INCLUDE CryptoHash.inc}
interface
uses
{$IF DEFINED(SUPPORTS_INTERFACES)}
chHash.CRC.CRC3.Impl;
{$ELSE ~ NOT SUPPORTS_INTERFACES}
chHash.CRC.CRC3;
{$ENDIF ~ SUPPORTS_INTERFACES}
type
{ TchReverseCrc3 }
TchReverseCrc3 = class(TchCrc3)
public
procedure Calculate(var Current: Byte; const Data: Pointer; const Length: Cardinal); override;
function Final(const Current: Byte): Byte; override;
end;
implementation
uses
{$IF DEFINED(USE_JEDI_CORE_LIBRARY)}
JclLogic;
{$ELSE ~ NOT USE_JEDI_CORE_LIBRARY}
chHash.Core.Bits;
{$ENDIF ~ USE_JEDI_CORE_LIBRARY}
{ TchReverseCrc3 }
procedure TchReverseCrc3.Calculate(var Current: Byte; const Data: Pointer; const Length: Cardinal);
const
ShiftToBits = Byte(BitsPerByte - TchCrc3.Size);
begin
Current := Current shl ShiftToBits;
inherited Calculate(Current, Data, Length);
Current := Current shr ShiftToBits;
end;
function TchReverseCrc3.Final(const Current: Byte): Byte;
const
ShiftToBits = Byte(BitsPerByte - TchCrc3.Size);
begin
Result := inherited Final(Current shl ShiftToBits);
end;
end.
| 30.676923 | 100 | 0.508024 |
f124809bc9fa90751874dbcadf109c38725e5b2f
| 861 |
dfm
|
Pascal
|
Data.Module.Conexao.dfm
|
andrehelena/Heranca_Tela
|
27c7f964872968f5b1f570f5cf6ebbe08f0b2d4a
|
[
"MIT"
] | 1 |
2021-08-11T19:56:52.000Z
|
2021-08-11T19:56:52.000Z
|
Data.Module.Conexao.dfm
|
andrehelena/Heranca_Tela
|
27c7f964872968f5b1f570f5cf6ebbe08f0b2d4a
|
[
"MIT"
] | null | null | null |
Data.Module.Conexao.dfm
|
andrehelena/Heranca_Tela
|
27c7f964872968f5b1f570f5cf6ebbe08f0b2d4a
|
[
"MIT"
] | null | null | null |
object DataModuleConexao: TDataModuleConexao
OldCreateOrder = False
OnCreate = DataModuleCreate
Height = 241
Width = 272
object FDConnection_Live: TFDConnection
Params.Strings = (
'Database=test'
'DriverID=MySQL'
'Password=server'
'Port=3307'
'Server=192.168.10.12'
'User_Name=root')
LoginPrompt = False
Left = 80
Top = 72
end
object FDPhysMySQLDriverLink1: TFDPhysMySQLDriverLink
VendorLib =
'C:\Users\andre\Desktop\Geito Errado - Conexao\Win32\Debug\libmar' +
'iadb.dll'
Left = 72
Top = 168
end
object FDQuery1: TFDQuery
Connection = FDConnection_Live
Left = 200
Top = 72
end
object FDGUIxWaitCursor1: TFDGUIxWaitCursor
Provider = 'Forms'
ScreenCursor = gcrAppWait
Left = 184
Top = 160
end
end
| 23.27027 | 75 | 0.635308 |
f1df1050dabb9832b71ded3187926dcf0151ae71
| 17,257 |
pas
|
Pascal
|
Projects/CL.Ag5/Source/_CommonSources/CLAg5.CompareDataFromClientDataSet.pas
|
iclinicadoleite/controle-ag5
|
2e315c4a7c9bcb841a8d2f2390ae9d7c2c2cb721
|
[
"Apache-2.0"
] | 1 |
2020-05-07T07:51:27.000Z
|
2020-05-07T07:51:27.000Z
|
Projects/CL.Ag5/Source/_CommonSources/CLAg5.CompareDataFromClientDataSet.pas
|
iclinicadoleite/controle-ag5
|
2e315c4a7c9bcb841a8d2f2390ae9d7c2c2cb721
|
[
"Apache-2.0"
] | null | null | null |
Projects/CL.Ag5/Source/_CommonSources/CLAg5.CompareDataFromClientDataSet.pas
|
iclinicadoleite/controle-ag5
|
2e315c4a7c9bcb841a8d2f2390ae9d7c2c2cb721
|
[
"Apache-2.0"
] | 3 |
2020-02-17T18:01:52.000Z
|
2020-05-07T07:51:28.000Z
|
unit CLAg5.CompareDataFromClientDataSet;
interface
uses
System.SysUtils, System.Classes, System.WideStrings, DBXFirebird, Tc.DBRTL.AbstractDB,
Tc.DBRTL.AbstractDB.DBX, Data.DB, Tc.Data.DB.Helpers, Data.SqlExpr, Tc.Data.SQLExpr,
DataSnap.DBClient, Tc.DataSnap.DBClient.Helpers, VCL.Dialogs, SQLTimSt ;
type
TLog = procedure ( ALog : string ) of object ;
TCompareDataFromClientDataSet = class
private
{ Private declarations }
FBaseSyncFolder : string ;
FSyncDateString : string ;
FSyncDate : TDateTime ;
FSelectedFarm : integer ;
FSQLStmt : string ;
FParams : TParams ;
FUploadSyncFolder : string ;
FDownloadSyncFolder : string ;
FLog: TLog;
FDefaultTableList : TClientDataSet ;
procedure MakeInsert ( ATableName : string ; AFields : TFields ) ;
procedure MakeUpdate ( ATableName : string ; AFields : TFields ) ;
procedure MakeUpdateOrInsert ( ATableName : string ; AFields : TFields ) ;
procedure MakeDelete ( ATableName : string ; AFields : TFields ) ;
procedure ExecuteSQLStmt( ATableName : string ) ;
procedure Compare ( ATableName : string ; ASource, ATarget : TClientDataSet ) ;
procedure SetLog(const Value: TLog);
procedure DoLog ( ALog : string ) ;
public
{ Public declarations }
procedure UpdateTables ( APath, ATableName : string ) ;
property Log : TLog read FLog write SetLog;
end;
implementation
uses ClAg5.DatabaseIntf,
IniFiles,
DateUtils,
Tc.RTL.Folders,
Tc.JVCL.Compressor,
Tc.RTL.Exceptions,
Tc.VCL.Application,
ShellAPI, WinApi.Windows, Forms ;
procedure ExecuteWait ( ExecuteFile, ParamString, StartInString: string ) ;
var
SEInfo: TShellExecuteInfo;
ExitCode: DWORD;
begin
FillChar(SEInfo, SizeOf(SEInfo), 0) ;
SEInfo.cbSize := SizeOf(TShellExecuteInfo) ;
with SEInfo do
begin
fMask := SEE_MASK_NOCLOSEPROCESS;
Wnd := Application.Handle;
lpFile := PChar(ExecuteFile) ;
{
ParamString can contain the
application parameters.
}
if ParamString <> '' then
lpParameters := PChar(ParamString) ;
{
StartInString specifies the
name of the working directory.
If ommited, the current directory is used.
}
if StartInString <> '' then
lpDirectory := PChar(StartInString) ;
nShow := SW_SHOWNORMAL;
end;
if ShellExecuteEx(@SEInfo) then begin
repeat
Application.ProcessMessages;
GetExitCodeProcess(SEInfo.hProcess, ExitCode) ;
until (ExitCode <> STILL_ACTIVE) or Application.Terminated ;
end
else
Raise Warning.Create ( '' ) ;
end;
procedure TCompareDataFromClientDataSet.Compare( ATableName : string ; ASource, ATarget: TClientDataSet);
begin
FParams := TParams.Create ;
ASource.First ;
ATarget.First ;
while not ( ASource.eof or ATarget.eof ) do
begin
FSQLStmt := '' ;
if ( ASource.Fields[ 0 ].Value = ATarget.Fields[ 0 ].Value ) then
begin
if ( ASource.FieldValues[ 'SYS$DU' ] > ATarget.FieldValues[ 'SYS$DU' ] ) then
{ MakeUpdate } MakeUpdateOrInsert ( ATableName, ASource.Fields ) ;
ASource.Next ;
ATarget.Next ;
end
else if CompareText ( ASource.Fields[ 0 ].Value, ATarget.Fields[ 0 ].Value ) > 0 then
begin
/////////////////////////MakeDelete ( ATableName, ATarget.Fields ) ;
ATarget.Next ;
end
else
begin
{ MakeInsert } MakeUpdateOrInsert ( ATableName, ASource.Fields ) ;
ASource.Next ;
end ;
ExecuteSQLStmt( ATableName )
end;
while not ( ASource.eof ) do
begin
{ MakeInsert } MakeUpdateOrInsert ( ATableName, ASource.Fields ) ;
ASource.Next ;
ExecuteSQLStmt( ATableName )
end;
(*
while not ( ATarget.eof ) do
begin
MakeDelete ( ATableName, ATarget.Fields ) ;
ATarget.Next ;
ExecuteSQLStmt( ATableName )
end;
*)
FParams.Free ;
end;
procedure TCompareDataFromClientDataSet.UpdateTables ( APath, ATableName : string ) ;
var
SourceCDS, TargetCDS : TClientDataSet ;
begin
try
DoLog ( 'Comparando ' + ATableName ) ;
SourceCDS := TClientDataSet.Create( nil ) ;
SourceCDS.LoadFromFile ( IncludeTrailingPathDelimiter ( APath ) + ATableName { + '.$' } ) ;
TargetCDS := nil ;
Tc.DBRTL.AbstractDB.TTcAbstractDB.GetByAlias( 'ENTIDADES' ).populateClientDataSet ( TargetCDS, 'SELECT * FROM ' + ATableName ) ;
SourceCDS.Fields[0].ProviderFlags := SourceCDS.Fields[0].ProviderFlags + [pfInKey ] ;
TargetCDS.Fields[0].ProviderFlags := TargetCDS.Fields[0].ProviderFlags + [pfInKey ] ;
SourceCDS.IndexFieldNames := SourceCDS.Fields[0].FieldName ;
TargetCDS.IndexFieldNames := TargetCDS.Fields[0].FieldName ;
Compare ( ATableName, SourceCDS, TargetCDS ) ;
SourceCDS.free ;
TargetCDS.Free ;
except On e : Exception do
showMessage ( e.message ) ;
end
end;
procedure TCompareDataFromClientDataSet.SetLog(const Value: TLog);
begin
FLog := Value;
end;
procedure TCompareDataFromClientDataSet.MakeInsert(ATableName: string; AFields : TFields ) ;
const
_INSERT_STMT =
'EXECUTE BLOCK'
+#13#10'AS'
+#13#10'BEGIN'
+#13#10' RDB$SET_CONTEXT( ''USER_TRANSACTION'', ''RLOG$OFF'', ''1'' ) ;'
+#13#10' INSERT INTO'
+#13#10' %s'
+#13#10' ( %s )'
+#13#10' VALUES'
+#13#10' ( %s ) ;'
+#13#10' RDB$SET_CONTEXT( ''USER_TRANSACTION'', ''RLOG$OFF'', NULL) ;'
+#13#10'END' ;
var
IterateFieldsList : integer ;
FieldsList, FieldsValues : string ;
begin
FieldsList := '' ;
FieldsValues := '' ;
FParams.Clear ;
for IterateFieldsList := 0 to AFields.Count -1 do
begin
FieldsList := Format ( '%s%s,'#13#10, [ FieldsList, AFields[ IterateFieldsList ].FieldName ] ) ;
FieldsValues := Format ( '%s:%s,'#13#10, [ FieldsValues, AFields[ IterateFieldsList ].FieldName ] ) ;
FParams.CreateParam ( ftUnknown, '', ptInput ).AssignField( AFields[ IterateFieldsList ] ) ;
end;
SetLength ( FieldsList, Length ( FieldsList ) -3 ) ;
SetLength ( FieldsValues, Length ( FieldsValues ) -3 ) ;
FSQLStmt := Format ( _INSERT_STMT, [ ATableName, FieldsList, FieldsValues ] ) ;
end;
procedure TCompareDataFromClientDataSet.MakeUpdate(ATableName: string; AFields: TFields );
const
_UPDATE_STMT =
'EXECUTE BLOCK'
+#13#10'AS'
+#13#10'BEGIN'
+#13#10' RDB$SET_CONTEXT( ''USER_TRANSACTION'', ''RLOG$OFF'', ''1'' ) ;'
+#13#10' UPDATE %s'
+#13#10' SET'
+#13#10' %s'
+#13#10' WHERE ('
+#13#10' %s'
+#13#10') ;'
+#13#10' RDB$SET_CONTEXT( ''USER_TRANSACTION'', ''RLOG$OFF'', NULL) ;'
+#13#10'END' ;
var
KeysList, FieldsList : string ;
IterateKeysList, IterateFieldsList : integer ;
begin
KeysList := '' ;
FieldsList := '' ;
FParams.Clear ;
for IterateFieldsList := 0 to AFields.Count -1 do
begin
FieldsList := Format ( '%s %s = :%1:s,'#13#10, [ FieldsList, AFields[ IterateFieldsList ].FieldName ] ) ;
FParams.CreateParam ( ftUnknown, '', ptInput ).AssignField( AFields[ IterateFieldsList ] ) ;
end ;
for IterateKeysList := 0 to AFields.Count -1 do
if pfInKey in AFields[ IterateKeysList ].ProviderFlags then
begin
KeysList := Format ( '%s %s = :%1:s'#13#10'AND ', [ KeysList, AFields[ IterateKeysList ].FieldName ] ) ;
FParams.CreateParam ( ftUnknown, '', ptInput ).AssignField( AFields[ IterateKeysList ] ) ;
end;
SetLength ( KeysList, Length ( KeysList ) -6 ) ;
SetLength ( FieldsList, Length ( FieldsList ) -3 ) ;
FSQLStmt := Format ( _UPDATE_STMT, [ ATableName, FieldsList, KeysList ] ) ;
end;
procedure TCompareDataFromClientDataSet.MakeUpdateOrInsert(ATableName: string; AFields: TFields );
const
_INSERT_STMT =
'EXECUTE BLOCK'
+#13#10'AS'
+#13#10'%s'
+#13#10'BEGIN'
+#13#10' RDB$SET_CONTEXT( ''USER_TRANSACTION'', ''RLOG$OFF'', ''1'') ;'
+#13#10' UPDATE OR INSERT INTO'
+#13#10' %s'
+#13#10' ( %s )'
+#13#10' VALUES'
+#13#10' ( %s )'
+#13#10' MATCHING ( %s ) ;'
+#13#10' RDB$SET_CONTEXT( ''USER_TRANSACTION'', ''RLOG$OFF'', NULL) ;'
+#13#10'END' ;
var
IterateFieldsList : integer ;
DeclareList, FieldsList, FieldsValues : string ;
function GetDeclare( AField : TField ) : string ;
var
LFieldType : string ;
LFieldValue : string ;
FS : TFormatSettings ;
begin
LFieldValue := 'NULL' ;
FS.DecimalSeparator := '.' ;
if AField is TIntegerField then
begin
LFieldType := 'integer' ;
if not AField.IsNull then
LFieldValue := AField.AsString ;
end;
if AField is TStringField then
begin
LFieldType := Format( 'varchar(%d)', [ AField.Size ] ) ;
if not AField.IsNull then
LFieldValue := QuotedStr ( AField.asString ) ;
end;
if AField is TMemoField then
begin
LFieldType := Format( 'varchar(%d)', [ 2048 ] ) ;
if not AField.IsNull then
LFieldValue := QuotedStr ( Copy ( AField.asString, 2048 ) ) ;
end;
if AField is TDateTimeField then
begin
LFieldType := 'TIMESTAMP' ;
if not AField.IsNull then
LFieldValue := QuotedStr ( FormatDateTime ( 'YYYY-MM-DD HH:MM:SS', TDateTimeField(AField).AsDateTime ) ) ;
end;
if AField is TSQLTimeStampField then
begin
LFieldType := 'TIMESTAMP' ;
if not AField.IsNull then
LFieldValue := QuotedStr ( FormatDateTime ( 'YYYY-MM-DD HH:MM:SS', TSQLTimeStampField(AField).AsDateTime ) ) ;
end;
if AField is TFloatField then
begin
LFieldType := 'double precision' ;
if not AField.IsNull then
LFieldValue := Format ( '%f', [ TFloatField ( AField ).AsFloat ], FS ) ;
end;
Result := Format ( 'DECLARE %s %s = %s', [ AField.FieldName, LFieldType, LFieldValue ] ) ;
end ;
begin
DeclareList := '' ;
FieldsList := '' ;
FieldsValues := '' ;
FParams.Clear ;
for IterateFieldsList := 0 to AFields.Count -1 do
if AFields[ IterateFieldsList ].FieldName <> 'LOGO' then
begin
DeclareList := Format ( '%s%s;'#13#10, [ DeclareList, GetDeclare( AFields[ IterateFieldsList ] ) ] ) ;
FieldsList := Format ( '%s%s,'#13#10, [ FieldsList, AFields[ IterateFieldsList ].FieldName ] ) ;
FieldsValues := Format ( '%s:%s,'#13#10, [ FieldsValues, AFields[ IterateFieldsList ].FieldName ] ) ;
FParams.CreateParam ( ftUnknown, '', ptInput ).AssignField( AFields[ IterateFieldsList ] ) ;
end;
SetLength ( DeclareList, Length ( DeclareList ) -2 ) ; //reteain ';'
SetLength ( FieldsList, Length ( FieldsList ) -3 ) ;
SetLength ( FieldsValues, Length ( FieldsValues ) -3 ) ;
FSQLStmt := Format ( _INSERT_STMT, [ DeclareList, ATableName, FieldsList, FieldsValues, AFields[ 0 ].FieldName ] ) ;
end;
(*
procedure TCompareDataFromClientDataSet.MakeUpdateOrInsert(ATableName: string; AFields: TFields );
const
_UPDATE_OR_INSERT_STMT =
'EXECUTE BLOCK'
+#13#10'AS'
+#13#10'%s'
+#13#10'BEGIN'
+#13#10' RDB$SET_CONTEXT( ''USER_TRANSACTION'', ''RLOG$OFF'', ''1'' ) ;'
+#13#10' IF EXISTS ( SELECT 1 FROM %s WHERE %s ) THEN'
+#13#10' UPDATE'
+#13#10' SET'
+#13#10' %s'
+#13#10' WHERE ( %s ) ;'
+#13#10' ELSE'
+#13#10' INSERT INTO'
+#13#10' %s'
+#13#10' ( %s )'
+#13#10' VALUES'
+#13#10' ( %s ) ;'
+#13#10' RDB$SET_CONTEXT( ''USER_TRANSACTION'', ''RLOG$OFF'', NULL) ;'
+#13#10'END' ;
function GetDeclare( AField : TField ) : string ;
var
LFieldType : string ;
LFieldValue : string ;
FS : TFormatSettings ;
begin
LFieldValue := 'NULL' ;
FS.DecimalSeparator := '.' ;
if AField is TStringField then
begin
LFieldType := Format( 'varchar(%d)', [ AField.Size ] ) ;
if not AField.IsNull then
LFieldValue := QuotedStr ( AField.asString ) ;
end;
if AField is TMemoField then
begin
LFieldType := Format( 'varchar(%d)', [ 2048 ] ) ;
if not AField.IsNull then
LFieldValue := QuotedStr ( Copy ( AField.asString, 2048 ) ) ;
end;
if AField is TDateTimeField then
begin
LFieldType := 'TIMESTAMP' ;
if not AField.IsNull then
LFieldValue := QuotedStr ( FormatDateTime ( 'YYYY-MM-DD HH:MM:SS', TDateTimeField(AField).AsDateTime ) ) ;
end;
if AField is TSQLTimeStampField then
begin
LFieldType := 'TIMESTAMP' ;
if not AField.IsNull then
LFieldValue := QuotedStr ( FormatDateTime ( 'YYYY-MM-DD HH:MM:SS', TSQLTimeStampField(AField).AsDateTime ) ) ;
end;
if AField is TFloatField then
begin
LFieldType := 'double precision' ;
if not AField.IsNull then
LFieldValue := Format ( '%f', [ TFloatField ( AField ).AsFloat ], FS ) ;
end;
Result := Format ( 'DECLARE %s %s = %s', [ AField.FieldName, LFieldType, LFieldValue ] ) ;
end ;
var
IterateKeysList,
IterateFieldsList : integer ;
DeclareList,
SelectKeysList, UpdateKeysList,
InsertFieldsList, InsertFieldsValues : string ;
UpdateFieldsList : string ;
FieldsList, FieldsValues : string ;
begin
DeclareList := '' ;
UpdateKeysList := '' ;
InsertFieldsList := '' ;
InsertFieldsValues := '' ;
UpdateFieldsList := '' ;
FParams.Clear ;
// keys for select
for IterateKeysList := 0 to AFields.Count -1 do
if pfInKey in AFields[ IterateKeysList ].ProviderFlags then
begin
SelectKeysList := Format ( '%s %s = :%1:s'#13#10'AND ', [ SelectKeysList, AFields[ IterateKeysList ].FieldName ] ) ;
FParams.CreateParam ( ftUnknown, '', ptInput ).AssignField( AFields[ IterateKeysList ] ) ;
end;
// fields for insert
for IterateFieldsList := 0 to AFields.Count -1 do
begin
DeclareList := Format ( '%s%s;'#13#10, [ DeclareList, GetDeclare( AFields[ IterateFieldsList ] ) ] ) ;
InsertFieldsList := Format ( '%s%s,'#13#10, [ InsertFieldsList, AFields[ IterateFieldsList ].FieldName ] ) ;
InsertFieldsValues := Format ( '%s:%s,'#13#10, [ InsertFieldsValues, AFields[ IterateFieldsList ].FieldName ] ) ;
FParams.CreateParam ( ftUnknown, '', ptInput ).AssignField( AFields[ IterateFieldsList ] ) ;
end;
// fields for update
for IterateFieldsList := 0 to AFields.Count -1 do
begin
UpdateFieldsList := Format ( '%s %s = :%1:s,'#13#10, [ UpdateFieldsList, AFields[ IterateFieldsList ].FieldName ] ) ;
FParams.CreateParam ( ftUnknown, '', ptInput ).AssignField( AFields[ IterateFieldsList ] ) ;
end ;
// keys for update
for IterateKeysList := 0 to AFields.Count -1 do
if pfInKey in AFields[ IterateKeysList ].ProviderFlags then
begin
UpdateKeysList := Format ( '%s %s = :%1:s'#13#10'AND ', [ UpdateKeysList, AFields[ IterateKeysList ].FieldName ] ) ;
FParams.CreateParam ( ftUnknown, '', ptInput ).AssignField( AFields[ IterateKeysList ] ) ;
end;
SetLength ( DeclareList, Length ( DeclareList ) -2 ) ; // retain ";"
SetLength ( SelectKeysList, Length ( SelectKeysList ) -6 ) ;
SetLength ( UpdateKeysList, Length ( UpdateKeysList ) -6 ) ;
SetLength ( UpdateFieldsList, Length ( UpdateFieldsList ) -3 ) ;
SetLength ( InsertFieldsList, Length ( InsertFieldsList ) -3 ) ;
SetLength ( InsertFieldsValues, Length ( InsertFieldsValues ) -3 ) ;
FSQLStmt := Format ( _UPDATE_OR_INSERT_STMT, [
DeclareList,
ATableName, SelectKeysList,
ATableName, UpdateFieldsList, UpdateKeysList,
ATableName, InsertFieldsList, InsertFieldsValues ] ) ;
end;
*)
procedure TCompareDataFromClientDataSet.DoLog(ALog: string);
begin
if Assigned ( FLog ) then
FLog ( ALog ) ;
end;
procedure TCompareDataFromClientDataSet.ExecuteSQLStmt( ATableName : string );
begin
if FSQLStmt = '' then
exit ;
if ( ATableName = 'CAD_ENTIDADES' )
and ( FParams[ 0 ].asString = LoggedUser.DomainID ) then
exit ;
if ( ATableName = 'SYS$USERS' )
and ( FParams[ 1 ].asString.ToLower = 'admin' ) then
exit ;
DoLog ( Copy ( FSQLStmt, 1, 6 ) + ': ' + FParams[ 0 ].asString ) ;
try
FPArams.Clear ; /// for use EXECUTE BLOCK no need params ....
Tc.DBRTL.AbstractDB.TTcAbstractDB.GetByAlias( 'ENTIDADES' ).Execute( FSQLStmt, FParams );
except On E : Exception do
ShowMessage ( E.Message ) ;
end;
end;
procedure TCompareDataFromClientDataSet.MakeDelete(ATableName: string; AFields : TFields );
const
_DELETE_STMT = 'DELETE FROM %s WHERE ( %s ) ' ;
var
KeysList : string ;
IterateKeysList : integer ;
begin
KeysList := '' ;
FParams.Clear ;
for IterateKeysList := 0 to AFields.Count -1 do
if pfInKey in AFields[ IterateKeysList ].ProviderFlags then
begin
KeysList := Format ( '%s%s = :%1:s'#13#10'AND ', [ KeysList, AFields[ IterateKeysList ].FieldName ] ) ;
FParams.CreateParam ( ftUnknown, '', ptInput ).AssignField( AFields[ IterateKeysList ] ) ;
end;
SetLength ( KeysList, Length ( KeysList ) -6 ) ;
FSQLStmt := Format ( _DELETE_STMT, [ ATableName, KeysList ] ) ;
end;
end.
| 32.256075 | 132 | 0.632091 |
f1c1765b04eb70ca000b9344acbd029c2b4fd52e
| 16,373 |
pas
|
Pascal
|
LogViewer.MainForm.pas
|
atkins126/LogViewer
|
47b331478b74c89ffffc48bb20bbe62f4362c556
|
[
"Apache-2.0"
] | null | null | null |
LogViewer.MainForm.pas
|
atkins126/LogViewer
|
47b331478b74c89ffffc48bb20bbe62f4362c556
|
[
"Apache-2.0"
] | null | null | null |
LogViewer.MainForm.pas
|
atkins126/LogViewer
|
47b331478b74c89ffffc48bb20bbe62f4362c556
|
[
"Apache-2.0"
] | null | null | null |
{
Copyright (C) 2013-2021 Tim Sinaeve tim.sinaeve@gmail.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
}
unit LogViewer.MainForm;
{ Application main form. }
interface
uses
Winapi.Windows, Winapi.Messages, Winapi.GDIPOBJ,
System.SysUtils, System.Variants, System.Classes, System.Actions,
System.Win.TaskbarCore, System.ImageList,
Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, Vcl.Taskbar,
Vcl.ExtCtrls, Vcl.ActnList, Vcl.ImgList, Vcl.Menus,
ChromeTabs, ChromeTabsClasses, ChromeTabsTypes,
kcontrols, kprogress,
Spring,
DDuce.Utils,
LogViewer.Interfaces, LogViewer.Factories, LogViewer.Settings,
LogViewer.Dashboard.View;
type
TfrmMain = class(TForm)
{$REGION 'designer controls'}
aclMain : TActionList;
actCenterToScreen : TAction;
actShowVersion : TAction;
ctMain : TChromeTabs;
imlMain : TImageList;
pbrCPU : TKPercentProgressBar;
pnlDelta : TPanel;
pnlMainClient : TPanel;
pnlMemory : TPanel;
pnlMessageCount : TPanel;
pnlSourceName : TPanel;
pnlStatusBar : TPanel;
pnlTop : TPanel;
shpLine : TShape;
tmrPoll : TTimer;
tskbrMain : TTaskbar;
imlTabStates : TImageList;
{$ENDREGION}
{$REGION 'action handlers'}
procedure actCenterToScreenExecute(Sender: TObject);
procedure actShowVersionExecute(Sender: TObject);
{$ENDREGION}
{$REGION 'event handlers'}
procedure ctMainButtonCloseTabClick(
Sender : TObject;
ATab : TChromeTab;
var Close : Boolean
);
procedure ctMainNeedDragImageControl(
Sender : TObject;
ATab : TChromeTab;
var DragControl : TWinControl
);
procedure ctMainActiveTabChanged(
Sender : TObject;
ATab : TChromeTab
);
procedure ctMainBeforeDrawItem(
Sender : TObject;
TargetCanvas : TGPGraphics;
ItemRect : TRect;
ItemType : TChromeTabItemType;
TabIndex : Integer;
var Handled : Boolean
);
procedure FormShortCut(var Msg: TWMKey; var Handled: Boolean);
procedure tmrPollTimer(Sender: TObject);
{$ENDREGION}
private
FManager : ILogViewerManager;
FSettings : TLogViewerSettings;
FMainToolbar : TToolBar;
FDashboard : TfrmDashboard;
FDashboardTab : TChromeTab;
procedure SettingsChanged(Sender: TObject);
procedure EventsAddLogViewer(
Sender : TObject;
ALogViewer : ILogViewer
);
procedure EventsDeleteLogViewer(
Sender : TObject;
ALogViewer : ILogViewer
);
procedure EventsActiveViewChange(
Sender : TObject;
ALogViewer : ILogViewer
);
procedure EventsShowDashboard(Sender: TObject);
protected
{$REGION 'property access methods'}
function GetEvents: ILogViewerEvents;
function GetActions: ILogViewerActions;
function GetMenus: ILogViewerMenus;
function GetManager: ILogViewerManager;
{$ENDREGION}
procedure CreateDashboardView;
procedure DrawPanelText(
APanel : TPanel;
const AText : string
);
procedure UpdateStatusBar;
procedure UpdateActions; override;
procedure UpdateTabStates;
procedure OptimizeWidth(APanel: TPanel);
procedure OptimizeStatusBarPanelWidths;
public
procedure AfterConstruction; override;
destructor Destroy; override;
property Manager: ILogViewerManager
read GetManager;
property Actions: ILogViewerActions
read GetActions;
{ Menu components to use in the user interface. }
property Menus: ILogViewerMenus
read GetMenus;
{ Set of events where the user interface can respond to. }
property Events: ILogViewerEvents
read GetEvents;
end;
var
frmMain: TfrmMain;
implementation
{$R *.dfm}
uses
Spring.Utils,
DDuce.Factories.VirtualTrees,
DDuce.Logger, DDuce.Logger.Channels.ZeroMQ, DDuce.Utils.Winapi,
LogViewer.Resources;
{$REGION 'non-interfaced routines'}
{ Extracts the ZMQ library form resources if it does not exist. }
procedure EnsureZMQLibExists;
const
LIBZMQ = 'libzmq';
var
LResStream : TResourceStream;
LFileStream : TFileStream;
LPath : string;
begin
LPath := Format('%s\%s.dll', [ExtractFileDir(ParamStr(0)), LIBZMQ]);
if not FileExists(LPath) then
begin
LResStream := TResourceStream.Create(HInstance, LIBZMQ, RT_RCDATA);
try
LFileStream := TFileStream.Create(LPath, fmCreate);
try
LFileStream.CopyFrom(LResStream, 0);
finally
LFileStream.Free;
end;
finally
LResStream.Free;
end;
end;
end;
{$ENDREGION}
{$REGION 'construction and destruction'}
procedure TfrmMain.AfterConstruction;
var
FVI : TFileVersionInfo;
begin
inherited AfterConstruction;
TVirtualStringTreeFactory.DefaultTreeOptions.BorderStyle := bsNone;
TVirtualStringTreeFactory.DefaultGridOptions.BorderStyle := bsNone;
TVirtualStringTreeFactory.DefaultListOptions.BorderStyle := bsNone;
TVirtualStringTreeFactory.DefaultTreeGridOptions.BorderStyle := bsNone;
TVirtualStringTreeFactory.DefaultTreeListOptions.BorderStyle := bsNone;
FVI := TFileVersionInfo.GetVersionInfo(Application.ExeName);
Caption := Format('%s %s', [FVI.ProductName, FVI.ProductVersion]);
FSettings := TLogViewerFactories.CreateSettings;
try
FSettings.Load;
except
// ignore it and continue with defaults
end;
Logger.Enabled := FSettings.EmitLogMessages;
if Logger.Enabled then
begin
// setup logchannel for using a log LogViewer instance to debug itself.
Logger.Channels.Add(
TZeroMQChannel.Create(Format('tcp://*:%d', [LOGVIEWER_ZMQ_PORT]))
);
end;
Logger.Clear;
FManager := TLogViewerFactories.CreateManager(Self, FSettings);
Events.OnAddLogViewer.Add(EventsAddLogViewer);
Events.OnDeleteLogViewer.Add(EventsDeleteLogViewer);
Events.OnActiveViewChange.Add(EventsActiveViewChange);
Events.OnShowDashboard.Add(EventsShowDashboard);
FSettings.FormSettings.AssignTo(Self);
FSettings.OnChanged.Add(SettingsChanged);
FMainToolbar := TLogViewerFactories.CreateMainToolbar(
Self,
pnlTop,
Actions,
Menus
);
CreateDashboardView;
ctMain.LookAndFeel.Tabs.NotActive.Style.StartColor := ColorToRGB(clBtnFace);
ctMain.LookAndFeel.Tabs.NotActive.Style.StopColor := ColorToRGB(clBtnFace);
ctMain.LookAndFeel.Tabs.Active.Style.StartColor := ColorToRGB(clWindowFrame);
ctMain.LookAndFeel.Tabs.Active.Style.StopColor := ColorToRGB(clWindowFrame);
ctMain.LookAndFeel.Tabs.Hot.Style.StartColor := clSilver;
ctMain.LookAndFeel.Tabs.Hot.Style.StopColor := clSilver;
ctMain.PopupMenu := Manager.Menus.SubscriberPopupMenu;
tmrPoll.Enabled := True;
end;
destructor TfrmMain.Destroy;
begin
Logger.Track(Self, 'Destroy');
tmrPoll.Enabled := False;
Events.OnDeleteLogViewer.RemoveAll(Self);
Events.OnAddLogViewer.RemoveAll(Self);
Events.OnActiveViewChange.RemoveAll(Self);
Events.OnShowDashboard.RemoveAll(Self);
FSettings.FormSettings.Assign(Self);
FManager := nil;
FreeAndNil(FDashboard); // needs to be freed before manager!
try
inherited Destroy; // will destroy manager object as the mainform is its owner
finally
FSettings.OnChanged.RemoveAll(Self);
FreeAndNil(FSettings);
end;
end;
{$ENDREGION}
{$REGION 'action handlers'}
procedure TfrmMain.actCenterToScreenExecute(Sender: TObject);
begin
WindowState := wsMinimized;
Top := 0;
Left := 0;
WindowState := wsMaximized;
end;
procedure TfrmMain.actShowVersionExecute(Sender: TObject);
const
LIBZMQ = 'libzmq';
var
FVI : TFileVersionInfo;
begin
FVI := TFileVersionInfo.GetVersionInfo(
Format('%s\%s.dll', [ExtractFileDir(ParamStr(0)), LIBZMQ])
);
ShowMessage(FVI.ToString);
end;
{$ENDREGION}
{$REGION 'event handlers'}
procedure TfrmMain.ctMainActiveTabChanged(Sender: TObject; ATab: TChromeTab);
var
MV : ILogViewer;
begin
Logger.Track(Self, 'ctMainActiveTabChanged');
if ATab = FDashboardTab then
begin
FDashboard.Show;
FDashboard.SetFocus;
pnlSourceName.Caption := '';
pnlMessageCount.Caption := '';
pnlDelta.Caption := '';
OptimizeStatusBarPanelWidths;
end
else if Assigned(ATab.Data) then
begin
MV := ILogViewer(ATab.Data);
MV.Form.Show;
MV.Form.SetFocus;
UpdateStatusBar;
Manager.ActiveView := MV;
OptimizeStatusBarPanelWidths;
end;
end;
procedure TfrmMain.ctMainBeforeDrawItem(Sender: TObject;
TargetCanvas: TGPGraphics; ItemRect: TRect; ItemType: TChromeTabItemType;
TabIndex: Integer; var Handled: Boolean);
//var
// V : ILogViewer;
begin
// if ItemType = itTabText then
// begin
// V := ILogViewer(ctMain.Tabs[TabIndex].Data);
// TargetCanvas.DrawString()
// Handled := True;
// end;
// if ItemType = itBackground then
// begin
// V := ILogViewer(ctMain.Tabs[TabIndex].Data);
// TargetCanvas.DrawString()
// Handled := True;
// end;
end;
procedure TfrmMain.ctMainButtonCloseTabClick(Sender: TObject; ATab: TChromeTab;
var Close: Boolean);
var
V : ILogViewer;
begin
Logger.Track(Self, 'ctMainButtonCloseTabClick');
Close := False; // cleanup happens in EventsDeleteLogViewer
if ATab <> FDashboardTab then
begin
V := ILogViewer(ATab.Data);
Manager.DeleteView(V);
end;
end;
procedure TfrmMain.ctMainNeedDragImageControl(Sender: TObject; ATab: TChromeTab;
var DragControl: TWinControl);
begin
DragControl := pnlMainClient;
end;
procedure TfrmMain.EventsActiveViewChange(Sender: TObject;
ALogViewer: ILogViewer);
var
CT : TChromeTab;
I : Integer;
begin
Logger.Track(Self, 'EventsActiveViewChange');
if Assigned(ALogViewer) then
begin
for I := 0 to ctMain.Tabs.Count - 1 do
begin
CT := ctMain.Tabs[I];
if CT.Data = Pointer(ALogViewer) then
ctMain.ActiveTab := CT;
end;
ALogViewer.Form.Show;
end
else
begin
FDashboard.Show;
end;
end;
procedure TfrmMain.EventsAddLogViewer(Sender: TObject;
ALogViewer: ILogViewer);
var
S : string;
begin
ALogViewer.Subscriber.Enabled := True;
ALogViewer.Form.Parent := pnlMainClient;
S := ExtractFileName(ALogViewer.Subscriber.SourceName);
ctMain.Tabs.Add;
ctMain.ActiveTab.Data := Pointer(ALogViewer);
ctMain.ActiveTab.Caption :=
Format('%s (%d, %s)', [
S,
ALogViewer.Subscriber.SourceId,
ALogViewer.Subscriber.Receiver.ToString
]);
ALogViewer.Form.Show;
UpdateStatusBar;
OptimizeStatusBarPanelWidths;
end;
procedure TfrmMain.EventsDeleteLogViewer(Sender: TObject;
ALogViewer: ILogViewer);
var
I : Integer;
LDeleted : Boolean;
begin
LDeleted := False;
I := 1; // zero is dashboard
while (I < ctMain.Tabs.Count) and not LDeleted do
begin
if ILogViewer(ctMain.Tabs[I].Data) = ALogViewer then
begin
ctMain.Tabs.Delete(I);
LDeleted := True;
end
else
begin
Inc(I);
end;
end;
ctMain.Resize;
end;
procedure TfrmMain.EventsShowDashboard(Sender: TObject);
begin
FDashboardTab.Active := True;
FDashboard.Show;
end;
procedure TfrmMain.SettingsChanged(Sender: TObject);
begin
FormStyle := FSettings.FormSettings.FormStyle;
WindowState := FSettings.FormSettings.WindowState;
end;
procedure TfrmMain.tmrPollTimer(Sender: TObject);
begin
pbrCPU.Position := Round(GetProcessCpuUsagePct(GetCurrentProcessId));
pnlMemory.Caption := FormatBytes(MemoryUsed);
UpdateTabStates;
end;
procedure TfrmMain.FormShortCut(var Msg: TWMKey; var Handled: Boolean);
begin
Handled := Manager.Actions.ActionList.IsShortCut(Msg);
end;
{$ENDREGION}
{$REGION 'property access methods'}
function TfrmMain.GetActions: ILogViewerActions;
begin
Result := Manager.Actions;
end;
function TfrmMain.GetEvents: ILogViewerEvents;
begin
Result := FManager as ILogViewerEvents;
end;
function TfrmMain.GetManager: ILogViewerManager;
begin
Result := FManager as ILogViewerManager;
end;
function TfrmMain.GetMenus: ILogViewerMenus;
begin
Result := Manager.Menus;
end;
{$ENDREGION}
{$REGION 'protected methods'}
procedure TfrmMain.CreateDashboardView;
begin
FDashboard := TfrmDashboard.Create(Self, Manager);
FDashboard.Parent := pnlMainClient;
FDashboard.Align := alClient;
FDashboard.BorderStyle := bsNone;
ctMain.Tabs.Add;
ctMain.ActiveTab.Data := Pointer(FDashboard);
ctMain.ActiveTab.Caption := 'Dashboard';
ctMain.ActiveTab.DisplayName := 'Dashboard';
ctMain.ActiveTab.Pinned := True;
FDashboardTab := ctMain.ActiveTab;
FDashboard.Show;
end;
procedure TfrmMain.DrawPanelText(APanel: TPanel; const AText: string);
var
LCanvas : Shared<TControlCanvas>;
LBitmap : Shared<TBitmap>;
begin
LBitmap := TBitmap.Create;
LBitmap.Value.SetSize(APanel.Width, APanel.Height - 2);
LBitmap.Value.Canvas.Brush.Color := APanel.Color;
LBitmap.Value.Canvas.FillRect(LBitmap.Value.Canvas.ClipRect);
DrawFormattedText(
LBitmap.Value.Canvas.ClipRect,
LBitmap.Value.Canvas,
AText
);
LCanvas := TControlCanvas.Create;
LCanvas.Value.Control := APanel;
LCanvas.Value.Draw(0, 0, LBitmap);
end;
procedure TfrmMain.UpdateActions;
begin
UpdateStatusBar;
OptimizeStatusBarPanelWidths;
if Assigned(Actions) then
Actions.Items['actDashboard'].Checked := FDashboard.Focused;
inherited UpdateActions;
end;
procedure TfrmMain.OptimizeStatusBarPanelWidths;
begin
//OptimizeWidth(pnlSourceName);
end;
procedure TfrmMain.OptimizeWidth(APanel: TPanel);
var
S : string;
begin
S := APanel.Caption;
if Trim(S) <> '' then
begin
APanel.Width := GetTextWidth(APanel.Caption, APanel.Font) + 10;
APanel.AlignWithMargins := True;
end
else
begin
APanel.Width := 0;
APanel.AlignWithMargins := False;
end;
end;
procedure TfrmMain.UpdateStatusBar;
var
N : Integer;
//S : string;
begin
if Assigned(ctMain.ActiveTab) and Assigned(Manager)
and Assigned(Manager.ActiveView)
and Assigned(Manager.ActiveView.Subscriber)
and (ctMain.ActiveTab <> FDashboardTab) then
begin
// S := Format(SSubscriberSource, [
// Manager.ActiveView.Subscriber.SourceName,
// Manager.ActiveView.Subscriber.SourceId
// ]);
// DrawPanelText(pnlSourceName, S);
N := Manager.ActiveView.MilliSecondsBetweenSelection;
if N <> -1 then
begin
pnlDelta.Caption := Format('Delta: %dms', [N]);
pnlDelta.Color := clWhite;
end
else
begin
pnlDelta.Caption := '';
pnlDelta.Color := clBtnFace;
end;
// S := Format(SReceivedCount, [Manager.ActiveView.Subscriber.MessageCount]);
// DrawPanelText(pnlMessageCount, S);
end
else
begin
pnlSourceName.Caption := '';
pnlMessageCount.Caption := '';
pnlDelta.Caption := '';
OptimizeStatusBarPanelWidths;
end;
end;
procedure TfrmMain.UpdateTabStates;
var
I : Integer;
S : ISubscriber;
LV : ILogViewer;
begin
for I := 0 to ctMain.Tabs.Count - 1 do
begin
if ctMain.Tabs[I] <> FDashboardTab then
begin
LV := ILogViewer(ctMain.Tabs[I].Data);
S := LV.Subscriber;
if Supports(S, IWinipc) or Supports(S, IWinods) then
begin
if CheckProcessExists(S.SourceId) then
begin
if S.Enabled then
ctMain.Tabs[I].ImageIndex := 0 // Green
else
begin
ctMain.Tabs[I].ImageIndex := 2 // Red
end;
end
else
begin
ctMain.Tabs[I].ImageIndex := 1; // Off
end;
end
else
begin
if S.Enabled then
ctMain.Tabs[I].ImageIndex := 0 // Green
else
begin
ctMain.Tabs[I].ImageIndex := 2 // Red
end;
end;
end;
end;
end;
{$ENDREGION}
initialization
EnsureZMQLibExists;
end.
| 26.1968 | 82 | 0.699139 |
85f89fae59227e557d54ce9bf4ed4b9a7bf34095
| 391,747 |
pas
|
Pascal
|
source/libavutil.pas
|
paidong/Delphi-FFMPEG
|
1c13d3c4087b4abab65a90d119a5168fe914257d
|
[
"MIT"
] | 1 |
2019-12-02T09:42:53.000Z
|
2019-12-02T09:42:53.000Z
|
source/libavutil.pas
|
paidong/Delphi-FFMPEG
|
1c13d3c4087b4abab65a90d119a5168fe914257d
|
[
"MIT"
] | null | null | null |
source/libavutil.pas
|
paidong/Delphi-FFMPEG
|
1c13d3c4087b4abab65a90d119a5168fe914257d
|
[
"MIT"
] | null | null | null |
unit libavutil;
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}
interface
Uses
ffmpeg_types;
{$I ffmpeg.inc}
{$REGION 'avconfig.h'}
const
AV_HAVE_BIGENDIAN = 0;
AV_HAVE_FAST_UNALIGNED = 1;
{$ENDREGION}
{$REGION 'common.h'}
// rounded division & shift
// #define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
function RSHIFT(a, b: int): int; inline;
/// * assume b>0 */
// #define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b))
function ROUNDED_DIV(a, b: int): int; inline;
// (* Fast a/(1<<b) rounded toward +inf. Assume a>=0 and b>=0 *)
// #define AV_CEIL_RSHIFT(a,b) (!av_builtin_constant_p(b) ? -((-(a)) >> (b)) : ((a) + (1<<(b)) - 1) >> (b))
/// * Backwards compat. */
// #define FF_CEIL_RSHIFT AV_CEIL_RSHIFT
// #define FFUDIV(a,b) (((a)>0 ?(a):(a)-(b)+1) / (b))
function FFUDIV(a, b: int): int; inline;
// #define FFUMOD(a,b) ((a)-(b)*FFUDIV(a,b))
function FFUMOD(a, b: int): int; inline;
(* *
* Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they
* are not representable as absolute values of their type. This is the same
* as with *abs()
* @see FFNABS()
*)
// #define FFABS(a) ((a) >= 0 ? (a) : (-(a)))
function FFABS(a: int): int; inline;
// #define FFSIGN(a) ((a) > 0 ? 1 : -1)
function FFSIGN(a: int): int; inline;
(* *
* Negative Absolute value.
* this works for all integers of all types.
* As with many macros, this evaluates its argument twice, it thus must not have
* a sideeffect, that is FFNABS(x++) has undefined behavior.
*)
// #define FFNABS(a) ((a) <= 0 ? (a) : (-(a)))
function FFNABS(a: int): int; inline;
(* *
* Comparator.
* For two numerical expressions x and y, gives 1 if x > y, -1 if x < y, and 0
* if x == y. This is useful for instance in a qsort comparator callback.
* Furthermore, compilers are able to optimize this to branchless code, and
* there is no risk of overflow with signed types.
* As with many macros, this evaluates its argument multiple times, it thus
* must not have a side-effect.
*)
// #define FFDIFFSIGN(x,y) (((x)>(y)) - ((x)<(y)))
function FFDIFFSIGN(x, y: int): Boolean; inline;
// #define FFMAX(a,b) ((a) > (b) ? (a) : (b))
function FFMAX(a, b: int): int; inline;
// #define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c)
// #define FFMIN(a,b) ((a) > (b) ? (b) : (a))
// #define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c)
// #define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0)
// #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
(* misc math functions *)
// #ifndef av_log2
// av_const int av_log2(unsigned v);
// #endif
function av_log2(v: unsigned): int; cdecl; external avutil_dll;
// #ifndef av_log2_16bit
// av_const int av_log2_16bit(unsigned v);
// #endif
function av_log2_16bit(v: unsigned): int; cdecl; external avutil_dll;
(* *
* Clip a signed integer value into the amin-amax range.
* @param a value to clip
* @param amin minimum value of the clip range
* @param amax maximum value of the clip range
* @return clipped value
*)
// static av_always_inline av_const int av_clip_c(int a, int amin, int amax)
function av_clip_c(a: int; amin: int; amax: int): int; inline;
(* *
* Clip a signed 64bit integer value into the amin-amax range.
* @param a value to clip
* @param amin minimum value of the clip range
* @param amax maximum value of the clip range
* @return clipped value
*)
// static av_always_inline av_const int64_t av_clip64_c(int64_t a, int64_t amin, int64_t amax)
function av_clip64_c(a: int64_t; amin: int64_t; amax: int64_t): int64_t; inline;
(* *
* Clip a signed integer value into the 0-255 range.
* @param a value to clip
* @return clipped value
*)
// static av_always_inline av_const uint8_t av_clip_uint8_c(int a)
function av_clip_uint8_c(a: int): uint8_t; inline;
(* *
* Clip a signed integer value into the -128,127 range.
* @param a value to clip
* @return clipped value
*)
// static av_always_inline av_const int8_t av_clip_int8_c(int a)
function av_clip_int8_c(a: int): int8_t; inline;
(* *
* Clip a signed integer value into the 0-65535 range.
* @param a value to clip
* @return clipped value
*)
// static av_always_inline av_const uint16_t av_clip_uint16_c(int a)
function av_clip_uint16_c(a: int): uint16_t; inline;
(* *
* Clip a signed integer value into the -32768,32767 range.
* @param a value to clip
* @return clipped value
*)
// static av_always_inline av_const int16_t av_clip_int16_c(int a)
function av_clip_int16_c(a: int): int16_t; inline;
(* *
* Clip a signed 64-bit integer value into the -2147483648,2147483647 range.
* @param a value to clip
* @return clipped value
*)
// static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a)
function av_clipl_int32_c(a: int64_t): int32_t; inline;
(* *
* Clip a signed integer into the -(2^p),(2^p-1) range.
* @param a value to clip
* @param p bit position to clip at
* @return clipped value
*)
// static av_always_inline av_const int av_clip_intp2_c(int a, int p)
function av_clip_intp2_c(a: int; p: int): int; inline;
(* *
* Clip a signed integer to an unsigned power of two range.
* @param a value to clip
* @param p bit position to clip at
* @return clipped value
*)
// static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
function av_clip_uintp2_c(a, p: int): unsigned; inline;
(* *
* Clear high bits from an unsigned integer starting with specific bit position
* @param a value to clip
* @param p bit position to clip at
* @return clipped value
*)
// static av_always_inline av_const unsigned av_mod_uintp2_c(unsigned a, unsigned p)
function av_mod_uintp2_c(a, p: unsigned): unsigned; inline;
(* *
* Add two signed 32-bit values with saturation.
*
* @param a one value
* @param b another value
* @return sum with signed saturation
*)
// static av_always_inline int av_sat_add32_c(int a, int b)
function av_sat_add32_c(a, b: int): int; inline;
(* *
* Add a doubled value to another value with saturation at both stages.
*
* @param a first value
* @param b value doubled and added to a
* @return sum sat(a + sat(2*b)) with signed saturation
*)
// static av_always_inline int av_sat_dadd32_c(int a, int b)
function av_sat_dadd32_c(a, b: int): int; inline;
(* *
* Subtract two signed 32-bit values with saturation.
*
* @param a one value
* @param b another value
* @return difference with signed saturation
*)
// static av_always_inline int av_sat_sub32_c(int a, int b)
function av_sat_sub32_c(a, b: int): int; inline;
(* *
* Subtract a doubled value from another value with saturation at both stages.
*
* @param a first value
* @param b value doubled and subtracted from a
* @return difference sat(a - sat(2*b)) with signed saturation
*)
// static av_always_inline int av_sat_dsub32_c(int a, int b)
function av_sat_dsub32_c(a, b: int): int; inline;
(* *
* Clip a float value into the amin-amax range.
* @param a value to clip
* @param amin minimum value of the clip range
* @param amax maximum value of the clip range
* @return clipped value
*)
// static av_always_inline av_const float av_clipf_c(float a, float amin, float amax)
function av_clipf_c(a, amin, amax: float): float; inline;
(* *
* Clip a double value into the amin-amax range.
* @param a value to clip
* @param amin minimum value of the clip range
* @param amax maximum value of the clip range
* @return clipped value
*)
// static av_always_inline av_const double av_clipd_c(double a, double amin, double amax)
function av_clipd_c(a, amin, amax: double): double; inline;
(* * Compute ceil(log2(x)).
* @param x value used to compute ceil(log2(x))
* @return computed ceiling of log2(x)
*)
// static av_always_inline av_const int av_ceil_log2_c(int x)
function av_ceil_log2_c(x: int): int; inline;
(* *
* Count number of bits set to one in x
* @param x value to count bits of
* @return the number of bits set to one in x
*)
// static av_always_inline av_const int av_popcount_c(uint32_t x)
function av_popcount_c(x: uint32_t): int; inline;
// static av_always_inline av_const int av_parity_c(uint32_t v)
function av_parity_c(v: uint32_t): int; inline;
(* *
* Count number of bits set to one in x
* @param x value to count bits of
* @return the number of bits set to one in x
*)
// static av_always_inline av_const int av_popcount64_c(uint64_t x)
function av_popcount64_c(x: uint64_t): int; inline;
{$ENDREGION}
{$REGION 'bprint.h'}
(* *
* Buffer to print data progressively
*
* The string buffer grows as necessary and is always 0-terminated.
* The content of the string is never accessed, and thus is
* encoding-agnostic and can even hold binary data.
*
* Small buffers are kept in the structure itself, and thus require no
* memory allocation at all (unless the contents of the buffer is needed
* after the structure goes out of scope). This is almost as lightweight as
* declaring a local "char buf[512]".
*
* The length of the string can go beyond the allocated size: the buffer is
* then truncated, but the functions still keep account of the actual total
* length.
*
* In other words, buf->len can be greater than buf->size and records the
* total length of what would have been to the buffer if there had been
* enough memory.
*
* Append operations do not need to be tested for failure: if a memory
* allocation fails, data stop being appended to the buffer, but the length
* is still updated. This situation can be tested with
* av_bprint_is_complete().
*
* The size_max field determines several possible behaviours:
*
* size_max = -1 (= UINT_MAX) or any large value will let the buffer be
* reallocated as necessary, with an amortized linear cost.
*
* size_max = 0 prevents writing anything to the buffer: only the total
* length is computed. The write operations can then possibly be repeated in
* a buffer with exactly the necessary size
* (using size_init = size_max = len + 1).
*
* size_max = 1 is automatically replaced by the exact size available in the
* structure itself, thus ensuring no dynamic memory allocation. The
* internal buffer is large enough to hold a reasonable paragraph of text,
* such as the current paragraph.
*)
type
// FF_PAD_STRUCTURE(AVBPrint, 1024,
// char *str; (**< string so far *)
// unsigned len; (**< length so far *)
// unsigned size; (**< allocated memory *)
// unsigned size_max; (**< maximum allocated memory *)
// char reserved_internal_buffer[1];
// )
FF_PAD_STRUCTURE_AVBPrint = record
str: PAnsiChar; (* *< string so far *)
len: Cardinal; (* *< length so far *)
size: Cardinal; (* *< allocated memory *)
size_max: Cardinal; (* *< maximum allocated memory *)
reserved_internal_buffer: array [0 .. 0] of AnsiChar;
end;
pAVBPrint = ^AVBPrint;
AVBPrint = record
str: PAnsiChar; (* *< string so far *)
len: Cardinal; (* *< length so far *)
size: Cardinal; (* *< allocated memory *)
size_max: Cardinal; (* *< maximum allocated memory *)
reserved_internal_buffer: array [0 .. 0] of AnsiChar;
reserved_padding: array [0 .. 1024 - SizeOf(FF_PAD_STRUCTURE_AVBPrint) - 1] of AnsiChar;
end;
{$ENDREGION}
{$REGION 'channel_layout.h'}
const
(* *
* @defgroup channel_masks Audio channel masks
*
* A channel layout is a 64-bits integer with a bit set for every channel.
* The number of bits set must be equal to the number of channels.
* The value 0 means that the channel layout is not known.
* @note this data structure is not powerful enough to handle channels
* combinations that have the same channel multiple times, such as
* dual-mono.
*
* @{
*)
AV_CH_FRONT_LEFT = $00000001;
AV_CH_FRONT_RIGHT = $00000002;
AV_CH_FRONT_CENTER = $00000004;
AV_CH_LOW_FREQUENCY = $00000008;
AV_CH_BACK_LEFT = $00000010;
AV_CH_BACK_RIGHT = $00000020;
AV_CH_FRONT_LEFT_OF_CENTER = $00000040;
AV_CH_FRONT_RIGHT_OF_CENTER = $00000080;
AV_CH_BACK_CENTER = $00000100;
AV_CH_SIDE_LEFT = $00000200;
AV_CH_SIDE_RIGHT = $00000400;
AV_CH_TOP_CENTER = $00000800;
AV_CH_TOP_FRONT_LEFT = $00001000;
AV_CH_TOP_FRONT_CENTER = $00002000;
AV_CH_TOP_FRONT_RIGHT = $00004000;
AV_CH_TOP_BACK_LEFT = $00008000;
AV_CH_TOP_BACK_CENTER = $00010000;
AV_CH_TOP_BACK_RIGHT = $00020000;
AV_CH_STEREO_LEFT = $20000000;
/// < Stereo downmix.
AV_CH_STEREO_RIGHT = $40000000;
/// < See AV_CH_STEREO_LEFT.
AV_CH_WIDE_LEFT = $0000000080000000;
AV_CH_WIDE_RIGHT = $0000000100000000;
AV_CH_SURROUND_DIRECT_LEFT = $0000000200000000;
AV_CH_SURROUND_DIRECT_RIGHT = $0000000400000000;
AV_CH_LOW_FREQUENCY_2 = $0000000800000000;
(* * Channel mask value used for AVCodecContext.request_channel_layout
to indicate that the user requests the channel order of the decoder output
to be the native codec channel order. *)
AV_CH_LAYOUT_NATIVE = $8000000000000000;
(* *
* @}
* @defgroup channel_mask_c Audio channel layouts
* @{
* *)
AV_CH_LAYOUT_MONO = (AV_CH_FRONT_CENTER);
AV_CH_LAYOUT_STEREO = (AV_CH_FRONT_LEFT or AV_CH_FRONT_RIGHT);
AV_CH_LAYOUT_2POINT1 = (AV_CH_LAYOUT_STEREO or AV_CH_LOW_FREQUENCY);
AV_CH_LAYOUT_2_1 = (AV_CH_LAYOUT_STEREO or AV_CH_BACK_CENTER);
AV_CH_LAYOUT_SURROUND = (AV_CH_LAYOUT_STEREO or AV_CH_FRONT_CENTER);
AV_CH_LAYOUT_3POINT1 = (AV_CH_LAYOUT_SURROUND or AV_CH_LOW_FREQUENCY);
AV_CH_LAYOUT_4POINT0 = (AV_CH_LAYOUT_SURROUND or AV_CH_BACK_CENTER);
AV_CH_LAYOUT_4POINT1 = (AV_CH_LAYOUT_4POINT0 or AV_CH_LOW_FREQUENCY);
AV_CH_LAYOUT_2_2 = (AV_CH_LAYOUT_STEREO or AV_CH_SIDE_LEFT or AV_CH_SIDE_RIGHT);
AV_CH_LAYOUT_QUAD = (AV_CH_LAYOUT_STEREO or AV_CH_BACK_LEFT or AV_CH_BACK_RIGHT);
AV_CH_LAYOUT_5POINT0 = (AV_CH_LAYOUT_SURROUND or AV_CH_SIDE_LEFT or AV_CH_SIDE_RIGHT);
AV_CH_LAYOUT_5POINT1 = (AV_CH_LAYOUT_5POINT0 or AV_CH_LOW_FREQUENCY);
AV_CH_LAYOUT_5POINT0_BACK = (AV_CH_LAYOUT_SURROUND or AV_CH_BACK_LEFT or AV_CH_BACK_RIGHT);
AV_CH_LAYOUT_5POINT1_BACK = (AV_CH_LAYOUT_5POINT0_BACK or AV_CH_LOW_FREQUENCY);
AV_CH_LAYOUT_6POINT0 = (AV_CH_LAYOUT_5POINT0 or AV_CH_BACK_CENTER);
AV_CH_LAYOUT_6POINT0_FRONT = (AV_CH_LAYOUT_2_2 or AV_CH_FRONT_LEFT_OF_CENTER or AV_CH_FRONT_RIGHT_OF_CENTER);
AV_CH_LAYOUT_HEXAGONAL = (AV_CH_LAYOUT_5POINT0_BACK or AV_CH_BACK_CENTER);
AV_CH_LAYOUT_6POINT1 = (AV_CH_LAYOUT_5POINT1 or AV_CH_BACK_CENTER);
AV_CH_LAYOUT_6POINT1_BACK = (AV_CH_LAYOUT_5POINT1_BACK or AV_CH_BACK_CENTER);
AV_CH_LAYOUT_6POINT1_FRONT = (AV_CH_LAYOUT_6POINT0_FRONT or AV_CH_LOW_FREQUENCY);
AV_CH_LAYOUT_7POINT0 = (AV_CH_LAYOUT_5POINT0 or AV_CH_BACK_LEFT or AV_CH_BACK_RIGHT);
AV_CH_LAYOUT_7POINT0_FRONT = (AV_CH_LAYOUT_5POINT0 or AV_CH_FRONT_LEFT_OF_CENTER or AV_CH_FRONT_RIGHT_OF_CENTER);
AV_CH_LAYOUT_7POINT1 = (AV_CH_LAYOUT_5POINT1 or AV_CH_BACK_LEFT or AV_CH_BACK_RIGHT);
AV_CH_LAYOUT_7POINT1_WIDE = (AV_CH_LAYOUT_5POINT1 or AV_CH_FRONT_LEFT_OF_CENTER or AV_CH_FRONT_RIGHT_OF_CENTER);
AV_CH_LAYOUT_7POINT1_WIDE_BACK = (AV_CH_LAYOUT_5POINT1_BACK or AV_CH_FRONT_LEFT_OF_CENTER or AV_CH_FRONT_RIGHT_OF_CENTER);
AV_CH_LAYOUT_OCTAGONAL = (AV_CH_LAYOUT_5POINT0 or AV_CH_BACK_LEFT or AV_CH_BACK_CENTER or AV_CH_BACK_RIGHT);
AV_CH_LAYOUT_HEXADECAGONAL = (AV_CH_LAYOUT_OCTAGONAL or AV_CH_WIDE_LEFT or AV_CH_WIDE_RIGHT or AV_CH_TOP_BACK_LEFT or AV_CH_TOP_BACK_RIGHT or
AV_CH_TOP_BACK_CENTER or AV_CH_TOP_FRONT_CENTER or AV_CH_TOP_FRONT_LEFT or AV_CH_TOP_FRONT_RIGHT);
AV_CH_LAYOUT_STEREO_DOWNMIX = (AV_CH_STEREO_LEFT or AV_CH_STEREO_RIGHT);
type
AVMatrixEncoding = ( //
AV_MATRIX_ENCODING_NONE, AV_MATRIX_ENCODING_DOLBY, AV_MATRIX_ENCODING_DPLII, AV_MATRIX_ENCODING_DPLIIX, AV_MATRIX_ENCODING_DPLIIZ,
AV_MATRIX_ENCODING_DOLBYEX, AV_MATRIX_ENCODING_DOLBYHEADPHONE, AV_MATRIX_ENCODING_NB);
(* *
* Return a channel layout id that matches name, or 0 if no match is found.
*
* name can be one or several of the following notations,
* separated by '+' or '|':
* - the name of an usual channel layout (mono, stereo, 4.0, quad, 5.0,
* 5.0(side), 5.1, 5.1(side), 7.1, 7.1(wide), downmix);
* - the name of a single channel (FL, FR, FC, LFE, BL, BR, FLC, FRC, BC,
* SL, SR, TC, TFL, TFC, TFR, TBL, TBC, TBR, DL, DR);
* - a number of channels, in decimal, followed by 'c', yielding
* the default channel layout for that number of channels (@see
* av_get_default_channel_layout);
* - a channel layout mask, in hexadecimal starting with "0x" (see the
* AV_CH_* macros).
*
* Example: "stereo+FC" = "2c+FC" = "2c+1c" = "0x7"
*)
// uint64_t av_get_channel_layout(const char *name);
function av_get_channel_layout(const name: PAnsiChar): uint64_t; cdecl; external avutil_dll;
(* *
* Return a channel layout and the number of channels based on the specified name.
*
* This function is similar to (@see av_get_channel_layout), but can also parse
* unknown channel layout specifications.
*
* @param[in] name channel layout specification string
* @param[out] channel_layout parsed channel layout (0 if unknown)
* @param[out] nb_channels number of channels
*
* @return 0 on success, AVERROR(EINVAL) if the parsing fails.
*)
// int av_get_extended_channel_layout(const char *name, uint64_t* channel_layout, int* nb_channels);
function av_get_extended_channel_layout(const name: PAnsiChar; var channel_layout: uint64_t; var nb_channels: int): int; cdecl; external avutil_dll;
(* *
* Return a description of a channel layout.
* If nb_channels is <= 0, it is guessed from the channel_layout.
*
* @param buf put here the string containing the channel layout
* @param buf_size size in bytes of the buffer
*)
// void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout);
procedure av_get_channel_layout_string(buf: PAnsiChar; buf_size: int; nb_channels: int; channel_layout: uint64_t); cdecl; external avutil_dll;
(* *
* Append a description of a channel layout to a bprint buffer.
*)
// void av_bprint_channel_layout(struct AVBPrint *bp, int nb_channels, uint64_t channel_layout);
procedure av_bprint_channel_layout(bp: pAVBPrint; nb_channels: int; channel_layout: uint64_t); cdecl; external avutil_dll;
(* *
* Return the number of channels in the channel layout.
*)
// int av_get_channel_layout_nb_channels(uint64_t channel_layout);
function av_get_channel_layout_nb_channels(channel_layout: uint64_t): int; cdecl; external avutil_dll;
(* *
* Return default channel layout for a given number of channels.
*)
// int64_t av_get_default_channel_layout(int nb_channels);
function av_get_default_channel_layout(nb_channels: int): int64_t; cdecl; external avutil_dll;
(* *
* Get the index of a channel in channel_layout.
*
* @param channel a channel layout describing exactly one channel which must be
* present in channel_layout.
*
* @return index of channel in channel_layout on success, a negative AVERROR
* on error.
*)
// int av_get_channel_layout_channel_index(uint64_t channel_layout, uint64_t channel);
function av_get_channel_layout_channel_index(channel_layout: uint64_t; channel: uint64_t): int; cdecl; external avutil_dll;
(* *
* Get the channel with the given index in channel_layout.
*)
// uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index);
function av_channel_layout_extract_channel(channel_layout: uint64_t; index: int): uint64_t; cdecl; external avutil_dll;
(* *
* Get the name of a given channel.
*
* @return channel name on success, NULL on error.
*)
// const char *av_get_channel_name(uint64_t channel);
function av_get_channel_name(channel: uint64_t): PAnsiChar; cdecl; external avutil_dll;
(* *
* Get the description of a given channel.
*
* @param channel a channel layout with a single channel
* @return channel description on success, NULL on error
*)
// const char *av_get_channel_description(uint64_t channel);
function av_get_channel_description(channel: uint64_t): PAnsiChar; cdecl; external avutil_dll;
(* *
* Get the value and name of a standard channel layout.
*
* @param[in] index index in an internal list, starting at 0
* @param[out] layout channel layout mask
* @param[out] name name of the layout
* @return 0 if the layout exists,
* <0 if index is beyond the limits
*)
// int av_get_standard_channel_layout(unsigned index, uint64_t *layout, const char **name);
function av_get_standard_channel_layout(index: unsigned; var layout: uint64_t; const name: ppAnsiChar): int; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'dict.h'}
const
AV_DICT_MATCH_CASE = 1; (* *< Only get an entry with exact-case key match. Only relevant in av_dict_get(). *)
AV_DICT_IGNORE_SUFFIX = 2; (* *< Return first entry in a dictionary whose first part corresponds to the search key,
ignoring the suffix of the found key string. Only relevant in av_dict_get(). *)
AV_DICT_DONT_STRDUP_KEY = 4; (* *< Take ownership of a key that's been
allocated with av_malloc() or another memory allocation function. *)
AV_DICT_DONT_STRDUP_VAL = 8; (* *< Take ownership of a value that's been
allocated with av_malloc() or another memory allocation function. *)
AV_DICT_DONT_OVERWRITE = 16;
// < Don't overwrite existing entries.
AV_DICT_APPEND = 32; (* *< If the entry already exists, append to it. Note that no
delimiter is added, the strings are simply concatenated. *)
AV_DICT_MULTIKEY = 64; (* *< Allow to store several equal keys in the dictionary *)
Type
AVDictionaryEntry = record
key: PAnsiChar;
value: PAnsiChar;
end;
pAVDictionaryEntry = ^AVDictionaryEntry;
AVDictionary = record
end;
pAVDictionary = ^AVDictionary;
ppAVDictionary = ^pAVDictionary;
(* *
* Get a dictionary entry with matching key.
*
* The returned entry key or value must not be changed, or it will
* cause undefined behavior.
*
* To iterate through all the dictionary entries, you can set the matching key
* to the null string "" and set the AV_DICT_IGNORE_SUFFIX flag.
*
* @param prev Set to the previous matching element to find the next.
* If set to NULL the first matching element is returned.
* @param key matching key
* @param flags a collection of AV_DICT_* flags controlling how the entry is retrieved
* @return found entry or NULL in case no matching entry was found in the dictionary
*)
// AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key,
// const AVDictionaryEntry *prev, int flags);
function av_dict_get(const m: pAVDictionary; const key: PAnsiChar; const prev: pAVDictionaryEntry; flags: int): pAVDictionaryEntry; cdecl; external avutil_dll;
(* *
* Get number of entries in dictionary.
*
* @param m dictionary
* @return number of entries in dictionary
*)
// int av_dict_count(const AVDictionary *m);
function av_dict_count(const m: pAVDictionary): int; cdecl; external avutil_dll;
(* *
* Set the given entry in *pm, overwriting an existing entry.
*
* Note: If AV_DICT_DONT_STRDUP_KEY or AV_DICT_DONT_STRDUP_VAL is set,
* these arguments will be freed on error.
*
* Warning: Adding a new entry to a dictionary invalidates all existing entries
* previously returned with av_dict_get.
*
* @param pm pointer to a pointer to a dictionary struct. If *pm is NULL
* a dictionary struct is allocated and put in *pm.
* @param key entry key to add to *pm (will either be av_strduped or added as a new key depending on flags)
* @param value entry value to add to *pm (will be av_strduped or added as a new key depending on flags).
* Passing a NULL value will cause an existing entry to be deleted.
* @return >= 0 on success otherwise an error code <0
*)
// int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags);
function av_dict_set(Var pm: pAVDictionary; const key: PAnsiChar; const value: PAnsiChar; flags: int): int; cdecl; external avutil_dll;
(* *
* Convenience wrapper for av_dict_set that converts the value to a string
* and stores it.
*
* Note: If AV_DICT_DONT_STRDUP_KEY is set, key will be freed on error.
*)
// int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags);
function av_dict_set_int(var pm: pAVDictionary; const key: PAnsiChar; value: int64_t; flags: int): int; cdecl; external avutil_dll;
(* *
* Parse the key/value pairs list and add the parsed entries to a dictionary.
*
* In case of failure, all the successfully set entries are stored in
* *pm. You may need to manually free the created dictionary.
*
* @param key_val_sep a 0-terminated list of characters used to separate
* key from value
* @param pairs_sep a 0-terminated list of characters used to separate
* two pairs from each other
* @param flags flags to use when adding to dictionary.
* AV_DICT_DONT_STRDUP_KEY and AV_DICT_DONT_STRDUP_VAL
* are ignored since the key/value tokens will always
* be duplicated.
* @return 0 on success, negative AVERROR code on failure
*)
// int av_dict_parse_string(AVDictionary **pm, const char *str,
// const char *key_val_sep, const char *pairs_sep,
// int flags);
function av_dict_parse_string(Var pm: pAVDictionary; const str: PAnsiChar; const key_val_sep: PAnsiChar; const pairs_sep: PAnsiChar; flags: int): int; cdecl;
external avutil_dll;
(* *
* Copy entries from one AVDictionary struct into another.
* @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL,
* this function will allocate a struct for you and put it in *dst
* @param src pointer to source AVDictionary struct
* @param flags flags to use when setting entries in *dst
* @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag
* @return 0 on success, negative AVERROR code on failure. If dst was allocated
* by this function, callers should free the associated memory.
*)
// int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags);
function av_dict_copy(var dst: pAVDictionary; const src: pAVDictionary; flags: int): int; cdecl; external avutil_dll;
(* *
* Free all the memory allocated for an AVDictionary struct
* and all keys and values.
*)
// void av_dict_free(AVDictionary **m);
procedure av_dict_free(Var m: pAVDictionary); cdecl; external avutil_dll;
(* *
* Get dictionary entries as a string.
*
* Create a string containing dictionary's entries.
* Such string may be passed back to av_dict_parse_string().
* @note String is escaped with backslashes ('\').
*
* @param[in] m dictionary
* @param[out] buffer Pointer to buffer that will be allocated with string containg entries.
* Buffer must be freed by the caller when is no longer needed.
* @param[in] key_val_sep character used to separate key from value
* @param[in] pairs_sep character used to separate two pairs from each other
* @return >= 0 on success, negative on error
* @warning Separators cannot be neither '\\' nor '\0'. They also cannot be the same.
*)
// int av_dict_get_string(const AVDictionary *m, char **buffer,
// const char key_val_sep, const char pairs_sep);
function av_dict_get_string(const m: pAVDictionary; Var buffer: PAnsiChar; const key_val_sep: AnsiChar; const pairs_sep: AnsiChar): int; cdecl;
external avutil_dll;
{$ENDREGION}
{$REGION 'buffer.h'}
type
(* *
* A reference counted buffer type. It is opaque and is meant to be used through
* references (AVBufferRef).
*)
AVBuffer = record
end;
pAVBuffer = ^AVBuffer;
(* *
* A reference to a data buffer.
*
* The size of this struct is not a part of the public ABI and it is not meant
* to be allocated directly.
*)
AVBufferRef = record
buffer: pAVBuffer;
(* *
* The data buffer. It is considered writable if and only if
* this is the only reference to the buffer, in which case
* av_buffer_is_writable() returns 1.
*)
data: puint8_t;
(* *
* Size of data in bytes.
*)
size: int;
end;
pAVBufferRef = ^AVBufferRef;
ppAVBufferRef = ^pAVBufferRef;
(* *
* Allocate an AVBuffer of the given size using av_malloc().
*
* @return an AVBufferRef of given size or NULL when out of memory
*)
// AVBufferRef *av_buffer_alloc(int size);
function av_buffer_alloc(size: int): pAVBufferRef; cdecl; external avutil_dll;
(* *
* Same as av_buffer_alloc(), except the returned buffer will be initialized
* to zero.
*)
// AVBufferRef *av_buffer_allocz(int size);
function av_buffer_allocz(size: int): pAVBufferRef; cdecl; external avutil_dll;
const
(* *
* Always treat the buffer as read-only, even when it has only one
* reference.
*)
AV_BUFFER_FLAG_READONLY = (1 shl 0);
(* *
* Create an AVBuffer from an existing array.
*
* If this function is successful, data is owned by the AVBuffer. The caller may
* only access data through the returned AVBufferRef and references derived from
* it.
* If this function fails, data is left untouched.
* @param data data array
* @param size size of data in bytes
* @param free a callback for freeing this buffer's data
* @param opaque parameter to be got for processing or passed to free
* @param flags a combination of AV_BUFFER_FLAG_*
*
* @return an AVBufferRef referring to data on success, NULL on failure.
*)
// AVBufferRef *av_buffer_create(uint8_t *data, int size,
// void (*free)(void *opaque, uint8_t *data),
// void *opaque, int flags);
type
TFreeProc = procedure(opaque: Pointer; data: puint8_t); cdecl;
function av_buffer_create(data: puint8_t; size: int; freeproc: TFreeProc; opaque: Pointer; flags: int): AVBufferRef; cdecl; external avutil_dll;
(* *
* Default free callback, which calls av_free() on the buffer data.
* This function is meant to be passed to av_buffer_create(), not called
* directly.
*)
// void av_buffer_default_free(void *opaque, uint8_t *data);
procedure av_buffer_default_free(opaque: Pointer; data: puint8_t); cdecl; external avutil_dll;
(* *
* Create a new reference to an AVBuffer.
*
* @return a new AVBufferRef referring to the same AVBuffer as buf or NULL on
* failure.
*)
// AVBufferRef *av_buffer_ref(AVBufferRef *buf);
function av_buffer_ref(buf: pAVBufferRef): pAVBufferRef; cdecl; external avutil_dll;
(* *
* Free a given reference and automatically free the buffer if there are no more
* references to it.
*
* @param buf the reference to be freed. The pointer is set to NULL on return.
*)
// void av_buffer_unref(AVBufferRef **buf);
procedure av_buffer_unref(var buf: pAVBufferRef); cdecl; external avutil_dll;
(* *
* @return 1 if the caller may write to the data referred to by buf (which is
* true if and only if buf is the only reference to the underlying AVBuffer).
* Return 0 otherwise.
* A positive answer is valid until av_buffer_ref() is called on buf.
*)
// int av_buffer_is_writable(const AVBufferRef *buf);
function av_buffer_is_writable(const buf: pAVBufferRef): int; cdecl; external avutil_dll;
(* *
* @return the opaque parameter set by av_buffer_create.
*)
// void *av_buffer_get_opaque(const AVBufferRef *buf);
function av_buffer_get_opaque(const buf: pAVBufferRef): Pointer; cdecl; external avutil_dll;
// int av_buffer_get_ref_count(const AVBufferRef *buf);
function av_buffer_get_ref_count(const buf: pAVBufferRef): int; cdecl; external avutil_dll;
(* *
* Create a writable reference from a given buffer reference, avoiding data copy
* if possible.
*
* @param buf buffer reference to make writable. On success, buf is either left
* untouched, or it is unreferenced and a new writable AVBufferRef is
* written in its place. On failure, buf is left untouched.
* @return 0 on success, a negative AVERROR on failure.
*)
// int av_buffer_make_writable(AVBufferRef **buf);
function av_buffer_make_writable(var buf: pAVBufferRef): int; cdecl; external avutil_dll;
(* *
* Reallocate a given buffer.
*
* @param buf a buffer reference to reallocate. On success, buf will be
* unreferenced and a new reference with the required size will be
* written in its place. On failure buf will be left untouched. *buf
* may be NULL, then a new buffer is allocated.
* @param size required new buffer size.
* @return 0 on success, a negative AVERROR on failure.
*
* @note the buffer is actually reallocated with av_realloc() only if it was
* initially allocated through av_buffer_realloc(NULL) and there is only one
* reference to it (i.e. the one passed to this function). In all other cases
* a new buffer is allocated and the data is copied.
*)
// int av_buffer_realloc(AVBufferRef **buf, int size);
function av_buffer_realloc(var buf: pAVBufferRef; size: int): int; cdecl; external avutil_dll;
(* *
* @defgroup lavu_bufferpool AVBufferPool
* @ingroup lavu_data
*
* @{
* AVBufferPool is an API for a lock-free thread-safe pool of AVBuffers.
*
* Frequently allocating and freeing large buffers may be slow. AVBufferPool is
* meant to solve this in cases when the caller needs a set of buffers of the
* same size (the most obvious use case being buffers for raw video or audio
* frames).
*
* At the beginning, the user must call av_buffer_pool_init() to create the
* buffer pool. Then whenever a buffer is needed, call av_buffer_pool_get() to
* get a reference to a new buffer, similar to av_buffer_alloc(). This new
* reference works in all aspects the same way as the one created by
* av_buffer_alloc(). However, when the last reference to this buffer is
* unreferenced, it is returned to the pool instead of being freed and will be
* reused for subsequent av_buffer_pool_get() calls.
*
* When the caller is done with the pool and no longer needs to allocate any new
* buffers, av_buffer_pool_uninit() must be called to mark the pool as freeable.
* Once all the buffers are released, it will automatically be freed.
*
* Allocating and releasing buffers with this API is thread-safe as long as
* either the default alloc callback is used, or the user-supplied one is
* thread-safe.
*)
type
(* *
* The buffer pool. This structure is opaque and not meant to be accessed
* directly. It is allocated with av_buffer_pool_init() and freed with
* av_buffer_pool_uninit().
*)
AVBufferPool = record
end;
pAVBufferPool = ^AVBufferPool;
(* *
* Allocate and initialize a buffer pool.
*
* @param size size of each buffer in this pool
* @param alloc a function that will be used to allocate new buffers when the
* pool is empty. May be NULL, then the default allocator will be used
* (av_buffer_alloc()).
* @return newly created buffer pool on success, NULL on error.
*)
// AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size));
type
Tbuffer_pool_init_proc = function(size: int): pAVBufferRef; cdecl;
function av_buffer_pool_init(size: int; alloc: Tbuffer_pool_init_proc): pAVBufferPool; cdecl; external avutil_dll;
(* *
* Allocate and initialize a buffer pool with a more complex allocator.
*
* @param size size of each buffer in this pool
* @param opaque arbitrary user data used by the allocator
* @param alloc a function that will be used to allocate new buffers when the
* pool is empty.
* @param pool_free a function that will be called immediately before the pool
* is freed. I.e. after av_buffer_pool_uninit() is called
* by the caller and all the frames are returned to the pool
* and freed. It is intended to uninitialize the user opaque
* data.
* @return newly created buffer pool on success, NULL on error.
*)
type
Tav_buffer_pool_init2_alloc_proc = function(opaque: Pointer; size: int): pAVBufferRef; cdecl;
Tav_buffer_pool_init2_pool_free_proc = procedure(opaque: Pointer); cdecl;
// AVBufferPool *av_buffer_pool_init2(int size, void *opaque,
// AVBufferRef* (*alloc)(void *opaque, int size),
// void (*pool_free)(void *opaque));
function av_buffer_pool_init2(size: int; opaque: Pointer; alloc: Tav_buffer_pool_init2_alloc_proc; pool_free: Tav_buffer_pool_init2_pool_free_proc)
: pAVBufferPool; cdecl; external avutil_dll;
(* *
* Mark the pool as being available for freeing. It will actually be freed only
* once all the allocated buffers associated with the pool are released. Thus it
* is safe to call this function while some of the allocated buffers are still
* in use.
*
* @param pool pointer to the pool to be freed. It will be set to NULL.
*)
// void av_buffer_pool_uninit(AVBufferPool **pool);
procedure av_buffer_pool_uninit(var pool: pAVBufferPool); cdecl; external avutil_dll;
(* *
* Allocate a new AVBuffer, reusing an old buffer from the pool when available.
* This function may be called simultaneously from multiple threads.
*
* @return a reference to the new buffer on success, NULL on error.
*)
// AVBufferRef *av_buffer_pool_get(AVBufferPool *pool);
function av_buffer_pool_get(pool: pAVBufferPool): pAVBufferRef; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'rational.h'}
Type
(* *
* Rational number (pair of numerator and denominator).
*)
AVRational = record
num: int; // < Numerator
den: int; // < Denominator
end;
pAVRational = ^AVRational;
(* *
* Create an AVRational.
*
* Useful for compilers that do not support compound literals.
*
* @note The return value is not reduced.
* @see av_reduce()
*)
// static inline AVRational av_make_q(int num, int den)
function av_make_q(_num: int; _den: int): AVRational; inline;
(* *
* Compare two rationals.
*
* @param a First rational
* @param b Second rational
*
* @return One of the following values:
* - 0 if `a == b`
* - 1 if `a > b`
* - -1 if `a < b`
* - `INT_MIN` if one of the values is of the form `0 / 0`
*)
// static inline int av_cmp_q(AVRational a, AVRational b)
function av_cmp_q(a, b: AVRational): int; inline;
(* *
* Convert an AVRational to a `double`.
* @param a AVRational to convert
* @return `a` in floating-point form
* @see av_d2q()
*)
// static inline double av_q2d(AVRational a)
function av_q2d(a: AVRational): double; inline;
(* *
* Reduce a fraction.
*
* This is useful for framerate calculations.
*
* @param[out] dst_num Destination numerator
* @param[out] dst_den Destination denominator
* @param[in] num Source numerator
* @param[in] den Source denominator
* @param[in] max Maximum allowed values for `dst_num` & `dst_den`
* @return 1 if the operation is exact, 0 otherwise
*)
// int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max);
function av_reduce(Var dst_num: int; var dst_den: int; num: int64_t; den: int64_t; max: int64_t): int; cdecl; external avutil_dll;
(* *
* Multiply two rationals.
* @param b First rational
* @param c Second rational
* @return b*c
*)
// AVRational av_mul_q(AVRational b, AVRational c) av_const;
function av_mul_q(b, c: AVRational): AVRational; cdecl; external avutil_dll;
(* *
* Divide one rational by another.
* @param b First rational
* @param c Second rational
* @return b/c
*)
// AVRational av_div_q(AVRational b, AVRational c) av_const;
function av_div_q(b, c: AVRational): AVRational; cdecl; external avutil_dll;
(* *
* Add two rationals.
* @param b First rational
* @param c Second rational
* @return b+c
*)
// AVRational av_add_q(AVRational b, AVRational c) av_const;
function av_add_q(b, c: AVRational): AVRational; cdecl; external avutil_dll;
(* *
* Subtract one rational from another.
* @param b First rational
* @param c Second rational
* @return b-c
*)
// AVRational av_sub_q(AVRational b, AVRational c) av_const;
function av_sub_q(b, c: AVRational): AVRational; cdecl; external avutil_dll;
(* *
* Invert a rational.
* @param q value
* @return 1 / q
*)
// static av_always_inline AVRational av_inv_q(AVRational q)
function av_inv_q(q: AVRational): AVRational; inline;
(* *
* Convert a double precision floating point number to a rational.
*
* In case of infinity, the returned value is expressed as `{1, 0}` or
* `{-1, 0}` depending on the sign.
*
* @param d `double` to convert
* @param max Maximum allowed numerator and denominator
* @return `d` in AVRational form
* @see av_q2d()
*)
// AVRational av_d2q(double d, int max) av_const;
function av_d2q(d: double; max: int): AVRational; cdecl; external avutil_dll;
(* *
* Find which of the two rationals is closer to another rational.
*
* @param q Rational to be compared against
* @param q1,q2 Rationals to be tested
* @return One of the following values:
* - 1 if `q1` is nearer to `q` than `q2`
* - -1 if `q2` is nearer to `q` than `q1`
* - 0 if they have the same distance
*)
// int av_nearer_q(AVRational q, AVRational q1, AVRational q2);
function av_nearer_q(q: AVRational; q1: AVRational; q2: AVRational): int; cdecl; external avutil_dll;
(* *
* Find the value in a list of rationals nearest a given reference rational.
*
* @param q Reference rational
* @param q_list Array of rationals terminated by `{0, 0}`
* @return Index of the nearest value found in the array
*)
// int av_find_nearest_q_idx(AVRational q, const AVRational* q_list);
function av_find_nearest_q_idx(q: AVRational; const q_list: pAVRational): int; cdecl; external avutil_dll;
(* *
* Convert an AVRational to a IEEE 32-bit `float` expressed in fixed-point
* format.
*
* @param q Rational to be converted
* @return Equivalent floating-point value, expressed as an unsigned 32-bit
* integer.
* @note The returned value is platform-indepedant.
*)
// uint32_t av_q2intfloat(AVRational q);
function av_q2intfloat(q: AVRational): uint32_t; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'avutil'}
(* *
* @}
*)
(* *
* @addtogroup lavu_media Media Type
* @brief Media Type
*)
type
AVMediaType = ( //
AVMEDIA_TYPE_UNKNOWN = -1,
// < Usually treated as AVMEDIA_TYPE_DATA
AVMEDIA_TYPE_VIDEO = 0, //
AVMEDIA_TYPE_AUDIO = 1, //
AVMEDIA_TYPE_DATA = 2,
// < Opaque data information usually continuous
AVMEDIA_TYPE_SUBTITLE = 3, //
AVMEDIA_TYPE_ATTACHMENT = 4,
// < Opaque data information usually sparse
AVMEDIA_TYPE_NB = 5);
(* *
* @defgroup lavu_const Constants
* @{
*
* @defgroup lavu_enc Encoding specific
*
* @note those definition should move to avcodec
* @{
*)
const
FF_LAMBDA_SHIFT = 7;
FF_LAMBDA_SCALE = (1 shl FF_LAMBDA_SHIFT);
FF_QP2LAMBDA = 118;
// < factor to convert from H.263 QP to lambda
FF_LAMBDA_MAX = (256 * 128 - 1);
FF_QUALITY_SCALE = FF_LAMBDA_SCALE; // FIXME maybe remove
(* *
* @}
* @defgroup lavu_time Timestamp specific
*
* FFmpeg internal timebase and timestamp definitions
*
* @{
*)
(* *
* @brief Undefined timestamp value
*
* Usually reported by demuxer that work on containers that do not provide
* either pts or dts.
*)
AV_NOPTS_VALUE = int64_t($8000000000000000);
(* *
* Internal time base represented as integer
*)
AV_TIME_BASE = 1000000;
(* *
* Internal time base represented as fractional value
*)
AV_TIME_BASE_Q: AVRational = (num: 1; den: AV_TIME_BASE);
(* *
* @}
* @}
* @defgroup lavu_picture Image related
*
* AVPicture types, pixel formats and basic image planes manipulation.
*
* @{
*)
type
AVPictureType = ( //
AV_PICTURE_TYPE_NONE = 0,
// < Undefined
AV_PICTURE_TYPE_I = 1,
// < Intra
AV_PICTURE_TYPE_P = 2,
// < Predicted
AV_PICTURE_TYPE_B = 3,
// < Bi-dir predicted
AV_PICTURE_TYPE_S = 4,
// < S(GMC)-VOP MPEG-4
AV_PICTURE_TYPE_SI = 5,
// < Switching Intra
AV_PICTURE_TYPE_SP = 6,
// < Switching Predicted
AV_PICTURE_TYPE_BI = 7);
// < BI type
{$ENDREGION}
{$REGION 'pixfmt.h'}
type
(* *
* Pixel format.
*
* @note
* AV_PIX_FMT_RGB32 is handled in an endian-specific manner. An RGBA
* color is put together as:
* (A shl 24) | (R shl 16) | (G shl 8) | B
* This is stored as BGRA on little-endian CPU architectures and ARGB on
* big-endian CPUs.
*
* @par
* When the pixel format is palettized RGB32 (AV_PIX_FMT_PAL8), the palettized
* image data is stored in AVFrame.data[0]. The palette is transported in
* AVFrame.data[1], is 1024 bytes long (256 4-byte entries) and is
* formatted the same as in AV_PIX_FMT_RGB32 described above (i.e., it is
* also endian-specific). Note also that the individual RGB32 palette
* components stored in AVFrame.data[1] should be in the range 0..255.
* This is important as many custom PAL8 video codecs that were designed
* to run on the IBM VGA graphics adapter use 6-bit palette components.
*
* @par
* For all the 8 bits per pixel formats, an RGB32 palette is in data[1] like
* for pal8. This palette is filled in automatically by the function
* allocating the picture.
*)
pAVPixelFormat = ^AVPixelFormat;
AVPixelFormat = ( //
AV_PIX_FMT_NONE = -1, //
AV_PIX_FMT_YUV420P,
// < planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
AV_PIX_FMT_YUYV422,
// < packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr
AV_PIX_FMT_RGB24,
// < packed RGB 8:8:8, 24bpp, RGBRGB...
AV_PIX_FMT_BGR24,
// < packed RGB 8:8:8, 24bpp, BGRBGR...
AV_PIX_FMT_YUV422P,
// < planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
AV_PIX_FMT_YUV444P,
// < planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
AV_PIX_FMT_YUV410P,
// < planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
AV_PIX_FMT_YUV411P,
// < planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
AV_PIX_FMT_GRAY8,
// < Y , 8bpp
AV_PIX_FMT_MONOWHITE,
// < Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb
AV_PIX_FMT_MONOBLACK,
// < Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb
AV_PIX_FMT_PAL8,
// < 8 bits with AV_PIX_FMT_RGB32 palette
AV_PIX_FMT_YUVJ420P,
// < planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting color_range
AV_PIX_FMT_YUVJ422P,
// < planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting color_range
AV_PIX_FMT_YUVJ444P,
// < planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting color_range
{$IFDEF FF_API_XVMC}
AV_PIX_FMT_XVMC_MPEG2_MC,
// < XVideo Motion Acceleration via common packet passing
AV_PIX_FMT_XVMC_MPEG2_IDCT, AV_PIX_FMT_XVMC = AV_PIX_FMT_XVMC_MPEG2_IDCT,
{$ENDIF} (* FF_API_XVMC *)
AV_PIX_FMT_UYVY422,
// < packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1
AV_PIX_FMT_UYYVYY411,
// < packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3
AV_PIX_FMT_BGR8,
// < packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb)
AV_PIX_FMT_BGR4,
// < packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits
AV_PIX_FMT_BGR4_BYTE,
// < packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb)
AV_PIX_FMT_RGB8,
// < packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb)
AV_PIX_FMT_RGB4,
// < packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits
AV_PIX_FMT_RGB4_BYTE,
// < packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb)
AV_PIX_FMT_NV12,
// < planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V)
AV_PIX_FMT_NV21,
// < as above, but U and V bytes are swapped
AV_PIX_FMT_ARGB,
// < packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
AV_PIX_FMT_RGBA,
// < packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
AV_PIX_FMT_ABGR,
// < packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
AV_PIX_FMT_BGRA,
// < packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
AV_PIX_FMT_GRAY16BE,
// < Y , 16bpp, big-endian
AV_PIX_FMT_GRAY16LE,
// < Y , 16bpp, little-endian
AV_PIX_FMT_YUV440P,
// < planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
AV_PIX_FMT_YUVJ440P,
// < planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
AV_PIX_FMT_YUVA420P,
// < planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
{$IFDEF FF_API_VDPAU}
AV_PIX_FMT_VDPAU_H264,
// < H.264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
AV_PIX_FMT_VDPAU_MPEG1,
// < MPEG-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
AV_PIX_FMT_VDPAU_MPEG2,
// < MPEG-2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
AV_PIX_FMT_VDPAU_WMV3,
// < WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
AV_PIX_FMT_VDPAU_VC1,
// < VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
{$ENDIF}
AV_PIX_FMT_RGB48BE,
// < packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian
AV_PIX_FMT_RGB48LE,
// < packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian
AV_PIX_FMT_RGB565BE,
// < packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian
AV_PIX_FMT_RGB565LE,
// < packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian
AV_PIX_FMT_RGB555BE,
// < packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), big-endian , X=unused/undefined
AV_PIX_FMT_RGB555LE,
// < packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined
AV_PIX_FMT_BGR565BE,
// < packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian
AV_PIX_FMT_BGR565LE,
// < packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian
AV_PIX_FMT_BGR555BE,
// < packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), big-endian , X=unused/undefined
AV_PIX_FMT_BGR555LE,
// < packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), little-endian, X=unused/undefined
{$IFDEF FF_API_VAAPI}
(* * @name Deprecated pixel formats *)
(* *@{ *)
AV_PIX_FMT_VAAPI_MOCO,
// < HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers
AV_PIX_FMT_VAAPI_IDCT,
// < HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers
AV_PIX_FMT_VAAPI_VLD,
// < HW decoding through VA API, Picture.data[3] contains a VASurfaceID
(* *@} *)
AV_PIX_FMT_VAAPI = AV_PIX_FMT_VAAPI_VLD,
{$ELSE}
(* *
* Hardware acceleration through VA-API, data[3] contains a
* VASurfaceID.
*)
AV_PIX_FMT_VAAPI,
{$ENDIF}
AV_PIX_FMT_YUV420P16LE,
// < planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
AV_PIX_FMT_YUV420P16BE,
// < planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
AV_PIX_FMT_YUV422P16LE,
// < planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
AV_PIX_FMT_YUV422P16BE,
// < planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
AV_PIX_FMT_YUV444P16LE,
// < planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
AV_PIX_FMT_YUV444P16BE,
// < planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
{$IFDEF FF_API_VDPAU}
AV_PIX_FMT_VDPAU_MPEG4,
// < MPEG-4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
{$ENDIF}
AV_PIX_FMT_DXVA2_VLD,
// < HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer
AV_PIX_FMT_RGB444LE,
// < packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), little-endian, X=unused/undefined
AV_PIX_FMT_RGB444BE,
// < packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), big-endian, X=unused/undefined
AV_PIX_FMT_BGR444LE,
// < packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), little-endian, X=unused/undefined
AV_PIX_FMT_BGR444BE,
// < packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), big-endian, X=unused/undefined
AV_PIX_FMT_YA8,
// < 8 bits gray, 8 bits alpha
AV_PIX_FMT_Y400A = AV_PIX_FMT_YA8,
// < alias for AV_PIX_FMT_YA8
AV_PIX_FMT_GRAY8A = AV_PIX_FMT_YA8,
// < alias for AV_PIX_FMT_YA8
AV_PIX_FMT_BGR48BE,
// < packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big-endian
AV_PIX_FMT_BGR48LE,
// < packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as little-endian
(* *
* The following 12 formats have the disadvantage of needing 1 format for each bit depth.
* Notice that each 9/10 bits sample is stored in 16 bits with extra padding.
* If you want to support multiple bit depths, then using AV_PIX_FMT_YUV420P16* with the bpp stored separately is better.
*)
AV_PIX_FMT_YUV420P9BE,
// < planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
AV_PIX_FMT_YUV420P9LE,
// < planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
AV_PIX_FMT_YUV420P10BE,
// < planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
AV_PIX_FMT_YUV420P10LE,
// < planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
AV_PIX_FMT_YUV422P10BE,
// < planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
AV_PIX_FMT_YUV422P10LE,
// < planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
AV_PIX_FMT_YUV444P9BE,
// < planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
AV_PIX_FMT_YUV444P9LE,
// < planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
AV_PIX_FMT_YUV444P10BE,
// < planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
AV_PIX_FMT_YUV444P10LE,
// < planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
AV_PIX_FMT_YUV422P9BE,
// < planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
AV_PIX_FMT_YUV422P9LE,
// < planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
AV_PIX_FMT_VDA_VLD,
// < hardware decoding through VDA
AV_PIX_FMT_GBRP,
// < planar GBR 4:4:4 24bpp
AV_PIX_FMT_GBR24P = AV_PIX_FMT_GBRP, // alias for #AV_PIX_FMT_GBRP
AV_PIX_FMT_GBRP9BE,
// < planar GBR 4:4:4 27bpp, big-endian
AV_PIX_FMT_GBRP9LE,
// < planar GBR 4:4:4 27bpp, little-endian
AV_PIX_FMT_GBRP10BE,
// < planar GBR 4:4:4 30bpp, big-endian
AV_PIX_FMT_GBRP10LE,
// < planar GBR 4:4:4 30bpp, little-endian
AV_PIX_FMT_GBRP16BE,
// < planar GBR 4:4:4 48bpp, big-endian
AV_PIX_FMT_GBRP16LE,
// < planar GBR 4:4:4 48bpp, little-endian
AV_PIX_FMT_YUVA422P,
// < planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
AV_PIX_FMT_YUVA444P,
// < planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
AV_PIX_FMT_YUVA420P9BE,
// < planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian
AV_PIX_FMT_YUVA420P9LE,
// < planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian
AV_PIX_FMT_YUVA422P9BE,
// < planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian
AV_PIX_FMT_YUVA422P9LE,
// < planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian
AV_PIX_FMT_YUVA444P9BE,
// < planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
AV_PIX_FMT_YUVA444P9LE,
// < planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
AV_PIX_FMT_YUVA420P10BE,
// < planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
AV_PIX_FMT_YUVA420P10LE,
// < planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
AV_PIX_FMT_YUVA422P10BE,
// < planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
AV_PIX_FMT_YUVA422P10LE,
// < planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
AV_PIX_FMT_YUVA444P10BE,
// < planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
AV_PIX_FMT_YUVA444P10LE,
// < planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
AV_PIX_FMT_YUVA420P16BE,
// < planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian)
AV_PIX_FMT_YUVA420P16LE,
// < planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian)
AV_PIX_FMT_YUVA422P16BE,
// < planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian)
AV_PIX_FMT_YUVA422P16LE,
// < planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian)
AV_PIX_FMT_YUVA444P16BE,
// < planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian)
AV_PIX_FMT_YUVA444P16LE,
// < planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian)
AV_PIX_FMT_VDPAU,
// < HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface
AV_PIX_FMT_XYZ12LE,
// < packed XYZ 4:4:4, 36 bpp, (msb) 12X, 12Y, 12Z (lsb), the 2-byte value for each X/Y/Z is stored as little-endian, the 4 lower bits are set to 0
AV_PIX_FMT_XYZ12BE,
// < packed XYZ 4:4:4, 36 bpp, (msb) 12X, 12Y, 12Z (lsb), the 2-byte value for each X/Y/Z is stored as big-endian, the 4 lower bits are set to 0
AV_PIX_FMT_NV16,
// < interleaved chroma YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
AV_PIX_FMT_NV20LE,
// < interleaved chroma YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
AV_PIX_FMT_NV20BE,
// < interleaved chroma YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
AV_PIX_FMT_RGBA64BE,
// < packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
AV_PIX_FMT_RGBA64LE,
// < packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
AV_PIX_FMT_BGRA64BE,
// < packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian
AV_PIX_FMT_BGRA64LE,
// < packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian
AV_PIX_FMT_YVYU422,
// < packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb
AV_PIX_FMT_VDA,
// < HW acceleration through VDA, data[3] contains a CVPixelBufferRef
AV_PIX_FMT_YA16BE,
// < 16 bits gray, 16 bits alpha (big-endian)
AV_PIX_FMT_YA16LE,
// < 16 bits gray, 16 bits alpha (little-endian)
AV_PIX_FMT_GBRAP,
// < planar GBRA 4:4:4:4 32bpp
AV_PIX_FMT_GBRAP16BE,
// < planar GBRA 4:4:4:4 64bpp, big-endian
AV_PIX_FMT_GBRAP16LE,
// < planar GBRA 4:4:4:4 64bpp, little-endian
(* *
* HW acceleration through QSV, data[3] contains a pointer to the
* mfxFrameSurface1 structure.
*)
AV_PIX_FMT_QSV,
(* *
* HW acceleration though MMAL, data[3] contains a pointer to the
* MMAL_BUFFER_HEADER_T structure.
*)
AV_PIX_FMT_MMAL,
AV_PIX_FMT_D3D11VA_VLD,
// < HW decoding through Direct3D11, Picture.data[3] contains a ID3D11VideoDecoderOutputView pointer
(* *
* HW acceleration through CUDA. data[i] contain CUdeviceptr pointers
* exactly as for system memory frames.
*)
AV_PIX_FMT_CUDA, AV_PIX_FMT_0RGB = $123 + 4,
// < packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
AV_PIX_FMT_RGB0,
// < packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
AV_PIX_FMT_0BGR,
// < packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
AV_PIX_FMT_BGR0,
// < packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
AV_PIX_FMT_YUV420P12BE,
// < planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
AV_PIX_FMT_YUV420P12LE,
// < planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
AV_PIX_FMT_YUV420P14BE,
// < planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian
AV_PIX_FMT_YUV420P14LE,
// < planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian
AV_PIX_FMT_YUV422P12BE,
// < planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
AV_PIX_FMT_YUV422P12LE,
// < planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
AV_PIX_FMT_YUV422P14BE,
// < planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian
AV_PIX_FMT_YUV422P14LE,
// < planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian
AV_PIX_FMT_YUV444P12BE,
// < planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
AV_PIX_FMT_YUV444P12LE,
// < planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
AV_PIX_FMT_YUV444P14BE,
// < planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian
AV_PIX_FMT_YUV444P14LE,
// < planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian
AV_PIX_FMT_GBRP12BE,
// < planar GBR 4:4:4 36bpp, big-endian
AV_PIX_FMT_GBRP12LE,
// < planar GBR 4:4:4 36bpp, little-endian
AV_PIX_FMT_GBRP14BE,
// < planar GBR 4:4:4 42bpp, big-endian
AV_PIX_FMT_GBRP14LE,
// < planar GBR 4:4:4 42bpp, little-endian
AV_PIX_FMT_YUVJ411P,
// < planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV411P and setting color_range
AV_PIX_FMT_BAYER_BGGR8,
// < bayer, BGBG..(odd line), GRGR..(even line), 8-bit samples *)
AV_PIX_FMT_BAYER_RGGB8,
// < bayer, RGRG..(odd line), GBGB..(even line), 8-bit samples *)
AV_PIX_FMT_BAYER_GBRG8,
// < bayer, GBGB..(odd line), RGRG..(even line), 8-bit samples *)
AV_PIX_FMT_BAYER_GRBG8,
// < bayer, GRGR..(odd line), BGBG..(even line), 8-bit samples *)
AV_PIX_FMT_BAYER_BGGR16LE,
// < bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, little-endian *)
AV_PIX_FMT_BAYER_BGGR16BE,
// < bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, big-endian *)
AV_PIX_FMT_BAYER_RGGB16LE,
// < bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, little-endian *)
AV_PIX_FMT_BAYER_RGGB16BE,
// < bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, big-endian *)
AV_PIX_FMT_BAYER_GBRG16LE,
// < bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, little-endian *)
AV_PIX_FMT_BAYER_GBRG16BE,
// < bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, big-endian *)
AV_PIX_FMT_BAYER_GRBG16LE,
// < bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, little-endian *)
AV_PIX_FMT_BAYER_GRBG16BE,
// < bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, big-endian *)
{$IFNDEF FF_API_XVMC}
AV_PIX_FMT_XVMC,
// < XVideo Motion Acceleration via common packet passing
{$ENDIF} (* !FF_API_XVMC *)
AV_PIX_FMT_YUV440P10LE,
// < planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
AV_PIX_FMT_YUV440P10BE,
// < planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
AV_PIX_FMT_YUV440P12LE,
// < planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian
AV_PIX_FMT_YUV440P12BE,
// < planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian
AV_PIX_FMT_AYUV64LE,
// < packed AYUV 4:4:4,64bpp (1 Cr & Cb sample per 1x1 Y & A samples), little-endian
AV_PIX_FMT_AYUV64BE,
// < packed AYUV 4:4:4,64bpp (1 Cr & Cb sample per 1x1 Y & A samples), big-endian
AV_PIX_FMT_VIDEOTOOLBOX,
// < hardware decoding through Videotoolbox
AV_PIX_FMT_P010LE,
// < like NV12, with 10bpp per component, data in the high bits, zeros in the low bits, little-endian
AV_PIX_FMT_P010BE,
// < like NV12, with 10bpp per component, data in the high bits, zeros in the low bits, big-endian
AV_PIX_FMT_GBRAP12BE,
// < planar GBR 4:4:4:4 48bpp, big-endian
AV_PIX_FMT_GBRAP12LE,
// < planar GBR 4:4:4:4 48bpp, little-endian
AV_PIX_FMT_GBRAP10BE,
// < planar GBR 4:4:4:4 40bpp, big-endian
AV_PIX_FMT_GBRAP10LE,
// < planar GBR 4:4:4:4 40bpp, little-endian
AV_PIX_FMT_MEDIACODEC,
// < hardware decoding through MediaCodec
AV_PIX_FMT_GRAY12BE,
// < Y , 12bpp, big-endian
AV_PIX_FMT_GRAY12LE,
// < Y , 12bpp, little-endian
AV_PIX_FMT_GRAY10BE,
// < Y , 10bpp, big-endian
AV_PIX_FMT_GRAY10LE,
// < Y , 10bpp, little-endian
AV_PIX_FMT_P016LE,
// < like NV12, with 16bpp per component, little-endian
AV_PIX_FMT_P016BE,
// < like NV12, with 16bpp per component, big-endian
(* *
* Hardware surfaces for Direct3D11.
*
* This is preferred over the legacy AV_PIX_FMT_D3D11VA_VLD. The new D3D11
* hwaccel API and filtering support AV_PIX_FMT_D3D11 only.
*
* data[0] contains a ID3D11Texture2D pointer, and data[1] contains the
* texture array index of the frame as intptr_t if the ID3D11Texture2D is
* an array texture (or always 0 if it's a normal texture).
*)
AV_PIX_FMT_D3D11,
AV_PIX_FMT_GRAY9BE,
/// < Y , 9bpp, big-endian
AV_PIX_FMT_GRAY9LE,
/// < Y , 9bpp, little-endian
AV_PIX_FMT_GBRPF32BE,
/// < IEEE-754 single precision planar GBR 4:4:4, 96bpp, big-endian
AV_PIX_FMT_GBRPF32LE,
/// < IEEE-754 single precision planar GBR 4:4:4, 96bpp, little-endian
AV_PIX_FMT_GBRAPF32BE,
/// < IEEE-754 single precision planar GBRA 4:4:4:4, 128bpp, big-endian
AV_PIX_FMT_GBRAPF32LE,
/// < IEEE-754 single precision planar GBRA 4:4:4:4, 128bpp, little-endian
(* *
* DRM-managed buffers exposed through PRIME buffer sharing.
*
* data[0] points to an AVDRMFrameDescriptor.
*)
AV_PIX_FMT_DRM_PRIME,
(* *
* Hardware surfaces for OpenCL.
*
* data[i] contain 2D image objects (typed in C as cl_mem, used
* in OpenCL as image2d_t) for each plane of the surface.
*)
AV_PIX_FMT_OPENCL, //
AV_PIX_FMT_GRAY14BE,
/// < Y , 14bpp, big-endian
AV_PIX_FMT_GRAY14LE,
/// < Y , 14bpp, little-endian
AV_PIX_FMT_GRAYF32BE,
/// < IEEE-754 single precision Y, 32bpp, big-endian
AV_PIX_FMT_GRAYF32LE,
/// < IEEE-754 single precision Y, 32bpp, little-endian
AV_PIX_FMT_YUVA422P12BE,
/// < planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), 12b alpha, big-endian
AV_PIX_FMT_YUVA422P12LE,
/// < planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), 12b alpha, little-endian
AV_PIX_FMT_YUVA444P12BE,
/// < planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), 12b alpha, big-endian
AV_PIX_FMT_YUVA444P12LE,
/// < planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), 12b alpha, little-endian
AV_PIX_FMT_NV24,
/// < planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V)
AV_PIX_FMT_NV42,
/// < as above, but U and V bytes are swapped
AV_PIX_FMT_NB
// < number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
);
const
AVPALETTE_SIZE = 1024;
AVPALETTE_COUNT = 256;
AV_PIX_FMT_RGB32: AVPixelFormat = AV_PIX_FMT_BGRA; // AV_PIX_FMT_NE(ARGB, BGRA)
AV_PIX_FMT_RGB32_1: AVPixelFormat = AV_PIX_FMT_ABGR; // AV_PIX_FMT_NE(RGBA, ABGR)
AV_PIX_FMT_BGR32: AVPixelFormat = AV_PIX_FMT_RGBA; // AV_PIX_FMT_NE(ABGR, RGBA)
AV_PIX_FMT_BGR32_1: AVPixelFormat = AV_PIX_FMT_ARGB; // AV_PIX_FMT_NE(BGRA, ARGB)
AV_PIX_FMT_0RGB32: AVPixelFormat = AV_PIX_FMT_BGR0; // AV_PIX_FMT_NE(0RGB, BGR0)
AV_PIX_FMT_0BGR32: AVPixelFormat = AV_PIX_FMT_RGB0; // AV_PIX_FMT_NE(0BGR, RGB0)
AV_PIX_FMT_GRAY10: AVPixelFormat = AV_PIX_FMT_GRAY10LE; // AV_PIX_FMT_NE(GRAY10BE, GRAY10LE)
AV_PIX_FMT_GRAY12: AVPixelFormat = AV_PIX_FMT_GRAY12LE; // AV_PIX_FMT_NE(GRAY12BE, GRAY12LE)
AV_PIX_FMT_GRAY16: AVPixelFormat = AV_PIX_FMT_GRAY16LE; // AV_PIX_FMT_NE(GRAY16BE, GRAY16LE)
AV_PIX_FMT_YA16: AVPixelFormat = AV_PIX_FMT_YA16LE; // AV_PIX_FMT_NE(YA16BE, YA16LE )
AV_PIX_FMT_RGB48: AVPixelFormat = AV_PIX_FMT_RGB48LE; // AV_PIX_FMT_NE(RGB48BE, RGB48LE )
AV_PIX_FMT_RGB565: AVPixelFormat = AV_PIX_FMT_RGB565LE; // AV_PIX_FMT_NE(RGB565BE, RGB565LE)
AV_PIX_FMT_RGB555: AVPixelFormat = AV_PIX_FMT_RGB555LE; // AV_PIX_FMT_NE(RGB555BE, RGB555LE)
AV_PIX_FMT_RGB444: AVPixelFormat = AV_PIX_FMT_RGB444LE; // AV_PIX_FMT_NE(RGB444BE, RGB444LE)
AV_PIX_FMT_RGBA64: AVPixelFormat = AV_PIX_FMT_RGBA64LE; // AV_PIX_FMT_NE(RGBA64BE, RGBA64LE)
AV_PIX_FMT_BGR48: AVPixelFormat = AV_PIX_FMT_BGR48LE; // AV_PIX_FMT_NE(BGR48BE, BGR48LE )
AV_PIX_FMT_BGR565: AVPixelFormat = AV_PIX_FMT_BGR565LE; // AV_PIX_FMT_NE(BGR565BE, BGR565LE)
AV_PIX_FMT_BGR555: AVPixelFormat = AV_PIX_FMT_BGR555LE; // AV_PIX_FMT_NE(BGR555BE, BGR555LE)
AV_PIX_FMT_BGR444: AVPixelFormat = AV_PIX_FMT_BGR444LE; // AV_PIX_FMT_NE(BGR444BE, BGR444LE)
AV_PIX_FMT_BGRA64: AVPixelFormat = AV_PIX_FMT_BGRA64LE; // AV_PIX_FMT_NE(BGRA64BE, BGRA64LE)
AV_PIX_FMT_YUV420P9: AVPixelFormat = AV_PIX_FMT_YUV420P9LE; // AV_PIX_FMT_NE(YUV420P9BE , YUV420P9LE )
AV_PIX_FMT_YUV422P9: AVPixelFormat = AV_PIX_FMT_YUV422P9LE; // AV_PIX_FMT_NE(YUV422P9BE , YUV422P9LE )
AV_PIX_FMT_YUV444P9: AVPixelFormat = AV_PIX_FMT_YUV444P9LE; // AV_PIX_FMT_NE(YUV444P9BE , YUV444P9LE )
AV_PIX_FMT_YUV420P10: AVPixelFormat = AV_PIX_FMT_YUV420P10LE; // AV_PIX_FMT_NE(YUV420P10BE, YUV420P10LE)
AV_PIX_FMT_YUV422P10: AVPixelFormat = AV_PIX_FMT_YUV422P10LE; // AV_PIX_FMT_NE(YUV422P10BE, YUV422P10LE)
AV_PIX_FMT_YUV440P10: AVPixelFormat = AV_PIX_FMT_YUV440P10LE; // AV_PIX_FMT_NE(YUV440P10BE, YUV440P10LE)
AV_PIX_FMT_YUV444P10: AVPixelFormat = AV_PIX_FMT_YUV444P10LE; // AV_PIX_FMT_NE(YUV444P10BE, YUV444P10LE)
AV_PIX_FMT_YUV420P12: AVPixelFormat = AV_PIX_FMT_YUV420P12LE; // AV_PIX_FMT_NE(YUV420P12BE, YUV420P12LE)
AV_PIX_FMT_YUV422P12: AVPixelFormat = AV_PIX_FMT_YUV422P12LE; // AV_PIX_FMT_NE(YUV422P12BE, YUV422P12LE)
AV_PIX_FMT_YUV440P12: AVPixelFormat = AV_PIX_FMT_YUV440P12LE; // AV_PIX_FMT_NE(YUV440P12BE, YUV440P12LE)
AV_PIX_FMT_YUV444P12: AVPixelFormat = AV_PIX_FMT_YUV444P12LE; // AV_PIX_FMT_NE(YUV444P12BE, YUV444P12LE)
AV_PIX_FMT_YUV420P14: AVPixelFormat = AV_PIX_FMT_YUV420P14LE; // AV_PIX_FMT_NE(YUV420P14BE, YUV420P14LE)
AV_PIX_FMT_YUV422P14: AVPixelFormat = AV_PIX_FMT_YUV422P14LE; // AV_PIX_FMT_NE(YUV422P14BE, YUV422P14LE)
AV_PIX_FMT_YUV444P14: AVPixelFormat = AV_PIX_FMT_YUV444P14LE; // AV_PIX_FMT_NE(YUV444P14BE, YUV444P14LE)
AV_PIX_FMT_YUV420P16: AVPixelFormat = AV_PIX_FMT_YUV420P16LE; // AV_PIX_FMT_NE(YUV420P16BE, YUV420P16LE)
AV_PIX_FMT_YUV422P16: AVPixelFormat = AV_PIX_FMT_YUV422P16LE; // AV_PIX_FMT_NE(YUV422P16BE, YUV422P16LE)
AV_PIX_FMT_YUV444P16: AVPixelFormat = AV_PIX_FMT_YUV444P16LE; // AV_PIX_FMT_NE(YUV444P16BE, YUV444P16LE)
AV_PIX_FMT_GBRP9: AVPixelFormat = AV_PIX_FMT_GBRP9LE; // AV_PIX_FMT_NE(GBRP9BE , GBRP9LE )
AV_PIX_FMT_GBRP10: AVPixelFormat = AV_PIX_FMT_GBRP10LE; // AV_PIX_FMT_NE(GBRP10BE, GBRP10LE )
AV_PIX_FMT_GBRP12: AVPixelFormat = AV_PIX_FMT_GBRP12LE; // AV_PIX_FMT_NE(GBRP12BE, GBRP12LE )
AV_PIX_FMT_GBRP14: AVPixelFormat = AV_PIX_FMT_GBRP14LE; // AV_PIX_FMT_NE(GBRP14BE, GBRP14LE )
AV_PIX_FMT_GBRP16: AVPixelFormat = AV_PIX_FMT_GBRP16LE; // AV_PIX_FMT_NE(GBRP16BE, GBRP16LE )
AV_PIX_FMT_GBRAP10: AVPixelFormat = AV_PIX_FMT_GBRAP10LE; // AV_PIX_FMT_NE(GBRAP10BE, GBRAP10LE)
AV_PIX_FMT_GBRAP12: AVPixelFormat = AV_PIX_FMT_GBRAP12LE; // AV_PIX_FMT_NE(GBRAP12BE, GBRAP12LE)
AV_PIX_FMT_GBRAP16: AVPixelFormat = AV_PIX_FMT_GBRAP16LE; // AV_PIX_FMT_NE(GBRAP16BE, GBRAP16LE)
AV_PIX_FMT_BAYER_BGGR16: AVPixelFormat = AV_PIX_FMT_BAYER_BGGR16LE; // AV_PIX_FMT_NE(BAYER_BGGR16BE, BAYER_BGGR16LE)
AV_PIX_FMT_BAYER_RGGB16: AVPixelFormat = AV_PIX_FMT_BAYER_RGGB16LE; // AV_PIX_FMT_NE(BAYER_RGGB16BE, BAYER_RGGB16LE)
AV_PIX_FMT_BAYER_GBRG16: AVPixelFormat = AV_PIX_FMT_BAYER_GBRG16LE; // AV_PIX_FMT_NE(BAYER_GBRG16BE, BAYER_GBRG16LE)
AV_PIX_FMT_BAYER_GRBG16: AVPixelFormat = AV_PIX_FMT_BAYER_GRBG16LE; // AV_PIX_FMT_NE(BAYER_GRBG16BE, BAYER_GRBG16LE)
AV_PIX_FMT_YUVA420P9: AVPixelFormat = AV_PIX_FMT_YUVA420P9LE; // AV_PIX_FMT_NE(YUVA420P9BE , YUVA420P9LE )
AV_PIX_FMT_YUVA422P9: AVPixelFormat = AV_PIX_FMT_YUVA422P9LE; // AV_PIX_FMT_NE(YUVA422P9BE , YUVA422P9LE )
AV_PIX_FMT_YUVA444P9: AVPixelFormat = AV_PIX_FMT_YUVA444P9LE; // AV_PIX_FMT_NE(YUVA444P9BE , YUVA444P9LE )
AV_PIX_FMT_YUVA420P10: AVPixelFormat = AV_PIX_FMT_YUVA420P10LE; // AV_PIX_FMT_NE(YUVA420P10BE, YUVA420P10LE)
AV_PIX_FMT_YUVA422P10: AVPixelFormat = AV_PIX_FMT_YUVA422P10LE; // AV_PIX_FMT_NE(YUVA422P10BE, YUVA422P10LE)
AV_PIX_FMT_YUVA444P10: AVPixelFormat = AV_PIX_FMT_YUVA444P10LE; // AV_PIX_FMT_NE(YUVA444P10BE, YUVA444P10LE)
AV_PIX_FMT_YUVA422P12: AVPixelFormat = AV_PIX_FMT_YUVA422P12LE; // AV_PIX_FMT_NE(YUVA422P12BE, YUVA422P12LE);
AV_PIX_FMT_YUVA444P12: AVPixelFormat = AV_PIX_FMT_YUVA444P12LE; // AV_PIX_FMT_NE(YUVA444P12BE, YUVA444P12LE);
AV_PIX_FMT_YUVA420P16: AVPixelFormat = AV_PIX_FMT_YUVA420P16LE; // AV_PIX_FMT_NE(YUVA420P16BE, YUVA420P16LE)
AV_PIX_FMT_YUVA422P16: AVPixelFormat = AV_PIX_FMT_YUVA422P16LE; // AV_PIX_FMT_NE(YUVA422P16BE, YUVA422P16LE)
AV_PIX_FMT_YUVA444P16: AVPixelFormat = AV_PIX_FMT_YUVA444P16LE; // AV_PIX_FMT_NE(YUVA444P16BE, YUVA444P16LE)
AV_PIX_FMT_XYZ12: AVPixelFormat = AV_PIX_FMT_XYZ12LE; // AV_PIX_FMT_NE(XYZ12BE, XYZ12LE )
AV_PIX_FMT_NV20: AVPixelFormat = AV_PIX_FMT_NV20LE; // AV_PIX_FMT_NE(NV20BE, NV20LE )
AV_PIX_FMT_AYUV64: AVPixelFormat = AV_PIX_FMT_AYUV64LE; // AV_PIX_FMT_NE(AYUV64BE,AYUV64LE)
AV_PIX_FMT_P010: AVPixelFormat = AV_PIX_FMT_P010LE; // AV_PIX_FMT_NE(P010BE, P010LE )
AV_PIX_FMT_P016: AVPixelFormat = AV_PIX_FMT_P016LE; // AV_PIX_FMT_NE(P016BE, P016LE )
(* *
* Chromaticity coordinates of the source primaries.
*)
Type
AVColorPrimaries = ( //
AVCOL_PRI_RESERVED0 = 0, AVCOL_PRI_BT709 = 1,
// < also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B
AVCOL_PRI_UNSPECIFIED = 2, AVCOL_PRI_RESERVED = 3, AVCOL_PRI_BT470M = 4,
// < also FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
AVCOL_PRI_BT470BG = 5,
// < also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM
AVCOL_PRI_SMPTE170M = 6,
// < also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
AVCOL_PRI_SMPTE240M = 7,
// < functionally identical to above
AVCOL_PRI_FILM = 8,
// < colour filters using Illuminant C
AVCOL_PRI_BT2020 = 9,
// < ITU-R BT2020
AVCOL_PRI_SMPTE428 = 10,
// < SMPTE ST 428-1 (CIE 1931 XYZ)
AVCOL_PRI_SMPTEST428_1 = AVCOL_PRI_SMPTE428, //
AVCOL_PRI_SMPTE431 = 11, // < SMPTE ST 431-2 (2011) / DCI P3
AVCOL_PRI_SMPTE432 = 12, // < SMPTE ST 432-1 (2010) / P3 D65 / Display P3
AVCOL_PRI_EBU3213 = 22, // < EBU Tech. 3213-E / JEDEC P22 phosphors
AVCOL_PRI_JEDEC_P22 = AVCOL_PRI_EBU3213, //
AVCOL_PRI_NB // < Not part of ABI
);
(* *
* Color Transfer Characteristic.
*)
AVColorTransferCharacteristic = ( //
AVCOL_TRC_RESERVED0 = 0, AVCOL_TRC_BT709 = 1,
// < also ITU-R BT1361
AVCOL_TRC_UNSPECIFIED = 2, AVCOL_TRC_RESERVED = 3, AVCOL_TRC_GAMMA22 = 4,
// < also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM
AVCOL_TRC_GAMMA28 = 5,
// < also ITU-R BT470BG
AVCOL_TRC_SMPTE170M = 6,
// < also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC
AVCOL_TRC_SMPTE240M = 7, AVCOL_TRC_LINEAR = 8,
// < "Linear transfer characteristics"
AVCOL_TRC_LOG = 9,
// < "Logarithmic transfer characteristic (100:1 range)"
AVCOL_TRC_LOG_SQRT = 10,
// < "Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)"
AVCOL_TRC_IEC61966_2_4 = 11,
// < IEC 61966-2-4
AVCOL_TRC_BT1361_ECG = 12,
// < ITU-R BT1361 Extended Colour Gamut
AVCOL_TRC_IEC61966_2_1 = 13,
// < IEC 61966-2-1 (sRGB or sYCC)
AVCOL_TRC_BT2020_10 = 14,
// < ITU-R BT2020 for 10-bit system
AVCOL_TRC_BT2020_12 = 15,
// < ITU-R BT2020 for 12-bit system
AVCOL_TRC_SMPTE2084 = 16,
// < SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems
AVCOL_TRC_SMPTEST2084 = AVCOL_TRC_SMPTE2084, AVCOL_TRC_SMPTE428 = 17,
// < SMPTE ST 428-1
AVCOL_TRC_SMPTEST428_1 = AVCOL_TRC_SMPTE428, AVCOL_TRC_ARIB_STD_B67 = 18,
// < ARIB STD-B67, known as "Hybrid log-gamma"
AVCOL_TRC_NB
// < Not part of ABI
);
(* *
* YUV colorspace type.
*)
AVColorSpace = ( //
AVCOL_SPC_RGB = 0,
// < order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB)
AVCOL_SPC_BT709 = 1,
// < also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
AVCOL_SPC_UNSPECIFIED = 2, AVCOL_SPC_RESERVED = 3, AVCOL_SPC_FCC = 4,
// < FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
AVCOL_SPC_BT470BG = 5,
// < also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
AVCOL_SPC_SMPTE170M = 6,
// < also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
AVCOL_SPC_SMPTE240M = 7,
// < functionally identical to above
AVCOL_SPC_YCGCO = 8,
// < Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16
AVCOL_SPC_YCOCG = AVCOL_SPC_YCGCO, AVCOL_SPC_BT2020_NCL = 9,
// < ITU-R BT2020 non-constant luminance system
AVCOL_SPC_BT2020_CL = 10,
// < ITU-R BT2020 constant luminance system
AVCOL_SPC_SMPTE2085 = 11,
// < SMPTE 2085, Y'D'zD'x
AVCOL_SPC_NB
// < Not part of ABI
);
// #define AVCOL_SPC_YCGCO AVCOL_SPC_YCOCG
(* *
* MPEG vs JPEG YUV range.
*)
AVColorRange = ( //
AVCOL_RANGE_UNSPECIFIED = 0, AVCOL_RANGE_MPEG = 1,
// < the normal 219*2^(n-8) "MPEG" YUV ranges
AVCOL_RANGE_JPEG = 2,
// < the normal 2^n-1 "JPEG" YUV ranges
AVCOL_RANGE_NB
// < Not part of ABI
);
(* *
* Location of chroma samples.
*
* Illustration showing the location of the first (top left) chroma sample of the
* image, the left shows only luma, the right
* shows the location of the chroma sample, the 2 could be imagined to overlay
* each other but are drawn separately due to limitations of ASCII
*
*----------------1st 2nd 1st 2nd horizontal luma sample positions
*-----------------v v v v
* ______ ______
*1st luma line > |X X ... |3 4 X ... X are luma samples,
*----------------| |1 2 1-6 are possible chroma positions
*2nd luma line > |X X ... |5 6 X ... 0 is undefined/unknown position
*)
AVChromaLocation = ( //
AVCHROMA_LOC_UNSPECIFIED = 0, AVCHROMA_LOC_LEFT = 1,
// < MPEG-2/4 4:2:0, H.264 default for 4:2:0
AVCHROMA_LOC_CENTER = 2,
// < MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0
AVCHROMA_LOC_TOPLEFT = 3,
// < ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2
AVCHROMA_LOC_TOP = 4, AVCHROMA_LOC_BOTTOMLEFT = 5, AVCHROMA_LOC_BOTTOM = 6, AVCHROMA_LOC_NB
// < Not part of ABI
);
{$ENDREGION}
{$REGION 'frame.h'}
const
AV_NUM_DATA_POINTERS = 8;
Type
TAVNDPArray = array [0 .. AV_NUM_DATA_POINTERS - 1] of int;
pAVNDPArray = ^TAVNDPArray;
TAVNDPArray_int = TAVNDPArray;
pAVNDPArray_int = ^TAVNDPArray_int;
TAVNDPArray_puint8_t = array [0 .. AV_NUM_DATA_POINTERS - 1] of puint8_t;
pAVNDPArray_puint8_t = ^TAVNDPArray_puint8_t;
TAVNDPArray_uint64_t = array [0 .. AV_NUM_DATA_POINTERS - 1] of uint64_t;
TAVNDPArray_pAVBufferRef = array [0 .. AV_NUM_DATA_POINTERS - 1] of pAVBufferRef;
pAVNDPArray_pAVBufferRef = ^TAVNDPArray_pAVBufferRef;
// uint8_t * data[4];
Tuint8_t_array_4 = array [0 .. 3] of uint8_t;
puint8_t_array_4 = ^Tuint8_t_array_4;
// int linesize[4];
Tint_array_4 = array [0 .. 3] of int;
AVFrameSideDataType = (
(* *
* The data is the AVPanScan struct defined in libavcodec.
*)
AV_FRAME_DATA_PANSCAN,
(* *
* ATSC A53 Part 4 Closed Captions.
* A53 CC bitstream is stored as uint8_t in AVFrameSideData.data.
* The number of bytes of CC data is AVFrameSideData.size.
*)
AV_FRAME_DATA_A53_CC,
(* *
* Stereoscopic 3d metadata.
* The data is the AVStereo3D struct defined in libavutil/stereo3d.h.
*)
AV_FRAME_DATA_STEREO3D,
(* *
* The data is the AVMatrixEncoding enum defined in libavutil/channel_layout.h.
*)
AV_FRAME_DATA_MATRIXENCODING,
(* *
* Metadata relevant to a downmix procedure.
* The data is the AVDownmixInfo struct defined in libavutil/downmix_info.h.
*)
AV_FRAME_DATA_DOWNMIX_INFO,
(* *
* ReplayGain information in the form of the AVReplayGain struct.
*)
AV_FRAME_DATA_REPLAYGAIN,
(* *
* This side data contains a 3x3 transformation matrix describing an affine
* transformation that needs to be applied to the frame for correct
* presentation.
*
* See libavutil/display.h for a detailed description of the data.
*)
AV_FRAME_DATA_DISPLAYMATRIX,
(* *
* Active Format Description data consisting of a single byte as specified
* in ETSI TS 101 154 using AVActiveFormatDescription enum.
*)
AV_FRAME_DATA_AFD,
(* *
* Motion vectors exported by some codecs (on demand through the export_mvs
* flag set in the libavcodec AVCodecContext flags2 option).
* The data is the AVMotionVector struct defined in
* libavutil/motion_vector.h.
*)
AV_FRAME_DATA_MOTION_VECTORS,
(* *
* Recommmends skipping the specified number of samples. This is exported
* only if the "skip_manual" AVOption is set in libavcodec.
* This has the same format as AV_PKT_DATA_SKIP_SAMPLES.
* @code
* u32le number of samples to skip from start of this packet
* u32le number of samples to skip from end of this packet
* u8 reason for start skip
* u8 reason for end skip (0=padding silence, 1=convergence)
* @endcode
*)
AV_FRAME_DATA_SKIP_SAMPLES,
(* *
* This side data must be associated with an audio frame and corresponds to
* enum AVAudioServiceType defined in avcodec.h.
*)
AV_FRAME_DATA_AUDIO_SERVICE_TYPE,
(* *
* Mastering display metadata associated with a video frame. The payload is
* an AVMasteringDisplayMetadata type and contains information about the
* mastering display color volume.
*)
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA,
(* *
* The GOP timecode in 25 bit timecode format. Data format is 64-bit integer.
* This is set on the first frame of a GOP that has a temporal reference of 0.
*)
AV_FRAME_DATA_GOP_TIMECODE,
(* *
* The data represents the AVSphericalMapping structure defined in
* libavutil/spherical.h.
*)
AV_FRAME_DATA_SPHERICAL,
(* *
* Content light level (based on CTA-861.3). This payload contains data in
* the form of the AVContentLightMetadata struct.
*)
AV_FRAME_DATA_CONTENT_LIGHT_LEVEL,
(* *
* The data contains an ICC profile as an opaque octet buffer following the
* format described by ISO 15076-1 with an optional name defined in the
* metadata key entry "name".
*)
AV_FRAME_DATA_ICC_PROFILE,
{$IFDEF FF_API_FRAME_QP}
(* *
* Implementation-specific description of the format of AV_FRAME_QP_TABLE_DATA.
* The contents of this side data are undocumented and internal; use
* av_frame_set_qp_table() and av_frame_get_qp_table() to access this in a
* meaningful way instead.
*)
AV_FRAME_DATA_QP_TABLE_PROPERTIES,
(* *
* Raw QP table data. Its format is described by
* AV_FRAME_DATA_QP_TABLE_PROPERTIES. Use av_frame_set_qp_table() and
* av_frame_get_qp_table() to access this instead.
*)
AV_FRAME_DATA_QP_TABLE_DATA,
{$ENDIF}
(*
* Timecode which conforms to SMPTE ST 12-1. The data is an array of 4 uint32_t
* where the first uint32_t describes how many (1-3) of the other timecodes are used.
* The timecode format is described in the av_timecode_get_smpte_from_framenum()
* function in libavutil/timecode.c.
*)
AV_FRAME_DATA_S12M_TIMECODE, //
(*
* HDR dynamic metadata associated with a video frame. The payload is
* an AVDynamicHDRPlus type and contains information for color
* volume transform - application 4 of SMPTE 2094-40:2016 standard.
*)
AV_FRAME_DATA_DYNAMIC_HDR_PLUS,
(*
* Regions Of Interest, the data is an array of AVRegionOfInterest type, the number of
* array element is implied by AVFrameSideData.size / AVRegionOfInterest.self_size.
*)
AV_FRAME_DATA_REGIONS_OF_INTEREST //
);
AVActiveFormatDescription = ( //
AV_AFD_SAME = 8, AV_AFD_4_3 = 9, AV_AFD_16_9 = 10, AV_AFD_14_9 = 11, AV_AFD_4_3_SP_14_9 = 13, AV_AFD_16_9_SP_14_9 = 14, AV_AFD_SP_4_3 = 15);
(* *
* Structure to hold side data for an AVFrame.
*
* sizeof(AVFrameSideData) is not a part of the public ABI, so new fields may be added
* to the end with a minor bump.
*)
AVFrameSideData = record
_type: AVFrameSideDataType;
data: puint8_t;
size: int;
metadata: pAVDictionary;
buf: pAVBufferRef;
end;
pAVFrameSideData = ^AVFrameSideData;
ppAVFrameSideData = ^pAVFrameSideData;
(*
* Structure describing a single Region Of Interest.
*
* When multiple regions are defined in a single side-data block, they
* should be ordered from most to least important - some encoders are only
* capable of supporting a limited number of distinct regions, so will have
* to truncate the list.
*
* When overlapping regions are defined, the first region containing a given
* area of the frame applies.
*)
AVRegionOfInterest = record
(*
* Must be set to the size of this data structure (that is,
* sizeof(AVRegionOfInterest)).
*)
self_size: uint32_t;
(*
* Distance in pixels from the top edge of the frame to the top and
* bottom edges and from the left edge of the frame to the left and
* right edges of the rectangle defining this region of interest.
*
* The constraints on a region are encoder dependent, so the region
* actually affected may be slightly larger for alignment or other
* reasons.
*)
top: int;
bottom: int;
left: int;
right: int;
(*
* Quantisation offset.
*
* Must be in the range -1 to +1. A value of zero indicates no quality
* change. A negative value asks for better quality (less quantisation),
* while a positive value asks for worse quality (greater quantisation).
*
* The range is calibrated so that the extreme values indicate the
* largest possible offset - if the rest of the frame is encoded with the
* worst possible quality, an offset of -1 indicates that this region
* should be encoded with the best possible quality anyway. Intermediate
* values are then interpolated in some codec-dependent way.
*
* For example, in 10-bit H.264 the quantisation parameter varies between
* -12 and 51. A typical qoffset value of -1/10 therefore indicates that
* this region should be encoded with a QP around one-tenth of the full
* range better than the rest of the frame. So, if most of the frame
* were to be encoded with a QP of around 30, this region would get a QP
* of around 24 (an offset of approximately -1/10 * (51 - -12) = -6.3).
* An extreme value of -1 would indicate that this region should be
* encoded with the best possible quality regardless of the treatment of
* the rest of the frame - that is, should be encoded at a QP of -12.
*)
qoffset: AVRational;
end;
pAVRegionOfInterest = ^AVRegionOfInterest;
(* *
* This structure describes decoded (raw) audio or video data.
*
* AVFrame must be allocated using av_frame_alloc(). Note that this only
* allocates the AVFrame itself, the buffers for the data must be managed
* through other means (see below).
* AVFrame must be freed with av_frame_free().
*
* AVFrame is typically allocated once and then reused multiple times to hold
* different data (e.g. a single AVFrame to hold frames received from a
* decoder). In such a case, av_frame_unref() will free any references held by
* the frame and reset it to its original clean state before it
* is reused again.
*
* The data described by an AVFrame is usually reference counted through the
* AVBuffer API. The underlying buffer references are stored in AVFrame.buf /
* AVFrame.extended_buf. An AVFrame is considered to be reference counted if at
* least one reference is set, i.e. if AVFrame.buf[0] != NULL. In such a case,
* every single data plane must be contained in one of the buffers in
* AVFrame.buf or AVFrame.extended_buf.
* There may be a single buffer for all the data, or one separate buffer for
* each plane, or anything in between.
*
* sizeof(AVFrame) is not a part of the public ABI, so new fields may be added
* to the end with a minor bump.
*
* Fields can be accessed through AVOptions, the name string used, matches the
* C structure field name for fields accessible through AVOptions. The AVClass
* for AVFrame can be obtained from avcodec_get_frame_class()
*)
(* *
* @defgroup lavu_frame_flags AV_FRAME_FLAGS
* @ingroup lavu_frame
* Flags describing additional frame properties.
*)
const
(* *
* The frame data may be corrupted, e.g. due to decoding errors.
*)
AV_FRAME_FLAG_CORRUPT = (1 shl 0);
(* *
* A flag to mark the frames which need to be decoded, but shouldn't be output.
*)
AV_FRAME_FLAG_DISCARD = (1 shl 2);
// AVFrame -> decode_error_flags:int;
FF_DECODE_ERROR_INVALID_BITSTREAM = 1;
FF_DECODE_ERROR_MISSING_REFERENCE = 2;
FF_DECODE_ERROR_CONCEALMENT_ACTIVE = 4;
FF_DECODE_ERROR_DECODE_SLICES = 8;
type
pAVFrame = ^AVFrame;
AVFrame = record
(* *
* pointer to the picture/channel planes.
* This might be different from the first allocated byte
*
* Some decoders access areas outside 0,0 - width,height, please
* see avcodec_align_dimensions2(). Some filters and swscale can read
* up to 16 bytes beyond the planes, if these filters are to be used,
* then 16 extra bytes must be allocated.
*
* NOTE: Except for hwaccel formats, pointers not needed by the format
* MUST be set to NULL.
*)
data: TAVNDPArray_puint8_t;
(* *
* For video, size in bytes of each picture line.
* For audio, size in bytes of each plane.
*
* For audio, only linesize[0] may be set. For planar audio, each channel
* plane must be the same size.
*
* For video the linesizes should be multiples of the CPUs alignment
* preference, this is 16 or 32 for modern desktop CPUs.
* Some code requires such alignment other code can be slower without
* correct alignment, for yet other it makes no difference.
*
* @note The linesize may be larger than the size of usable data -- there
* may be extra padding present for performance reasons.
*)
linesize: TAVNDPArray_int;
(* *
* pointers to the data planes/channels.
*
* For video, this should simply point to data[].
*
* For planar audio, each channel has a separate data pointer, and
* linesize[0] contains the size of each channel buffer.
* For packed audio, there is just one data pointer, and linesize[0]
* contains the total size of the buffer for all channels.
*
* Note: Both data and extended_data should always be set in a valid frame,
* but for planar audio with more channels that can fit in data,
* extended_data must be used in order to access all channels.
*)
extended_data: ppuint8_t;
(* *
* @name Video dimensions
* Video frames only. The coded dimensions (in pixels) of the video frame,
* i.e. the size of the rectangle that contains some well-defined values.
*
* @note The part of the frame intended for display/presentation is further
* restricted by the @ref cropping "Cropping rectangle".
* @{
*)
width, height: int;
(* *
* @}
*)
(* *
* number of audio samples (per channel) described by this frame
*)
nb_samples: int;
(* *
* format of the frame, -1 if unknown or unset
* Values correspond to enum AVPixelFormat for video frames,
* enum AVSampleFormat for audio)
*)
format: int;
(* *
* 1 -> keyframe, 0-> not
*)
key_frame: int;
(* *
* Picture type of the frame.
*)
pict_type: AVPictureType;
(* *
* Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
*)
sample_aspect_ratio: AVRational;
(* *
* Presentation timestamp in time_base units (time when frame should be shown to user).
*)
pts: int64_t;
{$IFDEF FF_API_PKT_PTS}
(* *
* PTS copied from the AVPacket that was decoded to produce this frame.
* @deprecated use the pts field instead
*)
// attribute_deprecated
pkt_pts: int64_t;
{$ENDIF}
(* *
* DTS copied from the AVPacket that triggered returning this frame. (if frame threading isn't used)
* This is also the Presentation time of this AVFrame calculated from
* only AVPacket.dts values without pts values.
*)
pkt_dts: int64_t;
(* *
* picture number in bitstream order
*)
coded_picture_number: int;
(* *
* picture number in display order
*)
display_picture_number: int;
(* *
* quality (between 1 (good) and FF_LAMBDA_MAX (bad))
*)
quality: int;
(* *
* for some private data of the user
*)
opaque: Pointer;
{$IFDEF FF_API_ERROR_FRAME}
(* *
* @deprecated unused
*)
// attribute_deprecated
error: TAVNDPArray_puint8_t;
{$ENDIF}
(* *
* When decoding, this signals how much the picture must be delayed.
* extra_delay = repeat_pict / (2*fps)
*)
repeat_pict: int;
(* *
* The content of the picture is interlaced.
*)
interlaced_frame: int;
(* *
* If the content is interlaced, is top field displayed first.
*)
top_field_first: int;
(* *
* Tell user application that palette has changed from previous frame.
*)
palette_has_changed: int;
(* *
* reordered opaque 64 bits (generally an integer or a double precision float
* PTS but can be anything).
* The user sets AVCodecContext.reordered_opaque to represent the input at
* that time,
* the decoder reorders values as needed and sets AVFrame.reordered_opaque
* to exactly one of the values provided by the user through AVCodecContext.reordered_opaque
*)
reordered_opaque: int64_t;
(* *
* Sample rate of the audio data.
*)
sample_rate: int;
(* *
* Channel layout of the audio data.
*)
channel_layout: uint64_t;
(* *
* AVBuffer references backing the data for this frame. If all elements of
* this array are NULL, then this frame is not reference counted. This array
* must be filled contiguously -- if buf[i] is non-NULL then buf[j] must
* also be non-NULL for all j < i.
*
* There may be at most one AVBuffer per data plane, so for video this array
* always contains all the references. For planar audio with more than
* AV_NUM_DATA_POINTERS channels, there may be more buffers than can fit in
* this array. Then the extra AVBufferRef pointers are stored in the
* extended_buf array.
*)
buf: TAVNDPArray_pAVBufferRef;
(* *
* For planar audio which requires more than AV_NUM_DATA_POINTERS
* AVBufferRef pointers, this array will hold all the references which
* cannot fit into AVFrame.buf.
*
* Note that this is different from AVFrame.extended_data, which always
* contains all the pointers. This array only contains the extra pointers,
* which cannot fit into AVFrame.buf.
*
* This array is always allocated using av_malloc() by whoever constructs
* the frame. It is freed in av_frame_unref().
*)
extended_buf: ppAVBufferRef;
(* *
* Number of elements in extended_buf.
*)
nb_extended_buf: int;
side_data: ppAVFrameSideData;
nb_side_data: int;
(* *
* Frame flags, a combination of @ref lavu_frame_flags
*)
flags: int;
(* *
* MPEG vs JPEG YUV range.
* - encoding: Set by user
* - decoding: Set by libavcodec
*)
color_range: AVColorRange;
color_primaries: AVColorPrimaries;
color_trc: AVColorTransferCharacteristic;
(* *
* YUV colorspace type.
* - encoding: Set by user
* - decoding: Set by libavcodec
*)
colorspace: AVColorSpace;
chroma_location: AVChromaLocation;
(* *
* frame timestamp estimated using various heuristics, in stream time base
* - encoding: unused
* - decoding: set by libavcodec, read by user.
*)
best_effort_timestamp: int64_t;
(* *
* reordered pos from the last AVPacket that has been input into the decoder
* - encoding: unused
* - decoding: Read by user.
*)
pkt_pos: int64_t;
(* *
* duration of the corresponding packet, expressed in
* AVStream->time_base units, 0 if unknown.
* - encoding: unused
* - decoding: Read by user.
*)
pkt_duration: int64_t;
(* *
* metadata.
* - encoding: Set by user.
* - decoding: Set by libavcodec.
*)
metadata: pAVDictionary;
(* *
* decode error flags of the frame, set to a combination of
* FF_DECODE_ERROR_xxx flags if the decoder produced a frame, but there
* were errors during the decoding.
* - encoding: unused
* - decoding: set by libavcodec, read by user.
*)
decode_error_flags: int;
(* *
* number of audio channels, only used for audio.
* - encoding: unused
* - decoding: Read by user.
*)
channels: int;
(* *
* size of the corresponding packet containing the compressed
* frame.
* It is set to a negative value if unknown.
* - encoding: unused
* - decoding: set by libavcodec, read by user.
*)
pkt_size: int;
{$IFDEF FF_API_FRAME_QP}
(* *
* QP table
*)
// attribute_deprecated
qscale_table: pint8_t;
(* *
* QP store stride
*)
// attribute_deprecated
qstride: int;
// attribute_deprecated
qscale_type: int;
// attribute_deprecated
qp_table_buf: pAVBufferRef;
{$ENDIF}
(* *
* For hwaccel-format frames, this should be a reference to the
* AVHWFramesContext describing the frame.
*)
hw_frames_ctx: pAVBufferRef;
(* *
* AVBufferRef for free use by the API user. FFmpeg will never check the
* contents of the buffer ref. FFmpeg calls av_buffer_unref() on it when
* the frame is unreferenced. av_frame_copy_props() calls create a new
* reference with av_buffer_ref() for the target frame's opaque_ref field.
*
* This is unrelated to the opaque field, although it serves a similar
* purpose.
*)
opaque_ref: pAVBufferRef;
(* *
* @anchor cropping
* @name Cropping
* Video frames only. The number of pixels to discard from the the
* top/bottom/left/right border of the frame to obtain the sub-rectangle of
* the frame intended for presentation.
* @{
*)
crop_top: size_t;
crop_bottom: size_t;
crop_left: size_t;
crop_right: size_t;
(* *
* @}
*)
(* *
* AVBufferRef for internal use by a single libav* library.
* Must not be used to transfer data between libraries.
* Has to be NULL when ownership of the frame leaves the respective library.
*
* Code outside the FFmpeg libs should never check or change the contents of the buffer ref.
*
* FFmpeg calls av_buffer_unref() on it when the frame is unreferenced.
* av_frame_copy_props() calls create a new reference with av_buffer_ref()
* for the target frame's private_ref field.
*)
private_ref: pAVBufferRef;
end;
{$IFDEF FF_API_FRAME_GET_SET}
(* *
* Accessors for some AVFrame fields. These used to be provided for ABI
* compatibility, and do not need to be used anymore.
*)
// attribute_deprecated
// int64_t av_frame_get_best_effort_timestamp(const AVFrame *frame);
function av_frame_get_best_effort_timestamp(const frame: pAVFrame): int64_t; cdecl; external avutil_dll;
// attribute_deprecated
// void av_frame_set_best_effort_timestamp(AVFrame *frame, int64_t val);
procedure av_frame_set_best_effort_timestamp(frame: pAVFrame; val: int64_t); cdecl; external avutil_dll;
// attribute_deprecated
// int64_t av_frame_get_pkt_duration (const AVFrame *frame);
function av_frame_get_pkt_duration(const frame: pAVFrame): int64_t; cdecl; external avutil_dll;
// attribute_deprecated
// void av_frame_set_pkt_duration (AVFrame *frame, int64_t val);
procedure av_frame_set_pkt_duration(frame: pAVFrame; val: int64_t); cdecl; external avutil_dll;
// attribute_deprecated
// int64_t av_frame_get_pkt_pos (const AVFrame *frame);
function av_frame_get_pkt_pos(const frame: pAVFrame): int64_t; cdecl; external avutil_dll;
// attribute_deprecated
// void av_frame_set_pkt_pos (AVFrame *frame, int64_t val);
procedure av_frame_set_pkt_pos(frame: pAVFrame; val: int64_t); cdecl; external avutil_dll;
// attribute_deprecated
// int64_t av_frame_get_channel_layout (const AVFrame *frame);
function av_frame_get_channel_layout(const frame: pAVFrame): int64_t; cdecl; external avutil_dll;
// attribute_deprecated
// void av_frame_set_channel_layout (AVFrame *frame, int64_t val);
procedure av_frame_set_channel_layout(frame: pAVFrame; val: int64_t); cdecl; external avutil_dll;
// attribute_deprecated
// int av_frame_get_channels (const AVFrame *frame);
function av_frame_get_channels(const frame: pAVFrame): int; cdecl; external avutil_dll;
// attribute_deprecated
// void av_frame_set_channels (AVFrame *frame, int val);
procedure av_frame_set_channels(frame: pAVFrame; val: int); cdecl; external avutil_dll;
// attribute_deprecated
// int av_frame_get_sample_rate (const AVFrame *frame);
function av_frame_get_sample_rate(const frame: pAVFrame): int; cdecl; external avutil_dll;
// attribute_deprecated
// void av_frame_set_sample_rate (AVFrame *frame, int val);
procedure av_frame_set_sample_rate(frame: pAVFrame; val: int); cdecl; external avutil_dll;
// attribute_deprecated
// AVDictionary *av_frame_get_metadata (const AVFrame *frame);
function av_frame_get_metadata(const frame: AVFrame): pAVDictionary; cdecl; external avutil_dll;
// attribute_deprecated
// void av_frame_set_metadata (AVFrame *frame, AVDictionary *val);
procedure av_frame_set_metadata(frame: pAVFrame; val: pAVDictionary); cdecl; external avutil_dll;
// attribute_deprecated
// int av_frame_get_decode_error_flags (const AVFrame *frame);
function av_frame_get_decode_error_flags(const frame: pAVFrame): int; cdecl; external avutil_dll;
// attribute_deprecated
// void av_frame_set_decode_error_flags (AVFrame *frame, int val);
procedure av_frame_set_decode_error_flags(frame: pAVFrame; val: int); cdecl; external avutil_dll;
// attribute_deprecated
// int av_frame_get_pkt_size(const AVFrame *frame);
function av_frame_get_pkt_size(const frame: pAVFrame): int; cdecl; external avutil_dll;
// attribute_deprecated
// void av_frame_set_pkt_size(AVFrame *frame, int val);
procedure av_frame_set_pkt_size(frame: AVFrame; val: int); cdecl; external avutil_dll;
{$IFDEF FF_API_FRAME_QP}
// attribute_deprecated
// int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type);
function av_frame_get_qp_table(f: pAVFrame; stride: pint; _type: pint): pint8_t; cdecl; external avutil_dll;
// attribute_deprecated
// int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int type);
function av_frame_set_qp_table(f: pAVFrame; buf: pAVBufferRef; stride: int; _type: int): int; cdecl; external avutil_dll;
{$ENDIF}
// attribute_deprecated
// enum AVColorSpace av_frame_get_colorspace(const AVFrame *frame);
function av_frame_get_colorspace(const frame: pAVFrame): AVColorSpace; cdecl; external avutil_dll;
// attribute_deprecated
// void av_frame_set_colorspace(AVFrame *frame, enum AVColorSpace val);
procedure av_frame_set_colorspace(frame: pAVFrame; val: AVColorSpace); cdecl; external avutil_dll;
// attribute_deprecated
// enum AVColorRange av_frame_get_color_range(const AVFrame *frame);
function av_frame_get_color_range(const frame: pAVFrame): AVColorRange; cdecl; external avutil_dll;
// attribute_deprecated
// void av_frame_set_color_range(AVFrame *frame, enum AVColorRange val);
procedure av_frame_set_color_range(frame: pAVFrame; val: AVColorRange); cdecl; external avutil_dll;
{$ENDIF}
(* *
* Get the name of a colorspace.
* @return a static string identifying the colorspace; can be NULL.
*)
// const char *av_get_colorspace_name(enum AVColorSpace val);
function av_get_colorspace_name(val: AVColorSpace): PAnsiChar; cdecl; external avutil_dll;
(* *
* Allocate an AVFrame and set its fields to default values. The resulting
* struct must be freed using av_frame_free().
*
* @return An AVFrame filled with default values or NULL on failure.
*
* @note this only allocates the AVFrame itself, not the data buffers. Those
* must be allocated through other means, e.g. with av_frame_get_buffer() or
* manually.
*)
// AVFrame *av_frame_alloc(void);
function av_frame_alloc(): pAVFrame; cdecl; external avutil_dll;
(* *
* Free the frame and any dynamically allocated objects in it,
* e.g. extended_data. If the frame is reference counted, it will be
* unreferenced first.
*
* @param frame frame to be freed. The pointer will be set to NULL.
*)
// void av_frame_free(AVFrame **frame);
procedure av_frame_free(Var frame: pAVFrame); cdecl; external avutil_dll;
(* *
* Set up a new reference to the data described by the source frame.
*
* Copy frame properties from src to dst and create a new reference for each
* AVBufferRef from src.
*
* If src is not reference counted, new buffers are allocated and the data is
* copied.
*
* @warning: dst MUST have been either unreferenced with av_frame_unref(dst),
* or newly allocated with av_frame_alloc() before calling this
* function, or undefined behavior will occur.
*
* @return 0 on success, a negative AVERROR on error
*)
// int av_frame_ref(AVFrame *dst, const AVFrame *src);
function av_frame_ref(dst: pAVFrame; const src: pAVFrame): int; cdecl; external avutil_dll;
(* *
* Create a new frame that references the same data as src.
*
* This is a shortcut for av_frame_alloc()+av_frame_ref().
*
* @return newly created AVFrame on success, NULL on error.
*)
// AVFrame *av_frame_clone(const AVFrame *src);
function av_frame_clone(const src: pAVFrame): pAVFrame; cdecl; external avutil_dll;
(* *
* Unreference all the buffers referenced by frame and reset the frame fields.
*)
// void av_frame_unref(AVFrame *frame);
procedure av_frame_unref(frame: pAVFrame); cdecl; external avutil_dll;
(* *
* Move everything contained in src to dst and reset src.
*
* @warning: dst is not unreferenced, but directly overwritten without reading
* or deallocating its contents. Call av_frame_unref(dst) manually
* before calling this function to ensure that no memory is leaked.
*)
// void av_frame_move_ref(AVFrame *dst, AVFrame *src);
procedure av_frame_move_ref(dst: pAVFrame; src: pAVFrame); cdecl; external avutil_dll;
(* *
* Allocate new buffer(s) for audio or video data.
*
* The following fields must be set on frame before calling this function:
* - format (pixel format for video, sample format for audio)
* - width and height for video
* - nb_samples and channel_layout for audio
*
* This function will fill AVFrame.data and AVFrame.buf arrays and, if
* necessary, allocate and fill AVFrame.extended_data and AVFrame.extended_buf.
* For planar formats, one buffer will be allocated for each plane.
*
* @warning: if frame already has been allocated, calling this function will
* leak memory. In addition, undefined behavior can occur in certain
* cases.
*
* @param frame frame in which to store the new buffers.
* @param align Required buffer size alignment. If equal to 0, alignment will be
* chosen automatically for the current CPU. It is highly
* recommended to pass 0 here unless you know what you are doing.
*
* @return 0 on success, a negative AVERROR on error.
*)
// int av_frame_get_buffer(AVFrame *frame, int align);
function av_frame_get_buffer(frame: pAVFrame; align: int): int; cdecl; external avutil_dll;
(* *
* Check if the frame data is writable.
*
* @return A positive value if the frame data is writable (which is true if and
* only if each of the underlying buffers has only one reference, namely the one
* stored in this frame). Return 0 otherwise.
*
* If 1 is returned the answer is valid until av_buffer_ref() is called on any
* of the underlying AVBufferRefs (e.g. through av_frame_ref() or directly).
*
* @see av_frame_make_writable(), av_buffer_is_writable()
*)
// int av_frame_is_writable(AVFrame *frame);
function av_frame_is_writable(frame: pAVFrame): int; cdecl; external avutil_dll;
(* *
* Ensure that the frame data is writable, avoiding data copy if possible.
*
* Do nothing if the frame is writable, allocate new buffers and copy the data
* if it is not.
*
* @return 0 on success, a negative AVERROR on error.
*
* @see av_frame_is_writable(), av_buffer_is_writable(),
* av_buffer_make_writable()
*)
// int av_frame_make_writable(AVFrame *frame);
function av_frame_make_writable(frame: pAVFrame): int; cdecl; external avutil_dll;
(* *
* Copy the frame data from src to dst.
*
* This function does not allocate anything, dst must be already initialized and
* allocated with the same parameters as src.
*
* This function only copies the frame data (i.e. the contents of the data /
* extended data arrays), not any other properties.
*
* @return >= 0 on success, a negative AVERROR on error.
*)
// int av_frame_copy(AVFrame *dst, const AVFrame *src);
function av_frame_copy(dst: pAVFrame; const src: pAVFrame): int; cdecl; external avutil_dll;
(* *
* Copy only "metadata" fields from src to dst.
*
* Metadata for the purpose of this function are those fields that do not affect
* the data layout in the buffers. E.g. pts, sample rate (for audio) or sample
* aspect ratio (for video), but not width/height or channel layout.
* Side data is also copied.
*)
// int av_frame_copy_props(AVFrame *dst, const AVFrame *src);
function av_frame_copy_props(dst: pAVFrame; const src: pAVFrame): int; cdecl; external avutil_dll;
(* *
* Get the buffer reference a given data plane is stored in.
*
* @param plane index of the data plane of interest in frame->extended_data.
*
* @return the buffer reference that contains the plane or NULL if the input
* frame is not valid.
*)
// AVBufferRef *av_frame_get_plane_buffer(AVFrame *frame, int plane);
function av_frame_get_plane_buffer(frame: pAVFrame; plane: int): pAVBufferRef; cdecl; external avutil_dll;
(* *
* Add a new side data to a frame.
*
* @param frame a frame to which the side data should be added
* @param type type of the added side data
* @param size size of the side data
*
* @return newly added side data on success, NULL on error
*)
// AVFrameSideData *av_frame_new_side_data(AVFrame *frame,
// enum AVFrameSideDataType type,
// int size);
function av_frame_new_side_data(frame: AVFrame; _type: AVFrameSideDataType; size: int): pAVFrameSideData; cdecl; external avutil_dll;
(* *
* Add a new side data to a frame from an existing AVBufferRef
*
* @param frame a frame to which the side data should be added
* @param type the type of the added side data
* @param buf an AVBufferRef to add as side data. The ownership of
* the reference is transferred to the frame.
*
* @return newly added side data on success, NULL on error. On failure
* the frame is unchanged and the AVBufferRef remains owned by
* the caller.
*)
// AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame,
// enum AVFrameSideDataType type,
// AVBufferRef *buf);
function av_frame_new_side_data_from_buf(frame: pAVFrame; _type: AVFrameSideDataType; buf: pAVBufferRef): pAVFrameSideData; cdecl; external avutil_dll;
(* *
* @return a pointer to the side data of a given type on success, NULL if there
* is no side data with such type in this frame.
*)
// AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,
// enum AVFrameSideDataType type);
function av_frame_get_side_data(const frame: pAVFrame; _type: AVFrameSideDataType): pAVFrameSideData; cdecl; external avutil_dll;
(* *
* If side data of the supplied type exists in the frame, free it and remove it
* from the frame.
*)
// void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type);
procedure av_frame_remove_side_data(frame: pAVFrame; _type: AVFrameSideDataType); cdecl; external avutil_dll;
const
(* *
* Flags for frame cropping.
*)
(* *
* Apply the maximum possible cropping, even if it requires setting the
* AVFrame.data[] entries to unaligned pointers. Passing unaligned data
* to FFmpeg API is generally not allowed, and causes undefined behavior
* (such as crashes). You can pass unaligned data only to FFmpeg APIs that
* are explicitly documented to accept it. Use this flag only if you
* absolutely know what you are doing.
*)
AV_FRAME_CROP_UNALIGNED = 1 shl 0;
(* *
* Crop the given video AVFrame according to its crop_left/crop_top/crop_right/
* crop_bottom fields. If cropping is successful, the function will adjust the
* data pointers and the width/height fields, and set the crop fields to 0.
*
* In all cases, the cropping boundaries will be rounded to the inherent
* alignment of the pixel format. In some cases, such as for opaque hwaccel
* formats, the left/top cropping is ignored. The crop fields are set to 0 even
* if the cropping was rounded or ignored.
*
* @param frame the frame which should be cropped
* @param flags Some combination of AV_FRAME_CROP_* flags, or 0.
*
* @return >= 0 on success, a negative AVERROR on error. If the cropping fields
* were invalid, AVERROR(ERANGE) is returned, and nothing is changed.
*)
// int av_frame_apply_cropping(AVFrame *frame, int flags);
function av_frame_apply_cropping(frame: pAVFrame; flags: int): int; cdecl; external avutil_dll;
(* *
* @return a string identifying the side data type
*)
// const char *av_frame_side_data_name(enum AVFrameSideDataType type);
function av_frame_side_data_name(_type: AVFrameSideDataType): PAnsiChar; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'framequeue.h'}
type
pFFFrameBucket = ^FFFrameBucket;
FFFrameBucket = record
frame: pAVFrame;
end;
(* *
* Structure to hold global options and statistics for frame queues.
*
* This structure is intended to allow implementing global control of the
* frame queues, including memory consumption caps.
*
* It is currently empty.
*)
pFFFrameQueueGlobal = ^FFFrameQueueGlobal;
FFFrameQueueGlobal = record
dummy: AnsiChar; (* C does not allow empty structs *)
end;
(* *
* Queue of AVFrame pointers.
*)
pFFFrameQueue = ^FFFrameQueue;
FFFrameQueue = record
(* *
* Array of allocated buckets, used as a circular buffer.
*)
queue: pFFFrameBucket;
(* *
* Size of the array of buckets.
*)
allocated: size_t;
(* *
* Tail of the queue.
* It is the index in the array of the next frame to take.
*)
tail: size_t;
(* *
* Number of currently queued frames.
*)
queued: size_t;
(* *
* Pre-allocated bucket for queues of size 1.
*)
first_bucket: FFFrameBucket;
(* *
* Total number of frames entered in the queue.
*)
total_frames_head: uint64_t;
(* *
* Total number of frames dequeued from the queue.
* queued = total_frames_head - total_frames_tail
*)
total_frames_tail: uint64_t;
(* *
* Total number of samples entered in the queue.
*)
total_samples_head: uint64_t;
(* *
* Total number of samples dequeued from the queue.
* queued_samples = total_samples_head - total_samples_tail
*)
total_samples_tail: uint64_t;
(* *
* Indicate that samples are skipped
*)
samples_skipped: int;
end;
{$ENDREGION}
{$REGION 'opt.h'}
Type
AVOptionType = ( //
AV_OPT_TYPE_FLAGS, AV_OPT_TYPE_INT, AV_OPT_TYPE_INT64, AV_OPT_TYPE_DOUBLE, AV_OPT_TYPE_FLOAT, AV_OPT_TYPE_STRING, AV_OPT_TYPE_RATIONAL, AV_OPT_TYPE_BINARY,
// < offset must point to a pointer immediately followed by an int for the length
AV_OPT_TYPE_DICT, AV_OPT_TYPE_UINT64, AV_OPT_TYPE_CONST, AV_OPT_TYPE_IMAGE_SIZE,
// < offset must point to two consecutive integers
AV_OPT_TYPE_PIXEL_FMT, AV_OPT_TYPE_SAMPLE_FMT, AV_OPT_TYPE_VIDEO_RATE,
// < offset must point to AVRational
AV_OPT_TYPE_DURATION, AV_OPT_TYPE_COLOR, AV_OPT_TYPE_CHANNEL_LAYOUT, AV_OPT_TYPE_BOOL);
(* *
* AVOption
*)
Tdefault_val = record
case int of
0:
(i64: int64_t);
1:
(dbl: double);
2:
(str: PAnsiChar);
(* TODO those are unused now *)
3:
(q: AVRational);
end;
AVOption = record
// const char *name;
name: PAnsiChar;
(* *
* short English help text
* @todo What about other languages?
*)
// const char *help;
help: PAnsiChar;
(* *
* The offset relative to the context structure where the option
* value is stored. It should be 0 for named constants.
*)
// int offset;
offset: int;
// enum AVOptionType type;
_type: AVOptionType;
(* *
* the default value for scalar options
*)
default_val: Tdefault_val;
min: double;
// < minimum valid value for the option
max: double;
// < maximum valid value for the option
flags: int;
(* *
* The logical unit to which the option belongs. Non-constant
* options and corresponding named constants share the same
* unit. May be NULL.
*)
// const char *unit;
_unit: PAnsiChar;
end;
pAVOption = ^AVOption;
(* *
* A single allowed range of values, or a single allowed value.
*)
AVOptionRange = record
// const char *str;
str: PAnsiChar;
(* *
* Value range.
* For string ranges this represents the min/max length.
* For dimensions this represents the min/max pixel count or width/height in multi-component case.
*)
value_min, value_max: double;
(* *
* Value's component range.
* For string this represents the unicode range for chars, 0-127 limits to ASCII.
*)
component_min, component_max: double;
(* *
* Range flag.
* If set to 1 the struct encodes a range, if set to 0 a single value.
*)
is_range: int;
end;
pAVOptionRange = ^AVOptionRange;
ppAVOptionRange = ^pAVOptionRange;
(* *
* List of AVOptionRange structs.
*)
AVOptionRanges = record
(* *
* Array of option ranges.
*
* Most of option types use just one component.
* Following describes multi-component option types:
*
* AV_OPT_TYPE_IMAGE_SIZE:
* component index 0: range of pixel count (width * height).
* component index 1: range of width.
* component index 2: range of height.
*
* @note To obtain multi-component version of this structure, user must
* provide AV_OPT_MULTI_COMPONENT_RANGE to av_opt_query_ranges or
* av_opt_query_ranges_default function.
*
* Multi-component range can be read as in following example:
*
* @code
* int range_index, component_index;
* AVOptionRanges *ranges;
* AVOptionRange *range[3]; //may require more than 3 in the future.
* av_opt_query_ranges(&ranges, obj, key, AV_OPT_MULTI_COMPONENT_RANGE);
* for (range_index = 0; range_index < ranges->nb_ranges; range_index++) {
* for (component_index = 0; component_index < ranges->nb_components; component_index++)
* range[component_index] = ranges->range[ranges->nb_ranges * component_index + range_index];
* //do something with range here.
* }
* av_opt_freep_ranges(&ranges);
* @endcode
*)
// AVOptionRange **range;
range: ppAVOptionRange;
(* *
* Number of ranges per component.
*)
nb_ranges: int;
(* *
* Number of componentes.
*)
nb_components: int;
end;
pAVOptionRanges = ^AVOptionRanges;
const
AV_OPT_FLAG_ENCODING_PARAM = 1;
// < a generic parameter which can be set by the user for muxing or encoding
AV_OPT_FLAG_DECODING_PARAM = 2;
// < a generic parameter which can be set by the user for demuxing or decoding
AV_OPT_FLAG_AUDIO_PARAM = 8;
AV_OPT_FLAG_VIDEO_PARAM = 16;
AV_OPT_FLAG_SUBTITLE_PARAM = 32;
(* *
* The option is intended for exporting values to the caller.
*)
AV_OPT_FLAG_EXPORT = 64;
(* *
* The option may not be set through the AVOptions API, only read.
* This flag only makes sense when AV_OPT_FLAG_EXPORT is also set.
*)
AV_OPT_FLAG_READONLY = 128;
AV_OPT_FLAG_BSF_PARAM = (1 shl 8);
// < a generic parameter which can be set by the user for bit stream filtering
AV_OPT_FLAG_FILTERING_PARAM = (1 shl 16);
{$ENDREGION}
{$REGION 'log.h'}
type
AVClassCategory = ( //
AV_CLASS_CATEGORY_NA = 0, //
AV_CLASS_CATEGORY_INPUT, //
AV_CLASS_CATEGORY_OUTPUT, //
AV_CLASS_CATEGORY_MUXER, //
AV_CLASS_CATEGORY_DEMUXER, //
AV_CLASS_CATEGORY_ENCODER, //
AV_CLASS_CATEGORY_DECODER, //
AV_CLASS_CATEGORY_FILTER, //
AV_CLASS_CATEGORY_BITSTREAM_FILTER, //
AV_CLASS_CATEGORY_SWSCALER, //
AV_CLASS_CATEGORY_SWRESAMPLER, //
AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT = 40, //
AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT, //
AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT, //
AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT, //
AV_CLASS_CATEGORY_DEVICE_OUTPUT, //
AV_CLASS_CATEGORY_DEVICE_INPUT, //
AV_CLASS_CATEGORY_NB
// < not part of ABI/API
);
pAVClassCategory = ^AVClassCategory;
// #define AV_IS_INPUT_DEVICE(category) \
// (((category) == AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT) || \
// ((category) == AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT) || \
// ((category) == AV_CLASS_CATEGORY_DEVICE_INPUT))
//
// #define AV_IS_OUTPUT_DEVICE(category) \
// (((category) == AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT) || \
// ((category) == AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT) || \
// ((category) == AV_CLASS_CATEGORY_DEVICE_OUTPUT))
// struct AVOptionRanges;
// AVOptionRanges = record
// end;
// pAVOptionRanges = ^AVOptionRanges;
(* *
* Describe the class of an AVClass context structure. That is an
* arbitrary struct of which the first field is a pointer to an
* AVClass struct (e.g. AVCodecContext, AVFormatContext etc.).
*)
pAVClass = ^avclass;
avclass = record
(* *
* The name of the class; usually it is the same name as the
* context structure type to which the AVClass is associated.
*)
// const char* class_name;
class_name: PAnsiChar;
(* *
* A pointer to a function which returns the name of a context
* instance ctx associated with the class.
*)
// const char* (*item_name)(void* ctx);
item_name: function(ctx: Pointer): PAnsiChar; cdecl;
(* *
* a pointer to the first option specified in the class if any or NULL
*
* @see av_set_default_options()
*)
// const struct AVOption *option;
option: pAVOption;
(* *
* LIBAVUTIL_VERSION with which this structure was created.
* This is used to allow fields to be added without requiring major
* version bumps everywhere.
*)
version: int;
(* *
* Offset in the structure where log_level_offset is stored.
* 0 means there is no such variable
*)
log_level_offset_offset: int;
(* *
* Offset in the structure where a pointer to the parent context for
* logging is stored. For example a decoder could pass its AVCodecContext
* to eval as such a parent context, which an av_log() implementation
* could then leverage to display the parent context.
* The offset can be NULL.
*)
parent_log_context_offset: int;
(* *
* Return next AVOptions-enabled child or NULL
*)
// void * (* child_next)(void *obj, void *prev);
child_next: function(obj: Pointer; prev: Pointer): Pointer; cdecl;
(* *
* Return an AVClass corresponding to the next potential
* AVOptions-enabled child.
*
* The difference between child_next and this is that
* child_next iterates over _already existing_ objects, while
* child_class_next iterates over _all possible_ children.
*)
// const struct AVClass* (*child_class_next)(const struct AVClass *prev);
child_class_next: function(const prev: pAVClass): pAVClass; cdecl;
(* *
* Category used for visualization (like color)
* This is only set if the category is equal for all objects using this class.
* available since version (51 shl 16 | 56 shl 8 | 100)
*)
category: AVClassCategory;
(* *
* Callback to return the category.
* available since version (51 shl 16 | 59 shl 8 | 100)
*)
// AVClassCategory (*get_category)(void* ctx);
get_category: function(ctx: Pointer): pAVClassCategory; cdecl;
(* *
* Callback to return the supported/allowed ranges.
* available since version (52.12)
*)
// int (*query_ranges)(struct AVOptionRanges **, void *obj, const char *key, int flags);
query_ranges: function(var ranges: pAVOptionRanges; obj: Pointer; const key: PAnsiChar; flags: int): int; cdecl;
end;
PVA_LIST = ^VA_LIST;
VA_LIST = array [0 .. 0] of Pointer;
(* *
* Print no output.
*)
const
AV_LOG_QUIET = -8;
(* *
* Something went really wrong and we will crash now.
*)
AV_LOG_PANIC = 0;
(* *
* Something went wrong and recovery is not possible.
* For example, no header was found for a format which depends
* on headers or an illegal combination of parameters is used.
*)
AV_LOG_FATAL = 8;
(* *
* Something went wrong and cannot losslessly be recovered.
* However, not all future data is affected.
*)
AV_LOG_ERROR = 16;
(* *
* Something somehow does not look correct. This may or may not
* lead to problems. An example would be the use of '-vstrict -2'.
*)
AV_LOG_WARNING = 24;
(* *
* Standard information.
*)
AV_LOG_INFO = 32;
(* *
* Detailed information.
*)
AV_LOG_VERBOSE = 40;
(* *
* Stuff which is only useful for libav* developers.
*)
AV_LOG_DEBUG = 48;
(* *
* Extremely verbose debugging, useful for libav* development.
*)
AV_LOG_TRACE = 56;
AV_LOG_MAX_OFFSET = (AV_LOG_TRACE - AV_LOG_QUIET);
{$ENDREGION}
{$REGION 'samplefmt.h'}
type
pAVSampleFormat = ^AVSampleFormat;
AVSampleFormat = ( //
AV_SAMPLE_FMT_NONE = -1, //
AV_SAMPLE_FMT_U8,
// < unsigned 8 bits
AV_SAMPLE_FMT_S16,
// < signed 16 bits
AV_SAMPLE_FMT_S32,
// < signed 32 bits
AV_SAMPLE_FMT_FLT,
// < float
AV_SAMPLE_FMT_DBL,
// < double
AV_SAMPLE_FMT_U8P,
// < unsigned 8 bits, planar
AV_SAMPLE_FMT_S16P,
// < signed 16 bits, planar
AV_SAMPLE_FMT_S32P,
// < signed 32 bits, planar
AV_SAMPLE_FMT_FLTP,
// < float, planar
AV_SAMPLE_FMT_DBLP,
// < double, planar
AV_SAMPLE_FMT_S64,
// < signed 64 bits
AV_SAMPLE_FMT_S64P,
// < signed 64 bits, planar
AV_SAMPLE_FMT_NB
// < Number of sample formats. DO NOT USE if linking dynamically
);
(* *
* Return the name of sample_fmt, or NULL if sample_fmt is not
* recognized.
*)
// const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt);
function av_get_sample_fmt_name(sample_fmt: AVSampleFormat): PAnsiChar; cdecl; external avutil_dll;
(* *
* Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE
* on error.
*)
// enum AVSampleFormat av_get_sample_fmt(const char *name);
function av_get_sample_fmt(const name: PAnsiChar): AVSampleFormat; cdecl; external avutil_dll;
(* *
* Return the planar<->packed alternative form of the given sample format, or
* AV_SAMPLE_FMT_NONE on error. If the passed sample_fmt is already in the
* requested planar/packed format, the format returned is the same as the
* input.
*)
// enum AVSampleFormat av_get_alt_sample_fmt(enum AVSampleFormat sample_fmt, int planar);
function av_get_alt_sample_fmt(sample_fmt: AVSampleFormat; planar: int): AVSampleFormat; cdecl; external avutil_dll;
(* *
* Get the packed alternative form of the given sample format.
*
* If the passed sample_fmt is already in packed format, the format returned is
* the same as the input.
*
* @return the packed alternative form of the given sample format or
AV_SAMPLE_FMT_NONE on error.
*)
// enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt);
function av_get_packed_sample_fmt(sample_fmt: AVSampleFormat): AVSampleFormat; cdecl; external avutil_dll;
(* *
* Get the planar alternative form of the given sample format.
*
* If the passed sample_fmt is already in planar format, the format returned is
* the same as the input.
*
* @return the planar alternative form of the given sample format or
AV_SAMPLE_FMT_NONE on error.
*)
// enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt);
function av_get_planar_sample_fmt(sample_fmt: AVSampleFormat): AVSampleFormat; cdecl; external avutil_dll;
(* *
* Generate a string corresponding to the sample format with
* sample_fmt, or a header if sample_fmt is negative.
*
* @param buf the buffer where to write the string
* @param buf_size the size of buf
* @param sample_fmt the number of the sample format to print the
* corresponding info string, or a negative value to print the
* corresponding header.
* @return the pointer to the filled buffer or NULL if sample_fmt is
* unknown or in case of other errors
*)
// char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt);
function av_get_sample_fmt_string(buf: PAnsiChar; buf_size: int; sample_fmt: AVSampleFormat): PAnsiChar; cdecl; external avutil_dll;
(* *
* Return number of bytes per sample.
*
* @param sample_fmt the sample format
* @return number of bytes per sample or zero if unknown for the given
* sample format
*)
// int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt);
function av_get_bytes_per_sample(sample_fmt: AVSampleFormat): int; cdecl; external avutil_dll;
(* *
* Check if the sample format is planar.
*
* @param sample_fmt the sample format to inspect
* @return 1 if the sample format is planar, 0 if it is interleaved
*)
// int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt);
function av_sample_fmt_is_planar(sample_fmt: AVSampleFormat): int; cdecl; external avutil_dll;
(* *
* Get the required buffer size for the given audio parameters.
*
* @param[out] linesize calculated linesize, may be NULL
* @param nb_channels the number of channels
* @param nb_samples the number of samples in a single channel
* @param sample_fmt the sample format
* @param align buffer size alignment (0 = default, 1 = no alignment)
* @return required buffer size, or negative error code on failure
*)
// int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples,
// enum AVSampleFormat sample_fmt, int align);
function av_samples_get_buffer_size(var linesize: int; nb_channels: int; nb_samples: int; sample_fmt: AVSampleFormat; align: int): int; cdecl;
external avutil_dll;
(* *
* @}
*
* @defgroup lavu_sampmanip Samples manipulation
*
* Functions that manipulate audio samples
* @{
*)
(* *
* Fill plane data pointers and linesize for samples with sample
* format sample_fmt.
*
* The audio_data array is filled with the pointers to the samples data planes:
* for planar, set the start point of each channel's data within the buffer,
* for packed, set the start point of the entire buffer only.
*
* The value pointed to by linesize is set to the aligned size of each
* channel's data buffer for planar layout, or to the aligned size of the
* buffer for all channels for packed layout.
*
* The buffer in buf must be big enough to contain all the samples
* (use av_samples_get_buffer_size() to compute its minimum size),
* otherwise the audio_data pointers will point to invalid data.
*
* @see enum AVSampleFormat
* The documentation for AVSampleFormat describes the data layout.
*
* @param[out] audio_data array to be filled with the pointer for each channel
* @param[out] linesize calculated linesize, may be NULL
* @param buf the pointer to a buffer containing the samples
* @param nb_channels the number of channels
* @param nb_samples the number of samples in a single channel
* @param sample_fmt the sample format
* @param align buffer size alignment (0 = default, 1 = no alignment)
* @return >=0 on success or a negative error code on failure
* @todo return minimum size in bytes required for the buffer in case
* of success at the next bump
*)
// int av_samples_fill_arrays(uint8_t **audio_data, int *linesize,
// const uint8_t *buf,
// int nb_channels, int nb_samples,
// enum AVSampleFormat sample_fmt, int align);
function av_samples_fill_arrays(var audio_data: puint8_t; var linesize: int; const buf: puint8_t; nb_channels: int; nb_samples: int; sample_fmt: AVSampleFormat;
align: int): int; cdecl; external avutil_dll;
(* *
* Allocate a samples buffer for nb_samples samples, and fill data pointers and
* linesize accordingly.
* The allocated samples buffer can be freed by using av_freep(&audio_data[0])
* Allocated data will be initialized to silence.
*
* @see enum AVSampleFormat
* The documentation for AVSampleFormat describes the data layout.
*
* @param[out] audio_data array to be filled with the pointer for each channel
* @param[out] linesize aligned size for audio buffer(s), may be NULL
* @param nb_channels number of audio channels
* @param nb_samples number of samples per channel
* @param align buffer size alignment (0 = default, 1 = no alignment)
* @return >=0 on success or a negative error code on failure
* @todo return the size of the allocated buffer in case of success at the next bump
* @see av_samples_fill_arrays()
* @see av_samples_alloc_array_and_samples()
*)
// int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels,
// int nb_samples, enum AVSampleFormat sample_fmt, int align);
function av_samples_alloc(var audio_data: puint8_t; linesize: pint; nb_channels: int; nb_samples: int; sample_fmt: AVSampleFormat; align: int): int; cdecl;
external avutil_dll;
(* *
* Allocate a data pointers array, samples buffer for nb_samples
* samples, and fill data pointers and linesize accordingly.
*
* This is the same as av_samples_alloc(), but also allocates the data
* pointers array.
*
* @see av_samples_alloc()
*)
// int av_samples_alloc_array_and_samples(uint8_t ***audio_data, int *linesize, int nb_channels,
// int nb_samples, enum AVSampleFormat sample_fmt, int align);
function av_samples_alloc_array_and_samples(Var audio_data: ppuint8_t; var linesize: int; nb_channels: int; nb_samples: int; sample_fmt: AVSampleFormat;
align: int): int; cdecl; external avutil_dll;
(* *
* Copy samples from src to dst.
*
* @param dst destination array of pointers to data planes
* @param src source array of pointers to data planes
* @param dst_offset offset in samples at which the data will be written to dst
* @param src_offset offset in samples at which the data will be read from src
* @param nb_samples number of samples to be copied
* @param nb_channels number of audio channels
* @param sample_fmt audio sample format
*)
// int av_samples_copy(uint8_t **dst, uint8_t * const *src, int dst_offset,
// int src_offset, int nb_samples, int nb_channels,
// enum AVSampleFormat sample_fmt);
function av_samples_copy(var dst: puint8_t; const src: ppuint8_t; dst_offset: int; src_offset: int; nb_samples: int; nb_channels: int;
sample_fmt: AVSampleFormat): int; cdecl; external avutil_dll;
(* *
* Fill an audio buffer with silence.
*
* @param audio_data array of pointers to data planes
* @param offset offset in samples at which to start filling
* @param nb_samples number of samples to fill
* @param nb_channels number of audio channels
* @param sample_fmt audio sample format
*)
// int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples,
// int nb_channels, enum AVSampleFormat sample_fmt);
function av_samples_set_silence(var audio_data: puint8_t; offset: int; nb_samples: int; nb_channels: int; sample_fmt: AVSampleFormat): int; cdecl;
external avutil_dll;
{$ENDREGION}
{$REGION 'opt.h'}
(* *
* Show the obj options.
*
* @param req_flags requested flags for the options to show. Show only the
* options for which it is opt->flags & req_flags.
* @param rej_flags rejected flags for the options to show. Show only the
* options for which it is !(opt->flags & req_flags).
* @param av_log_obj log context to use for showing the options
*)
// int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags);
function av_opt_show2(obj, av_log_obj: Pointer; req_flags, rej_flags: int): int; cdecl; external avutil_dll;
(* *
* Set the values of all AVOption fields to their default values.
*
* @param s an AVOption-enabled struct (its first member must be a pointer to AVClass)
*)
// void av_opt_set_defaults(void *s);
procedure av_opt_set_defaults(s: Pointer); cdecl; external avutil_dll;
(* *
* Set the values of all AVOption fields to their default values. Only these
* AVOption fields for which (opt->flags & mask) == flags will have their
* default applied to s.
*
* @param s an AVOption-enabled struct (its first member must be a pointer to AVClass)
* @param mask combination of AV_OPT_FLAG_*
* @param flags combination of AV_OPT_FLAG_*
*)
// void av_opt_set_defaults2(void *s, int mask, int flags);
procedure av_opt_set_defaults2(s: Pointer; mask, flags: int); cdecl; external avutil_dll;
(* *
* Parse the key/value pairs list in opts. For each key/value pair
* found, stores the value in the field in ctx that is named like the
* key. ctx must be an AVClass context, storing is done using
* AVOptions.
*
* @param opts options string to parse, may be NULL
* @param key_val_sep a 0-terminated list of characters used to
* separate key from value
* @param pairs_sep a 0-terminated list of characters used to separate
* two pairs from each other
* @return the number of successfully set key/value pairs, or a negative
* value corresponding to an AVERROR code in case of error:
* AVERROR(EINVAL) if opts cannot be parsed,
* the error code issued by av_opt_set() if a key/value pair
* cannot be set
*)
// int av_set_options_string(void *ctx, const char *opts,
// const char *key_val_sep, const char *pairs_sep);
function av_set_options_string(ctx: Pointer; const opts: PAnsiChar; const key_val_sep: PAnsiChar; const pairs_sep: PAnsiChar): int; cdecl; external avutil_dll;
(* *
* Parse the key-value pairs list in opts. For each key=value pair found,
* set the value of the corresponding option in ctx.
*
* @param ctx the AVClass object to set options on
* @param opts the options string, key-value pairs separated by a
* delimiter
* @param shorthand a NULL-terminated array of options names for shorthand
* notation: if the first field in opts has no key part,
* the key is taken from the first element of shorthand;
* then again for the second, etc., until either opts is
* finished, shorthand is finished or a named option is
* found; after that, all options must be named
* @param key_val_sep a 0-terminated list of characters used to separate
* key from value, for example '='
* @param pairs_sep a 0-terminated list of characters used to separate
* two pairs from each other, for example ':' or ','
* @return the number of successfully set key=value pairs, or a negative
* value corresponding to an AVERROR code in case of error:
* AVERROR(EINVAL) if opts cannot be parsed,
* the error code issued by av_set_string3() if a key/value pair
* cannot be set
*
* Options names must use only the following characters: a-z A-Z 0-9 - . / _
* Separators must use characters distinct from option names and from each
* other.
*)
// int av_opt_set_from_string(void *ctx, const char *opts,
// const char *const *shorthand,
// const char *key_val_sep, const char *pairs_sep);
function av_opt_set_from_string(ctx: Pointer; const opts: PAnsiChar; const shorthand: ppAnsiChar; const key_val_sep: PAnsiChar; const pairs_sep: PAnsiChar)
: int; cdecl; external avutil_dll;
(* *
* Free all allocated objects in obj.
*)
// void av_opt_free(void *obj);
procedure av_opt_free(obj: Pointer); cdecl; external avutil_dll;
(* *
* Check whether a particular flag is set in a flags field.
*
* @param field_name the name of the flag field option
* @param flag_name the name of the flag to check
* @return non-zero if the flag is set, zero if the flag isn't set,
* isn't of the right type, or the flags field doesn't exist.
*)
// int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name);
function av_opt_flag_is_set(obj: Pointer; const field_name: PAnsiChar; const flag_name: PAnsiChar): int; cdecl; external avutil_dll;
(* *
* Set all the options from a given dictionary on an object.
*
* @param obj a struct whose first element is a pointer to AVClass
* @param options options to process. This dictionary will be freed and replaced
* by a new one containing all options not found in obj.
* Of course this new dictionary needs to be freed by caller
* with av_dict_free().
*
* @return 0 on success, a negative AVERROR if some option was found in obj,
* but could not be set.
*
* @see av_dict_copy()
*)
// int av_opt_set_dict(void *obj, struct AVDictionary **options);
function av_opt_set_dict(obj: Pointer; var options: pAVDictionary): int; cdecl; external avutil_dll;
(* *
* Set all the options from a given dictionary on an object.
*
* @param obj a struct whose first element is a pointer to AVClass
* @param options options to process. This dictionary will be freed and replaced
* by a new one containing all options not found in obj.
* Of course this new dictionary needs to be freed by caller
* with av_dict_free().
* @param search_flags A combination of AV_OPT_SEARCH_*.
*
* @return 0 on success, a negative AVERROR if some option was found in obj,
* but could not be set.
*
* @see av_dict_copy()
*)
// int av_opt_set_dict2(void *obj, struct AVDictionary **options, int search_flags);
function av_opt_set_dict2(obj: Pointer; Var options: pAVDictionary; search_flags: int): int; cdecl; external avutil_dll;
(* *
* Extract a key-value pair from the beginning of a string.
*
* @param ropts pointer to the options string, will be updated to
* point to the rest of the string (one of the pairs_sep
* or the final NUL)
* @param key_val_sep a 0-terminated list of characters used to separate
* key from value, for example '='
* @param pairs_sep a 0-terminated list of characters used to separate
* two pairs from each other, for example ':' or ','
* @param flags flags; see the AV_OPT_FLAG_* values below
* @param rkey parsed key; must be freed using av_free()
* @param rval parsed value; must be freed using av_free()
*
* @return >=0 for success, or a negative value corresponding to an
* AVERROR code in case of error; in particular:
* AVERROR(EINVAL) if no key is present
*
*)
// int av_opt_get_key_value(const char **ropts,
// const char *key_val_sep, const char *pairs_sep,
// unsigned flags,
// char **rkey, char **rval);
function av_opt_get_key_value(const ropts: ppAnsiChar; const key_val_sep: PAnsiChar; const pairs_sep: PAnsiChar; flags: unsigned; rkey: ppAnsiChar;
rval: ppAnsiChar): int; cdecl; external avutil_dll;
(* *
* Accept to parse a value without a key; the key will then be returned
* as NULL.
*)
const
AV_OPT_FLAG_IMPLICIT_KEY = 1;
(* *
* @defgroup opt_eval_funcs Evaluating option strings
* @{
* This group of functions can be used to evaluate option strings
* and get numbers out of them. They do the same thing as av_opt_set(),
* except the result is written into the caller-supplied pointer.
*
* @param obj a struct whose first element is a pointer to AVClass.
* @param o an option for which the string is to be evaluated.
* @param val string to be evaluated.
* @param *_out value of the string will be written here.
*
* @return 0 on success, a negative number on failure.
*)
// int av_opt_eval_flags (void *obj, const AVOption *o, const char *val, int *flags_out);
function av_opt_eval_flags(obj: Pointer; const o: pAVOption; const val: PAnsiChar; var flags_out: int): int; cdecl; external avutil_dll;
// int av_opt_eval_int (void *obj, const AVOption *o, const char *val, int *int_out);
// int av_opt_eval_int64 (void *obj, const AVOption *o, const char *val, int64_t *int64_out);
// int av_opt_eval_float (void *obj, const AVOption *o, const char *val, float *float_out);
// int av_opt_eval_double(void *obj, const AVOption *o, const char *val, double *double_out);
// int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational *q_out);
(* *
* @}
*)
const
AV_OPT_SEARCH_CHILDREN = (1 shl 0); (* *< Search in possible children of the
given object first. *)
(* *
* The obj passed to av_opt_find() is fake -- only a double pointer to AVClass
* instead of a required pointer to a struct containing AVClass. This is
* useful for searching for options without needing to allocate the corresponding
* object.
*)
AV_OPT_SEARCH_FAKE_OBJ = (1 shl 1);
(* *
* In av_opt_get, return NULL if the option has a pointer type and is set to NULL,
* rather than returning an empty string.
*)
AV_OPT_ALLOW_NULL = (1 shl 2);
(* *
* Allows av_opt_query_ranges and av_opt_query_ranges_default to return more than
* one component for certain option types.
* @see AVOptionRanges for details.
*)
AV_OPT_MULTI_COMPONENT_RANGE = (1 shl 12);
(* *
* Look for an option in an object. Consider only options which
* have all the specified flags set.
*
* @param[in] obj A pointer to a struct whose first element is a
* pointer to an AVClass.
* Alternatively a double pointer to an AVClass, if
* AV_OPT_SEARCH_FAKE_OBJ search flag is set.
* @param[in] name The name of the option to look for.
* @param[in] unit When searching for named constants, name of the unit
* it belongs to.
* @param opt_flags Find only options with all the specified flags set (AV_OPT_FLAG).
* @param search_flags A combination of AV_OPT_SEARCH_*.
*
* @return A pointer to the option found, or NULL if no option
* was found.
*
* @note Options found with AV_OPT_SEARCH_CHILDREN flag may not be settable
* directly with av_opt_set(). Use special calls which take an options
* AVDictionary (e.g. avformat_open_input()) to set options found with this
* flag.
*)
// const AVOption *av_opt_find(void *obj, const char *name, const char *unit,
// int opt_flags, int search_flags);
function av_opt_find(obj: Pointer; const name: PAnsiChar; const _unit: PAnsiChar; opt_flags: int; search_flags: int): pAVOption; cdecl; external avutil_dll;
(* *
* Look for an option in an object. Consider only options which
* have all the specified flags set.
*
* @param[in] obj A pointer to a struct whose first element is a
* pointer to an AVClass.
* Alternatively a double pointer to an AVClass, if
* AV_OPT_SEARCH_FAKE_OBJ search flag is set.
* @param[in] name The name of the option to look for.
* @param[in] unit When searching for named constants, name of the unit
* it belongs to.
* @param opt_flags Find only options with all the specified flags set (AV_OPT_FLAG).
* @param search_flags A combination of AV_OPT_SEARCH_*.
* @param[out] target_obj if non-NULL, an object to which the option belongs will be
* written here. It may be different from obj if AV_OPT_SEARCH_CHILDREN is present
* in search_flags. This parameter is ignored if search_flags contain
* AV_OPT_SEARCH_FAKE_OBJ.
*
* @return A pointer to the option found, or NULL if no option
* was found.
*)
// const AVOption *av_opt_find2(void *obj, const char *name, const char *unit,
// int opt_flags, int search_flags, void **target_obj);
function av_opt_find2(obj: Pointer; const name: PAnsiChar; const _unit: PAnsiChar; opt_flags: int; search_flags: int; Var target_obj: Pointer): pAVOption;
cdecl; external avutil_dll;
(* *
* Iterate over all AVOptions belonging to obj.
*
* @param obj an AVOptions-enabled struct or a double pointer to an
* AVClass describing it.
* @param prev result of the previous call to av_opt_next() on this object
* or NULL
* @return next AVOption or NULL
*)
// const AVOption *av_opt_next(const void *obj, const AVOption *prev);
function av_opt_next(const obj: Pointer; const prev: pAVOption): pAVOption; cdecl; external avutil_dll;
(* *
* Iterate over AVOptions-enabled children of obj.
*
* @param prev result of a previous call to this function or NULL
* @return next AVOptions-enabled child or NULL
*)
// void *av_opt_child_next(void *obj, void *prev);
function av_opt_child_next(obj: Pointer; prev: Pointer): Pointer; cdecl; external avutil_dll;
(* *
* Iterate over potential AVOptions-enabled children of parent.
*
* @param prev result of a previous call to this function or NULL
* @return AVClass corresponding to next potential child or NULL
*)
// const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *prev);
function av_opt_child_class_next(const parent: pAVClass; const prev: pAVClass): pAVClass; cdecl; external avutil_dll;
(* *
* @defgroup opt_set_funcs Option setting functions
* @{
* Those functions set the field of obj with the given name to value.
*
* @param[in] obj A struct whose first element is a pointer to an AVClass.
* @param[in] name the name of the field to set
* @param[in] val The value to set. In case of av_opt_set() if the field is not
* of a string type, then the given string is parsed.
* SI postfixes and some named scalars are supported.
* If the field is of a numeric type, it has to be a numeric or named
* scalar. Behavior with more than one scalar and +- infix operators
* is undefined.
* If the field is of a flags type, it has to be a sequence of numeric
* scalars or named flags separated by '+' or '-'. Prefixing a flag
* with '+' causes it to be set without affecting the other flags;
* similarly, '-' unsets a flag.
* @param search_flags flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN
* is passed here, then the option may be set on a child of obj.
*
* @return 0 if the value has been set, or an AVERROR code in case of
* error:
* AVERROR_OPTION_NOT_FOUND if no matching option exists
* AVERROR(ERANGE) if the value is out of range
* AVERROR(EINVAL) if the value is not valid
*)
// int av_opt_set (void *obj, const char *name, const char *val, int search_flags);
function av_opt_set(obj: Pointer; const name: PAnsiChar; const val: PAnsiChar; search_flags: int): int; cdecl; external avutil_dll;
// int av_opt_set_int (void *obj, const char *name, int64_t val, int search_flags);
function av_opt_set_int(obj: Pointer; const name: PAnsiChar; val: int64_t; search_flags: int): int; cdecl; external avutil_dll;
// int av_opt_set_double (void *obj, const char *name, double val, int search_flags);
function av_opt_set_double(obj: Pointer; const name: PAnsiChar; val: double; search_flags: int): int; cdecl; external avutil_dll;
// int av_opt_set_q (void *obj, const char *name, AVRational val, int search_flags);
function av_opt_set_q(obj: Pointer; const name: PAnsiChar; val: AVRational; search_flags: int): int; cdecl; external avutil_dll;
// int av_opt_set_bin (void *obj, const char *name, const uint8_t *val, int size, int search_flags);
function av_opt_set_bin(obj: Pointer; const name: PAnsiChar; const val: puint8_t; size: int; search_flags: int): int; cdecl; external avutil_dll;
// int av_opt_set_image_size(void *obj, const char *name, int w, int h, int search_flags);
function av_opt_set_image_size(obj: Pointer; const name: PAnsiChar; w, h, search_flags: int): int; cdecl; external avutil_dll;
// int av_opt_set_pixel_fmt (void *obj, const char *name, enum AVPixelFormat fmt, int search_flags);
function av_opt_set_pixel_fmt(obj: Pointer; const name: PAnsiChar; fmt: AVPixelFormat; search_flags: int): int; cdecl; external avutil_dll;
// int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags);
function av_opt_set_sample_fmt(obj: Pointer; const name: PAnsiChar; fmt: AVSampleFormat; search_flags: int): int; cdecl; external avutil_dll;
// int av_opt_set_video_rate(void *obj, const char *name, AVRational val, int search_flags);
function av_opt_set_video_rate(obj: Pointer; const name: PAnsiChar; val: AVRational; search_flags: int): int; cdecl; external avutil_dll;
// int av_opt_set_channel_layout(void *obj, const char *name, int64_t ch_layout, int search_flags);
function av_opt_set_channel_layout(obj: Pointer; const name: PAnsiChar; ch_layout: int64_t; search_flags: int): int; cdecl; external avutil_dll;
(* *
* @note Any old dictionary present is discarded and replaced with a copy of the new one. The
* caller still owns val is and responsible for freeing it.
*)
// int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, int search_flags);
function av_opt_set_dict_val(obj: Pointer; const name: PAnsiChar; const val: pAVDictionary; search_flags: int): int; cdecl; external avutil_dll;
(* *
* Set a binary option to an integer list.
*
* @param obj AVClass object to set options on
* @param name name of the binary option
* @param val pointer to an integer list (must have the correct type with
* regard to the contents of the list)
* @param term list terminator (usually 0 or -1)
* @param flags search flags
*)
// #define av_opt_set_int_list(obj, name, val, term, flags) \
// (av_int_list_length(val, term) > INT_MAX / sizeof(*(val)) ? \
// AVERROR(EINVAL) : \
// av_opt_set_bin(obj, name, (const uint8_t *)(val), \
// av_int_list_length(val, term) * sizeof(*(val)), flags))
function av_opt_set_int_list(obj: Pointer; name: PAnsiChar; list: Pointer; item_size: int; term: int64_t; flags: int): Integer; inline;
(* *
* @}
*)
(* *
* @defgroup opt_get_funcs Option getting functions
* @{
* Those functions get a value of the option with the given name from an object.
*
* @param[in] obj a struct whose first element is a pointer to an AVClass.
* @param[in] name name of the option to get.
* @param[in] search_flags flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN
* is passed here, then the option may be found in a child of obj.
* @param[out] out_val value of the option will be written here
* @return >=0 on success, a negative error code otherwise
*)
(* *
* @note the returned string will be av_malloc()ed and must be av_free()ed by the caller
*
* @note if AV_OPT_ALLOW_NULL is set in search_flags in av_opt_get, and the option has
* AV_OPT_TYPE_STRING or AV_OPT_TYPE_BINARY and is set to NULL, *out_val will be set
* to NULL instead of an allocated empty string.
*)
// int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val);
function av_opt_get(obj: Pointer; const name: PAnsiChar; search_flags: int; Var out_val: puint8_t): int; cdecl; external avutil_dll;
// int av_opt_get_int (void *obj, const char *name, int search_flags, int64_t *out_val);
function av_opt_get_int(obj: Pointer; const name: PAnsiChar; search_flags: int; var out_val: int64_t): int; cdecl; external avutil_dll;
// int av_opt_get_double (void *obj, const char *name, int search_flags, double *out_val);
function av_opt_get_double(obj: Pointer; const name: PAnsiChar; search_flags: int; out_val: double): int; cdecl; external avutil_dll;
// int av_opt_get_q (void *obj, const char *name, int search_flags, AVRational *out_val);
function av_opt_get_q(obj: Pointer; const name: PAnsiChar; search_flags: int; var out_val: AVRational): int; cdecl; external avutil_dll;
// int av_opt_get_image_size(void *obj, const char *name, int search_flags, int *w_out, int *h_out);
function av_opt_get_image_size(obj: Pointer; const name: PAnsiChar; search_flags: int; var w_out, h_out: int): int; cdecl; external avutil_dll;
// int av_opt_get_pixel_fmt (void *obj, const char *name, int search_flags, enum AVPixelFormat *out_fmt);
function av_opt_get_pixel_fmt(obj: Pointer; const name: PAnsiChar; search_flags: int; var out_fmt: AVPixelFormat): int; cdecl; external avutil_dll;
// int av_opt_get_sample_fmt(void *obj, const char *name, int search_flags, enum AVSampleFormat *out_fmt);
function av_opt_get_sample_fmt(obj: Pointer; const name: PAnsiChar; search_flags: int; var out_fmt: AVSampleFormat): int; cdecl; external avutil_dll;
// int av_opt_get_video_rate(void *obj, const char *name, int search_flags, AVRational *out_val);
function av_opt_get_video_rate(obj: Pointer; const name: PAnsiChar; search_flags: int; var out_val: AVRational): int; cdecl; external avutil_dll;
// int av_opt_get_channel_layout(void *obj, const char *name, int search_flags, int64_t *ch_layout);
function av_opt_get_channel_layout(obj: Pointer; const name: PAnsiChar; search_flags: int; var ch_layout: int64_t): int; cdecl; external avutil_dll;
(* *
* @param[out] out_val The returned dictionary is a copy of the actual value and must
* be freed with av_dict_free() by the caller
*)
// int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDictionary **out_val);
function av_opt_get_dict_val(obj: Pointer; const name: PAnsiChar; search_flags: int; var out_val: pAVDictionary): int; cdecl; external avutil_dll;
(* *
* @}
*)
(* *
* Gets a pointer to the requested field in a struct.
* This function allows accessing a struct even when its fields are moved or
* renamed since the application making the access has been compiled,
*
* @returns a pointer to the field, it can be cast to the correct type and read
* or written to.
*)
// void *av_opt_ptr(const AVClass *avclass, void *obj, const char *name);
function av_opt_ptr(const avclass: pAVClass; obj: Pointer; const name: PAnsiChar): Pointer; cdecl; external avutil_dll;
(* *
* Free an AVOptionRanges struct and set it to NULL.
*)
// void av_opt_freep_ranges(AVOptionRanges **ranges);
procedure av_opt_freep_ranges(var ranges: pAVOptionRanges); cdecl; external avutil_dll;
(* *
* Get a list of allowed ranges for the given option.
*
* The returned list may depend on other fields in obj like for example profile.
*
* @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
* AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
* AV_OPT_MULTI_COMPONENT_RANGE indicates that function may return more than one component, @see AVOptionRanges
*
* The result must be freed with av_opt_freep_ranges.
*
* @return number of compontents returned on success, a negative errro code otherwise
*)
// int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags);
function av_opt_query_ranges(Var ranges: pAVOptionRanges; obj: Pointer; const key: PAnsiChar; flags: int): int; cdecl; external avutil_dll;
(* *
* Copy options from src object into dest object.
*
* Options that require memory allocation (e.g. string or binary) are malloc'ed in dest object.
* Original memory allocated for such options is freed unless both src and dest options points to the same memory.
*
* @param dest Object to copy from
* @param src Object to copy into
* @return 0 on success, negative on error
*)
// int av_opt_copy(void *dest, const void *src);
function av_opt_copy(dest: Pointer; const src: Pointer): int; cdecl; external avutil_dll;
(* *
* Get a default list of allowed ranges for the given option.
*
* This list is constructed without using the AVClass.query_ranges() callback
* and can be used as fallback from within the callback.
*
* @param flags is a bitmask of flags, undefined flags should not be set and should be ignored
* AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance
* AV_OPT_MULTI_COMPONENT_RANGE indicates that function may return more than one component, @see AVOptionRanges
*
* The result must be freed with av_opt_free_ranges.
*
* @return number of compontents returned on success, a negative errro code otherwise
*)
// int av_opt_query_ranges_default(AVOptionRanges **, void *obj, const char *key, int flags);
function av_opt_query_ranges_default(var ranges: pAVOptionRanges; obj: Pointer; const key: PAnsiChar; flags: int): int; cdecl; external avutil_dll;
(* *
* Check if given option is set to its default value.
*
* Options o must belong to the obj. This function must not be called to check child's options state.
* @see av_opt_is_set_to_default_by_name().
*
* @param obj AVClass object to check option on
* @param o option to be checked
* @return >0 when option is set to its default,
* 0 when option is not set its default,
* <0 on error
*)
// int av_opt_is_set_to_default(void *obj, const AVOption *o);
function av_opt_is_set_to_default(obj: Pointer; const o: pAVOption): int; cdecl; external avutil_dll;
(* *
* Check if given option is set to its default value.
*
* @param obj AVClass object to check option on
* @param name option name
* @param search_flags combination of AV_OPT_SEARCH_*
* @return >0 when option is set to its default,
* 0 when option is not set its default,
* <0 on error
*)
// int av_opt_is_set_to_default_by_name(void *obj, const char *name, int search_flags);
function av_opt_is_set_to_default_by_name(obj: Pointer; const name: PAnsiChar; search_flags: int): int; cdecl; external avutil_dll;
const
AV_OPT_SERIALIZE_SKIP_DEFAULTS = $00000001;
// < Serialize options that are not set to default values only.
AV_OPT_SERIALIZE_OPT_FLAGS_EXACT = $00000002;
// < Serialize options that exactly match opt_flags only.
(* *
* Serialize object's options.
*
* Create a string containing object's serialized options.
* Such string may be passed back to av_opt_set_from_string() in order to restore option values.
* A key/value or pairs separator occurring in the serialized value or
* name string are escaped through the av_escape() function.
*
* @param[in] obj AVClass object to serialize
* @param[in] opt_flags serialize options with all the specified flags set (AV_OPT_FLAG)
* @param[in] flags combination of AV_OPT_SERIALIZE_* flags
* @param[out] buffer Pointer to buffer that will be allocated with string containg serialized options.
* Buffer must be freed by the caller when is no longer needed.
* @param[in] key_val_sep character used to separate key from value
* @param[in] pairs_sep character used to separate two pairs from each other
* @return >= 0 on success, negative on error
* @warning Separators cannot be neither '\\' nor '\0'. They also cannot be the same.
*)
// int av_opt_serialize(void *obj, int opt_flags, int flags, char **buffer,
// const char key_val_sep, const char pairs_sep);
function av_opt_serialize(obj: Pointer; opt_flags: int; flags: int; Var buffer: PAnsiChar; const key_val_sep: AnsiChar; const pairs_sep: AnsiChar): int; cdecl;
external avutil_dll;
{$ENDREGION}
{$REGION 'log.h'}
(* *
* Sets additional colors for extended debugging sessions.
* @code
av_log(ctx, AV_LOG_DEBUG|AV_LOG_C(134), "Message in purple\n");
@endcode
* Requires 256color terminal support. Uses outside debugging is not
* recommended.
*)
// #define AV_LOG_C(x) ((x) shl 8)
(* *
* Send the specified message to the log if the level is less than or equal
* to the current av_log_level. By default, all logging messages are sent to
* stderr. This behavior can be altered by setting a different logging callback
* function.
* @see av_log_set_callback
*
* @param avcl A pointer to an arbitrary struct of which the first field is a
* pointer to an AVClass struct or NULL if general log.
* @param level The importance level of the message expressed using a @ref
* lavu_log_constants "Logging Constant".
* @param fmt The format string (printf-compatible) that specifies how
* subsequent arguments are converted to output.
*)
// void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4);
procedure av_log(avcl: Pointer; level: int; const fmt: PAnsiChar);
cdecl varargs;
external avutil_dll;
(* *
* Send the specified message to the log if the level is less than or equal
* to the current av_log_level. By default, all logging messages are sent to
* stderr. This behavior can be altered by setting a different logging callback
* function.
* @see av_log_set_callback
*
* @param avcl A pointer to an arbitrary struct of which the first field is a
* pointer to an AVClass struct.
* @param level The importance level of the message expressed using a @ref
* lavu_log_constants "Logging Constant".
* @param fmt The format string (printf-compatible) that specifies how
* subsequent arguments are converted to output.
* @param vl The arguments referenced by the format string.
*)
// void av_vlog(void *avcl, int level, const char *fmt, va_list vl);
procedure av_vlog(avcl: Pointer; level: int; const fmt: PAnsiChar; vl: PVA_LIST); cdecl; external avutil_dll;
(* *
* Get the current log level
*
* @see lavu_log_constants
*
* @return Current log level
*)
// int av_log_get_level(void);
function av_log_get_level(): int; cdecl; external avutil_dll;
(* *
* Set the log level
*
* @see lavu_log_constants
*
* @param level Logging level
*)
// void av_log_set_level(int level);
procedure av_log_set_level(level: int); cdecl; external avutil_dll;
(* *
* Set the logging callback
*
* @note The callback must be thread safe, even if the application does not use
* threads itself as some codecs are multithreaded.
*
* @see av_log_default_callback
*
* @param callback A logging function with a compatible signature.
*)
// void av_log_set_callback(void (*callback)(void*, int, const char*, va_list));
Type
Tav_log_callback = procedure(p: Pointer; lvl: Integer; fmt: PAnsiChar; vl: PVA_LIST);
cdecl varargs;
procedure av_log_set_callback(callbackproc: Tav_log_callback); cdecl; external avutil_dll;
(* *
* Default logging callback
*
* It prints the message to stderr, optionally colorizing it.
*
* @param avcl A pointer to an arbitrary struct of which the first field is a
* pointer to an AVClass struct.
* @param level The importance level of the message expressed using a @ref
* lavu_log_constants "Logging Constant".
* @param fmt The format string (printf-compatible) that specifies how
* subsequent arguments are converted to output.
* @param vl The arguments referenced by the format string.
*)
// void av_log_default_callback(void *avcl, int level, const char *fmt, va_list vl);
procedure av_log_default_callback(avcl: Pointer; level: int; const fmt: PAnsiChar; vl: PVA_LIST); cdecl; external avutil_dll;
(* *
* Return the context name
*
* @param ctx The AVClass context
*
* @return The AVClass class_name
*)
// const char* av_default_item_name(void* ctx);
function av_default_item_name(ctx: Pointer): PAnsiChar; cdecl; external avutil_dll;
// AVClassCategory av_default_get_category(void *ptr);
function av_default_get_category(ptr: Pointer): AVClassCategory; cdecl; external avutil_dll;
(* *
* Format a line of log the same way as the default callback.
* @param line buffer to receive the formatted line
* @param line_size size of the buffer
* @param print_prefix used to store whether the prefix must be printed;
* must point to a persistent integer initially set to 1
*)
// void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl,
// char *line, int line_size, int *print_prefix);
procedure av_log_format_line(ptr: Pointer; level: int; const fmt: PAnsiChar; vl: PVA_LIST; line: PAnsiChar; line_size: int; Var print_prefix: int); cdecl;
external avutil_dll;
(* *
* Format a line of log the same way as the default callback.
* @param line buffer to receive the formatted line;
* may be NULL if line_size is 0
* @param line_size size of the buffer; at most line_size-1 characters will
* be written to the buffer, plus one null terminator
* @param print_prefix used to store whether the prefix must be printed;
* must point to a persistent integer initially set to 1
* @return Returns a negative value if an error occurred, otherwise returns
* the number of characters that would have been written for a
* sufficiently large buffer, not including the terminating null
* character. If the return value is not less than line_size, it means
* that the log message was truncated to fit the buffer.
*)
// int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl,
// char *line, int line_size, int *print_prefix);
function av_log_format_line2(ptr: Pointer; level: int; const fmt: PAnsiChar; vl: PVA_LIST; line: PAnsiChar; line_size: int; Var print_prefix: int): int; cdecl;
external avutil_dll;
(* *
* Skip repeated messages, this requires the user app to use av_log() instead of
* (f)printf as the 2 would otherwise interfere and lead to
* "Last message repeated x times" messages below (f)printf messages with some
* bad luck.
* Also to receive the last, "last repeated" line if any, the user app must
* call av_log(NULL, AV_LOG_QUIET, "%s", ""); at the end
*)
const
AV_LOG_SKIP_REPEATED = 1;
(* *
* Include the log severity in messages originating from codecs.
*
* Results in messages such as:
* [rawvideo @ $DEADBEEF] [error] encode did not produce valid pts
*)
AV_LOG_PRINT_LEVEL = 2;
// void av_log_set_flags(int arg);
procedure av_log_set_flags(arg: int); cdecl; external avutil_dll;
// int av_log_get_flags(void);
function av_log_get_flags(): int; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'avutil.h'}
(* *
* Return the LIBAVUTIL_VERSION_INT constant.
*)
// unsigned avutil_version(void);
function avutil_version(): unsigned; cdecl; external avutil_dll;
(* *
* Return an informative version string. This usually is the actual release
* version number or a git commit description. This string has no fixed format
* and can change any time. It should never be parsed by code.
*)
// const char *av_version_info(void);
function av_version_info(): PAnsiChar; cdecl; external avutil_dll;
(* *
* Return the libavutil build-time configuration.
*)
// const char *avutil_configuration(void);
function avutil_configuration(): PAnsiChar; cdecl; external avutil_dll;
(* *
* Return the libavutil license.
*)
// const char *avutil_license(void);
function avutil_license(): PAnsiChar; cdecl; external avutil_dll;
(* *
* Return a string describing the media_type enum, NULL if media_type
* is unknown.
*)
// const char *av_get_media_type_string(enum AVMediaType media_type);
function av_get_media_type_string(media_type: AVMediaType): PAnsiChar; cdecl; external avutil_dll;
(* *
* Return a single letter to describe the given picture type
* pict_type.
*
* @param[in] pict_type the picture type @return a single character
* representing the picture type, '?' if pict_type is unknown
*)
// char av_get_picture_type_char(enum AVPictureType pict_type);
function av_get_picture_type_char(pict_type: AVPictureType): AnsiChar; cdecl; external avutil_dll;
(* *
* Return x default pointer in case p is NULL.
*)
// static inline void *av_x_if_null(const void *p, const void *x)
// {
// return (void *)(intptr_t)(p ? p : x);
// }
function av_x_if_null(const p: Pointer; const x: Pointer): Pointer; inline;
(* *
* Compute the length of an integer list.
*
* @param elsize size in bytes of each list element (only 1, 2, 4 or 8)
* @param term list terminator (usually 0 or -1)
* @param list pointer to the list
* @return length of the list, in elements, not counting the terminator
*)
// unsigned av_int_list_length_for_size(unsigned elsize,
// const void *list, uint64_t term) av_pure;
function av_int_list_length_for_size(elsize: unsigned; const list: Pointer; term: uint64_t): unsigned; cdecl; external avutil_dll;
(* *
* Compute the length of an integer list.
*
* @param term list terminator (usually 0 or -1)
* @param list pointer to the list
* @return length of the list, in elements, not counting the terminator
*)
// #define av_int_list_length(list, term) \
// av_int_list_length_for_size(sizeof(*(list)), list, term)
function av_int_list_length(list: Pointer; item_size: int; term: int64_t): int; inline;
(* *
* Open a file using a UTF-8 filename.
* The API of this function matches POSIX fopen(), errors are returned through
* errno.
*)
// FILE *av_fopen_utf8(const char *path, const char *mode);
function av_fopen_utf8(const path: PAnsiChar; const mode: PAnsiChar): pFile; cdecl; external avutil_dll;
(* *
* Return the fractional representation of the internal time base.
*)
// AVRational av_get_time_base_q(void);
function av_get_time_base_q(): AVRational; cdecl; external avutil_dll;
const
AV_FOURCC_MAX_STRING_SIZE = 32;
// #define av_fourcc2str(fourcc) av_fourcc_make_string((char[AV_FOURCC_MAX_STRING_SIZE]){0}, fourcc)
(* *
* Fill the provided buffer with a string containing a FourCC (four-character
* code) representation.
*
* @param buf a buffer with size in bytes of at least AV_FOURCC_MAX_STRING_SIZE
* @param fourcc the fourcc to represent
* @return the buffer in input
*)
// char *av_fourcc_make_string(char *buf, uint32_t fourcc);
function av_fourcc_make_string(buf: PAnsiChar; fourcc: uint32_t): PAnsiChar; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'file.h'}
(* *
* Read the file with name filename, and put its content in a newly
* allocated buffer or map it with mmap() when available.
* In case of success set *bufptr to the read or mmapped buffer, and
* *size to the size in bytes of the buffer in *bufptr.
* The returned buffer must be released with av_file_unmap().
*
* @param log_offset loglevel offset used for logging
* @param log_ctx context used for logging
* @return a non negative number in case of success, a negative value
* corresponding to an AVERROR error code in case of failure
*)
// av_warn_unused_result
// int av_file_map(const char *filename, uint8_t **bufptr, size_t *size,
// int log_offset, void *log_ctx);
function av_file_map(const filename: PAnsiChar; var bufptr: puint8_t; var size: size_t; log_offset: int; log_ctx: Pointer): int; cdecl; external avutil_dll;
(* *
* Unmap or free the buffer bufptr created by av_file_map().
*
* @param size size in bytes of bufptr, must be the same as returned
* by av_file_map()
*)
// void av_file_unmap(uint8_t *bufptr, size_t size);
procedure av_file_unmap(bufptr: puint8_t; size: size_t); cdecl; external avutil_dll;
(* *
* Wrapper to work around the lack of mkstemp() on mingw.
* Also, tries to create file in /tmp first, if possible.
* *prefix can be a character constant; *filename will be allocated internally.
* @return file descriptor of opened file (or negative value corresponding to an
* AVERROR code on error)
* and opened file name in **filename.
* @note On very old libcs it is necessary to set a secure umask before
* calling this, av_tempfile() can't call umask itself as it is used in
* libraries and could interfere with the calling application.
* @deprecated as fd numbers cannot be passed saftely between libs on some platforms
*)
// int av_tempfile(const char *prefix, char **filename, int log_offset, void *log_ctx);
function av_tempfile(const prefix: PAnsiChar; var filename: PAnsiChar; log_offset: int; log_ctx: Pointer): int; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'error.h'}
const
// #define AVERROR_BSF_NOT_FOUND FFERRTAG(0xF8,'B','S','F') //< Bitstream filter not found
AVERROR_BSF_NOT_FOUND = -($F8 or (Ord('B') shl 8) or (Ord('S') shl 16) or (Ord('F') shl 24));
// #define AVERROR_BUG FFERRTAG( 'B','U','G','!') //< Internal bug, also see AVERROR_BUG2
AVERROR_BUG = -(Ord('B') or (Ord('U') shl 8) or (Ord('G') shl 16) or (Ord('!') shl 24));
// #define AVERROR_BUFFER_TOO_SMALL FFERRTAG( 'B','U','F','S') //< Buffer too small
AVERROR_BUFFER_TOO_SMALL = -(Ord('B') or (Ord('U') shl 8) or (Ord('F') shl 16) or (Ord('S') shl 24));
// #define AVERROR_DECODER_NOT_FOUND FFERRTAG(0xF8,'D','E','C') //< Decoder not found
AVERROR_DECODER_NOT_FOUND = -($F8 or (Ord('D') shl 8) or (Ord('E') shl 16) or (Ord('C') shl 24));
// #define AVERROR_DEMUXER_NOT_FOUND FFERRTAG(0xF8,'D','E','M') //< Demuxer not found
AVERROR_DEMUXER_NOT_FOUND = -($F8 or (Ord('D') shl 8) or (Ord('E') shl 16) or (Ord('M') shl 24));
// #define AVERROR_ENCODER_NOT_FOUND FFERRTAG(0xF8,'E','N','C') //< Encoder not found
AVERROR_ENCODER_NOT_FOUND = -($F8 or (Ord('E') shl 8) or (Ord('N') shl 16) or (Ord('C') shl 24));
// #define AVERROR_EOF FFERRTAG( 'E','O','F',' ') //< End of file
AVERROR_EOF = -(Ord('E') or (Ord('O') shl 8) or (Ord('F') shl 16) or (Ord(' ') shl 24));
// #define AVERROR_EXIT FFERRTAG( 'E','X','I','T') //< Immediate exit was requested; the called function should not be restarted
AVERROR_EXIT = -(Ord('E') or (Ord('X') shl 8) or (Ord('I') shl 16) or (Ord('T') shl 24));
// #define AVERROR_EXTERNAL FFERRTAG( 'E','X','T',' ') //< Generic error in an external library
AVERROR_EXTERNAL = -(Ord('E') or (Ord('X') shl 8) or (Ord('T') shl 16) or (Ord(' ') shl 24));
// #define AVERROR_FILTER_NOT_FOUND FFERRTAG(0xF8,'F','I','L') //< Filter not found
AVERROR_FILTER_NOT_FOUND = -($F8 or (Ord('F') shl 8) or (Ord('I') shl 16) or (Ord('L') shl 24));
// #define AVERROR_INVALIDDATA FFERRTAG( 'I','N','D','A') //< Invalid data found when processing input
AVERROR_INVALIDDATA = -(Ord('I') or (Ord('N') shl 8) or (Ord('D') shl 16) or (Ord('A') shl 24));
// #define AVERROR_MUXER_NOT_FOUND FFERRTAG(0xF8,'M','U','X') //< Muxer not found
AVERROR_MUXER_NOT_FOUND = -($F8 or (Ord('M') shl 8) or (Ord('U') shl 16) or (Ord('X') shl 24));
// #define AVERROR_OPTION_NOT_FOUND FFERRTAG(0xF8,'O','P','T') //< Option not found
AVERROR_OPTION_NOT_FOUND = -($F8 or (Ord('O') shl 8) or (Ord('P') shl 16) or (Ord('T') shl 24));
// #define AVERROR_PATCHWELCOME FFERRTAG( 'P','A','W','E') //< Not yet implemented in FFmpeg, patches welcome
AVERROR_PATCHWELCOME = -(Ord('P') or (Ord('A') shl 8) or (Ord('W') shl 16) or (Ord('E') shl 24));
// #define AVERROR_PROTOCOL_NOT_FOUND FFERRTAG(0xF8,'P','R','O') //< Protocol not found
AVERROR_PROTOCOL_NOT_FOUND = -($F8 or (Ord('P') shl 8) or (Ord('R') shl 16) or (Ord('O') shl 24));
// #define AVERROR_STREAM_NOT_FOUND FFERRTAG(0xF8,'S','T','R') //< Stream not found
AVERROR_STREAM_NOT_FOUND = -($F8 or (Ord('S') shl 8) or (Ord('T') shl 16) or (Ord('R') shl 24));
(* *
* This is semantically identical to AVERROR_BUG
* it has been introduced in Libav after our AVERROR_BUG and with a modified value.
*)
// #define AVERROR_BUG2 FFERRTAG( 'B','U','G',' ')
AVERROR_BUG2 = -(Ord('B') or (Ord('U') shl 8) or (Ord('G') shl 16) or (Ord(' ') shl 24));
// #define AVERROR_UNKNOWN FFERRTAG( 'U','N','K','N') //< Unknown error, typically from an external library
AVERROR_UNKNOWN = -(Ord('U') or (Ord('N') shl 8) or (Ord('K') shl 16) or (Ord('N') shl 24));
// #define AVERROR_EXPERIMENTAL (-0x2bb2afa8) //< Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.
AVERROR_EXPERIMENTAL = -$2BB2AFA8;
// #define AVERROR_INPUT_CHANGED (-0x636e6701) //< Input changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_OUTPUT_CHANGED)
AVERROR_INPUT_CHANGED = -$636E6701;
// #define AVERROR_OUTPUT_CHANGED (-0x636e6702) //< Output changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_INPUT_CHANGED)
AVERROR_OUTPUT_CHANGED = -$636E6702;
// * HTTP & RTSP errors */
// #define AVERROR_HTTP_BAD_REQUEST FFERRTAG(0xF8,'4','0','0')
AVERROR_HTTP_BAD_REQUEST = -($F8 or (Ord('4') shl 8) or (Ord('0') shl 16) or (Ord('0') shl 24));
// #define AVERROR_HTTP_UNAUTHORIZED FFERRTAG(0xF8,'4','0','1')
AVERROR_HTTP_UNAUTHORIZED = -($F8 or (Ord('4') shl 8) or (Ord('0') shl 16) or (Ord('1') shl 24));
// #define AVERROR_HTTP_FORBIDDEN FFERRTAG(0xF8,'4','0','3')
AVERROR_HTTP_FORBIDDEN = -($F8 or (Ord('4') shl 8) or (Ord('0') shl 16) or (Ord('3') shl 24));
// #define AVERROR_HTTP_NOT_FOUND FFERRTAG(0xF8,'4','0','4')
AVERROR_HTTP_NOT_FOUND = -($F8 or (Ord('4') shl 8) or (Ord('0') shl 16) or (Ord('4') shl 24));
// #define AVERROR_HTTP_OTHER_4XX FFERRTAG(0xF8,'4','X','X')
AVERROR_HTTP_OTHER_4XX = -($F8 or (Ord('4') shl 8) or (Ord('X') shl 16) or (Ord('X') shl 24));
// #define AVERROR_HTTP_SERVER_ERROR FFERRTAG(0xF8,'5','X','X')
AVERROR_HTTP_SERVER_ERROR = -($F8 or (Ord('5') shl 8) or (Ord('X') shl 16) or (Ord('X') shl 24));
AV_ERROR_MAX_STRING_SIZE = 64;
// errno.h
AVERROR_EPERM = -1;
// < Operation not permitted
AVERROR_ENOENT = -2;
// < No such file or directory
AVERROR_ESRCH = -3;
// < No such process
AVERROR_EINTR = -4;
// < Interrupted function call
AVERROR_EIO = -5;
// < I/O error
AVERROR_ENXIO = -6;
// < No such device or address
AVERROR_E2BIG = -7;
// < Argument list too long
AVERROR_ENOEXEC = -8;
// < Exec format error
AVERROR_EBADF = -9;
// < Bad file number
AVERROR_ECHILD = -10;
// < No child processes
AVERROR_EAGAIN = -11;
// < Resource temporarily unavailable / Try again
AVERROR_ENOMEM = -12;
// < Not enough space / Out of memory
AVERROR_EACCES = -13;
// < Permission denied
AVERROR_EFAULT = -14;
// < Bad address
AVERROR_ENOTBLK = -15;
// < Block device required (WIN: Unknown error)
AVERROR_EBUSY = -16;
// < Device or resource busy
AVERROR_EEXIST = -17;
// < File exists
AVERROR_EXDEV = -18;
// < Cross-device link
AVERROR_ENODEV = -19;
// < No such device
AVERROR_ENOTDIR = -20;
// < Not a directory
AVERROR_EISDIR = -21;
// < Is a directory
AVERROR_EINVAL = -22;
// < Invalid argument
AVERROR_ENFILE = -23;
// < Too many open files in system / File table overflow
AVERROR_EMFILE = -24;
// < Too many open files
AVERROR_ENOTTY = -25;
// < Inappropriate I/O control operation / Not a typewriter
AVERROR_ETXTBSY = -26;
// < Text file busy (WIN: Unknown error)
AVERROR_EFBIG = -27;
// < File too large
AVERROR_ENOSPC = -28;
// < No space left on device
AVERROR_ESPIPE = -29;
// < Illegal seek
AVERROR_EROFS = -30;
// < Read-only file system
AVERROR_EMLINK = -31;
// < Too many links
AVERROR_EPIPE = -32;
// < Broken pipe
AVERROR_EDOM = -33;
// < Math argument out of domain of func
AVERROR_ERANGE = -34;
// < Math result not representable
AVERROR_EDEADLK = -36;
// < Resource deadlock avoided
AVERROR_ENAMETOOLONG = -38;
// < File name too long
AVERROR_ENOLCK = -39;
// < No locks available
AVERROR_ENOSYS = -40;
// < Function not implemented
AVERROR_ENOTEMPTY = -41;
// < Directory not empty
AVERROR_ELOOP = -114;
// < Too many symbolic links encountered
AVERROR_ENOMSG = -91;
// < No message of desired type (WIN: Unknown error)
AVERROR_EIDRM = -90;
// < Identifier removed (WIN: Unknown error)
AVERROR_ENOSTR = -99;
// < Device not a stream
AVERROR_ENODATA = -96;
// < No data available
AVERROR_ETIME = -101;
// < Timer expired
AVERROR_ENOSR = -98;
// < Out of streams resources
AVERROR_EREMOTE = -71;
// < Too many levels of remote in path
AVERROR_ENOLINK = -97;
// < Link has been severed
AVERROR_EMULTIHOP = -95;
// < Multihop attempted
AVERROR_EBADMSG = -94;
// < Not a data message
AVERROR_EPROTO = -134;
// < Protocol error
AVERROR_EOVERFLOW = -132;
// < Value too large for defined data type
AVERROR_EILSEQ = -42;
// < Illegal byte sequence
AVERROR_EUSERS = -68;
// < Too many users
AVERROR_ENOTSOCK = -128;
// < Socket operation on non-socket
AVERROR_EDESTADDRREQ = -109;
// < Destination address required
AVERROR_EMSGSIZE = -115;
// < Message too long
AVERROR_EPROTOTYPE = -136;
// < Protocol wrong type for socket
AVERROR_ENOPROTOOPT = -123;
// < Protocol not available
AVERROR_EPROTONOSUPPORT = -135;
// < Protocol not supported
AVERROR_ESOCKTNOSUPPORT = -44;
// < Socket type not supported
AVERROR_EOPNOTSUPP = -130;
// < Operation not supported on transport endpoint
AVERROR_EPFNOSUPPORT = -46;
// < Protocol family not supported
AVERROR_EAFNOSUPPORT = -102;
// < Address family not supported by protocol
AVERROR_EADDRINUSE = -100;
// < Address already in use
AVERROR_EADDRNOTAVAIL = -101;
// < Cannot assign requested address
AVERROR_ENETDOWN = -116;
// < Network is down
AVERROR_ENETUNREACH = -118;
// < Network is unreachable
AVERROR_ENETRESET = -117;
// < Network dropped connection because of reset
AVERROR_ECONNABORTED = -106;
// < Software caused connection abort
AVERROR_ECONNRESET = -108;
// < Connection reset by peer
AVERROR_ENOBUFS = -119;
// < No buffer space available
AVERROR_EISCONN = -113;
// < Transport endpoint is already connected
AVERROR_ENOTCONN = -126;
// < Transport endpoint is not connected
AVERROR_ESHUTDOWN = -58;
// < Cannot send after transport endpoint shutdown
AVERROR_ETOOMANYREFS = -59;
// < Too many references: cannot splice
AVERROR_ETIMEDOUT = -138;
// < Connection timed out
AVERROR_ECONNREFUSED = -107;
// < Connection refused
AVERROR_EHOSTDOWN = -64;
// < Host is down
AVERROR_EHOSTUNREACH = -110;
// < No route to host
AVERROR_EALREADY = -103;
// < Operation already in progress
AVERROR_EINPROGRESS = -112;
// < Operation now in progress
AVERROR_ESTALE = -70;
// < Stale NFS file handle
AVERROR_ECANCELED = -105;
// < Operation Canceled
AVERROR_EOWNERDEAD = -133;
// < Owner died
AVERROR_ENOTRECOVERABLE = -44;
// < State not recoverable
WSABASEERR = -10000;
{$EXTERNALSYM WSABASEERR}
WSAEINTR = WSABASEERR - 4;
{$EXTERNALSYM WSAEINTR}
WSAEBADF = WSABASEERR - 9;
{$EXTERNALSYM WSAEBADF}
WSAEACCES = WSABASEERR - 13;
{$EXTERNALSYM WSAEACCES}
WSAEFAULT = WSABASEERR - 14;
{$EXTERNALSYM WSAEFAULT}
WSAEINVAL = WSABASEERR - 22;
{$EXTERNALSYM WSAEINVAL}
WSAEMFILE = WSABASEERR - 24;
{$EXTERNALSYM WSAEMFILE}
WSAEWOULDBLOCK = WSABASEERR - 35;
{$EXTERNALSYM WSAEWOULDBLOCK}
WSAEINPROGRESS = WSABASEERR - 36; (* deprecated on WinSock2 *)
{$EXTERNALSYM WSAEINPROGRESS}
WSAEALREADY = WSABASEERR - 37;
{$EXTERNALSYM WSAEALREADY}
WSAENOTSOCK = WSABASEERR - 38;
{$EXTERNALSYM WSAENOTSOCK}
WSAEDESTADDRREQ = WSABASEERR - 39;
{$EXTERNALSYM WSAEDESTADDRREQ}
WSAEMSGSIZE = WSABASEERR - 40;
{$EXTERNALSYM WSAEMSGSIZE}
WSAEPROTOTYPE = WSABASEERR - 41;
{$EXTERNALSYM WSAEPROTOTYPE}
WSAENOPROTOOPT = WSABASEERR - 42;
{$EXTERNALSYM WSAENOPROTOOPT}
WSAEPROTONOSUPPORT = WSABASEERR - 43;
{$EXTERNALSYM WSAEPROTONOSUPPORT}
WSAESOCKTNOSUPPORT = WSABASEERR - 44;
{$EXTERNALSYM WSAESOCKTNOSUPPORT}
WSAEOPNOTSUPP = WSABASEERR - 45;
{$EXTERNALSYM WSAEOPNOTSUPP}
WSAEPFNOSUPPORT = WSABASEERR - 46;
{$EXTERNALSYM WSAEPFNOSUPPORT}
WSAEAFNOSUPPORT = WSABASEERR - 47;
{$EXTERNALSYM WSAEAFNOSUPPORT}
WSAEADDRINUSE = WSABASEERR - 48;
{$EXTERNALSYM WSAEADDRINUSE}
WSAEADDRNOTAVAIL = WSABASEERR - 49;
{$EXTERNALSYM WSAEADDRNOTAVAIL}
WSAENETDOWN = WSABASEERR - 50;
{$EXTERNALSYM WSAENETDOWN}
WSAENETUNREACH = WSABASEERR - 51;
{$EXTERNALSYM WSAENETUNREACH}
WSAENETRESET = WSABASEERR - 52;
{$EXTERNALSYM WSAENETRESET}
WSAECONNABORTED = WSABASEERR - 53;
{$EXTERNALSYM WSAECONNABORTED}
WSAECONNRESET = WSABASEERR - 54;
{$EXTERNALSYM WSAECONNRESET}
WSAENOBUFS = WSABASEERR - 55;
{$EXTERNALSYM WSAENOBUFS}
WSAEISCONN = WSABASEERR - 56;
{$EXTERNALSYM WSAEISCONN}
WSAENOTCONN = WSABASEERR - 57;
{$EXTERNALSYM WSAENOTCONN}
WSAESHUTDOWN = WSABASEERR - 58;
{$EXTERNALSYM WSAESHUTDOWN}
WSAETOOMANYREFS = WSABASEERR - 59;
{$EXTERNALSYM WSAETOOMANYREFS}
WSAETIMEDOUT = WSABASEERR - 60;
{$EXTERNALSYM WSAETIMEDOUT}
WSAECONNREFUSED = WSABASEERR - 61;
{$EXTERNALSYM WSAECONNREFUSED}
WSAELOOP = WSABASEERR - 62;
{$EXTERNALSYM WSAELOOP}
WSAENAMETOOLONG = WSABASEERR - 63;
{$EXTERNALSYM WSAENAMETOOLONG}
WSAEHOSTDOWN = WSABASEERR - 64;
{$EXTERNALSYM WSAEHOSTDOWN}
WSAEHOSTUNREACH = WSABASEERR - 65;
{$EXTERNALSYM WSAEHOSTUNREACH}
WSAENOTEMPTY = WSABASEERR - 66;
{$EXTERNALSYM WSAENOTEMPTY}
WSAEPROCLIM = WSABASEERR - 67;
{$EXTERNALSYM WSAEPROCLIM}
WSAEUSERS = WSABASEERR - 68;
{$EXTERNALSYM WSAEUSERS}
WSAEDQUOT = WSABASEERR - 69;
{$EXTERNALSYM WSAEDQUOT}
WSAESTALE = WSABASEERR - 70;
{$EXTERNALSYM WSAESTALE}
WSAEREMOTE = WSABASEERR - 71;
{$EXTERNALSYM WSAEREMOTE}
WSAEDISCON = WSABASEERR - 101;
{$EXTERNALSYM WSAEDISCON}
WSASYSNOTREADY = WSABASEERR - 91;
{$EXTERNALSYM WSASYSNOTREADY}
WSAVERNOTSUPPORTED = WSABASEERR - 92;
{$EXTERNALSYM WSAVERNOTSUPPORTED}
WSANOTINITIALISED = WSABASEERR - 93;
{$EXTERNALSYM WSANOTINITIALISED}
WSAHOST_NOT_FOUND = WSABASEERR - 1001;
{$EXTERNALSYM WSAHOST_NOT_FOUND}
WSATRY_AGAIN = WSABASEERR - 1002;
{$EXTERNALSYM WSATRY_AGAIN}
WSANO_RECOVERY = WSABASEERR - 1003;
{$EXTERNALSYM WSANO_RECOVERY}
WSANO_DATA = WSABASEERR - 1004;
{$EXTERNALSYM WSANO_DATA}
(* WinSock2 specific error codes *)
WSAENOMORE = WSABASEERR - 102;
{$EXTERNALSYM WSAENOMORE}
WSAECANCELLED = WSABASEERR - 103;
{$EXTERNALSYM WSAECANCELLED}
WSAEINVALIDPROCTABLE = WSABASEERR - 104;
{$EXTERNALSYM WSAEINVALIDPROCTABLE}
WSAEINVALIDPROVIDER = WSABASEERR - 105;
{$EXTERNALSYM WSAEINVALIDPROVIDER}
WSAEPROVIDERFAILEDINIT = WSABASEERR - 106;
{$EXTERNALSYM WSAEPROVIDERFAILEDINIT}
WSASYSCALLFAILURE = WSABASEERR - 107;
{$EXTERNALSYM WSASYSCALLFAILURE}
WSASERVICE_NOT_FOUND = WSABASEERR - 108;
{$EXTERNALSYM WSASERVICE_NOT_FOUND}
WSATYPE_NOT_FOUND = WSABASEERR - 109;
{$EXTERNALSYM WSATYPE_NOT_FOUND}
WSA_E_NO_MORE = WSABASEERR - 110;
{$EXTERNALSYM WSA_E_NO_MORE}
WSA_E_CANCELLED = WSABASEERR - 111;
{$EXTERNALSYM WSA_E_CANCELLED}
WSAEREFUSED = WSABASEERR - 112;
{$EXTERNALSYM WSAEREFUSED}
(* WS QualityofService errors *)
WSA_QOS_RECEIVERS = WSABASEERR - 1005;
{$EXTERNALSYM WSA_QOS_RECEIVERS}
WSA_QOS_SENDERS = WSABASEERR - 1006;
{$EXTERNALSYM WSA_QOS_SENDERS}
WSA_QOS_NO_SENDERS = WSABASEERR - 1007;
{$EXTERNALSYM WSA_QOS_NO_SENDERS}
WSA_QOS_NO_RECEIVERS = WSABASEERR - 1008;
{$EXTERNALSYM WSA_QOS_NO_RECEIVERS}
WSA_QOS_REQUEST_CONFIRMED = WSABASEERR - 1009;
{$EXTERNALSYM WSA_QOS_REQUEST_CONFIRMED}
WSA_QOS_ADMISSION_FAILURE = WSABASEERR - 1010;
{$EXTERNALSYM WSA_QOS_ADMISSION_FAILURE}
WSA_QOS_POLICY_FAILURE = WSABASEERR - 1011;
{$EXTERNALSYM WSA_QOS_POLICY_FAILURE}
WSA_QOS_BAD_STYLE = WSABASEERR - 1012;
{$EXTERNALSYM WSA_QOS_BAD_STYLE}
WSA_QOS_BAD_OBJECT = WSABASEERR - 1013;
{$EXTERNALSYM WSA_QOS_BAD_OBJECT}
WSA_QOS_TRAFFIC_CTRL_ERROR = WSABASEERR - 1014;
{$EXTERNALSYM WSA_QOS_TRAFFIC_CTRL_ERROR}
WSA_QOS_GENERIC_ERROR = WSABASEERR - 1015;
{$EXTERNALSYM WSA_QOS_GENERIC_ERROR}
WSA_QOS_ESERVICETYPE = WSABASEERR - 1016;
{$EXTERNALSYM WSA_QOS_ESERVICETYPE}
WSA_QOS_EFLOWSPEC = WSABASEERR - 1017;
{$EXTERNALSYM WSA_QOS_EFLOWSPEC}
WSA_QOS_EPROVSPECBUF = WSABASEERR - 1018;
{$EXTERNALSYM WSA_QOS_EPROVSPECBUF}
WSA_QOS_EFILTERSTYLE = WSABASEERR - 1019;
{$EXTERNALSYM WSA_QOS_EFILTERSTYLE}
WSA_QOS_EFILTERTYPE = WSABASEERR - 1020;
{$EXTERNALSYM WSA_QOS_EFILTERTYPE}
WSA_QOS_EFILTERCOUNT = WSABASEERR - 1021;
{$EXTERNALSYM WSA_QOS_EFILTERCOUNT}
WSA_QOS_EOBJLENGTH = WSABASEERR - 1022;
{$EXTERNALSYM WSA_QOS_EOBJLENGTH}
WSA_QOS_EFLOWCOUNT = WSABASEERR - 1023;
{$EXTERNALSYM WSA_QOS_EFLOWCOUNT}
WSA_QOS_EUNKOWNPSOBJ = WSABASEERR - 1024;
{$EXTERNALSYM WSA_QOS_EUNKOWNPSOBJ}
WSA_QOS_EPOLICYOBJ = WSABASEERR - 1025;
{$EXTERNALSYM WSA_QOS_EPOLICYOBJ}
WSA_QOS_EFLOWDESC = WSABASEERR - 1026;
{$EXTERNALSYM WSA_QOS_EFLOWDESC}
WSA_QOS_EPSFLOWSPEC = WSABASEERR - 1027;
{$EXTERNALSYM WSA_QOS_EPSFLOWSPEC}
WSA_QOS_EPSFILTERSPEC = WSABASEERR - 1028;
{$EXTERNALSYM WSA_QOS_EPSFILTERSPEC}
WSA_QOS_ESDMODEOBJ = WSABASEERR - 1029;
{$EXTERNALSYM WSA_QOS_ESDMODEOBJ}
WSA_QOS_ESHAPERATEOBJ = WSABASEERR - 1030;
{$EXTERNALSYM WSA_QOS_ESHAPERATEOBJ}
WSA_QOS_RESERVED_PETYPE = WSABASEERR - 1031;
{$EXTERNALSYM WSA_QOS_RESERVED_PETYPE}
type
TErrorItem = record
err: Integer;
msg: string;
end;
const
CErrorList: array [0 .. 173] of TErrorItem = ((err: WSAEINTR; msg: 'Interrupted function call'), (err: WSAEBADF; msg: 'Bad file number'), (err: WSAEACCES;
msg: 'Permission denied'), (err: WSAEFAULT; msg: 'Bad address'), (err: WSAEINVAL; msg: 'Invalid argument / Invalid data found when processing input'),
(err: WSAEMFILE; msg: 'Too many open files'), (err: WSAENAMETOOLONG; msg: 'File name too long'), (err: WSAENOTEMPTY; msg: 'Directory not empty'),
(err: WSAELOOP; msg: 'Too many symbolic links encountered'), (err: WSAEREMOTE; msg: 'Too many levels of remote in path'), (err: WSAEUSERS;
msg: 'Too many users'), (err: WSAENOTSOCK; msg: 'Socket operation on non-socket'), (err: WSAEDESTADDRREQ; msg: 'Destination address required'),
(err: WSAEMSGSIZE; msg: 'Message too long'), (err: WSAEPROTOTYPE; msg: 'Protocol wrong type for socket'), (err: WSAENOPROTOOPT;
msg: 'Protocol not available'), (err: WSAEPROTONOSUPPORT; msg: 'Protocol not supported'), (err: WSAESOCKTNOSUPPORT; msg: 'Socket type not supported'),
(err: WSAEOPNOTSUPP; msg: 'Operation not supported on transport endpoint'), (err: WSAEPFNOSUPPORT; msg: 'Protocol family not supported'),
(err: WSAEAFNOSUPPORT; msg: 'Address family not supported by protocol'), (err: WSAEADDRINUSE; msg: 'Address already in use'), (err: WSAEADDRNOTAVAIL;
msg: 'Cannot assign requested address'), (err: WSAENETDOWN; msg: 'Network is down'), (err: WSAENETUNREACH; msg: 'Network is unreachable'),
(err: WSAENETRESET; msg: 'Network dropped connection because of reset'), (err: WSAECONNABORTED; msg: 'Software caused connection abort'),
(err: WSAECONNRESET; msg: 'Connection reset by peer'), (err: WSAENOBUFS; msg: 'No buffer space available'), (err: WSAEISCONN;
msg: 'Transport endpoint is already connected'), (err: WSAENOTCONN; msg: 'Transport endpoint is not connected'), (err: WSAESHUTDOWN;
msg: 'Cannot send after transport endpoint shutdown'), (err: WSAETOOMANYREFS; msg: 'Too many references: cannot splice'), (err: WSAETIMEDOUT;
msg: 'Connection timed out'), (err: WSAECONNREFUSED; msg: 'Connection refused'), (err: WSAEHOSTDOWN; msg: 'Host is down'), (err: WSAEHOSTUNREACH;
msg: 'No route to host'), (err: WSAEALREADY; msg: 'Operation already in progress'), (err: WSAEINPROGRESS; msg: 'Operation now in progress'),
(err: WSAESTALE; msg: 'Stale NFS file handle'), (err: WSAEDQUOT; msg: 'Quota exceeded'), (err: WSAEWOULDBLOCK; msg: 'WSAEWOULDBLOCK'), (err: WSAEPROCLIM;
msg: 'WSAEPROCLIM'), (err: WSAEDISCON; msg: 'WSAEDISCON'), (err: WSASYSNOTREADY; msg: 'WSASYSNOTREADY'), (err: WSAVERNOTSUPPORTED;
msg: 'WSAVERNOTSUPPORTED'), (err: WSANOTINITIALISED; msg: 'WSANOTINITIALISED'), (err: WSAHOST_NOT_FOUND; msg: 'WSAHOST_NOT_FOUND'), (err: WSATRY_AGAIN;
msg: 'WSATRY_AGAIN'), (err: WSANO_RECOVERY; msg: 'WSANO_RECOVERY'), (err: WSANO_DATA; msg: 'WSANO_DATA'), (err: WSAENOMORE; msg: 'WSAENOMORE'),
(err: WSAECANCELLED; msg: 'WSAECANCELLED'), (err: WSAEINVALIDPROCTABLE; msg: 'WSAEINVALIDPROCTABLE'), (err: WSAEINVALIDPROVIDER;
msg: 'WSAEINVALIDPROVIDER'), (err: WSAEPROVIDERFAILEDINIT; msg: 'WSAEPROVIDERFAILEDINIT'), (err: WSASYSCALLFAILURE; msg: 'WSASYSCALLFAILURE'),
(err: WSASERVICE_NOT_FOUND; msg: 'WSASERVICE_NOT_FOUND'), (err: WSATYPE_NOT_FOUND; msg: 'WSATYPE_NOT_FOUND'), (err: WSA_E_NO_MORE; msg: 'WSA_E_NO_MORE'),
(err: WSA_E_CANCELLED; msg: 'WSA_E_CANCELLED'), (err: WSAEREFUSED; msg: 'WSAEREFUSED'), //
(err: AVERROR_BSF_NOT_FOUND; msg: 'Bitstream filter not found'), (err: AVERROR_BUG; msg: 'Internal bug, should not have happened'), (err: AVERROR_BUG2;
msg: 'Internal bug, should not have happened'), (err: AVERROR_BUFFER_TOO_SMALL; msg: 'Buffer too small'), (err: AVERROR_DECODER_NOT_FOUND;
msg: 'Decoder not found'), (err: AVERROR_DEMUXER_NOT_FOUND; msg: 'Demuxer not found'), (err: AVERROR_ENCODER_NOT_FOUND; msg: 'Encoder not found'),
(err: AVERROR_EOF; msg: 'End of file'), (err: AVERROR_EXIT; msg: 'Immediate exit requested'), (err: AVERROR_EXTERNAL;
msg: 'Generic error in an external library'), (err: AVERROR_FILTER_NOT_FOUND; msg: 'Filter not found'), (err: AVERROR_INVALIDDATA;
msg: 'Invalid data found when processing input'), (err: AVERROR_MUXER_NOT_FOUND; msg: 'Muxer not found'), (err: AVERROR_OPTION_NOT_FOUND;
msg: 'Option not found'), (err: AVERROR_PATCHWELCOME; msg: 'Not yet implemented in FFmpeg, patches welcome'), (err: AVERROR_PROTOCOL_NOT_FOUND;
msg: 'Protocol not found'), (err: AVERROR_STREAM_NOT_FOUND; msg: 'Stream not found'), (err: AVERROR_UNKNOWN; msg: 'Unknown error occurred'),
(err: AVERROR_EXPERIMENTAL; msg: 'Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it.'),
(err: AVERROR_INPUT_CHANGED; msg: 'Input changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_OUTPUT_CHANGED)'),
(err: AVERROR_OUTPUT_CHANGED; msg: 'Output changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_INPUT_CHANGED)'),
(err: AVERROR_HTTP_BAD_REQUEST; msg: 'HTTP or RTSP error: bad request(400)'), (err: AVERROR_HTTP_UNAUTHORIZED;
msg: 'HTTP or RTSP error: unauthorized(401)'), (err: AVERROR_HTTP_FORBIDDEN; msg: 'HTTP or RTSP error: forbidden(403)'), (err: AVERROR_HTTP_NOT_FOUND;
msg: 'HTTP or RTSP error: not found(404)'), (err: AVERROR_HTTP_OTHER_4XX; msg: 'HTTP or RTSP error: other error(4xx)'), (err: AVERROR_HTTP_SERVER_ERROR;
msg: 'HTTP or RTSP error: server error(5xx)'), (err: AVERROR_ENOENT; msg: 'No such file or directory'), (err: AVERROR_ESRCH; msg: 'No such process'),
(err: AVERROR_EINTR; msg: 'Interrupted function call'), (err: AVERROR_EIO; msg: 'I/O error'), (err: AVERROR_ENXIO; msg: 'No such device or address'),
(err: AVERROR_E2BIG; msg: 'Argument list too long'), (err: AVERROR_ENOEXEC; msg: 'Exec format error'), (err: AVERROR_EBADF; msg: 'Bad file number'),
(err: AVERROR_ECHILD; msg: 'No child processes'), (err: AVERROR_EAGAIN; msg: 'Resource temporarily unavailable / Try again'), (err: AVERROR_ENOMEM;
msg: 'Not enough space / Out of memory'), (err: AVERROR_EACCES; msg: 'Permission denied'), (err: AVERROR_EFAULT; msg: 'Bad address'), (err: AVERROR_ENOTBLK;
msg: 'Unknown error'), (err: AVERROR_EBUSY; msg: 'Device or resource busy'), (err: AVERROR_EEXIST; msg: 'File exists'), (err: AVERROR_EXDEV;
msg: 'Cross-device link'), (err: AVERROR_ENODEV; msg: 'No such device'), (err: AVERROR_ENOTDIR; msg: 'Not a directory'), (err: AVERROR_EISDIR;
msg: 'Is a directory'), (err: AVERROR_EINVAL; msg: 'Invalid argument / Invalid data found when processing input'), (err: AVERROR_ENFILE;
msg: 'Too many open files in system / File table overflow'), (err: AVERROR_EMFILE; msg: 'Too many open files'), (err: AVERROR_ENOTTY;
msg: 'Inappropriate I/O control operation / Not a typewriter'), (err: AVERROR_ETXTBSY; msg: 'Unknown error'), (err: AVERROR_EFBIG; msg: 'File too large'),
(err: AVERROR_ENOSPC; msg: 'No space left on device'), (err: AVERROR_ESPIPE; msg: 'Illegal seek'), (err: AVERROR_EROFS; msg: 'Read-only file system'),
(err: AVERROR_EMLINK; msg: 'Too many links'), (err: AVERROR_EPIPE; msg: 'Broken pipe'), (err: AVERROR_EDOM; msg: 'Math argument out of domain of func'),
(err: AVERROR_ERANGE; msg: 'Math result not representable'), (err: AVERROR_EDEADLK; msg: 'Resource deadlock avoided'), (err: AVERROR_ENAMETOOLONG;
msg: 'File name too long'), (err: AVERROR_ENOLCK; msg: 'No locks available'), (err: AVERROR_ENOSYS; msg: 'Function not implemented'),
(err: AVERROR_ENOTEMPTY; msg: 'Directory not empty'), (err: AVERROR_ELOOP; msg: 'Too many symbolic links encountered'), (err: AVERROR_ENOMSG;
msg: 'Unknown error'), (err: AVERROR_EIDRM; msg: 'Unknown error'), (err: AVERROR_ENOSTR; msg: 'Unknown error'), (err: AVERROR_ENODATA;
msg: 'Unknown error'), (err: AVERROR_ETIME; msg: 'Unknown error'), (err: AVERROR_ENOSR; msg: 'Unknown error'), (err: AVERROR_EREMOTE; msg: 'Unknown error'),
(err: AVERROR_ENOLINK; msg: 'Unknown error'), (err: AVERROR_EPROTO; msg: 'Protocol error'), (err: AVERROR_EMULTIHOP; msg: 'Unknown error'),
(err: AVERROR_EBADMSG; msg: 'Unknown error'), (err: AVERROR_EOVERFLOW; msg: 'Value too large for defined data type'), (err: AVERROR_EILSEQ;
msg: 'Illegal byte sequence'), (err: AVERROR_EUSERS; msg: 'Unknown error'), (err: AVERROR_ENOTSOCK; msg: 'Socket operation on non-socket'),
(err: AVERROR_EDESTADDRREQ; msg: 'Destination address required'), (err: AVERROR_EMSGSIZE; msg: 'Message too long'), (err: AVERROR_EPROTOTYPE;
msg: 'Protocol wrong type for socket'), (err: AVERROR_ENOPROTOOPT; msg: 'Protocol not available'), (err: AVERROR_EPROTONOSUPPORT;
msg: 'Protocol not supported'), (err: AVERROR_ESOCKTNOSUPPORT; msg: 'Unknown error'), (err: AVERROR_EOPNOTSUPP;
msg: 'Operation not supported on transport endpoint'), (err: AVERROR_EPFNOSUPPORT; msg: 'Unknown error'), (err: AVERROR_EAFNOSUPPORT;
msg: 'Address family not supported by protocol'), (err: AVERROR_EADDRINUSE; msg: 'Address already in use'), (err: AVERROR_EADDRNOTAVAIL;
msg: 'Cannot assign requested address'), (err: AVERROR_ENETDOWN; msg: 'Network is down'), (err: AVERROR_ENETUNREACH; msg: 'Network is unreachable'),
(err: AVERROR_ENETRESET; msg: 'Network dropped connection because of reset'), (err: AVERROR_ECONNABORTED; msg: 'Software caused connection abort'),
(err: AVERROR_ECONNRESET; msg: 'Connection reset by peer'), (err: AVERROR_ENOBUFS; msg: 'No buffer space available'), (err: AVERROR_EISCONN;
msg: 'Transport endpoint is already connected'), (err: AVERROR_ENOTCONN; msg: 'Transport endpoint is not connected'), (err: AVERROR_ESHUTDOWN;
msg: 'Unknown error'), (err: AVERROR_ETOOMANYREFS; msg: 'Unknown error'), (err: AVERROR_ETIMEDOUT; msg: 'Connection timed out'), (err: AVERROR_ECONNREFUSED;
msg: 'Connection refused'), (err: AVERROR_EHOSTDOWN; msg: 'Unknown error'), (err: AVERROR_EHOSTUNREACH; msg: 'No route to host'), (err: AVERROR_EALREADY;
msg: 'Operation already in progress'), (err: AVERROR_EINPROGRESS; msg: 'Operation now in progress'), (err: AVERROR_ESTALE; msg: 'Unknown error'),
(err: AVERROR_ECANCELED; msg: 'Operation Canceled'), (err: AVERROR_EOWNERDEAD; msg: 'Owner died'), (err: AVERROR_ENOTRECOVERABLE;
msg: 'State not recoverable'));
(* *
* Put a description of the AVERROR code errnum in errbuf.
* In case of failure the global variable errno is set to indicate the
* error. Even in case of failure av_strerror() will print a generic
* error message indicating the errnum provided to errbuf.
*
* @param errnum error code to describe
* @param errbuf buffer to which description is written
* @param errbuf_size the size in bytes of errbuf
* @return 0 on success, a negative value if a description for errnum
* cannot be found
*)
// int av_strerror(int errnum, char *errbuf, size_t errbuf_size);
function av_strerror(errnum: int; errbuf: PAnsiChar; errbuf_size: size_t): int; cdecl; external avutil_dll;
(* *
* Fill the provided buffer with a string containing an error string
* corresponding to the AVERROR code errnum.
*
* @param errbuf a buffer
* @param errbuf_size size in bytes of errbuf
* @param errnum error code to describe
* @return the buffer in input, filled with the error description
* @see av_strerror()
*)
// static inline char *av_make_error_string(char *errbuf, size_t errbuf_size, int errnum)
function av_make_error_string(errbuf: PAnsiChar; errbuf_size: size_t; errnum: int): PAnsiChar; inline;
(* *
* Convenience macro, the return value should be used only directly in
* function arguments but never stand-alone.
*)
function av_err2str(errnum: int): PAnsiChar;
{$ENDREGION}
{$REGION 'cpu.h'}
const
AV_CPU_FLAG_FORCE = $80000000; (* force usage of selected flags (OR) *)
(* lower 16 bits - CPU features *)
AV_CPU_FLAG_MMX = $0001; // < standard MMX
AV_CPU_FLAG_MMXEXT = $0002; // < SSE integer functions or AMD MMX ext
AV_CPU_FLAG_MMX2 = $0002; // < SSE integer functions or AMD MMX ext
AV_CPU_FLAG_3DNOW = $0004; // < AMD 3DNOW
AV_CPU_FLAG_SSE = $0008; // < SSE functions
AV_CPU_FLAG_SSE2 = $0010; // < PIV SSE2 functions
AV_CPU_FLAG_SSE2SLOW = $40000000; // < SSE2 supported, but usually not faster
// < than regular MMX/SSE (e.g. Core1)
AV_CPU_FLAG_3DNOWEXT = $0020; // < AMD 3DNowExt
AV_CPU_FLAG_SSE3 = $0040; // < Prescott SSE3 functions
AV_CPU_FLAG_SSE3SLOW = $20000000; // < SSE3 supported, but usually not faster
// < than regular MMX/SSE (e.g. Core1)
AV_CPU_FLAG_SSSE3 = $0080; // < Conroe SSSE3 functions
AV_CPU_FLAG_SSSE3SLOW = $4000000; // < SSSE3 supported, but usually not faster
AV_CPU_FLAG_ATOM = $10000000; // < Atom processor, some SSSE3 instructions are slower
AV_CPU_FLAG_SSE4 = $0100; // < Penryn SSE4.1 functions
AV_CPU_FLAG_SSE42 = $0200; // < Nehalem SSE4.2 functions
AV_CPU_FLAG_AESNI = $80000; // < Advanced Encryption Standard functions
AV_CPU_FLAG_AVX = $4000; // < AVX functions: requires OS support even if YMM registers aren't used
AV_CPU_FLAG_AVXSLOW = $8000000; // < AVX supported, but slow when using YMM registers (e.g. Bulldozer)
AV_CPU_FLAG_XOP = $0400; // < Bulldozer XOP functions
AV_CPU_FLAG_FMA4 = $0800; // < Bulldozer FMA4 functions
AV_CPU_FLAG_CMOV = $1000; // < supports cmov instruction
AV_CPU_FLAG_AVX2 = $8000; // < AVX2 functions: requires OS support even if YMM registers aren't used
AV_CPU_FLAG_FMA3 = $10000; // < Haswell FMA3 functions
AV_CPU_FLAG_BMI1 = $20000; // < Bit Manipulation Instruction Set 1
AV_CPU_FLAG_BMI2 = $40000; // < Bit Manipulation Instruction Set 2
AV_CPU_FLAG_AVX512 = $100000; // < AVX-512 functions: requires OS support even if YMM/ZMM registers aren't used
AV_CPU_FLAG_ALTIVEC = $0001; // < standard
AV_CPU_FLAG_VSX = $0002; // < ISA 2.06
AV_CPU_FLAG_POWER8 = $0004; // < ISA 2.07
AV_CPU_FLAG_ARMV5TE = (1 shl 0);
AV_CPU_FLAG_ARMV6 = (1 shl 1);
AV_CPU_FLAG_ARMV6T2 = (1 shl 2);
AV_CPU_FLAG_VFP = (1 shl 3);
AV_CPU_FLAG_VFPV3 = (1 shl 4);
AV_CPU_FLAG_NEON = (1 shl 5);
AV_CPU_FLAG_ARMV8 = (1 shl 6);
AV_CPU_FLAG_VFP_VM = (1 shl 7); // < VFPv2 vector mode, deprecated in ARMv7-A and unavailable in various CPUs implementations
AV_CPU_FLAG_SETEND = (1 shl 16);
(* *
* Return the flags which specify extensions supported by the CPU.
* The returned value is affected by av_force_cpu_flags() if that was used
* before. So av_get_cpu_flags() can easily be used in an application to
* detect the enabled cpu flags.
*)
// int av_get_cpu_flags(void);
function av_get_cpu_flags(): int; cdecl; external avutil_dll;
(* *
* Disables cpu detection and forces the specified flags.
* -1 is a special case that disables forcing of specific flags.
*)
// void av_force_cpu_flags(int flags);
procedure av_force_cpu_flags(flags: int); cdecl; external avutil_dll;
(* *
* Set a mask on flags returned by av_get_cpu_flags().
* This function is mainly useful for testing.
* Please use av_force_cpu_flags() and av_get_cpu_flags() instead which are more flexible
*)
// attribute_deprecated void av_set_cpu_flags_mask(int mask);
procedure av_set_cpu_flags_mask(mask: int); cdecl; external avutil_dll;
deprecated 'Please use av_force_cpu_flags() and av_get_cpu_flags() instead which are more flexible';
(* *
* Parse CPU flags from a string.
*
* The returned flags contain the specified flags as well as related unspecified flags.
*
* This function exists only for compatibility with libav.
* Please use av_parse_cpu_caps() when possible.
* @return a combination of AV_CPU_* flags, negative on error.
*)
// attribute_deprecated int av_parse_cpu_flags(const char *s);
function av_parse_cpu_flags(const s: PAnsiChar): int; cdecl; external avutil_dll; deprecated 'Please use av_parse_cpu_caps() when possible';
(* *
* Parse CPU caps from a string and update the given AV_CPU_* flags based on that.
*
* @return negative on error.
*)
// int av_parse_cpu_caps(unsigned *flags, const char *s);
function av_parse_cpu_caps(var flags: unsigned; const s: PAnsiChar): int; cdecl; external avutil_dll;
(* *
* @return the number of logical CPU cores present.
*)
// int av_cpu_count(void);
function av_cpu_count(): int; cdecl; external avutil_dll;
(* *
* Get the maximum data alignment that may be required by FFmpeg.
*
* Note that this is affected by the build configuration and the CPU flags mask,
* so e.g. if the CPU supports AVX, but libavutil has been built with
* --disable-avx or the AV_CPU_FLAG_AVX flag has been disabled through
* av_set_cpu_flags_mask(), then this function will behave as if AVX is not
* present.
*)
// size_t av_cpu_max_align(void);
function av_cpu_max_align(): size_t; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'audio_fifo.h'}
(* *
* Context for an Audio FIFO Buffer.
*
* - Operates at the sample level rather than the byte level.
* - Supports multiple channels with either planar or packed sample format.
* - Automatic reallocation when writing to a full buffer.
*)
type
pAVAudioFifo = ^AVAudioFifo;
AVAudioFifo = record
end;
(* *
* Free an AVAudioFifo.
*
* @param af AVAudioFifo to free
*)
// void av_audio_fifo_free(AVAudioFifo *af);
procedure av_audio_fifo_free(af: pAVAudioFifo); cdecl; external avutil_dll;
(* *
* Allocate an AVAudioFifo.
*
* @param sample_fmt sample format
* @param channels number of channels
* @param nb_samples initial allocation size, in samples
* @return newly allocated AVAudioFifo, or NULL on error
*)
// AVAudioFifo *av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels,
// int nb_samples);
function av_audio_fifo_alloc(sample_fmt: AVSampleFormat; channels: int; nb_samples: int): pAVAudioFifo; cdecl; external avutil_dll;
(* *
* Reallocate an AVAudioFifo.
*
* @param af AVAudioFifo to reallocate
* @param nb_samples new allocation size, in samples
* @return 0 if OK, or negative AVERROR code on failure
*)
// av_warn_unused_result
// int av_audio_fifo_realloc(AVAudioFifo *af, int nb_samples);
function av_audio_fifo_realloc(af: pAVAudioFifo; nb_samples: int): int; cdecl; external avutil_dll;
(* *
* Write data to an AVAudioFifo.
*
* The AVAudioFifo will be reallocated automatically if the available space
* is less than nb_samples.
*
* @see enum AVSampleFormat
* The documentation for AVSampleFormat describes the data layout.
*
* @param af AVAudioFifo to write to
* @param data audio data plane pointers
* @param nb_samples number of samples to write
* @return number of samples actually written, or negative AVERROR
* code on failure. If successful, the number of samples
* actually written will always be nb_samples.
*)
// int av_audio_fifo_write(AVAudioFifo *af, void **data, int nb_samples);
function av_audio_fifo_write(af: pAVAudioFifo; var data: puint8_t; nb_samples: int): int; cdecl; external avutil_dll;
(* *
* Peek data from an AVAudioFifo.
*
* @see enum AVSampleFormat
* The documentation for AVSampleFormat describes the data layout.
*
* @param af AVAudioFifo to read from
* @param data audio data plane pointers
* @param nb_samples number of samples to peek
* @return number of samples actually peek, or negative AVERROR code
* on failure. The number of samples actually peek will not
* be greater than nb_samples, and will only be less than
* nb_samples if av_audio_fifo_size is less than nb_samples.
*)
// int av_audio_fifo_peek(AVAudioFifo *af, void **data, int nb_samples);
function av_audio_fifo_peek(af: pAVAudioFifo; var data: puint8_t; nb_samples: int): int; cdecl; external avutil_dll;
(* *
* Peek data from an AVAudioFifo.
*
* @see enum AVSampleFormat
* The documentation for AVSampleFormat describes the data layout.
*
* @param af AVAudioFifo to read from
* @param data audio data plane pointers
* @param nb_samples number of samples to peek
* @param offset offset from current read position
* @return number of samples actually peek, or negative AVERROR code
* on failure. The number of samples actually peek will not
* be greater than nb_samples, and will only be less than
* nb_samples if av_audio_fifo_size is less than nb_samples.
*)
// int av_audio_fifo_peek_at(AVAudioFifo *af, void **data, int nb_samples, int offset);
function av_audio_fifo_peek_at(af: pAVAudioFifo; var data: Pointer; nb_samples: int; offset: int): int; cdecl; external avutil_dll;
(* *
* Read data from an AVAudioFifo.
*
* @see enum AVSampleFormat
* The documentation for AVSampleFormat describes the data layout.
*
* @param af AVAudioFifo to read from
* @param data audio data plane pointers
* @param nb_samples number of samples to read
* @return number of samples actually read, or negative AVERROR code
* on failure. The number of samples actually read will not
* be greater than nb_samples, and will only be less than
* nb_samples if av_audio_fifo_size is less than nb_samples.
*)
// int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples);
function av_audio_fifo_read(af: pAVAudioFifo; var data: Pointer; nb_samples: int): int; cdecl; external avutil_dll;
(* *
* Drain data from an AVAudioFifo.
*
* Removes the data without reading it.
*
* @param af AVAudioFifo to drain
* @param nb_samples number of samples to drain
* @return 0 if OK, or negative AVERROR code on failure
*)
// int av_audio_fifo_drain(AVAudioFifo *af, int nb_samples);
function av_audio_fifo_drain(af: pAVAudioFifo; nb_samples: int): int; cdecl; external avutil_dll;
(* *
* Reset the AVAudioFifo buffer.
*
* This empties all data in the buffer.
*
* @param af AVAudioFifo to reset
*)
// void av_audio_fifo_reset(AVAudioFifo *af);
procedure av_audio_fifo_reset(af: pAVAudioFifo); cdecl; external avutil_dll;
(* *
* Get the current number of samples in the AVAudioFifo available for reading.
*
* @param af the AVAudioFifo to query
* @return number of samples available for reading
*)
// int av_audio_fifo_size(AVAudioFifo *af);
function av_audio_fifo_size(af: pAVAudioFifo): int; cdecl; external avutil_dll;
(* *
* Get the current number of samples in the AVAudioFifo available for writing.
*
* @param af the AVAudioFifo to query
* @return number of samples available for writing
*)
// int av_audio_fifo_space(AVAudioFifo *af);
function av_audio_fifo_space(af: pAVAudioFifo): int; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'avstring.h'}
(* *
* Return non-zero if pfx is a prefix of str. If it is, *ptr is set to
* the address of the first character in str after the prefix.
*
* @param str input string
* @param pfx prefix to test
* @param ptr updated if the prefix is matched inside str
* @return non-zero if the prefix matches, zero otherwise
*)
// int av_strstart(const char *str, const char *pfx, const char **ptr);
function av_strstart(const str: PAnsiChar; const pfx: PAnsiChar; const ptr: ppAnsiChar): int; cdecl; external avutil_dll;
(* *
* Return non-zero if pfx is a prefix of str independent of case. If
* it is, *ptr is set to the address of the first character in str
* after the prefix.
*
* @param str input string
* @param pfx prefix to test
* @param ptr updated if the prefix is matched inside str
* @return non-zero if the prefix matches, zero otherwise
*)
// int av_stristart(const char *str, const char *pfx, const char **ptr);
function av_stristart(const str: PAnsiChar; const pfx: PAnsiChar; const ptr: ppAnsiChar): int; cdecl; external avutil_dll;
(* *
* Locate the first case-independent occurrence in the string haystack
* of the string needle. A zero-length string needle is considered to
* match at the start of haystack.
*
* This function is a case-insensitive version of the standard strstr().
*
* @param haystack string to search in
* @param needle string to search for
* @return pointer to the located match within haystack
* or a null pointer if no match
*)
// char *av_stristr(const char *haystack, const char *needle);
function av_stristr(const haystack: PAnsiChar; const needle: PAnsiChar): PAnsiChar; cdecl; external avutil_dll;
(* *
* Locate the first occurrence of the string needle in the string haystack
* where not more than hay_length characters are searched. A zero-length
* string needle is considered to match at the start of haystack.
*
* This function is a length-limited version of the standard strstr().
*
* @param haystack string to search in
* @param needle string to search for
* @param hay_length length of string to search in
* @return pointer to the located match within haystack
* or a null pointer if no match
*)
// char *av_strnstr(const char *haystack, const char *needle, size_t hay_length);
function av_strnstr(const haystack: PAnsiChar; const needle: PAnsiChar; hay_length: size_t): PAnsiChar; cdecl; external avutil_dll;
(* *
* Copy the string src to dst, but no more than size - 1 bytes, and
* null-terminate dst.
*
* This function is the same as BSD strlcpy().
*
* @param dst destination buffer
* @param src source string
* @param size size of destination buffer
* @return the length of src
*
* @warning since the return value is the length of src, src absolutely
* _must_ be a properly 0-terminated string, otherwise this will read beyond
* the end of the buffer and possibly crash.
*)
// size_t av_strlcpy(char *dst, const char *src, size_t size);
function av_strlcpy(dst: PAnsiChar; const src: PAnsiChar; size: size_t): size_t; cdecl; external avutil_dll;
(* *
* Append the string src to the string dst, but to a total length of
* no more than size - 1 bytes, and null-terminate dst.
*
* This function is similar to BSD strlcat(), but differs when
* size <= strlen(dst).
*
* @param dst destination buffer
* @param src source string
* @param size size of destination buffer
* @return the total length of src and dst
*
* @warning since the return value use the length of src and dst, these
* absolutely _must_ be a properly 0-terminated strings, otherwise this
* will read beyond the end of the buffer and possibly crash.
*)
// size_t av_strlcat(char *dst, const char *src, size_t size);
function av_strlcat(dst: PAnsiChar; const src: PAnsiChar; size: size_t): size_t; cdecl; external avutil_dll;
(* *
* Append output to a string, according to a format. Never write out of
* the destination buffer, and always put a terminating 0 within
* the buffer.
* @param dst destination buffer (string to which the output is
* appended)
* @param size total size of the destination buffer
* @param fmt printf-compatible format string, specifying how the
* following parameters are used
* @return the length of the string that would have been generated
* if enough space had been available
*)
// size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) av_printf_format(3, 4);
(* *
* Get the count of continuous non zero chars starting from the beginning.
*
* @param len maximum number of characters to check in the string, that
* is the maximum value which is returned by the function
*)
// static inline size_t av_strnlen(const char *s, size_t len)
function av_strnlen(const s: PAnsiChar; len: size_t): size_t; inline;
(* *
* Print arguments following specified format into a large enough auto
* allocated buffer. It is similar to GNU asprintf().
* @param fmt printf-compatible format string, specifying how the
* following parameters are used.
* @return the allocated string
* @note You have to free the string yourself with av_free().
*)
// char *av_asprintf(const char *fmt, ...) av_printf_format(1, 2);
(* *
* Convert a number to an av_malloced string.
*)
// char *av_d2str(double d);
function av_d2str(d: double): PAnsiChar; cdecl; external avutil_dll;
(* *
* Unescape the given string until a non escaped terminating char,
* and return the token corresponding to the unescaped string.
*
* The normal \ and ' escaping is supported. Leading and trailing
* whitespaces are removed, unless they are escaped with '\' or are
* enclosed between ''.
*
* @param buf the buffer to parse, buf will be updated to point to the
* terminating char
* @param term a 0-terminated list of terminating chars
* @return the malloced unescaped string, which must be av_freed by
* the user, NULL in case of allocation failure
*)
// char *av_get_token(const char **buf, const char *term);
function av_get_token(const buf: ppAnsiChar; const term: PAnsiChar): PAnsiChar; cdecl; external avutil_dll;
(* *
* Split the string into several tokens which can be accessed by
* successive calls to av_strtok().
*
* A token is defined as a sequence of characters not belonging to the
* set specified in delim.
*
* On the first call to av_strtok(), s should point to the string to
* parse, and the value of saveptr is ignored. In subsequent calls, s
* should be NULL, and saveptr should be unchanged since the previous
* call.
*
* This function is similar to strtok_r() defined in POSIX.1.
*
* @param s the string to parse, may be NULL
* @param delim 0-terminated list of token delimiters, must be non-NULL
* @param saveptr user-provided pointer which points to stored
* information necessary for av_strtok() to continue scanning the same
* string. saveptr is updated to point to the next character after the
* first delimiter found, or to NULL if the string was terminated
* @return the found token, or NULL when no token is found
*)
// char *av_strtok(char *s, const char *delim, char **saveptr);
function av_strtok(s: PAnsiChar; const delim: PAnsiChar; saveptr: ppAnsiChar): PAnsiChar; cdecl; external avutil_dll;
(* *
* Locale-independent conversion of ASCII isdigit.
*)
// static inline av_const int av_isdigit(int c)
function av_isdigit(c: int): Boolean; inline;
(* *
* Locale-independent conversion of ASCII isgraph.
*)
// static inline av_const int av_isgraph(int c)
function av_isgraph(c: int): Boolean; inline;
(* *
* Locale-independent conversion of ASCII isspace.
*)
// static inline av_const int av_isspace(int c)
function av_isspace(c1: int): Boolean; inline;
(* *
* Locale-independent conversion of ASCII characters to uppercase.
*)
// static inline av_const int av_toupper(int c)
function av_toupper(c1: int): int; inline;
(* *
* Locale-independent conversion of ASCII characters to lowercase.
*)
// static inline av_const int av_tolower(int c)
function av_tolower(c1: int): int; inline;
(* *
* Locale-independent conversion of ASCII isxdigit.
*)
// static inline av_const int av_isxdigit(int c)
function av_isxdigit(c1: int): Boolean; inline;
(* *
* Locale-independent case-insensitive compare.
* @note This means only ASCII-range characters are case-insensitive
*)
// int av_strcasecmp(const char *a, const char *b);
function av_strcasecmp(const a: PAnsiChar; const b: PAnsiChar): int; cdecl; external avutil_dll;
(* *
* Locale-independent case-insensitive compare.
* @note This means only ASCII-range characters are case-insensitive
*)
// int av_strncasecmp(const char *a, const char *b, size_t n);
function av_strncasecmp(const a: PAnsiChar; const b: PAnsiChar; n: size_t): int; cdecl; external avutil_dll;
(* *
* Locale-independent strings replace.
* @note This means only ASCII-range characters are replace
*)
// char *av_strireplace(const char *str, const char *from, const char *to);
function av_strireplace(const str: PAnsiChar; const from: PAnsiChar; const _to: PAnsiChar): PAnsiChar; cdecl; external avutil_dll;
(* *
* Thread safe basename.
* @param path the path, on DOS both \ and / are considered separators.
* @return pointer to the basename substring.
*)
// const char *av_basename(const char *path);
function av_basename(const path: PAnsiChar): PAnsiChar; cdecl; external avutil_dll;
(* *
* Thread safe dirname.
* @param path the path, on DOS both \ and / are considered separators.
* @return the path with the separator replaced by the string terminator or ".".
* @note the function may change the input string.
*)
// const char *av_dirname(char *path);
function av_dirname(path: PAnsiChar): PAnsiChar; cdecl; external avutil_dll;
(* *
* Match instances of a name in a comma-separated list of names.
* List entries are checked from the start to the end of the names list,
* the first match ends further processing. If an entry prefixed with '-'
* matches, then 0 is returned. The "ALL" list entry is considered to
* match all names.
*
* @param name Name to look for.
* @param names List of names.
* @return 1 on match, 0 otherwise.
*)
// int av_match_name(const char *name, const char *names);
function av_match_name(const name: PAnsiChar; const names: PAnsiChar): int; cdecl; external avutil_dll;
(* *
* Append path component to the existing path.
* Path separator '/' is placed between when needed.
* Resulting string have to be freed with av_free().
* @param path base path
* @param component component to be appended
* @return new path or NULL on error.
*)
// char *av_append_path_component(const char *path, const char *component);
function av_append_path_component(const path: PAnsiChar; const component: PAnsiChar): PAnsiChar; cdecl; external avutil_dll;
type
AVEscapeMode = ( //
AV_ESCAPE_MODE_AUTO,
// < Use auto-selected escaping mode.
AV_ESCAPE_MODE_BACKSLASH,
// < Use backslash escaping.
AV_ESCAPE_MODE_QUOTE
// < Use single-quote escaping.
);
const
(* *
* Consider spaces special and escape them even in the middle of the
* string.
*
* This is equivalent to adding the whitespace characters to the special
* characters lists, except it is guaranteed to use the exact same list
* of whitespace characters as the rest of libavutil.
*)
AV_ESCAPE_FLAG_WHITESPACE = (1 shl 0);
(* *
* Escape only specified special characters.
* Without this flag, escape also any characters that may be considered
* special by av_get_token(), such as the single quote.
*)
AV_ESCAPE_FLAG_STRICT = (1 shl 1);
(* *
* Escape string in src, and put the escaped string in an allocated
* string in *dst, which must be freed with av_free().
*
* @param dst pointer where an allocated string is put
* @param src string to escape, must be non-NULL
* @param special_chars string containing the special characters which
* need to be escaped, can be NULL
* @param mode escape mode to employ, see AV_ESCAPE_MODE_* macros.
* Any unknown value for mode will be considered equivalent to
* AV_ESCAPE_MODE_BACKSLASH, but this behaviour can change without
* notice.
* @param flags flags which control how to escape, see AV_ESCAPE_FLAG_ macros
* @return the length of the allocated string, or a negative error code in case of error
* @see av_bprint_escape()
*)
// av_warn_unused_result
// int av_escape(char **dst, const char *src, const char *special_chars,
// enum AVEscapeMode mode, int flags);
function av_escape(var dst: PAnsiChar; const src: PAnsiChar; const special_chars: PAnsiChar; mode: AVEscapeMode; flags: int): int; cdecl; external avutil_dll;
const
AV_UTF8_FLAG_ACCEPT_INVALID_BIG_CODES = 1;
// < accept codepoints over 0x10FFFF
AV_UTF8_FLAG_ACCEPT_NON_CHARACTERS = 2;
// < accept non-characters - 0xFFFE and 0xFFFF
AV_UTF8_FLAG_ACCEPT_SURROGATES = 4;
// < accept UTF-16 surrogates codes
AV_UTF8_FLAG_EXCLUDE_XML_INVALID_CONTROL_CODES = 8;
// < exclude control codes not accepted by XML
AV_UTF8_FLAG_ACCEPT_ALL = AV_UTF8_FLAG_ACCEPT_INVALID_BIG_CODES or AV_UTF8_FLAG_ACCEPT_NON_CHARACTERS or AV_UTF8_FLAG_ACCEPT_SURROGATES;
(* *
* Read and decode a single UTF-8 code point (character) from the
* buffer in *buf, and update *buf to point to the next byte to
* decode.
*
* In case of an invalid byte sequence, the pointer will be updated to
* the next byte after the invalid sequence and the function will
* return an error code.
*
* Depending on the specified flags, the function will also fail in
* case the decoded code point does not belong to a valid range.
*
* @note For speed-relevant code a carefully implemented use of
* GET_UTF8() may be preferred.
*
* @param codep pointer used to return the parsed code in case of success.
* The value in *codep is set even in case the range check fails.
* @param bufp pointer to the address the first byte of the sequence
* to decode, updated by the function to point to the
* byte next after the decoded sequence
* @param buf_end pointer to the end of the buffer, points to the next
* byte past the last in the buffer. This is used to
* avoid buffer overreads (in case of an unfinished
* UTF-8 sequence towards the end of the buffer).
* @param flags a collection of AV_UTF8_FLAG_* flags
* @return >= 0 in case a sequence was successfully read, a negative
* value in case of invalid sequence
*)
// av_warn_unused_result
// int av_utf8_decode(int32_t *codep, const uint8_t **bufp, const uint8_t *buf_end,
// unsigned int flags);
function av_utf8_decode(var codep: int32_t; const bufp: ppuint8_t; const buf_end: puint8_t; flags: unsigned_int): int; cdecl; external avutil_dll;
(* *
* Check if a name is in a list.
* @returns 0 if not found, or the 1 based index where it has been found in the
* list.
*)
// int av_match_list(const char *name, const char *list, char separator);
function av_match_list(const name: PAnsiChar; const list: PAnsiChar; separator: AnsiChar): int; cdecl; external avutil_dll;
(*
* See libc sscanf manual for more information.
* Locale-independent sscanf implementation.
*)
// int av_sscanf(const char *string, const char *format, ...);
{$ENDREGION}
{$REGION 'bprint.h'}
const
(* *
* Convenience macros for special values for av_bprint_init() size_max
* parameter.
*)
AV_BPRINT_SIZE_UNLIMITED = ((max_unsigned) - 1);
AV_BPRINT_SIZE_AUTOMATIC = 1;
AV_BPRINT_SIZE_COUNT_ONLY = 0;
(* *
* Init a print buffer.
*
* @param buf buffer to init
* @param size_init initial size (including the final 0)
* @param size_max maximum size;
* 0 means do not write anything, just count the length;
* 1 is replaced by the maximum value for automatic storage;
* any large value means that the internal buffer will be
* reallocated as needed up to that limit; -1 is converted to
* UINT_MAX, the largest limit possible.
* Check also AV_BPRINT_SIZE_* macros.
*)
// void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max);
procedure av_bprint_init(buf: pAVBPrint; size_init: unsigned; size_max: unsigned); cdecl; external avutil_dll;
(* *
* Init a print buffer using a pre-existing buffer.
*
* The buffer will not be reallocated.
*
* @param buf buffer structure to init
* @param buffer byte buffer to use for the string data
* @param size size of buffer
*)
// void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size);
procedure av_bprint_init_for_buffer(buf: pAVBPrint; buffer: PAnsiChar; size: unsigned); cdecl; external avutil_dll;
(* *
* Append a formatted string to a print buffer.
*)
// void av_bprintf(AVBPrint *buf, const char *fmt, ...) av_printf_format(2, 3);
(* *
* Append a formatted string to a print buffer.
*)
// void av_vbprintf(AVBPrint *buf, const char *fmt, va_list vl_arg);
procedure av_vbprintf(buf: pAVBPrint; const fmt: PAnsiChar; vl_arg: PVA_LIST); cdecl; external avutil_dll;
(* *
* Append char c n times to a print buffer.
*)
// void av_bprint_chars(AVBPrint *buf, char c, unsigned n);
procedure av_bprint_chars(buf: pAVBPrint; c: AnsiChar; n: unsigned); cdecl; external avutil_dll;
(* *
* Append data to a print buffer.
*
* param buf bprint buffer to use
* param data pointer to data
* param size size of data
*)
// void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size);
procedure av_bprint_append_data(buf: pAVBPrint; const data: PAnsiChar; size: unsigned); cdecl; external avutil_dll;
type
ptm = ^tm;
tm = record
end;
(* *
* Append a formatted date and time to a print buffer.
*
* param buf bprint buffer to use
* param fmt date and time format string, see strftime()
* param tm broken-down time structure to translate
*
* @note due to poor design of the standard strftime function, it may
* produce poor results if the format string expands to a very long text and
* the bprint buffer is near the limit stated by the size_max option.
*)
// void av_bprint_strftime(AVBPrint *buf, const char *fmt, const struct tm *tm);
procedure av_bprint_strftime(buf: pAVBPrint; const fmt: PAnsiChar; const tm: ptm); cdecl; external avutil_dll;
(* *
* Allocate bytes in the buffer for external use.
*
* @param[in] buf buffer structure
* @param[in] size required size
* @param[out] mem pointer to the memory area
* @param[out] actual_size size of the memory area after allocation;
* can be larger or smaller than size
*)
// void av_bprint_get_buffer(AVBPrint *buf, unsigned size,
// unsigned char **mem, unsigned *actual_size);
procedure av_bprint_get_buffer(buf: pAVBPrint; size: unsigned; var mem: punsigned_char; var actual_size: unsigned); cdecl; external avutil_dll;
(* *
* Reset the string to "" but keep internal allocated data.
*)
// void av_bprint_clear(AVBPrint *buf);
procedure av_bprint_clear(buf: pAVBPrint); cdecl; external avutil_dll;
(* *
* Test if the print buffer is complete (not truncated).
*
* It may have been truncated due to a memory allocation failure
* or the size_max limit (compare size and size_max if necessary).
*)
// static inline int av_bprint_is_complete(const AVBPrint *buf)
function av_bprint_is_complete(const buf: pAVBPrint): Boolean; inline;
(* *
* Finalize a print buffer.
*
* The print buffer can no longer be used afterwards,
* but the len and size fields are still valid.
*
* @arg[out] ret_str if not NULL, used to return a permanent copy of the
* buffer contents, or NULL if memory allocation fails;
* if NULL, the buffer is discarded and freed
* @return 0 for success or error code (probably AVERROR(ENOMEM))
*)
// int av_bprint_finalize(AVBPrint *buf, char **ret_str);
function av_bprint_finalize(buf: pAVBPrint; var ret_str: PAnsiChar): int; cdecl; external avutil_dll;
(* *
* Escape the content in src and append it to dstbuf.
*
* @param dstbuf already inited destination bprint buffer
* @param src string containing the text to escape
* @param special_chars string containing the special characters which
* need to be escaped, can be NULL
* @param mode escape mode to employ, see AV_ESCAPE_MODE_* macros.
* Any unknown value for mode will be considered equivalent to
* AV_ESCAPE_MODE_BACKSLASH, but this behaviour can change without
* notice.
* @param flags flags which control how to escape, see AV_ESCAPE_FLAG_* macros
*)
// void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_chars,
// enum AVEscapeMode mode, int flags);
procedure av_bprint_escape(dstbuf: pAVBPrint; const src: PAnsiChar; const special_chars: PAnsiChar; mode: AVEscapeMode; flags: int); cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'display.h'}
(* *
* @addtogroup lavu_video_display
* The display transformation matrix specifies an affine transformation that
* should be applied to video frames for correct presentation. It is compatible
* with the matrices stored in the ISO/IEC 14496-12 container format.
*
* The data is a 3x3 matrix represented as a 9-element array:
*
* @code{.unparsed}
* | a b u |
* (a, b, u, c, d, v, x, y, w) -> | c d v |
* | x y w |
* @endcode
*
* All numbers are stored in native endianness, as 16.16 fixed-point values,
* except for u, v and w, which are stored as 2.30 fixed-point values.
*
* The transformation maps a point (p, q) in the source (pre-transformation)
* frame to the point (p', q') in the destination (post-transformation) frame as
* follows:
*
* @code{.unparsed}
* | a b u |
* (p, q, 1) . | c d v | = z * (p', q', 1)
* | x y w |
* @endcode
*
* The transformation can also be more explicitly written in components as
* follows:
*
* @code{.unparsed}
* p' = (a * p + c * q + x) / z;
* q' = (b * p + d * q + y) / z;
* z = u * p + v * q + w
* @endcode
*)
type
Tav_display_matrix = array [0 .. 8] of int32_t;
(* *
* Extract the rotation component of the transformation matrix.
*
* @param matrix the transformation matrix
* @return the angle (in degrees) by which the transformation rotates the frame
* counterclockwise. The angle will be in range [-180.0, 180.0],
* or NaN if the matrix is singular.
*
* @note floating point numbers are inherently inexact, so callers are
* recommended to round the return value to nearest integer before use.
*)
// double av_display_rotation_get(const int32_t matrix[9]);
function av_display_rotation_get(const matrix: Tav_display_matrix): double; cdecl; external avutil_dll;
(* *
* Initialize a transformation matrix describing a pure counterclockwise
* rotation by the specified angle (in degrees).
*
* @param matrix an allocated transformation matrix (will be fully overwritten
* by this function)
* @param angle rotation angle in degrees.
*)
// void av_display_rotation_set(int32_t matrix[9], double angle);
procedure av_display_rotation_set(matrix: Tav_display_matrix; angle: double); cdecl; external avutil_dll;
(* *
* Flip the input matrix horizontally and/or vertically.
*
* @param matrix an allocated transformation matrix
* @param hflip whether the matrix should be flipped horizontally
* @param vflip whether the matrix should be flipped vertically
*)
// void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip);
procedure av_display_matrix_flip(matrix: Tav_display_matrix; hflip: int; vflip: int); cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'eval.h'}
type
pAVExpr = ^AVExpr;
AVExpr = record
end;
// double (* const *funcs1)(void *, double)
Tav_expr_funcs1 = function(p1: Pointer; p2: double): ppDouble; cdecl;
// double (* const *funcs2)(void *, double, double)
Tav_expr_funcs2 = function(p1: Pointer; p2: double; p3: double): ppDouble; cdecl;
(* *
* Parse and evaluate an expression.
* Note, this is significantly slower than av_expr_eval().
*
* @param res a pointer to a double where is put the result value of
* the expression, or NAN in case of error
* @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)"
* @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0}
* @param const_values a zero terminated array of values for the identifiers from const_names
* @param func1_names NULL terminated array of zero terminated strings of funcs1 identifiers
* @param funcs1 NULL terminated array of function pointers for functions which take 1 argument
* @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers
* @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments
* @param opaque a pointer which will be passed to all functions from funcs1 and funcs2
* @param log_ctx parent logging context
* @return >= 0 in case of success, a negative value corresponding to an
* AVERROR code otherwise
*)
// int av_expr_parse_and_eval(double *res, const char *s,
// const char * const *const_names, const double *const_values,
// const char * const *func1_names, double (* const *funcs1)(void *, double),
// const char * const *func2_names, double (* const *funcs2)(void *, double, double),
// void *opaque, int log_offset, void *log_ctx);
function av_expr_parse_and_eval(var res: double; const s: PAnsiChar; const_names: ppAnsiChar; const const_values: pdouble; func1_names: ppAnsiChar;
funcs1: Tav_expr_funcs1; func2_names: ppAnsiChar; funcs2: Tav_expr_funcs2; opaque: Pointer; log_offset: int; log_ctx: Pointer): int; cdecl;
external avutil_dll;
(* *
* Parse an expression.
*
* @param expr a pointer where is put an AVExpr containing the parsed
* value in case of successful parsing, or NULL otherwise.
* The pointed to AVExpr must be freed with av_expr_free() by the user
* when it is not needed anymore.
* @param s expression as a zero terminated string, for example "1+2^3+5*5+sin(2/3)"
* @param const_names NULL terminated array of zero terminated strings of constant identifiers, for example {"PI", "E", 0}
* @param func1_names NULL terminated array of zero terminated strings of funcs1 identifiers
* @param funcs1 NULL terminated array of function pointers for functions which take 1 argument
* @param func2_names NULL terminated array of zero terminated strings of funcs2 identifiers
* @param funcs2 NULL terminated array of function pointers for functions which take 2 arguments
* @param log_ctx parent logging context
* @return >= 0 in case of success, a negative value corresponding to an
* AVERROR code otherwise
*)
// int av_expr_parse(AVExpr **expr, const char *s,
// const char * const *const_names,
// const char * const *func1_names, double (* const *funcs1)(void *, double),
// const char * const *func2_names, double (* const *funcs2)(void *, double, double),
// int log_offset, void *log_ctx);
function av_expr_parse(var expr: pAVExpr; const s: PAnsiChar; const_names: ppAnsiChar; func1_names: ppAnsiChar; funcs1: Tav_expr_funcs1;
func2_names: ppAnsiChar; funcs2: Tav_expr_funcs2; log_offset: int; log_ctx: Pointer): int; cdecl; external avutil_dll;
(* *
* Evaluate a previously parsed expression.
*
* @param const_values a zero terminated array of values for the identifiers from av_expr_parse() const_names
* @param opaque a pointer which will be passed to all functions from funcs1 and funcs2
* @return the value of the expression
*)
// double av_expr_eval(AVExpr *e, const double *const_values, void *opaque);
function av_expr_eval(e: pAVExpr; const const_values: pdouble; opaque: Pointer): double; cdecl; external avutil_dll;
(* *
* Free a parsed expression previously created with av_expr_parse().
*)
// void av_expr_free(AVExpr *e);
procedure av_expr_free(e: pAVExpr); cdecl; external avutil_dll;
(* *
* Parse the string in numstr and return its value as a double. If
* the string is empty, contains only whitespaces, or does not contain
* an initial substring that has the expected syntax for a
* floating-point number, no conversion is performed. In this case,
* returns a value of zero and the value returned in tail is the value
* of numstr.
*
* @param numstr a string representing a number, may contain one of
* the International System number postfixes, for example 'K', 'M',
* 'G'. If 'i' is appended after the postfix, powers of 2 are used
* instead of powers of 10. The 'B' postfix multiplies the value by
* 8, and can be appended after another postfix or used alone. This
* allows using for example 'KB', 'MiB', 'G' and 'B' as postfix.
* @param tail if non-NULL puts here the pointer to the char next
* after the last parsed character
*)
// double av_strtod(const char *numstr, char **tail);
function av_strtod(const numstr: PAnsiChar; var tail: PAnsiChar): double; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'fifo.h'}
type
pAVFifoBuffer = ^AVFifoBuffer;
AVFifoBuffer = record
buffer: puint8_t;
rptr, wptr, _end: puint8_t;
rndx, wndx: uint32_t;
end;
(* *
* Initialize an AVFifoBuffer.
* @param size of FIFO
* @return AVFifoBuffer or NULL in case of memory allocation failure
*)
// AVFifoBuffer *av_fifo_alloc(unsigned int size);
function av_fifo_alloc(size: unsigned_int): pAVFifoBuffer; cdecl; external avutil_dll;
(* *
* Initialize an AVFifoBuffer.
* @param nmemb number of elements
* @param size size of the single element
* @return AVFifoBuffer or NULL in case of memory allocation failure
*)
// AVFifoBuffer *av_fifo_alloc_array(size_t nmemb, size_t size);
function av_fifo_alloc_array(nmemb: size_t; size: size_t): pAVFifoBuffer; cdecl; external avutil_dll;
(* *
* Free an AVFifoBuffer.
* @param f AVFifoBuffer to free
*)
// void av_fifo_free(AVFifoBuffer *f);
procedure av_fifo_free(f: pAVFifoBuffer); cdecl; external avutil_dll;
(* *
* Free an AVFifoBuffer and reset pointer to NULL.
* @param f AVFifoBuffer to free
*)
// void av_fifo_freep(AVFifoBuffer **f);
procedure av_fifo_freep(var f: pAVFifoBuffer); cdecl; external avutil_dll;
(* *
* Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied.
* @param f AVFifoBuffer to reset
*)
// void av_fifo_reset(AVFifoBuffer *f);
procedure av_fifo_reset(f: pAVFifoBuffer); cdecl; external avutil_dll;
(* *
* Return the amount of data in bytes in the AVFifoBuffer, that is the
* amount of data you can read from it.
* @param f AVFifoBuffer to read from
* @return size
*)
// int av_fifo_size(const AVFifoBuffer *f);
function av_fifo_size(const f: pAVFifoBuffer): int; cdecl; external avutil_dll;
(* *
* Return the amount of space in bytes in the AVFifoBuffer, that is the
* amount of data you can write into it.
* @param f AVFifoBuffer to write into
* @return size
*)
// int av_fifo_space(const AVFifoBuffer *f);
function av_fifo_space(const f: pAVFifoBuffer): int; cdecl; external avutil_dll;
(* *
* Feed data at specific position from an AVFifoBuffer to a user-supplied callback.
* Similar as av_fifo_gereric_read but without discarding data.
* @param f AVFifoBuffer to read from
* @param offset offset from current read position
* @param buf_size number of bytes to read
* @param func generic read function
* @param dest data destination
*)
// int av_fifo_generic_peek_at(AVFifoBuffer *f, void *dest, int offset, int buf_size, void (*func)(void*, void*, int));
type
Tav_fifo_proc = procedure(p1: Pointer; p2: Pointer; p3: int); cdecl;
Tav_fifo_func = function(p1: Pointer; p2: Pointer; p3: int): int; cdecl;
function av_fifo_generic_peek_at(f: pAVFifoBuffer; dest: Pointer; offset: int; buf_size: int; func: Tav_fifo_proc): int; cdecl; external avutil_dll;
(* *
* Feed data from an AVFifoBuffer to a user-supplied callback.
* Similar as av_fifo_gereric_read but without discarding data.
* @param f AVFifoBuffer to read from
* @param buf_size number of bytes to read
* @param func generic read function
* @param dest data destination
*)
// int av_fifo_generic_peek(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));
function av_fifo_generic_peek(f: pAVFifoBuffer; dest: Pointer; buf_size: int; func: Tav_fifo_proc): int; cdecl; external avutil_dll;
(* *
* Feed data from an AVFifoBuffer to a user-supplied callback.
* @param f AVFifoBuffer to read from
* @param buf_size number of bytes to read
* @param func generic read function
* @param dest data destination
*)
// int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void (*func)(void*, void*, int));
function av_fifo_generic_read(f: pAVFifoBuffer; dest: Pointer; buf_size: int; func: Tav_fifo_proc): int; cdecl; external avutil_dll;
(* *
* Feed data from a user-supplied callback to an AVFifoBuffer.
* @param f AVFifoBuffer to write to
* @param src data source; non-const since it may be used as a
* modifiable context by the function defined in func
* @param size number of bytes to write
* @param func generic write function; the first parameter is src,
* the second is dest_buf, the third is dest_buf_size.
* func must return the number of bytes written to dest_buf, or <= 0 to
* indicate no more data available to write.
* If func is NULL, src is interpreted as a simple byte array for source data.
* @return the number of bytes written to the FIFO
*)
// int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int));
function av_fifo_generic_write(f: pAVFifoBuffer; src: Pointer; size: int; func: Tav_fifo_func): int; cdecl; external avutil_dll;
(* *
* Resize an AVFifoBuffer.
* In case of reallocation failure, the old FIFO is kept unchanged.
*
* @param f AVFifoBuffer to resize
* @param size new AVFifoBuffer size in bytes
* @return <0 for failure, >=0 otherwise
*)
// int av_fifo_realloc2(AVFifoBuffer *f, unsigned int size);
function av_fifo_realloc2(f: pAVFifoBuffer; size: unsigned_int): int; cdecl; external avutil_dll;
(* *
* Enlarge an AVFifoBuffer.
* In case of reallocation failure, the old FIFO is kept unchanged.
* The new fifo size may be larger than the requested size.
*
* @param f AVFifoBuffer to resize
* @param additional_space the amount of space in bytes to allocate in addition to av_fifo_size()
* @return <0 for failure, >=0 otherwise
*)
// int av_fifo_grow(AVFifoBuffer *f, unsigned int additional_space);
function av_fifo_grow(f: pAVFifoBuffer; additional_space: unsigned_int): int; cdecl; external avutil_dll;
(* *
* Read and discard the specified amount of data from an AVFifoBuffer.
* @param f AVFifoBuffer to read from
* @param size amount of data to read in bytes
*)
// void av_fifo_drain(AVFifoBuffer *f, int size);
procedure av_fifo_drain(f: pAVFifoBuffer; size: int); cdecl; external avutil_dll;
(* *
* Return a pointer to the data stored in a FIFO buffer at a certain offset.
* The FIFO buffer is not modified.
*
* @param f AVFifoBuffer to peek at, f must be non-NULL
* @param offs an offset in bytes, its absolute value must be less
* than the used buffer size or the returned pointer will
* point outside to the buffer data.
* The used buffer size can be checked with av_fifo_size().
*)
// static inline uint8_t *av_fifo_peek2(const AVFifoBuffer *f, int offs)
function av_fifo_peek2(const f: pAVFifoBuffer; offs: int): puint8_t; inline;
{$ENDREGION}
{$REGION 'hwcontext.h'}
type
AVHWDeviceType = (AV_HWDEVICE_TYPE_NONE, AV_HWDEVICE_TYPE_VDPAU, AV_HWDEVICE_TYPE_CUDA, AV_HWDEVICE_TYPE_VAAPI, AV_HWDEVICE_TYPE_DXVA2, AV_HWDEVICE_TYPE_QSV,
AV_HWDEVICE_TYPE_VIDEOTOOLBOX, AV_HWDEVICE_TYPE_D3D11VA, AV_HWDEVICE_TYPE_DRM, AV_HWDEVICE_TYPE_OPENCL, AV_HWDEVICE_TYPE_MEDIACODEC);
pAVHWDeviceInternal = ^AVHWDeviceInternal;
AVHWDeviceInternal = record
end;
(* *
* This struct aggregates all the (hardware/vendor-specific) "high-level" state,
* i.e. state that is not tied to a concrete processing configuration.
* E.g., in an API that supports hardware-accelerated encoding and decoding,
* this struct will (if possible) wrap the state that is common to both encoding
* and decoding and from which specific instances of encoders or decoders can be
* derived.
*
* This struct is reference-counted with the AVBuffer mechanism. The
* av_hwdevice_ctx_alloc() constructor yields a reference, whose data field
* points to the actual AVHWDeviceContext. Further objects derived from
* AVHWDeviceContext (such as AVHWFramesContext, describing a frame pool with
* specific properties) will hold an internal reference to it. After all the
* references are released, the AVHWDeviceContext itself will be freed,
* optionally invoking a user-specified callback for uninitializing the hardware
* state.
*)
pAVHWDeviceContext = ^AVHWDeviceContext;
AVHWDeviceContext = record
(* *
* A class for logging. Set by av_hwdevice_ctx_alloc().
*)
av_class: pAVClass;
(* *
* Private data used internally by libavutil. Must not be accessed in any
* way by the caller.
*)
internal: pAVHWDeviceInternal;
(* *
* This field identifies the underlying API used for hardware access.
*
* This field is set when this struct is allocated and never changed
* afterwards.
*)
_type: AVHWDeviceType;
(* *
* The format-specific data, allocated and freed by libavutil along with
* this context.
*
* Should be cast by the user to the format-specific context defined in the
* corresponding header (hwcontext_*.h) and filled as described in the
* documentation before calling av_hwdevice_ctx_init().
*
* After calling av_hwdevice_ctx_init() this struct should not be modified
* by the caller.
*)
hwctx: Pointer;
(* *
* This field may be set by the caller before calling av_hwdevice_ctx_init().
*
* If non-NULL, this callback will be called when the last reference to
* this context is unreferenced, immediately before it is freed.
*
* @note when other objects (e.g an AVHWFramesContext) are derived from this
* struct, this callback will be invoked after all such child objects
* are fully uninitialized and their respective destructors invoked.
*)
// void (*free)(struct AVHWDeviceContext *ctx);
free: procedure(ctx: pAVHWDeviceContext); cdecl;
(* *
* Arbitrary user data, to be used e.g. by the free() callback.
*)
user_opaque: Pointer;
end;
pAVHWFramesInternal = ^AVHWFramesInternal;
AVHWFramesInternal = record
end;
(* *
* This struct describes a set or pool of "hardware" frames (i.e. those with
* data not located in normal system memory). All the frames in the pool are
* assumed to be allocated in the same way and interchangeable.
*
* This struct is reference-counted with the AVBuffer mechanism and tied to a
* given AVHWDeviceContext instance. The av_hwframe_ctx_alloc() constructor
* yields a reference, whose data field points to the actual AVHWFramesContext
* struct.
*)
pAVHWFramesContext = ^AVHWFramesContext;
AVHWFramesContext = record
(* *
* A class for logging.
*)
av_class: pAVClass;
(* *
* Private data used internally by libavutil. Must not be accessed in any
* way by the caller.
*)
internal: pAVHWFramesInternal;
(* *
* A reference to the parent AVHWDeviceContext. This reference is owned and
* managed by the enclosing AVHWFramesContext, but the caller may derive
* additional references from it.
*)
device_ref: pAVBufferRef;
(* *
* The parent AVHWDeviceContext. This is simply a pointer to
* device_ref->data provided for convenience.
*
* Set by libavutil in av_hwframe_ctx_init().
*)
device_ctx: pAVHWDeviceContext;
(* *
* The format-specific data, allocated and freed automatically along with
* this context.
*
* Should be cast by the user to the format-specific context defined in the
* corresponding header (hwframe_*.h) and filled as described in the
* documentation before calling av_hwframe_ctx_init().
*
* After any frames using this context are created, the contents of this
* struct should not be modified by the caller.
*)
hwctx: Pointer;
(* *
* This field may be set by the caller before calling av_hwframe_ctx_init().
*
* If non-NULL, this callback will be called when the last reference to
* this context is unreferenced, immediately before it is freed.
*)
// void (*free)(struct AVHWFramesContext *ctx);
free: procedure(ctx: pAVHWFramesContext); cdecl;
(* *
* Arbitrary user data, to be used e.g. by the free() callback.
*)
user_opaque: Pointer;
(* *
* A pool from which the frames are allocated by av_hwframe_get_buffer().
* This field may be set by the caller before calling av_hwframe_ctx_init().
* The buffers returned by calling av_buffer_pool_get() on this pool must
* have the properties described in the documentation in the corresponding hw
* type's header (hwcontext_*.h). The pool will be freed strictly before
* this struct's free() callback is invoked.
*
* This field may be NULL, then libavutil will attempt to allocate a pool
* internally. Note that certain device types enforce pools allocated at
* fixed size (frame count), which cannot be extended dynamically. In such a
* case, initial_pool_size must be set appropriately.
*)
pool: pAVBufferPool;
(* *
* Initial size of the frame pool. If a device type does not support
* dynamically resizing the pool, then this is also the maximum pool size.
*
* May be set by the caller before calling av_hwframe_ctx_init(). Must be
* set if pool is NULL and the device type does not support dynamic pools.
*)
initial_pool_size: int;
(* *
* The pixel format identifying the underlying HW surface type.
*
* Must be a hwaccel format, i.e. the corresponding descriptor must have the
* AV_PIX_FMT_FLAG_HWACCEL flag set.
*
* Must be set by the user before calling av_hwframe_ctx_init().
*)
format: AVPixelFormat;
(* *
* The pixel format identifying the actual data layout of the hardware
* frames.
*
* Must be set by the caller before calling av_hwframe_ctx_init().
*
* @note when the underlying API does not provide the exact data layout, but
* only the colorspace/bit depth, this field should be set to the fully
* planar version of that format (e.g. for 8-bit 420 YUV it should be
* AV_PIX_FMT_YUV420P, not AV_PIX_FMT_NV12 or anything else).
*)
sw_format: AVPixelFormat;
(* *
* The allocated dimensions of the frames in this pool.
*
* Must be set by the user before calling av_hwframe_ctx_init().
*)
width, height: int;
end;
(* *
* Look up an AVHWDeviceType by name.
*
* @param name String name of the device type (case-insensitive).
* @return The type from enum AVHWDeviceType, or AV_HWDEVICE_TYPE_NONE if
* not found.
*)
// enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name);
function av_hwdevice_find_type_by_name(const name: PAnsiChar): AVHWDeviceType; cdecl; external avutil_dll;
(* * Get the string name of an AVHWDeviceType.
*
* @param type Type from enum AVHWDeviceType.
* @return Pointer to a static string containing the name, or NULL if the type
* is not valid.
*)
// const char *av_hwdevice_get_type_name(enum AVHWDeviceType type);
function av_hwdevice_get_type_name(_type: AVHWDeviceType): PAnsiChar; cdecl; external avutil_dll;
(* *
* Iterate over supported device types.
*
* @param type AV_HWDEVICE_TYPE_NONE initially, then the previous type
* returned by this function in subsequent iterations.
* @return The next usable device type from enum AVHWDeviceType, or
* AV_HWDEVICE_TYPE_NONE if there are no more.
*)
// enum AVHWDeviceType av_hwdevice_iterate_types(enum AVHWDeviceType prev);
function av_hwdevice_iterate_types(prev: AVHWDeviceType): AVHWDeviceType; cdecl; external avutil_dll;
(* *
* Allocate an AVHWDeviceContext for a given hardware type.
*
* @param type the type of the hardware device to allocate.
* @return a reference to the newly created AVHWDeviceContext on success or NULL
* on failure.
*)
// AVBufferRef *av_hwdevice_ctx_alloc(enum AVHWDeviceType type);
function av_hwdevice_ctx_alloc(_type: AVHWDeviceType): pAVBufferRef; cdecl; external avutil_dll;
(* *
* Finalize the device context before use. This function must be called after
* the context is filled with all the required information and before it is
* used in any way.
*
* @param ref a reference to the AVHWDeviceContext
* @return 0 on success, a negative AVERROR code on failure
*)
// int av_hwdevice_ctx_init(AVBufferRef *ref);
function av_hwdevice_ctx_init(ref: pAVBufferRef): int; cdecl; external avutil_dll;
(* *
* Open a device of the specified type and create an AVHWDeviceContext for it.
*
* This is a convenience function intended to cover the simple cases. Callers
* who need to fine-tune device creation/management should open the device
* manually and then wrap it in an AVHWDeviceContext using
* av_hwdevice_ctx_alloc()/av_hwdevice_ctx_init().
*
* The returned context is already initialized and ready for use, the caller
* should not call av_hwdevice_ctx_init() on it. The user_opaque/free fields of
* the created AVHWDeviceContext are set by this function and should not be
* touched by the caller.
*
* @param device_ctx On success, a reference to the newly-created device context
* will be written here. The reference is owned by the caller
* and must be released with av_buffer_unref() when no longer
* needed. On failure, NULL will be written to this pointer.
* @param type The type of the device to create.
* @param device A type-specific string identifying the device to open.
* @param opts A dictionary of additional (type-specific) options to use in
* opening the device. The dictionary remains owned by the caller.
* @param flags currently unused
*
* @return 0 on success, a negative AVERROR code on failure.
*)
// int av_hwdevice_ctx_create(AVBufferRef **device_ctx, enum AVHWDeviceType type,
// const char *device, AVDictionary *opts, int flags);
function av_hwdevice_ctx_create(var device_ctx: pAVBufferRef; _type: AVHWDeviceType; const device: PAnsiChar; opts: pAVDictionary; flags: int): int; cdecl;
external avutil_dll;
(* *
* Create a new device of the specified type from an existing device.
*
* If the source device is a device of the target type or was originally
* derived from such a device (possibly through one or more intermediate
* devices of other types), then this will return a reference to the
* existing device of the same type as is requested.
*
* Otherwise, it will attempt to derive a new device from the given source
* device. If direct derivation to the new type is not implemented, it will
* attempt the same derivation from each ancestor of the source device in
* turn looking for an implemented derivation method.
*
* @param dst_ctx On success, a reference to the newly-created
* AVHWDeviceContext.
* @param type The type of the new device to create.
* @param src_ctx A reference to an existing AVHWDeviceContext which will be
* used to create the new device.
* @param flags Currently unused; should be set to zero.
* @return Zero on success, a negative AVERROR code on failure.
*)
// int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ctx,
// enum AVHWDeviceType type,
// AVBufferRef *src_ctx, int flags);
function av_hwdevice_ctx_create_derived(var dst_ctx: pAVBufferRef; _type: AVHWDeviceType; src_ctx: pAVBufferRef; flags: int): int; cdecl; external avutil_dll;
(* *
* Allocate an AVHWFramesContext tied to a given device context.
*
* @param device_ctx a reference to a AVHWDeviceContext. This function will make
* a new reference for internal use, the one passed to the
* function remains owned by the caller.
* @return a reference to the newly created AVHWFramesContext on success or NULL
* on failure.
*)
// AVBufferRef *av_hwframe_ctx_alloc(AVBufferRef *device_ctx);
function av_hwframe_ctx_alloc(device_ctx: pAVBufferRef): pAVBufferRef; cdecl; external avutil_dll;
(* *
* Finalize the context before use. This function must be called after the
* context is filled with all the required information and before it is attached
* to any frames.
*
* @param ref a reference to the AVHWFramesContext
* @return 0 on success, a negative AVERROR code on failure
*)
// int av_hwframe_ctx_init(AVBufferRef *ref);
function av_hwframe_ctx_init(ref: pAVBufferRef): int; cdecl; external avutil_dll;
(* *
* Allocate a new frame attached to the given AVHWFramesContext.
*
* @param hwframe_ctx a reference to an AVHWFramesContext
* @param frame an empty (freshly allocated or unreffed) frame to be filled with
* newly allocated buffers.
* @param flags currently unused, should be set to zero
* @return 0 on success, a negative AVERROR code on failure
*)
// int av_hwframe_get_buffer(AVBufferRef *hwframe_ctx, AVFrame *frame, int flags);
function av_hwframe_get_buffer(hwframe_ctx: pAVBufferRef; frame: pAVFrame; flags: int): int; cdecl; external avutil_dll;
(* *
* Copy data to or from a hw surface. At least one of dst/src must have an
* AVHWFramesContext attached.
*
* If src has an AVHWFramesContext attached, then the format of dst (if set)
* must use one of the formats returned by av_hwframe_transfer_get_formats(src,
* AV_HWFRAME_TRANSFER_DIRECTION_FROM).
* If dst has an AVHWFramesContext attached, then the format of src must use one
* of the formats returned by av_hwframe_transfer_get_formats(dst,
* AV_HWFRAME_TRANSFER_DIRECTION_TO)
*
* dst may be "clean" (i.e. with data/buf pointers unset), in which case the
* data buffers will be allocated by this function using av_frame_get_buffer().
* If dst->format is set, then this format will be used, otherwise (when
* dst->format is AV_PIX_FMT_NONE) the first acceptable format will be chosen.
*
* The two frames must have matching allocated dimensions (i.e. equal to
* AVHWFramesContext.width/height), since not all device types support
* transferring a sub-rectangle of the whole surface. The display dimensions
* (i.e. AVFrame.width/height) may be smaller than the allocated dimensions, but
* also have to be equal for both frames. When the display dimensions are
* smaller than the allocated dimensions, the content of the padding in the
* destination frame is unspecified.
*
* @param dst the destination frame. dst is not touched on failure.
* @param src the source frame.
* @param flags currently unused, should be set to zero
* @return 0 on success, a negative AVERROR error code on failure.
*)
// int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags);
function av_hwframe_transfer_data(dst: pAVFrame; const src: pAVFrame; flags: int): int; cdecl; external avutil_dll;
type
AVHWFrameTransferDirection = (
(* *
* Transfer the data from the queried hw frame.
*)
AV_HWFRAME_TRANSFER_DIRECTION_FROM,
(* *
* Transfer the data to the queried hw frame.
*)
AV_HWFRAME_TRANSFER_DIRECTION_TO);
(* *
* Get a list of possible source or target formats usable in
* av_hwframe_transfer_data().
*
* @param hwframe_ctx the frame context to obtain the information for
* @param dir the direction of the transfer
* @param formats the pointer to the output format list will be written here.
* The list is terminated with AV_PIX_FMT_NONE and must be freed
* by the caller when no longer needed using av_free().
* If this function returns successfully, the format list will
* have at least one item (not counting the terminator).
* On failure, the contents of this pointer are unspecified.
* @param flags currently unused, should be set to zero
* @return 0 on success, a negative AVERROR code on failure.
*)
// int av_hwframe_transfer_get_formats(AVBufferRef *hwframe_ctx,
// enum AVHWFrameTransferDirection dir,
// enum AVPixelFormat **formats, int flags);
function av_hwframe_transfer_get_formats(hwframe_ctx: pAVBufferRef; dir: AVHWFrameTransferDirection; var formats: pAVPixelFormat; flags: int): int; cdecl;
external avutil_dll;
type
(* *
* This struct describes the constraints on hardware frames attached to
* a given device with a hardware-specific configuration. This is returned
* by av_hwdevice_get_hwframe_constraints() and must be freed by
* av_hwframe_constraints_free() after use.
*)
pAVHWFramesConstraints = ^AVHWFramesConstraints;
AVHWFramesConstraints = record
(* *
* A list of possible values for format in the hw_frames_ctx,
* terminated by AV_PIX_FMT_NONE. This member will always be filled.
*)
valid_hw_formats: pAVPixelFormat;
(* *
* A list of possible values for sw_format in the hw_frames_ctx,
* terminated by AV_PIX_FMT_NONE. Can be NULL if this information is
* not known.
*)
valid_sw_formats: pAVPixelFormat;
(* *
* The minimum size of frames in this hw_frames_ctx.
* (Zero if not known.)
*)
min_width: int;
min_height: int;
(* *
* The maximum size of frames in this hw_frames_ctx.
* (INT_MAX if not known / no limit.)
*)
max_width: int;
max_height: int;
end;
(* *
* Allocate a HW-specific configuration structure for a given HW device.
* After use, the user must free all members as required by the specific
* hardware structure being used, then free the structure itself with
* av_free().
*
* @param device_ctx a reference to the associated AVHWDeviceContext.
* @return The newly created HW-specific configuration structure on
* success or NULL on failure.
*)
// void *av_hwdevice_hwconfig_alloc(AVBufferRef *device_ctx);
function av_hwdevice_hwconfig_alloc(device_ctx: pAVBufferRef): Pointer; cdecl; external avutil_dll;
(* *
* Get the constraints on HW frames given a device and the HW-specific
* configuration to be used with that device. If no HW-specific
* configuration is provided, returns the maximum possible capabilities
* of the device.
*
* @param ref a reference to the associated AVHWDeviceContext.
* @param hwconfig a filled HW-specific configuration structure, or NULL
* to return the maximum possible capabilities of the device.
* @return AVHWFramesConstraints structure describing the constraints
* on the device, or NULL if not available.
*)
// AVHWFramesConstraints *av_hwdevice_get_hwframe_constraints(AVBufferRef *ref,const void *hwconfig);
function av_hwdevice_get_hwframe_constraints(ref: pAVBufferRef; const hwconfig: Pointer): pAVHWFramesConstraints; cdecl; external avutil_dll;
(* *
* Free an AVHWFrameConstraints structure.
*
* @param constraints The (filled or unfilled) AVHWFrameConstraints structure.
*)
// void av_hwframe_constraints_free(AVHWFramesConstraints **constraints);
procedure av_hwframe_constraints_free(var constraints: pAVHWFramesConstraints); cdecl; external avutil_dll;
const
(* *
* Flags to apply to frame mappings.
*)
(* *
* The mapping must be readable.
*)
AV_HWFRAME_MAP_READ = 1 shl 0;
(* *
* The mapping must be writeable.
*)
AV_HWFRAME_MAP_WRITE = 1 shl 1;
(* *
* The mapped frame will be overwritten completely in subsequent
* operations, so the current frame data need not be loaded. Any values
* which are not overwritten are unspecified.
*)
AV_HWFRAME_MAP_OVERWRITE = 1 shl 2;
(* *
* The mapping must be direct. That is, there must not be any copying in
* the map or unmap steps. Note that performance of direct mappings may
* be much lower than normal memory.
*)
AV_HWFRAME_MAP_DIRECT = 1 shl 3;
(* *
* Map a hardware frame.
*
* This has a number of different possible effects, depending on the format
* and origin of the src and dst frames. On input, src should be a usable
* frame with valid buffers and dst should be blank (typically as just created
* by av_frame_alloc()). src should have an associated hwframe context, and
* dst may optionally have a format and associated hwframe context.
*
* If src was created by mapping a frame from the hwframe context of dst,
* then this function undoes the mapping - dst is replaced by a reference to
* the frame that src was originally mapped from.
*
* If both src and dst have an associated hwframe context, then this function
* attempts to map the src frame from its hardware context to that of dst and
* then fill dst with appropriate data to be usable there. This will only be
* possible if the hwframe contexts and associated devices are compatible -
* given compatible devices, av_hwframe_ctx_create_derived() can be used to
* create a hwframe context for dst in which mapping should be possible.
*
* If src has a hwframe context but dst does not, then the src frame is
* mapped to normal memory and should thereafter be usable as a normal frame.
* If the format is set on dst, then the mapping will attempt to create dst
* with that format and fail if it is not possible. If format is unset (is
* AV_PIX_FMT_NONE) then dst will be mapped with whatever the most appropriate
* format to use is (probably the sw_format of the src hwframe context).
*
* A return value of AVERROR(ENOSYS) indicates that the mapping is not
* possible with the given arguments and hwframe setup, while other return
* values indicate that it failed somehow.
*
* @param dst Destination frame, to contain the mapping.
* @param src Source frame, to be mapped.
* @param flags Some combination of AV_HWFRAME_MAP_* flags.
* @return Zero on success, negative AVERROR code on failure.
*)
// int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags);
function av_hwframe_map(dst: pAVFrame; const src: pAVFrame; flags: int): int; cdecl; external avutil_dll;
(* *
* Create and initialise an AVHWFramesContext as a mapping of another existing
* AVHWFramesContext on a different device.
*
* av_hwframe_ctx_init() should not be called after this.
*
* @param derived_frame_ctx On success, a reference to the newly created
* AVHWFramesContext.
* @param derived_device_ctx A reference to the device to create the new
* AVHWFramesContext on.
* @param source_frame_ctx A reference to an existing AVHWFramesContext
* which will be mapped to the derived context.
* @param flags Some combination of AV_HWFRAME_MAP_* flags, defining the
* mapping parameters to apply to frames which are allocated
* in the derived device.
* @return Zero on success, negative AVERROR code on failure.
*)
// int av_hwframe_ctx_create_derived(AVBufferRef **derived_frame_ctx,
// enum AVPixelFormat format,
// AVBufferRef *derived_device_ctx,
// AVBufferRef *source_frame_ctx,
// int flags);
function av_hwframe_ctx_create_derived(var derived_frame_ctx: pAVBufferRef; format: AVPixelFormat; derived_device_ctx: pAVBufferRef;
source_frame_ctx: pAVBufferRef; flags: int): int; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'hwcontext_mediacodec.h'}
(* *
* MediaCodec details.
*
* Allocated as AVHWDeviceContext.hwctx
*)
type
pAVMediaCodecDeviceContext = ^AVMediaCodecDeviceContext;
AVMediaCodecDeviceContext = record
(* *
* android/view/Surface handle, to be filled by the user.
*
* This is the default surface used by decoders on this device.
*)
surface: Pointer;
end;
{$ENDREGION}
{$REGION 'hwcontext_drm.h'}
(* *
* @file
* API-specific header for AV_HWDEVICE_TYPE_DRM.
*
* Internal frame allocation is not currently supported - all frames
* must be allocated by the user. Thus AVHWFramesContext is always
* NULL, though this may change if support for frame allocation is
* added in future.
*)
const
(* *
* The maximum number of layers/planes in a DRM frame.
*)
AV_DRM_MAX_PLANES = 4;
(* *
* DRM object descriptor.
*
* Describes a single DRM object, addressing it as a PRIME file
* descriptor.
*)
type
pAVDRMObjectDescriptor = ^AVDRMObjectDescriptor;
AVDRMObjectDescriptor = record
(* *
* DRM PRIME fd for the object.
*)
fd: int;
(* *
* Total size of the object.
*
* (This includes any parts not which do not contain image data.)
*)
size: size_t;
(* *
* Format modifier applied to the object (DRM_FORMAT_MOD_* ).
*
* If the format modifier is unknown then this should be set to
* DRM_FORMAT_MOD_INVALID.
*)
format_modifier: uint64_t;
end;
(* *
* DRM plane descriptor.
*
* Describes a single plane of a layer, which is contained within
* a single object.
*)
pAVDRMPlaneDescriptor = ^AVDRMPlaneDescriptor;
AVDRMPlaneDescriptor = record
(* *
* Index of the object containing this plane in the objects
* array of the enclosing frame descriptor.
*)
object_index: int;
(* *
* Offset within that object of this plane.
*)
offset: ptrdiff_t;
(* *
* Pitch (linesize) of this plane.
*)
pitch: ptrdiff_t;
end;
(* *
* DRM layer descriptor.
*
* Describes a single layer within a frame. This has the structure
* defined by its format, and will contain one or more planes.
*)
pAVDRMLayerDescriptor = ^AVDRMLayerDescriptor;
AVDRMLayerDescriptor = record
(* *
* Format of the layer (DRM_FORMAT_* ).
*)
format: uint32_t;
(* *
* Number of planes in the layer.
*
* This must match the number of planes required by format.
*)
nb_planes: int;
(* *
* Array of planes in this layer.
*)
planes: array [0 .. AV_DRM_MAX_PLANES - 1] of AVDRMPlaneDescriptor;
end;
(* *
* DRM frame descriptor.
*
* This is used as the data pointer for AV_PIX_FMT_DRM_PRIME frames.
* It is also used by user-allocated frame pools - allocating in
* AVHWFramesContext.pool must return AVBufferRefs which contain
* an object of this type.
*
* The fields of this structure should be set such it can be
* imported directly by EGL using the EGL_EXT_image_dma_buf_import
* and EGL_EXT_image_dma_buf_import_modifiers extensions.
* (Note that the exact layout of a particular format may vary between
* platforms - we only specify that the same platform should be able
* to import it.)
*
* The total number of planes must not exceed AV_DRM_MAX_PLANES, and
* the order of the planes by increasing layer index followed by
* increasing plane index must be the same as the order which would
* be used for the data pointers in the equivalent software format.
*)
pAVDRMFrameDescriptor = ^AVDRMFrameDescriptor;
AVDRMFrameDescriptor = record
(* *
* Number of DRM objects making up this frame.
*)
nb_objects: int;
(* *
* Array of objects making up the frame.
*)
objects: array [0 .. AV_DRM_MAX_PLANES - 1] of AVDRMObjectDescriptor;
(* *
* Number of layers in the frame.
*)
nb_layers: int;
(* *
* Array of layers in the frame.
*)
layers: array [0 .. AV_DRM_MAX_PLANES - 1] of AVDRMLayerDescriptor;
end;
(* *
* DRM device.
*
* Allocated as AVHWDeviceContext.hwctx.
*)
pAVDRMDeviceContext = ^AVDRMDeviceContext;
AVDRMDeviceContext = record
(* *
* File descriptor of DRM device.
*
* This is used as the device to create frames on, and may also be
* used in some derivation and mapping operations.
*
* If no device is required, set to -1.
*)
fd: int;
end;
{$ENDREGION}
{$REGION 'pixdesc.h'}
type
pAVComponentDescriptor = ^AVComponentDescriptor;
AVComponentDescriptor = record
(* *
* Which of the 4 planes contains the component.
*)
plane: int;
(* *
* Number of elements between 2 horizontally consecutive pixels.
* Elements are bits for bitstream formats, bytes otherwise.
*)
step: int;
(* *
* Number of elements before the component of the first pixel.
* Elements are bits for bitstream formats, bytes otherwise.
*)
offset: int;
(* *
* Number of least significant bits that must be shifted away
* to get the value.
*)
shift: int;
(* *
* Number of bits in the component.
*)
depth: int;
{$IFDEF FF_API_PLUS1_MINUS1}
(* * deprecated, use step instead *)
// attribute_deprecated int step_minus1;
step_minus1: int deprecated;
(* * deprecated, use depth instead *)
// attribute_deprecated int depth_minus1;
depth_minus1: int deprecated;
(* * deprecated, use offset instead *)
// attribute_deprecated int offset_plus1;
offset_plus1: int deprecated;
{$ENDIF}
end;
(* *
* Descriptor that unambiguously describes how the bits of a pixel are
* stored in the up to 4 data planes of an image. It also stores the
* subsampling factors and number of components.
*
* @note This is separate of the colorspace (RGB, YCbCr, YPbPr, JPEG-style YUV
* and all the YUV variants) AVPixFmtDescriptor just stores how values
* are stored not what these values represent.
*)
pAVPixFmtDescriptor = ^AVPixFmtDescriptor;
AVPixFmtDescriptor = record
name: PAnsiChar;
nb_components: uint8_t;
/// < The number of components each pixel has, (1-4)
(* *
* Amount to shift the luma width right to find the chroma width.
* For YV12 this is 1 for example.
* chroma_width = AV_CEIL_RSHIFT(luma_width, log2_chroma_w)
* The note above is needed to ensure rounding up.
* This value only refers to the chroma components.
*)
log2_chroma_w: uint8_t;
(* *
* Amount to shift the luma height right to find the chroma height.
* For YV12 this is 1 for example.
* chroma_height= AV_CEIL_RSHIFT(luma_height, log2_chroma_h)
* The note above is needed to ensure rounding up.
* This value only refers to the chroma components.
*)
log2_chroma_h: uint8_t;
(* *
* Combination of AV_PIX_FMT_FLAG_... flags.
*)
flags: uint64_t;
(* *
* Parameters that describe how pixels are packed.
* If the format has 1 or 2 components, then luma is 0.
* If the format has 3 or 4 components:
* if the RGB flag is set then 0 is red, 1 is green and 2 is blue;
* otherwise 0 is luma, 1 is chroma-U and 2 is chroma-V.
*
* If present, the Alpha channel is always the last component.
*)
comp: array [0 .. 3] of AVComponentDescriptor;
(* *
* Alternative comma-separated names.
*)
alias: PAnsiChar;
end;
const
(* *
* Pixel format is big-endian.
*)
AV_PIX_FMT_FLAG_BE = (1 shl 0);
(* *
* Pixel format has a palette in data[1], values are indexes in this palette.
*)
AV_PIX_FMT_FLAG_PAL = (1 shl 1);
(* *
* All values of a component are bit-wise packed end to end.
*)
AV_PIX_FMT_FLAG_BITSTREAM = (1 shl 2);
(* *
* Pixel format is an HW accelerated format.
*)
AV_PIX_FMT_FLAG_HWACCEL = (1 shl 3);
(* *
* At least one pixel component is not in the first data plane.
*)
AV_PIX_FMT_FLAG_PLANAR = (1 shl 4);
(* *
* The pixel format contains RGB-like data (as opposed to YUV/grayscale).
*)
AV_PIX_FMT_FLAG_RGB = (1 shl 5);
(* *
* The pixel format is "pseudo-paletted". This means that it contains a
* fixed palette in the 2nd plane but the palette is fixed/constant for each
* PIX_FMT. This allows interpreting the data as if it was PAL8, which can
* in some cases be simpler. Or the data can be interpreted purely based on
* the pixel format without using the palette.
* An example of a pseudo-paletted format is AV_PIX_FMT_GRAY8
*
* @deprecated This flag is deprecated, and will be removed. When it is removed,
* the extra palette allocation in AVFrame.data[1] is removed as well. Only
* actual paletted formats (as indicated by AV_PIX_FMT_FLAG_PAL) will have a
* palette. Starting with FFmpeg versions which have this flag deprecated, the
* extra "pseudo" palette is already ignored, and API users are not required to
* allocate a palette for AV_PIX_FMT_FLAG_PSEUDOPAL formats (it was required
* before the deprecation, though).
*)
AV_PIX_FMT_FLAG_PSEUDOPAL = (1 shl 6);
(* *
* The pixel format has an alpha channel. This is set on all formats that
* support alpha in some way. The exception is AV_PIX_FMT_PAL8, which can
* carry alpha as part of the palette. Details are explained in the
* AVPixelFormat enum, and are also encoded in the corresponding
* AVPixFmtDescriptor.
*
* The alpha is always straight, never pre-multiplied.
*
* If a codec or a filter does not support alpha, it should set all alpha to
* opaque, or use the equivalent pixel formats without alpha component, e.g.
* AV_PIX_FMT_RGB0 (or AV_PIX_FMT_RGB24 etc.) instead of AV_PIX_FMT_RGBA.
*)
AV_PIX_FMT_FLAG_ALPHA = (1 shl 7);
(* *
* The pixel format is following a Bayer pattern
*)
AV_PIX_FMT_FLAG_BAYER = (1 shl 8);
(* *
* The pixel format contains IEEE-754 floating point values. Precision (double,
* single, or half) should be determined by the pixel size (64, 32, or 16 bits).
*)
AV_PIX_FMT_FLAG_FLOAT = (1 shl 9);
(* *
* Return the number of bits per pixel used by the pixel format
* described by pixdesc. Note that this is not the same as the number
* of bits per sample.
*
* The returned number of bits refers to the number of bits actually
* used for storing the pixel information, that is padding bits are
* not counted.
*)
// int av_get_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
function av_get_bits_per_pixel(const pixdesc: pAVPixFmtDescriptor): int; cdecl; external avutil_dll;
(* *
* Return the number of bits per pixel for the pixel format
* described by pixdesc, including any padding or unused bits.
*)
// int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc);
function av_get_padded_bits_per_pixel(const pixdesc: pAVPixFmtDescriptor): int; cdecl; external avutil_dll;
(* *
* @return a pixel format descriptor for provided pixel format or NULL if
* this pixel format is unknown.
*)
// const AVPixFmtDescriptor *av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt);
function av_pix_fmt_desc_get(pix_fmt: AVPixelFormat): pAVPixFmtDescriptor; cdecl; external avutil_dll;
(* *
* Iterate over all pixel format descriptors known to libavutil.
*
* @param prev previous descriptor. NULL to get the first descriptor.
*
* @return next descriptor or NULL after the last descriptor
*)
// const AVPixFmtDescriptor *av_pix_fmt_desc_next(const AVPixFmtDescriptor *prev);
function av_pix_fmt_desc_next(const prev: pAVPixFmtDescriptor): pAVPixFmtDescriptor; cdecl; external avutil_dll;
(* *
* @return an AVPixelFormat id described by desc, or AV_PIX_FMT_NONE if desc
* is not a valid pointer to a pixel format descriptor.
*)
// enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc);
function av_pix_fmt_desc_get_id(const desc: pAVPixFmtDescriptor): AVPixelFormat; cdecl; external avutil_dll;
(* *
* Utility function to access log2_chroma_w log2_chroma_h from
* the pixel format AVPixFmtDescriptor.
*
* @param[in] pix_fmt the pixel format
* @param[out] h_shift store log2_chroma_w (horizontal/width shift)
* @param[out] v_shift store log2_chroma_h (vertical/height shift)
*
* @return 0 on success, AVERROR(ENOSYS) on invalid or unknown pixel format
*)
// int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt,int *h_shift, int *v_shift);
function av_pix_fmt_get_chroma_sub_sample(pix_fmt: AVPixelFormat; var h_shift: int; var v_shift: int): int; cdecl; external avutil_dll;
(* *
* @return number of planes in pix_fmt, a negative AVERROR if pix_fmt is not a
* valid pixel format.
*)
// int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt);
function av_pix_fmt_count_planes(pix_fmt: AVPixelFormat): int; cdecl; external avutil_dll;
(* *
* @return the name for provided color range or NULL if unknown.
*)
// const char *av_color_range_name(enum AVColorRange range);
function av_color_range_name(range: AVColorRange): PAnsiChar; cdecl; external avutil_dll;
(* *
* @return the AVColorRange value for name or an AVError if not found.
*)
// int av_color_range_from_name(const char *name);
function av_color_range_from_name(const name: PAnsiChar): int; cdecl; external avutil_dll;
(* *
* @return the name for provided color primaries or NULL if unknown.
*)
// const char *av_color_primaries_name(enum AVColorPrimaries primaries);
function av_color_primaries_name(primaries: AVColorPrimaries): PAnsiChar; cdecl; external avutil_dll;
(* *
* @return the AVColorPrimaries value for name or an AVError if not found.
*)
// int av_color_primaries_from_name(const char *name);
function av_color_primaries_from_name(const name: PAnsiChar): int; cdecl; external avutil_dll;
(* *
* @return the name for provided color transfer or NULL if unknown.
*)
// const char *av_color_transfer_name(enum AVColorTransferCharacteristic transfer);
function av_color_transfer_name(transfer: AVColorTransferCharacteristic): PAnsiChar; cdecl; external avutil_dll;
(* *
* @return the AVColorTransferCharacteristic value for name or an AVError if not found.
*)
// int av_color_transfer_from_name(const char *name);
function av_color_transfer_from_name(const name: PAnsiChar): int; cdecl; external avutil_dll;
(* *
* @return the name for provided color space or NULL if unknown.
*)
// const char *av_color_space_name(enum AVColorSpace space);
function av_color_space_name(space: AVColorSpace): PAnsiChar; cdecl; external avutil_dll;
(* *
* @return the AVColorSpace value for name or an AVError if not found.
*)
// int av_color_space_from_name(const char *name);
function av_color_space_from_name(const name: PAnsiChar): int; cdecl; external avutil_dll;
(* *
* @return the name for provided chroma location or NULL if unknown.
*)
// const char *av_chroma_location_name(enum AVChromaLocation location);
function av_chroma_location_name(location: AVChromaLocation): PAnsiChar; cdecl; external avutil_dll;
(* *
* @return the AVChromaLocation value for name or an AVError if not found.
*)
// int av_chroma_location_from_name(const char *name);
function av_chroma_location_from_name(const name: PAnsiChar): int; cdecl; external avutil_dll;
(* *
* Return the pixel format corresponding to name.
*
* If there is no pixel format with name name, then looks for a
* pixel format with the name corresponding to the native endian
* format of name.
* For example in a little-endian system, first looks for "gray16",
* then for "gray16le".
*
* Finally if no pixel format has been found, returns AV_PIX_FMT_NONE.
*)
// enum AVPixelFormat av_get_pix_fmt(const char *name);
function av_get_pix_fmt(const name: PAnsiChar): AVPixelFormat; cdecl; external avutil_dll;
(* *
* Return the short name for a pixel format, NULL in case pix_fmt is
* unknown.
*
* @see av_get_pix_fmt(), av_get_pix_fmt_string()
*)
// const char *av_get_pix_fmt_name(enum AVPixelFormat pix_fmt);
function av_get_pix_fmt_name(pix_fmt: AVPixelFormat): PAnsiChar; cdecl; external avutil_dll;
(* *
* Print in buf the string corresponding to the pixel format with
* number pix_fmt, or a header if pix_fmt is negative.
*
* @param buf the buffer where to write the string
* @param buf_size the size of buf
* @param pix_fmt the number of the pixel format to print the
* corresponding info string, or a negative value to print the
* corresponding header.
*)
// char *av_get_pix_fmt_string(char *buf, int buf_size, enum AVPixelFormat pix_fmt);
function av_get_pix_fmt_string(buf: PAnsiChar; buf_size: int; pix_fmt: AVPixelFormat): PAnsiChar; cdecl; external avutil_dll;
(* *
* Read a line from an image, and write the values of the
* pixel format component c to dst.
*
* @param data the array containing the pointers to the planes of the image
* @param linesize the array containing the linesizes of the image
* @param desc the pixel format descriptor for the image
* @param x the horizontal coordinate of the first pixel to read
* @param y the vertical coordinate of the first pixel to read
* @param w the width of the line to read, that is the number of
* values to write to dst
* @param read_pal_component if not zero and the format is a paletted
* format writes the values corresponding to the palette
* component c in data[1] to dst, rather than the palette indexes in
* data[0]. The behavior is undefined if the format is not paletted.
* @param dst_element_size size of elements in dst array (2 or 4 byte)
*)
Type
Tav_read_array4_puint8_t = record
{$IFDEF REALISE}
array4_puint8_t;
{$ENDIF}
end;
pav_read_array4_puint8_t = ^Tav_read_array4_puint8_t;
Tav_read_array4_int = record
{$IFDEF REALISE}
array4_int;
{$ENDIF}
end;
pav_read_array4_int = ^Tav_read_array4_int;
// void av_read_image_line2(void *dst, const uint8_t *data[4],
// const int linesize[4], const AVPixFmtDescriptor *desc,
// int x, int y, int c, int w, int read_pal_component,
// int dst_element_size);
procedure av_read_image_line2(dst: Pointer; const data: pav_read_array4_puint8_t; const linesize: pav_read_array4_int; const desc: pAVPixFmtDescriptor;
x, y, c, w, read_pal_component, dst_element_size: int); cdecl; external avutil_dll;
// void av_read_image_line(uint16_t *dst, const uint8_t *data[4],
// const int linesize[4], const AVPixFmtDescriptor *desc,
// int x, int y, int c, int w, int read_pal_component);
procedure av_read_image_line(dst: puint16_t; const data: pav_read_array4_puint8_t; const linesize: pav_read_array4_int; const desc: pAVPixFmtDescriptor;
x, y, c, w: int; read_pal_component: int); cdecl; external avutil_dll;
(* *
* Write the values from src to the pixel format component c of an
* image line.
*
* @param src array containing the values to write
* @param data the array containing the pointers to the planes of the
* image to write into. It is supposed to be zeroed.
* @param linesize the array containing the linesizes of the image
* @param desc the pixel format descriptor for the image
* @param x the horizontal coordinate of the first pixel to write
* @param y the vertical coordinate of the first pixel to write
* @param w the width of the line to write, that is the number of
* values to write to the image line
* @param src_element_size size of elements in src array (2 or 4 byte)
*)
// void av_write_image_line2(const void *src, uint8_t *data[4],
// const int linesize[4], const AVPixFmtDescriptor *desc,
// int x, int y, int c, int w, int src_element_size);
procedure av_write_image_line2(const src: puint16_t; data: pav_read_array4_puint8_t; const linesize: pav_read_array4_int; const desc: pAVPixFmtDescriptor;
x: int; y: int; c: int; w: int; src_element_size: int); cdecl; external avutil_dll;
// void av_write_image_line(const uint16_t *src, uint8_t *data[4],
// const int linesize[4], const AVPixFmtDescriptor *desc,
// int x, int y, int c, int w);
procedure av_write_image_line(const src: puint16_t; data: pav_read_array4_puint8_t; const linesize: pav_read_array4_int; const desc: pAVPixFmtDescriptor;
x: int; y: int; c: int; w: int); cdecl; external avutil_dll;
(* *
* Utility function to swap the endianness of a pixel format.
*
* @param[in] pix_fmt the pixel format
*
* @return pixel format with swapped endianness if it exists,
* otherwise AV_PIX_FMT_NONE
*)
// enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt);
function av_pix_fmt_swap_endianness(pix_fmt: AVPixelFormat): AVPixelFormat; cdecl; external avutil_dll;
const
FF_LOSS_RESOLUTION = $0001; (* *< loss due to resolution change *)
FF_LOSS_DEPTH = $0002; (* *< loss due to color depth change *)
FF_LOSS_COLORSPACE = $0004; (* *< loss due to color space conversion *)
FF_LOSS_ALPHA = $0008; (* *< loss of alpha bits *)
FF_LOSS_COLORQUANT = $0010; (* *< loss due to color quantization *)
FF_LOSS_CHROMA = $0020; (* *< loss of chroma (e.g. RGB to gray conversion) *)
(* *
* Compute what kind of losses will occur when converting from one specific
* pixel format to another.
* When converting from one pixel format to another, information loss may occur.
* For example, when converting from RGB24 to GRAY, the color information will
* be lost. Similarly, other losses occur when converting from some formats to
* other formats. These losses can involve loss of chroma, but also loss of
* resolution, loss of color depth, loss due to the color space conversion, loss
* of the alpha bits or loss due to color quantization.
* av_get_fix_fmt_loss() informs you about the various types of losses
* which will occur when converting from one pixel format to another.
*
* @param[in] dst_pix_fmt destination pixel format
* @param[in] src_pix_fmt source pixel format
* @param[in] has_alpha Whether the source pixel format alpha channel is used.
* @return Combination of flags informing you what kind of losses will occur
* (maximum loss for an invalid dst_pix_fmt).
*)
// int av_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt,
// enum AVPixelFormat src_pix_fmt,
// int has_alpha);
function av_get_pix_fmt_loss(dst_pix_fmt: AVPixelFormat; src_pix_fmt: AVPixelFormat; has_alpha: int): int; cdecl; external avutil_dll;
(* *
* Compute what kind of losses will occur when converting from one specific
* pixel format to another.
* When converting from one pixel format to another, information loss may occur.
* For example, when converting from RGB24 to GRAY, the color information will
* be lost. Similarly, other losses occur when converting from some formats to
* other formats. These losses can involve loss of chroma, but also loss of
* resolution, loss of color depth, loss due to the color space conversion, loss
* of the alpha bits or loss due to color quantization.
* av_get_fix_fmt_loss() informs you about the various types of losses
* which will occur when converting from one pixel format to another.
*
* @param[in] dst_pix_fmt destination pixel format
* @param[in] src_pix_fmt source pixel format
* @param[in] has_alpha Whether the source pixel format alpha channel is used.
* @return Combination of flags informing you what kind of losses will occur
* (maximum loss for an invalid dst_pix_fmt).
*)
// enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2,
// enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr);
function av_find_best_pix_fmt_of_2(dst_pix_fmt1: AVPixelFormat; dst_pix_fmt2: AVPixelFormat; src_pix_fmt: AVPixelFormat; has_alpha: int; var loss_ptr: int)
: AVPixelFormat; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'imgutils.h'}
type
Tav_image_array4_int = array4_int;
pav_image_array4_int = ^Tav_image_array4_int;
Tav_image_array4_puint8_t = array4_puint8_t;
pav_image_array4_puint8_t = ^Tav_image_array4_puint8_t;
Tav_image_array4_ptrdiff_t = array4_ptrdiff_t;
pav_image_array4_ptrdiff_t = ^Tav_image_array4_ptrdiff_t;
(* *
* Compute the max pixel step for each plane of an image with a
* format described by pixdesc.
*
* The pixel step is the distance in bytes between the first byte of
* the group of bytes which describe a pixel component and the first
* byte of the successive group in the same plane for the same
* component.
*
* @param max_pixsteps an array which is filled with the max pixel step
* for each plane. Since a plane may contain different pixel
* components, the computed max_pixsteps[plane] is relative to the
* component in the plane with the max pixel step.
* @param max_pixstep_comps an array which is filled with the component
* for each plane which has the max pixel step. May be NULL.
*)
// void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
// const AVPixFmtDescriptor *pixdesc);
procedure av_image_fill_max_pixsteps(max_pixsteps: pav_image_array4_int; max_pixstep_comps: pav_image_array4_int; const pixdesc: pAVPixFmtDescriptor); cdecl;
external avutil_dll;
(* *
* Compute the size of an image line with format pix_fmt and width
* width for the plane plane.
*
* @return the computed size in bytes
*)
// int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane);
function av_image_get_linesize(pix_fmt: AVPixelFormat; width: int; plane: int): int; cdecl; external avutil_dll;
(* *
* Fill plane linesizes for an image with pixel format pix_fmt and
* width width.
*
* @param linesizes array to be filled with the linesize for each plane
* @return >= 0 in case of success, a negative error code otherwise
*)
// int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width);
function av_image_fill_linesizes(linesizes: pav_image_array4_int; pix_fmt: AVPixelFormat; width: int): int; cdecl; external avutil_dll;
(* *
* Fill plane data pointers for an image with pixel format pix_fmt and
* height height.
*
* @param data pointers array to be filled with the pointer for each image plane
* @param ptr the pointer to a buffer which will contain the image
* @param linesizes the array containing the linesize for each
* plane, should be filled by av_image_fill_linesizes()
* @return the size in bytes required for the image buffer, a negative
* error code in case of failure
*)
// int av_image_fill_pointers(uint8_t *data[4], enum AVPixelFormat pix_fmt, int height,
// uint8_t *ptr, const int linesizes[4]);
function av_image_fill_pointers(data: pav_image_array4_puint8_t; pix_fmt: AVPixelFormat; height: int; ptr: puint8_t; const linesizes: pav_image_array4_int)
: int; cdecl; external avutil_dll;
(* *
* Allocate an image with size w and h and pixel format pix_fmt, and
* fill pointers and linesizes accordingly.
* The allocated image buffer has to be freed by using
* av_freep(&pointers[0]).
*
* @param align the value to use for buffer size alignment
* @return the size in bytes required for the image buffer, a negative
* error code in case of failure
*)
// int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
// int w, int h, enum AVPixelFormat pix_fmt, int align);
function av_image_alloc(pointers: pav_image_array4_puint8_t; linesizes: pav_image_array4_int; w: int; h: int; pix_fmt: AVPixelFormat; align: int): int; cdecl;
external avutil_dll;
(* *
* Copy image plane from src to dst.
* That is, copy "height" number of lines of "bytewidth" bytes each.
* The first byte of each successive line is separated by *_linesize
* bytes.
*
* bytewidth must be contained by both absolute values of dst_linesize
* and src_linesize, otherwise the function behavior is undefined.
*
* @param dst_linesize linesize for the image plane in dst
* @param src_linesize linesize for the image plane in src
*)
// void av_image_copy_plane(uint8_t *dst, int dst_linesize,
// const uint8_t *src, int src_linesize,
// int bytewidth, int height);
procedure av_image_copy_plane(dst: puint8_t; dst_linesize: int; const src: puint8_t; src_linesize: int; bytewidth: int; height: int); cdecl;
external avutil_dll;
(* *
* Copy image in src_data to dst_data.
*
* @param dst_linesizes linesizes for the image in dst_data
* @param src_linesizes linesizes for the image in src_data
*)
// void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
// const uint8_t *src_data[4], const int src_linesizes[4],
// enum AVPixelFormat pix_fmt, int width, int height);
procedure av_image_copy(dst_data: pav_image_array4_puint8_t; dst_linesizes: pav_image_array4_int; const src_data: pav_image_array4_puint8_t;
const src_linesizes: pav_image_array4_int; pix_fmt: AVPixelFormat; width: int; height: int); cdecl; external avutil_dll;
(* *
* Copy image data located in uncacheable (e.g. GPU mapped) memory. Where
* available, this function will use special functionality for reading from such
* memory, which may result in greatly improved performance compared to plain
* av_image_copy().
*
* The data pointers and the linesizes must be aligned to the maximum required
* by the CPU architecture.
*
* @note The linesize parameters have the type ptrdiff_t here, while they are
* int for av_image_copy().
* @note On x86, the linesizes currently need to be aligned to the cacheline
* size (i.e. 64) to get improved performance.
*)
// void av_image_copy_uc_from(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4],
// const uint8_t *src_data[4], const ptrdiff_t src_linesizes[4],
// enum AVPixelFormat pix_fmt, int width, int height);
procedure av_image_copy_uc_from(dst_data: pav_image_array4_puint8_t; const dst_linesizes: pav_image_array4_ptrdiff_t; const src_data: pav_image_array4_puint8_t;
const src_linesizes: pav_image_array4_ptrdiff_t; pix_fmt: AVPixelFormat; width: int; height: int); cdecl; external avutil_dll;
(* *
* Setup the data pointers and linesizes based on the specified image
* parameters and the provided array.
*
* The fields of the given image are filled in by using the src
* address which points to the image data buffer. Depending on the
* specified pixel format, one or multiple image data pointers and
* line sizes will be set. If a planar format is specified, several
* pointers will be set pointing to the different picture planes and
* the line sizes of the different planes will be stored in the
* lines_sizes array. Call with src == NULL to get the required
* size for the src buffer.
*
* To allocate the buffer and fill in the dst_data and dst_linesize in
* one call, use av_image_alloc().
*
* @param dst_data data pointers to be filled in
* @param dst_linesize linesizes for the image in dst_data to be filled in
* @param src buffer which will contain or contains the actual image data, can be NULL
* @param pix_fmt the pixel format of the image
* @param width the width of the image in pixels
* @param height the height of the image in pixels
* @param align the value used in src for linesize alignment
* @return the size in bytes required for src, a negative error code
* in case of failure
*)
// int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4],
// const uint8_t *src,
// enum AVPixelFormat pix_fmt, int width, int height, int align);
function av_image_fill_arrays(dst_data: pav_image_array4_puint8_t; dst_linesize: pav_image_array4_int; const src: puint8_t; pix_fmt: AVPixelFormat; width: int;
height: int; align: int): int; cdecl; external avutil_dll;
(* *
* Return the size in bytes of the amount of data required to store an
* image with the given parameters.
*
* @param pix_fmt the pixel format of the image
* @param width the width of the image in pixels
* @param height the height of the image in pixels
* @param align the assumed linesize alignment
* @return the buffer size in bytes, a negative error code in case of failure
*)
// int av_image_get_buffer_size(enum AVPixelFormat pix_fmt, int width, int height, int align);
function av_image_get_buffer_size(pix_fmt: AVPixelFormat; width: int; height: int; align: int): int; cdecl; external avutil_dll;
(* *
* Copy image data from an image into a buffer.
*
* av_image_get_buffer_size() can be used to compute the required size
* for the buffer to fill.
*
* @param dst a buffer into which picture data will be copied
* @param dst_size the size in bytes of dst
* @param src_data pointers containing the source image data
* @param src_linesize linesizes for the image in src_data
* @param pix_fmt the pixel format of the source image
* @param width the width of the source image in pixels
* @param height the height of the source image in pixels
* @param align the assumed linesize alignment for dst
* @return the number of bytes written to dst, or a negative value
* (error code) on error
*)
// int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
// const uint8_t * const src_data[4], const int src_linesize[4],
// enum AVPixelFormat pix_fmt, int width, int height, int align);
function av_image_copy_to_buffer(dst: puint8_t; dst_size: int; const src_data: pav_image_array4_puint8_t; const src_linesize: pav_image_array4_int;
pix_fmt: AVPixelFormat; width: int; height: int; align: int): int; cdecl; external avutil_dll;
(* *
* Check if the given dimension of an image is valid, meaning that all
* bytes of the image can be addressed with a signed int.
*
* @param w the width of the picture
* @param h the height of the picture
* @param log_offset the offset to sum to the log level for logging with log_ctx
* @param log_ctx the parent logging context, it may be NULL
* @return >= 0 if valid, a negative error code otherwise
*)
// int av_image_check_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
function av_image_check_size(w: unsigned_int; h: unsigned_int; log_offset: int; log_ctx: Pointer): int; cdecl; external avutil_dll;
(* *
* Check if the given dimension of an image is valid, meaning that all
* bytes of a plane of an image with the specified pix_fmt can be addressed
* with a signed int.
*
* @param w the width of the picture
* @param h the height of the picture
* @param max_pixels the maximum number of pixels the user wants to accept
* @param pix_fmt the pixel format, can be AV_PIX_FMT_NONE if unknown.
* @param log_offset the offset to sum to the log level for logging with log_ctx
* @param log_ctx the parent logging context, it may be NULL
* @return >= 0 if valid, a negative error code otherwise
*)
// int av_image_check_size2(unsigned int w, unsigned int h, int64_t max_pixels, enum AVPixelFormat pix_fmt, int log_offset, void *log_ctx);
function av_image_check_size2(w: unsigned_int; h: unsigned_int; max_pixels: int64_t; pix_fmt: AVPixelFormat; log_offset: int; log_ctx: Pointer): int; cdecl;
external avutil_dll;
(* *
* Check if the given sample aspect ratio of an image is valid.
*
* It is considered invalid if the denominator is 0 or if applying the ratio
* to the image size would make the smaller dimension less than 1. If the
* sar numerator is 0, it is considered unknown and will return as valid.
*
* @param w width of the image
* @param h height of the image
* @param sar sample aspect ratio of the image
* @return 0 if valid, a negative AVERROR code otherwise
*)
// int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar);
function av_image_check_sar(w: unsigned_int; h: unsigned_int; sar: AVRational): int; cdecl; external avutil_dll;
(* *
* Overwrite the image data with black. This is suitable for filling a
* sub-rectangle of an image, meaning the padding between the right most pixel
* and the left most pixel on the next line will not be overwritten. For some
* formats, the image size might be rounded up due to inherent alignment.
*
* If the pixel format has alpha, the alpha is cleared to opaque.
*
* This can return an error if the pixel format is not supported. Normally, all
* non-hwaccel pixel formats should be supported.
*
* Passing NULL for dst_data is allowed. Then the function returns whether the
* operation would have succeeded. (It can return an error if the pix_fmt is
* not supported.)
*
* @param dst_data data pointers to destination image
* @param dst_linesize linesizes for the destination image
* @param pix_fmt the pixel format of the image
* @param range the color range of the image (important for colorspaces such as YUV)
* @param width the width of the image in pixels
* @param height the height of the image in pixels
* @return 0 if the image data was cleared, a negative AVERROR code otherwise
*)
// int av_image_fill_black(uint8_t *dst_data[4], const ptrdiff_t dst_linesize[4],
// enum AVPixelFormat pix_fmt, enum AVColorRange range,
// int width, int height);
function av_image_fill_black(dst_data: pav_image_array4_puint8_t; const dst_linesize: pav_image_array4_ptrdiff_t; pix_fmt: AVPixelFormat; range: AVColorRange;
width: int; height: int): int; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'time.h'}
(* *
* Get the current time in microseconds.
*)
// int64_t av_gettime(void);
function av_gettime(): int64_t; cdecl; external avutil_dll;
(* *
* Get the current time in microseconds since some unspecified starting point.
* On platforms that support it, the time comes from a monotonic clock
* This property makes this time source ideal for measuring relative time.
* The returned values may not be monotonic on platforms where a monotonic
* clock is not available.
*)
// int64_t av_gettime_relative(void);
function av_gettime_relative(): int64_t; cdecl; external avutil_dll;
(* *
* Indicates with a boolean result if the av_gettime_relative() time source
* is monotonic.
*)
// int av_gettime_relative_is_monotonic(void);
function av_gettime_relative_is_monotonic(): int; cdecl; external avutil_dll;
(* *
* Sleep for a period of time. Although the duration is expressed in
* microseconds, the actual delay may be rounded to the precision of the
* system timer.
*
* @param usec Number of microseconds to sleep.
* @return zero on success or (negative) error code.
*)
// int av_usleep(unsigned usec);
function av_usleep(usec: unsigned): int; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'timestamp.h'}
const
AV_TS_MAX_STRING_SIZE = 32;
(* *
* Fill the provided buffer with a string containing a timestamp
* representation.
*
* @param buf a buffer with size in bytes of at least AV_TS_MAX_STRING_SIZE
* @param ts the timestamp to represent
* @return the buffer in input
*)
// static inline char *av_ts_make_string(char *buf, int64_t ts)
function av_ts_make_string(buf: PAnsiChar; ts: int64_t): PAnsiChar;
(* *
* Convenience macro, the return value should be used only directly in
* function arguments but never stand-alone.
*)
// #define av_ts2str(ts) av_ts_make_string((char[AV_TS_MAX_STRING_SIZE]){0}, ts)
function av_ts2str(ts: int64_t): PAnsiChar;
(* *
* Fill the provided buffer with a string containing a timestamp time
* representation.
*
* @param buf a buffer with size in bytes of at least AV_TS_MAX_STRING_SIZE
* @param ts the timestamp to represent
* @param tb the timebase of the timestamp
* @return the buffer in input
*)
// static inline char *av_ts_make_time_string(char *buf, int64_t ts, AVRational *tb)
function av_ts_make_time_string(buf: PAnsiChar; ts: int64_t; tb: pAVRational): PAnsiChar;
(* *
* Convenience macro, the return value should be used only directly in
* function arguments but never stand-alone.
*)
// #define av_ts2timestr(ts, tb) av_ts_make_time_string((char[AV_TS_MAX_STRING_SIZE]){0}, ts, tb)
function av_ts2timestr(ts: int64_t; tb: pAVRational): PAnsiChar;
{$ENDREGION}
{$REGION 'mem.h'}
(* *
* Allocate a memory block with alignment suitable for all memory accesses
* (including vectors if available on the CPU).
*
* @param size Size in bytes for the memory block to be allocated
* @return Pointer to the allocated block, or `NULL` if the block cannot
* be allocated
* @see av_mallocz()
*)
// void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1);
function av_malloc(size: size_t): Pointer; cdecl; external avutil_dll;
(* *
* Allocate a memory block with alignment suitable for all memory accesses
* (including vectors if available on the CPU) and zero all the bytes of the
* block.
*
* @param size Size in bytes for the memory block to be allocated
* @return Pointer to the allocated block, or `NULL` if it cannot be allocated
* @see av_malloc()
*)
// void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1);
function av_mallocz(size: size_t): Pointer; cdecl; external avutil_dll;
(* *
* Allocate a memory block for an array with av_malloc().
*
* The allocated memory will have size `size * nmemb` bytes.
*
* @param nmemb Number of element
* @param size Size of a single element
* @return Pointer to the allocated block, or `NULL` if the block cannot
* be allocated
* @see av_malloc()
*)
// av_alloc_size(1, 2) void *av_malloc_array(size_t nmemb, size_t size);
function av_malloc_array(nmemb: size_t; size: size_t): Pointer; cdecl; external avutil_dll;
(* *
* Allocate a memory block for an array with av_mallocz().
*
* The allocated memory will have size `size * nmemb` bytes.
*
* @param nmemb Number of elements
* @param size Size of the single element
* @return Pointer to the allocated block, or `NULL` if the block cannot
* be allocated
*
* @see av_mallocz()
* @see av_malloc_array()
*)
// av_alloc_size(1, 2) void *av_mallocz_array(size_t nmemb, size_t size);
function av_mallocz_array(nmemb: size_t; size: size_t): Pointer; cdecl; external avutil_dll;
(* *
* Non-inlined equivalent of av_mallocz_array().
*
* Created for symmetry with the calloc() C function.
*)
// void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib;
function av_calloc(nmemb: size_t; size: size_t): Pointer; cdecl; external avutil_dll;
(* *
* Allocate, reallocate, or free a block of memory.
*
* If `ptr` is `NULL` and `size` > 0, allocate a new block. If `size` is
* zero, free the memory block pointed to by `ptr`. Otherwise, expand or
* shrink that block of memory according to `size`.
*
* @param ptr Pointer to a memory block already allocated with
* av_realloc() or `NULL`
* @param size Size in bytes of the memory block to be allocated or
* reallocated
*
* @return Pointer to a newly-reallocated block or `NULL` if the block
* cannot be reallocated or the function is used to free the memory block
*
* @warning Unlike av_malloc(), the returned pointer is not guaranteed to be
* correctly aligned.
* @see av_fast_realloc()
* @see av_reallocp()
*)
// void *av_realloc(void *ptr, size_t size) av_alloc_size(2);
function av_realloc(ptr: Pointer; size: size_t): Pointer; cdecl; external avutil_dll;
(* *
* Allocate, reallocate, or free a block of memory through a pointer to a
* pointer.
*
* If `*ptr` is `NULL` and `size` > 0, allocate a new block. If `size` is
* zero, free the memory block pointed to by `*ptr`. Otherwise, expand or
* shrink that block of memory according to `size`.
*
* @param[in,out] ptr Pointer to a pointer to a memory block already allocated
* with av_realloc(), or a pointer to `NULL`. The pointer
* is updated on success, or freed on failure.
* @param[in] size Size in bytes for the memory block to be allocated or
* reallocated
*
* @return Zero on success, an AVERROR error code on failure
*
* @warning Unlike av_malloc(), the allocated memory is not guaranteed to be
* correctly aligned.
*)
// av_warn_unused_result
// int av_reallocp(void *ptr, size_t size);
function av_reallocp(ptr: Pointer; size: size_t): int; cdecl; external avutil_dll;
(* *
* Allocate, reallocate, or free a block of memory.
*
* This function does the same thing as av_realloc(), except:
* - It takes two size arguments and allocates `nelem * elsize` bytes,
* after checking the result of the multiplication for integer overflow.
* - It frees the input block in case of failure, thus avoiding the memory
* leak with the classic
* @code{.c}
* buf = realloc(buf);
* if (!buf)
* return -1;
* @endcode
* pattern.
*)
// void *av_realloc_f(void *ptr, size_t nelem, size_t elsize);
function av_realloc_f(ptr: Pointer; nelem: size_t; elsize: size_t): Pointer; cdecl; external avutil_dll;
(* *
* Allocate, reallocate, or free an array.
*
* If `ptr` is `NULL` and `nmemb` > 0, allocate a new block. If
* `nmemb` is zero, free the memory block pointed to by `ptr`.
*
* @param ptr Pointer to a memory block already allocated with
* av_realloc() or `NULL`
* @param nmemb Number of elements in the array
* @param size Size of the single element of the array
*
* @return Pointer to a newly-reallocated block or NULL if the block
* cannot be reallocated or the function is used to free the memory block
*
* @warning Unlike av_malloc(), the allocated memory is not guaranteed to be
* correctly aligned.
* @see av_reallocp_array()
*)
// av_alloc_size(2, 3) void *av_realloc_array(void *ptr, size_t nmemb, size_t size);
function av_realloc_array(ptr: Pointer; nmemb: size_t; size: size_t): Pointer; cdecl; external avutil_dll;
(* *
* Allocate, reallocate, or free an array through a pointer to a pointer.
*
* If `*ptr` is `NULL` and `nmemb` > 0, allocate a new block. If `nmemb` is
* zero, free the memory block pointed to by `*ptr`.
*
* @param[in,out] ptr Pointer to a pointer to a memory block already
* allocated with av_realloc(), or a pointer to `NULL`.
* The pointer is updated on success, or freed on failure.
* @param[in] nmemb Number of elements
* @param[in] size Size of the single element
*
* @return Zero on success, an AVERROR error code on failure
*
* @warning Unlike av_malloc(), the allocated memory is not guaranteed to be
* correctly aligned.
*)
// av_alloc_size(2, 3) int av_reallocp_array(void *ptr, size_t nmemb, size_t size);
function av_reallocp_array(ptr: Pointer; nmemb: size_t; size: size_t): int; cdecl; external avutil_dll;
(* *
* Reallocate the given buffer if it is not large enough, otherwise do nothing.
*
* If the given buffer is `NULL`, then a new uninitialized buffer is allocated.
*
* If the given buffer is not large enough, and reallocation fails, `NULL` is
* returned and `*size` is set to 0, but the original buffer is not changed or
* freed.
*
* A typical use pattern follows:
*
* @code{.c}
* uint8_t *buf = ...;
* uint8_t *new_buf = av_fast_realloc(buf, ¤t_size, size_needed);
* if (!new_buf) {
* // Allocation failed; clean up original buffer
* av_freep(&buf);
* return AVERROR(ENOMEM);
* }
* @endcode
*
* @param[in,out] ptr Already allocated buffer, or `NULL`
* @param[in,out] size Pointer to the size of buffer `ptr`. `*size` is
* updated to the new allocated size, in particular 0
* in case of failure.
* @param[in] min_size Desired minimal size of buffer `ptr`
* @return `ptr` if the buffer is large enough, a pointer to newly reallocated
* buffer if the buffer was not large enough, or `NULL` in case of
* error
* @see av_realloc()
* @see av_fast_malloc()
*)
// void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size);
function av_fast_realloc(ptr: Pointer; var size: unsigned_int; min_size: size_t): Pointer; cdecl; external avutil_dll;
(* *
* Allocate a buffer, reusing the given one if large enough.
*
* Contrary to av_fast_realloc(), the current buffer contents might not be
* preserved and on error the old buffer is freed, thus no special handling to
* avoid memleaks is necessary.
*
* `*ptr` is allowed to be `NULL`, in which case allocation always happens if
* `size_needed` is greater than 0.
*
* @code{.c}
* uint8_t *buf = ...;
* av_fast_malloc(&buf, ¤t_size, size_needed);
* if (!buf) {
* // Allocation failed; buf already freed
* return AVERROR(ENOMEM);
* }
* @endcode
*
* @param[in,out] ptr Pointer to pointer to an already allocated buffer.
* `*ptr` will be overwritten with pointer to new
* buffer on success or `NULL` on failure
* @param[in,out] size Pointer to the size of buffer `*ptr`. `*size` is
* updated to the new allocated size, in particular 0
* in case of failure.
* @param[in] min_size Desired minimal size of buffer `*ptr`
* @see av_realloc()
* @see av_fast_mallocz()
*)
// void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size);
procedure av_fast_malloc(ptr: Pointer; var size: unsigned_int; min_size: size_t); cdecl; external avutil_dll;
(* *
* Allocate and clear a buffer, reusing the given one if large enough.
*
* Like av_fast_malloc(), but all newly allocated space is initially cleared.
* Reused buffer is not cleared.
*
* `*ptr` is allowed to be `NULL`, in which case allocation always happens if
* `size_needed` is greater than 0.
*
* @param[in,out] ptr Pointer to pointer to an already allocated buffer.
* `*ptr` will be overwritten with pointer to new
* buffer on success or `NULL` on failure
* @param[in,out] size Pointer to the size of buffer `*ptr`. `*size` is
* updated to the new allocated size, in particular 0
* in case of failure.
* @param[in] min_size Desired minimal size of buffer `*ptr`
* @see av_fast_malloc()
*)
// void av_fast_mallocz(void *ptr, unsigned int *size, size_t min_size);
procedure av_fast_mallocz(ptr: Pointer; var size: unsigned_int; min_size: size_t); cdecl; external avutil_dll;
(* *
* Free a memory block which has been allocated with a function of av_malloc()
* or av_realloc() family.
*
* @param ptr Pointer to the memory block which should be freed.
*
* @note `ptr = NULL` is explicitly allowed.
* @note It is recommended that you use av_freep() instead, to prevent leaving
* behind dangling pointers.
* @see av_freep()
*)
// void av_free(void *ptr);
procedure av_free(ptr: Pointer); cdecl; external avutil_dll;
(* *
* Free a memory block which has been allocated with a function of av_malloc()
* or av_realloc() family, and set the pointer pointing to it to `NULL`.
*
* @code{.c}
* uint8_t *buf = av_malloc(16);
* av_free(buf);
* // buf now contains a dangling pointer to freed memory, and accidental
* // dereference of buf will result in a use-after-free, which may be a
* // security risk.
*
* uint8_t *buf = av_malloc(16);
* av_freep(&buf);
* // buf is now NULL, and accidental dereference will only result in a
* // NULL-pointer dereference.
* @endcode
*
* @param ptr Pointer to the pointer to the memory block which should be freed
* @note `*ptr = NULL` is safe and leads to no action.
* @see av_free()
*)
// void av_freep(void *ptr);
procedure av_freep(ptr: Pointer); cdecl; external avutil_dll;
(* *
* Duplicate a string.
*
* @param s String to be duplicated
* @return Pointer to a newly-allocated string containing a
* copy of `s` or `NULL` if the string cannot be allocated
* @see av_strndup()
*)
// char *av_strdup(const char *s) av_malloc_attrib;
function av_strdup(const s: PAnsiChar): PAnsiChar; cdecl; external avutil_dll;
(* *
* Duplicate a substring of a string.
*
* @param s String to be duplicated
* @param len Maximum length of the resulting string (not counting the
* terminating byte)
* @return Pointer to a newly-allocated string containing a
* substring of `s` or `NULL` if the string cannot be allocated
*)
// char *av_strndup(const char *s, size_t len) av_malloc_attrib;
function av_strndup(const s: PAnsiChar; len: size_t): PAnsiChar; cdecl; external avutil_dll;
(* *
* Duplicate a buffer with av_malloc().
*
* @param p Buffer to be duplicated
* @param size Size in bytes of the buffer copied
* @return Pointer to a newly allocated buffer containing a
* copy of `p` or `NULL` if the buffer cannot be allocated
*)
// void *av_memdup(const void *p, size_t size);
function av_memdup(const p: Pointer; size: size_t): Pointer; cdecl; external avutil_dll;
(* *
* Overlapping memcpy() implementation.
*
* @param dst Destination buffer
* @param back Number of bytes back to start copying (i.e. the initial size of
* the overlapping window); must be > 0
* @param cnt Number of bytes to copy; must be >= 0
*
* @note `cnt > back` is valid, this will copy the bytes we just copied,
* thus creating a repeating pattern with a period length of `back`.
*)
// void av_memcpy_backptr(uint8_t *dst, int back, int cnt);
procedure av_memcpy_backptr(dst: puint8_t; back: int; cnt: int); cdecl; external avutil_dll;
(* *
* @defgroup lavu_mem_dynarray Dynamic Array
*
* Utilities to make an array grow when needed.
*
* Sometimes, the programmer would want to have an array that can grow when
* needed. The libavutil dynamic array utilities fill that need.
*
* libavutil supports two systems of appending elements onto a dynamically
* allocated array, the first one storing the pointer to the value in the
* array, and the second storing the value directly. In both systems, the
* caller is responsible for maintaining a variable containing the length of
* the array, as well as freeing of the array after use.
*
* The first system stores pointers to values in a block of dynamically
* allocated memory. Since only pointers are stored, the function does not need
* to know the size of the type. Both av_dynarray_add() and
* av_dynarray_add_nofree() implement this system.
*
* @code
* type **array = NULL; //< an array of pointers to values
* int nb = 0; //< a variable to keep track of the length of the array
*
* type to_be_added = ...;
* type to_be_added2 = ...;
*
* av_dynarray_add(&array, &nb, &to_be_added);
* if (nb == 0)
* return AVERROR(ENOMEM);
*
* av_dynarray_add(&array, &nb, &to_be_added2);
* if (nb == 0)
* return AVERROR(ENOMEM);
*
* // Now:
* // nb == 2
* // &to_be_added == array[0]
* // &to_be_added2 == array[1]
*
* av_freep(&array);
* @endcode
*
* The second system stores the value directly in a block of memory. As a
* result, the function has to know the size of the type. av_dynarray2_add()
* implements this mechanism.
*
* @code
* type *array = NULL; //< an array of values
* int nb = 0; //< a variable to keep track of the length of the array
*
* type to_be_added = ...;
* type to_be_added2 = ...;
*
* type *addr = av_dynarray2_add((void ** )&array, &nb, sizeof(*array), NULL);
* if (!addr)
* return AVERROR(ENOMEM);
* memcpy(addr, &to_be_added, sizeof(to_be_added));
*
* // Shortcut of the above.
* type *addr = av_dynarray2_add((void ** )&array, &nb, sizeof( *array),
* (const void * )&to_be_added2);
* if (!addr)
* return AVERROR(ENOMEM);
*
* // Now:
* // nb == 2
* // to_be_added == array[0]
* // to_be_added2 == array[1]
*
* av_freep(&array);
* @endcode
*
* @{
*)
(* *
* Add the pointer to an element to a dynamic array.
*
* The array to grow is supposed to be an array of pointers to
* structures, and the element to add must be a pointer to an already
* allocated structure.
*
* The array is reallocated when its size reaches powers of 2.
* Therefore, the amortized cost of adding an element is constant.
*
* In case of success, the pointer to the array is updated in order to
* point to the new grown array, and the number pointed to by `nb_ptr`
* is incremented.
* In case of failure, the array is freed, `*tab_ptr` is set to `NULL` and
* `*nb_ptr` is set to 0.
*
* @param[in,out] tab_ptr Pointer to the array to grow
* @param[in,out] nb_ptr Pointer to the number of elements in the array
* @param[in] elem Element to add
* @see av_dynarray_add_nofree(), av_dynarray2_add()
*)
// void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem);
procedure av_dynarray_add(tab_ptr: Pointer; var nb_ptr: int; elem: Pointer); cdecl; external avutil_dll;
(* *
* Add an element to a dynamic array.
*
* Function has the same functionality as av_dynarray_add(),
* but it doesn't free memory on fails. It returns error code
* instead and leave current buffer untouched.
*
* @return >=0 on success, negative otherwise
* @see av_dynarray_add(), av_dynarray2_add()
*)
// av_warn_unused_result
// int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem);
function av_dynarray_add_nofree(tab_ptr: Pointer; var nb_ptr: int; elem: Pointer): int; cdecl; external avutil_dll;
(* *
* Add an element of size `elem_size` to a dynamic array.
*
* The array is reallocated when its number of elements reaches powers of 2.
* Therefore, the amortized cost of adding an element is constant.
*
* In case of success, the pointer to the array is updated in order to
* point to the new grown array, and the number pointed to by `nb_ptr`
* is incremented.
* In case of failure, the array is freed, `*tab_ptr` is set to `NULL` and
* `*nb_ptr` is set to 0.
*
* @param[in,out] tab_ptr Pointer to the array to grow
* @param[in,out] nb_ptr Pointer to the number of elements in the array
* @param[in] elem_size Size in bytes of an element in the array
* @param[in] elem_data Pointer to the data of the element to add. If
* `NULL`, the space of the newly added element is
* allocated but left uninitialized.
*
* @return Pointer to the data of the element to copy in the newly allocated
* space
* @see av_dynarray_add(), av_dynarray_add_nofree()
*)
// void *av_dynarray2_add(void **tab_ptr, int *nb_ptr, size_t elem_size,
// const uint8_t *elem_data);
function av_dynarray2_add(var tab_ptr: Pointer; var nb_ptr: int; elem_size: size_t; const elem_data: puint8_t): Pointer; cdecl; external avutil_dll;
(* *
* @defgroup lavu_mem_misc Miscellaneous Functions
*
* Other functions related to memory allocation.
*
* @{
*)
(* *
* Multiply two `size_t` values checking for overflow.
*
* @param[in] a,b Operands of multiplication
* @param[out] r Pointer to the result of the operation
* @return 0 on success, AVERROR(EINVAL) on overflow
*)
// static inline int av_size_mult(size_t a, size_t b, size_t *r)
function av_size_mult(a: size_t; b: size_t; var r: size_t): int; inline;
(* *
* Set the maximum size that may be allocated in one block.
*
* The value specified with this function is effective for all libavutil's @ref
* lavu_mem_funcs "heap management functions."
*
* By default, the max value is defined as `INT_MAX`.
*
* @param max Value to be set as the new maximum size
*
* @warning Exercise extreme caution when using this function. Don't touch
* this if you do not understand the full consequence of doing so.
*)
// void av_max_alloc(size_t max);
procedure av_max_alloc(max: size_t); cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'timecode.h'}
const
AV_TIMECODE_STR_SIZE = 23;
type
AVTimecodeFlag = ( //
AV_TIMECODE_FLAG_DROPFRAME = 1 shl 0,
/// < timecode is drop frame
AV_TIMECODE_FLAG_24HOURSMAX = 1 shl 1,
/// < timecode wraps after 24 hours
AV_TIMECODE_FLAG_ALLOWNEGATIVE = 1 shl 2
/// < negative time values are allowed
);
pAVTimecode = ^AVTimecode;
AVTimecode = record
start: int;
/// < timecode frame start (first base frame number)
flags: uint32_t;
/// < flags such as drop frame, +24 hours support, ...
rate: AVRational;
/// < frame rate in rational form
fps: unsigned;
/// < frame per second; must be consistent with the rate field
end;
(* *
* Adjust frame number for NTSC drop frame time code.
*
* @param framenum frame number to adjust
* @param fps frame per second, 30 or 60
* @return adjusted frame number
* @warning adjustment is only valid in NTSC 29.97 and 59.94
*)
// int av_timecode_adjust_ntsc_framenum2(int framenum, int fps);
function av_timecode_adjust_ntsc_framenum2(framenum: int; fps: int): int; cdecl; external avutil_dll;
(* *
* Convert frame number to SMPTE 12M binary representation.
*
* @param tc timecode data correctly initialized
* @param framenum frame number
* @return the SMPTE binary representation
*
* @note Frame number adjustment is automatically done in case of drop timecode,
* you do NOT have to call av_timecode_adjust_ntsc_framenum2().
* @note The frame number is relative to tc->start.
* @note Color frame (CF), binary group flags (BGF) and biphase mark polarity
* correction (PC) bits are set to zero.
*)
// uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum);
function av_timecode_get_smpte_from_framenum(const tc: pAVTimecode; framenum: int): uint32_t; cdecl; external avutil_dll;
(* *
* Load timecode string in buf.
*
* @param buf destination buffer, must be at least AV_TIMECODE_STR_SIZE long
* @param tc timecode data correctly initialized
* @param framenum frame number
* @return the buf parameter
*
* @note Timecode representation can be a negative timecode and have more than
* 24 hours, but will only be honored if the flags are correctly set.
* @note The frame number is relative to tc->start.
*)
// char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum);
function av_timecode_make_string(const tc: pAVTimecode; buf: PAnsiChar; framenum: int): PAnsiChar; cdecl; external avutil_dll;
(* *
* Get the timecode string from the SMPTE timecode format.
*
* @param buf destination buffer, must be at least AV_TIMECODE_STR_SIZE long
* @param tcsmpte the 32-bit SMPTE timecode
* @param prevent_df prevent the use of a drop flag when it is known the DF bit
* is arbitrary
* @return the buf parameter
*)
// char *av_timecode_make_smpte_tc_string(char *buf, uint32_t tcsmpte, int prevent_df);
function av_timecode_make_smpte_tc_string(buf: PAnsiChar; tcsmpte: uint32_t; prevent_df: int): PAnsiChar; cdecl; external avutil_dll;
(* *
* Get the timecode string from the 25-bit timecode format (MPEG GOP format).
*
* @param buf destination buffer, must be at least AV_TIMECODE_STR_SIZE long
* @param tc25bit the 25-bits timecode
* @return the buf parameter
*)
// char *av_timecode_make_mpeg_tc_string(char *buf, uint32_t tc25bit);
function av_timecode_make_mpeg_tc_string(buf: PAnsiChar; tc25bit: uint32_t): PAnsiChar; cdecl; external avutil_dll;
(* *
* Init a timecode struct with the passed parameters.
*
* @param log_ctx a pointer to an arbitrary struct of which the first field
* is a pointer to an AVClass struct (used for av_log)
* @param tc pointer to an allocated AVTimecode
* @param rate frame rate in rational form
* @param flags miscellaneous flags such as drop frame, +24 hours, ...
* (see AVTimecodeFlag)
* @param frame_start the first frame number
* @return 0 on success, AVERROR otherwise
*)
// int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx);
function av_timecode_init(tc: pAVTimecode; rate: AVRational; flags: int; rame_start: int; log_ctx: Pointer): int; cdecl; external avutil_dll;
(* *
* Parse timecode representation (hh:mm:ss[:;.]ff).
*
* @param log_ctx a pointer to an arbitrary struct of which the first field is a
* pointer to an AVClass struct (used for av_log).
* @param tc pointer to an allocated AVTimecode
* @param rate frame rate in rational form
* @param str timecode string which will determine the frame start
* @return 0 on success, AVERROR otherwise
*)
// int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *str, void *log_ctx);
function av_timecode_init_from_string(tc: pAVTimecode; rate: AVRational; const str: PAnsiChar; log_ctx: Pointer): int; cdecl; external avutil_dll;
(* *
* Check if the timecode feature is available for the given frame rate
*
* @return 0 if supported, <0 otherwise
*)
// int av_timecode_check_frame_rate(AVRational rate);
function av_timecode_check_frame_rate(rate: AVRational): int; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'mathematics.h'}
const
M_E = 2.7182818284590452354; (* e *)
M_LN2 = 0.69314718055994530942; (* log_e 2 *)
M_LN10 = 2.30258509299404568402; (* log_e 10 *)
M_LOG2_10 = 3.32192809488736234787; (* log_2 10 *)
M_PHI = 1.61803398874989484820; (* phi / golden ratio *)
M_PI = 3.14159265358979323846; (* pi *)
M_PI_2 = 1.57079632679489661923; (* pi/2 *)
M_SQRT1_2 = 0.70710678118654752440; (* 1/sqrt(2) *)
M_SQRT2 = 1.41421356237309504880; (* sqrt(2) *)
// NAN = av_int2float(0x7fc00000);
// INFINITY = av_int2float(0x7f800000);
type
AVRounding = int;
(* *
* Rounding methods.
*)
const
// AVRounding = ( //
AV_ROUND_ZERO = 0;
/// < Round toward zero.
AV_ROUND_INF = 1;
/// < Round away from zero.
AV_ROUND_DOWN = 2;
/// < Round toward -infinity.
AV_ROUND_UP = 3;
/// < Round toward +infinity.
AV_ROUND_NEAR_INF = 5;
/// < Round to nearest and halfway cases away from zero.
(* *
* Flag telling rescaling functions to pass `INT64_MIN`/`MAX` through
* unchanged, avoiding special cases for #AV_NOPTS_VALUE.
*
* Unlike other values of the enumeration AVRounding, this value is a
* bitmask that must be used in conjunction with another value of the
* enumeration through a bitwise OR, in order to set behavior for normal
* cases.
*
* @code{.c}
* av_rescale_rnd(3, 1, 2, AV_ROUND_UP | AV_ROUND_PASS_MINMAX);
* // Rescaling 3:
* // Calculating 3 * 1 / 2
* // 3 / 2 is rounded up to 2
* // => 2
*
* av_rescale_rnd(AV_NOPTS_VALUE, 1, 2, AV_ROUND_UP | AV_ROUND_PASS_MINMAX);
* // Rescaling AV_NOPTS_VALUE:
* // AV_NOPTS_VALUE == INT64_MIN
* // AV_NOPTS_VALUE is passed through
* // => AV_NOPTS_VALUE
* @endcode
*)
AV_ROUND_PASS_MINMAX = 8192;
// );
(* *
* Compute the greatest common divisor of two integer operands.
*
* @param a,b Operands
* @return GCD of a and b up to sign; if a >= 0 and b >= 0, return value is >= 0;
* if a == 0 and b == 0, returns 0.
*)
// int64_t av_const av_gcd(int64_t a, int64_t b);
function av_gcd(a, b: int64_t): int64_t; cdecl; external avutil_dll;
(* *
* Rescale a 64-bit integer with rounding to nearest.
*
* The operation is mathematically equivalent to `a * b / c`, but writing that
* directly can overflow.
*
* This function is equivalent to av_rescale_rnd() with #AV_ROUND_NEAR_INF.
*
* @see av_rescale_rnd(), av_rescale_q(), av_rescale_q_rnd()
*)
// int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const;
function av_rescale(a, b, c: int64_t): int64_t; cdecl; external avutil_dll;
(* *
* Rescale a 64-bit integer with specified rounding.
*
* The operation is mathematically equivalent to `a * b / c`, but writing that
* directly can overflow, and does not support different rounding methods.
*
* @see av_rescale(), av_rescale_q(), av_rescale_q_rnd()
*)
// int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd) av_const;
function av_rescale_rnd(a, b, c: int64_t; rnd: AVRounding): int64_t; cdecl; external avutil_dll;
(* *
* Rescale a 64-bit integer by 2 rational numbers.
*
* The operation is mathematically equivalent to `a * bq / cq`.
*
* This function is equivalent to av_rescale_q_rnd() with #AV_ROUND_NEAR_INF.
*
* @see av_rescale(), av_rescale_rnd(), av_rescale_q_rnd()
*)
// int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const;
function av_rescale_q(a: int64_t; bq: AVRational; cq: AVRational): int64_t; cdecl; external avutil_dll;
(* *
* Rescale a 64-bit integer by 2 rational numbers with specified rounding.
*
* The operation is mathematically equivalent to `a * bq / cq`.
*
* @see av_rescale(), av_rescale_rnd(), av_rescale_q()
*)
// int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, enum AVRounding rnd) av_const;
function av_rescale_q_rnd(a: int64_t; bq: AVRational; cq: AVRational; rnd: AVRounding): int64_t; cdecl; external avutil_dll;
(* *
* Compare two timestamps each in its own time base.
*
* @return One of the following values:
* - -1 if `ts_a` is before `ts_b`
* - 1 if `ts_a` is after `ts_b`
* - 0 if they represent the same position
*
* @warning
* The result of the function is undefined if one of the timestamps is outside
* the `int64_t` range when represented in the other's timebase.
*)
// int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b);
function av_compare_ts(ts_a: int64_t; tb_a: AVRational; ts_b: int64_t; tb_b: AVRational): int; cdecl; external avutil_dll;
(* *
* Compare the remainders of two integer operands divided by a common divisor.
*
* In other words, compare the least significant `log2(mod)` bits of integers
* `a` and `b`.
*
* @code{.c}
* av_compare_mod(0x11, 0x02, 0x10) < 0 // since 0x11 % 0x10 (0x1) < 0x02 % 0x10 (0x2)
* av_compare_mod(0x11, 0x02, 0x20) > 0 // since 0x11 % 0x20 (0x11) > 0x02 % 0x20 (0x02)
* @endcode
*
* @param a,b Operands
* @param mod Divisor; must be a power of 2
* @return
* - a negative value if `a % mod < b % mod`
* - a positive value if `a % mod > b % mod`
* - zero if `a % mod == b % mod`
*)
// int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod);
function av_compare_mod(a: uint64_t; b: uint64_t; _mod: uint64_t): int64_t; cdecl; external avutil_dll;
(* *
* Rescale a timestamp while preserving known durations.
*
* This function is designed to be called per audio packet to scale the input
* timestamp to a different time base. Compared to a simple av_rescale_q()
* call, this function is robust against possible inconsistent frame durations.
*
* The `last` parameter is a state variable that must be preserved for all
* subsequent calls for the same stream. For the first call, `*last` should be
* initialized to #AV_NOPTS_VALUE.
*
* @param[in] in_tb Input time base
* @param[in] in_ts Input timestamp
* @param[in] fs_tb Duration time base; typically this is finer-grained
* (greater) than `in_tb` and `out_tb`
* @param[in] duration Duration till the next call to this function (i.e.
* duration of the current packet/frame)
* @param[in,out] last Pointer to a timestamp expressed in terms of
* `fs_tb`, acting as a state variable
* @param[in] out_tb Output timebase
* @return Timestamp expressed in terms of `out_tb`
*
* @note In the context of this function, "duration" is in term of samples, not
* seconds.
*)
// int64_t av_rescale_delta(AVRational in_tb, int64_t in_ts, AVRational fs_tb, int duration, int64_t *last, AVRational out_tb);
function av_rescale_delta(in_tb: AVRational; in_ts: int64_t; fs_tb: AVRational; duration: int; var last: int64_t; out_tb: AVRational): int64_t; cdecl;
external avutil_dll;
(* *
* Add a value to a timestamp.
*
* This function guarantees that when the same value is repeatly added that
* no accumulation of rounding errors occurs.
*
* @param[in] ts Input timestamp
* @param[in] ts_tb Input timestamp time base
* @param[in] inc Value to be added
* @param[in] inc_tb Time base of `inc`
*)
// int64_t av_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t inc);
function av_add_stable(ts_tb: AVRational; ts: int64_t; inc_tb: AVRational; inc: int64_t): int64_t; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'parseutils.h'}
(* *
* Parse str and store the parsed ratio in q.
*
* Note that a ratio with infinite (1/0) or negative value is
* considered valid, so you should check on the returned value if you
* want to exclude those values.
*
* The undefined value can be expressed using the "0:0" string.
*
* @param[in,out] q pointer to the AVRational which will contain the ratio
* @param[in] str the string to parse: it has to be a string in the format
* num:den, a float number or an expression
* @param[in] max the maximum allowed numerator and denominator
* @param[in] log_offset log level offset which is applied to the log
* level of log_ctx
* @param[in] log_ctx parent logging context
* @return >= 0 on success, a negative error code otherwise
*)
// int av_parse_ratio(AVRational *q, const char *str, int max, int log_offset, void *log_ctx);
function av_parse_ratio(q: pAVRational; const str: PAnsiChar; max, log_offset: int; log_ctx: Pointer): int; cdecl; external avutil_dll;
// #define av_parse_ratio_quiet(rate, str, max) av_parse_ratio(rate, str, max, AV_LOG_MAX_OFFSET, NULL)
function av_parse_ratio_quiet(q: pAVRational; const str: PAnsiChar; max: int): int; inline;
(* *
* Parse str and put in width_ptr and height_ptr the detected values.
*
* @param[in,out] width_ptr pointer to the variable which will contain the detected
* width value
* @param[in,out] height_ptr pointer to the variable which will contain the detected
* height value
* @param[in] str the string to parse: it has to be a string in the format
* width x height or a valid video size abbreviation.
* @return >= 0 on success, a negative error code otherwise
*)
// int av_parse_video_size(int *width_ptr, int *height_ptr, const char *str);
function av_parse_video_size(var width_ptr: int; var height_ptr: int; const str: PAnsiChar): int; cdecl; external avutil_dll;
(* *
* Parse str and store the detected values in *rate.
*
* @param[in,out] rate pointer to the AVRational which will contain the detected
* frame rate
* @param[in] str the string to parse: it has to be a string in the format
* rate_num / rate_den, a float number or a valid video rate abbreviation
* @return >= 0 on success, a negative error code otherwise
*)
// int av_parse_video_rate(AVRational *rate, const char *str);
function av_parse_video_rate(rate: pAVRational; const str: PAnsiChar): int; cdecl; external avutil_dll;
(* *
* Put the RGBA values that correspond to color_string in rgba_color.
*
* @param color_string a string specifying a color. It can be the name of
* a color (case insensitive match) or a [0x|#]RRGGBB[AA] sequence,
* possibly followed by "@" and a string representing the alpha
* component.
* The alpha component may be a string composed by "0x" followed by an
* hexadecimal number or a decimal number between 0.0 and 1.0, which
* represents the opacity value (0x00/0.0 means completely transparent,
* 0xff/1.0 completely opaque).
* If the alpha component is not specified then 0xff is assumed.
* The string "random" will result in a random color.
* @param slen length of the initial part of color_string containing the
* color. It can be set to -1 if color_string is a null terminated string
* containing nothing else than the color.
* @return >= 0 in case of success, a negative value in case of
* failure (for example if color_string cannot be parsed).
*)
// int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, void *log_ctx);
function av_parse_color(rgba_color: puint8_t; const color_string: PAnsiChar; slen: int; log_ctx: Pointer): int; cdecl; external avutil_dll;
(* *
* Get the name of a color from the internal table of hard-coded named
* colors.
*
* This function is meant to enumerate the color names recognized by
* av_parse_color().
*
* @param color_idx index of the requested color, starting from 0
* @param rgbp if not NULL, will point to a 3-elements array with the color value in RGB
* @return the color name string or NULL if color_idx is not in the array
*)
// const char *av_get_known_color_name(int color_idx, const uint8_t **rgb);
function av_get_known_color_name(color_idx: int; const rgb: ppuint8_t): PAnsiChar; cdecl; external avutil_dll;
(* *
* Parse timestr and return in *time a corresponding number of
* microseconds.
*
* @param timeval puts here the number of microseconds corresponding
* to the string in timestr. If the string represents a duration, it
* is the number of microseconds contained in the time interval. If
* the string is a date, is the number of microseconds since 1st of
* January, 1970 up to the time of the parsed date. If timestr cannot
* be successfully parsed, set *time to INT64_MIN.
* @param timestr a string representing a date or a duration.
* - If a date the syntax is:
* @code
* [{YYYY-MM-DD|YYYYMMDD}[T|t| ]]{{HH:MM:SS[.m...]]]}|{HHMMSS[.m...]]]}}[Z]
* now
* @endcode
* If the value is "now" it takes the current time.
* Time is local time unless Z is appended, in which case it is
* interpreted as UTC.
* If the year-month-day part is not specified it takes the current
* year-month-day.
* - If a duration the syntax is:
* @code
* [-][HH:]MM:SS[.m...]
* [-]S+[.m...]
* @endcode
* @param duration flag which tells how to interpret timestr, if not
* zero timestr is interpreted as a duration, otherwise as a date
* @return >= 0 in case of success, a negative value corresponding to an
* AVERROR code otherwise
*)
// int av_parse_time(int64_t *timeval, const char *timestr, int duration);
function av_parse_time(timeval: pint64_t; const timestr: PAnsiChar; duration: int): int; cdecl; external avutil_dll;
(* *
* Attempt to find a specific tag in a URL.
*
* syntax: '?tag1=val1&tag2=val2...'. Little URL decoding is done.
* Return 1 if found.
*)
// int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info);
function av_find_info_tag(arg: PAnsiChar; arg_size: int; const tag1: PAnsiChar; const info: PAnsiChar): int; cdecl; external avutil_dll;
(* *
* Simplified version of strptime
*
* Parse the input string p according to the format string fmt and
* store its results in the structure dt.
* This implementation supports only a subset of the formats supported
* by the standard strptime().
*
* The supported input field descriptors are listed below.
* - %H: the hour as a decimal number, using a 24-hour clock, in the
* range '00' through '23'
* - %J: hours as a decimal number, in the range '0' through INT_MAX
* - %M: the minute as a decimal number, using a 24-hour clock, in the
* range '00' through '59'
* - %S: the second as a decimal number, using a 24-hour clock, in the
* range '00' through '59'
* - %Y: the year as a decimal number, using the Gregorian calendar
* - %m: the month as a decimal number, in the range '1' through '12'
* - %d: the day of the month as a decimal number, in the range '1'
* through '31'
* - %T: alias for '%H:%M:%S'
* - %%: a literal '%'
*
* @return a pointer to the first character not processed in this function
* call. In case the input string contains more characters than
* required by the format string the return value points right after
* the last consumed input character. In case the whole input string
* is consumed the return value points to the null byte at the end of
* the string. On failure NULL is returned.
*)
// char *av_small_strptime(const char *p, const char *fmt, struct tm *dt);
function av_small_strptime(const p: PAnsiChar; const fmt: PAnsiChar; dt: ptm): PAnsiChar; cdecl; external avutil_dll;
(* *
* Convert the decomposed UTC time in tm to a time_t value.
*)
// time_t av_timegm(struct tm *tm);
function av_timegm(tm: ptm): time_t; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'motion_vector.h'}
type
pAVMotionVector = ^AVMotionVector;
AVMotionVector = record
(* *
* Where the current macroblock comes from; negative value when it comes
* from the past, positive value when it comes from the future.
* XXX: set exact relative ref frame reference instead of a +/- 1 "direction".
*)
source: int32_t;
(* *
* Width and height of the block.
*)
w, h: uint8_t;
(* *
* Absolute source position. Can be outside the frame area.
*)
src_x, src_y: int16_t;
(* *
* Absolute destination position. Can be outside the frame area.
*)
dst_x, dst_y: int16_t;
(* *
* Extra flag information.
* Currently unused.
*)
flags: uint64_t;
(* *
* Motion vector
* src_x = dst_x + motion_x / motion_scale
* src_y = dst_y + motion_y / motion_scale
*)
motion_x, motion_y: int32_t;
motion_scale: uint16_t;
end;
{$ENDREGION}
{$REGION 'md5.h'}
type
pAVMD5 = ^AVMD5;
AVMD5 = record
end;
(* *
* Allocate an AVMD5 context.
*)
// struct AVMD5 *av_md5_alloc(void);
function av_md5_alloc(): pAVMD5; cdecl; external avutil_dll;
(* *
* Initialize MD5 hashing.
*
* @param ctx pointer to the function context (of size av_md5_size)
*)
// void av_md5_init(struct AVMD5 *ctx);
procedure av_md5_init(ctx: pAVMD5); cdecl; external avutil_dll;
(* *
* Update hash value.
*
* @param ctx hash function context
* @param src input data to update hash with
* @param len input data length
*)
// #if FF_API_CRYPTO_SIZE_T
// void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, int len);
// #else
// void av_md5_update(struct AVMD5 *ctx, const uint8_t *src, size_t len);
// #endif
procedure av_md5_update(ctx: pAVMD5; const src: puint8_t; len:
{$IFDEF FF_API_CRYPTO_SIZE_T}
int
{$ELSE}
size_t
{$ENDIF}
); cdecl; external avutil_dll;
(* *
* Finish hashing and output digest value.
*
* @param ctx hash function context
* @param dst buffer where output digest value is stored
*)
// void av_md5_final(struct AVMD5 *ctx, uint8_t *dst);
procedure av_md5_final(ctx: pAVMD5; dst: puint8_t); cdecl; external avutil_dll;
(* *
* Hash an array of data.
*
* @param dst The output buffer to write the digest into
* @param src The data to hash
* @param len The length of the data, in bytes
*)
// #if FF_API_CRYPTO_SIZE_T
// void av_md5_sum(uint8_t *dst, const uint8_t *src, const int len);
// #else
// void av_md5_sum(uint8_t *dst, const uint8_t *src, size_t len);
// #endif
procedure av_md5_sum(dst: puint8_t; const src: puint8_t; const len:
{$IFDEF FF_API_CRYPTO_SIZE_T}
int
{$ELSE}
size_t
{$ENDIF}
); cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'avassert.h'}
(* *
* Assert that floating point opperations can be executed.
*
* This will av_assert0() that the cpu is not in MMX state on X86
*)
// void av_assert0_fpu(void);
procedure av_assert0_fpu(); cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'intfloat.h'}
type
av_intfloat32 = record
case Integer of
0:
(i: uint32_t);
1:
(f: float);
end;
av_intfloat64 = record
case Integer of
0:
(i: uint64_t);
1:
(f: double);
end;
(* *
* Reinterpret a 32-bit integer as a float.
*)
// static av_always_inline float av_int2float(uint32_t i)
function av_int2float(i: uint32_t): float; inline;
(* *
* Reinterpret a float as a 32-bit integer.
*)
// static av_always_inline uint32_t av_float2int(float f)
function av_float2int(f: float): uint32_t; inline;
(* *
* Reinterpret a 64-bit integer as a double.
*)
// static av_always_inline double av_int2double(uint64_t i)
function av_int2double(i: uint64_t): double; inline;
(* *
* Reinterpret a double as a 64-bit integer.
*)
// static av_always_inline uint64_t av_double2int(double f)
function av_double2int(f: double): uint64_t; inline;
{$ENDREGION}
{$REGION 'mastering_display_metadata.h'}
type
(* *
* Mastering display metadata capable of representing the color volume of
* the display used to master the content (SMPTE 2086:2014).
*
* To be used as payload of a AVFrameSideData or AVPacketSideData with the
* appropriate type.
*
* @note The struct should be allocated with av_mastering_display_metadata_alloc()
* and its size is not a part of the public ABI.
*)
pAVMasteringDisplayMetadata = ^AVMasteringDisplayMetadata;
AVMasteringDisplayMetadata = record
(* *
* CIE 1931 xy chromaticity coords of color primaries (r, g, b order).
*)
display_primaries: array [0 .. 2, 0 .. 1] of AVRational;
(* *
* CIE 1931 xy chromaticity coords of white point.
*)
white_point: array [0 .. 1] of AVRational;
(* *
* Min luminance of mastering display (cd/m^2).
*)
min_luminance: AVRational;
(* *
* Max luminance of mastering display (cd/m^2).
*)
max_luminance: AVRational;
(* *
* Flag indicating whether the display primaries (and white point) are set.
*)
has_primaries: int;
(* *
* Flag indicating whether the luminance (min_ and max_) have been set.
*)
has_luminance: int;
end;
(* *
* Allocate an AVMasteringDisplayMetadata structure and set its fields to
* default values. The resulting struct can be freed using av_freep().
*
* @return An AVMasteringDisplayMetadata filled with default values or NULL
* on failure.
*)
// AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void);
function av_mastering_display_metadata_alloc(): pAVMasteringDisplayMetadata; cdecl; external avutil_dll;
(* *
* Allocate a complete AVMasteringDisplayMetadata and add it to the frame.
*
* @param frame The frame which side data is added to.
*
* @return The AVMasteringDisplayMetadata structure to be filled by caller.
*)
// AVMasteringDisplayMetadata *av_mastering_display_metadata_create_side_data(AVFrame *frame);
function av_mastering_display_metadata_create_side_data(frame: pAVFrame): pAVMasteringDisplayMetadata; cdecl; external avutil_dll;
type
(* *
* Content light level needed by to transmit HDR over HDMI (CTA-861.3).
*
* To be used as payload of a AVFrameSideData or AVPacketSideData with the
* appropriate type.
*
* @note The struct should be allocated with av_content_light_metadata_alloc()
* and its size is not a part of the public ABI.
*)
pAVContentLightMetadata = ^AVContentLightMetadata;
AVContentLightMetadata = record
(* *
* Max content light level (cd/m^2).
*)
MaxCLL: unsigned;
(* *
* Max average light level per frame (cd/m^2).
*)
MaxFALL: unsigned;
end;
(* *
* Allocate an AVContentLightMetadata structure and set its fields to
* default values. The resulting struct can be freed using av_freep().
*
* @return An AVContentLightMetadata filled with default values or NULL
* on failure.
*)
// AVContentLightMetadata *av_content_light_metadata_alloc(size_t *size);
function av_content_light_metadata_alloc(var size: size_t): pAVContentLightMetadata; cdecl; external avutil_dll;
(* *
* Allocate a complete AVContentLightMetadata and add it to the frame.
*
* @param frame The frame which side data is added to.
*
* @return The AVContentLightMetadata structure to be filled by caller.
*)
// AVContentLightMetadata *av_content_light_metadata_create_side_data(AVFrame *frame);
function av_content_light_metadata_create_side_data(frame: pAVFrame): pAVContentLightMetadata; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'pixelutils.h'}
(* *
* Sum of abs(src1[x] - src2[x])
*)
type
// int (*av_pixelutils_sad_fn)(const uint8_t *src1, ptrdiff_t stride1,
// const uint8_t *src2, ptrdiff_t stride2);
av_pixelutils_sad_fn = function(const src1: puint8_t; stride1: ptrdiff_t; const src2: puint8_t; stride2: ptrdiff_t): int; cdecl;
(* *
* Get a potentially optimized pointer to a Sum-of-absolute-differences
* function (see the av_pixelutils_sad_fn prototype).
*
* @param w_bits 1<<w_bits is the requested width of the block size
* @param h_bits 1<<h_bits is the requested height of the block size
* @param aligned If set to 2, the returned sad function will assume src1 and
* src2 addresses are aligned on the block size.
* If set to 1, the returned sad function will assume src1 is
* aligned on the block size.
* If set to 0, the returned sad function assume no particular
* alignment.
* @param log_ctx context used for logging, can be NULL
*
* @return a pointer to the SAD function or NULL in case of error (because of
* invalid parameters)
*)
// av_pixelutils_sad_fn av_pixelutils_get_sad_fn(int w_bits, int h_bits, int aligned, void *log_ctx);
function av_pixelutils_get_sad_fn(w_bits: int; h_bits: int; aligned: int; log_ctx: Pointer): av_pixelutils_sad_fn; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'random_seed.h'}
(* *
* Get a seed to use in conjunction with random functions.
* This function tries to provide a good seed at a best effort bases.
* Its possible to call this function multiple times if more bits are needed.
* It can be quite slow, which is why it should only be used as seed for a faster
* PRNG. The quality of the seed depends on the platform.
*)
// uint32_t av_get_random_seed(void);
function av_get_random_seed(): uint32_t; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'aes.h'}
Type
pAVAES = ^AVAES;
AVAES = record
end;
(* *
* Allocate an AVAES context.
*)
// struct AVAES *av_aes_alloc(void);
function av_aes_alloc: pAVAES; cdecl; external avutil_dll;
(* *
* Initialize an AVAES context.
* @param key_bits 128, 192 or 256
* @param decrypt 0 for encryption, 1 for decryption
*)
// int av_aes_init(struct AVAES *a, const uint8_t *key, int key_bits, int decrypt);
function av_aes_init(a: pAVAES; const key: puint8_t; key_bits: int; decrypt: int): int; cdecl; external avutil_dll;
(* *
* Encrypt or decrypt a buffer using a previously initialized context.
* @param count number of 16 byte blocks
* @param dst destination array, can be equal to src
* @param src source array, can be equal to dst
* @param iv initialization vector for CBC mode, if NULL then ECB will be used
* @param decrypt 0 for encryption, 1 for decryption
*)
// void av_aes_crypt(struct AVAES *a, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt);
procedure av_aes_crypt(a: pAVAES; dst: puint8_t; const src: puint8_t; count: int; iv: puint8_t; decrypt: int); cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'twofish.h'}
type
pAVTWOFISH = ^AVTWOFISH;
AVTWOFISH = record
end;
(* *
* Allocate an AVTWOFISH context
* To free the struct: av_free(ptr)
*)
// struct AVTWOFISH *av_twofish_alloc(void);
function av_twofish_alloc: pAVTWOFISH; cdecl; external avutil_dll;
(* *
* Initialize an AVTWOFISH context.
*
* @param ctx an AVTWOFISH context
* @param key a key of size ranging from 1 to 32 bytes used for encryption/decryption
* @param key_bits number of keybits: 128, 192, 256 If less than the required, padded with zeroes to nearest valid value; return value is 0 if key_bits is 128/192/256, -1 if less than 0, 1 otherwise
*)
// int av_twofish_init(struct AVTWOFISH *ctx, const uint8_t *key, int key_bits);
function av_twofish_init(ctx: pAVTWOFISH; const key: puint8_t; key_bits: int): int; cdecl; external avutil_dll;
(* *
* Encrypt or decrypt a buffer using a previously initialized context
*
* @param ctx an AVTWOFISH context
* @param dst destination array, can be equal to src
* @param src source array, can be equal to dst
* @param count number of 16 byte blocks
* @paran iv initialization vector for CBC mode, NULL for ECB mode
* @param decrypt 0 for encryption, 1 for decryption
*)
// void av_twofish_crypt(struct AVTWOFISH *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t* iv, int decrypt);
procedure av_twofish_crypt(ctx: pAVTWOFISH; dst: puint8_t; const src: puint8_t; count: int; iv: puint8_t; decrypt: int); cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'tea.h'}
type
pAVTEA = ^AVTEA;
AVTEA = record
end;
(* *
* Allocate an AVTEA context
* To free the struct: av_free(ptr)
*)
// struct AVTEA *av_tea_alloc(void);
function av_tea_alloc: pAVTEA; cdecl; external avutil_dll;
(* *
* Initialize an AVTEA context.
*
* @param ctx an AVTEA context
* @param key a key of 16 bytes used for encryption/decryption
* @param rounds the number of rounds in TEA (64 is the "standard")
*)
// void av_tea_init(struct AVTEA *ctx, const uint8_t key[16], int rounds);
procedure av_tea_init(ctx: pAVTEA; const key: puint8_t; rounds: int); cdecl; external avutil_dll;
(* *
* Encrypt or decrypt a buffer using a previously initialized context.
*
* @param ctx an AVTEA context
* @param dst destination array, can be equal to src
* @param src source array, can be equal to dst
* @param count number of 8 byte blocks
* @param iv initialization vector for CBC mode, if NULL then ECB will be used
* @param decrypt 0 for encryption, 1 for decryption
*)
// void av_tea_crypt(struct AVTEA *ctx, uint8_t *dst, const uint8_t *src,
// int count, uint8_t *iv, int decrypt);
procedure av_tea_crypt(ctx: pAVTEA; dst: puint8_t; const src: puint8_t; count: int; iv: puint8_t; decrypt: int); cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'hwcontext_videotoolbox.h'}
(*
* Convert a VideoToolbox (actually CoreVideo) format to AVPixelFormat.
* Returns AV_PIX_FMT_NONE if no known equivalent was found.
*)
// enum AVPixelFormat av_map_videotoolbox_format_to_pixfmt(uint32_t cv_fmt);
function av_map_videotoolbox_format_to_pixfmt(cv_fmt: uint32_t): AVPixelFormat; cdecl; external avutil_dll;
(*
* Convert an AVPixelFormat to a VideoToolbox (actually CoreVideo) format.
* Returns 0 if no known equivalent was found.
*)
// uint32_t av_map_videotoolbox_format_from_pixfmt(enum AVPixelFormat pix_fmt);
function av_map_videotoolbox_format_from_pixfmt(pix_fmt: AVPixelFormat): uint32_t; cdecl; external avutil_dll;
(*
* Same as av_map_videotoolbox_format_from_pixfmt function, but can map and
* return full range pixel formats via a flag.
*)
// uint32_t av_map_videotoolbox_format_from_pixfmt2(enum AVPixelFormat pix_fmt, bool full_range);
function av_map_videotoolbox_format_from_pixfmt2(pix_fmt: AVPixelFormat; full_range: bool): uint32_t; cdecl; external avutil_dll;
{$ENDREGION}
{$REGION 'tx.h'}
// typedef struct AVTXContext AVTXContext;
Type
AVTXContext = record
end;
pAVTXContext = ^AVTXContext;
AVComplexFloat = record
re, im: float;
end;
AVComplexDouble = record
re, im: double;
end;
AVTXType = (
(*
* Standard complex to complex FFT with sample data type AVComplexFloat.
* Scaling currently unsupported
*)
AV_TX_FLOAT_FFT = 0,
(*
* Standard MDCT with sample data type of float and a scale type of
* float. Length is the frame size, not the window size (which is 2x frame)
*)
AV_TX_FLOAT_MDCT = 1,
(*
* Same as AV_TX_FLOAT_FFT with a data type of AVComplexDouble.
*)
AV_TX_DOUBLE_FFT = 2,
(*
* Same as AV_TX_FLOAT_MDCT with data and scale type of double.
*)
AV_TX_DOUBLE_MDCT = 3 //
);
(*
* Function pointer to a function to perform the transform.
*
* @note Using a different context than the one allocated during av_tx_init()
* is not allowed.
*
* @param s the transform context
* @param out the output array
* @param in the input array
* @param stride the input or output stride (depending on transform direction)
* in bytes, currently implemented for all MDCT transforms
*)
// typedef void (*av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride);
av_tx_fn = procedure(s: pAVTXContext; &out, &in: Pointer; stride: ptrdiff_t); cdecl;
(*
* Initialize a transform context with the given configuration
* Currently power of two lengths from 4 to 131072 are supported, along with
* any length decomposable to a power of two and either 3, 5 or 15.
*
* @param ctx the context to allocate, will be NULL on error
* @param tx pointer to the transform function pointer to set
* @param type type the type of transform
* @param inv whether to do an inverse or a forward transform
* @param len the size of the transform in samples
* @param scale pointer to the value to scale the output if supported by type
* @param flags currently unused
*
* @return 0 on success, negative error code on failure
*)
// int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, int inv, int len, const void *scale, uint64_t flags);
function av_tx_init(Var ctx: pAVTXContext; tx: av_tx_fn; &type: AVTXType; inv, len: int; const scale: Pointer; flags: uint64_t):int; cdecl; external avutil_dll;
(*
* Frees a context and sets ctx to NULL, does nothing when ctx == NULL
*)
// void av_tx_uninit(AVTXContext **ctx);
procedure av_tx_uninit(Var ctx: pAVTXContext); cdecl; external avutil_dll;
{$ENDREGION}
implementation
{$REGION 'common.h'}
function RSHIFT(a, b: int): int; inline;
begin
if a > 0 then
Result := ((a) + ((1 shl (b)) shr 1)) shr (b)
else
Result := ((a) + ((1 shl (b)) shr 1) - 1) shr (b);
end;
function ROUNDED_DIV(a, b: int): int; inline;
begin
if a > 0 then
Result := a + (b shr 1)
else
Result := a - (b shr 1) div b;
end;
function FFUDIV(a, b: int): int; inline;
begin
if a > 0 then
Result := a
else
Result := a - b + 1;
Result := Result div b;
end;
function FFUMOD(a, b: int): int; inline;
begin
Result := a - b * FFUDIV(a, b);
end;
function FFABS(a: int): int; inline;
begin
if a >= 0 then
Result := a
else
Result := -a;
end;
function FFSIGN(a: int): int; inline;
begin
if a > 0 then
Result := 1
else
Result := -1;
end;
function FFNABS(a: int): int; inline;
begin
if a <= 0 then
Result := a
else
Result := -a;
end;
function FFDIFFSIGN(x, y: int): Boolean; inline;
begin
Result := FFSIGN(x) <> FFSIGN(y);
end;
function FFMAX(a, b: int): int; inline;
begin
if a > b then
Result := a
else
Result := b;
end;
function av_clip_c(a: int; amin: int; amax: int): int; inline;
begin
// #if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
// if (amin > amax) abort();
// #endif
if (a < amin) then
Result := amin
else if (a > amax) then
Result := amax
else
Result := a;
end;
function av_clip64_c(a: int64_t; amin: int64_t; amax: int64_t): int64_t; inline;
begin
// #if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2
// if (amin > amax) abort();
// #endif
if (a < amin) then
Result := amin
else if (a > amax) then
Result := amax
else
Result := a;
end;
function av_clip_uint8_c(a: int): uint8_t; inline;
begin
// if (a&(~0xFF)) return (~a)>>31;
// else return a;
if (a and (not $FF)) <> 0 then
Result := (not a) shr 31
else
Result := a;
end;
function av_clip_int8_c(a: int): int8_t; inline;
begin
if ((a + $80) and (not $FF)) <> 0 then
Result := (a shr 31) xor $7F
else
Result := a;
end;
function av_clip_uint16_c(a: int): uint16_t; inline;
begin
if (a and (not $FFFF)) <> 0 then
Result := (not a) shr 31
else
Result := a;
end;
function av_clip_int16_c(a: int): int16_t; inline;
begin
if ((a + $8000) and (not $FFFF)) <> 0 then
Result := (a shr 31) xor $7FFF
else
Result := a;
end;
function av_clipl_int32_c(a: int64_t): int32_t; inline;
begin
if ((a + $80000000) and (not $FFFFFFFF)) <> 0 then
Result := ((a shr 63) xor $7FFFFFFF)
else
Result := a;
end;
function av_clip_intp2_c(a: int; p: int): int; inline;
begin
if ((a + (1 shl p)) and (not((2 shl p) - 1))) <> 0 then
Result := (a shr 31) xor ((1 shl p) - 1)
else
Result := a;
end;
function av_clip_uintp2_c(a: int; p: int): UINT; inline;
begin
if (a and (not((1 shl p) - 1))) <> 0 then
Result := (not a) shr 31 and ((1 shl p) - 1)
else
Result := a;
end;
function av_mod_uintp2_c(a: UINT; p: UINT): UINT; inline;
begin
Result := a and ((UINT(1) shl p) - 1);
end;
function av_sat_add32_c(a: int; b: int): int; inline;
begin
Result := av_clipl_int32_c(a + b);
end;
function av_sat_dadd32_c(a: int; b: int): int; inline;
begin
Result := av_sat_add32_c(a, av_sat_add32_c(b, b));
end;
function av_sat_sub32_c(a: int; b: int): int; inline;
begin
Result := av_clipl_int32_c(a - b);
end;
function av_sat_dsub32_c(a: int; b: int): int; inline;
begin
Result := av_sat_sub32_c(a, av_sat_add32_c(b, b));
end;
function av_clipf_c(a: float; amin: float; amax: float): float; inline;
begin
if a < amin then
Result := amin
else if a > amax then
Result := amax
else
Result := a;
end;
function av_clipd_c(a: double; amin: double; amax: double): double; inline;
begin
if a < amin then
Result := amin
else if a > amax then
Result := amax
else
Result := a;
end;
function av_ceil_log2_c(x: int): int; inline;
begin
Result := av_log2((x - 1) shl 1);
end;
function av_popcount_c(x: uint32_t): int; inline;
begin
x := x - ((x shr 1) and $55555555);
x := (x and $33333333) + ((x shr 2) and $33333333);
x := (x + (x shr 4)) and $0F0F0F0F;
x := x + (x shr 8);
Result := (x + (x shr 16)) and $3F;
end;
function av_popcount64_c(x: uint64_t): int; inline;
begin
Result := av_popcount_c(x) + av_popcount_c(x shr 32);
end;
function av_parity_c(v: uint32_t): int; inline;
begin
Result := av_popcount_c(v) and 1;
end;
{$ENDREGION}
{$REGION 'rational.h'}
function av_make_q(_num: int; _den: int): AVRational; inline;
begin
Result.num := _num;
Result.den := _den;
end;
function av_cmp_q(a, b: AVRational): int; inline;
Var
tmp: int64_t;
begin
tmp := a.num * b.den - b.num * a.den;
if (tmp <> 0) then
Result := ((tmp xor a.den xor b.den) shr 63) or 1
else if (b.den and a.den) <> 0 then
Result := 0
else if (a.num and b.num) <> 0 then
Result := (a.num shr 31) - (b.num shr 31)
else
Result := -MaxInt;
end;
function av_q2d(a: AVRational): double; inline;
begin
Result := a.num / a.den;
end;
function av_inv_q(q: AVRational): AVRational; inline;
begin
Result.den := q.den;
Result.num := q.num;
end;
function av_x_if_null(const p: Pointer; const x: Pointer): Pointer; inline;
begin
// return (void *)(intptr_t)(p ? p : x);
if Assigned(p) then
Result := p
else
Result := x;
end;
{$ENDREGION}
{$REGION 'opt.h'}
function av_opt_set_int_list(obj: Pointer; name: PAnsiChar; list: Pointer; item_size: int; term: int64_t; flags: int): Integer; inline;
begin
if av_int_list_length(list, item_size, term) > MaxInt / item_size then
Result := AVERROR_EINVAL
else
Result := av_opt_set_bin(obj, name, puint8_t(list), av_int_list_length(list, item_size, term) * item_size, flags);
end;
function av_int_list_length(list: Pointer; item_size: int; term: int64_t): int; inline;
begin
Result := av_int_list_length_for_size(item_size, list, term);
end;
{$ENDREGION}
{$REGION 'error.h'}
function av_make_error_string(errbuf: PAnsiChar; errbuf_size: size_t; errnum: int): PAnsiChar;
begin
av_strerror(errnum, @errbuf, errbuf_size);
Result := @errbuf;
end;
var
error_str: array [0 .. AV_ERROR_MAX_STRING_SIZE - 1] of AnsiChar;
function av_err2str(errnum: int): PAnsiChar;
begin
FillChar(error_str, SizeOf(error_str), 0);
av_make_error_string(@error_str, AV_ERROR_MAX_STRING_SIZE, errnum);
Result := @error_str;
end;
{$ENDREGION}
{$REGION 'avstring.h'}
function av_strnlen(const s: PAnsiChar; len: size_t): size_t; inline;
begin
Result := 0;
While s[Result] <> #0 do
inc(Result);
end;
function av_isdigit(c: int): Boolean; inline;
begin
Result := (AnsiChar(c) >= '0') and (AnsiChar(c) <= '9');
end;
function av_isgraph(c: int): Boolean; inline;
begin
Result := (c > 32) and (c < 127);
end;
function av_isspace(c1: int): Boolean; inline;
var
c: AnsiChar;
begin
c := AnsiChar(c1);
Result := //
(c = ' ') or //
(c = #$0C) or //
(c = #$0A) or //
(c = #$0D) or //
(c = #$09) or //
(c = #$0B);
end;
function av_toupper(c1: int): int; inline;
var
c: AnsiChar;
begin
c := AnsiChar(c1);
Result := Ord(c);
if (c >= 'a') and (c <= 'z') then
Result := Result xor $20;
end;
function av_tolower(c1: int): int; inline;
var
c: AnsiChar;
begin
c := AnsiChar(c1);
Result := Ord(c);
if (c >= 'A') and (c <= 'Z') then
Result := Result xor $20;
end;
function av_isxdigit(c1: int): Boolean; inline;
var
c: AnsiChar;
begin
c1 := av_tolower(c1);
c := AnsiChar(AnsiChar(c1));
Result := av_isdigit(c1) or ((c >= 'a') and (c <= 'f'));
end;
{$ENDREGION}
{$REGION 'bprint.h'}
function av_bprint_is_complete(const buf: pAVBPrint): Boolean; inline;
begin
Result := buf^.len < buf^.size;
end;
{$ENDREGION}
{$REGION 'fifo.h'}
function av_fifo_peek2(const f: pAVFifoBuffer; offs: int): puint8_t; inline;
var
ptr: puint8_t;
begin
ptr := f^.rptr + offs;
if (ptr >= f^._end) then
ptr := f^.buffer + (ptr - f^._end)
else if (ptr < f^.buffer) then
ptr := f^._end - (f^.buffer - ptr);
Result := ptr;
end;
{$ENDREGION}
{$REGION 'timestamp.h'}
function av_ts_make_string(buf: PAnsiChar; ts: int64_t): PAnsiChar;
Var
p: AnsiString;
m: size_t;
begin
{
if (ts == AV_NOPTS_VALUE)
snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS");
else
snprintf(buf, AV_TS_MAX_STRING_SIZE, "%" PRId64, ts);
return buf;
}
if (ts = AV_NOPTS_VALUE) then
p := 'NOPTS'
else
str(ts, p);
m := Length(p);
if m > AV_TS_MAX_STRING_SIZE then
m := AV_TS_MAX_STRING_SIZE;
move(p[1], buf^, m);
Result := buf;
end;
var
av_ts_buf: array [0 .. AV_TS_MAX_STRING_SIZE] of AnsiChar;
function av_ts2str(ts: int64_t): PAnsiChar;
begin
FillChar(av_ts_buf, SizeOf(av_ts_buf), 0);
Result := av_ts_make_string(@av_ts_buf[0], ts);
end;
function av_ts_make_time_string(buf: PAnsiChar; ts: int64_t; tb: pAVRational): PAnsiChar;
Var
p: AnsiString;
m: size_t;
begin
{
if (ts == AV_NOPTS_VALUE) snprintf(buf, AV_TS_MAX_STRING_SIZE, "NOPTS");
else snprintf(buf, AV_TS_MAX_STRING_SIZE, "%.6g", av_q2d(*tb) * ts);
return buf;
}
if (ts = AV_NOPTS_VALUE) then
p := 'NOPTS'
else
str((av_q2d(tb^) * ts): 1: 6, p);
m := Length(p);
if m > AV_TS_MAX_STRING_SIZE then
m := AV_TS_MAX_STRING_SIZE;
move(p[1], buf^, m);
Result := buf;
end;
function av_ts2timestr(ts: int64_t; tb: pAVRational): PAnsiChar;
begin
FillChar(av_ts_buf, SizeOf(av_ts_buf), 0);
Result := av_ts_make_time_string(@av_ts_buf[0], ts, tb);
end;
{$ENDREGION}
{$REGION 'mem.h'}
function av_size_mult(a: size_t; b: size_t; var r: size_t): int; inline;
var
t: size_t;
begin
t := a * b;
(* Hack inspired from glibc: don't try the division if nelem and elsize
* are both less than sqrt(SIZE_MAX). *)
if ((a or b) >= (size_t(1) shl (SizeOf(size_t) * 4))) and (a <> 0) and ((t div a) <> b) then
Exit(AVERROR_EINVAL);
r := t;
Result := 0;
end;
{$ENDREGION}
{$REGION 'parseutils.h'}
function av_parse_ratio_quiet(q: pAVRational; const str: PAnsiChar; max: int): int; inline;
begin
Result := av_parse_ratio(q, str, max, AV_LOG_MAX_OFFSET, nil);
end;
{$ENDREGION}
{$REGION 'intfloat.h'}
function av_int2float(i: uint32_t): float; inline;
begin
Result := av_intfloat32(i).f;
end;
function av_float2int(f: float): uint32_t; inline;
begin
Result := av_intfloat32(f).i;
end;
function av_int2double(i: uint64_t): double; inline;
begin
Result := av_intfloat64(i).f;
end;
function av_double2int(f: double): uint64_t; inline;
begin
Result := av_intfloat64(f).i;
end;
{$ENDREGION}
end.
| 40.832499 | 204 | 0.700005 |
470b76835476d157c9adfac7e759ba69c668a1f7
| 1,759 |
pas
|
Pascal
|
src/GL Visir/TGLVisir/OgreEventQueue.pas
|
xackery/openzone
|
c9d4c91515ea10a206cefe3f104c730ad4abcc02
|
[
"MIT"
] | null | null | null |
src/GL Visir/TGLVisir/OgreEventQueue.pas
|
xackery/openzone
|
c9d4c91515ea10a206cefe3f104c730ad4abcc02
|
[
"MIT"
] | null | null | null |
src/GL Visir/TGLVisir/OgreEventQueue.pas
|
xackery/openzone
|
c9d4c91515ea10a206cefe3f104c730ad4abcc02
|
[
"MIT"
] | null | null | null |
Unit OgreEventQueue;
Interface
Uses Classes,SyncObjs,OgreInputEvent;
Type
EventQueue = Class
Protected
List : TStringList;
Mutex : TCriticalSection;
mActivateEventQueue : Boolean;
Public
Constructor Create;
Destructor Destroy; Override;
Procedure Push(Event: InputEvent);
Function Pop: InputEvent;
Procedure ActivateEventQueue(Activate: Boolean);
Function GetSize: Integer;
End;
Implementation
Constructor EventQueue.Create;
Begin
List := TStringList.Create;
Mutex := TCriticalSection.Create;
mActivateEventQueue := False;
End; // EventQueue.Create
Destructor EventQueue.Destroy;
Var I: Integer;
Begin
For I := 0 To List.Count - 1 Do List.Objects[I].Free;
List.Free;
Mutex.Free;
End; // EventQueue.Destroy
Procedure EventQueue.Push(Event: InputEvent);
Begin
Try
Mutex.Enter;
If mActivateEventQueue Then List.AddObject('',Event);
Finally
Mutex.Leave;
End;
End; // EventQueue.Push
Function EventQueue.Pop: InputEvent;
Begin
Try
Mutex.Enter;
If mActivateEventQueue And (List.Count > 0) Then
Begin
Result := InputEvent(List.Objects[0]);
List.Delete(0);
End
Else Result := Nil;
Finally
Mutex.Leave;
End;
End; // EventQueue.Pop
Procedure EventQueue.ActivateEventQueue(Activate: Boolean);
Begin
Try
Mutex.Enter;
mActivateEventQueue := Activate;
Finally
Mutex.Leave;
End;
End; // EventQueue.ActivateEventQueue
Function EventQueue.GetSize: Integer;
Begin
Try
Mutex.Enter;
Result := List.Count;
Finally
Mutex.Leave;
End;
End; // EventQueue.GetSize
End.
| 20.694118 | 60 | 0.648664 |
839f9f3b412b803b257cc51937c9fe913b8f6573
| 765 |
dpr
|
Pascal
|
utilities/fmx/FMX_FHIR_UI/test_ui/FHIRComponentTest.dpr
|
danka74/fhirserver
|
1fc53b6fba67a54be6bee39159d3db28d42eb8e2
|
[
"BSD-3-Clause"
] | 132 |
2015-02-02T00:22:40.000Z
|
2021-08-11T12:08:08.000Z
|
utilities/fmx/FMX_FHIR_UI/test_ui/FHIRComponentTest.dpr
|
danka74/fhirserver
|
1fc53b6fba67a54be6bee39159d3db28d42eb8e2
|
[
"BSD-3-Clause"
] | 113 |
2015-03-20T01:55:20.000Z
|
2021-10-08T16:15:28.000Z
|
utilities/fmx/FMX_FHIR_UI/test_ui/FHIRComponentTest.dpr
|
danka74/fhirserver
|
1fc53b6fba67a54be6bee39159d3db28d42eb8e2
|
[
"BSD-3-Clause"
] | 49 |
2015-04-11T14:59:43.000Z
|
2021-03-30T10:29:18.000Z
|
program FHIRComponentTest;
uses
System.StartUpCopy,
FMX.Forms,
fhir_objects in '..\..\..\..\base\fhir_objects.pas',
fhir4_resources in '..\..\..\..\R4\fhir4_resources.pas',
FHIR.Server.Session in '..\..\..\..\tools\FHIR.Server.Session.pas',
fhir_indexing in '..\..\..\..\tools\fhir_indexing.pas',
FHIR.Server.Security in '..\..\..\..\tools\FHIR.Server.Security.pas',
FHIR.Version.Parser in '..\..\..\..\version\FHIR.Version.Parser.pas',
FHIR.FMX.Ctrls in '..\..\..\..\ui\fmx\FMX_FHIR_UI\FHIR.FMX.Ctrls.pas',
FHIR.Server.XhtmlComp in '..\..\..\..\tools\FHIR.Server.XhtmlComp.pas',
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
| 33.26087 | 74 | 0.636601 |
61dd0a3bd0bd3144badf00d0888066dc9acaf1de
| 1,999 |
pas
|
Pascal
|
Demos/SqlClient/TSqlClientQuery/MasterDetail/fQueryMasterDetail.pas
|
CrystalNet-Tech/ADONetDAC4Delphi_Tutorials
|
7b0ad4f962b5d2075a90e451b57257596b41ed62
|
[
"Apache-2.0"
] | 1 |
2020-09-24T23:26:35.000Z
|
2020-09-24T23:26:35.000Z
|
Demos/SqlClient/TSqlClientQuery/MasterDetail/fQueryMasterDetail.pas
|
CrystalNet-Tech/ADONetDAC4Delphi_Tutorials
|
7b0ad4f962b5d2075a90e451b57257596b41ed62
|
[
"Apache-2.0"
] | null | null | null |
Demos/SqlClient/TSqlClientQuery/MasterDetail/fQueryMasterDetail.pas
|
CrystalNet-Tech/ADONetDAC4Delphi_Tutorials
|
7b0ad4f962b5d2075a90e451b57257596b41ed62
|
[
"Apache-2.0"
] | null | null | null |
unit fQueryMasterDetail;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms, Dialogs, fMainQueryBase, CNClrLib.ADONet.Enums,
CNClrLib.ADONet.Error, CNClrLib.ADONet.EventArgs,
CNClrLib.ADONet.SqlEventArgs, DB, CNClrLib.ADONet.Client,
CNClrLib.ADONet.SqlClient, Buttons, StdCtrls, ComCtrls,
ExtCtrls, Grids, DBGrids;
type
TfrmMasterDetail = class(TfrmMainQueryBase)
mmoComment: TMemo;
pnl2: TPanel;
btnRefreshMaster: TButton;
btnRefreshDetails: TButton;
dbgrd1: TDBGrid;
spl1: TSplitter;
dbgrd2: TDBGrid;
dsOrders: TDataSource;
dsOrderDetails: TDataSource;
SqlClientQueryOrders: TSqlClientQuery;
SqlClientQueryOrderDetails: TSqlClientQuery;
procedure FormCreate(Sender: TObject);
procedure btnConnectClick(Sender: TObject);
procedure btnRefreshMasterClick(Sender: TObject);
procedure btnRefreshDetailsClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frmMasterDetail: TfrmMasterDetail;
implementation
{$R *.dfm}
procedure TfrmMasterDetail.btnRefreshMasterClick(Sender: TObject);
begin
SqlClientQueryOrders.Refresh;
end;
procedure TfrmMasterDetail.btnRefreshDetailsClick(Sender: TObject);
begin
SqlClientQueryOrderDetails.Refresh;
end;
procedure TfrmMasterDetail.btnConnectClick(Sender: TObject);
begin
btnRefreshMaster.Enabled := False;
btnRefreshDetails.Enabled := False;
SqlClientQueryOrderDetails.Close;
SqlClientQueryOrders.Close;
inherited;
SqlClientQueryOrders.Open;
SqlClientQueryOrderDetails.Open;
btnRefreshMaster.Enabled := True;
btnRefreshDetails.Enabled := True;
end;
procedure TfrmMasterDetail.FormCreate(Sender: TObject);
begin
inherited;
RegisterDS(SqlClientQueryOrders);
RegisterDS(SqlClientQueryOrderDetails);
btnRefreshMaster.Enabled := False;
btnRefreshDetails.Enabled := False;
end;
end.
| 26.302632 | 68 | 0.751376 |
f14d651f1b9f7f89f368f8cded42fcf4bfa1083b
| 3,003 |
dfm
|
Pascal
|
src/tarefa_tipo/tarefa_tipo.listagem.dfm
|
eficiente-app/faina-delphi-vcl
|
90dd70bf21867013abdeb548488eae9ff1a395a2
|
[
"MIT"
] | 3 |
2021-01-04T23:12:52.000Z
|
2021-03-24T19:25:05.000Z
|
src/tarefa_tipo/tarefa_tipo.listagem.dfm
|
eficiente-app/faina-delphi-vcl
|
90dd70bf21867013abdeb548488eae9ff1a395a2
|
[
"MIT"
] | null | null | null |
src/tarefa_tipo/tarefa_tipo.listagem.dfm
|
eficiente-app/faina-delphi-vcl
|
90dd70bf21867013abdeb548488eae9ff1a395a2
|
[
"MIT"
] | 1 |
2020-12-17T10:48:34.000Z
|
2020-12-17T10:48:34.000Z
|
object TarefaTipoListagem: TTarefaTipoListagem
Left = 0
Top = 0
Caption = 'Tarefa Tipo'
ClientHeight = 605
ClientWidth = 583
Color = clWindow
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
KeyPreview = True
OldCreateOrder = False
Position = poOwnerFormCenter
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object dbgridPasta: TDBGrid
Left = 0
Top = 145
Width = 583
Height = 460
Align = alClient
DataSource = srcTarefaTipo
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'Tahoma'
TitleFont.Style = []
end
object pnlPesquisa: TPanel
Left = 0
Top = 30
Width = 583
Height = 115
Align = alTop
BevelOuter = bvNone
TabOrder = 1
object pnlPesquisar: TPanel
AlignWithMargins = True
Left = 380
Top = 5
Width = 81
Height = 109
Margins.Left = 0
Margins.Top = 5
Margins.Bottom = 1
Align = alLeft
BevelOuter = bvNone
TabOrder = 0
object btnPesquisar: TButton
AlignWithMargins = True
Left = 3
Top = 3
Width = 75
Height = 73
Align = alClient
Caption = 'Pesquisar'
TabOrder = 0
OnClick = btnPesquisarClick
end
object btnLimpar: TButton
AlignWithMargins = True
Left = 3
Top = 81
Width = 75
Height = 25
Margins.Top = 2
Align = alBottom
Caption = 'Limpar'
TabOrder = 1
end
end
object gbxPesquisa: TGroupBox
AlignWithMargins = True
Left = 3
Top = 3
Width = 374
Height = 109
Align = alLeft
Caption = ' Pesquisa '
TabOrder = 1
end
end
object pnlTopo: TPanel
Left = 0
Top = 0
Width = 583
Height = 30
Align = alTop
BevelKind = bkTile
BevelOuter = bvNone
TabOrder = 2
object sbtFechar: TSpeedButton
Left = 556
Top = 0
Width = 23
Height = 26
Align = alRight
Caption = 'X'
OnClick = sbtFecharClick
ExplicitTop = -4
end
object btnIncluir: TButton
Left = 0
Top = 0
Width = 75
Height = 26
Align = alLeft
Caption = 'Incluir'
TabOrder = 0
OnClick = btnIncluirClick
end
object btnAlterar: TButton
Left = 75
Top = 0
Width = 75
Height = 26
Align = alLeft
Caption = 'Alterar'
TabOrder = 1
OnClick = btnAlterarClick
end
object btnVisualizar: TButton
Left = 150
Top = 0
Width = 75
Height = 26
Align = alLeft
Caption = 'Visualizar'
TabOrder = 2
OnClick = btnVisualizarClick
end
end
object srcTarefaTipo: TDataSource
AutoEdit = False
DataSet = TarefaTipoDados.tblTarefaTipo
Left = 360
Top = 1
end
end
| 20.854167 | 46 | 0.575758 |
83d68fe6c673eabbda267d216b440fb30dd7bb85
| 1,044 |
pas
|
Pascal
|
04 - Estruturas de Vetores-Arrays/Lista2/Exercicio06b.pas
|
AndreLucyo2/Algoritmos-Pascal_1SemIFPR
|
ca170be7b7bf0d8f5d5529ebf0908df1975f60c1
|
[
"MIT"
] | null | null | null |
04 - Estruturas de Vetores-Arrays/Lista2/Exercicio06b.pas
|
AndreLucyo2/Algoritmos-Pascal_1SemIFPR
|
ca170be7b7bf0d8f5d5529ebf0908df1975f60c1
|
[
"MIT"
] | null | null | null |
04 - Estruturas de Vetores-Arrays/Lista2/Exercicio06b.pas
|
AndreLucyo2/Algoritmos-Pascal_1SemIFPR
|
ca170be7b7bf0d8f5d5529ebf0908df1975f60c1
|
[
"MIT"
] | null | null | null |
{
6. Escrever um algoritmo que lê um vetor N(20) e o escreve.
Troque, a seguir, o 1* elemento com o último, o 2* com o penúltimo, etc até o 10* com o 11* e escreva o
vetor N assim modificado.
}
{$CODEPAGE UTF8}
program Exercicio06b;
uses crt;
const
dimVetor = 20;
var
vetA : array [1..dimVetor] of integer;
vetB : array [1..dimVetor] of integer;
cont : integer;
aux : Integer;
begin
cont:=0;
aux := dimVetor;
for cont:= 1 to dimVetor do
begin
vetA[cont] := random(100);//Preenche o vetor A
end;
//Inverte o Vetor
for cont:= 1 to dimVetor do
begin
vetB[aux] := vetA[cont] ;//Preenche o vetor B com o vetB invertido.
aux := dimVetor - cont ;//Decrementa o contador
end;
//Mostra o vetor A:
for cont:= 1 to dimVetor do
begin
Write(vetA[cont],'-');
end;
WriteLn();
//Mostra o vetor B:
for cont:= 1 to dimVetor do
begin
Write(vetB[cont],'-');
end;
readkey;
end.
| 20.076923 | 104 | 0.570881 |
83ca225a3db15a48b94fd6c9cef602850f62af01
| 156,491 |
pas
|
Pascal
|
src/Tests/Tests.Conformance.Base.pas
|
delphidabbler/delphi-coll
|
f072f729a3d18b1ae8cfc7aca9ea1887a1b6e9f1
|
[
"BSD-3-Clause",
"MIT"
] | 11 |
2018-12-07T16:10:51.000Z
|
2021-04-26T12:42:04.000Z
|
src/Tests/Tests.Conformance.Base.pas
|
delphidabbler/delphi-coll
|
f072f729a3d18b1ae8cfc7aca9ea1887a1b6e9f1
|
[
"BSD-3-Clause",
"MIT"
] | null | null | null |
src/Tests/Tests.Conformance.Base.pas
|
delphidabbler/delphi-coll
|
f072f729a3d18b1ae8cfc7aca9ea1887a1b6e9f1
|
[
"BSD-3-Clause",
"MIT"
] | 4 |
2017-12-08T21:22:51.000Z
|
2020-04-20T15:37:12.000Z
|
(*
*-Copyright (c) 2011, Ciobanu Alexandru
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the <organization> nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*)
{
This file has been modified from the original by Peter Johnson
(@delphidabbler). For full details of modifications see the commit history of
the delphidabbler/delphi-coll fork on GitHub
}
unit Tests.Conformance.Base;
interface
uses SysUtils,
TestFramework,
Tests.Internal.Basics,
Generics.Defaults,
Generics.Collections,
Collections.Base;
{
Things that remain to test:
1. TEnexOps.Select (all 5).
2. TEnexOps.GroupBy.
3. IDynamic in collections.
4. Fill Collection.
5. A derived TEnumerator from TAbstractEnumerator.
6. The forwarding enumerator.
7. TAbstractOperableCollection with a minimum implementation.
8. Stack.Peek = Last
9. Queue.Peek = First
10. Push-Pop, Enqueue-Dequeue chain
11. MaxKey/MinKey check for correct orderfing on Ascending/Descending.
}
{
NAME CHANGES (Names that have changed in this version of tests from those in forked version):
TEST CLASSES:
TConformance_IEnumerable_Simple => TConformance_IEnumerable
(same tests)
TConformance_ICollection_Simple => TConformance_IContainer
(same tests)
TConformance_IEnexColletion => TConformance_ISequence
(same tests, but more needed for extra ISequence methods)
TConformance_IOperableCollection => TConformance_ICollection
(same tests)
TConformance_IEnexAssociativeCollection => TConformance_IAssociation
(same tests, but more needed for extra IAssociation methods)
INTERFACES:
ICollection => IContainer
(same methods)
IEnexCollection => ISequence
(IEnexCollection appeared to be a subset of ISequence)
IOperableCollection => ICollection
(same methods)
IEnexAssociativeCollection => IAssociation
(IEnexAssociativeCollection appeared to be a subset of IAssociation)
TYPES:
TAbstractOperableCollection => TCollection
}
type
TOrdering = (oNone, oInsert, oAscending, oDescending);
TElements = TArray<NativeInt>;
TPairs = TArray<TPair<NativeInt, NativeInt>>;
TConformance_IEnumerable = class(TTestCaseEx)
strict private
FEmpty, FOne, FFull: IEnumerable<NativeInt>;
FElements: TElements;
FOrdering: TOrdering;
protected
property Ordering: TOrdering read FOrdering;
property Elements: TElements read FElements;
procedure SetUp_IEnumerable(out AEmpty, AOne, AFull: IEnumerable<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); virtual; abstract;
procedure SetUp; override;
procedure TearDown; override;
published
procedure Test_GetEnumerator();
procedure Test_Enumerator_Early_Current;
procedure Test_Enumerator_ReachEnd;
end;
TConformance_IContainer = class(TConformance_IEnumerable)
strict private
FEmpty, FOne, FFull: IContainer<NativeInt>;
protected
procedure SetUp_IEnumerable(out AEmpty, AOne, AFull: IEnumerable<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); override;
procedure SetUp_IContainer(out AEmpty, AOne, AFull: IContainer<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); virtual; abstract;
published
procedure Test_Version();
procedure Test_GetCount; // alias for Count property
procedure Test_Empty;
procedure Test_Single;
procedure Test_SingleOrDefault;
procedure Test_CopyTo_1;
procedure Test_CopyTo_2;
procedure Test_ToArray;
end;
TConformance_ISequence = class(TConformance_IContainer)
strict private
FEmpty, FOne, FFull: ISequence<NativeInt>;
function GetCountOf(const APredicate: TPredicate<NativeInt>): NativeInt;
protected
procedure SetUp_IContainer(out AEmpty, AOne, AFull: IContainer<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); override;
procedure SetUp_ISequence(out AEmpty, AOne, AFull: ISequence<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); virtual; abstract;
published
// TODO: Need extra test methods for additional ISequence methods
procedure Test_EqualsTo;
procedure Test_ToList;
procedure Test_ToSet;
procedure Test_Max;
procedure Test_Min;
procedure Test_First;
procedure Test_FirstOrDefault;
procedure Test_FirstWhere;
procedure Test_FirstWhereOrDefault;
procedure Test_FirstWhereNot;
procedure Test_FirstWhereNotOrDefault;
procedure Test_Last;
procedure Test_LastOrDefault;
procedure Test_Aggregate;
procedure Test_AggregateOrDefault;
procedure Test_ElementAt;
procedure Test_ElementAtOrDefault;
procedure Test_Any;
procedure Test_All;
procedure Test_Where;
procedure Test_WhereNot;
procedure Test_Distinct;
procedure Test_Ordered_1;
procedure Test_Ordered_2;
procedure Test_Reversed;
procedure Test_Concat;
procedure Test_Union;
procedure Test_Exclude;
procedure Test_Intersect;
procedure Test_Range;
procedure Test_Take;
procedure Test_TakeWhile;
procedure Test_Skip;
procedure Test_SkipWhile;
end;
TConformance_IGrouping = class(TConformance_ISequence)
strict private
FEmpty, FOne, FFull: IGrouping<NativeInt, NativeInt>;
FKey: NativeInt;
protected
procedure SetUp_ISequence(out AEmpty, AOne, AFull: ISequence<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); override;
procedure SetUp_IGrouping(out AEmpty, AOne, AFull: IGrouping<NativeInt, NativeInt>; out AKey: NativeInt; out AElements: TElements; out AOrdering: TOrdering); virtual; abstract;
published
procedure Test_GetKey; // alias for Key property
end;
TConformance_ICollection = class(TConformance_ISequence)
strict private
FEmpty, FOne, FFull: ICollection<NativeInt>;
FRemovedList: Generics.Collections.TList<NativeInt>;
procedure EnsureOrdering(const ACollection: ICollection<NativeInt>);
protected
property RemovedList: Generics.Collections.TList<NativeInt> read FRemovedList;
procedure RemoveNotification(const AValue: NativeInt);
procedure SetUp_ISequence(out AEmpty, AOne, AFull: ISequence<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); override;
procedure SetUp_ICollection(out AEmpty, AOne, AFull: ICollection<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); virtual; abstract;
procedure SetUp; override;
procedure TearDown; override;
published
procedure Test_Clear;
procedure Test_Add;
procedure Test_AddAll;
procedure Test_Remove;
procedure Test_RemoveAll;
procedure Test_Contains;
procedure Test_ContainsAll;
end;
TConformance_IStack = class(TConformance_ICollection)
strict private
FEmpty, FOne, FFull: IStack<NativeInt>;
protected
procedure SetUp_ICollection(out AEmpty, AOne, AFull: ICollection<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); override;
procedure SetUp_IStack(out AEmpty, AOne, AFull: IStack<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); virtual; abstract;
published
procedure Test_Push;
procedure Test_Pop;
procedure Test_Peek;
end;
TConformance_IQueue = class(TConformance_ICollection)
strict private
FEmpty, FOne, FFull: IQueue<NativeInt>;
protected
procedure SetUp_ICollection(out AEmpty, AOne, AFull: ICollection<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); override;
procedure SetUp_IQueue(out AEmpty, AOne, AFull: IQueue<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); virtual; abstract;
published
procedure Test_Enqueue;
procedure Test_Dequeue;
procedure Test_Peek;
end;
TConformance_ISet = class(TConformance_ICollection)
strict private
FEmpty, FOne, FFull: ISet<NativeInt>;
protected
procedure SetUp_ICollection(out AEmpty, AOne, AFull: ICollection<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); override;
procedure SetUp_ISet(out AEmpty, AOne, AFull: ISet<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); virtual; abstract;
published
end;
TConformance_ISortedSet = class(TConformance_ISet)
strict private
FEmpty, FOne, FFull: ISortedSet<NativeInt>;
protected
procedure SetUp_ISet(out AEmpty, AOne, AFull: ISet<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); override;
procedure SetUp_ISortedSet(out AEmpty, AOne, AFull: ISortedSet<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); virtual; abstract;
end;
TConformance_IBag = class(TConformance_ISet)
strict private
FEmpty, FOne, FFull: IBag<NativeInt>;
protected
procedure SetUp_ISet(out AEmpty, AOne, AFull: ISet<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); override;
procedure SetUp_IBag(out AEmpty, AOne, AFull: IBag<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); virtual; abstract;
published
procedure Test_AddWeight;
procedure Test_RemoveWeight;
procedure Test_RemoveAllWeight;
procedure Test_ContainsWeight;
procedure Test_GetWeight;
procedure Test_SetWeight;
end;
TConformance_IList = class(TConformance_ICollection)
strict private
FEmpty, FOne, FFull: IList<NativeInt>;
protected
procedure SetUp_ICollection(out AEmpty, AOne, AFull: ICollection<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); override;
procedure SetUp_IList(out AEmpty, AOne, AFull: IList<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); virtual; abstract;
published
procedure Test_Insert;
procedure Test_InsertAll;
procedure Test_RemoveAt;
procedure Test_ExtractAt;
procedure Test_IndexOf;
procedure Test_LastIndexOf;
procedure Test_GetItem;
procedure Test_SetItem;
end;
TConformance_ILinkedList = class(TConformance_IList)
strict private
FEmpty, FOne, FFull: ILinkedList<NativeInt>;
protected
procedure SetUp_IList(out AEmpty, AOne, AFull: IList<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); override;
procedure SetUp_ILinkedList(out AEmpty, AOne, AFull: ILinkedList<NativeInt>; out AElements: TElements; out AOrdering: TOrdering); virtual; abstract;
published
procedure Test_AddLast;
procedure Test_AddAllLast;
procedure Test_AddFirst;
procedure Test_AddAllFirst;
procedure Test_RemoveFirst;
procedure Test_RemoveLast;
procedure Test_ExtractFirst;
procedure Test_ExtractLast;
procedure Test_ILinkedList_First;
procedure Test_ILinkedList_Last;
end;
TConformance_IEnumerable_Associative = class(TTestCaseEx)
strict private
FEmpty, FOne, FFull: IEnumerable<TPair<NativeInt, NativeInt>>;
FPairs: TPairs;
FKeyOrdering: TOrdering;
protected
property KeyOrdering: TOrdering read FKeyOrdering;
property Pairs: TPairs read FPairs;
procedure SetUp_IEnumerable(out AEmpty, AOne, AFull: IEnumerable<TPair<NativeInt, NativeInt>>; out APairs: TPairs; out AKeyOrdering: TOrdering); virtual; abstract;
procedure SetUp; override;
procedure TearDown; override;
procedure CheckEquals(const AExpected, AActual: TPair<NativeInt, NativeInt>; const AMessage: String = ''); overload;
published
procedure Test_GetEnumerator();
procedure Test_Enumerator_Early_Current;
procedure Test_Enumerator_ReachEnd;
end;
TConformance_ICollection_Associative = class(TConformance_IEnumerable_Associative)
strict private
FEmpty, FOne, FFull: IContainer<TPair<NativeInt, NativeInt>>;
protected
procedure SetUp_IEnumerable(out AEmpty, AOne, AFull: IEnumerable<TPair<NativeInt, NativeInt>>; out APairs: TPairs; out AKeyOrdering: TOrdering); override;
procedure SetUp_IContainer(out AEmpty, AOne, AFull: IContainer<TPair<NativeInt, NativeInt>>; out APairs: TPairs; out AKeyOrdering: TOrdering); virtual; abstract;
function MinusOne: TPair<NativeInt, NativeInt>; overload;
function MinusOne(const APair: TPair<NativeInt, NativeInt>): TPair<NativeInt, NativeInt>; overload;
published
procedure Test_Version();
procedure Test_GetCount;
procedure Test_Empty;
procedure Test_Single;
procedure Test_SingleOrDefault;
procedure Test_CopyTo_1;
procedure Test_CopyTo_2;
procedure Test_ToArray;
end;
TConformance_IAssociation = class(TConformance_ICollection_Associative)
strict private
FEmpty, FOne, FFull: IAssociation<NativeInt, NativeInt>;
protected
procedure SetUp_IContainer(out AEmpty, AOne, AFull: IContainer<TPair<NativeInt, NativeInt>>; out APairs: TPairs; out AKeyOrdering: TOrdering); override;
procedure SetUp_IAssociation(out AEmpty, AOne, AFull: IAssociation<NativeInt, NativeInt>; out APairs: TPairs; out AKeyOrdering: TOrdering); virtual; abstract;
published
procedure Test_ToDictionary;
procedure Test_ValueForKey;
procedure Test_KeyHasValue;
procedure Test_MaxKey;
procedure Test_MinKey;
procedure Test_MaxValue;
procedure Test_MinValue;
procedure Test_SelectKeys; // Alias for Keys property
procedure Test_SelectValues; // Alias for Values property
procedure Test_DistinctByKeys;
procedure Test_DistinctByValues;
procedure Test_Includes;
procedure Test_Where;
procedure Test_WhereNot;
// TODO: procedure Test_WhereKeyLower;
// TODO: procedure Test_WhereKeyLowerOrEqual;
// TODO: procedure Test_WhereKeyGreater;
// TODO: procedure Test_WhereKeyGreaterOrEqual;
// TODO: procedure Test_WhereKeyBetween;
// TODO: procedure Test_WhereValueLower;
// TODO: procedure Test_WhereValueLowerOrEqual;
// TODO: procedure Test_WhereValueGreater;
// TODO: procedure Test_WhereValueGreaterOrEqual;
// TODO: procedure Test_WhereValueBetween;
end;
TConformance_IMap = class(TConformance_IAssociation)
strict private
FEmpty, FOne, FFull: IMap<NativeInt, NativeInt>;
FRemovedKeys: Generics.Collections.TList<NativeInt>;
FRemovedValues: Generics.Collections.TList<NativeInt>;
protected
property RemovedKeys: Generics.Collections.TList<NativeInt> read FRemovedKeys;
property RemovedValues: Generics.Collections.TList<NativeInt> read FRemovedValues;
procedure KeyRemoveNotification(const AValue: NativeInt);
procedure ValueRemoveNotification(const AValue: NativeInt);
procedure SetUp_IAssociation(out AEmpty, AOne, AFull: IAssociation<NativeInt, NativeInt>; out APairs: TPairs; out AKeyOrdering: TOrdering); override;
procedure SetUp_IMap(out AEmpty, AOne, AFull: IMap<NativeInt, NativeInt>; out APairs: TPairs; out AKeyOrdering: TOrdering); virtual; abstract;
procedure SetUp; override;
procedure TearDown; override;
published
procedure Test_Clear;
procedure Test_Add_1;
procedure Test_Add_2;
procedure Test_AddAll;
procedure Test_Remove;
procedure Test_ContainsKey;
procedure Test_ContainsValue;
end;
TConformance_IDictionary = class(TConformance_IMap)
strict private
FEmpty, FOne, FFull: IDictionary<NativeInt, NativeInt>;
protected
procedure SetUp_IMap(out AEmpty, AOne, AFull: IMap<NativeInt, NativeInt>; out APairs: TPairs; out AKeyOrdering: TOrdering); override;
procedure SetUp_IDictionary(out AEmpty, AOne, AFull: IDictionary<NativeInt, NativeInt>; out APairs: TPairs; out AKeyOrdering: TOrdering); virtual; abstract;
published
// TODO: Implement these tests
procedure Test_Extract;
procedure Test_TryGetValue;
procedure Test_GetValue;
procedure Test_SetValue;
end;
TConformance_IBidiDictionary = class(TConformance_IMap)
strict private
FEmpty, FOne, FFull: IBidiDictionary<NativeInt, NativeInt>;
protected
procedure SetUp_IMap(out AEmpty, AOne, AFull: IMap<NativeInt, NativeInt>; out APairs: TPairs; out AKeyOrdering: TOrdering); override;
procedure SetUp_IBidiDictionary(out AEmpty, AOne, AFull: IBidiDictionary<NativeInt, NativeInt>; out APairs: TPairs; out AKeyOrdering: TOrdering); virtual; abstract;
published
// TODO: Implement these tests
procedure Test_ExtractValueForKey;
procedure Test_ExtractKeyForValue;
procedure Test_RemoveValueForKey;
procedure Test_RemoveKeyForValue;
procedure Test_RemovePair_1;
procedure Test_RemovePair_2;
procedure Test_ContainsPair_1;
procedure Test_ContainsPair_2;
procedure Test_TryGetValueForKey;
procedure Test_GetValueForKey;
procedure Test_SetValueForKey;
procedure Test_TryGetKeyForValue;
procedure Test_GetKeyForValue;
procedure Test_SetKeyForValue;
end;
TConformance_IBidiMap = class(TConformance_IMap)
strict private
FEmpty, FOne, FFull: IBidiMap<NativeInt, NativeInt>;
protected
procedure SetUp_IMap(out AEmpty, AOne, AFull: IMap<NativeInt, NativeInt>; out APairs: TPairs; out AKeyOrdering: TOrdering); override;
procedure SetUp_IBidiMap(out AEmpty, AOne, AFull: IBidiMap<NativeInt, NativeInt>; out APairs: TPairs; out AKeyOrdering: TOrdering); virtual; abstract;
published
// TODO: Implement these tests
procedure Test_RemoveValuesForKey;
procedure Test_RemoveKeysForValue;
procedure Test_RemovePair_1;
procedure Test_RemovePair_2;
procedure Test_ContainsPair_1;
procedure Test_ContainsPair_2;
procedure Test_GetValuesByKey;
procedure Test_GetKeysByValue;
end;
TConformance_IMultiMap = class(TConformance_IMap)
strict private
FEmpty, FOne, FFull: IMultiMap<NativeInt, NativeInt>;
protected
procedure SetUp_IMap(out AEmpty, AOne, AFull: IMap<NativeInt, NativeInt>; out APairs: TPairs; out AKeyOrdering: TOrdering); override;
procedure SetUp_IMultiMap(out AEmpty, AOne, AFull: IMultiMap<NativeInt, NativeInt>; out APairs: TPairs; out AKeyOrdering: TOrdering); virtual; abstract;
published
// TODO: Implement these tests
procedure Test_ExtractValues;
procedure Test_RemovePair_1;
procedure Test_RemovePair_2;
procedure Test_ContainsPair_1;
procedure Test_ContainsPair_2;
procedure Test_GetValues;
procedure Test_TryGetValues_1;
procedure Test_TryGetValues_2;
end;
function GenerateUniqueRandomElements: TElements;
function GenerateRepeatableRandomElements: TElements;
function GenerateUniqueRandomElement(const AKnownElements: TElements): NativeInt;
implementation
const
CElements = 100;
function GenerateUniqueRandomElement(const AKnownElements: TElements): NativeInt;
var
I: Integer;
LWas: Boolean;
begin
Randomize;
LWas := True;
Result := 0;
while LWas do
begin
Result := Random(MaxInt);
LWas := False;
for I := 0 to Length(AKnownElements) - 1 do
if AKnownElements[I] = Result then
begin
LWas := True;
Break;
end;
end;
end;
function GenerateRepeatableRandomElements: TElements;
var
I, R: NativeInt;
begin
Randomize;
SetLength(Result, CElements);
I := 0;
while I < CElements do
begin
R := Random(MaxInt);
Result[I] := R;
Inc(I);
if (Random(2) = 1) and (I > 1) then
begin
Result[I] := Result[I - 2];
Inc(I);
end;
end;
end;
function GenerateUniqueRandomElements: TElements;
var
X, Y, R, L: NativeInt;
LWas: Boolean;
begin
Randomize;
L := 0;
SetLength(Result, CElements);
for X := 0 to CElements - 1 do
begin
LWas := True;
while LWas do
begin
LWas := False;
R := Random(MaxInt);
for Y := 0 to L - 1 do
if Result[Y] = R then
begin
LWas := True;
Break;
end;
if not LWas then
begin
Result[L] := R;
Inc(L);
end;
end;
end;
end;
{ TConformance_IEnumerable }
procedure TConformance_IEnumerable.SetUp;
begin
inherited;
SetUp_IEnumerable(FEmpty, FOne, FFull, FElements, FOrdering);
end;
procedure TConformance_IEnumerable.TearDown;
begin
inherited;
FEmpty := nil;
FOne := nil;
FFull := nil;
end;
procedure TConformance_IEnumerable.Test_Enumerator_Early_Current;
begin
CheckTrue(FEmpty.GetEnumerator().Current = Default(NativeInt), 'Expected Current to be default for [empty].');
CheckTrue(FOne.GetEnumerator().Current = Default(NativeInt), 'Expected Current to be default for [one].');
CheckTrue(FFull.GetEnumerator().Current = Default(NativeInt), 'Expected Current to be default for [full].');
end;
procedure TConformance_IEnumerable.Test_Enumerator_ReachEnd;
var
LEnumerator: IEnumerator<NativeInt>;
LLast, LIndex: NativeInt;
LList: Generics.Collections.TList<NativeInt>;
LIsFirst: Boolean;
begin
LEnumerator := FEmpty.GetEnumerator();
CheckFalse(LEnumerator.MoveNext(), 'Did not expect a valid 1.MoveNext() for [empty]');
CheckFalse(LEnumerator.MoveNext(), 'Did not expect a valid 2.MoveNext() for [empty]');
LEnumerator := FOne.GetEnumerator();
CheckTrue(LEnumerator.MoveNext(), 'Expected a valid 1.MoveNext() for [one]');
LLast := LEnumerator.Current;
CheckFalse(LEnumerator.MoveNext(), 'Did not expect a valid 2.MoveNext() for [one]');
CheckEquals(LLast, LEnumerator.Current, 'Expected the last value to remain constant for [one]');
CheckFalse(LEnumerator.MoveNext(), 'Did not expect a valid 3.MoveNext() for [one]');
CheckEquals(LLast, LEnumerator.Current, 'Expected the last value to remain constant for [one]');
CheckEquals(LLast, FElements[0], 'Expected the only value to be valid [one]');
LEnumerator := FFull.GetEnumerator();
LList := Generics.Collections.TList<NativeInt>.Create();
LList.AddRange(FElements);
LIsFirst := True;
LIndex := 0;
while LEnumerator.MoveNext() do
begin
if LIsFirst then
LIsFirst := False
else begin
{ Check ordering if applied }
if FOrdering = oAscending then
CheckTrue(LEnumerator.Current >= LLast, 'Expected Vi >= Vi-1 always for [full]!')
else if FOrdering = oDescending then
CheckTrue(LEnumerator.Current <= LLast, 'Expected Vi <= Vi-1 always for [full]!');
end;
LLast := LEnumerator.Current;
if FOrdering = oInsert then
CheckTrue(FElements[LIndex] = LLast, 'Expected insert ordering to apply for [full].');
LList.Remove(LEnumerator.Current);
Inc(LIndex);
end;
{ Check that all elements have been enumerated }
CheckEquals(0, LList.Count, 'Expected that all elements are enumerated in [full].');
LList.Free;
end;
procedure TConformance_IEnumerable.Test_GetEnumerator;
var
LEnumerator: IEnumerator<NativeInt>;
begin
LEnumerator := FEmpty.GetEnumerator();
CheckTrue(Assigned(LEnumerator), 'Expected a non-nil enumerator for [empty].');
CheckTrue(Pointer(LEnumerator) <> Pointer(FEmpty.GetEnumerator()), 'Expected a new object enumerator for [empty].');
LEnumerator := FOne.GetEnumerator();
CheckTrue(Assigned(LEnumerator), 'Expected a non-nil enumerator for [one].');
CheckTrue(Pointer(LEnumerator) <> Pointer(FOne.GetEnumerator()), 'Expected a new object enumerator for [one].');
LEnumerator := FFull.GetEnumerator();
CheckTrue(Assigned(LEnumerator), 'Expected a non-nil enumerator for [full].');
CheckTrue(Pointer(LEnumerator) <> Pointer(FFull.GetEnumerator()), 'Expected a new object enumerator for [full].');
end;
{ TConformance_IContainer }
procedure TConformance_IContainer.SetUp_IEnumerable(out AEmpty, AOne,
AFull: IEnumerable<NativeInt>; out AElements: TElements;
out AOrdering: TOrdering);
begin
SetUp_IContainer(FEmpty, FOne, FFull, AElements, AOrdering);
AEmpty := FEmpty;
AOne := FOne;
AFull := FFull;
end;
procedure TConformance_IContainer.Test_CopyTo_1;
var
LArray: TArray<NativeInt>;
LEnumerator: IEnumerator<NativeInt>;
LIndex: NativeInt;
begin
SetLength(LArray, 1);
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.CopyTo(LArray, -1); end,
'EArgumentOutOfRangeException not thrown in [empty].CopyTo(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.CopyTo(LArray, 2); end,
'EArgumentOutOfRangeException not thrown in [empty].CopyTo(2)'
);
FEmpty.CopyTo(LArray, 0);
SetLength(LArray, 0);
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.CopyTo(LArray, 0); end,
'EArgumentOutOfRangeException not thrown in [empty].CopyTo(0)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.CopyTo(LArray, 0); end,
'EArgumentOutOfRangeException not thrown in [one].CopyTo(0)'
);
SetLength(LArray, 10);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.CopyTo(LArray, -1); end,
'EArgumentOutOfRangeException not thrown in [one].CopyTo(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.CopyTo(LArray, 10); end,
'EArgumentOutOfRangeException not thrown in [one].CopyTo(10)'
);
FOne.CopyTo(LArray, 9);
CheckEquals(LArray[9], Elements[0], 'Expected the element to be coopied properly [one].');
SetLength(LArray, 0);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.CopyTo(LArray, 0); end,
'EArgumentOutOfRangeException not thrown in [full].CopyTo(0)'
);
SetLength(LArray, Length(Elements) - 1);
CheckException(EArgumentOutOfSpaceException,
procedure() begin FFull.CopyTo(LArray, 0); end,
'EArgumentOutOfSpaceException not thrown in [full].CopyTo(0)'
);
SetLength(LArray, Length(Elements) + 1);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.CopyTo(LArray, -1); end,
'EArgumentOutOfRangeException not thrown in [full].CopyTo(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.CopyTo(LArray, Length(LArray)); end,
'EArgumentOutOfRangeException not thrown in [full].CopyTo(L)'
);
FFull.CopyTo(LArray, 1);
LEnumerator := FFull.GetEnumerator();
LIndex := 1;
while LEnumerator.MoveNext() do
begin
CheckEquals(LEnumerator.Current, LArray[LIndex], 'Expected the copied array to be same order as enumerator for [full].');
Inc(LIndex);
end;
CheckEquals(Length(LArray), LIndex, 'Expected same count as enumerator for [full]');
end;
procedure TConformance_IContainer.Test_CopyTo_2;
var
LArray: TArray<NativeInt>;
LEnumerator: IEnumerator<NativeInt>;
LIndex: NativeInt;
begin
SetLength(LArray, 1);
FEmpty.CopyTo(LArray);
SetLength(LArray, 0);
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.CopyTo(LArray); end,
'EArgumentOutOfRangeException not thrown in [empty].CopyTo()'
);
SetLength(LArray, 10);
FOne.CopyTo(LArray, 9);
CheckEquals(LArray[9], Elements[0], 'Expected the element to be coopied properly [one].');
SetLength(LArray, 0);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.CopyTo(LArray); end,
'EArgumentOutOfRangeException not thrown in [full].CopyTo()'
);
SetLength(LArray, Length(Elements) - 1);
CheckException(EArgumentOutOfSpaceException,
procedure() begin FFull.CopyTo(LArray); end,
'EArgumentOutOfSpaceException not thrown in [full].CopyTo()'
);
SetLength(LArray, Length(Elements) + 1);
FFull.CopyTo(LArray, 1);
LEnumerator := FFull.GetEnumerator();
LIndex := 1;
while LEnumerator.MoveNext() do
begin
CheckEquals(LEnumerator.Current, LArray[LIndex], 'Expected the copied array to be same order as enumerator for [full].');
Inc(LIndex);
end;
CheckEquals(Length(LArray), LIndex, 'Expected same count as enumerator for [full]');
end;
procedure TConformance_IContainer.Test_Empty;
begin
CheckTrue(FEmpty.Empty, 'Expected empty for [empty].');
CheckFalse(FOne.Empty, 'Expected non-empty for [one].');
CheckFalse(FFull.Empty, 'Expected non-empty for [full].');
end;
procedure TConformance_IContainer.Test_GetCount;
begin
CheckEquals(0, FEmpty.GetCount(), 'Expected zero count for [empty].');
CheckEquals(1, FOne.GetCount(), 'Expected 1 count for [one].');
CheckEquals(Length(Elements), FFull.GetCount(), 'Expected > 1 count for [full].');
end;
procedure TConformance_IContainer.Test_Single;
begin
CheckException(ECollectionEmptyException,
procedure() begin FEmpty.Single(); end,
'ECollectionEmptyException not thrown in [empty].Single()'
);
CheckEquals(Elements[0], FOne.Single(), 'Expected "single" value failed for [one]');
CheckException(ECollectionNotOneException,
procedure() begin FFull.Single(); end,
'ECollectionNotOneException not thrown in [full].Single()'
);
end;
procedure TConformance_IContainer.Test_SingleOrDefault;
var
LSingle: NativeInt;
begin
CheckException(ECollectionNotOneException,
procedure() begin FFull.SingleOrDefault(-1); end,
'ECollectionNotOneException not thrown in [full].SingleOrDefault()'
);
CheckEquals(-1, FEmpty.SingleOrDefault(-1), 'Expected "-1" value failed for [one]');
LSingle := FOne.Single();
CheckEquals(LSingle, FOne.SingleOrDefault(LSingle - 1), 'Expected "single" value failed for [one]');
end;
procedure TConformance_IContainer.Test_ToArray;
var
LArray: TArray<NativeInt>;
LEnumerator: IEnumerator<NativeInt>;
LIndex: NativeInt;
begin
LArray := FEmpty.ToArray();
CheckEquals(0, Length(LArray), 'Expected a length of zero for the elements of [empty].');
LArray := FOne.ToArray();
CheckEquals(1, Length(LArray), 'Expected a length of 1 for the elements of [one].');
CheckEquals(Elements[0], LArray[0], 'Expected a proper single element for [one].');
LArray := FFull.ToArray();
CheckEquals(Length(Elements), Length(LArray), 'Expected a proper length for [full].');
LEnumerator := FFull.GetEnumerator();
LIndex := 0;
while LEnumerator.MoveNext() do
begin
CheckEquals(LEnumerator.Current, LArray[LIndex], 'Expected the copied array to be same order as enumerator for [full]');
Inc(LIndex);
end;
CheckEquals(Length(LArray), LIndex, 'Expected same count as enumerator for [full]');
end;
procedure TConformance_IContainer.Test_Version;
begin
CheckEquals(0, FEmpty.Version(), 'Expected the version for [empty] to be zero.');
CheckTrue(FOne.Version() > FEmpty.Version(), 'Expected the version for [one] to be bigger than zero.');
CheckTrue(FFull.Version() > FEmpty.Version(), 'Expected the version for [full] to be bigger than for [one].');
end;
{ TConformance_ISequence }
function TConformance_ISequence.GetCountOf(const APredicate: TPredicate<NativeInt>): NativeInt;
var
I: Integer;
begin
Result := 0;
for I := 0 to Length(Elements) - 1 do
if APredicate(Elements[I]) then
Inc(Result);
end;
procedure TConformance_ISequence.SetUp_IContainer(out AEmpty, AOne, AFull: IContainer<NativeInt>;
out AElements: TElements; out AOrdering: TOrdering);
begin
SetUp_ISequence(FEmpty, FOne, FFull, AElements, AOrdering);
AEmpty := FEmpty;
AOne := FOne;
AFull := FFull;
end;
procedure TConformance_ISequence.Test_Aggregate;
var
LAggregator: TFunc<NativeInt, NativeInt, NativeInt>;
LSum, I: NativeInt;
begin
{ Tests:
1. EArgumentNilException in all cases for nil predicates.
2. ECollectionEmptyException for [empty].
3. Proper aggregation for [one].
4. Real aggregation for [full].
}
CheckException(EArgumentNilException,
procedure() begin FEmpty.Aggregate(nil) end,
'EArgumentNilException not thrown in [empty].Aggregate()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.Aggregate(nil) end,
'EArgumentNilException not thrown in [one].Aggregate()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.Aggregate(nil) end,
'EArgumentNilException not thrown in [full].Aggregate()'
);
LAggregator := function(Arg1, Arg2: NativeInt): NativeInt begin Exit(Arg1 + Arg2); end;
CheckException(ECollectionEmptyException,
procedure() begin FEmpty.Aggregate(LAggregator) end,
'ECollectionEmptyException not thrown in [empty].Aggregate()'
);
CheckEquals(Elements[0], FOne.Aggregate(LAggregator), 'Expected the only element for [one]');
LSum := 0;
for I := 0 to Length(Elements) - 1 do
Inc(LSum, Elements[I]);
CheckEquals(LSum, FFull.Aggregate(LAggregator), 'Expected the sum of elements for [full]');
end;
procedure TConformance_ISequence.Test_AggregateOrDefault;
var
LAggregator: TFunc<NativeInt, NativeInt, NativeInt>;
LSum, I: NativeInt;
begin
{ Tests:
1. EArgumentNilException in all cases for nil predicates.
2. Proper aggregation for [one].
3. Real aggregation for [full].
4. Default for [empty].
}
CheckException(EArgumentNilException,
procedure() begin FEmpty.AggregateOrDefault(nil, -1) end,
'EArgumentNilException not thrown in [empty].AggregateOrDefault()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.AggregateOrDefault(nil, -1) end,
'EArgumentNilException not thrown in [one].AggregateOrDefault()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.AggregateOrDefault(nil, -1) end,
'EArgumentNilException not thrown in [full].AggregateOrDefault()'
);
LAggregator := function(Arg1, Arg2: NativeInt): NativeInt begin Exit(Arg1 + Arg2); end;
CheckEquals(-1, FEmpty.AggregateOrDefault(LAggregator, -1), 'Expected the only element for [empty]');
CheckEquals(Elements[0], FOne.AggregateOrDefault(LAggregator, Elements[0] - 1), 'Expected the only element for [one]');
LSum := 0;
for I := 0 to Length(Elements) - 1 do
Inc(LSum, Elements[I]);
CheckEquals(LSum, FFull.AggregateOrDefault(LAggregator, -1), 'Expected the sum of elements for [full]');
end;
procedure TConformance_ISequence.Test_All;
var
LAlwaysTruePredicate,
LPredicate: TPredicate<NativeInt>;
LLast: NativeInt;
begin
{ Tests:
1. EArgumentNilException for nil predicates.
2. True for [empty]
3. True for an always true predicate.
4. Proper All for [one] and [full].
}
CheckException(EArgumentNilException,
procedure() begin FEmpty.All(nil) end,
'EArgumentNilException not thrown in [empty].All()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.All(nil) end,
'EArgumentNilException not thrown in [one].All()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.All(nil) end,
'EArgumentNilException not thrown in [full].All()'
);
LAlwaysTruePredicate := function(Arg: NativeInt): Boolean begin Exit(True); end;
CheckEquals(True, FEmpty.All(LAlwaysTruePredicate), 'Expected all = true for [empty]');
CheckEquals(True, FOne.All(LAlwaysTruePredicate), 'Expected all = true for [empty]');
CheckEquals(True, FFull.All(LAlwaysTruePredicate), 'Expected all = true for [empty]');
LPredicate := function(Arg: NativeInt): Boolean begin Exit(Arg = Elements[0]); end;
CheckEquals(True, FOne.All(LPredicate), 'Expected all = true for [one]');
LLast := FFull.Last;
LPredicate := function(Arg: NativeInt): Boolean begin Exit(Arg = LLast); end;
CheckEquals(False, FFull.All(LPredicate), 'Expected all = false for [full]');
end;
procedure TConformance_ISequence.Test_Any;
var
LAlwaysFalsePredicate,
LPredicate: TPredicate<NativeInt>;
LLast: NativeInt;
begin
{ Tests:
1. EArgumentNilException for nil predicates.
2. False for [empty]
3. False for an always false predicate.
4. Proper All for [one] and [full].
}
CheckException(EArgumentNilException,
procedure() begin FEmpty.Any(nil) end,
'EArgumentNilException not thrown in [empty].Any()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.Any(nil) end,
'EArgumentNilException not thrown in [one].Any()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.Any(nil) end,
'EArgumentNilException not thrown in [full].Any()'
);
LAlwaysFalsePredicate := function(Arg: NativeInt): Boolean begin Exit(false); end;
CheckEquals(False, FEmpty.Any(LAlwaysFalsePredicate), 'Expected any = false for [empty]');
CheckEquals(False, FOne.Any(LAlwaysFalsePredicate), 'Expected any = false for [empty]');
CheckEquals(False, FFull.Any(LAlwaysFalsePredicate), 'Expected any = false for [empty]');
LPredicate := function(Arg: NativeInt): Boolean begin Exit(Arg = Elements[0]); end;
CheckEquals(True, FOne.Any(LPredicate), 'Expected any = true for [one]');
LLast := FFull.Last;
LPredicate := function(Arg: NativeInt): Boolean begin Exit(Arg = LLast); end;
CheckEquals(True, FFull.Any(LPredicate), 'Expected any = true for [full]');
end;
procedure TConformance_ISequence.Test_Concat;
var
LList: IList<NativeInt>;
begin
{ Tests:
1. EArgumentNilException for nil collections.
2. [empty] + [empty] = [empty]
3. [empty] + [one] = [one]
4. [one] + [empty] = [empty]
5. [one] + [one] = 2 x [one]
6. [full] + [one] = [full], then [one]
}
CheckException(EArgumentNilException,
procedure() begin FEmpty.Concat(nil) end,
'EArgumentNilException not thrown in [empty].Concat()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.Concat(nil) end,
'EArgumentNilException not thrown in [one].Concat()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.Concat(nil) end,
'EArgumentNilException not thrown in [full].Concat()'
);
CheckTrue( FEmpty.Concat(FEmpty).EqualsTo(FEmpty), 'Expected [empty] + [empty] = [empty]');
CheckTrue( FEmpty.Concat(FOne).EqualsTo(FOne), 'Expected [empty] + [one] = [one]');
CheckTrue( FOne.Concat(FEmpty).EqualsTo(FOne), 'Expected [one] + [empty] = [one]');
LList := FFull.ToList(); LList.Add(FOne.Single);
CheckTrue( FFull.Concat(FOne).EqualsTo(LList), 'Expected [full] + [one] to be correct');
LList := FFull.ToList(); LList.AddAll(FFull);
CheckTrue( FFull.Concat(FFull).EqualsTo(LList), 'Expected [full] + [full] to be correct');
end;
procedure TConformance_ISequence.Test_Distinct;
var
LSet: ISet<NativeInt>;
LDistinct: ISequence<NativeInt>;
LValue: NativeInt;
begin
{ Tests:
1. Equivalent to ToSet().
2. [empty] is empty.
3. [one] has one.
}
LDistinct := FEmpty.Distinct();
CheckTrue(LDistinct.Empty, 'Expected empty distinct result for [empty]');
LDistinct := FOne.Distinct();
CheckEquals(1, LDistinct.Count, 'Expected 1-length distinct result for [one]');
CheckEquals(FOne.Single(), LDistinct.Single(), 'Expected the same element for [one]');
LDistinct := FFull.Distinct();
LSet := FFull.ToSet();
CheckTrue(FFull.Count >= LDistinct.Count, 'Expected distinct length >= [full]');
CheckEquals(LSet.Count, LDistinct.Count, 'Expected N-length distinct result for [full]');
for LValue in LDistinct do
begin
CheckTrue(LSet.Contains(LValue), 'Expected the distinct element to be in the set [full].');
LSet.Remove(LValue);
end;
CheckTrue(LSet.Empty, 'Expected same elements in distinct of [full] as in set of [full].');
end;
procedure TConformance_ISequence.Test_ElementAt;
begin
{ Tests:
1. EArgumentOutOfRangeException for negative, always
2. EArgumentOutOfRangeException for [empty]
3. EArgumentOutOfRangeException for actual out of range.
4. ElementAt[0] = First and ElementAt[L-1] = Last.
}
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.ElementAt(-1) end,
'EArgumentOutOfRangeException not thrown in [empty].ElementAt(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.ElementAt(-1) end,
'EArgumentOutOfRangeException not thrown in [one].ElementAt(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.ElementAt(-1) end,
'EArgumentOutOfRangeException not thrown in [full].ElementAt(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.ElementAt(0) end,
'EArgumentOutOfRangeException not thrown in [empty].ElementAt(0)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.ElementAt(1) end,
'EArgumentOutOfRangeException not thrown in [one].ElementAt(1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.ElementAt(FFull.GetCount()) end,
'EArgumentOutOfRangeException not thrown in [full].ElementAt(L)'
);
CheckEquals(Elements[0], FOne.ElementAt(0), 'Expected element[0] to be correct in [one]');
CheckEquals(FFull.First, FFull.ElementAt(0), 'Expected element[0] to be equal to First in [full]');
CheckEquals(FFull.Last, FFull.ElementAt(FFull.GetCount() - 1), 'Expected element[L-1] to be equal to Last in [full]');
end;
procedure TConformance_ISequence.Test_ElementAtOrDefault;
begin
{ Tests:
1. EArgumentOutOfRangeException for negative, always
2. The default for [empty], or out-of-range.
4. ElementAtOrDefault[0] = First and ElementAtOrDefault[L-1] = Last.
}
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.ElementAtOrDefault(-1, -1) end,
'EArgumentOutOfRangeException not thrown in [empty].ElementAtOrDefault(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.ElementAtOrDefault(-1, -1) end,
'EArgumentOutOfRangeException not thrown in [one].ElementAtOrDefault(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.ElementAtOrDefault(-1, -1) end,
'EArgumentOutOfRangeException not thrown in [full].ElementAtOrDefault(-1)'
);
CheckEquals(-1, FEmpty.ElementAtOrDefault(0, -1), 'Expected default in [empty]');
CheckEquals(-1, FOne.ElementAtOrDefault(1, -1), 'Expected default in [one]');
CheckEquals(-1, FFull.ElementAtOrDefault(FFull.Count, -1), 'Expected default in [full]');
CheckEquals(Elements[0], FOne.ElementAtOrDefault(0, Elements[0] - 1), 'Expected element[0] to be correct in [one]');
CheckEquals(FFull.First, FFull.ElementAtOrDefault(0, FFull.First - 1), 'Expected element[0] to be equal to First in [full]');
CheckEquals(FFull.Last, FFull.ElementAtOrDefault(FFull.GetCount() - 1, FFull.Last - 1), 'Expected element[L-1] to be equal to Last in [full]');
end;
procedure TConformance_ISequence.Test_EqualsTo;
begin
CheckTrue(FEmpty.EqualsTo(FEmpty), 'Expected [empty] = [empty]');
CheckFalse(FOne.EqualsTo(FEmpty), 'Expected [one] <> [empty]');
CheckFalse(FEmpty.EqualsTo(FOne), 'Expected [empty] <> [one]');
CheckTrue(FFull.EqualsTo(FFull), 'Expected [full] = [full]');
CheckFalse(FFull.EqualsTo(FFull.Concat(FOne)), 'Expected [full] <> [full + one]');
CheckFalse(FFull.EqualsTo(FFull.Exclude(FOne)), 'Expected [full] <> [full - one]');
end;
procedure TConformance_ISequence.Test_Exclude;
var
LList: IList<NativeInt>;
begin
{ Tests:
1. EArgumentNilException for nil collections.
2. [empty] - [empty] = [empty]
3. [empty] - [one] = [empty]
4. [one] - [empty] = [one]
5. [one] - [one] = [empty]
}
CheckException(EArgumentNilException,
procedure() begin FEmpty.Exclude(nil) end,
'EArgumentNilException not thrown in [empty].Union()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.Exclude(nil) end,
'EArgumentNilException not thrown in [one].Union()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.Exclude(nil) end,
'EArgumentNilException not thrown in [full].Union()'
);
CheckTrue( FEmpty.Exclude(FEmpty).EqualsTo(FEmpty), 'Expected [empty] - [empty] = [empty]');
CheckTrue( FEmpty.Exclude(FOne).EqualsTo(FEmpty), 'Expected [empty] - [one] = [empty]');
CheckTrue( FOne.Exclude(FEmpty).EqualsTo(FOne), 'Expected [one] - [empty] = [one]');
CheckTrue( FOne.Exclude(FOne).EqualsTo(FEmpty), 'Expected [one] - [one] = [empty]');
CheckTrue( FFull.Exclude(FFull).EqualsTo(FEmpty), 'Expected [full] - [full] = [empty]');
LList := FFull.ToList();
while LList.Contains(FOne.Single) do
LList.Remove(FOne.Single);
CheckTrue( FFull.Exclude(FOne).EqualsTo(LList), 'Expected [full] - [one] = [full - 1]');
end;
procedure TConformance_ISequence.Test_First;
var
LEnumerator: IEnumerator<NativeInt>;
begin
CheckException(ECollectionEmptyException,
procedure() begin FEmpty.First() end,
'ECollectionEmptyException not thrown in [empty].First()'
);
CheckEquals(Elements[0], FOne.First(), 'Expected proper first for [one].');
LEnumerator := FFull.GetEnumerator();
LEnumerator.MoveNext();
CheckEquals(LEnumerator.Current, FFull.First(), 'Expected proper first for [full].');
end;
procedure TConformance_ISequence.Test_FirstOrDefault;
var
LEnumerator: IEnumerator<NativeInt>;
begin
{ Tests:
1. The default for [empty]
2. The actual element for [one].
3. The actual first element for [full].
}
CheckEquals(-1, FEmpty.FirstOrDefault(-1), 'Expected proper first for [empty].');
CheckEquals(Elements[0], FOne.FirstOrDefault(Elements[0] - 1), 'Expected proper first for [one].');
LEnumerator := FFull.GetEnumerator();
LEnumerator.MoveNext();
CheckEquals(LEnumerator.Current, FFull.FirstOrDefault(LEnumerator.Current - 1), 'Expected proper first for [full].');
end;
procedure TConformance_ISequence.Test_FirstWhere;
var
LAlwaysFalsePredicate,
LPredicate: TPredicate<NativeInt>;
begin
{ Tests:
1. ECollectionFilteredEmptyException for [empty].
2. ECollectionFilteredEmptyException for [one] but wrong predicate.
3. ECollectionFilteredEmptyException for [full] but wrong predicate.
4. The actual element for [one] with a proper predicate.
5. The actual elemnts for [full] with a proper predicate.
6. EArgumentNilException if the predicate is nil.
}
CheckException(EArgumentNilException,
procedure() begin FEmpty.FirstWhere(nil) end,
'EArgumentNilException not thrown in [empty].FirstWhere()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.FirstWhere(nil) end,
'EArgumentNilException not thrown in [one].FirstWhere()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.FirstWhere(nil) end,
'EArgumentNilException not thrown in [full].FirstWhere()'
);
LAlwaysFalsePredicate := function(Arg: NativeInt): Boolean begin Exit(false); end;
CheckException(ECollectionFilteredEmptyException,
procedure() begin FFull.FirstWhere(LAlwaysFalsePredicate) end,
'ECollectionFilteredEmptyException not thrown in [empty].FirstWhere(false)'
);
CheckException(ECollectionFilteredEmptyException,
procedure() begin FFull.FirstWhere(LAlwaysFalsePredicate) end,
'ECollectionFilteredEmptyException not thrown in [one].FirstWhere(false)'
);
CheckException(ECollectionFilteredEmptyException,
procedure() begin FFull.FirstWhere(LAlwaysFalsePredicate) end,
'ECollectionFilteredEmptyException not thrown in [full].FirstWhere(false)'
);
LPredicate := function(Arg: NativeInt): Boolean begin Exit(Arg = Elements[0]); end;
CheckEquals(Elements[0], FOne.FirstWhere(LPredicate), 'Expected first element for [one]');
CheckEquals(Elements[0], FFull.FirstWhere(LPredicate), 'Expected proper element for [full]');
end;
procedure TConformance_ISequence.Test_FirstWhereNot;
var
LAlwaysTruePredicate,
LPredicate: TPredicate<NativeInt>;
begin
{ Tests:
1. ECollectionFilteredEmptyException for [empty].
2. ECollectionFilteredEmptyException for [one] but wrong predicate.
3. ECollectionFilteredEmptyException for [full] but wrong predicate.
4. The actual element for [one] with a proper predicate.
5. The actual elemnts for [full] with a proper predicate.
6. EArgumentNilException if the predicate is nil.
}
CheckException(EArgumentNilException,
procedure() begin FEmpty.FirstWhereNot(nil) end,
'EArgumentNilException not thrown in [empty].FirstWhereNot()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.FirstWhereNot(nil) end,
'EArgumentNilException not thrown in [one].FirstWhereNot()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.FirstWhereNot(nil) end,
'EArgumentNilException not thrown in [full].FirstWhereNot()'
);
LAlwaysTruePredicate := function(Arg: NativeInt): Boolean begin Exit(true); end;
CheckException(ECollectionFilteredEmptyException,
procedure() begin FFull.FirstWhereNot(LAlwaysTruePredicate) end,
'ECollectionFilteredEmptyException not thrown in [empty].FirstWhereNot(false)'
);
CheckException(ECollectionFilteredEmptyException,
procedure() begin FFull.FirstWhereNot(LAlwaysTruePredicate) end,
'ECollectionFilteredEmptyException not thrown in [one].FirstWhereNot(false)'
);
CheckException(ECollectionFilteredEmptyException,
procedure() begin FFull.FirstWhereNot(LAlwaysTruePredicate) end,
'ECollectionFilteredEmptyException not thrown in [full].FirstWhereNot(false)'
);
LPredicate := function(Arg: NativeInt): Boolean begin Exit(Arg <> Elements[0]); end;
CheckEquals(Elements[0], FOne.FirstWhereNot(LPredicate), 'Expected first element for [one]');
CheckEquals(Elements[0], FFull.FirstWhereNot(LPredicate), 'Expected proper element for [full]');
end;
procedure TConformance_ISequence.Test_FirstWhereNotOrDefault;
var
LAlwaysTruePredicate,
LPredicate: TPredicate<NativeInt>;
begin
{ Tests:
1. ECollectionFilteredEmptyException for [empty].
2. ECollectionFilteredEmptyException for [one] but wrong predicate.
3. ECollectionFilteredEmptyException for [full] but wrong predicate.
4. The actual element for [one] with a proper predicate.
5. The actual elemnts for [full] with a proper predicate.
6. EArgumentNilException if the predicate is nil.
}
CheckException(EArgumentNilException,
procedure() begin FEmpty.FirstWhereNotOrDefault(nil, -1) end,
'EArgumentNilException not thrown in [empty].FirstWhereOrDefault()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.FirstWhereNotOrDefault(nil, -1) end,
'EArgumentNilException not thrown in [one].FirstWhereOrDefault()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.FirstWhereNotOrDefault(nil, -1) end,
'EArgumentNilException not thrown in [full].FirstWhereOrDefault()'
);
LAlwaysTruePredicate := function(Arg: NativeInt): Boolean begin Exit(True); end;
CheckEquals(-1, FEmpty.FirstWhereNotOrDefault(LAlwaysTruePredicate, -1), 'Expected -1 element for [empty]');
CheckEquals(-1, FOne.FirstWhereNotOrDefault(LAlwaysTruePredicate, -1), 'Expected -1 element for [one]');
CheckEquals(-1, FFull.FirstWhereNotOrDefault(LAlwaysTruePredicate, -1), 'Expected -1 element for [full]');
LPredicate := function(Arg: NativeInt): Boolean begin Exit(Arg <> Elements[0]); end;
CheckEquals(Elements[0], FOne.FirstWhereNotOrDefault(LPredicate, Elements[0] - 1), 'Expected first element for [one]');
CheckEquals(Elements[0], FFull.FirstWhereNotOrDefault(LPredicate, Elements[0] - 1), 'Expected proper element for [full]');
end;
procedure TConformance_ISequence.Test_FirstWhereOrDefault;
var
LAlwaysFalsePredicate,
LPredicate: TPredicate<NativeInt>;
begin
{ Tests:
1. ECollectionFilteredEmptyException for [empty].
2. ECollectionFilteredEmptyException for [one] but wrong predicate.
3. ECollectionFilteredEmptyException for [full] but wrong predicate.
4. The actual element for [one] with a proper predicate.
5. The actual elemnts for [full] with a proper predicate.
6. EArgumentNilException if the predicate is nil.
}
CheckException(EArgumentNilException,
procedure() begin FEmpty.FirstWhereOrDefault(nil, -1) end,
'EArgumentNilException not thrown in [empty].FirstWhereOrDefault()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.FirstWhereOrDefault(nil, -1) end,
'EArgumentNilException not thrown in [one].FirstWhereOrDefault()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.FirstWhereOrDefault(nil, -1) end,
'EArgumentNilException not thrown in [full].FirstWhereOrDefault()'
);
LAlwaysFalsePredicate := function(Arg: NativeInt): Boolean begin Exit(false); end;
CheckEquals(-1, FEmpty.FirstWhereOrDefault(LAlwaysFalsePredicate, -1), 'Expected -1 element for [empty]');
CheckEquals(-1, FOne.FirstWhereOrDefault(LAlwaysFalsePredicate, -1), 'Expected -1 element for [one]');
CheckEquals(-1, FFull.FirstWhereOrDefault(LAlwaysFalsePredicate, -1), 'Expected -1 element for [full]');
LPredicate := function(Arg: NativeInt): Boolean begin Exit(Arg = Elements[0]); end;
CheckEquals(Elements[0], FOne.FirstWhereOrDefault(LPredicate, Elements[0] - 1), 'Expected first element for [one]');
CheckEquals(Elements[0], FFull.FirstWhereOrDefault(LPredicate, Elements[0] - 1), 'Expected proper element for [full]');
end;
procedure TConformance_ISequence.Test_Intersect;
var
LHalf: ISequence<NativeInt>;
begin
{ Tests:
1. EArgumentNilException for nil collections.
2. [empty] x [empty] = [empty]
3. [empty] x [one] = [empty]
4. [one] x [empty] = [empty]
5. [one] x [one] = [one]
6. [full] * [one] = [one]
}
CheckException(EArgumentNilException,
procedure() begin FEmpty.Intersect(nil) end,
'EArgumentNilException not thrown in [empty].Union()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.Intersect(nil) end,
'EArgumentNilException not thrown in [one].Union()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.Intersect(nil) end,
'EArgumentNilException not thrown in [full].Union()'
);
LHalf := FFull.Take(FFull.Count div 2);
CheckTrue( FEmpty.Intersect(FEmpty).EqualsTo(FEmpty), 'Expected [empty] x [empty] = [empty]');
CheckTrue( FEmpty.Intersect(FOne) .EqualsTo(FEmpty), 'Expected [empty] x [one] = [empty]');
CheckTrue( FOne .Intersect(FEmpty).EqualsTo(FEmpty), 'Expected [one] x [empty] = [empty]');
CheckTrue( FOne .Intersect(FOne) .EqualsTo(FOne), 'Expected [one] x [one] = [one]');
CheckTrue( FFull .Intersect(FOne) .EqualsTo(FOne), 'Expected [full] x [one] = [one]');
CheckTrue( FFull .Intersect(LHalf) .EqualsTo(LHalf), 'Expected [full] x [full/2] = [full/2]');
end;
procedure TConformance_ISequence.Test_Last;
var
LEnumerator: IEnumerator<NativeInt>;
begin
{ Tests:
1. ECollectionEmptyException for [empty].
2. The actual element for [one].
3. The actual first element for [full].
}
CheckException(ECollectionEmptyException,
procedure() begin FEmpty.Last() end,
'ECollectionEmptyException not thrown in [empty].Last()'
);
CheckEquals(Elements[0], FOne.Last(), 'Expected proper last for [one].');
LEnumerator := FFull.GetEnumerator();
while LEnumerator.MoveNext() do;
CheckEquals(LEnumerator.Current, FFull.Last(), 'Expected proper last for [full].');
end;
procedure TConformance_ISequence.Test_LastOrDefault;
var
LEnumerator: IEnumerator<NativeInt>;
begin
{ Tests:
1. The default for [empty]
2. The actual element for [one].
3. The actual first element for [full].
}
CheckEquals(-1, FEmpty.LastOrDefault(-1), 'Expected proper last for [empty].');
CheckEquals(Elements[0], FOne.LastOrDefault(Elements[0] - 1), 'Expected proper last for [one].');
LEnumerator := FFull.GetEnumerator();
while LEnumerator.MoveNext() do;
CheckEquals(LEnumerator.Current, FFull.LastOrDefault(LEnumerator.Current - 1), 'Expected proper last for [full].');
end;
procedure TConformance_ISequence.Test_Max;
var
LMax, LIndex: NativeInt;
begin
CheckException(ECollectionEmptyException,
procedure() begin FEmpty.Max() end,
'ECollectionEmptyException not thrown in [empty].Max()'
);
CheckEquals(Elements[0], FOne.Max(), 'Expected proper max for [one]');
LMax := Elements[0];
for LIndex := 1 to Length(Elements) - 1 do
if LMax < Elements[LIndex] then
LMax := Elements[LIndex];
CheckEquals(LMax, FFull.Max(), 'Expected proper max for [full]');
if Ordering = oAscending then
begin
CheckEquals(FFull.Max(), FFull.Last(), 'Expected Max to be equal to Last in [full]');
CheckEquals(FFull.Max(), FFull.ElementAt(FFull.Count - 1), 'Expected Max to be equal to [L-1] in [full]');
end;
if Ordering = oDescending then
begin
CheckEquals(FFull.Max(), FFull.First(), 'Expected Max to be equal to First in [full]');
CheckEquals(FFull.Max(), FFull.ElementAt(0), 'Expected Max to be equal to [0] in [full]');
end;
end;
procedure TConformance_ISequence.Test_Min;
var
LMin, LIndex: NativeInt;
begin
CheckException(ECollectionEmptyException,
procedure() begin FEmpty.Min() end,
'ECollectionEmptyException not thrown in [empty].Min()'
);
CheckEquals(Elements[0], FOne.Min(), 'Expected proper min for [one]');
LMin := Elements[0];
for LIndex := 1 to Length(Elements) - 1 do
if LMin > Elements[LIndex] then
LMin := Elements[LIndex];
CheckEquals(LMin, FFull.Min(), 'Expected proper min for [full]');
if Ordering = oAscending then
begin
CheckEquals(FFull.Min(), FFull.First(), 'Expected Min to be equal to First in [full]');
CheckEquals(FFull.Min(), FFull.ElementAt(0), 'Expected Min to be equal to [0] in [full]');
end;
if Ordering = oDescending then
begin
CheckEquals(FFull.Min(), FFull.Last(), 'Expected Min to be equal to Last in [full]');
CheckEquals(FFull.Min(), FFull.ElementAt(FFull.Count - 1), 'Expected Min to be equal to [L-1] in [full]');
end;
end;
procedure TConformance_ISequence.Test_Ordered_1;
var
LComparer: TComparison<NativeInt>;
LList: IList<NativeInt>;
LOrdered: ISequence<NativeInt>;
LValue, LPrev: NativeInt;
LFirst: Boolean;
begin
LComparer := nil;
CheckException(EArgumentNilException,
procedure() begin FEmpty.Ordered(LComparer) end,
'EArgumentNilException not thrown in [empty].Ordered()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.Ordered(LComparer) end,
'EArgumentNilException not thrown in [one].Ordered()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.Ordered(LComparer) end,
'EArgumentNilException not thrown in [full].Ordered()'
);
{ Ascending }
LComparer := function(const L, R: NativeInt): Integer
begin
if L > R then Exit(1);
if L < R then Exit(-1);
Exit(0);
end;
LOrdered := FEmpty.Ordered(LComparer);
CheckTrue(LOrdered.Empty, 'Expected empty asc ordered for [empty]');
LOrdered := FOne.Ordered(LComparer);
CheckEquals(1, LOrdered.Count, 'Expected 1-length asc ordered for [one]');
CheckEquals(LOrdered.Single, FOne.Single, 'Expected correct asc ordered for [one]');
LOrdered := FFull.Ordered(LComparer);
LList := FFull.ToList();
CheckEquals(FFull.Count, LOrdered.Count, 'Expected N-length asc ordered for [full]');
LFirst := True;
LPrev := 0;
for LValue in LOrdered do
begin
CheckTrue(LList.Contains(LValue), 'Expected the asc value to be in [full]');
LList.Remove(LValue);
if LFirst then
LFirst := False
else begin
CheckTrue(LPrev <= LValue, 'Expected Vi >= Vi-1 in asc ordering');
end;
LPrev := LValue;
end;
CheckTrue(LList.Empty, 'Expected all asc values to be in [full]');
{ Descending }
LComparer := function(const L, R: NativeInt): Integer
begin
if L < R then Exit(1);
if L > R then Exit(-1);
Exit(0);
end;
LOrdered := FEmpty.Ordered(LComparer);
CheckTrue(LOrdered.Empty, 'Expected empty desc ordered for [empty]');
LOrdered := FOne.Ordered(LComparer);
CheckEquals(1, LOrdered.Count, 'Expected 1-length desc ordered for [one]');
CheckEquals(LOrdered.Single, FOne.Single, 'Expected correct desc ordered for [one]');
LOrdered := FFull.Ordered(LComparer);
LList := FFull.ToList();
CheckEquals(FFull.Count, LOrdered.Count, 'Expected N-length desc ordered for [full]');
LFirst := True;
LPrev := 0;
for LValue in LOrdered do
begin
CheckTrue(LList.Contains(LValue), 'Expected the desc value to be in [full]');
LList.Remove(LValue);
if LFirst then
LFirst := False
else begin
CheckTrue(LPrev >= LValue, 'Expected Vi <= Vi-1 in desc ordering');
end;
LPrev := LValue;
end;
CheckTrue(LList.Empty, 'Expected all desc values to be in [full]');
end;
procedure TConformance_ISequence.Test_Ordered_2;
var
LList: IList<NativeInt>;
LOrdered: ISequence<NativeInt>;
LValue, LPrev: NativeInt;
LFirst: Boolean;
begin
{ Ascending }
LOrdered := FEmpty.Ordered(True);
CheckTrue(LOrdered.Empty, 'Expected empty asc ordered for [empty]');
LOrdered := FOne.Ordered(True);
CheckEquals(1, LOrdered.Count, 'Expected 1-length asc ordered for [one]');
CheckEquals(LOrdered.Single, FOne.Single, 'Expected correct asc ordered for [one]');
LOrdered := FFull.Ordered(True);
LList := FFull.ToList();
CheckEquals(FFull.Count, LOrdered.Count, 'Expected N-length asc ordered for [full]');
LFirst := True;
LPrev := 0;
for LValue in LOrdered do
begin
CheckTrue(LList.Contains(LValue), 'Expected the asc value to be in [full]');
LList.Remove(LValue);
if LFirst then
LFirst := False
else begin
CheckTrue(LPrev <= LValue, 'Expected Vi >= Vi-1 in asc ordering');
end;
LPrev := LValue;
end;
CheckTrue(LList.Empty, 'Expected all asc values to be in [full]');
{ Descending }
LOrdered := FEmpty.Ordered(False);
CheckTrue(LOrdered.Empty, 'Expected empty desc ordered for [empty]');
LOrdered := FOne.Ordered(False);
CheckEquals(1, LOrdered.Count, 'Expected 1-length desc ordered for [one]');
CheckEquals(LOrdered.Single, FOne.Single, 'Expected correct desc ordered for [one]');
LOrdered := FFull.Ordered(False);
LList := FFull.ToList();
CheckEquals(FFull.Count, LOrdered.Count, 'Expected N-length desc ordered for [full]');
LFirst := True;
LPrev := 0;
for LValue in LOrdered do
begin
CheckTrue(LList.Contains(LValue), 'Expected the desc value to be in [full]');
LList.Remove(LValue);
if LFirst then
LFirst := False
else begin
CheckTrue(LPrev >= LValue, 'Expected Vi <= Vi-1 in desc ordering');
end;
LPrev := LValue;
end;
CheckTrue(LList.Empty, 'Expected all desc values to be in [full]');
end;
procedure TConformance_ISequence.Test_Range;
var
LRange: ISequence<NativeInt>;
begin
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.Range(-1, 0) end,
'EArgumentOutOfRangeException not thrown in [empty].Range(-1, 0)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.Range(1, 0) end,
'EArgumentOutOfRangeException not thrown in [empty].Range(1, 0)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.Range(-1, 0) end,
'EArgumentOutOfRangeException not thrown in [one].Range(-1, 0)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.Range(1, 0) end,
'EArgumentOutOfRangeException not thrown in [one].Range(1, 0)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.Range(-1, 0) end,
'EArgumentOutOfRangeException not thrown in [full].Range(-1, 0)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.Range(1, 0) end,
'EArgumentOutOfRangeException not thrown in [full].Range(1, 0)'
);
LRange := FEmpty.Range(0, FFull.Count);
CheckTrue(LRange.Empty, 'Expected an empty range for [empty]');
LRange := FOne.Range(0, FFull.Count);
CheckEquals(FOne.Single, LRange.Single, 'Expected an 1-L range for [one]');
LRange := FOne.Range(0, 0);
CheckFalse(LRange.Empty, 'Expected a full range for [one]');
CheckEquals(FOne.Single, LRange.Single, 'Expected a full range for [one]');
LRange := FFull.Range(0, 0);
CheckFalse(LRange.Empty, 'Expected a 1 range for [full]');
CheckEquals(FFull.First, LRange.Single, 'Expected a 1 range for [full]');
LRange := FFull.Range(0, FFull.Count - 1);
CheckTrue(LRange.EqualsTo(FFull), 'Expected a N range for [full]');
end;
procedure TConformance_ISequence.Test_Reversed;
var
LReversed: ISequence<NativeInt>;
LArray: TArray<NativeInt>;
LIndex, LValue: NativeInt;
begin
LReversed := FEmpty.Reversed();
CheckTrue(LReversed.Empty, 'Expected reversed of [empty] to be empty');
LReversed := FOne.Reversed();
CheckEquals(1, LReversed.Count, 'Expected reversed of [one] to be 1-length.');
CheckEquals(FOne.Single, LReversed.Single, 'Expected reversed of [one] to have the same element.');
LReversed := FFull.Reversed();
CheckEquals(FFull.Count, LReversed.Count, 'Expected reversed of [full] to be the same length.');
LArray := LReversed.ToArray();
LIndex := Length(LArray) - 1;
for LValue in FFull do
begin
CheckEquals(LValue, LArray[LIndex], 'Expected proper reversing in [full].');
Dec(LIndex);
end;
end;
procedure TConformance_ISequence.Test_Skip;
var
LRange, LCut: ISequence<NativeInt>;
begin
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.Skip(-1) end,
'EArgumentOutOfRangeException not thrown in [empty].Skip(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.Skip(-1) end,
'EArgumentOutOfRangeException not thrown in [one].Skip(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.Skip(-1) end,
'EArgumentOutOfRangeException not thrown in [full].Skip(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.Skip(0) end,
'EArgumentOutOfRangeException not thrown in [empty].Skip(0)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.Skip(0) end,
'EArgumentOutOfRangeException not thrown in [one].Skip(0)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.Skip(0) end,
'EArgumentOutOfRangeException not thrown in [full].Skip(0)'
);
LRange := FEmpty.Skip(1); CheckTrue(LRange.Empty, 'Expected an empty skip for [empty]');
LRange := FOne.Skip(1); CheckTrue(LRange.Empty, 'Expected an empty skip for [empty]');
LRange := FFull.Skip(FFull.Count); CheckTrue(LRange.Empty, 'Expected an empty skip for [full]');
LRange := FFull.Skip(1);
LCut := FFull.Range(1, FFull.Count - 1);
CheckEquals(LCut.Count, LRange.Count, 'Expected proper count for [full]');
CheckTrue(LRange.EqualsTo(LCut), 'Expected an N skip for [full]');
end;
procedure TConformance_ISequence.Test_SkipWhile;
var
LPredicate: TPredicate<NativeInt>;
LSkip: ISequence<NativeInt>;
LFirst, LLast: NativeInt;
begin
CheckException(EArgumentNilException,
procedure() begin FEmpty.SkipWhile(nil) end,
'EArgumentNilException not thrown in [empty].SkipWhile()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.SkipWhile(nil) end,
'EArgumentNilException not thrown in [one].SkipWhile()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.SkipWhile(nil) end,
'EArgumentNilException not thrown in [full].SkipWhile()'
);
LPredicate := function(V: NativeInt): Boolean begin Exit(False); end;
LSkip := FEmpty.SkipWhile(LPredicate);
CheckTrue(LSkip.Empty, 'Expected empty skip for [empty]');
LSkip := FOne.SkipWhile(LPredicate);
CheckFalse(LSkip.Empty, 'Expected 1-L skip for [one]');
CheckEquals(FOne.Single(), LSkip.Single(), 'Expected same element skip for [one]');
LSkip := FFull.SkipWhile(LPredicate);
CheckTrue(FFull.EqualsTo(LSkip), 'Expected no skip for [full]');
LPredicate := function(V: NativeInt): Boolean begin Exit(True); end;
LSkip := FFull.SkipWhile(LPredicate);
CheckTrue(LSkip.Empty, 'Expected empty skip for [full]');
LFirst := FFull.First;
LLast := FFull.Last;
LPredicate := function(V: NativeInt): Boolean begin Exit((V = LFirst) or (V = LLast)); end;
LSkip := FFull.SkipWhile(LPredicate);
CheckTrue(LSkip.EqualsTo(FFull.Skip(1)), 'Expected skip - 1 for [full]');
end;
procedure TConformance_ISequence.Test_Take;
var
LRange: ISequence<NativeInt>;
begin
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.Take(-1) end,
'EArgumentOutOfRangeException not thrown in [empty].Take(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.Take(-1) end,
'EArgumentOutOfRangeException not thrown in [one].Take(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.Take(-1) end,
'EArgumentOutOfRangeException not thrown in [full].Take(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.Take(0) end,
'EArgumentOutOfRangeException not thrown in [empty].Take(0)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.Take(0) end,
'EArgumentOutOfRangeException not thrown in [one].Take(0)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.Take(0) end,
'EArgumentOutOfRangeException not thrown in [full].Take(0)'
);
LRange := FEmpty.Take(1); CheckTrue(LRange.Empty, 'Expected an empty take for [empty]');
LRange := FOne.Take(1); CheckEquals(FOne.Single, LRange.Single, 'Expected an 1-L take for [one]');
LRange := FOne.Take(2); CheckEquals(FOne.Single, LRange.Single, 'Expected an 1-L take for [one]');
LRange := FFull.Take(1); CheckEquals(FFull.First, LRange.Single, 'Expected an 1-L take for [full]');
LRange := FFull.Take(FFull.Count); CheckTrue(LRange.EqualsTo(FFull), 'Expected a N take for [full]');
end;
procedure TConformance_ISequence.Test_TakeWhile;
var
LPredicate: TPredicate<NativeInt>;
LTake: ISequence<NativeInt>;
LFirst, LLast: NativeInt;
begin
CheckException(EArgumentNilException,
procedure() begin FEmpty.TakeWhile(nil) end,
'EArgumentNilException not thrown in [empty].TakeWhile()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.TakeWhile(nil) end,
'EArgumentNilException not thrown in [one].TakeWhile()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.TakeWhile(nil) end,
'EArgumentNilException not thrown in [full].TakeWhile()'
);
LPredicate := function(V: NativeInt): Boolean begin Exit(True); end;
LTake := FEmpty.TakeWhile(LPredicate);
CheckTrue(LTake.Empty, 'Expected empty take for [empty]');
LTake := FOne.TakeWhile(LPredicate);
CheckFalse(LTake.Empty, 'Expected 1-L take for [one]');
CheckEquals(FOne.Single(), LTake.Single(), 'Expected same element take for [one]');
LTake := FFull.TakeWhile(LPredicate);
CheckTrue(FFull.EqualsTo(LTake), 'Expected no take for [full]');
LPredicate := function(V: NativeInt): Boolean begin Exit(False); end;
LTake := FFull.TakeWhile(LPredicate);
CheckTrue(LTake.Empty, 'Expected empty take for [full]');
LFirst := FFull.First;
LLast := FFull.Last;
LPredicate := function(V: NativeInt): Boolean begin Exit((V = LFirst) or (V = LLast)); end;
LTake := FFull.TakeWhile(LPredicate);
CheckTrue(LTake.EqualsTo(FFull.Take(1)), 'Expected take - 1 for [full]');
end;
procedure TConformance_ISequence.Test_ToList;
var
LList: IList<NativeInt>;
begin
LList := FEmpty.ToList();
CheckTrue(Pointer(LList) <> Pointer(FEmpty.ToList()), 'Expected new list for [empty]');
CheckTrue(LList.Empty, 'Expected empty list for [empty]');
LList := FOne.ToList();
CheckTrue(Pointer(LList) <> Pointer(FOne.ToList()), 'Expected new list for [one]');
CheckEquals(1, LList.GetCount(), 'Expected one-element list for [one]');
CheckEquals(Elements[0], LList.GetItem(0), 'Expected proper element copy for [one]');
LList := FFull.ToList();
CheckTrue(Pointer(LList) <> Pointer(FFull.ToList()), 'Expected new list for [full]');
CheckEquals(Length(Elements), LList.GetCount(), 'Expected full-element list for [full]');
CheckTrue(LList.EqualsTo(FFull), 'Expected proper element copy for [full]');
end;
procedure TConformance_ISequence.Test_ToSet;
var
LSet: ISet<NativeInt>;
LValue: NativeInt;
begin
LSet := FEmpty.ToSet();
CheckTrue(LSet.Empty, 'Expected empty set for [empty]');
LSet := FOne.ToSet();
CheckEquals(1, LSet.Count, 'Expected 1-L set for [one]');
CheckEquals(LSet.Single, FOne.Single, 'Expected same set element for [one]');
LSet := FFull.ToSet();
CheckTrue(LSet.Count <= FFull.Count, 'Expected the set to have less or equal elements as [full]');
for LValue in FFull do
CheckTrue(LSet.Contains(LValue), 'Expected set to contain all elements in [full]');
end;
procedure TConformance_ISequence.Test_Union;
begin
CheckException(EArgumentNilException,
procedure() begin FEmpty.Union(nil) end,
'EArgumentNilException not thrown in [empty].Union()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.Union(nil) end,
'EArgumentNilException not thrown in [one].Union()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.Union(nil) end,
'EArgumentNilException not thrown in [full].Union()'
);
CheckTrue( FEmpty.Union(FEmpty).EqualsTo(FEmpty), 'Expected [empty] * [empty] = [empty]');
CheckTrue( FEmpty.Union(FOne).EqualsTo(FOne), 'Expected [empty] * [one] = [one]');
CheckTrue( FOne.Union(FEmpty).EqualsTo(FOne), 'Expected [one] * [empty] = [one]');
CheckTrue( FFull.Union(FFull.Take(FFull.Count div 2)).EqualsTo(FFull), 'Expected [full] * [full/2] = [full]');
CheckTrue( FFull.Union(FEmpty).EqualsTo(FFull), 'Expected [full] * [empty] = [full]');
CheckTrue( FFull.Union(FOne).EqualsTo(FFull), 'Expected [full] * [one] = [full]');
end;
procedure TConformance_ISequence.Test_Where;
var
LAlwaysFalsePredicate,
LPredicate: TPredicate<NativeInt>;
LSequence: ISequence<NativeInt>;
LF, LL: NativeInt;
begin
CheckException(EArgumentNilException,
procedure() begin FEmpty.Where(nil) end,
'EArgumentNilException not thrown in [empty].Where()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.Where(nil) end,
'EArgumentNilException not thrown in [one].Where()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.Where(nil) end,
'EArgumentNilException not thrown in [full].Where()'
);
LAlwaysFalsePredicate := function(Arg: NativeInt): Boolean begin Exit(False); end;
LSequence := FEmpty.Where(LAlwaysFalsePredicate);
CheckEquals(True, LSequence.Empty, 'Expected empty where collection for [empty]');
LSequence := FOne.Where(LAlwaysFalsePredicate);
CheckEquals(True, LSequence.Empty, 'Expected empty where collection for [one]');
LSequence := FFull.Where(LAlwaysFalsePredicate);
CheckEquals(True, LSequence.Empty, 'Expected empty where collection for [full]');
LF := FOne.First; LL := FOne.Last;
LPredicate := function(Arg: NativeInt): Boolean begin Exit((Arg = LF) or (Arg = LL)); end;
LSequence := FOne.Where(LPredicate);
CheckEquals(1, LSequence.Count, 'Expected 1-length where collection for [one]');
CheckEquals(LF, LSequence.First, 'Expected proper selected element for [one]');
LF := FFull.First; LL := FFull.Last;
LPredicate := function(Arg: NativeInt): Boolean begin Exit((Arg = LF) or (Arg = LL)); end;
LSequence := FFull.Where(LPredicate);
CheckEquals(GetCountOf(LPredicate), LSequence.Count, 'Expected 2-length where collection for [one]');
CheckEquals(LF, LSequence.First, 'Expected proper 1 selected element for [one]');
CheckEquals(LL, LSequence.Last, 'Expected proper 2 selected element for [one]');
end;
procedure TConformance_ISequence.Test_WhereNot;
var
LAlwaysTruePredicate,
LPredicate: TPredicate<NativeInt>;
LSequence: ISequence<NativeInt>;
LF, LL: NativeInt;
begin
CheckException(EArgumentNilException,
procedure() begin FEmpty.WhereNot(nil) end,
'EArgumentNilException not thrown in [empty].WhereNot()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.WhereNot(nil) end,
'EArgumentNilException not thrown in [one].WhereNot()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.WhereNot(nil) end,
'EArgumentNilException not thrown in [full].WhereNot()'
);
LAlwaysTruePredicate := function(Arg: NativeInt): Boolean begin Exit(True); end;
LSequence := FEmpty.WhereNot(LAlwaysTruePredicate);
CheckEquals(True, LSequence.Empty, 'Expected empty where collection for [empty]');
LSequence := FOne.WhereNot(LAlwaysTruePredicate);
CheckEquals(True, LSequence.Empty, 'Expected empty where collection for [one]');
LSequence := FFull.WhereNot(LAlwaysTruePredicate);
CheckEquals(True, LSequence.Empty, 'Expected empty where collection for [full]');
LF := FOne.First; LL := FOne.Last;
LPredicate := function(Arg: NativeInt): Boolean begin Exit((Arg <> LF) and (Arg <> LL)); end;
LSequence := FOne.WhereNot(LPredicate);
CheckEquals(1, LSequence.Count, 'Expected 1-length where collection for [one]');
CheckEquals(LF, LSequence.First, 'Expected proper selected element for [one]');
LF := FFull.First; LL := FFull.Last;
LPredicate := function(Arg: NativeInt): Boolean begin Exit((Arg <> LF) and (Arg <> LL)); end;
LSequence := FFull.WhereNot(LPredicate);
CheckEquals(FFull.Count - GetCountOf(LPredicate), LSequence.Count, 'Expected 2-length where collection for [one]');
CheckEquals(LF, LSequence.First, 'Expected proper 1 selected element for [one]');
CheckEquals(LL, LSequence.Last, 'Expected proper 2 selected element for [one]');
end;
{ TConformance_IGrouping }
procedure TConformance_IGrouping.SetUp_ISequence(out AEmpty, AOne, AFull: ISequence<NativeInt>;
out AElements: TElements; out AOrdering: TOrdering);
begin
SetUp_IGrouping(FEmpty, FOne, FFull, FKey, AElements, AOrdering);
AEmpty := FEmpty;
AOne := FOne;
AFull := FFull;
end;
procedure TConformance_IGrouping.Test_GetKey;
begin
// TODO: Implement this test for IGrouping.GetKey
Fail('Not implemented!');
end;
{ TConformance_ICollection }
procedure TConformance_ICollection.EnsureOrdering(const ACollection: ICollection<NativeInt>);
var
LFirst: Boolean;
LPrev, LCurrent: NativeInt;
begin
LFirst := True;
LPrev := 0;
for LCurrent in ACollection do
begin
if LFirst then
LFirst := False
else begin
if Ordering = oAscending then
CheckTrue(LPrev <= LCurrent, 'Expected Vi >= Vi-1 always.')
else if Ordering = oDescending then
CheckTrue(LPrev >= LCurrent, 'Expected Vi <= Vi-1 always.');
end;
LPrev := LCurrent;
end;
end;
procedure TConformance_ICollection.RemoveNotification(const AValue: NativeInt);
begin
if Assigned(FRemovedList) then
FRemovedList.Add(AValue);
end;
procedure TConformance_ICollection.SetUp;
begin
inherited;
FRemovedList := Generics.Collections.TList<NativeInt>.Create();
end;
procedure TConformance_ICollection.SetUp_ISequence(out AEmpty, AOne, AFull: ISequence<NativeInt>;
out AElements: TElements; out AOrdering: TOrdering);
begin
SetUp_ICollection(FEmpty, FOne, FFull, AElements, AOrdering);
AEmpty := FEmpty;
AOne := FOne;
AFull := FFull;
end;
procedure TConformance_ICollection.TearDown;
begin
FreeAndNil(FRemovedList);
inherited;
end;
procedure TConformance_ICollection.Test_Add;
var
LLastVersion: NativeInt;
LNew, I: NativeInt;
begin
LLastVersion := FEmpty.Version;
FEmpty.Add(FOne.Single);
CheckTrue(FEmpty.Contains(FOne.Single), 'Expected [empty] to contain [one]');
CheckNotEquals(LLastVersion, FEmpty.Version, 'Expected the version to differ in [empty]');
FEmpty.Add(FOne.Single);
CheckTrue(FEmpty.Contains(FOne.Single), 'Expected [empty] to contain [one] again');
for I := 0 to FFull.Count - 1 do
begin
LNew := GenerateUniqueRandomElement(Elements);
LLastVersion := FFull.Version;
FFull.Add(LNew);
CheckNotEquals(LLastVersion, FFull.Version, 'Expected the version to differ in [full]');
CheckTrue(FFull.Contains(LNew), 'Expected [full] to contain "new" value.');
end;
EnsureOrdering(FFull);
CheckEquals(0, FRemovedList.Count, 'Did not expect any element to be removed!');
end;
procedure TConformance_ICollection.Test_AddAll;
var
LLastVersion: NativeInt;
LValue, I: NativeInt;
begin
CheckException(EArgumentNilException,
procedure() begin FEmpty.AddAll(nil) end,
'EArgumentNilException not thrown in [empty].AddAll()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.AddAll(nil) end,
'EArgumentNilException not thrown in [one].AddAll()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.AddAll(nil) end,
'EArgumentNilException not thrown in [full].AddAll()'
);
LLastVersion := FEmpty.Version;
FEmpty.AddAll(FOne);
CheckTrue(FEmpty.Contains(FOne.Single), 'Expected [empty] to contain [one]');
CheckNotEquals(LLastVersion, FEmpty.Version, 'Expected the version to differ in [empty]');
FEmpty.Add(FOne.Single);
CheckTrue(FEmpty.Contains(FOne.Single), 'Expected [empty] to contain [one] again');
FEmpty.Clear();
FRemovedList.Clear();
for I := 0 to FFull.Count - 1 do
FEmpty.Add(GenerateUniqueRandomElement(Elements));
LLastVersion := FFull.Version;
FFull.AddAll(FEmpty);
CheckNotEquals(LLastVersion, FFull.Version, 'Expected the version to differ in [full]');
for LValue in FEmpty do
CheckTrue(FFull.Contains(LValue), 'Expected [full] to contain "new" value.');
EnsureOrdering(FFull);
CheckEquals(0, FRemovedList.Count, 'Did not expect any element to be removed!');
end;
procedure TConformance_ICollection.Test_Clear;
var
LList: IList<NativeInt>;
LValue: NativeInt;
LLastVersion: NativeInt;
begin
LLastVersion := FEmpty.Version;
FEmpty.Clear();
CheckEquals(0, FRemovedList.Count, 'Nothing should have been removed in [empty]');
CheckEquals(LLastVersion, FEmpty.Version, 'Version should stay the same in [empty]');
LLastVersion := FOne.Version;
FOne.Clear();
CheckEquals(1, FRemovedList.Count, '1-L should have been removed in [one]');
CheckNotEquals(LLastVersion, FEmpty.Version, 'Version should not stay the same in [empty]');
FRemovedList.Clear;
LList := FFull.ToList();
LLastVersion := FFull.Version;
FFull.Clear();
CheckEquals(LList.Count, FRemovedList.Count, 'N-L should have been removed in [full]');
CheckNotEquals(LLastVersion, FFull.Version, 'Version should not stay the same in [full]');
for LValue in FRemovedList do
begin
CheckTrue(LList.Contains(LValue), 'Expected a real removed element in [full]');
LList.Remove(LValue);
end;
CheckTrue(LList.Empty, 'Expected all elements to be removed in [full]');
end;
procedure TConformance_ICollection.Test_Contains;
var
LNew, LValue: NativeInt;
begin
CheckFalse(FEmpty.Contains(FOne.Single), 'Did not expect [empty] to contain anything');
CheckTrue(FOne.Contains(FOne.Single), 'Expected [one] to contain itself');
LNew := GenerateUniqueRandomElement(Elements);
CheckFalse(FOne.Contains(LNew), 'Did not expect [one] to contain new');
for LValue in FFull do
CheckTrue(FFull.Contains(LValue), 'Expected [full] to contain its elements');
CheckEquals(0, FRemovedList.Count, 'Expected the number of removed elements to not grow in [full]');
end;
procedure TConformance_ICollection.Test_ContainsAll;
begin
CheckException(EArgumentNilException,
procedure() begin FEmpty.ContainsAll(nil) end,
'EArgumentNilException not thrown in [empty].ContainsAll()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.ContainsAll(nil) end,
'EArgumentNilException not thrown in [one].ContainsAll()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.ContainsAll(nil) end,
'EArgumentNilException not thrown in [full].ContainsAll()'
);
CheckFalse(FEmpty.ContainsAll(FOne), 'Did not expect [empty] to contain anything');
CheckTrue(FOne.ContainsAll(FOne), 'Expected [one] to contain itself');
CheckTrue(FOne.ContainsAll(FEmpty), 'Expected [one] to contain [empty]');
CheckFalse(FOne.ContainsAll(FFull), 'Did not expect [one] to contain [full]');
CheckTrue(FFull.ContainsAll(FFull), 'Expected [full] to contain [full]');
CheckEquals(0, FRemovedList.Count, 'Expected the number of removed elements to not grow in [full]');
end;
procedure TConformance_ICollection.Test_Remove;
var
LLastVersion: NativeInt;
LNew, LValue: NativeInt;
LList: IList<NativeInt>;
begin
LLastVersion := FEmpty.Version;
FEmpty.Remove(FOne.Single);
CheckEquals(LLastVersion, FEmpty.Version, 'Expected the version to be same in [empty]');
LLastVersion := FFull.Version;
LNew := GenerateUniqueRandomElement(Elements);
FFull.Remove(LNew);
CheckEquals(LLastVersion, FFull.Version, 'Expected the version to be same in [full]');
LList := FFull.ToList();
for LValue in LList do
begin
LLastVersion := FEmpty.Version;
FFull.Remove(LValue);
CheckNotEquals(LLastVersion, FFull.Version, 'Expected the version to be different in [full]');
CheckEquals(0, FRemovedList.Count, 'Expected the number of removed elements to not grow in [full]');
EnsureOrdering(FFull);
end;
CheckTrue(FFull.Empty, 'Expected all elements to be removed in [full]');
end;
procedure TConformance_ICollection.Test_RemoveAll;
var
LLastVersion: NativeInt;
LFirst: NativeInt;
begin
CheckException(EArgumentNilException,
procedure() begin FEmpty.RemoveAll(nil) end,
'EArgumentNilException not thrown in [empty].RemoveAll()'
);
CheckException(EArgumentNilException,
procedure() begin FOne.RemoveAll(nil) end,
'EArgumentNilException not thrown in [one].RemoveAll()'
);
CheckException(EArgumentNilException,
procedure() begin FFull.RemoveAll(nil) end,
'EArgumentNilException not thrown in [full].RemoveAll()'
);
LLastVersion := FEmpty.Version;
FEmpty.RemoveAll(FOne);
CheckEquals(LLastVersion, FEmpty.Version, 'Expected the version to be same in [empty]');
LLastVersion := FFull.Version;
FEmpty.Add(GenerateUniqueRandomElement(Elements));
FFull.RemoveAll(FEmpty);
CheckEquals(LLastVersion, FFull.Version, 'Expected the version to be same in [full]');
LLastVersion := FEmpty.Version;
LFirst := FFull.First;
FFull.RemoveAll(FFull.Skip(1).ToList());
CheckNotEquals(LLastVersion, FFull.Version, 'Expected the version to be different in [full]');
CheckEquals(1, FFull.Count, 'Expected all elements-1 to be removed in [full]');
CheckEquals(LFirst, FFull.Single, 'Expected same first element in [full]');
CheckEquals(0, FRemovedList.Count, 'Expected the number of removed elements to not grow in [full]');
end;
{ TConformance_IStack }
procedure TConformance_IStack.SetUp_ICollection(out AEmpty, AOne, AFull: ICollection<NativeInt>;
out AElements: TElements; out AOrdering: TOrdering);
begin
SetUp_IStack(FEmpty, FOne, FFull, AElements, AOrdering);
AEmpty := FEmpty;
AOne := FOne;
AFull := FFull;
end;
procedure TConformance_IStack.Test_Peek;
var
LLastVersion: NativeInt;
LValue: NativeInt;
LList: IList<NativeInt>;
LPop: NativeInt;
begin
CheckException(ECollectionEmptyException,
procedure() begin FEmpty.Peek() end,
'ECollectionEmptyException not thrown in [empty].Peek()'
);
LLastVersion := FOne.Version;
LValue := FOne.Single;
LPop := FOne.Peek();
CheckEquals(LLastVersion, FOne.Version, 'Expected the version to be same in [one]');
CheckEquals(LValue, LPop, 'Expected the version to be same in [one]');
CheckEquals(0, RemovedList.Count, 'Expected the number of removed elements to not grow in [one]');
LList := FFull.ToList();
while not FFull.Empty do
begin
LLastVersion := FFull.Version;
LPop := FFull.Peek();
CheckEquals(LLastVersion, FFull.Version, 'Did not expected the version to be different in [full]');
CheckEquals(0, RemovedList.Count, 'Expected the number of removed elements to not grow in [full]');
CheckTrue(LList.Contains(LPop), 'Expected all elements to be peeked in [full]');
LList.Remove(LPop);
FFull.Pop();
RemovedList.Clear;
end;
CheckTrue(LList.Empty, 'Expected all elements to be peeked in [full]');
end;
procedure TConformance_IStack.Test_Pop;
var
LLastVersion: NativeInt;
LValue: NativeInt;
LList: IList<NativeInt>;
LPop: NativeInt;
begin
CheckException(ECollectionEmptyException,
procedure() begin FEmpty.Pop() end,
'ECollectionEmptyException not thrown in [empty].Pop()'
);
LLastVersion := FOne.Version;
LValue := FOne.Single;
LPop := FOne.Pop();
CheckNotEquals(LLastVersion, FOne.Version, 'Did not expect the version to be same in [one]');
CheckEquals(LValue, LPop, 'Expected the version to be same in [one]');
CheckEquals(0, RemovedList.Count, 'Expected the number of removed elements to not grow in [one]');
LList := FFull.ToList();
while not FFull.Empty do
begin
LLastVersion := FFull.Version;
LPop := FFull.Pop();
CheckNotEquals(LLastVersion, FFull.Version, 'Expected the version to be different in [full]');
CheckEquals(0, RemovedList.Count, 'Expected the number of removed elements to not grow in [full]');
CheckTrue(LList.Contains(LPop), 'Expected all elements to be poped in [full]');
LList.Remove(LPop);
end;
CheckTrue(LList.Empty, 'Expected all elements to be poped in [full]');
end;
procedure TConformance_IStack.Test_Push;
var
LLastVersion: NativeInt;
LNew, I: NativeInt;
begin
LLastVersion := FEmpty.Version;
FEmpty.Push(FOne.Single);
CheckTrue(FEmpty.Contains(FOne.Single), 'Expected [empty] to contain [one]');
CheckNotEquals(LLastVersion, FEmpty.Version, 'Expected the version to differ in [empty]');
FEmpty.Push(FOne.Single);
CheckTrue(FEmpty.Contains(FOne.Single), 'Expected [empty] to contain [one] again');
for I := 0 to FFull.Count - 1 do
begin
LNew := GenerateUniqueRandomElement(Elements);
LLastVersion := FFull.Version;
FFull.Push(LNew);
CheckNotEquals(LLastVersion, FFull.Version, 'Expected the version to differ in [full]');
CheckTrue(FFull.Contains(LNew), 'Expected [full] to contain "new" value.');
end;
CheckEquals(0, RemovedList.Count, 'Did not expect any element to be removed!');
end;
{ TConformance_IQueue }
procedure TConformance_IQueue.SetUp_ICollection(out AEmpty, AOne, AFull: ICollection<NativeInt>;
out AElements: TElements; out AOrdering: TOrdering);
begin
SetUp_IQueue(FEmpty, FOne, FFull, AElements, AOrdering);
AEmpty := FEmpty;
AOne := FOne;
AFull := FFull;
end;
procedure TConformance_IQueue.Test_Dequeue;
var
LLastVersion: NativeInt;
LValue: NativeInt;
LList: IList<NativeInt>;
LPop: NativeInt;
begin
CheckException(ECollectionEmptyException,
procedure() begin FEmpty.Dequeue() end,
'ECollectionEmptyException not thrown in [empty].Dequeue()'
);
LLastVersion := FOne.Version;
LValue := FOne.Single;
LPop := FOne.Dequeue();
CheckNotEquals(LLastVersion, FOne.Version, 'Did not expect the version to be same in [one]');
CheckEquals(LValue, LPop, 'Expected the version to be same in [one]');
CheckEquals(0, RemovedList.Count, 'Expected the number of removed elements to not grow in [one]');
LList := FFull.ToList();
while not FFull.Empty do
begin
LLastVersion := FFull.Version;
LPop := FFull.Dequeue();
CheckNotEquals(LLastVersion, FFull.Version, 'Expected the version to be different in [full]');
CheckEquals(0, RemovedList.Count, 'Expected the number of removed elements to not grow in [full]');
CheckTrue(LList.Contains(LPop), 'Expected all elements to be poped in [full]');
LList.Remove(LPop);
end;
CheckTrue(LList.Empty, 'Expected all elements to be poped in [full]');
end;
procedure TConformance_IQueue.Test_Enqueue;
var
LLastVersion: NativeInt;
LNew, I: NativeInt;
begin
LLastVersion := FEmpty.Version;
FEmpty.Enqueue(FOne.Single);
CheckTrue(FEmpty.Contains(FOne.Single), 'Expected [empty] to contain [one]');
CheckNotEquals(LLastVersion, FEmpty.Version, 'Expected the version to differ in [empty]');
FEmpty.Enqueue(FOne.Single);
CheckTrue(FEmpty.Contains(FOne.Single), 'Expected [empty] to contain [one] again');
for I := 0 to FFull.Count - 1 do
begin
LNew := GenerateUniqueRandomElement(Elements);
LLastVersion := FFull.Version;
FFull.Enqueue(LNew);
CheckNotEquals(LLastVersion, FFull.Version, 'Expected the version to differ in [full]');
CheckTrue(FFull.Contains(LNew), 'Expected [full] to contain "new" value.');
end;
CheckEquals(0, RemovedList.Count, 'Did not expect any element to be removed!');
end;
procedure TConformance_IQueue.Test_Peek;
var
LLastVersion: NativeInt;
LValue: NativeInt;
LList: IList<NativeInt>;
LPop: NativeInt;
begin
CheckException(ECollectionEmptyException,
procedure() begin FEmpty.Peek() end,
'ECollectionEmptyException not thrown in [empty].Peek()'
);
LLastVersion := FOne.Version;
LValue := FOne.Single;
LPop := FOne.Peek();
CheckEquals(LLastVersion, FOne.Version, 'Expected the version to be same in [one]');
CheckEquals(LValue, LPop, 'Expected the version to be same in [one]');
CheckEquals(0, RemovedList.Count, 'Expected the number of removed elements to not grow in [one]');
LList := FFull.ToList();
while not FFull.Empty do
begin
LLastVersion := FFull.Version;
LPop := FFull.Peek();
CheckEquals(LLastVersion, FFull.Version, 'Did not expected the version to be different in [full]');
CheckEquals(0, RemovedList.Count, 'Expected the number of removed elements to not grow in [full]');
CheckTrue(LList.Contains(LPop), 'Expected all elements to be peeked in [full]');
LList.Remove(LPop);
FFull.Dequeue();
RemovedList.Clear;
end;
CheckTrue(LList.Empty, 'Expected all elements to be peeked in [full]');
end;
{ TConformance_ISortedSet }
procedure TConformance_ISortedSet.SetUp_ISet(out AEmpty, AOne, AFull: ISet<NativeInt>;
out AElements: TElements; out AOrdering: TOrdering);
begin
SetUp_ISortedSet(FEmpty, FOne, FFull, AElements, AOrdering);
AEmpty := FEmpty;
AOne := FOne;
AFull := FFull;
end;
{ TConformance_IList }
procedure TConformance_IList.SetUp_ICollection(out AEmpty, AOne, AFull: ICollection<NativeInt>;
out AElements: TElements; out AOrdering: TOrdering);
begin
SetUp_IList(FEmpty, FOne, FFull, AElements, AOrdering);
AEmpty := FEmpty;
AOne := FOne;
AFull := FFull;
end;
procedure TConformance_IList.Test_ExtractAt;
var
LValue, LVersion: NativeInt;
begin
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.ExtractAt(-1) end,
'EArgumentOutOfRangeException not thrown in [empty].ExtractAt(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.ExtractAt(0) end,
'EArgumentOutOfRangeException not thrown in [empty].ExtractAt(0)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.ExtractAt(-1) end,
'EArgumentOutOfRangeException not thrown in [one].ExtractAt(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.ExtractAt(1) end,
'EArgumentOutOfRangeException not thrown in [one].ExtractAt(1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.ExtractAt(-1) end,
'EArgumentOutOfRangeException not thrown in [full].ExtractAt(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.ExtractAt(FFull.Count) end,
'EArgumentOutOfRangeException not thrown in [full].ExtractAt(L)'
);
LValue := FOne.Single;
LVersion := FOne.Version;
CheckEquals(LValue, FOne.ExtractAt(0));
CheckEquals(0, RemovedList.Count);
CheckNotEquals(LVersion, FOne.Version);
while not FFull.Empty do
begin
LValue := FFull.First;
LVersion := FFull.Version;
CheckEquals(LValue, FFull.ExtractAt(0));
CheckEquals(0, RemovedList.Count);
CheckNotEquals(LVersion, FOne.Version);
RemovedList.Clear;
end;
end;
procedure TConformance_IList.Test_GetItem;
var
LIndex, LValue: NativeInt;
begin
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.GetItem(-1) end,
'EArgumentOutOfRangeException not thrown in [empty].GetItem(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.GetItem(0) end,
'EArgumentOutOfRangeException not thrown in [empty].GetItem(0)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.GetItem(-1) end,
'EArgumentOutOfRangeException not thrown in [one].GetItem(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.GetItem(1) end,
'EArgumentOutOfRangeException not thrown in [one].GetItem(1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.GetItem(-1) end,
'EArgumentOutOfRangeException not thrown in [full].GetItem(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.GetItem(FFull.Count) end,
'EArgumentOutOfRangeException not thrown in [full].GetItem(L)'
);
CheckEquals(FOne.Single, FOne.GetItem(0));
CheckEquals(FOne.ElementAt(0), FOne.GetItem(0));
LIndex := 0;
for LValue in FFull do
begin
CheckEquals(LValue, FFull.GetItem(LIndex));
CheckEquals(LValue, FFull.ElementAt(LIndex));
Inc(LIndex);
end;
end;
procedure TConformance_IList.Test_IndexOf;
var
LExpIndex, LValue, I: NativeInt;
begin
CheckEquals(-1, FEmpty.IndexOf(FOne.Single));
CheckEquals(-1, FOne.IndexOf(FOne.Single - 1));
CheckEquals(0, FOne.IndexOf(FOne.Single));
for LValue in FFull do
begin
LExpIndex := -1;
for I := 0 to FFull.Count - 1 do
if FFull.GetItem(I) = LValue then
begin
LExpIndex := I;
Break;
end;
CheckEquals(LExpIndex, FFull.IndexOf(LValue));
end;
CheckEquals(-1, FFull.IndexOf(GenerateUniqueRandomElement(Elements)));
end;
procedure TConformance_IList.Test_Insert;
var
LVersion: NativeInt;
begin
if Ordering in [oAscending, oDescending] then
begin
CheckException(ENotSupportedException,
procedure() begin FEmpty.Insert(-1, -1) end,
'ENotSupportedException not thrown in [empty].Insert(-1)'
);
CheckException(ENotSupportedException,
procedure() begin FOne.Insert(0, -1) end,
'ENotSupportedException not thrown in [one].Insert(0)'
);
Exit;
end;
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.Insert(-1, -1) end,
'EArgumentOutOfRangeException not thrown in [empty].Insert(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.Insert(1, -1) end,
'EArgumentOutOfRangeException not thrown in [empty].Insert(1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.Insert(-1, -1) end,
'EArgumentOutOfRangeException not thrown in [one].Insert(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.Insert(2, -1) end,
'EArgumentOutOfRangeException not thrown in [one].Insert(1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.Insert(-1, -1) end,
'EArgumentOutOfRangeException not thrown in [full].Insert(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.Insert(FFull.Count + 1, -1) end,
'EArgumentOutOfRangeException not thrown in [full].Insert(1)'
);
LVersion := FEmpty.Version;
FEmpty.Insert(0, FOne.Single);
CheckEquals(1, FEmpty.Count);
CheckEquals(FOne.Single, FEmpty.GetItem(0));
CheckNotEquals(LVersion, FEmpty.Version);
LVersion := FEmpty.Version;
FEmpty.Insert(0, FOne.Single - 1);
CheckEquals(2, FEmpty.Count);
CheckEquals(FOne.Single - 1, FEmpty.GetItem(0));
CheckEquals(FOne.Single, FEmpty.GetItem(1));
CheckNotEquals(LVersion, FEmpty.Version);
LVersion := FEmpty.Version;
FEmpty.Insert(1, FOne.Single - 2);
CheckEquals(3, FEmpty.Count);
CheckEquals(FOne.Single - 1, FEmpty.GetItem(0));
CheckEquals(FOne.Single - 2, FEmpty.GetItem(1));
CheckEquals(FOne.Single, FEmpty.GetItem(2));
CheckNotEquals(LVersion, FEmpty.Version);
LVersion := FEmpty.Version;
FEmpty.Insert(3, FOne.Single - 3);
CheckEquals(4, FEmpty.Count);
CheckEquals(FOne.Single - 1, FEmpty.GetItem(0));
CheckEquals(FOne.Single - 2, FEmpty.GetItem(1));
CheckEquals(FOne.Single, FEmpty.GetItem(2));
CheckEquals(FOne.Single - 3, FEmpty.GetItem(3));
CheckNotEquals(LVersion, FEmpty.Version);
end;
procedure TConformance_IList.Test_InsertAll;
var
LVersion: NativeInt;
begin
if Ordering in [oAscending, oDescending] then
begin
CheckException(ENotSupportedException,
procedure() begin FEmpty.InsertAll(-1, nil) end,
'ENotSupportedException not thrown in [empty].InsertAll(-1)'
);
CheckException(ENotSupportedException,
procedure() begin FOne.InsertAll(0, FEmpty) end,
'ENotSupportedException not thrown in [one].InsertAll(0)'
);
Exit;
end;
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.InsertAll(-1, FOne) end,
'EArgumentOutOfRangeException not thrown in [empty].InsertAll(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.InsertAll(1, FOne) end,
'EArgumentOutOfRangeException not thrown in [empty].InsertAll(1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.InsertAll(-1, FOne) end,
'EArgumentOutOfRangeException not thrown in [one].InsertAll(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.InsertAll(2, FOne) end,
'EArgumentOutOfRangeException not thrown in [one].InsertAll(1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.InsertAll(-1, FOne) end,
'EArgumentOutOfRangeException not thrown in [full].InsertAll(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.InsertAll(FFull.Count + 1, FOne) end,
'EArgumentOutOfRangeException not thrown in [full].InsertAll(1)'
);
CheckException(EArgumentNilException,
procedure() begin FEmpty.InsertAll(0, nil) end,
'EArgumentNilException not thrown in [empty].InsertAll(nil)'
);
CheckException(EArgumentNilException,
procedure() begin FOne.InsertAll(0, nil) end,
'EArgumentNilException not thrown in [one].InsertAll(nil)'
);
CheckException(EArgumentNilException,
procedure() begin FFull.InsertAll(0, nil) end,
'EArgumentNilException not thrown in [full].InsertAll(nil)'
);
FOne.Add(FOne.Single - 1);
LVersion := FEmpty.Version;
FEmpty.InsertAll(0, FOne);
CheckEquals(2, FEmpty.Count);
CheckEquals(FOne.First, FEmpty.GetItem(0));
CheckEquals(FOne.Last, FEmpty.GetItem(1));
CheckNotEquals(LVersion, FEmpty.Version);
LVersion := FEmpty.Version;
FEmpty.InsertAll(1, FOne);
CheckEquals(4, FEmpty.Count);
CheckEquals(FOne.First, FEmpty.GetItem(0));
CheckEquals(FOne.First, FEmpty.GetItem(1));
CheckEquals(FOne.Last, FEmpty.GetItem(2));
CheckEquals(FOne.Last, FEmpty.GetItem(3));
CheckNotEquals(LVersion, FEmpty.Version);
LVersion := FEmpty.Version;
FEmpty.InsertAll(4, FOne);
CheckEquals(6, FEmpty.Count);
CheckEquals(FOne.First, FEmpty.GetItem(0));
CheckEquals(FOne.First, FEmpty.GetItem(1));
CheckEquals(FOne.Last, FEmpty.GetItem(2));
CheckEquals(FOne.Last, FEmpty.GetItem(3));
CheckEquals(FOne.First, FEmpty.GetItem(4));
CheckEquals(FOne.Last, FEmpty.GetItem(5));
CheckNotEquals(LVersion, FEmpty.Version);
end;
procedure TConformance_IList.Test_LastIndexOf;
var
LExpIndex, LValue, I: NativeInt;
begin
CheckEquals(-1, FEmpty.LastIndexOf(FOne.Single));
CheckEquals(-1, FOne.LastIndexOf(FOne.Single - 1));
CheckEquals(0, FOne.LastIndexOf(FOne.Single));
for LValue in FFull do
begin
LExpIndex := -1;
for I := FFull.Count - 1 downto 0 do
if FFull.GetItem(I) = LValue then
begin
LExpIndex := I;
Break;
end;
CheckEquals(LExpIndex, FFull.LastIndexOf(LValue));
end;
CheckEquals(-1, FFull.LastIndexOf(GenerateUniqueRandomElement(Elements)));
end;
procedure TConformance_IList.Test_RemoveAt;
var
LValue, LVersion: NativeInt;
begin
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.RemoveAt(-1) end,
'EArgumentOutOfRangeException not thrown in [empty].RemoveAt(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.RemoveAt(0) end,
'EArgumentOutOfRangeException not thrown in [empty].RemoveAt(0)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.RemoveAt(-1) end,
'EArgumentOutOfRangeException not thrown in [one].RemoveAt(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.RemoveAt(1) end,
'EArgumentOutOfRangeException not thrown in [one].RemoveAt(1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.RemoveAt(-1) end,
'EArgumentOutOfRangeException not thrown in [full].RemoveAt(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.RemoveAt(FFull.Count) end,
'EArgumentOutOfRangeException not thrown in [full].RemoveAt(L)'
);
LValue := FOne.Single;
LVersion := FOne.Version;
FOne.RemoveAt(0);
CheckEquals(1, RemovedList.Count);
CheckEquals(LValue, RemovedList[0]);
CheckNotEquals(LVersion, FOne.Version);
RemovedList.Clear;
while not FFull.Empty do
begin
LValue := FFull.First;
LVersion := FFull.Version;
FFull.RemoveAt(0);
CheckEquals(1, RemovedList.Count);
CheckEquals(LValue, RemovedList[0]);
CheckNotEquals(LVersion, FOne.Version);
RemovedList.Clear;
end;
end;
procedure TConformance_IList.Test_SetItem;
var
LVersion: NativeInt;
begin
if Ordering in [oAscending, oDescending] then
begin
CheckException(ENotSupportedException,
procedure() begin FEmpty.SetItem(-1, -1) end,
'ENotSupportedException not thrown in [empty].SetItem(-1)'
);
CheckException(ENotSupportedException,
procedure() begin FOne.SetItem(0, -1) end,
'ENotSupportedException not thrown in [one].SetItem(0)'
);
Exit;
end;
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.SetItem(-1, -1) end,
'EArgumentOutOfRangeException not thrown in [empty].SetItem(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.SetItem(0, -1) end,
'EArgumentOutOfRangeException not thrown in [empty].SetItem(0)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.SetItem(-1, -1) end,
'EArgumentOutOfRangeException not thrown in [one].SetItem(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.SetItem(1, -1) end,
'EArgumentOutOfRangeException not thrown in [one].SetItem(1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.SetItem(-1, -1) end,
'EArgumentOutOfRangeException not thrown in [full].SetItem(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.SetItem(FFull.Count, -1) end,
'EArgumentOutOfRangeException not thrown in [full].SetItem(L)'
);
LVersion := FOne.Version;
FOne.SetItem(0, FOne.Single);
CheckEquals(0, RemovedList.Count);
CheckNotEquals(LVersion, FOne.Version);
FOne.SetItem(0, FOne.Single - 1);
CheckEquals(1, RemovedList.Count);
CheckEquals(FOne.Single + 1, RemovedList[0]);
CheckNotEquals(LVersion, FOne.Version);
end;
{ TConformance_ILinkedList }
procedure TConformance_ILinkedList.SetUp_IList(out AEmpty, AOne, AFull: IList<NativeInt>;
out AElements: TElements; out AOrdering: TOrdering);
begin
SetUp_ILinkedList(FEmpty, FOne, FFull, AElements, AOrdering);
AEmpty := FEmpty;
AOne := FOne;
AFull := FFull;
end;
procedure TConformance_ILinkedList.Test_AddAllFirst;
var
LVersion: NativeInt;
begin
if Ordering in [oAscending, oDescending] then
begin
CheckException(ENotSupportedException,
procedure() begin FEmpty.AddAllFirst(nil) end,
'ENotSupportedException not thrown in [empty].AddAllFirst(nil)'
);
CheckException(ENotSupportedException,
procedure() begin FOne.AddAllFirst(FEmpty) end,
'ENotSupportedException not thrown in [one].AddAllFirst(E)'
);
Exit;
end;
CheckException(EArgumentNilException,
procedure() begin FEmpty.AddAllFirst(nil) end,
'EArgumentNilException not thrown in [empty].AddAllFirst(nil)'
);
CheckException(EArgumentNilException,
procedure() begin FOne.AddAllFirst(nil) end,
'EArgumentNilException not thrown in [one].AddAllFirst(nil)'
);
CheckException(EArgumentNilException,
procedure() begin FFull.AddAllFirst(nil) end,
'EArgumentNilException not thrown in [full].AddAllFirst(nil)'
);
LVersion := FOne.Version;
FOne.AddAllFirst(FEmpty);
CheckEquals(1, FOne.Count);
CheckEquals(LVersion, FOne.Version);
LVersion := FEmpty.Version;
FEmpty.AddAllFirst(FOne);
CheckEquals(1, FEmpty.Count);
CheckEquals(FOne.Single, FEmpty.Single);
CheckNotEquals(LVersion, FEmpty.Version);
LVersion := FOne.Version;
FOne.AddAllFirst(FFull);
CheckEquals(FFull.Count + 1, FOne.Count);
CheckNotEquals(LVersion, FOne.Version);
CheckTrue(FOne.EqualsTo(FFull.Reversed().Concat(FEmpty)));
end;
procedure TConformance_ILinkedList.Test_AddAllLast;
var
LVersion: NativeInt;
begin
if Ordering in [oAscending, oDescending] then
begin
CheckException(ENotSupportedException,
procedure() begin FEmpty.AddAllLast(nil) end,
'ENotSupportedException not thrown in [empty].AddAllLast(nil)'
);
CheckException(ENotSupportedException,
procedure() begin FOne.AddAllLast(FEmpty) end,
'ENotSupportedException not thrown in [one].AddAllLast(E)'
);
Exit;
end;
CheckException(EArgumentNilException,
procedure() begin FEmpty.AddAllLast(nil) end,
'EArgumentNilException not thrown in [empty].AddAllLast(nil)'
);
CheckException(EArgumentNilException,
procedure() begin FOne.AddAllLast(nil) end,
'EArgumentNilException not thrown in [one].AddAllLast(nil)'
);
CheckException(EArgumentNilException,
procedure() begin FFull.AddAllLast(nil) end,
'EArgumentNilException not thrown in [full].AddAllLast(nil)'
);
LVersion := FOne.Version;
FOne.AddAllLast(FEmpty);
CheckEquals(1, FOne.Count);
CheckEquals(LVersion, FOne.Version);
LVersion := FEmpty.Version;
FEmpty.AddAllLast(FOne);
CheckEquals(1, FEmpty.Count);
CheckEquals(FOne.Single, FEmpty.Single);
CheckNotEquals(LVersion, FEmpty.Version);
LVersion := FOne.Version;
FOne.AddAllLast(FFull);
CheckEquals(FFull.Count + 1, FOne.Count);
CheckNotEquals(LVersion, FOne.Version);
CheckTrue(FOne.EqualsTo(FEmpty.Concat(FFull)));
end;
procedure TConformance_ILinkedList.Test_AddFirst;
var
LVersion: NativeInt;
LNew: NativeInt;
LLastCount: NativeInt;
LEnumerator: IEnumerator<NativeInt>;
I: NativeInt;
begin
if Ordering in [oAscending, oDescending] then
begin
CheckException(ENotSupportedException,
procedure() begin FEmpty.AddFirst(-1) end,
'ENotSupportedException not thrown in [empty].AddFirst(-1)'
);
CheckException(ENotSupportedException,
procedure() begin FOne.AddFirst(-1) end,
'ENotSupportedException not thrown in [one].AddFirst(-1)'
);
Exit;
end;
LVersion := FEmpty.Version;
FEmpty.AddFirst(FOne.Single);
CheckEquals(1, FEmpty.Count);
CheckEquals(FOne.Single, FEmpty.Single);
CheckNotEquals(LVersion, FEmpty.Version);
LNew := GenerateUniqueRandomElement(Elements);
LLastCount := FFull.Count;
FFull.AddFirst(LNew);
CheckEquals(LLastCount + 1, FFull.Count);
CheckEquals(0, FFull.IndexOf(LNew));
CheckTrue(FFull.Contains(LNew));
LEnumerator := FFull.GetEnumerator();
LEnumerator.MoveNext();
for I := 0 to Length(Elements) - 1 do
begin
CheckTrue(LEnumerator.MoveNext());
CheckEquals(Elements[I], LEnumerator.Current);
end;
end;
procedure TConformance_ILinkedList.Test_AddLast;
var
LVersion: NativeInt;
LNew: NativeInt;
LLastCount: NativeInt;
LEnumerator: IEnumerator<NativeInt>;
I: NativeInt;
begin
if Ordering in [oAscending, oDescending] then
begin
CheckException(ENotSupportedException,
procedure() begin FEmpty.AddLast(-1) end,
'ENotSupportedException not thrown in [empty].AddLast(-1)'
);
CheckException(ENotSupportedException,
procedure() begin FOne.AddLast(-1) end,
'ENotSupportedException not thrown in [one].AddLast(-1)'
);
Exit;
end;
LVersion := FEmpty.Version;
FEmpty.AddLast(FOne.Single);
CheckEquals(1, FEmpty.Count);
CheckEquals(FOne.Single, FEmpty.Single);
CheckNotEquals(LVersion, FEmpty.Version);
LNew := GenerateUniqueRandomElement(Elements);
LLastCount := FFull.Count;
FFull.AddLast(LNew);
CheckEquals(LLastCount + 1, FFull.Count);
CheckEquals(LLastCount, FFull.IndexOf(LNew));
CheckTrue(FFull.Contains(LNew));
LEnumerator := FFull.GetEnumerator();
for I := 0 to Length(Elements) - 1 do
begin
CheckTrue(LEnumerator.MoveNext());
CheckEquals(Elements[I], LEnumerator.Current);
end;
end;
procedure TConformance_ILinkedList.Test_ExtractFirst;
var
LValue, LVersion: NativeInt;
begin
CheckException(ECollectionEmptyException,
procedure() begin FEmpty.ExtractFirst() end,
'ECollectionEmptyException not thrown in [empty].ExtractFirst()'
);
LValue := FOne.Single;
LVersion := FOne.Version;
CheckEquals(LValue, FOne.ExtractFirst());
CheckEquals(0, RemovedList.Count);
CheckNotEquals(LVersion, FOne.Version);
while not FFull.Empty do
begin
LValue := FFull.First;
LVersion := FFull.Version;
CheckEquals(LValue, FFull.ExtractFirst());
CheckEquals(0, RemovedList.Count);
CheckNotEquals(LVersion, FOne.Version);
RemovedList.Clear;
end;
end;
procedure TConformance_ILinkedList.Test_ExtractLast;
var
LValue, LVersion: NativeInt;
begin
CheckException(ECollectionEmptyException,
procedure() begin FEmpty.ExtractLast() end,
'ECollectionEmptyException not thrown in [empty].ExtractLast()'
);
LValue := FOne.Single;
LVersion := FOne.Version;
CheckEquals(LValue, FOne.ExtractLast());
CheckEquals(0, RemovedList.Count);
CheckNotEquals(LVersion, FOne.Version);
while not FFull.Empty do
begin
LValue := FFull.Last;
LVersion := FFull.Version;
CheckEquals(LValue, FFull.ExtractLast());
CheckEquals(0, RemovedList.Count);
CheckNotEquals(LVersion, FOne.Version);
RemovedList.Clear;
end;
end;
procedure TConformance_ILinkedList.Test_ILinkedList_First;
begin
Test_First;
end;
procedure TConformance_ILinkedList.Test_ILinkedList_Last;
begin
Test_Last;
end;
procedure TConformance_ILinkedList.Test_RemoveFirst;
var
LValue, LVersion: NativeInt;
begin
CheckException(ECollectionEmptyException,
procedure() begin FEmpty.RemoveFirst() end,
'ECollectionEmptyException not thrown in [empty].RemoveFirst()'
);
LValue := FOne.Single;
LVersion := FOne.Version;
FOne.RemoveFirst();
CheckEquals(1, RemovedList.Count);
CheckEquals(LValue, RemovedList[0]);
CheckNotEquals(LVersion, FOne.Version);
RemovedList.Clear;
while not FFull.Empty do
begin
LValue := FFull.First;
LVersion := FFull.Version;
FFull.RemoveFirst();
CheckEquals(1, RemovedList.Count);
CheckEquals(LValue, RemovedList[0]);
CheckNotEquals(LVersion, FOne.Version);
RemovedList.Clear;
end;
end;
procedure TConformance_ILinkedList.Test_RemoveLast;
var
LValue, LVersion: NativeInt;
begin
CheckException(ECollectionEmptyException,
procedure() begin FEmpty.RemoveLast() end,
'ECollectionEmptyException not thrown in [empty].RemoveLast()'
);
LValue := FOne.Single;
LVersion := FOne.Version;
FOne.RemoveLast();
CheckEquals(1, RemovedList.Count);
CheckEquals(LValue, RemovedList[0]);
CheckNotEquals(LVersion, FOne.Version);
RemovedList.Clear;
while not FFull.Empty do
begin
LValue := FFull.Last;
LVersion := FFull.Version;
FFull.RemoveLast();
CheckEquals(1, RemovedList.Count);
CheckEquals(LValue, RemovedList[0]);
CheckNotEquals(LVersion, FOne.Version);
RemovedList.Clear;
end;
end;
{ TConformance_IEnumerable_Associative }
procedure TConformance_IEnumerable_Associative.CheckEquals(const AExpected, AActual: TPair<NativeInt, NativeInt>; const AMessage: String);
begin
CheckEquals(AExpected.Key, AActual.Key, AMessage);
CheckEquals(AExpected.Value, AActual.Value, AMessage);
end;
procedure TConformance_IEnumerable_Associative.SetUp;
begin
inherited;
SetUp_IEnumerable(FEmpty, FOne, FFull, FPairs, FKeyOrdering);
end;
procedure TConformance_IEnumerable_Associative.TearDown;
begin
inherited;
FEmpty := nil;
FOne := nil;
FFull := nil;
end;
procedure TConformance_IEnumerable_Associative.Test_Enumerator_Early_Current;
begin
CheckEquals(FEmpty.GetEnumerator().Current, Default(TPair<NativeInt, NativeInt>), 'Expected Current to be default for [empty].');
CheckEquals(FOne.GetEnumerator().Current, Default(TPair<NativeInt, NativeInt>), 'Expected Current to be default for [one].');
CheckEquals(FFull.GetEnumerator().Current, Default(TPair<NativeInt, NativeInt>), 'Expected Current to be default for [full].');
end;
procedure TConformance_IEnumerable_Associative.Test_Enumerator_ReachEnd;
var
LEnumerator: IEnumerator<TPair<NativeInt, NativeInt>>;
LLast: TPair<NativeInt, NativeInt>;
LIndex: NativeInt;
LList: Generics.Collections.TList<TPair<NativeInt, NativeInt>>;
LIsFirst: Boolean;
begin
LEnumerator := FEmpty.GetEnumerator();
CheckFalse(LEnumerator.MoveNext(), 'Did not expect a valid 1.MoveNext() for [empty]');
CheckFalse(LEnumerator.MoveNext(), 'Did not expect a valid 2.MoveNext() for [empty]');
LEnumerator := FOne.GetEnumerator();
CheckTrue(LEnumerator.MoveNext(), 'Expected a valid 1.MoveNext() for [one]');
LLast := LEnumerator.Current;
CheckFalse(LEnumerator.MoveNext(), 'Did not expect a valid 2.MoveNext() for [one]');
CheckEquals(LLast, LEnumerator.Current, 'Expected the last value to remain constant for [one]');
CheckFalse(LEnumerator.MoveNext(), 'Did not expect a valid 3.MoveNext() for [one]');
CheckEquals(LLast, LEnumerator.Current, 'Expected the last value to remain constant for [one]');
CheckEquals(LLast, FPairs[0], 'Expected the only value to be valid [one]');
LEnumerator := FFull.GetEnumerator();
LList := Generics.Collections.TList<TPair<NativeInt, NativeInt>>.Create();
LList.AddRange(FPairs);
LIsFirst := True;
LIndex := 0;
while LEnumerator.MoveNext() do
begin
if LIsFirst then
LIsFirst := False
else begin
{ Check ordering if applied }
if FKeyOrdering = oAscending then
CheckTrue(LEnumerator.Current.Key >= LLast.Key, 'Expected Vi >= Vi-1 always for [full]!')
else if FKeyOrdering = oDescending then
CheckTrue(LEnumerator.Current.Key <= LLast.Key, 'Expected Vi <= Vi-1 always for [full]!');
end;
LLast := LEnumerator.Current;
if FKeyOrdering = oInsert then
CheckEquals(FPairs[LIndex], LLast, 'Expected insert ordering to apply for [full].');
LList.Remove(LEnumerator.Current);
Inc(LIndex);
end;
{ Check that all elements have been enumerated }
CheckEquals(0, LList.Count, 'Expected that all elements are enumerated in [full].');
LList.Free;
end;
procedure TConformance_IEnumerable_Associative.Test_GetEnumerator;
var
LEnumerator: IEnumerator<TPair<NativeInt, NativeInt>>;
begin
LEnumerator := FEmpty.GetEnumerator();
CheckTrue(Assigned(LEnumerator), 'Expected a non-nil enumerator for [empty].');
CheckTrue(Pointer(LEnumerator) <> Pointer(FEmpty.GetEnumerator()), 'Expected a new object enumerator for [empty].');
LEnumerator := FOne.GetEnumerator();
CheckTrue(Assigned(LEnumerator), 'Expected a non-nil enumerator for [one].');
CheckTrue(Pointer(LEnumerator) <> Pointer(FOne.GetEnumerator()), 'Expected a new object enumerator for [one].');
LEnumerator := FFull.GetEnumerator();
CheckTrue(Assigned(LEnumerator), 'Expected a non-nil enumerator for [full].');
CheckTrue(Pointer(LEnumerator) <> Pointer(FFull.GetEnumerator()), 'Expected a new object enumerator for [full].');
end;
{ TConformance_ICollection_Associative }
function TConformance_ICollection_Associative.MinusOne: TPair<NativeInt, NativeInt>;
begin
Result.Key := -1;
Result.Value := -1;
end;
function TConformance_ICollection_Associative.MinusOne(const APair: TPair<NativeInt, NativeInt>): TPair<NativeInt, NativeInt>;
begin
Result.Key := APair.Key - 1;
Result.Value := APair.Value - 1;
end;
procedure TConformance_ICollection_Associative.SetUp_IEnumerable(out AEmpty, AOne, AFull: IEnumerable<TPair<NativeInt, NativeInt>>;
out APairs: TPairs; out AKeyOrdering: TOrdering);
begin
SetUp_IContainer(FEmpty, FOne, FFull, APairs, AKeyOrdering);
AEmpty := FEmpty;
AOne := FOne;
AFull := FFull;
end;
procedure TConformance_ICollection_Associative.Test_CopyTo_1;
var
LArray: TArray<TPair<NativeInt, NativeInt>>;
LEnumerator: IEnumerator<TPair<NativeInt, NativeInt>>;
LIndex: NativeInt;
begin
SetLength(LArray, 1);
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.CopyTo(LArray, -1); end,
'EArgumentOutOfRangeException not thrown in [empty].CopyTo(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.CopyTo(LArray, 2); end,
'EArgumentOutOfRangeException not thrown in [empty].CopyTo(2)'
);
FEmpty.CopyTo(LArray, 0);
SetLength(LArray, 0);
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.CopyTo(LArray, 0); end,
'EArgumentOutOfRangeException not thrown in [empty].CopyTo(0)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.CopyTo(LArray, 0); end,
'EArgumentOutOfRangeException not thrown in [one].CopyTo(0)'
);
SetLength(LArray, 10);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.CopyTo(LArray, -1); end,
'EArgumentOutOfRangeException not thrown in [one].CopyTo(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FOne.CopyTo(LArray, 10); end,
'EArgumentOutOfRangeException not thrown in [one].CopyTo(10)'
);
FOne.CopyTo(LArray, 9);
CheckEquals(LArray[9], Pairs[0], 'Expected the element to be coopied properly [one].');
SetLength(LArray, 0);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.CopyTo(LArray, 0); end,
'EArgumentOutOfRangeException not thrown in [full].CopyTo(0)'
);
SetLength(LArray, Length(Pairs) - 1);
CheckException(EArgumentOutOfSpaceException,
procedure() begin FFull.CopyTo(LArray, 0); end,
'EArgumentOutOfSpaceException not thrown in [full].CopyTo(0)'
);
SetLength(LArray, Length(Pairs) + 1);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.CopyTo(LArray, -1); end,
'EArgumentOutOfRangeException not thrown in [full].CopyTo(-1)'
);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.CopyTo(LArray, Length(LArray)); end,
'EArgumentOutOfRangeException not thrown in [full].CopyTo(L)'
);
FFull.CopyTo(LArray, 1);
LEnumerator := FFull.GetEnumerator();
LIndex := 1;
while LEnumerator.MoveNext() do
begin
CheckEquals(LEnumerator.Current, LArray[LIndex], 'Expected the copied array to be same order as enumerator for [full].');
Inc(LIndex);
end;
CheckEquals(Length(LArray), LIndex, 'Expected same count as enumerator for [full]');
end;
procedure TConformance_ICollection_Associative.Test_CopyTo_2;
var
LArray: TArray<TPair<NativeInt, NativeInt>>;
LEnumerator: IEnumerator<TPair<NativeInt, NativeInt>>;
LIndex: NativeInt;
begin
SetLength(LArray, 1);
FEmpty.CopyTo(LArray);
SetLength(LArray, 0);
CheckException(EArgumentOutOfRangeException,
procedure() begin FEmpty.CopyTo(LArray); end,
'EArgumentOutOfRangeException not thrown in [empty].CopyTo()'
);
SetLength(LArray, 10);
FOne.CopyTo(LArray, 9);
CheckEquals(LArray[9], PAirs[0], 'Expected the element to be coopied properly [one].');
SetLength(LArray, 0);
CheckException(EArgumentOutOfRangeException,
procedure() begin FFull.CopyTo(LArray); end,
'EArgumentOutOfRangeException not thrown in [full].CopyTo()'
);
SetLength(LArray, Length(Pairs) - 1);
CheckException(EArgumentOutOfSpaceException,
procedure() begin FFull.CopyTo(LArray); end,
'EArgumentOutOfSpaceException not thrown in [full].CopyTo()'
);
SetLength(LArray, Length(Pairs) + 1);
FFull.CopyTo(LArray, 1);
LEnumerator := FFull.GetEnumerator();
LIndex := 1;
while LEnumerator.MoveNext() do
begin
CheckEquals(LEnumerator.Current, LArray[LIndex], 'Expected the copied array to be same order as enumerator for [full].');
Inc(LIndex);
end;
CheckEquals(Length(LArray), LIndex, 'Expected same count as enumerator for [full]');
end;
procedure TConformance_ICollection_Associative.Test_Empty;
begin
CheckTrue(FEmpty.Empty, 'Expected empty for [empty].');
CheckFalse(FOne.Empty, 'Expected non-empty for [one].');
CheckFalse(FFull.Empty, 'Expected non-empty for [full].');
end;
procedure TConformance_ICollection_Associative.Test_GetCount;
begin
CheckEquals(0, FEmpty.GetCount(), 'Expected zero count for [empty].');
CheckEquals(1, FOne.GetCount(), 'Expected 1 count for [one].');
CheckEquals(Length(Pairs), FFull.GetCount(), 'Expected > 1 count for [full].');
end;
procedure TConformance_ICollection_Associative.Test_Single;
begin
CheckException(ECollectionEmptyException,
procedure() begin FEmpty.Single(); end,
'ECollectionEmptyException not thrown in [empty].Single()'
);
CheckEquals(Pairs[0], FOne.Single(), 'Expected "single" value failed for [one]');
CheckException(ECollectionNotOneException,
procedure() begin FFull.Single(); end,
'ECollectionNotOneException not thrown in [full].Single()'
);
end;
procedure TConformance_ICollection_Associative.Test_SingleOrDefault;
var
LSingle: TPair<NativeInt, NativeInt>;
begin
CheckException(ECollectionNotOneException,
procedure() begin FFull.SingleOrDefault(MinusOne); end,
'ECollectionNotOneException not thrown in [full].SingleOrDefault()'
);
CheckEquals(MinusOne, FEmpty.SingleOrDefault(MinusOne), 'Expected "-1" value failed for [one]');
LSingle := FOne.Single();
CheckEquals(LSingle, FOne.SingleOrDefault(MinusOne(LSingle)), 'Expected "single" value failed for [one]');
end;
procedure TConformance_ICollection_Associative.Test_ToArray;
var
LArray: TArray<TPair<NativeInt, NativeInt>>;
LEnumerator: IEnumerator<TPair<NativeInt, NativeInt>>;
LIndex: NativeInt;
begin
LArray := FEmpty.ToArray();
CheckEquals(0, Length(LArray), 'Expected a length of zero for the elements of [empty].');
LArray := FOne.ToArray();
CheckEquals(1, Length(LArray), 'Expected a length of 1 for the elements of [one].');
CheckEquals(Pairs[0], LArray[0], 'Expected a proper single element for [one].');
LArray := FFull.ToArray();
CheckEquals(Length(Pairs), Length(LArray), 'Expected a proper length for [full].');
LEnumerator := FFull.GetEnumerator();
LIndex := 0;
while LEnumerator.MoveNext() do
begin
CheckEquals(LEnumerator.Current, LArray[LIndex], 'Expected the copied array to be same order as enumerator for [full]');
Inc(LIndex);
end;
CheckEquals(Length(LArray), LIndex, 'Expected same count as enumerator for [full]');
end;
procedure TConformance_ICollection_Associative.Test_Version;
begin
CheckEquals(0, FEmpty.Version(), 'Expected the version for [empty] to be zero.');
CheckTrue(FOne.Version() > FEmpty.Version(), 'Expected the version for [one] to be bigger than zero.');
CheckTrue(FFull.Version() > FEmpty.Version(), 'Expected the version for [full] to be bigger than for [one].');
end;
{ TConformance_IAssociation }
procedure TConformance_IAssociation.SetUp_IContainer(out AEmpty, AOne, AFull: IContainer<TPair<NativeInt, NativeInt>>;
out APairs: TPairs; out AKeyOrdering: TOrdering);
begin
SetUp_IAssociation(FEmpty, FOne, FFull, APairs, AKeyOrdering);
AEmpty := FEmpty;
AOne := FOne;
AFull := FFull;
end;
procedure TConformance_IAssociation.Test_DistinctByKeys;
var
LDistinct: IAssociation<NativeInt, NativeInt>;
LDistKeys: ISet<NativeInt>;
LPair: TPair<NativeInt, NativeInt>;
begin
LDistinct := FEmpty.DistinctByKeys;
CheckTrue(LDistinct.Empty);
LDistinct := FOne.DistinctByKeys;
CheckEquals(1, LDistinct.Count);
CheckEquals(LDistinct.Single, FOne.Single);
LDistinct := FFull.DistinctByKeys;
CheckTrue(LDistinct.Count <= FFull.Count);
LDistKeys := LDistinct.Keys.ToSet();
CheckTrue(LDistKeys.Count = LDistinct.Count);
for LPair in FFull do
CheckTrue(LDistKeys.Contains(LPair.Key));
end;
procedure TConformance_IAssociation.Test_DistinctByValues;
var
LDistinct: IAssociation<NativeInt, NativeInt>;
LDistVals: ISet<NativeInt>;
LPair: TPair<NativeInt, NativeInt>;
begin
LDistinct := FEmpty.DistinctByValues;
CheckTrue(LDistinct.Empty);
LDistinct := FOne.DistinctByValues;
CheckEquals(1, LDistinct.Count);
CheckEquals(LDistinct.Single, FOne.Single);
LDistinct := FFull.DistinctByValues;
CheckTrue(LDistinct.Count <= FFull.Count);
LDistVals := LDistinct.Values.ToSet();
CheckTrue(LDistVals.Count = LDistinct.Count);
for LPair in FFull do
CheckTrue(LDistVals.Contains(LPair.Value));
end;
procedure TConformance_IAssociation.Test_Includes;
begin
CheckTrue(FEmpty.Includes(FEmpty));
CheckTrue(FOne.Includes(FEmpty));
CheckFalse(FEmpty.Includes(FOne));
CheckTrue(FOne.Includes(FOne));
CheckTrue(FFull.Includes(FOne));
CheckTrue(FFull.Includes(FFull));
end;
procedure TConformance_IAssociation.Test_KeyHasValue;
var
LPair: TPair<NativeInt, NativeInt>;
begin
{TODO: Fix these tests - KeyHasValue method requires two parameters, not one!}
// CheckFalse(FEmpty.KeyHasValue(-1));
// CheckFalse(FOne.KeyHasValue(FOne.Single.Key - 1));
// CheckTrue(FOne.KeyHasValue(FOne.Single.Key));
//
// for LPair in FFull do
// CheckTrue(FFull.KeyHasValue(LPair.Key));
end;
procedure TConformance_IAssociation.Test_MaxKey;
var
LPair: TPair<NativeInt, NativeInt>;
LMaxKey: NativeInt;
LFirst: Boolean;
begin
CheckException(ECollectionEmptyException,
procedure() begin FEmpty.MaxKey end,
'ECollectionEmptyException not thrown in [empty].MaxKey()'
);
CheckEquals(FOne.Single.Key, FOne.MaxKey);
LFirst := true;
LMaxKey := -1;
for LPair in FFull do
begin
if LFirst then
begin
LMaxKey := LPair.Key;
LFirst := false;
end else
begin
if LPair.Key > LMaxKey then
LMaxKey := LPair.Key;
end;
end;
CheckEquals(LMaxKey, FFull.MaxKey);
end;
procedure TConformance_IAssociation.Test_MaxValue;
var
LPair: TPair<NativeInt, NativeInt>;
LMaxValue: NativeInt;
LFirst: Boolean;
begin
CheckException(ECollectionEmptyException,
procedure() begin FEmpty.MaxValue end,
'ECollectionEmptyException not thrown in [empty].MaxKey()'
);
CheckEquals(FOne.Single.Key, FOne.MaxValue);
LFirst := true;
LMaxValue := -1;
for LPair in FFull do
begin
if LFirst then
begin
LMaxValue := LPair.Value;
LFirst := false;
end else
begin
if LPair.Value > LMaxValue then
LMaxValue := LPair.Key;
end;
end;
CheckEquals(LMaxValue, FFull.MaxValue);
end;
procedure TConformance_IAssociation.Test_MinKey;
var
LPair: TPair<NativeInt, NativeInt>;
LMinKey: NativeInt;
LFirst: Boolean;
begin
CheckException(ECollectionEmptyException,
procedure() begin FEmpty.MinKey end,
'ECollectionEmptyException not thrown in [empty].MinKey()'
);
CheckEquals(FOne.Single.Key, FOne.MinKey);
LFirst := true;
LMinKey := -1;
for LPair in FFull do
begin
if LFirst then
begin
LMinKey := LPair.Key;
LFirst := false;
end else
begin
if LPair.Key < LMinKey then
LMinKey := LPair.Key;
end;
end;
CheckEquals(LMinKey, FFull.MinKey);
end;
procedure TConformance_IAssociation.Test_MinValue;
var
LPair: TPair<NativeInt, NativeInt>;
LMinValue: NativeInt;
LFirst: Boolean;
begin
CheckException(ECollectionEmptyException,
procedure() begin FEmpty.MinValue end,
'ECollectionEmptyException not thrown in [empty].MaxKey()'
);
CheckEquals(FOne.Single.Key, FOne.MinValue);
LFirst := true;
LMinValue := -1;
for LPair in FFull do
begin
if LFirst then
begin
LMinValue := LPair.Value;
LFirst := false;
end else
begin
if LPair.Value < LMinValue then
LMinValue := LPair.Key;
end;
end;
CheckEquals(LMinValue, FFull.MinValue);
end;
procedure TConformance_IAssociation.Test_SelectKeys;
var
LKeys: ISequence<NativeInt>;
LKey: NativeInt;
begin
LKeys := FEmpty.SelectKeys;
CheckTrue(LKeys.Empty);
LKeys := FOne.SelectKeys;
CheckEquals(1, LKeys.Count);
CheckEquals(FOne.Single.Key, LKeys.Single);
LKeys := FFull.SelectKeys;
CheckTrue(LKeys.Count <= FFull.Count);
{TODO: Fix this tests - KeyHasValue method requires two parameters, not one!}
// for LKey in LKeys do
// CheckTrue(FFull.KeyHasValue(LKey));
end;
procedure TConformance_IAssociation.Test_SelectValues;
var
LValues: ISequence<NativeInt>;
LValueSet: ISet<NativeInt>;
LPair: TPair<NativeInt, NativeInt>;
begin
LValues := FEmpty.SelectKeys;
CheckTrue(LValues.Empty);
LValues := FOne.SelectKeys;
CheckEquals(1, LValues.Count);
CheckEquals(FOne.Single.Value, LValues.Single);
LValues := FFull.SelectKeys;
CheckTrue(LValues.Count = FFull.Count);
LValueSet := LValues.ToSet();
for LPair in FFull do
CheckTrue(LValueSet.Contains(LPair.Value));
end;
procedure TConformance_IAssociation.Test_ToDictionary;
begin
Fail('Not implemented!');
end;
procedure TConformance_IAssociation.Test_ValueForKey;
var
LPair: TPair<NativeInt, NativeInt>;
begin
CheckException(EKeyNotFoundException,
procedure() begin FEmpty.ValueForKey(-1); end,
'EKeyNotFoundException not thrown in [empty].ValueForKey()'
);
// NOTE: Fixed parameters to compile
CheckException(EKeyNotFoundException,
procedure() begin FOne.ValueForKey(MinusOne(FOne.Single).Key); end,
'EKeyNotFoundException not thrown in [one].ValueForKey()'
);
// NOTE: Fixed parameters to compile
CheckEquals(FOne.Single.Value, FOne.ValueForKey(FOne.Single.Key));
for LPair in FFull do
// NOTE: Fixed parameters to compile
CheckEquals(LPair.Value, FFull.ValueForKey(LPair.Key));
end;
procedure TConformance_IAssociation.Test_Where;
var
LPredicate: TPredicate<NativeInt, NativeInt>;
LFiltered: IAssociation<NativeInt, NativeInt>;
begin
CheckException(EArgumentNilException,
procedure() begin FEmpty.Where(nil) end,
'EArgumentNilException not thrown in [empty].Where(nil)'
);
CheckException(EArgumentNilException,
procedure() begin FOne.Where(nil) end,
'EArgumentNilException not thrown in [one].Where(nil)'
);
CheckException(EArgumentNilException,
procedure() begin FFull.Where(nil) end,
'EArgumentNilException not thrown in [full].Where(nil)'
);
LPredicate := function(K, V: NativeInt): Boolean begin Exit(False); end;
CheckTrue(FEmpty.Where(LPredicate).Empty);
CheckTrue(FOne.Where(LPredicate).Empty);
CheckTrue(FFull.Where(LPredicate).Empty);
LPredicate := function(K, V: NativeInt): Boolean begin Exit(True); end;
CheckTrue(FEmpty.Where(LPredicate).Empty);
LFiltered := FOne.Where(LPredicate);
CheckTrue(LFiltered.Includes(FOne));
CheckTrue(FOne.Includes(LFiltered));
LFiltered := FFull.Where(LPredicate);
CheckTrue(LFiltered.Includes(FFull));
CheckTrue(FFull.Includes(LFiltered));
end;
procedure TConformance_IAssociation.Test_WhereNot;
var
LPredicate: TPredicate<NativeInt, NativeInt>;
LFiltered: IAssociation<NativeInt, NativeInt>;
begin
CheckException(EArgumentNilException,
procedure() begin FEmpty.WhereNot(nil) end,
'EArgumentNilException not thrown in [empty].Where(nil)'
);
CheckException(EArgumentNilException,
procedure() begin FOne.WhereNot(nil) end,
'EArgumentNilException not thrown in [one].Where(nil)'
);
CheckException(EArgumentNilException,
procedure() begin FFull.WhereNot(nil) end,
'EArgumentNilException not thrown in [full].Where(nil)'
);
LPredicate := function(K, V: NativeInt): Boolean begin Exit(True); end;
CheckTrue(FEmpty.WhereNot(LPredicate).Empty);
CheckTrue(FOne.WhereNot(LPredicate).Empty);
CheckTrue(FFull.WhereNot(LPredicate).Empty);
LPredicate := function(K, V: NativeInt): Boolean begin Exit(False); end;
CheckTrue(FEmpty.WhereNot(LPredicate).Empty);
LFiltered := FOne.WhereNot(LPredicate);
CheckTrue(LFiltered.Includes(FOne));
CheckTrue(FOne.Includes(LFiltered));
LFiltered := FFull.WhereNot(LPredicate);
CheckTrue(LFiltered.Includes(FFull));
CheckTrue(FFull.Includes(LFiltered));
end;
{ TConformance_IMap }
procedure TConformance_IMap.KeyRemoveNotification(const AValue: NativeInt);
begin
if Assigned(FRemovedKeys) then
FRemovedKeys.Add(AValue);
end;
procedure TConformance_IMap.SetUp;
begin
inherited;
FRemovedKeys := Generics.Collections.TList<NativeInt>.Create();
FRemovedValues := Generics.Collections.TList<NativeInt>.Create();
end;
procedure TConformance_IMap.SetUp_IAssociation(out AEmpty, AOne, AFull: IAssociation<NativeInt, NativeInt>;
out APairs: TPairs; out AKeyOrdering: TOrdering);
begin
SetUp_IMap(FEmpty, FOne, FFull, APairs, AKeyOrdering);
AEmpty := FEmpty;
AOne := FOne;
AFull := FFull;
end;
procedure TConformance_IMap.TearDown;
begin
FreeAndNil(FRemovedKeys);
FreeAndNil(FRemovedValues);
inherited;
end;
procedure TConformance_IMap.Test_AddAll;
begin
Fail('Not implemented!');
end;
procedure TConformance_IMap.Test_Add_1;
begin
Fail('Not implemented!');
end;
procedure TConformance_IMap.Test_Add_2;
begin
Fail('Not implemented!');
end;
procedure TConformance_IMap.Test_Clear;
var
LKeyList, LValueList: IList<NativeInt>;
LValue: NativeInt;
LLastVersion: NativeInt;
begin
LLastVersion := FEmpty.Version;
FEmpty.Clear();
CheckEquals(0, FRemovedKeys.Count);
CheckEquals(0, FRemovedValues.Count);
CheckEquals(LLastVersion, FEmpty.Version);
LLastVersion := FOne.Version;
FOne.Clear();
CheckEquals(1, FRemovedKeys.Count);
CheckEquals(1, FRemovedValues.Count);
CheckNotEquals(LLastVersion, FEmpty.Version);
FRemovedKeys.Clear;
FRemovedValues.Clear;
LKeyList := FFull.Keys.ToList();
LValueList := FFull.Values.ToList();
LLastVersion := FFull.Version;
FFull.Clear();
CheckEquals(LKeyList.Count, FRemovedKeys.Count);
CheckEquals(LValueList.Count, FRemovedValues.Count);
CheckNotEquals(LLastVersion, FFull.Version);
for LValue in FRemovedKeys do
begin
CheckTrue(LKeyList.Contains(LValue));
LKeyList.Remove(LValue);
end;
{TODO: Add missing LValueList, work out what this test does, and restore it}
// for LValue in FRemovedValues do
// begin
// CheckTrue(LValuesList.Contains(LValue));
// LValueList.Remove(LValue);
// end;
CheckTrue(LKeyList.Empty);
CheckTrue(LValueList.Empty);
end;
procedure TConformance_IMap.Test_ContainsKey;
begin
Fail('Not implemented!');
end;
procedure TConformance_IMap.Test_ContainsValue;
begin
Fail('Not implemented!');
end;
procedure TConformance_IMap.Test_Remove;
begin
Fail('Not implemented!');
end;
procedure TConformance_IMap.ValueRemoveNotification(const AValue: NativeInt);
begin
if Assigned(FRemovedValues) then
FRemovedValues.Add(AValue);
end;
{ TConformance_IDictionary }
procedure TConformance_IDictionary.SetUp_IMap(out AEmpty, AOne, AFull: IMap<NativeInt, NativeInt>;
out APairs: TPairs; out AKeyOrdering: TOrdering);
begin
SetUp_IDictionary(FEmpty, FOne, FFull, APairs, AKeyOrdering);
AEmpty := FEmpty;
AOne := FOne;
AFull := FFull;
end;
procedure TConformance_IDictionary.Test_Extract;
begin
Fail('Not implemented!');
end;
procedure TConformance_IDictionary.Test_GetValue;
begin
Fail('Not implemented!');
end;
procedure TConformance_IDictionary.Test_SetValue;
begin
Fail('Not implemented!');
end;
procedure TConformance_IDictionary.Test_TryGetValue;
begin
Fail('Not implemented!');
end;
{ TConformance_IBidiDictionary }
procedure TConformance_IBidiDictionary.SetUp_IMap(out AEmpty, AOne, AFull: IMap<NativeInt, NativeInt>;
out APairs: TPairs; out AKeyOrdering: TOrdering);
begin
SetUp_IBidiDictionary(FEmpty, FOne, FFull, APairs, AKeyOrdering);
AEmpty := FEmpty;
AOne := FOne;
AFull := FFull;
end;
procedure TConformance_IBidiDictionary.Test_ContainsPair_1;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiDictionary.Test_ContainsPair_2;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiDictionary.Test_ExtractKeyForValue;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiDictionary.Test_ExtractValueForKey;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiDictionary.Test_GetKeyForValue;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiDictionary.Test_GetValueForKey;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiDictionary.Test_RemoveKeyForValue;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiDictionary.Test_RemovePair_1;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiDictionary.Test_RemovePair_2;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiDictionary.Test_RemoveValueForKey;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiDictionary.Test_SetKeyForValue;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiDictionary.Test_SetValueForKey;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiDictionary.Test_TryGetKeyForValue;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiDictionary.Test_TryGetValueForKey;
begin
Fail('Not implemented!');
end;
{ TConformance_IBidiMap }
procedure TConformance_IBidiMap.SetUp_IMap(out AEmpty, AOne, AFull: IMap<NativeInt, NativeInt>;
out APairs: TPairs; out AKeyOrdering: TOrdering);
begin
SetUp_IBidiMap(FEmpty, FOne, FFull, APairs, AKeyOrdering);
AEmpty := FEmpty;
AOne := FOne;
AFull := FFull;
end;
procedure TConformance_IBidiMap.Test_ContainsPair_1;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiMap.Test_ContainsPair_2;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiMap.Test_GetKeysByValue;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiMap.Test_GetValuesByKey;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiMap.Test_RemoveKeysForValue;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiMap.Test_RemovePair_1;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiMap.Test_RemovePair_2;
begin
Fail('Not implemented!');
end;
procedure TConformance_IBidiMap.Test_RemoveValuesForKey;
begin
Fail('Not implemented!');
end;
{ TConformance_IMultiMap }
procedure TConformance_IMultiMap.SetUp_IMap(out AEmpty, AOne, AFull: IMap<NativeInt, NativeInt>;
out APairs: TPairs; out AKeyOrdering: TOrdering);
begin
SetUp_IMultiMap(FEmpty, FOne, FFull, APairs, AKeyOrdering);
AEmpty := FEmpty;
AOne := FOne;
AFull := FFull;
end;
procedure TConformance_IMultiMap.Test_ContainsPair_1;
begin
Fail('Not implemented!');
end;
procedure TConformance_IMultiMap.Test_ContainsPair_2;
begin
Fail('Not implemented!');
end;
procedure TConformance_IMultiMap.Test_ExtractValues;
begin
Fail('Not implemented!');
end;
procedure TConformance_IMultiMap.Test_GetValues;
begin
Fail('Not implemented!');
end;
procedure TConformance_IMultiMap.Test_RemovePair_1;
begin
Fail('Not implemented!');
end;
procedure TConformance_IMultiMap.Test_RemovePair_2;
begin
Fail('Not implemented!');
end;
procedure TConformance_IMultiMap.Test_TryGetValues_1;
begin
Fail('Not implemented!');
end;
procedure TConformance_IMultiMap.Test_TryGetValues_2;
begin
Fail('Not implemented!');
end;
{ TConformance_IBag }
procedure TConformance_IBag.SetUp_ISet(out AEmpty, AOne, AFull: ISet<NativeInt>;
out AElements: TElements; out AOrdering: TOrdering);
begin
SetUp_IBag(FEmpty, FOne, FFull, AElements, AOrdering);
AEmpty := FEmpty;
AOne := FOne;
AFull := FFull;
end;
procedure TConformance_IBag.Test_AddWeight;
var
LWeight: NativeUInt;
LVersion: NativeInt;
begin
LVersion := FEmpty.Version;
FEmpty.Add(FOne.Single);
CheckEquals(1, FEmpty.Count, 'Expected count to be 1 in [empty]');
CheckNotEquals(LVersion, FEmpty.Version, 'Expected version change in [empty]');
LVersion := FEmpty.Version;
CheckTrue(FEmpty.ContainsWeight(FOne.Single, 1), 'Expected to contain at least a weight of 1 in [empty]');
FEmpty.AddWeight(FOne.Single, 100);
CheckEquals(101, FEmpty.Count, 'Expected count to be 101 in [empty]');
CheckNotEquals(LVersion, FEmpty.Version, 'Expected version change in [empty]');
CheckTrue(FEmpty.ContainsWeight(FOne.Single, 101), 'Expected to contain at least a weight of 101 in [empty]');
LVersion := FOne.Version;
LWeight := FOne.GetWeight(FOne.Single);
FOne.Add(FOne.Single);
CheckEquals(2, FOne.Count, 'Expected count to be 2 in [one]');
CheckNotEquals(LVersion, FOne.Version, 'Expected version change in [onr]');
CheckTrue(FOne.ContainsWeight(FOne.First, LWeight + 1), 'Expected to contain at least a weight of +1 in [one]' );
CheckTrue(FOne.ContainsWeight(FOne.First, LWeight + 2), 'Expected not to contain at least a weight of +2 in [one]' );
CheckEquals(0, RemovedList.Count, 'Did not expect any cleaning!');
end;
procedure TConformance_IBag.Test_ContainsWeight;
var
LValue: NativeInt;
begin
CheckTrue(FEmpty.ContainsWeight(FOne.Single, 0), 'Expected [empty] to contain a weight of zero.');
CheckTrue(FOne.ContainsWeight(FOne.Single, 0), 'Expected [one] to contain a weight of zero.');
CheckTrue(FOne.ContainsWeight(FOne.Single, 1), 'Expected [one] to contain a weight of 1.');
CheckTrue(FOne.ContainsWeight(FOne.Single, 2), 'Not expected [one] to contain a weight of 2.');
FOne.AddWeight(FOne.Single, 1);
CheckTrue(FOne.ContainsWeight(FOne.First, 2), 'Not expected [one] to contain a weight of 2.');
for LValue in FFull do
CheckTrue(FFull.ContainsWeight(LValue, 1), 'Expected [full] to contain the value');
end;
procedure TConformance_IBag.Test_GetWeight;
var
LGroupings: ISequence<IGrouping<NativeInt, NativeInt>>;
LGrouping: IGrouping<NativeInt, NativeInt>;
LValue: NativeInt;
begin
CheckEquals(0, FEmpty.GetWeight(Elements[0]), 'Expected 0 weight in [empty]');
CheckEquals(1, FOne.GetWeight(Elements[0]), 'Expected 1 weight in [one]');
FOne.Add(Elements[0]);
CheckEquals(2, FOne.GetWeight(Elements[0]), 'Expected 2 weight in [one]');
LGroupings := FFull.Distinct.Op.GroupBy<NativeInt>(
function(V: NativeInt): NativeInt begin Result := FFull.GetWeight(V); end);
for LGrouping in LGroupings do
for LValue in LGrouping do
begin
CheckEquals(FFull.GetWeight(LGrouping.Key), LValue);
end;
end;
procedure TConformance_IBag.Test_RemoveAllWeight;
var
LVersion: NativeInt;
LList: IList<NativeInt>;
LValue: NativeInt;
begin
LVersion := FEmpty.Version;
FEmpty.RemoveAllWeight(FOne.Single);
CheckEquals(LVersion, FEmpty.Version, 'Did not expect version change in [empty]');
CheckEquals(0, RemovedList.Count, 'Did not expect any cleaning for [empty]!');
FEmpty.AddWeight(FOne.Single, 100);
LVersion := FEmpty.Version;
CheckEquals(100, FEmpty.Count, 'Expected count to be 100 in [empty]');
FEmpty.RemoveAllWeight(FOne.Single);
CheckEquals(0, FEmpty.Count, 'Expected count to be 0 in [empty]');
CheckEquals(1, RemovedList.Count, 'Expect cleaning for [empty]');
CheckFalse(FEmpty.Contains(FOne.Single), 'Did not expect to contain at least a weight of 1 in [empty]');
CheckNotEquals(LVersion, FEmpty.Version, 'Expected version change in [empty]');
LVersion := FEmpty.Version;
FOne.RemoveAllWeight(FOne.Single);
CheckEquals(1, RemovedList.Count, 'Expected 1 cleaning for [one]!');
CheckEquals(Elements[0], RemovedList[0], 'Expected proper cleaned element for [one]!');
CheckNotEquals(LVersion, FEmpty.Version, 'Expected version change in [one]');
LList := FFull.ToList();
RemovedList.Clear;
for LValue in LList do
FFull.RemoveAllWeight(LValue);
CheckTrue(FFull.Empty, 'Expected fully cleaned [full]!');
CheckEquals(LList.Distinct.Count, RemovedList.Count, 'Expected N cleaning for [full]!');
end;
procedure TConformance_IBag.Test_RemoveWeight;
var
LVersion: NativeInt;
LList: IList<NativeInt>;
LValue: NativeInt;
begin
LVersion := FEmpty.Version;
FEmpty.RemoveWeight(FOne.Single, 1);
CheckEquals(LVersion, FEmpty.Version, 'Did not expect version change in [empty]');
CheckEquals(0, RemovedList.Count, 'Did not expect any cleaning for [empty]!');
FEmpty.AddWeight(FOne.Single, 100);
CheckEquals(100, FEmpty.Count, 'Expected count to be 100 in [empty]');
LVersion := FEmpty.Version;
FEmpty.RemoveWeight(FOne.Single, 99);
CheckEquals(1, FEmpty.Count, 'Expected count to be 1 in [empty]');
CheckEquals(0, RemovedList.Count, 'Did not expect any cleaning for empty!');
CheckTrue(FEmpty.ContainsWeight(FOne.Single, 1), 'Expected to contain at least a weight of 1 in [empty]');
CheckFalse(FEmpty.ContainsWeight(FOne.Single, 2), 'Did not expect to contain at least a weight of 2 in [empty]');
CheckTrue(FEmpty.Contains(FOne.Single), 'Expected to contain at least a weight of 1 in [empty]');
CheckNotEquals(LVersion, FEmpty.Version, 'Expected version change in [empty]');
LVersion := FEmpty.Version;
FEmpty.RemoveWeight(FOne.Single, 100);
CheckEquals(0, FEmpty.Count, 'Expected count to be 0 in [empty]');
CheckEquals(1, RemovedList.Count, 'Expected 1 cleaning for [empty]!');
CheckEquals(FOne.Single, RemovedList[0], 'Expected proper cleaned element for [empty]!');
CheckNotEquals(LVersion, FEmpty.Version, 'Expected version change in [empty]');
LList := FFull.ToList();
RemovedList.Clear;
for LValue in LList do
FFull.RemoveWeight(LValue, 1);
CheckTrue(FFull.Empty, 'Expected fully cleaned [full]!');
CheckEquals(LList.Distinct.Count, RemovedList.Count, 'Expected N cleaning for [full]!');
end;
procedure TConformance_IBag.Test_SetWeight;
var
LList: IList<NativeInt>;
LValue: NativeInt;
begin
FEmpty.SetWeight(FOne.Single, 10);
CheckEquals(10, FEmpty.GetWeight(FOne.Single), 'Expected a weight of 10 for [empty].');
FEmpty.SetWeight(FOne.Single, 0);
CheckEquals(0, FEmpty.GetWeight(FOne.Single), 'Expected a weight of 0 for [empty].');
CheckFalse(FEmpty.Contains(FOne.Single), 'Did not expect [empty] to contain the value.');
RemovedList.Clear;
LList := FFull.Distinct.ToList;
for LValue in LList do
begin
FFull.SetWeight(LValue, 0);
CheckTrue(RemovedList.Contains(LValue), 'Expected value set to 0 to be removed in [full].');
end;
CheckEquals(RemovedList.Count, LList.Count, 'Expected all values to be removed only once in [full]');
end;
{ TConformance_ISet }
procedure TConformance_ISet.SetUp_ICollection(out AEmpty, AOne, AFull: ICollection<NativeInt>;
out AElements: TElements; out AOrdering: TOrdering);
begin
SetUp_ISet(FEmpty, FOne, FFull, AElements, AOrdering);
AEmpty := FEmpty;
AOne := FOne;
AFull := FFull;
end;
end.
| 34.614245 | 181 | 0.712661 |
f1986839834c7383c4cc0de617061777eb5e6fc8
| 200 |
pas
|
Pascal
|
Test/SimpleScripts/array_range1.pas
|
skolkman/dwscript
|
b9f99d4b8187defac3f3713e2ae0f7b83b63d516
|
[
"Condor-1.1"
] | 79 |
2015-03-18T10:46:13.000Z
|
2022-03-17T18:05:11.000Z
|
Test/SimpleScripts/array_range1.pas
|
skolkman/dwscript
|
b9f99d4b8187defac3f3713e2ae0f7b83b63d516
|
[
"Condor-1.1"
] | 6 |
2016-03-29T14:39:00.000Z
|
2020-09-14T10:04:14.000Z
|
Test/SimpleScripts/array_range1.pas
|
skolkman/dwscript
|
b9f99d4b8187defac3f3713e2ae0f7b83b63d516
|
[
"Condor-1.1"
] | 25 |
2016-05-04T13:11:38.000Z
|
2021-09-29T13:34:31.000Z
|
var a : array of integer = [1..5];
for var i in a do Print(i);
a := [5..1];
for var i in a do Print(i);
PrintLn('');
a := [1..3, 5, 3..1];
for var i in a do Print(i);
PrintLn('');
| 13.333333 | 35 | 0.485 |
61ef2d389b87897411a1fda67a2334dcff8ec461
| 13,486 |
pas
|
Pascal
|
ZenGL/ZenGL_DX8/src/zgl_render_target.pas
|
farisss/penuhi-gizi
|
9c1032aff4799dd91e7b68b0d476d1f889da6877
|
[
"MIT"
] | null | null | null |
ZenGL/ZenGL_DX8/src/zgl_render_target.pas
|
farisss/penuhi-gizi
|
9c1032aff4799dd91e7b68b0d476d1f889da6877
|
[
"MIT"
] | 1 |
2018-06-24T06:38:48.000Z
|
2018-06-24T06:38:48.000Z
|
ZenGL/ZenGL_DX9/src/zgl_render_target.pas
|
farisss/penuhi-gizi
|
9c1032aff4799dd91e7b68b0d476d1f889da6877
|
[
"MIT"
] | null | null | null |
{
* Copyright (c) 2012 Andrey Kemka
*
* This software is provided 'as-is', without any express or
* implied warranty. In no event will the authors be held
* liable for any damages arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute
* it freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented;
* you must not claim that you wrote the original software.
* If you use this software in a product, an acknowledgment
* in the product documentation would be appreciated but
* is not required.
*
* 2. Altered source versions must be plainly marked as such,
* and must not be misrepresented as being the original software.
*
* 3. This notice may not be removed or altered from any
* source distribution.
}
unit zgl_render_target;
{$I zgl_config.cfg}
interface
uses
Windows,
{$IFDEF USE_DIRECT3D8}
DirectXGraphics,
{$ENDIF}
{$IFDEF USE_DIRECT3D9}
Direct3D9,
{$ENDIF}
zgl_direct3d,
zgl_direct3d_all,
zgl_textures;
const
RT_DEFAULT = $00;
RT_FULL_SCREEN = $01;
RT_USE_DEPTH = $02;
RT_CLEAR_COLOR = $04;
RT_CLEAR_DEPTH = $08;
RT_SAVE_CONTENT = $10;
type
zglPD3DTarget = ^zglTD3DTarget;
zglTD3DTarget = record
Old : zglPTexture;
{$IFDEF USE_DIRECT3D8}
Depth : IDirect3DSurface8;
{$ENDIF}
{$IFDEF USE_DIRECT3D9}
Depth : IDirect3DSurface9;
{$ENDIF}
end;
type
zglPRenderTarget = ^zglTRenderTarget;
zglTRenderTarget = record
Type_ : Byte;
Handle : zglPD3DTarget;
Surface : zglPTexture;
Flags : Byte;
prev, next : zglPRenderTarget;
end;
type
zglPRenderTargetManager = ^zglTRenderTargetManager;
zglTRenderTargetManager = record
Count : Integer;
First : zglTRenderTarget;
end;
type
zglTRenderCallback = procedure( Data : Pointer );
function rtarget_Add( Surface : zglPTexture; Flags : Byte ) : zglPRenderTarget;
procedure rtarget_Del( var Target : zglPRenderTarget );
procedure rtarget_Set( Target : zglPRenderTarget );
procedure rtarget_DrawIn( Target : zglPRenderTarget; RenderCallback : zglTRenderCallback; Data : Pointer );
procedure rtarget_Save( Target : zglPTexture );
procedure rtarget_Restore( Target : zglPTexture );
var
managerRTarget : zglTRenderTargetManager;
implementation
uses
zgl_main,
zgl_application,
zgl_screen,
zgl_render,
zgl_render_2d,
zgl_camera_2d,
zgl_types;
var
lCanDraw : Boolean;
lRTarget : zglPRenderTarget;
{$IFDEF USE_DIRECT3D8}
lSurface : IDirect3DSurface8;
{$ENDIF}
{$IFDEF USE_DIRECT3D9}
lSurface : IDirect3DSurface9;
{$ENDIF}
lGLW : Integer;
lGLH : Integer;
lResCX : Single;
lResCY : Single;
procedure rtarget_Save( Target : zglPTexture );
var
s, d : TD3DSurface_Desc;
{$IFDEF USE_DIRECT3D8}
src, dst : IDirect3DSurface8;
{$ENDIF}
{$IFDEF USE_DIRECT3D9}
src : IDirect3DSurface9;
{$ENDIF}
begin
{$IFDEF USE_DIRECT3D8}
d3dTexArray[ Target.ID ].Texture.GetLevelDesc( 0, d );
if Assigned( d3dResArray[ Target.ID ] ) Then
begin
d3dResArray[ Target.ID ].GetLevelDesc( 0, s );
if ( s.Width < d.Width ) or ( s.Height < d.Height ) or ( s.Format <> d.Format ) Then
d3dResArray[ Target.ID ] := nil;
end;
if not Assigned( d3dResArray[ Target.ID ] ) Then
d3dDevice.CreateTexture( d.Width, d.Height, 1, 0, d.Format, D3DPOOL_MANAGED, d3dResArray[ Target.ID ] );
d3dTexArray[ Target.ID ].Texture.GetSurfaceLevel( 0, src );
d3dResArray[ Target.ID ].GetSurfaceLevel( 0, dst );
d3dDevice.CopyRects( src, nil, 0, dst, nil );
src := nil;
dst := nil;
{$ENDIF}
{$IFDEF USE_DIRECT3D9}
d3dTexArray[ Target.ID ].Texture.GetLevelDesc( 0, d );
if Assigned( d3dResArray[ Target.ID ] ) Then
begin
d3dResArray[ Target.ID ].GetDesc( s );
if ( s.Width < d.Width ) or ( s.Height < d.Height ) or ( s.Format <> d.Format ) Then
d3dResArray[ Target.ID ] := nil;
end;
if not Assigned( d3dResArray[ Target.ID ] ) Then
d3dDevice.CreateOffscreenPlainSurface( d.Width, d.Height, d.Format, D3DPOOL_SYSTEMMEM, d3dResArray[ Target.ID ], nil );
d3dTexArray[ Target.ID ].Texture.GetSurfaceLevel( 0, src );
d3dDevice.GetRenderTargetData( src, d3dResArray[ Target.ID ] );
src := nil;
{$ENDIF}
end;
procedure rtarget_Restore( Target : zglPTexture );
var
{$IFDEF USE_DIRECT3D8}
src, dst : IDirect3DSurface8;
{$ENDIF}
{$IFDEF USE_DIRECT3D9}
dst : IDirect3DSurface9;
{$ENDIF}
begin
if not Assigned( d3dResArray[ Target.ID ] ) Then exit;
{$IFDEF USE_DIRECT3D8}
d3dTexArray[ Target.ID ].Texture.GetSurfaceLevel( 0, dst );
d3dResArray[ Target.ID ].GetSurfaceLevel( 0, src );
d3dDevice.CopyRects( src, nil, 0, dst, nil );
src := nil;
dst := nil;
{$ENDIF}
{$IFDEF USE_DIRECT3D9}
d3dTexArray[ Target.ID ].Texture.GetSurfaceLevel( 0, dst );
d3dDevice.UpdateSurface( d3dResArray[ Target.ID ], nil, dst, nil );
dst := nil;
{$ENDIF}
end;
function rtarget_Add( Surface : zglPTexture; Flags : Byte ) : zglPRenderTarget;
var
data : PByteArray;
begin
Result := @managerRTarget.First;
while Assigned( Result.Next ) do
Result := Result.Next;
zgl_GetMem( Pointer( Result.Next ), SizeOf( zglTRenderTarget ) );
zgl_GetMem( Pointer( Result.Next.Handle ), SizeOf( zglTD3DTarget ) );
tex_GetData( Surface, data );
d3dTexArray[ Surface.ID ].Texture := nil;
{$IFDEF USE_DIRECT3D8}
d3dDevice.CreateTexture( Round( Surface.Width / Surface.U ), Round( Surface.Height / Surface.V ), 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT,
d3dTexArray[ Surface.ID ].Texture );
if Flags and RT_USE_DEPTH > 0 Then
d3dDevice.CreateDepthStencilSurface( Round( Surface.Width / Surface.U ), Round( Surface.Height / Surface.V ), d3dParams.AutoDepthStencilFormat,
D3DMULTISAMPLE_NONE, Result.Next.Handle.Depth );
{$ENDIF}
{$IFDEF USE_DIRECT3D9}
d3dDevice.CreateTexture( Round( Surface.Width / Surface.U ), Round( Surface.Height / Surface.V ), 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT,
d3dTexArray[ Surface.ID ].Texture, nil );
if Flags and RT_USE_DEPTH > 0 Then
d3dDevice.CreateDepthStencilSurface( Round( Surface.Width / Surface.U ), Round( Surface.Height / Surface.V ), d3dParams.AutoDepthStencilFormat,
D3DMULTISAMPLE_NONE, 0, TRUE, Result.Next.Handle.Depth, nil );
{$ENDIF}
d3dTexArray[ Surface.ID ].Pool := D3DPOOL_DEFAULT;
Surface.Width := Round( Surface.Width / Surface.U );
Surface.Height := Round( Surface.Height / Surface.V );
tex_SetData( Surface, data, 0, 0, Surface.Width, Surface.Height );
Surface.Width := Round( Surface.Width * Surface.U );
Surface.Height := Round( Surface.Height * Surface.V );
zgl_FreeMem( Pointer( data ) );
Result.next.Type_ := 0;
Result.next.Handle.Old := Surface;
Result.next.Surface := Surface;
Result.next.Flags := Flags;
Result.next.prev := Result;
Result.next.next := nil;
Result := Result.next;
INC( managerRTarget.Count );
end;
procedure rtarget_Del( var Target : zglPRenderTarget );
begin
if not Assigned( Target ) Then exit;
tex_Del( Target.Surface );
if Assigned( Target.prev ) Then
Target.prev.next := Target.next;
if Assigned( Target.Next ) Then
Target.next.prev := Target.prev;
Target.Handle.Depth := nil;
FreeMem( Target.Handle );
FreeMem( Target );
Target := nil;
DEC( managerRTarget.Count );
end;
procedure rtarget_Set( Target : zglPRenderTarget );
var
d : TD3DSurface_Desc;
begin
batch2d_Flush();
if Assigned( Target ) Then
begin
lCanDraw := d3dCanDraw;
d3d_BeginScene();
lRTarget := Target;
lGLW := oglWidth;
lGLH := oglHeight;
lResCX := scrResCX;
lResCY := scrResCY;
if {$IFDEF USE_DIRECT3D9} ( not d3dCanD3DEx ) and {$ENDIF} ( Target.Surface <> Target.Handle.Old ) Then
begin
d3dTexArray[ Target.Surface.ID ].Texture.GetLevelDesc( 0, d );
if d.Pool <> D3DPOOL_DEFAULT Then
begin
Target.Handle.Old := Target.Surface;
rtarget_Save( Target.Surface );
d3dTexArray[ Target.Surface.ID ].Texture := nil;
Target.Handle.Depth := nil;
{$IFDEF USE_DIRECT3D8}
d3dDevice.CreateTexture( d.Width, d.Height, 1, D3DUSAGE_RENDERTARGET, d.Format, D3DPOOL_DEFAULT, d3dTexArray[ Target.Surface.ID ].Texture );
if Target.Flags and RT_USE_DEPTH > 0 Then
d3dDevice.CreateDepthStencilSurface( d.Width, d.Height, d3dParams.AutoDepthStencilFormat, D3DMULTISAMPLE_NONE, Target.Handle.Depth );
{$ENDIF}
{$IFDEF USE_DIRECT3D9}
d3dDevice.CreateTexture( d.Width, d.Height, 1, D3DUSAGE_RENDERTARGET, d.Format, D3DPOOL_DEFAULT, d3dTexArray[ Target.Surface.ID ].Texture, nil );
if Target.Flags and RT_USE_DEPTH > 0 Then
d3dDevice.CreateDepthStencilSurface( d.Width, d.Height, d3dParams.AutoDepthStencilFormat, D3DMULTISAMPLE_NONE, 0, TRUE, Target.Handle.Depth,
nil );
{$ENDIF}
d3dTexArray[ Target.Surface.ID ].Pool := D3DPOOL_DEFAULT;
rtarget_Restore( Target.Surface );
end;
end;
{$IFDEF USE_DIRECT3D8}
d3dDevice.GetRenderTarget( d3dSurface );
d3dDevice.GetDepthStencilSurface( d3dStencil );
d3dTexArray[ Target.Surface.ID ].Texture.GetSurfaceLevel( 0, lSurface );
if Target.Flags and RT_USE_DEPTH > 0 Then
d3dDevice.SetRenderTarget( lSurface, Target.Handle.Depth )
else
d3dDevice.SetRenderTarget( lSurface, nil );
{$ENDIF}
{$IFDEF USE_DIRECT3D9}
d3dDevice.GetDepthStencilSurface( d3dStencil );
d3dDevice.GetRenderTarget( 0, d3dSurface );
d3dTexArray[ Target.Surface.ID ].Texture.GetSurfaceLevel( 0, lSurface );
d3dDevice.SetRenderTarget( 0, lSurface );
if Target.Flags and RT_USE_DEPTH > 0 Then
d3dDevice.SetDepthStencilSurface( Target.Handle.Depth )
else
d3dDevice.SetDepthStencilSurface( nil );
{$ENDIF}
{$IFDEF USE_DIRECT3D8}
if Target.Flags and RT_FULL_SCREEN > 0 Then
begin
ScissorScaleX := oglTargetW / Target.Surface.Width;
ScissorScaleY := oglTargetH / Target.Surface.Height;
end else
begin
ScissorScaleX := 1;
ScissorScaleY := 1;
end;
{$ENDIF}
oglTarget := TARGET_TEXTURE;
oglTargetW := Target.Surface.Width;
oglTargetH := Target.Surface.Height;
if Target.Flags and RT_FULL_SCREEN > 0 Then
begin
if appFlags and CORRECT_RESOLUTION > 0 Then
begin
oglWidth := scrResW;
oglHeight := scrResH;
end;
end else
begin
oglWidth := Target.Surface.Width;
oglHeight := Target.Surface.Height;
scrResCX := 1;
scrResCY := 1;
end;
SetCurrentMode();
if Target.Flags and RT_CLEAR_COLOR > 0 Then
d3dDevice.Clear( 0, nil, D3DCLEAR_TARGET, D3DCOLOR_ARGB( 0, 0, 0, 0 ), 1, 0 );
if Target.Flags and RT_CLEAR_DEPTH > 0 Then
d3dDevice.Clear( 0, nil, D3DCLEAR_ZBUFFER, D3DCOLOR_ARGB( 0, 0, 0, 0 ), 1, 0 );
end else
if Assigned( lRTarget ) Then
begin
{$IFDEF USE_DIRECT3D8}
d3dDevice.SetRenderTarget( d3dSurface, d3dStencil );
{$ENDIF}
{$IFDEF USE_DIRECT3D9}
d3dDevice.SetRenderTarget( 0, d3dSurface );
d3dDevice.SetDepthStencilSurface( d3dStencil );
{$ENDIF}
lSurface := nil;
d3dSurface := nil;
d3dStencil := nil;
if {$IFDEF USE_DIRECT3D9} ( not d3dCanD3DEx ) and {$ENDIF} ( lRTarget.Flags and RT_SAVE_CONTENT > 0 ) Then
rtarget_Save( lRTarget.Surface );
oglTarget := TARGET_SCREEN;
oglWidth := lGLW;
oglHeight := lGLH;
oglTargetW := oglWidth;
oglTargetH := oglHeight;
if lRTarget.Flags and RT_FULL_SCREEN = 0 Then
begin
scrResCX := lResCX;
scrResCY := lResCY;
end;
lRTarget := nil;
SetCurrentMode();
if not lCanDraw then
d3d_EndScene();
end;
end;
procedure rtarget_DrawIn( Target : zglPRenderTarget; RenderCallback : zglTRenderCallback; Data : Pointer );
begin
if oglSeparate Then
begin
rtarget_Set( Target );
RenderCallback( Data );
rtarget_Set( nil );
end else
begin
rtarget_Set( Target );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE );
RenderCallback( Data );
batch2d_Flush();
glBlendFunc( GL_ONE, GL_ONE_MINUS_SRC_ALPHA );
glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE );
RenderCallback( Data );
rtarget_Set( nil );
glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );
glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
end;
end;
end.
| 32.73301 | 159 | 0.644965 |
47188ce35413b9c8ae8f23fecc500a64fe943541
| 48,242 |
pas
|
Pascal
|
src/gui-classic/UGridUtils.pas
|
lunatictac/PascalCash
|
2d52d0e4a98da51185b561df03ba225128e79f51
|
[
"MIT"
] | null | null | null |
src/gui-classic/UGridUtils.pas
|
lunatictac/PascalCash
|
2d52d0e4a98da51185b561df03ba225128e79f51
|
[
"MIT"
] | null | null | null |
src/gui-classic/UGridUtils.pas
|
lunatictac/PascalCash
|
2d52d0e4a98da51185b561df03ba225128e79f51
|
[
"MIT"
] | 1 |
2022-01-16T12:31:15.000Z
|
2022-01-16T12:31:15.000Z
|
unit UGridUtils;
{ Copyright (c) 2016 by Albert Molina
Distributed under the MIT software license, see the accompanying file LICENSE
or visit http://www.opensource.org/licenses/mit-license.php.
This unit is a part of the PascalCoin Project, an infinitely scalable
cryptocurrency. Find us here:
Web: https://pascalcoin.org
Source: https://github.com/PascalCoin/PascalCoin
If you like it, consider a donation using Bitcoin:
16K3HCZRhFUtM8GdWRcfKeaa6KsuyxZaYk
THIS LICENSE HEADER MUST NOT BE REMOVED.
}
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}
interface
{$I ../config.inc}
uses
{$IFnDEF FPC}
Windows,
{$ELSE}
LCLIntf, LCLType, LMessages,
{$ENDIF}
Classes, Grids, UNode, UAccounts, UBlockChain, UAppParams,
UWallet, UCrypto, UPoolMining, URPC;
Type
// TAccountsGrid implements a visual integration of TDrawGrid
// to show accounts information
TAccountColumnType = (act_account_number,act_account_key,act_balance,act_updated,act_n_operation,act_updated_state,act_name,act_type,act_saleprice);
TAccountColumn = Record
ColumnType : TAccountColumnType;
width : Integer;
End;
TAccountsGrid = Class(TComponent)
private
FAccountsBalance : Int64;
FAccountsList : TOrderedCardinalList;
FColumns : Array of TAccountColumn;
FDrawGrid : TDrawGrid;
FNodeNotifyEvents : TNodeNotifyEvents;
FShowAllAccounts: Boolean;
FOnUpdated: TNotifyEvent;
FAccountsCount: Integer;
FAllowMultiSelect: Boolean;
procedure SetDrawGrid(const Value: TDrawGrid);
Procedure InitGrid;
Procedure OnNodeNewOperation(Sender : TObject);
procedure OnGridDrawCell(Sender: TObject; ACol, ARow: Longint; Rect: TRect; State: TGridDrawState);
procedure SetNode(const Value: TNode);
function GetNode: TNode;
procedure SetShowAllAccounts(const Value: Boolean);
procedure SetAllowMultiSelect(const Value: Boolean);
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); Override;
public
Constructor Create(AOwner : TComponent); override;
Destructor Destroy; override;
Property DrawGrid : TDrawGrid read FDrawGrid write SetDrawGrid;
Function LockAccountsList : TOrderedCardinalList;
Procedure UnlockAccountsList;
Property Node : TNode read GetNode write SetNode;
Function AccountNumber(GridRow : Integer) : Int64;
Procedure SaveToStream(Stream : TStream);
Procedure LoadFromStream(Stream : TStream);
Property ShowAllAccounts : Boolean read FShowAllAccounts write SetShowAllAccounts;
Property AccountsBalance : Int64 read FAccountsBalance;
Property AccountsCount : Integer read FAccountsCount;
Function MoveRowToAccount(nAccount : Cardinal) : Boolean;
Property OnUpdated : TNotifyEvent read FOnUpdated write FOnUpdated;
Property AllowMultiSelect : Boolean read FAllowMultiSelect write SetAllowMultiSelect;
Function SelectedAccounts(accounts : TOrderedCardinalList) : Integer;
End;
TOperationsGrid = Class(TComponent)
private
FDrawGrid: TDrawGrid;
FAccountNumber: Int64;
FOperationsResume : TOperationsResumeList;
FNodeNotifyEvents : TNodeNotifyEvents;
FPendingOperations: Boolean;
FBlockStart: Int64;
FBlockEnd: Int64;
FMustShowAlwaysAnAccount: Boolean;
Procedure OnNodeNewOperation(Sender : TObject);
Procedure OnNodeNewAccount(Sender : TObject);
Procedure InitGrid;
procedure OnGridDrawCell(Sender: TObject; ACol, ARow: Longint; Rect: TRect; State: TGridDrawState);
procedure SetDrawGrid(const Value: TDrawGrid);
procedure SetAccountNumber(const Value: Int64);
procedure SetNode(const Value: TNode);
function GetNode: TNode;
procedure SetPendingOperations(const Value: Boolean);
procedure SetBlockEnd(const Value: Int64);
procedure SetBlockStart(const Value: Int64);
procedure SetMustShowAlwaysAnAccount(const Value: Boolean);
function GetSelectedOperation : TOperationResume;
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); Override;
public
property SelectedOperation : TOperationResume read GetSelectedOperation;
Constructor Create(AOwner : TComponent); override;
Destructor Destroy; override;
Property DrawGrid : TDrawGrid read FDrawGrid write SetDrawGrid;
Property PendingOperations : Boolean read FPendingOperations write SetPendingOperations;
Property AccountNumber : Int64 read FAccountNumber write SetAccountNumber;
Property MustShowAlwaysAnAccount : Boolean read FMustShowAlwaysAnAccount write SetMustShowAlwaysAnAccount;
Property Node : TNode read GetNode write SetNode;
Procedure UpdateAccountOperations; virtual;
Procedure ShowModalDecoder(WalletKeys: TWalletKeys; AppParams : TAppParams);
Property BlockStart : Int64 read FBlockStart write SetBlockStart;
Property BlockEnd : Int64 read FBlockEnd write SetBlockEnd;
Procedure SetBlocks(bstart,bend : Int64);
Property OperationsResume : TOperationsResumeList read FOperationsResume;
End;
TBlockChainData = Record
Block : Cardinal;
Timestamp : Cardinal;
BlockProtocolVersion,
BlockProtocolAvailable : Word;
OperationsCount : Integer;
Volume : Int64;
Reward, Fee : Int64;
Target : Cardinal;
HashRateTargetKhs : Int64;
HashRateKhs : Int64;
MinerPayload : TRawBytes;
PoW : TRawBytes;
SafeBoxHash : TRawBytes;
AccumulatedWork : UInt64;
TimeAverage200 : Real;
TimeAverage150 : Real;
TimeAverage100 : Real;
TimeAverage75 : Real;
TimeAverage50 : Real;
TimeAverage25 : Real;
TimeAverage10 : Real;
End;
TBlockChainDataArray = Array of TBlockChainData;
{ TBlockChainGrid }
TShowHashRateAs = (hr_Kilo, hr_Mega, hr_Giga, hr_Tera, hr_Peta, hr_Exa);
TBlockChainGrid = Class(TComponent)
private
FBlockChainDataArray : TBlockChainDataArray;
FBlockStart: Int64;
FHashRateAs: TShowHashRateAs;
FMaxBlocks: Integer;
FBlockEnd: Int64;
FDrawGrid: TDrawGrid;
FNodeNotifyEvents : TNodeNotifyEvents;
FHashRateAverageBlocksCount: Integer;
FShowTimeAverageColumns: Boolean;
Procedure OnNodeNewAccount(Sender : TObject);
Procedure InitGrid;
procedure OnGridDrawCell(Sender: TObject; ACol, ARow: Longint; Rect: TRect; State: TGridDrawState);
function GetNode: TNode;
procedure SetBlockEnd(const Value: Int64);
procedure SetBlockStart(const Value: Int64);
procedure SetDrawGrid(const Value: TDrawGrid);
procedure SetHashRateAs(AValue: TShowHashRateAs);
procedure SetMaxBlocks(const Value: Integer);
procedure SetNode(const Value: TNode);
procedure SetHashRateAverageBlocksCount(const Value: Integer);
procedure SetShowTimeAverageColumns(AValue: Boolean);
public
protected
procedure Notification(AComponent: TComponent; Operation: TOperation); Override;
public
Constructor Create(AOwner : TComponent); override;
Destructor Destroy; override;
Property DrawGrid : TDrawGrid read FDrawGrid write SetDrawGrid;
Property Node : TNode read GetNode write SetNode;
Procedure UpdateBlockChainGrid; virtual;
Property BlockStart : Int64 read FBlockStart write SetBlockStart;
Property BlockEnd : Int64 read FBlockEnd write SetBlockEnd;
Procedure SetBlocks(bstart,bend : Int64);
Property MaxBlocks : Integer read FMaxBlocks write SetMaxBlocks;
Property HashRateAverageBlocksCount : Integer read FHashRateAverageBlocksCount write SetHashRateAverageBlocksCount;
Property ShowTimeAverageColumns : Boolean read FShowTimeAverageColumns write SetShowTimeAverageColumns;
Property HashRateAs : TShowHashRateAs read FHashRateAs write SetHashRateAs;
End;
Const
CT_TBlockChainData_NUL : TBlockChainData = (Block:0;Timestamp:0;BlockProtocolVersion:0;BlockProtocolAvailable:0;OperationsCount:-1;Volume:-1;Reward:0;Fee:0;Target:0;HashRateTargetKhs:0;HashRateKhs:0;MinerPayload:'';PoW:'';SafeBoxHash:'';AccumulatedWork:0;TimeAverage200:0;TimeAverage150:0;TimeAverage100:0;TimeAverage75:0;TimeAverage50:0;TimeAverage25:0;TimeAverage10:0);
implementation
uses
Graphics, SysUtils, UTime, UOpTransaction, UConst,
UFRMPayloadDecoder, ULog;
{ TAccountsGrid }
Const CT_ColumnHeader : Array[TAccountColumnType] Of String =
('Account N.','Key','Balance','Updated','N Op.','S','Name','Type','Price');
function TAccountsGrid.AccountNumber(GridRow: Integer): Int64;
begin
if GridRow<1 then Result := -1
else if FShowAllAccounts then begin
if Assigned(Node) then begin
Result := GridRow-1;
end else Result := -1;
end else if GridRow<=FAccountsList.Count then begin
Result := (FAccountsList.Get(GridRow-1));
end else Result := -1;
end;
constructor TAccountsGrid.Create(AOwner: TComponent);
Var i : Integer;
begin
inherited;
FAllowMultiSelect := false;
FOnUpdated := Nil;
FAccountsBalance := 0;
FAccountsCount := 0;
FShowAllAccounts := false;
FAccountsList := TOrderedCardinalList.Create;
FDrawGrid := Nil;
SetLength(FColumns,7);
FColumns[0].ColumnType := act_account_number;
FColumns[0].width := 65;
FColumns[1].ColumnType := act_name;
FColumns[1].width := 80;
FColumns[2].ColumnType := act_balance;
FColumns[2].width := 80;
FColumns[3].ColumnType := act_n_operation;
FColumns[3].width := 40;
FColumns[4].ColumnType := act_type;
FColumns[4].width := 40;
FColumns[5].ColumnType := act_saleprice;
FColumns[5].width := 45;
FColumns[6].ColumnType := act_updated_state;
FColumns[6].width := 25;
FNodeNotifyEvents := TNodeNotifyEvents.Create(Self);
FNodeNotifyEvents.OnOperationsChanged := OnNodeNewOperation;
end;
destructor TAccountsGrid.Destroy;
begin
FNodeNotifyEvents.Free;
FAccountsList.Free;
inherited;
end;
function TAccountsGrid.GetNode: TNode;
begin
Result := FNodeNotifyEvents.Node;
end;
procedure TAccountsGrid.InitGrid;
Var i : Integer;
acc : TAccount;
begin
FAccountsBalance := 0;
FAccountsCount := FAccountsList.Count;
if Not assigned(DrawGrid) then exit;
if FShowAllAccounts then begin
if Assigned(Node) then begin
if Node.Bank.AccountsCount<1 then DrawGrid.RowCount := 2
else DrawGrid.RowCount := Node.Bank.AccountsCount+1;
FAccountsBalance := Node.Bank.SafeBox.TotalBalance;
end else DrawGrid.RowCount := 2;
end else begin
if FAccountsList.Count<1 then DrawGrid.RowCount := 2
else DrawGrid.RowCount := FAccountsList.Count+1;
if Assigned(Node) then begin
for i := 0 to FAccountsList.Count - 1 do begin
acc := Node.Bank.SafeBox.Account( FAccountsList.Get(i) );
inc(FAccountsBalance, acc.balance);
end;
end;
end;
DrawGrid.FixedRows := 1;
if Length(FColumns)=0 then DrawGrid.ColCount := 1
else DrawGrid.ColCount := Length(FColumns);
DrawGrid.FixedCols := 0;
for i := low(FColumns) to high(FColumns) do begin
DrawGrid.ColWidths[i] := FColumns[i].width;
end;
FDrawGrid.DefaultRowHeight := 18;
DrawGrid.Options := [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine,
{goRangeSelect, }goDrawFocusSelected, {goRowSizing, }goColSizing, {goRowMoving,}
{goColMoving, goEditing, }goTabs, goRowSelect, {goAlwaysShowEditor,}
goThumbTracking{$IFnDEF FPC}, goFixedColClick, goFixedRowClick, goFixedHotTrack{$ENDIF}];
if FAllowMultiSelect then DrawGrid.Options := DrawGrid.Options + [goRangeSelect];
FDrawGrid.Invalidate;
if Assigned(FOnUpdated) then FOnUpdated(Self);
end;
procedure TAccountsGrid.LoadFromStream(Stream: TStream);
Var c,i,j : Integer;
begin
if Stream.Read(c,sizeof(c))<sizeof(c) then exit;
if c<=0 then exit;
SetLength(FColumns,c);
for i := 0 to c - 1 do begin
Stream.Read(j,sizeof(j));
if (j>=Integer(Low(TAccountColumnType))) And (j<=Integer(High(TAccountColumnType))) then begin
FColumns[i].ColumnType := TAccountColumnType(j);
end else FColumns[i].ColumnType := act_account_number;
Stream.Read(FColumns[i].width,sizeof(FColumns[i].width));
end;
Stream.Read(j,sizeof(j));
If Assigned(FDrawGrid) then FDrawGrid.Width := j;
Stream.Read(j,sizeof(j));
If Assigned(FDrawGrid) then FDrawGrid.Height := j;
end;
function TAccountsGrid.LockAccountsList: TOrderedCardinalList;
begin
Result := FAccountsList;
end;
function TAccountsGrid.MoveRowToAccount(nAccount: Cardinal): Boolean;
Var oal : TOrderedCardinalList;
idx : Integer;
begin
Result := false;
if Not Assigned(FDrawGrid) then exit;
if Not Assigned(Node) then exit;
if FDrawGrid.RowCount<=1 then exit;
if FShowAllAccounts then begin
If (FDrawGrid.RowCount>nAccount+1) And (nAccount>=0) And (nAccount<Node.Bank.AccountsCount) then begin
FDrawGrid.Row := nAccount+1;
Result := true;
end else begin
FDrawGrid.Row := FDrawGrid.RowCount-1;
end;
end else begin
oal := LockAccountsList;
try
If oal.Find(nAccount,idx) then begin
If FDrawGrid.RowCount>idx+1 then begin
FDrawGrid.Row := idx+1;
Result := true;
end else begin
FDrawGrid.Row := FDrawGrid.RowCount-1;
end;
end else begin
If FDrawGrid.RowCount>idx+1 then begin
FDrawGrid.Row := idx+1;
end else begin
FDrawGrid.Row := FDrawGrid.RowCount-1;
end;
end;
finally
UnlockAccountsList;
end;
end;
end;
procedure TAccountsGrid.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if Operation=opRemove then begin
if (AComponent=FDrawGrid) then begin
SetDrawGrid(Nil);
end;
end;
end;
{$IFDEF FPC}
Type
TTextFormats = (tfBottom, tfCalcRect, tfCenter, tfEditControl, tfEndEllipsis,
tfPathEllipsis, tfExpandTabs, tfExternalLeading, tfLeft, tfModifyString,
tfNoClip, tfNoPrefix, tfRight, tfRtlReading, tfSingleLine, tfTop,
tfVerticalCenter, tfWordBreak);
TTextFormat = set of TTextFormats;
Procedure Canvas_TextRect(Canvas : TCanvas; var Rect: TRect; var Text: string; State: TGridDrawState; TextFormat: TTextFormat = []);
Var ts : TTextStyle;
Begin
if (tfRight in TextFormat) then ts.Alignment:=taRightJustify
else if (tfCenter in TextFormat) then ts.Alignment:=taCenter
else ts.Alignment:=taLeftJustify;
if (tfWordBreak in TextFormat) then ts.Wordbreak:=true
else ts.Wordbreak:=false;
if (tfVerticalCenter in TextFormat) then ts.Layout:=tlCenter
else if (tfBottom in TextFormat) then ts.Layout:=tlBottom
else ts.Layout:=tlTop;
ts.Clipping:=Not (tfNoClip in TextFormat);
ts.SingleLine := (tfSingleLine in TextFormat);
ts.Wordbreak:= (tfWordBreak in TextFormat);
ts.EndEllipsis:= (tfEndEllipsis in TextFormat);
ts.ExpandTabs:=false;
ts.Opaque:=false;
ts.ShowPrefix:= not (tfNoPrefix in TextFormat);
ts.SystemFont:=false;
Canvas.TextRect(Rect,Rect.Left,Rect.Top,Text,ts);
end;
{$ELSE}
Procedure Canvas_TextRect(Canvas : TCanvas; var Rect: TRect; var Text: string; State: TGridDrawState; TextFormat: TTextFormat = []);
Begin
Canvas.TextRect(Rect,Text,TextFormat);
end;
{$ENDIF}
procedure TAccountsGrid.OnGridDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
Function FromColorToColor(colorstart,colordest : Integer; step,totalsteps : Integer) : Integer;
var sr,sg,sb,dr,dg,db : Byte;
i : Integer;
begin
i := colorstart;
sr := GetRValue(i);
sg := GetGValue(i);
sb := GetBValue(i);
i := colordest;
dr := GetRValue(i);
dg := GetGValue(i);
db := GetBValue(i);
sr := sr + (((dr-sr) DIV totalsteps)*step);
sg := sg + (((dg-sg) DIV totalsteps)*step);
sb := sb + (((db-sb) DIV totalsteps)*step);
Result :=RGB(sr,sg,sb);
end;
Var C : TAccountColumn;
s : String;
n_acc : Int64;
account : TAccount;
ndiff : Cardinal;
begin
if Not Assigned(Node) then exit;
if (ACol>=0) AND (ACol<length(FColumns)) then begin
C := FColumns[ACol];
end else begin
C.ColumnType := act_account_number;
C.width := -1;
end;
{.$IFDEF FPC}
DrawGrid.Canvas.Font.Color:=clBlack;
{.$ENDIF}
if (ARow=0) then begin
// Header
s := CT_ColumnHeader[C.ColumnType];
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfCenter,tfVerticalCenter]);
end else begin
n_acc := AccountNumber(ARow);
if (n_acc>=0) then begin
if (n_acc>=Node.Bank.AccountsCount) then account := CT_Account_NUL
else account := Node.Operations.SafeBoxTransaction.Account(n_acc);
ndiff := Node.Bank.BlocksCount - account.updated_block;
if (gdSelected in State) then
If (gdFocused in State) then DrawGrid.Canvas.Brush.Color := clGradientActiveCaption
else DrawGrid.Canvas.Brush.Color := clGradientInactiveCaption
else DrawGrid.Canvas.Brush.Color := clWindow;
DrawGrid.Canvas.FillRect(Rect);
InflateRect(Rect,-2,-1);
case C.ColumnType of
act_account_number : Begin
s := TAccountComp.AccountNumberToAccountTxtNumber(n_acc);
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter,tfSingleLine]);
End;
act_account_key : Begin
s := Tcrypto.ToHexaString(TAccountComp.AccountKey2RawString(account.accountInfo.accountKey));
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfLeft,tfVerticalCenter,tfSingleLine]);
End;
act_balance : Begin
if ndiff=0 then begin
// Pending operation... showing final balance
DrawGrid.Canvas.Font.Color := clBlue;
s := '('+TAccountComp.FormatMoney(account.balance)+')';
end else begin
s := TAccountComp.FormatMoney(account.balance);
if account.balance>0 then DrawGrid.Canvas.Font.Color := ClGreen
else if account.balance=0 then DrawGrid.Canvas.Font.Color := clGrayText
else DrawGrid.Canvas.Font.Color := clRed;
end;
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter,tfSingleLine]);
End;
act_updated : Begin
s := Inttostr(account.updated_block);
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter,tfSingleLine]);
End;
act_n_operation : Begin
s := InttoStr(account.n_operation);
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter,tfSingleLine]);
End;
act_updated_state : Begin
if TAccountComp.IsAccountBlockedByProtocol(account.account,Node.Bank.BlocksCount) then begin
DrawGrid.Canvas.Brush.Color := clRed;
end else if ndiff=0 then begin
DrawGrid.Canvas.Brush.Color := RGB(255,128,0);
end else if ndiff<=8 then begin
DrawGrid.Canvas.Brush.Color := FromColorToColor(RGB(253,250,115),ColorToRGB(clGreen),ndiff-1,8-1);
end else begin
DrawGrid.Canvas.Brush.Color := clGreen;
end;
DrawGrid.Canvas.Ellipse(Rect.Left+1,Rect.Top+1,Rect.Right-1,Rect.Bottom-1);
End;
act_name : Begin
s := account.name;
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfLeft,tfVerticalCenter,tfSingleLine]);
end;
act_type : Begin
s := IntToStr(account.account_type);
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter,tfSingleLine]);
end;
act_saleprice : Begin
if TAccountComp.IsAccountForSale(account.accountInfo) then begin
// Show price for sale
s := TAccountComp.FormatMoney(account.accountInfo.price);
if TAccountComp.IsAccountForSaleAcceptingTransactions(account.accountInfo) then begin
if TAccountComp.IsAccountLocked(account.accountInfo,Node.Bank.BlocksCount) then begin
DrawGrid.Canvas.Font.Color := clNavy;
end else begin
DrawGrid.Canvas.Font.Color := clRed;
end;
end else begin
DrawGrid.Canvas.Font.Color := clGrayText
end;
end else s := '';
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter,tfSingleLine]);
end;
else
s := '(???)';
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfCenter,tfVerticalCenter,tfSingleLine]);
end;
end;
end;
end;
procedure TAccountsGrid.OnNodeNewOperation(Sender: TObject);
begin
If Assigned(FDrawGrid) then FDrawGrid.Invalidate;
end;
procedure TAccountsGrid.SaveToStream(Stream: TStream);
Var c,i,j : Integer;
begin
c := Length(FColumns);
Stream.Write(c,sizeof(c));
for i := 0 to c - 1 do begin
j := Integer(FColumns[i].ColumnType);
Stream.Write(j,sizeof(j));
if Assigned(FDrawGrid) then begin
FColumns[i].width := FDrawGrid.ColWidths[i];
end;
Stream.Write(FColumns[i].width,sizeof(FColumns[i].width));
end;
j := FDrawGrid.Width;
Stream.Write(j,sizeof(j));
j := FDrawGrid.Height;
Stream.Write(j,sizeof(j));
end;
function TAccountsGrid.SelectedAccounts(accounts: TOrderedCardinalList): Integer;
var i64 : Int64;
i : Integer;
begin
accounts.Clear;
Result := 0;
if not assigned(FDrawGrid) then exit;
if FAllowMultiSelect then begin
for i := FDrawGrid.Selection.Top to FDrawGrid.Selection.Bottom do begin
i64 := AccountNumber(i);
if i64>=0 then accounts.Add(i64);
end;
end;
If accounts.Count=0 then begin
i64 := AccountNumber(DrawGrid.Row);
if i64>=0 then accounts.Add(i64);
end;
Result := accounts.Count;
end;
procedure TAccountsGrid.SetAllowMultiSelect(const Value: Boolean);
begin
FAllowMultiSelect := Value;
InitGrid;
end;
procedure TAccountsGrid.SetDrawGrid(const Value: TDrawGrid);
begin
if FDrawGrid=Value then exit;
FDrawGrid := Value;
if Assigned(Value) then begin
Value.FreeNotification(self);
FDrawGrid.OnDrawCell := OnGridDrawCell;
InitGrid;
end;
end;
procedure TAccountsGrid.SetNode(const Value: TNode);
begin
if GetNode=Value then exit;
FNodeNotifyEvents.Node := Value;
InitGrid;
end;
procedure TAccountsGrid.SetShowAllAccounts(const Value: Boolean);
begin
if FShowAllAccounts=Value then exit;
FShowAllAccounts := Value;
InitGrid;
end;
procedure TAccountsGrid.UnlockAccountsList;
begin
InitGrid;
end;
{ TOperationsGrid }
constructor TOperationsGrid.Create(AOwner: TComponent);
begin
FAccountNumber := 0;
FDrawGrid := Nil;
MustShowAlwaysAnAccount := false;
FOperationsResume := TOperationsResumeList.Create;
FNodeNotifyEvents := TNodeNotifyEvents.Create(Self);
FNodeNotifyEvents.OnBlocksChanged := OnNodeNewAccount;
FNodeNotifyEvents.OnOperationsChanged := OnNodeNewOperation;
FBlockStart := -1;
FBlockEnd := -1;
FPendingOperations := false;
inherited;
end;
destructor TOperationsGrid.Destroy;
begin
FOperationsResume.Free;
FNodeNotifyEvents.Free;
inherited;
end;
function TOperationsGrid.GetNode: TNode;
begin
Result := FNodeNotifyEvents.Node;
end;
procedure TOperationsGrid.InitGrid;
begin
if Not Assigned(FDrawGrid) then exit;
if FOperationsResume.Count>0 then FDrawGrid.RowCount := FOperationsResume.Count+1
else FDrawGrid.RowCount := 2;
DrawGrid.FixedRows := 1;
DrawGrid.DefaultDrawing := true;
DrawGrid.FixedCols := 0;
DrawGrid.ColCount := 8;
DrawGrid.ColWidths[0] := 110; // Time
DrawGrid.ColWidths[1] := 70; // Block/Op
DrawGrid.ColWidths[2] := 60; // Account
DrawGrid.ColWidths[3] := 180; // OpType
DrawGrid.ColWidths[4] := 70; // Amount
DrawGrid.ColWidths[5] := 60; // Operation Fee
DrawGrid.ColWidths[6] := 80; // Balance
DrawGrid.ColWidths[7] := 500; // Payload
FDrawGrid.DefaultRowHeight := 18;
FDrawGrid.Invalidate;
DrawGrid.Options := [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine,
{goRangeSelect, }goDrawFocusSelected, {goRowSizing, }goColSizing, {goRowMoving,}
{goColMoving, goEditing, }goTabs, goRowSelect, {goAlwaysShowEditor,}
goThumbTracking{$IFnDEF FPC}, goFixedColClick, goFixedRowClick, goFixedHotTrack{$ENDIF}];
end;
procedure TOperationsGrid.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited;
if Operation=opRemove then begin
if (AComponent=FDrawGrid) then begin
SetDrawGrid(Nil);
end;
end;
end;
procedure TOperationsGrid.OnGridDrawCell(Sender: TObject; ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
Var s : String;
opr : TOperationResume;
begin
{.$IFDEF FPC}
DrawGrid.Canvas.Font.Color:=clBlack;
{.$ENDIF}
opr := CT_TOperationResume_NUL;
Try
if (ARow=0) then begin
// Header
case ACol of
0 : s := 'Time';
1 : s := 'Block/Op';
2 : s := 'Account';
3 : s := 'Operation';
4 : s := 'Amount';
5 : s := 'Fee';
6 : s := 'Balance';
7 : s := 'Payload';
else s:= '';
end;
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfCenter,tfVerticalCenter]);
end else begin
if (gdSelected in State) then
If (gdFocused in State) then DrawGrid.Canvas.Brush.Color := clGradientActiveCaption
else DrawGrid.Canvas.Brush.Color := clGradientInactiveCaption
else DrawGrid.Canvas.Brush.Color := clWindow;
DrawGrid.Canvas.FillRect(Rect);
InflateRect(Rect,-2,-1);
if (ARow<=FOperationsResume.Count) then begin
opr := FOperationsResume.OperationResume[ARow-1];
If (opr.AffectedAccount=opr.SignerAccount) then begin
end else begin
if (gdSelected in State) or (gdFocused in State) then begin
end else DrawGrid.Canvas.font.Color := clGrayText;
end;
if ACol=0 then begin
if opr.time=0 then s := '(Pending)'
else s := DateTimeToStr(UnivDateTime2LocalDateTime(UnixToUnivDateTime(opr.time)));
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfleft,tfVerticalCenter,tfSingleLine]);
end else if ACol=1 then begin
s := Inttostr(opr.Block);
if opr.NOpInsideBlock>=0 then s := s + '/'+Inttostr(opr.NOpInsideBlock+1);
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfleft,tfVerticalCenter,tfSingleLine]);
end else if ACol=2 then begin
s := TAccountComp.AccountNumberToAccountTxtNumber(opr.AffectedAccount);
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfleft,tfVerticalCenter,tfSingleLine]);
end else if ACol=3 then begin
s := opr.OperationTxt;
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfleft,tfVerticalCenter,tfSingleLine]);
end else if ACol=4 then begin
s := TAccountComp.FormatMoney(opr.Amount);
if opr.Amount>0 then DrawGrid.Canvas.Font.Color := ClGreen
else if opr.Amount=0 then DrawGrid.Canvas.Font.Color := clGrayText
else DrawGrid.Canvas.Font.Color := clRed;
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter,tfSingleLine]);
end else if ACol=5 then begin
s := TAccountComp.FormatMoney(opr.Fee);
if opr.Fee>0 then DrawGrid.Canvas.Font.Color := ClGreen
else if opr.Fee=0 then DrawGrid.Canvas.Font.Color := clGrayText
else DrawGrid.Canvas.Font.Color := clRed;
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter,tfSingleLine]);
end else if ACol=6 then begin
if opr.time=0 then begin
// Pending operation... showing final balance
DrawGrid.Canvas.Font.Color := clBlue;
s := '('+TAccountComp.FormatMoney(opr.Balance)+')';
end else begin
s := TAccountComp.FormatMoney(opr.Balance);
if opr.Balance>0 then DrawGrid.Canvas.Font.Color := ClGreen
else if opr.Balance=0 then DrawGrid.Canvas.Font.Color := clGrayText
else DrawGrid.Canvas.Font.Color := clRed;
end;
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter,tfSingleLine]);
end else if ACol=7 then begin
s := opr.PrintablePayload;
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfLeft,tfVerticalCenter,tfSingleLine]);
end else begin
s := '(???)';
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfCenter,tfVerticalCenter,tfSingleLine]);
end;
end;
end;
Except
On E:Exception do begin
TLog.NewLog(lterror,Classname,Format('Error at OnGridDrawCell row %d col %d Block %d - %s',[ARow,ACol,opr.Block,E.Message]));
end;
End;
end;
procedure TOperationsGrid.OnNodeNewAccount(Sender: TObject);
begin
If (AccountNumber<0) And (FBlockEnd<0) And (Not FPendingOperations) then UpdateAccountOperations;
end;
procedure TOperationsGrid.OnNodeNewOperation(Sender: TObject);
Var //Op : TPCOperation;
l : TList;
begin
Try
if (AccountNumber<0) then begin
If (FPendingOperations) then UpdateAccountOperations;
end else begin
l := TList.Create;
Try
If Node.Operations.OperationsHashTree.GetOperationsAffectingAccount(AccountNumber,l)>0 then begin
if l.IndexOf(TObject(PtrInt(AccountNumber)))>=0 then UpdateAccountOperations;
end;
Finally
l.Free;
End;
end;
Except
On E:Exception do begin
E.message := 'Exception on updating OperationsGrid '+inttostr(AccountNumber)+': '+E.Message;
Raise;
end;
end;
end;
procedure TOperationsGrid.SetAccountNumber(const Value: Int64);
begin
if FAccountNumber=Value then exit;
FAccountNumber := Value;
if FAccountNumber>=0 then FPendingOperations := false;
UpdateAccountOperations;
end;
procedure TOperationsGrid.SetBlockEnd(const Value: Int64);
begin
FBlockEnd := Value;
end;
procedure TOperationsGrid.SetBlocks(bstart, bend: Int64);
begin
if (bstart=FBlockStart) And (bend=FBlockEnd) then exit;
FBlockStart := bstart;
FBlockEnd := bend;
if (FBlockEnd>0) And (FBlockStart>FBlockEnd) then FBlockStart := -1;
FAccountNumber := -1;
FPendingOperations := false;
UpdateAccountOperations;
end;
procedure TOperationsGrid.SetBlockStart(const Value: Int64);
begin
FBlockStart := Value;
end;
procedure TOperationsGrid.SetDrawGrid(const Value: TDrawGrid);
begin
if FDrawGrid=Value then exit;
FDrawGrid := Value;
if Assigned(Value) then begin
Value.FreeNotification(self);
FDrawGrid.OnDrawCell := OnGridDrawCell;
InitGrid;
end;
end;
procedure TOperationsGrid.SetMustShowAlwaysAnAccount(const Value: Boolean);
begin
if FMustShowAlwaysAnAccount=Value then exit;
FMustShowAlwaysAnAccount := Value;
UpdateAccountOperations;
end;
procedure TOperationsGrid.SetNode(const Value: TNode);
begin
if GetNode=Value then exit;
FNodeNotifyEvents.Node := Value;
UpdateAccountOperations; // New Build 1.0.3
end;
procedure TOperationsGrid.SetPendingOperations(const Value: Boolean);
begin
FPendingOperations := Value;
if FPendingOperations then FAccountNumber := -1;
UpdateAccountOperations;
end;
function TOperationsGrid.GetSelectedOperation : TOperationResume;
Var i : Integer;
opr : TOperationResume;
FRM : TFRMPayloadDecoder;
begin
if Not Assigned(FDrawGrid) then exit;
if (FDrawGrid.Row<=0) Or (FDrawGrid.Row>FOperationsResume.Count) then begin
Result := CT_TOperationResume_NUL;
exit;
end;
Result := FOperationsResume.OperationResume[FDrawGrid.Row-1];
end;
procedure TOperationsGrid.ShowModalDecoder(WalletKeys: TWalletKeys; AppParams : TAppParams);
Var i : Integer;
opr : TOperationResume;
FRM : TFRMPayloadDecoder;
begin
if Not Assigned(FDrawGrid) then exit;
if (FDrawGrid.Row<=0) Or (FDrawGrid.Row>FOperationsResume.Count) then exit;
opr := FOperationsResume.OperationResume[FDrawGrid.Row-1];
FRM := TFRMPayloadDecoder.Create(FDrawGrid.Owner);
try
FRM.Init(opr,WalletKeys,AppParams);
FRM.ShowModal;
finally
FRM.Free;
end;
end;
procedure TOperationsGrid.UpdateAccountOperations;
Var list : TList;
i,j : Integer;
OPR : TOperationResume;
Op : TPCOperation;
opc : TPCOperationsComp;
bstart,bend : int64;
begin
FOperationsResume.Clear;
Try
if Not Assigned(Node) then exit;
if (MustShowAlwaysAnAccount) And (AccountNumber<0) then exit;
if FPendingOperations then begin
for i := Node.Operations.Count - 1 downto 0 do begin
Op := Node.Operations.OperationsHashTree.GetOperation(i);
If TPCOperation.OperationToOperationResume(0,Op,True,Op.SignerAccount,OPR) then begin
OPR.NOpInsideBlock := i;
OPR.Block := Node.Bank.BlocksCount;
OPR.Balance := Node.Operations.SafeBoxTransaction.Account(Op.SignerAccount).balance;
FOperationsResume.Add(OPR);
end;
end;
end else begin
if AccountNumber<0 then begin
opc := TPCOperationsComp.Create(Nil);
try
opc.bank := Node.Bank;
If FBlockEnd<0 then begin
If Node.Bank.BlocksCount>0 then bend := Node.Bank.BlocksCount-1
else bend := 0;
end else bend := FBlockEnd;
if FBlockStart<0 then begin
if (bend > 300) then bstart := bend - 300
else bstart := 0;
end else bstart:= FBlockStart;
If bstart<0 then bstart := 0;
if bend>=Node.Bank.BlocksCount then bend:=Node.Bank.BlocksCount;
while (bstart<=bend) do begin
opr := CT_TOperationResume_NUL;
if (Node.Bank.Storage.LoadBlockChainBlock(opc,bend)) then begin
// Reward operation
OPR := CT_TOperationResume_NUL;
OPR.valid := true;
OPR.Block := bend;
OPR.time := opc.OperationBlock.timestamp;
OPR.AffectedAccount := bend * CT_AccountsPerBlock;
OPR.Amount := opc.OperationBlock.reward;
OPR.Fee := opc.OperationBlock.fee;
OPR.Balance := OPR.Amount+OPR.Fee;
OPR.OperationTxt := 'Blockchain reward';
FOperationsResume.Add(OPR);
// Reverse operations inside a block
for i := opc.Count - 1 downto 0 do begin
if TPCOperation.OperationToOperationResume(bend,opc.Operation[i],True,opc.Operation[i].SignerAccount,opr) then begin
opr.NOpInsideBlock := i;
opr.Block := bend;
opr.time := opc.OperationBlock.timestamp;
FOperationsResume.Add(opr);
end;
end;
end else break;
dec(bend);
end;
finally
opc.Free;
end;
end else begin
list := TList.Create;
Try
Node.Operations.OperationsHashTree.GetOperationsAffectingAccount(AccountNumber,list);
for i := list.Count - 1 downto 0 do begin
Op := Node.Operations.OperationsHashTree.GetOperation(PtrInt(list[i]));
If TPCOperation.OperationToOperationResume(0,Op,False,AccountNumber,OPR) then begin
OPR.NOpInsideBlock := i;
OPR.Block := Node.Operations.OperationBlock.block;
OPR.Balance := Node.Operations.SafeBoxTransaction.Account(AccountNumber).balance;
FOperationsResume.Add(OPR);
end;
end;
Finally
list.Free;
End;
Node.GetStoredOperationsFromAccount(FOperationsResume,AccountNumber,100,0,5000);
end;
end;
Finally
InitGrid;
End;
end;
{ TBlockChainGrid }
constructor TBlockChainGrid.Create(AOwner: TComponent);
begin
inherited;
FBlockStart:=-1;
FBlockEnd:=-1;
FMaxBlocks := 300;
FDrawGrid := Nil;
FNodeNotifyEvents := TNodeNotifyEvents.Create(Self);
FNodeNotifyEvents.OnBlocksChanged := OnNodeNewAccount;
FHashRateAverageBlocksCount := 50;
SetLength(FBlockChainDataArray,0);
FShowTimeAverageColumns:=False;
FHashRateAs:={$IFDEF PRODUCTION}hr_Giga{$ELSE}hr_Mega{$ENDIF};
end;
destructor TBlockChainGrid.Destroy;
begin
FNodeNotifyEvents.OnBlocksChanged := Nil;
FNodeNotifyEvents.Node := Nil;
FreeAndNil(FNodeNotifyEvents);
inherited;
end;
function TBlockChainGrid.GetNode: TNode;
begin
Result := FNodeNotifyEvents.Node;
end;
procedure TBlockChainGrid.InitGrid;
begin
if Not Assigned(FDrawGrid) then exit;
FDrawGrid.RowCount := 2;
DrawGrid.FixedRows := 1;
DrawGrid.DefaultDrawing := true;
DrawGrid.FixedCols := 0;
If ShowTimeAverageColumns then DrawGrid.ColCount:=14
else DrawGrid.ColCount:=12;
DrawGrid.ColWidths[0] := 50; // Block
DrawGrid.ColWidths[1] := 110; // Time
DrawGrid.ColWidths[2] := 30; // Ops
DrawGrid.ColWidths[3] := 80; // Volume
DrawGrid.ColWidths[4] := 50; // Reward
DrawGrid.ColWidths[5] := 50; // Fee
DrawGrid.ColWidths[6] := 60; // Target
DrawGrid.ColWidths[7] := 80; // Hash Rate
DrawGrid.ColWidths[8] := 190; // Miner Payload
DrawGrid.ColWidths[9] := 190; // PoW
DrawGrid.ColWidths[10] := 190; // SafeBox Hash
DrawGrid.ColWidths[11] := 50; // Protocol
If ShowTimeAverageColumns then begin
DrawGrid.ColWidths[12] := 55; // Deviation
DrawGrid.ColWidths[13] := 350; // Time average
end;
FDrawGrid.DefaultRowHeight := 18;
FDrawGrid.Invalidate;
DrawGrid.Options := [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine,
{goRangeSelect, }goDrawFocusSelected, {goRowSizing, }goColSizing, {goRowMoving,}
{goColMoving, goEditing, }goTabs, goRowSelect, {goAlwaysShowEditor,}
goThumbTracking{$IFnDEF FPC}, goFixedColClick, goFixedRowClick, goFixedHotTrack{$ENDIF}];
UpdateBlockChainGrid;
end;
procedure TBlockChainGrid.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if Operation=opRemove then begin
if (AComponent=FDrawGrid) then begin
SetDrawGrid(Nil);
end;
end;
end;
procedure TBlockChainGrid.OnGridDrawCell(Sender: TObject; ACol, ARow: Longint;
Rect: TRect; State: TGridDrawState);
Var s : String;
bcd : TBlockChainData;
deviation : Real;
hr_base : Int64;
begin
{.$IFDEF FPC}
DrawGrid.Canvas.Font.Color:=clBlack;
{.$ENDIF}
if (ARow=0) then begin
// Header
case ACol of
0 : s := 'Block';
1 : s := 'Time';
2 : s := 'Ops';
3 : s := 'Volume';
4 : s := 'Reward';
5 : s := 'Fee';
6 : s := 'Target';
7 : begin
case HashRateAs of
hr_Kilo : s := 'Kh/s';
hr_Mega : s := 'Mh/s';
hr_Giga : s := 'Gh/s';
hr_Tera : s := 'Th/s';
hr_Peta : s := 'Ph/s';
hr_Exa : s := 'Eh/s';
else s := '?h/s';
end;
end;
8 : s := 'Miner Payload';
9 : s := 'Proof of Work';
10 : s := 'SafeBox Hash';
11 : s := 'Protocol';
12 : s := 'Deviation';
13 : s := 'Time average';
else s:= '';
end;
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfCenter,tfVerticalCenter]);
end else begin
if (gdSelected in State) then
If (gdFocused in State) then DrawGrid.Canvas.Brush.Color := clGradientActiveCaption
else DrawGrid.Canvas.Brush.Color := clGradientInactiveCaption
else DrawGrid.Canvas.Brush.Color := clWindow;
DrawGrid.Canvas.FillRect(Rect);
InflateRect(Rect,-2,-1);
if ((ARow-1)<=High(FBlockChainDataArray)) then begin
bcd := FBlockChainDataArray[ARow-1];
if ACol=0 then begin
s := IntToStr(bcd.Block);
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter]);
end else if ACol=1 then begin
s := DateTimeToStr(UnivDateTime2LocalDateTime(UnixToUnivDateTime((bcd.Timestamp))));
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfleft,tfVerticalCenter,tfSingleLine]);
end else if ACol=2 then begin
if bcd.OperationsCount>=0 then begin
s := IntToStr(bcd.OperationsCount);
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter]);
end else begin
DrawGrid.Canvas.Font.Color := clGrayText;
s := '(no data)';
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfCenter,tfVerticalCenter,tfSingleLine]);
end;
end else if ACol=3 then begin
if bcd.Volume>=0 then begin
s := TAccountComp.FormatMoney(bcd.Volume);
if FBlockChainDataArray[ARow-1].Volume>0 then DrawGrid.Canvas.Font.Color := ClGreen
else DrawGrid.Canvas.Font.Color := clGrayText;
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter,tfSingleLine]);
end else begin
DrawGrid.Canvas.Font.Color := clGrayText;
s := '(no data)';
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfCenter,tfVerticalCenter,tfSingleLine]);
end;
end else if ACol=4 then begin
s := TAccountComp.FormatMoney(bcd.Reward);
if FBlockChainDataArray[ARow-1].Reward>0 then DrawGrid.Canvas.Font.Color := ClGreen
else DrawGrid.Canvas.Font.Color := clGrayText;
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter,tfSingleLine]);
end else if ACol=5 then begin
s := TAccountComp.FormatMoney(bcd.Fee);
if bcd.Fee>0 then DrawGrid.Canvas.Font.Color := ClGreen
else DrawGrid.Canvas.Font.Color := clGrayText;
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter,tfSingleLine]);
end else if ACol=6 then begin
s := IntToHex(bcd.Target,8);
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfLeft,tfVerticalCenter]);
end else if ACol=7 then begin
case HashRateAs of
hr_Kilo : hr_base := 1;
hr_Mega : hr_base := 1000;
hr_Giga : hr_base := 1000000;
hr_Tera : hr_base := 1000000000;
hr_Peta : hr_base := 1000000000000;
hr_Exa : hr_base := 1000000000000000;
else hr_base := 1;
end;
s := Format('%.2n (%.2n)',[bcd.HashRateKhs/hr_base,bcd.HashRateTargetKhs/hr_base]);
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter]);
end else if ACol=8 then begin
if TCrypto.IsHumanReadable(bcd.MinerPayload) then
s := bcd.MinerPayload
else s := TCrypto.ToHexaString( bcd.MinerPayload );
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfLeft,tfVerticalCenter]);
end else if ACol=9 then begin
s := TCrypto.ToHexaString(bcd.PoW);
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfLeft,tfVerticalCenter]);
end else if ACol=10 then begin
s := TCrypto.ToHexaString(bcd.SafeBoxHash);
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfLeft,tfVerticalCenter]);
end else if ACol=11 then begin
s := Inttostr(bcd.BlockProtocolVersion)+'-'+IntToStr(bcd.BlockProtocolAvailable);
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfCenter,tfVerticalCenter,tfSingleLine]);
end else if ACol=12 then begin
deviation := ((CT_NewLineSecondsAvg - bcd.TimeAverage100) / CT_NewLineSecondsAvg)*100;
s := Format('%.2f',[deviation])+' %';
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfRight,tfVerticalCenter,tfSingleLine]);
end else if ACol=13 then begin
s := Format('200:%.1f 150:%.1f 100:%.1f 75:%.1f 50:%.1f 25:%.1f 10:%.1f',[bcd.TimeAverage200,
bcd.TimeAverage150,bcd.TimeAverage100,bcd.TimeAverage75,bcd.TimeAverage50,bcd.TimeAverage25,bcd.TimeAverage10]);
Canvas_TextRect(DrawGrid.Canvas,Rect,s,State,[tfLeft,tfVerticalCenter,tfSingleLine]);
end;
end;
end;
end;
procedure TBlockChainGrid.OnNodeNewAccount(Sender: TObject);
begin
if FBlockEnd<0 then UpdateBlockChainGrid;
end;
procedure TBlockChainGrid.SetBlockEnd(const Value: Int64);
begin
if FBlockEnd=Value then exit;
FBlockEnd := Value;
UpdateBlockChainGrid;
end;
procedure TBlockChainGrid.SetBlocks(bstart, bend: Int64);
begin
if (FBlockStart=bstart) And (FBlockEnd=bend) then exit;
FBlockStart := bstart;
FBlockEnd := bend;
UpdateBlockChainGrid;
end;
procedure TBlockChainGrid.SetBlockStart(const Value: Int64);
begin
If FBlockStart=Value then exit;
FBlockStart := Value;
UpdateBlockChainGrid;
end;
procedure TBlockChainGrid.SetDrawGrid(const Value: TDrawGrid);
begin
if FDrawGrid=Value then exit;
FDrawGrid := Value;
if Assigned(Value) then begin
Value.FreeNotification(self);
FDrawGrid.OnDrawCell := OnGridDrawCell;
InitGrid;
end;
end;
procedure TBlockChainGrid.SetHashRateAs(AValue: TShowHashRateAs);
begin
if FHashRateAs=AValue then Exit;
FHashRateAs:=AValue;
if Assigned(FDrawGrid) then begin
FDrawGrid.Invalidate;
end;
end;
procedure TBlockChainGrid.SetHashRateAverageBlocksCount(const Value: Integer);
begin
if FHashRateAverageBlocksCount=Value then exit;
FHashRateAverageBlocksCount := Value;
if FHashRateAverageBlocksCount<1 then FHashRateAverageBlocksCount := 1;
if FHashRateAverageBlocksCount>1000 then FHashRateAverageBlocksCount := 1000;
UpdateBlockChainGrid;
end;
procedure TBlockChainGrid.SetShowTimeAverageColumns(AValue: Boolean);
begin
if FShowTimeAverageColumns=AValue then Exit;
FShowTimeAverageColumns:=AValue;
InitGrid;
end;
procedure TBlockChainGrid.SetMaxBlocks(const Value: Integer);
begin
if FMaxBlocks=Value then exit;
FMaxBlocks := Value;
if (FMaxBlocks<=0) Or (FMaxBlocks>500) then FMaxBlocks := 300;
UpdateBlockChainGrid;
end;
procedure TBlockChainGrid.SetNode(const Value: TNode);
begin
FNodeNotifyEvents.Node := Value;
UpdateBlockChainGrid;
end;
procedure TBlockChainGrid.UpdateBlockChainGrid;
Var nstart,nend : Cardinal;
opc : TPCOperationsComp;
bcd : TBlockChainData;
i : Integer;
opb : TOperationBlock;
bn : TBigNum;
begin
if (FBlockStart>FBlockEnd) And (FBlockStart>=0) then FBlockEnd := -1;
if (FBlockEnd>=0) And (FBlockEnd<FBlockStart) then FBlockStart:=-1;
if Not Assigned(FNodeNotifyEvents.Node) then exit;
if FBlockStart>(FNodeNotifyEvents.Node.Bank.BlocksCount-1) then FBlockStart := -1;
try
if Node.Bank.BlocksCount<=0 then begin
SetLength(FBlockChainDataArray,0);
exit;
end;
if (FBlockEnd>=0) And (FBlockEnd<Node.Bank.BlocksCount) then begin
nend := FBlockEnd
end else begin
if (FBlockStart>=0) And (FBlockStart+MaxBlocks<=Node.Bank.BlocksCount) then nend := FBlockStart + MaxBlocks - 1
else nend := Node.Bank.BlocksCount-1;
end;
if (FBlockStart>=0) And (FBlockStart<Node.Bank.BlocksCount) then nstart := FBlockStart
else begin
if nend>MaxBlocks then nstart := nend - MaxBlocks + 1
else nstart := 0;
end;
SetLength(FBlockChainDataArray,nend - nstart +1);
opc := TPCOperationsComp.Create(Nil);
try
opc.bank := Node.Bank;
while (nstart<=nend) do begin
i := length(FBlockChainDataArray) - (nend-nstart+1);
bcd := CT_TBlockChainData_NUL;
opb := Node.Bank.SafeBox.Block(nend).blockchainInfo;
bcd.Block:=opb.block;
bcd.Timestamp := opb.timestamp;
bcd.BlockProtocolVersion := opb.protocol_version;
bcd.BlockProtocolAvailable := opb.protocol_available;
bcd.Reward := opb.reward;
bcd.Fee := opb.fee;
bcd.Target := opb.compact_target;
bcd.HashRateKhs := Node.Bank.SafeBox.CalcBlockHashRateInKhs(bcd.Block,HashRateAverageBlocksCount);
bn := TBigNum.TargetToHashRate(opb.compact_target);
Try
bcd.HashRateTargetKhs := bn.Divide(1024).Divide(CT_NewLineSecondsAvg).Value;
finally
bn.Free;
end;
bcd.MinerPayload := opb.block_payload;
bcd.PoW := opb.proof_of_work;
bcd.SafeBoxHash := opb.initial_safe_box_hash;
bcd.AccumulatedWork := Node.Bank.SafeBox.Block(bcd.Block).AccumulatedWork;
if (Node.Bank.LoadOperations(opc,nend)) then begin
bcd.OperationsCount := opc.Count;
bcd.Volume := opc.OperationsHashTree.TotalAmount + opc.OperationsHashTree.TotalFee;
end;
bcd.TimeAverage200:=Node.Bank.GetTargetSecondsAverage(bcd.Block,200);
bcd.TimeAverage150:=Node.Bank.GetTargetSecondsAverage(bcd.Block,150);
bcd.TimeAverage100:=Node.Bank.GetTargetSecondsAverage(bcd.Block,100);
bcd.TimeAverage75:=Node.Bank.GetTargetSecondsAverage(bcd.Block,75);
bcd.TimeAverage50:=Node.Bank.GetTargetSecondsAverage(bcd.Block,50);
bcd.TimeAverage25:=Node.Bank.GetTargetSecondsAverage(bcd.Block,25);
bcd.TimeAverage10:=Node.Bank.GetTargetSecondsAverage(bcd.Block,10);
FBlockChainDataArray[i] := bcd;
if (nend>0) then dec(nend) else break;
end;
finally
opc.Free;
end;
finally
if Assigned(FDrawGrid) then begin
if Length(FBlockChainDataArray)>0 then FDrawGrid.RowCount := length(FBlockChainDataArray)+1
else FDrawGrid.RowCount := 2;
FDrawGrid.Invalidate;
end;
end;
end;
end.
| 35.393984 | 373 | 0.700779 |
f195121b911911042c229188d9b4b325be8d7aa1
| 3,970 |
dfm
|
Pascal
|
libs/u_input_ttd.dfm
|
AndanTeknomedia/bazda-delphi-xe8
|
3cb9589e41bf7a7492323348a429a6ef7f357817
|
[
"MIT"
] | null | null | null |
libs/u_input_ttd.dfm
|
AndanTeknomedia/bazda-delphi-xe8
|
3cb9589e41bf7a7492323348a429a6ef7f357817
|
[
"MIT"
] | null | null | null |
libs/u_input_ttd.dfm
|
AndanTeknomedia/bazda-delphi-xe8
|
3cb9589e41bf7a7492323348a429a6ef7f357817
|
[
"MIT"
] | null | null | null |
object FInputTTD: TFInputTTD
Left = 0
Top = 0
BorderStyle = bsDialog
Caption = 'Penandatangan'
ClientHeight = 311
ClientWidth = 522
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poDesktopCenter
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 55
Top = 135
Width = 42
Height = 13
Caption = 'Jabatan '
end
object Label2: TLabel
Left = 55
Top = 158
Width = 27
Height = 13
Caption = 'Nama'
end
object Label4: TLabel
Left = 55
Top = 181
Width = 36
Height = 13
Caption = 'Tempat'
end
object Label5: TLabel
Left = 55
Top = 204
Width = 38
Height = 13
Caption = 'Tanggal'
end
object Label10: TLabel
Left = 25
Top = 115
Width = 89
Height = 13
Caption = 'Penandatangan'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ParentFont = False
end
object Label3: TLabel
Left = 25
Top = 15
Width = 122
Height = 13
Caption = 'Identitas Perusahaan'
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ParentFont = False
end
object Label6: TLabel
Left = 55
Top = 37
Width = 57
Height = 13
Caption = 'Perusahaan'
end
object Label7: TLabel
Left = 55
Top = 60
Width = 33
Height = 13
Caption = 'Alamat'
end
object Label8: TLabel
Left = 55
Top = 231
Width = 79
Height = 13
Caption = 'Jumlah Lampiran'
OnClick = Label8Click
end
object Label9: TLabel
Left = 217
Top = 231
Width = 26
Height = 13
Caption = 'Eksp.'
OnClick = Label8Click
end
object eNama: TEdit
Left = 140
Top = 159
Width = 341
Height = 21
TabOrder = 3
end
object eJabatan: TEdit
Left = 140
Top = 136
Width = 341
Height = 21
TabOrder = 2
end
object eTempat: TEdit
Left = 140
Top = 182
Width = 341
Height = 21
TabOrder = 4
end
object eTanggal: TEdit
Left = 140
Top = 205
Width = 325
Height = 21
TabOrder = 5
end
object DateTimePicker1: TDateTimePicker
Left = 461
Top = 205
Width = 20
Height = 21
Date = 42325.952195659720000000
Time = 42325.952195659720000000
TabOrder = 6
TabStop = False
OnChange = DateTimePicker1Change
end
object Panel2: TPanel
Left = 0
Top = 255
Width = 522
Height = 56
Align = alBottom
BevelOuter = bvNone
TabOrder = 8
ExplicitTop = 235
ExplicitWidth = 504
object Bevel2: TBevel
AlignWithMargins = True
Left = 10
Top = 3
Width = 502
Height = 6
Margins.Left = 10
Margins.Right = 10
Align = alTop
Shape = bsBottomLine
ExplicitLeft = 0
ExplicitTop = 35
ExplicitWidth = 647
end
object Button1: TButton
Left = 305
Top = 20
Width = 75
Height = 25
Caption = 'OK'
TabOrder = 0
OnClick = Button1Click
end
object Button2: TButton
Left = 386
Top = 20
Width = 75
Height = 25
Cancel = True
Caption = 'Batal'
TabOrder = 1
OnClick = Button2Click
end
end
object ePerusahaan: TEdit
Left = 140
Top = 34
Width = 341
Height = 21
TabOrder = 0
end
object eAlamat: TMemo
Left = 140
Top = 57
Width = 341
Height = 45
TabOrder = 1
end
object JvSpinEdit1: TJvSpinEdit
Left = 140
Top = 228
Width = 71
Height = 21
MaxValue = 99.000000000000000000
TabOrder = 7
end
object JvEnterAsTab1: TJvEnterAsTab
OnHandleEnter = JvEnterAsTab1HandleEnter
Left = 441
Top = 8
end
end
| 18.551402 | 44 | 0.589673 |
f15e2a8872b30fc56f1a49569551bd745656e018
| 4,068 |
pas
|
Pascal
|
Source/vcl/WrapVclActnList.pas
|
prodat/python4delphi
|
cba592c8a7b13275cbd6f8b0b9d7161fcdafa010
|
[
"MIT"
] | 685 |
2015-08-28T02:12:06.000Z
|
2022-03-28T19:44:07.000Z
|
Source/vcl/WrapVclActnList.pas
|
prodat/python4delphi
|
cba592c8a7b13275cbd6f8b0b9d7161fcdafa010
|
[
"MIT"
] | 248 |
2015-11-17T16:39:48.000Z
|
2022-03-29T18:44:53.000Z
|
Source/vcl/WrapVclActnList.pas
|
prodat/python4delphi
|
cba592c8a7b13275cbd6f8b0b9d7161fcdafa010
|
[
"MIT"
] | 259 |
2015-10-03T04:53:26.000Z
|
2022-03-31T18:23:06.000Z
|
{$I ..\Definition.Inc}
unit WrapVclActnList;
interface
uses
System.Classes,
PythonEngine, WrapDelphi,
WrapDelphiClasses,
WrapActions,
Vcl.ActnList;
type
{
Same as TPyDelphiContainedActionList but having wrappers, exposes
the types and allows the use of the constructors e.g. ActionList()
}
TPyDelphiCustomActionList = class(TPyDelphiContainedActionList)
private
function GetDelphiObject: TCustomActionList;
procedure SetDelphiObject(const Value: TCustomActionList);
public
class function DelphiObjectClass: TClass; override;
property DelphiObject: TCustomActionList read GetDelphiObject
write SetDelphiObject;
end;
TPyDelphiActionList = class (TPyDelphiCustomActionList)
private
function GetDelphiObject: TActionList;
procedure SetDelphiObject(const Value: TActionList);
public
// Class methods
class function DelphiObjectClass : TClass; override;
// Properties
property DelphiObject: TActionList read GetDelphiObject write SetDelphiObject;
end;
TPyDelphiCustomAction = class(TPyDelphiContainedAction)
private
function GetDelphiObject: TCustomAction;
procedure SetDelphiObject(const Value: TCustomAction);
public
class function DelphiObjectClass: TClass; override;
property DelphiObject: TCustomAction read GetDelphiObject
write SetDelphiObject;
end;
TPyDelphiAction = class(TPyDelphiContainedAction)
private
function GetDelphiObject: TAction;
procedure SetDelphiObject(const Value: TAction);
public
class function DelphiObjectClass: TClass; override;
property DelphiObject: TAction read GetDelphiObject write SetDelphiObject;
end;
implementation
{ Register the wrappers, the globals and the constants }
type
TActnListRegistration = class(TRegisteredUnit)
public
function Name : string; override;
procedure RegisterWrappers(APyDelphiWrapper : TPyDelphiWrapper); override;
end;
{ TActnListRegistration }
function TActnListRegistration.Name: string;
begin
Result := 'Vcl.ActnList';
end;
procedure TActnListRegistration.RegisterWrappers(APyDelphiWrapper: TPyDelphiWrapper);
begin
inherited;
APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiCustomActionList);
APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiActionList);
APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiCustomAction);
APyDelphiWrapper.RegisterDelphiWrapper(TPyDelphiAction);
end;
{ TPyDelphiCustomActionList }
class function TPyDelphiCustomActionList.DelphiObjectClass: TClass;
begin
Result := TCustomActionList;
end;
function TPyDelphiCustomActionList.GetDelphiObject: TCustomActionList;
begin
Result := TCustomActionList(inherited DelphiObject);
end;
procedure TPyDelphiCustomActionList.SetDelphiObject
(const Value: TCustomActionList);
begin
inherited DelphiObject := Value;
end;
{ TPyDelphiActionList }
class function TPyDelphiActionList.DelphiObjectClass: TClass;
begin
Result := TActionList;
end;
function TPyDelphiActionList.GetDelphiObject: TActionList;
begin
Result := TActionList(inherited DelphiObject);
end;
procedure TPyDelphiActionList.SetDelphiObject(
const Value: TActionList);
begin
inherited DelphiObject := Value;
end;
{ TPyDelphiCustomAction }
class function TPyDelphiCustomAction.DelphiObjectClass: TClass;
begin
Result := TCustomAction;
end;
function TPyDelphiCustomAction.GetDelphiObject: TCustomAction;
begin
Result := TCustomAction(inherited DelphiObject);
end;
procedure TPyDelphiCustomAction.SetDelphiObject(const Value: TCustomAction);
begin
inherited DelphiObject := Value;
end;
{ TPyDelphiAction }
class function TPyDelphiAction.DelphiObjectClass: TClass;
begin
Result := TAction;
end;
function TPyDelphiAction.GetDelphiObject: TAction;
begin
Result := TAction(inherited DelphiObject);
end;
procedure TPyDelphiAction.SetDelphiObject(const Value: TAction);
begin
inherited DelphiObject := Value;
end;
initialization
RegisteredUnits.Add(TActnListRegistration.Create);
end.
| 25.910828 | 86 | 0.785152 |
834660bbbfa94464f1dfc6314381514ba8376bba
| 1,709 |
pas
|
Pascal
|
Libraries/GraphicsLib/dwsJPEGEncoderOptions.pas
|
caxsf/dwscript
|
410a0416db3d4baf984e041b9cbf5707f2f8895f
|
[
"Condor-1.1"
] | 79 |
2015-03-18T10:46:13.000Z
|
2022-03-17T18:05:11.000Z
|
Libraries/GraphicsLib/dwsJPEGEncoderOptions.pas
|
caxsf/dwscript
|
410a0416db3d4baf984e041b9cbf5707f2f8895f
|
[
"Condor-1.1"
] | 6 |
2016-03-29T14:39:00.000Z
|
2020-09-14T10:04:14.000Z
|
Libraries/GraphicsLib/dwsJPEGEncoderOptions.pas
|
caxsf/dwscript
|
410a0416db3d4baf984e041b9cbf5707f2f8895f
|
[
"Condor-1.1"
] | 25 |
2016-05-04T13:11:38.000Z
|
2021-09-29T13:34:31.000Z
|
{**********************************************************************}
{ }
{ "The contents of this file are subject to the Mozilla Public }
{ License Version 1.1 (the "License"); you may not use this }
{ file except in compliance with the License. You may obtain }
{ a copy of the License at http://www.mozilla.org/MPL/ }
{ }
{ Software distributed under the License is distributed on an }
{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express }
{ or implied. See the License for the specific language }
{ governing rights and limitations under the License. }
{ }
{ Based on WriteJPEG example from OpenGL24.de }
{ http://www.opengl24.de/header/libjpeg }
{ }
{ Further changes Copyright Creative IT. }
{ Current maintainer: Eric Grange }
{ }
{**********************************************************************}
unit dwsJPEGEncoderOptions;
interface
type
TJPEGOption = (
jpgoOptimize, // optimize Huffman tables
jpgoNoJFIFHeader, // don't write JFIF header
jpgoProgressive // progressive JPEG
);
TJPEGOptions = set of TJPEGOption;
implementation
end.
| 48.828571 | 73 | 0.399064 |
836ef4fbe3200b34c4f5b97ee33ed53baa7f5073
| 223 |
lpr
|
Pascal
|
synapse40/source/demo/httpserv/httpserv.lpr
|
MFernstrom/FPRevShell
|
751ced2fdca3140fb5c88ad54ccf7cb7d9ef7c40
|
[
"Apache-2.0"
] | 2 |
2021-12-30T23:31:36.000Z
|
2021-12-31T05:22:47.000Z
|
synapse40/source/demo/httpserv/httpserv.lpr
|
MFernstrom/FPRevShell
|
751ced2fdca3140fb5c88ad54ccf7cb7d9ef7c40
|
[
"Apache-2.0"
] | null | null | null |
synapse40/source/demo/httpserv/httpserv.lpr
|
MFernstrom/FPRevShell
|
751ced2fdca3140fb5c88ad54ccf7cb7d9ef7c40
|
[
"Apache-2.0"
] | null | null | null |
program httpserv;
{$MODE Delphi}
uses
Forms, Interfaces,
main in 'main.pas' {Form1},
http in 'http.pas';
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
| 13.117647 | 40 | 0.690583 |
6a3e0ec55835c7fbd5bb15bf246210439a5da92b
| 415 |
dpr
|
Pascal
|
windows/src/ext/jedi/jcl/jcl/examples/windows/debug/stacktrack/StackTrackDLLsExample.dpr
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 219 |
2017-06-21T03:37:03.000Z
|
2022-03-27T12:09:28.000Z
|
windows/src/ext/jedi/jcl/jcl/examples/windows/debug/stacktrack/StackTrackDLLsExample.dpr
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 4,451 |
2017-05-29T02:52:06.000Z
|
2022-03-31T23:53:23.000Z
|
windows/src/ext/jedi/jcl/jcl/examples/windows/debug/stacktrack/StackTrackDLLsExample.dpr
|
bravogeorge/keyman
|
c0797e36292de903d7313214d1f765e3d9a2bf4d
|
[
"MIT"
] | 72 |
2017-05-26T04:08:37.000Z
|
2022-03-03T10:26:20.000Z
|
program StackTrackDLLsExample;
{$I jcl.inc}
uses
Forms,
StackTrackDLLsDemoMain in 'StackTrackDLLsDemoMain.pas' {MainForm},
ExceptDlg in '..\..\..\..\experts\repository\ExceptionDialog\StandardDialogs\ExceptDlg.pas' {ExceptionDialog};
{$R *.res}
{$R ..\..\..\..\source\windows\JclCommCtrlAsInvoker.res}
begin
Application.Initialize;
Application.CreateForm(TMainForm, MainForm);
Application.Run;
end.
| 23.055556 | 112 | 0.742169 |
85e5ce7b4fff3dc3f205968128ef0c4ce04b6748
| 5,142 |
pas
|
Pascal
|
toolkit2/frames/ftk_frame_home.pas
|
grahamegrieve/fhirserver
|
28f69977bde75490adac663e31a3dd77bc016f7c
|
[
"BSD-3-Clause"
] | 132 |
2015-02-02T00:22:40.000Z
|
2021-08-11T12:08:08.000Z
|
toolkit2/frames/ftk_frame_home.pas
|
grahamegrieve/fhirserver
|
28f69977bde75490adac663e31a3dd77bc016f7c
|
[
"BSD-3-Clause"
] | 113 |
2015-03-20T01:55:20.000Z
|
2021-10-08T16:15:28.000Z
|
toolkit2/frames/ftk_frame_home.pas
|
grahamegrieve/fhirserver
|
28f69977bde75490adac663e31a3dd77bc016f7c
|
[
"BSD-3-Clause"
] | 49 |
2015-04-11T14:59:43.000Z
|
2021-03-30T10:29:18.000Z
|
unit ftk_frame_home;
{
Copyright (c) 2001-2021, Health Intersections Pty Ltd (http://www.healthintersections.com.au)
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of HL7 nor the names of its contributors may be used to
endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
}
{$i fhir.inc}
interface
uses
Classes, SysUtils, Forms, Controls, StdCtrls, ComCtrls, ExtCtrls, Dialogs, LclIntf,
MarkdownProcessor,
fsl_utilities, fsl_json,
fui_lcl_managers,
fhir_common, fhir_factory, fhir_client,
ftk_utilities, ftk_constants, ftk_context, HtmlView, ftk_store_temp,
ftk_worker_base, HtmlGlobals;
type
TFrame = TBaseWorkerFrame;
THomePageFrame = class;
{ THomePageFrame }
THomePageFrame = class(TFrame)
HtmlViewer1: THtmlViewer;
lbMRU: TListBox;
Panel1: TPanel;
Panel2: TPanel;
Panel3: TPanel;
procedure FrameResize(Sender: TObject);
procedure HtmlViewer1HotSpotClick(Sender: TObject; const SRC: ThtString;
var Handled: Boolean);
procedure lbMRUDblClick(Sender: TObject);
procedure lbMRUShowHint(Sender: TObject; HintInfo: PHintInfo);
private
FTempStore: TFHIRToolkitTemporaryStorage;
FMru : TStringList;
procedure SetTempStore(AValue: TFHIRToolkitTemporaryStorage);
protected
procedure save(json : TJsonObject); override;
public
destructor Destroy; override;
procedure init(json : TJsonObject); override;
procedure saveStatus; override;
procedure getFocus; override;
property TempStore : TFHIRToolkitTemporaryStorage read FTempStore write SetTempStore;
end;
implementation
{$R *.lfm}
uses
frm_main;
const
HOME_PAGE =
'## Welcome to the FHIR Toolkit'+#13#10+#13#10+
'The FHIR Toolkit allows you to edit and validate all sorts of files that are useful when working with FHIR content.'+#13#10+
'In addition, you can connect to servers and explore them.</p>'+#13#10+
''+#13#10+
'## User Help'+#13#10+
'The best place to task for help is on the [tooling stream on chat.fhir.org](https://chat.fhir.org/#narrow/stream/179239-tooling).'+#13#10+
'Note that you might be ''encouraged'' to contribute to the documentation '#$F609'. '+#13#10+
''+#13#10;
{ THomePageFrame }
destructor THomePageFrame.Destroy;
begin
FMru.Free;
FTempStore.free;
inherited;
end;
procedure THomePageFrame.saveStatus;
begin
inherited;
end;
procedure THomePageFrame.getFocus;
var
s : String;
begin
FMRU.clear;
TempStore.getMRUListRaw(FMRU);
lbMRU.items.clear;
for s in FMru do
lbMRU.Items.add(s.Substring(s.IndexOf('|')+1));
end;
procedure THomePageFrame.init(json: TJsonObject);
var
proc : TMarkdownProcessor;
begin
FMru := TStringList.create;
proc := TMarkdownProcessor.createDialect(mdDaringFireball); // or flavor of your choice
try
proc.allowUnsafe := false;
HtmlViewer1.LoadFromString(proc.process(HOME_PAGE));
finally
proc.free;
end;
end;
procedure THomePageFrame.lbMRUDblClick(Sender: TObject);
var
s : string;
begin
s := FMru[lbMRU.ItemIndex];
s := s.Substring(0, s.IndexOf('|'));
MainToolkitForm.openFile(s);
end;
procedure THomePageFrame.FrameResize(Sender: TObject);
begin
panel1.width := width div 2;
end;
procedure THomePageFrame.HtmlViewer1HotSpotClick(Sender: TObject; const SRC: ThtString; var Handled: Boolean);
begin
Handled := true;
OpenURL(src);
end;
procedure THomePageFrame.lbMRUShowHint(Sender: TObject; HintInfo: PHintInfo);
begin
end;
procedure THomePageFrame.SetTempStore(AValue: TFHIRToolkitTemporaryStorage);
begin
FTempStore.Free;
FTempStore := AValue;
end;
procedure THomePageFrame.save(json: TJsonObject);
begin
json.str['home-page'] := 'true';
end;
end.
| 29.895349 | 144 | 0.730455 |
83e261a3959924521e174541babb93b40ba92400
| 5,609 |
pas
|
Pascal
|
components/jcl/experts/stacktraceviewer/JclStackTraceViewerMainFormDelphi.pas
|
padcom/delcos
|
dc9e8ac8545c0e6c0b4e963d5baf0dc7d72d2bf0
|
[
"Apache-2.0"
] | 15 |
2016-08-24T07:32:49.000Z
|
2021-11-16T11:25:00.000Z
|
components/jcl/experts/stacktraceviewer/JclStackTraceViewerMainFormDelphi.pas
|
CWBudde/delcos
|
656384c43c2980990ea691e4e52752d718fb0277
|
[
"Apache-2.0"
] | 1 |
2016-08-24T19:00:34.000Z
|
2016-08-25T19:02:14.000Z
|
components/jcl/experts/stacktraceviewer/JclStackTraceViewerMainFormDelphi.pas
|
padcom/delcos
|
dc9e8ac8545c0e6c0b4e963d5baf0dc7d72d2bf0
|
[
"Apache-2.0"
] | 4 |
2015-11-06T12:15:36.000Z
|
2018-10-08T15:17:17.000Z
|
{**************************************************************************************************}
{ }
{ Project JEDI Code Library (JCL) }
{ }
{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); }
{ you may not use this file except in compliance with the License. You may obtain a copy of the }
{ License at http://www.mozilla.org/MPL/ }
{ }
{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF }
{ ANY KIND, either express or implied. See the License for the specific language governing rights }
{ and limitations under the License. }
{ }
{ The Original Code is JclStackTraceViewerMainFormDelphi.pas. }
{ }
{ The Initial Developer of the Original Code is Uwe Schuster. }
{ Portions created by Uwe Schuster are Copyright (C) 2009 Uwe Schuster. All rights reserved. }
{ }
{ Contributor(s): }
{ Uwe Schuster (uschuster) }
{ }
{**************************************************************************************************}
{ }
{ Last modified: $Date:: 2009-08-25 20:22:46 +0200 (mar., 25 août 2009) $ }
{ Revision: $Rev:: 2969 $ }
{ Author: $Author:: outchy $ }
{ }
{**************************************************************************************************}
unit JclStackTraceViewerMainFormDelphi;
{$I jcl.inc}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Docktoolform, StdCtrls, ComCtrls, Menus,
ActnList, ToolWin, ExtCtrls, IniFiles,
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
JclStackTraceViewerOptions, JclStackTraceViewerMainFrame;
type
TfrmStackView = class(TDockableToolbarForm)
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
ToolButton5: TToolButton;
ToolButton6: TToolButton;
ToolButton7: TToolButton;
MainFrame: TfrmMain;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure SetOptions(const Value: TExceptionViewerOption);
function GetOptions: TExceptionViewerOption;
public
{ Public declarations }
procedure LoadWindowState(ADesktop: TMemIniFile); override;
procedure SaveWindowState(ADesktop: TMemIniFile; AIsProject: Boolean); override;
property Options: TExceptionViewerOption read GetOptions write SetOptions;
end;
var
frmStackView: TfrmStackView;
{$IFDEF UNITVERSIONING}
const
UnitVersioning: TUnitVersionInfo = (
RCSfile: '$URL: https://jcl.svn.sourceforge.net:443/svnroot/jcl/tags/JCL-2.2-Build3970/jcl/experts/stacktraceviewer/JclStackTraceViewerMainFormDelphi.pas $';
Revision: '$Revision: 2969 $';
Date: '$Date: 2009-08-25 20:22:46 +0200 (mar., 25 août 2009) $';
LogPath: 'JCL\experts\stacktraceviewer';
Extra: '';
Data: nil
);
{$ENDIF UNITVERSIONING}
implementation
uses
JclOtaConsts,
JclStackTraceViewerImpl;
{$R *.dfm}
{ TfrmStackView }
procedure TfrmStackView.FormCreate(Sender: TObject);
begin
inherited;
DeskSection := JclStackTraceViewerDesktopIniSection;
AutoSave := True;
if Assigned(StackTraceViewerExpert) then
Icon := StackTraceViewerExpert.Icon;
end;
function TfrmStackView.GetOptions: TExceptionViewerOption;
begin
Result := MainFrame.Options;
end;
procedure TfrmStackView.LoadWindowState(ADesktop: TMemIniFile);
begin
inherited LoadWindowState(ADesktop);
if Assigned(ADesktop) then
MainFrame.LoadWindowState(ADesktop);
end;
procedure TfrmStackView.SaveWindowState(ADesktop: TMemIniFile; AIsProject: Boolean);
begin
inherited SaveWindowState(ADesktop, AIsProject);
if SaveStateNecessary and Assigned(ADesktop) then
MainFrame.SaveWindowState(ADesktop, AIsProject);
end;
procedure TfrmStackView.SetOptions(const Value: TExceptionViewerOption);
begin
MainFrame.Options := Value;
end;
{$IFDEF UNITVERSIONING}
initialization
RegisterUnitVersion(HInstance, UnitVersioning);
finalization
UnregisterUnitVersion(HInstance);
{$ENDIF UNITVERSIONING}
end.
| 42.492424 | 162 | 0.499198 |
f100da86101c66623133b48e529f36c55f2d5e35
| 1,721 |
pas
|
Pascal
|
src/core/uMsg.pas
|
vdisasm/vdisasm
|
5827a579782d247e51e281533362517318dc47b4
|
[
"MIT"
] | 34 |
2015-05-04T03:55:42.000Z
|
2021-08-22T09:57:44.000Z
|
src/core/uMsg.pas
|
vdisasm/vdisasm
|
5827a579782d247e51e281533362517318dc47b4
|
[
"MIT"
] | null | null | null |
src/core/uMsg.pas
|
vdisasm/vdisasm
|
5827a579782d247e51e281533362517318dc47b4
|
[
"MIT"
] | 11 |
2016-08-11T10:00:15.000Z
|
2020-11-27T06:00:09.000Z
|
{
*
* Message manager.
*
* Implements adding, removing listeners and sending messages.
*
}
unit uMsg;
interface
uses
System.Generics.Collections,
VDAPI;
type
TListenerDic = TDictionary<TVDMessageListenerProc, integer>;
TVDMsgMgr = class(TInterfacedObject, IVDMessageManager)
private
FListeners: TListenerDic;
public
constructor Create;
destructor Destroy; override;
procedure AddListenerProc(Proc: TVDMessageListenerProc); stdcall;
procedure RemoveListenerProc(Proc: TVDMessageListenerProc); stdcall;
procedure Broadcast(Msg: TVDMessage; Param: Pointer); stdcall;
end;
implementation
uses
uDebugSession;
{ TVDMsgMgr }
procedure TVDMsgMgr.AddListenerProc(Proc: TVDMessageListenerProc);
begin
if Assigned(Proc) then
begin
// If it's first listener added we have to notify of core was
// initialized.
if FListeners.Count = 0 then
Proc(TVDMessage.MSG_CORE_INIT, nil);
// Register listener.
if not FListeners.ContainsKey(Proc) then
FListeners.Add(Proc, 0);
end;
end;
procedure TVDMsgMgr.RemoveListenerProc(Proc: TVDMessageListenerProc);
begin
if Assigned(Proc) then
if FListeners.ContainsKey(Proc) then
FListeners.Remove(Proc);
end;
procedure TVDMsgMgr.Broadcast(Msg: TVDMessage; Param: Pointer);
var
ListenerProc: TVDMessageListenerProc;
begin
// Implicit msg handlers.
case Msg of
MSG_DBG_STOPPED:
(CoreGet.DebugSession as TVDDebugSession).on_MSG_DBG_STOPPED;
end;
for ListenerProc in FListeners.Keys do
ListenerProc(Msg, Param);
end;
constructor TVDMsgMgr.Create;
begin
FListeners := TListenerDic.Create;
end;
destructor TVDMsgMgr.Destroy;
begin
FListeners.Free;
inherited;
end;
end.
| 20.247059 | 72 | 0.748402 |
6af87e6e70ada469342729da2e99c65caa1b8a10
| 2,258 |
dfm
|
Pascal
|
src/uAddFieldDialog.dfm
|
akhfaern/MySQLDummyDataCreator
|
c67fba5365cb00ee23e823e47fa4e5a025164d57
|
[
"MIT"
] | null | null | null |
src/uAddFieldDialog.dfm
|
akhfaern/MySQLDummyDataCreator
|
c67fba5365cb00ee23e823e47fa4e5a025164d57
|
[
"MIT"
] | null | null | null |
src/uAddFieldDialog.dfm
|
akhfaern/MySQLDummyDataCreator
|
c67fba5365cb00ee23e823e47fa4e5a025164d57
|
[
"MIT"
] | null | null | null |
object frmAddFieldDialog: TfrmAddFieldDialog
Left = 0
Top = 0
BorderStyle = bsDialog
Caption = 'Add Field'
ClientHeight = 171
ClientWidth = 290
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
Position = poMainFormCenter
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 13
object lbFieldName: TLabel
Left = 24
Top = 24
Width = 56
Height = 13
Caption = 'Field Name:'
end
object lbFieldType: TLabel
Left = 24
Top = 56
Width = 53
Height = 13
Caption = 'Field Type:'
end
object lbMaxFieldLen: TLabel
Left = 24
Top = 88
Width = 69
Height = 13
Caption = 'Max Field Len:'
end
object lbEnumValues: TLabel
Left = 24
Top = 88
Width = 60
Height = 13
Caption = 'Enum Values'
Visible = False
end
object edtFieldName: TEdit
Left = 104
Top = 21
Width = 161
Height = 21
TabOrder = 0
end
object cmbFieldTypes: TComboBox
Left = 104
Top = 52
Width = 161
Height = 21
Style = csDropDownList
TabOrder = 1
OnChange = cmbFieldTypesChange
Items.Strings = (
'Random String'
'Random Int'
'Name'
'Name + '#39' '#39' + Surname'
'Surname'
'Random Email'
'Email From Name + Surname + Random Int'
'Random Date'
'Random Time'
'Random DateTime'
'Enum')
end
object edtMaxFieldLen: TSpinEdit
Left = 104
Top = 85
Width = 161
Height = 22
MaxValue = 0
MinValue = 0
TabOrder = 2
Value = 0
end
object btnAddField: TButton
Left = 190
Top = 128
Width = 75
Height = 25
Caption = 'Add Field'
TabOrder = 3
OnClick = btnAddFieldClick
end
object btnCancel: TButton
Left = 109
Top = 128
Width = 75
Height = 25
Caption = 'Cancel'
TabOrder = 4
OnClick = btnCancelClick
end
object edtEnumValues: TEdit
Left = 104
Top = 86
Width = 161
Height = 21
TabOrder = 5
Text = '0, 1, 2'
Visible = False
end
end
| 19.807018 | 47 | 0.564216 |
cdff1cdf04eb3ea078a8080d336082186f23629a
| 231 |
dpr
|
Pascal
|
Components/cnvcl/Examples/SunRiseSet/SunRiseSet.dpr
|
98kmir2/98kmir2
|
46196a161d46cc7a85d168dca683b4aff477a709
|
[
"BSD-3-Clause"
] | 15 |
2020-02-13T11:59:11.000Z
|
2021-12-31T14:53:44.000Z
|
Components/cnvcl/Examples/SunRiseSet/SunRiseSet.dpr
|
bsjzx8/98
|
46196a161d46cc7a85d168dca683b4aff477a709
|
[
"BSD-3-Clause"
] | null | null | null |
Components/cnvcl/Examples/SunRiseSet/SunRiseSet.dpr
|
bsjzx8/98
|
46196a161d46cc7a85d168dca683b4aff477a709
|
[
"BSD-3-Clause"
] | 13 |
2020-02-20T07:22:09.000Z
|
2021-12-31T14:56:09.000Z
|
program SunRiseSet;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
CnCalendar in '..\..\Source\Common\CnCalendar.pas';
{$R *.RES}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
| 15.4 | 53 | 0.701299 |
8536101cb898e47232b062dd8d2253f57179e6dd
| 2,955 |
pas
|
Pascal
|
src/tagsparamshelper.pas
|
alb42/MUIClass
|
4223b4f456b770d40f9542707705cd94af612cd9
|
[
"Unlicense"
] | 3 |
2018-02-16T17:44:03.000Z
|
2018-12-01T20:59:17.000Z
|
src/tagsparamshelper.pas
|
alb42/MUIClass
|
4223b4f456b770d40f9542707705cd94af612cd9
|
[
"Unlicense"
] | null | null | null |
src/tagsparamshelper.pas
|
alb42/MUIClass
|
4223b4f456b770d40f9542707705cd94af612cd9
|
[
"Unlicense"
] | null | null | null |
{
*****************************************************************************
* TagsParamsHelper.pas *
* -------------- *
* Taglist handling for Amiga-style systems *
* *
*****************************************************************************
}
unit TagsParamsHelper;
{$mode objfpc}{$H+}
interface
uses
Exec, Utility,
Classes, SysUtils, Math;
const
TagTrue = 1;
TagFalse = 0;
type
{ TATagList }
TATagList = object
private
List: array of TTagItem;
procedure TagDbgOut(txt: string);
public
procedure Clear;
function GetTagPointer: PTagItem;
procedure AddTag(Tag: LongWord; Data: NativeUInt);
procedure AddTags(const AList: array of NativeUInt);
procedure DebugPrint;
end;
operator := (AList: TATagList): PTagItem;
implementation
{ TATagList }
procedure TATagList.Clear;
begin
SetLength(List, 1);
List[0].ti_Tag := TAG_DONE;
List[0].ti_Data := 0;
end;
function TATagList.GetTagPointer: PTagItem;
begin
Result := @(List[0]);
end;
procedure TATagList.AddTag(Tag: LongWord; Data: NativeUInt);
var
CurIdx: Integer;
begin
if Tag = TAG_DONE then
Exit;
CurIdx := Max(0, High(List));
SetLength(List, CurIdx + 2);
List[CurIdx].ti_Tag := Tag;
List[CurIdx].ti_Data := Data;
List[CurIdx + 1].ti_Tag := TAG_DONE;
List[CurIdx + 1].ti_Data := TAG_DONE;
end;
procedure TATagList.AddTags(const AList: array of NativeUInt);
var
Tag: LongWord;
Data: NativeUInt;
i: Integer;
begin
i := 0;
while i <= High(AList) do
begin
Tag := AList[i];
Inc(i);
if i <= High(AList) then
begin
Data := AList[i];
Self.AddTag(Tag, Data);
Inc(i);
end else
begin
if Tag <> TAG_DONE then
{$ifdef HASAMIGA}
SysDebugln('AddTags called with odd number of Parameter (' + IntToStr(Length(AList)) + ')');
{$else}
Writeln('AddTags called with odd number of Parameter (' + IntToStr(Length(AList)) + ')');
{$endif}
end;
end;
end;
procedure TATagList.TagDbgOut(txt: string);
begin
{$ifdef HASAMIGA}
SysDebugln('TagList('+HexStr(@List[0]) + '):' + txt);
{$else}
Writeln('TagList('+HexStr(@List[0]) + '):' + txt);
{$endif}
end;
procedure TATagList.DebugPrint;
var
i: Integer;
begin
TagDbgOut('List with ' + IntToStr(Length(List)) + ' Entries.');
for i := 0 to High(List) do
begin
//TagDbgOut('+ ' + IntToStr(i) + '. ' + HexStr(@List[i]));
TagDbgOut(' ' + IntToStr(i) + '. Tag: ' + HexStr(Pointer(List[i].ti_Tag)) + ' Data: ' + HexStr(Pointer(List[i].ti_Data)));
//TagDbgOut('- ' + IntToStr(i) + '. ' + HexStr(@List[i]));
end;
TagDbgOut('End Of List');
end;
operator := (AList: TATagList): PTagItem;
begin
Result := AList.GetTagPointer;
end;
end.
| 22.730769 | 127 | 0.548223 |
f1cee10338ea883f9e74b866aac0ef49488ffaa6
| 340 |
dpr
|
Pascal
|
engine/Projects/ThundaxSimulationPlant/ThundaxSimulationPlant.dpr
|
jomael/thundax-delphi-physics-engine
|
a86f38cdaba1f00c5ef5296a8ae67b816a59448e
|
[
"MIT"
] | 56 |
2015-03-15T10:22:50.000Z
|
2022-02-22T11:58:08.000Z
|
engine/Projects/ThundaxSimulationPlant/ThundaxSimulationPlant.dpr
|
jomael/thundax-delphi-physics-engine
|
a86f38cdaba1f00c5ef5296a8ae67b816a59448e
|
[
"MIT"
] | 2 |
2016-07-10T07:57:05.000Z
|
2019-10-14T15:49:06.000Z
|
engine/Projects/ThundaxSimulationPlant/ThundaxSimulationPlant.dpr
|
jomael/thundax-delphi-physics-engine
|
a86f38cdaba1f00c5ef5296a8ae67b816a59448e
|
[
"MIT"
] | 18 |
2015-07-17T19:24:39.000Z
|
2022-01-20T05:40:46.000Z
|
program ThundaxSimulationPlant;
uses
Forms,
fPlantDemo in 'fPlantDemo.pas' {FormMainPlantDemo};
{$R *.res}
begin
Application.Initialize;
ReportMemoryLeaksOnShutdown := True;
Application.Title := 'Thundax Simulation Plant';
Application.CreateForm(TFormMainPlantDemo, FormMainPlantDemo);
Application.Run;
end.
| 21.25 | 65 | 0.741176 |
f153f3c8de0c1aa37780716474440c2f92c4f47a
| 8,219 |
pas
|
Pascal
|
Libraries/DDuce/Components/DDuce.Components.PropertyInspector.CollectionEditor.pas
|
juliomar/Concepts
|
ef75301c6cc10c4cf7806432a970b87bf88937e2
|
[
"Apache-2.0"
] | null | null | null |
Libraries/DDuce/Components/DDuce.Components.PropertyInspector.CollectionEditor.pas
|
juliomar/Concepts
|
ef75301c6cc10c4cf7806432a970b87bf88937e2
|
[
"Apache-2.0"
] | null | null | null |
Libraries/DDuce/Components/DDuce.Components.PropertyInspector.CollectionEditor.pas
|
juliomar/Concepts
|
ef75301c6cc10c4cf7806432a970b87bf88937e2
|
[
"Apache-2.0"
] | 1 |
2021-03-16T16:06:57.000Z
|
2021-03-16T16:06:57.000Z
|
{
Copyright (C) 2013-2019 Tim Sinaeve tim.sinaeve@gmail.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
}
{$I DDuce.inc}
unit DDuce.Components.PropertyInspector.CollectionEditor;
interface
uses
System.SysUtils, System.Classes, System.TypInfo, System.ImageList,
System.Actions,
Winapi.Windows,
Vcl.ExtCtrls, Vcl.ComCtrls, Vcl.ActnList, Vcl.ImgList, Vcl.ToolWin,
Vcl.Controls, Vcl.Forms, Vcl.Menus,
DDuce.Components.PropertyInspector;
type
TfrmCollectionEditor = class(TForm)
aclMain : TActionList;
actAdd : TAction;
actDelete : TAction;
actDeleteAll : TAction;
actDown : TAction;
actSelectAll : TAction;
actUp : TAction;
btnAdd : TToolButton;
btnDelete : TToolButton;
btnDown : TToolButton;
btnSeperator : TToolButton;
btnUp : TToolButton;
imlMain : TImageList;
lvCollectionItems : TListView;
mniAdd : TMenuItem;
mniDelete : TMenuItem;
mniDeleteAll : TMenuItem;
mniSelectAll : TMenuItem;
N1 : TMenuItem;
pnlLeft : TPanel;
pnlRight : TPanel;
ppmMain : TPopupMenu;
splVertical : TSplitter;
tlbMain : TToolBar;
procedure actAddExecute(Sender: TObject);
procedure actDeleteExecute(Sender: TObject);
procedure actUpExecute(Sender: TObject);
procedure actDownExecute(Sender: TObject);
procedure actSelectAllExecute(Sender: TObject);
procedure lvCollectionItemsDragDrop(
Sender : TObject;
Source : TObject;
X : Integer;
Y : Integer
);
procedure lvCollectionItemsDragOver(
Sender : TObject;
Source : TObject;
X : Integer;
Y : Integer;
State : TDragState;
var Accept : Boolean
);
procedure lvCollectionItemsSelectItem(
Sender : TObject;
Item : TListItem;
Selected : Boolean
);
procedure FInspectorModified(Sender: TObject);
private
FCollection : TCollection;
FInspector : TPropertyInspector;
function GetActiveItem: TCollectionItem;
protected
procedure UpdateItems;
procedure UpdateInspector;
procedure UpdateActions; override;
public
constructor Create(
AOwner : TComponent;
ACollection : TCollection
); reintroduce;
property ActiveItem : TCollectionItem
read GetActiveItem;
end;
procedure ExecuteCollectionEditor(ACollection : TCollection);
implementation
uses
System.Rtti,
DDuce.Reflect;
{$R *.dfm}
{$REGION 'interfaced routines'}
procedure ExecuteCollectionEditor(ACollection : TCollection);
var
Form : TfrmCollectionEditor;
begin
Form := TfrmCollectionEditor.Create(Application, ACollection);
try
Form.ShowModal;
finally
Form.Free;
end;
end;
{$ENDREGION}
{$REGION 'construction and destruction'}
constructor TfrmCollectionEditor.Create(AOwner: TComponent;
ACollection: TCollection);
begin
inherited Create(AOwner);
FCollection := ACollection;
FInspector := TPropertyInspector.Create(Self);
FInspector.Parent := pnlRight;
FInspector.Align := alClient;
FInspector.Splitter := FInspector.ClientWidth div 2;
FInspector.OnModified := FInspectorModified;
UpdateItems;
end;
{$ENDREGION}
{$REGION 'property access methods'}
function TfrmCollectionEditor.GetActiveItem: TCollectionItem;
var
I : Integer;
begin
if lvCollectionItems.ItemIndex = -1 then
I := 0
else
I := lvCollectionItems.ItemIndex;
Result := TCollectionItem(lvCollectionItems.Items[I].Data);
end;
{$ENDREGION}
{$REGION 'action handlers'}
procedure TfrmCollectionEditor.actAddExecute(Sender: TObject);
begin
FCollection.Add;
UpdateItems;
end;
procedure TfrmCollectionEditor.actDeleteExecute(Sender: TObject);
begin
if FCollection.Count > 0 then
begin
FCollection.Delete(ActiveItem.Index);
UpdateItems;
end;
end;
procedure TfrmCollectionEditor.actSelectAllExecute(Sender: TObject);
begin
lvCollectionItems.SelectAll;
end;
procedure TfrmCollectionEditor.actUpExecute(Sender: TObject);
var
I : Integer;
begin
if ActiveItem.Index > 0 then
begin
ActiveItem.Index := ActiveItem.Index - 1;
I := ActiveItem.Index;
UpdateItems;
lvCollectionItems.ItemIndex := I;
end;
end;
procedure TfrmCollectionEditor.actDownExecute(Sender: TObject);
var
I : Integer;
begin
if ActiveItem.Index < FCollection.Count - 1 then
begin
ActiveItem.Index := ActiveItem.Index + 1;
I := ActiveItem.Index;
UpdateItems;
lvCollectionItems.ItemIndex := I;
end;
end;
{$ENDREGION}
{$REGION 'event handlers'}
procedure TfrmCollectionEditor.lvCollectionItemsDragDrop(Sender,
Source: TObject; X, Y: Integer);
begin
if not Assigned(Sender) or not Assigned(Source) or
not Assigned(lvCollectionItems.DropTarget) or
not Assigned(lvCollectionItems.Selected) or
(lvCollectionItems.Selected.Index = lvCollectionItems.DropTarget.Index)
then
Exit;
FCollection.Items[lvCollectionItems.Selected.Index].Index :=
lvCollectionItems.DropTarget.Index;
UpdateItems;
end;
procedure TfrmCollectionEditor.lvCollectionItemsDragOver(Sender,
Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
begin
Accept := True;
end;
procedure TfrmCollectionEditor.lvCollectionItemsSelectItem(Sender: TObject;
Item: TListItem; Selected: Boolean);
begin
if Selected then
UpdateInspector;
end;
procedure TfrmCollectionEditor.FInspectorModified(Sender: TObject);
var
S : string;
V : TValue;
AI : TPropsPageItem;
PI : TPropsPageItem;
SL : TStringList;
O : TObject;
begin
SL := TStringList.Create;
try
AI := FInspector.ActiveItem;
O := FInspector.Objects[0];
S := AI.Caption;
V := Reflect.Properties(O).Values[S];
PI := AI;
while Assigned(PI) do
begin
SL.Add(PI.Caption);
PI := PI.Parent;
end;
// todo TS fix this!
// for I := 0 to lvCollectionItems.Items.Count - 1 do
// begin
// if lvCollectionItems.Items[I].Selected then
// begin
// O := FCollection.Items[I];
// for J := SL.Count -1 downto 1 do
// O := GetObjectProp(O, SL[J]);
// Reflect.Properties(O).Values[S] := V;
// end;
// end;
finally
SL.Free;
end;
end;
{$ENDREGION}
{$REGION 'protected methods'}
procedure TfrmCollectionEditor.UpdateActions;
var
B: Boolean;
begin
inherited;
B := FCollection.Count > 1;
actDelete.Enabled := FCollection.Count > 0;
actUp.Enabled := B and (lvCollectionItems.ItemIndex > 0);
actDown.Enabled := B and (lvCollectionItems.ItemIndex < FCollection.Count - 1);
end;
procedure TfrmCollectionEditor.UpdateInspector;
var
I : Integer;
begin
FInspector.BeginUpdate;
try
FInspector.Clear;
if Assigned(lvCollectionItems.Items[lvCollectionItems.ItemIndex].Data) then
begin
FInspector.Add(
TPersistent(lvCollectionItems.Items[lvCollectionItems.ItemIndex].Data)
);
for I := 0 to FInspector.Items.Count - 1 do
begin
if FInspector.Items[I].Expandable = mieYes then
FInspector.Items[I].Expand;
end;
end;
finally
FInspector.EndUpdate;
UpdateActions;
end;
end;
procedure TfrmCollectionEditor.UpdateItems;
var
S : string;
I : Integer;
LI : TListItem;
begin
lvCollectionItems.Clear;
for I := 0 to FCollection.Count - 1 do
begin
S := Format('%s', [FCollection.Items[I].DisplayName]);
LI := lvCollectionItems.Items.Add;
LI.Caption := IntToStr(I);
LI.SubItems.Add(S);
LI.Data := FCollection.Items[I];
end;
end;
{$ENDREGION}
end.
| 24.756024 | 81 | 0.686337 |
cdc8ed0ab15b60711891712fd2db20f7867505cb
| 1,574 |
pas
|
Pascal
|
turtle/lottrp03.pas
|
nickelsworth/swag
|
7c21c0da2291fc249b9dc5cfe121a7672a4ffc08
|
[
"BSD-2-Clause"
] | 11 |
2015-12-12T05:13:15.000Z
|
2020-10-14T13:32:08.000Z
|
turtle/lottrp03.pas
|
nickelsworth/swag
|
7c21c0da2291fc249b9dc5cfe121a7672a4ffc08
|
[
"BSD-2-Clause"
] | null | null | null |
turtle/lottrp03.pas
|
nickelsworth/swag
|
7c21c0da2291fc249b9dc5cfe121a7672a4ffc08
|
[
"BSD-2-Clause"
] | 8 |
2017-05-05T05:24:01.000Z
|
2021-07-03T20:30:09.000Z
|
(* ┌───────────────────────────────────────────────────────────┐
│ Programated by Vladimir Zahoransky │
│ Vladko software │
│ Contact : zahoran@cezap.ii.fmph.uniba.sk │
│ Program tema : Raptile, turtles !!! │
└───────────────────────────────────────────────────────────┘ *)
{
This is small raptile. He just rotate. But there are turtles.
It is easy to undestand, if you know dynVelakor. All turtles have
defined just coefficient and in 3 for cycles is this effekt.
}
Uses dynvelakor,dynkor;
Const
n=60;
nn=640/n;
r=8;
nr=200 div r;
Var
v:velakor;
i:integer;
Type
PMyTur=^MyTur;
MyTur=Object(kor)
k:real;
Constructor init(x,y,u:real);
Procedure koef(kk:real);
Procedure dopredu(d:real); virtual;
End;
Constructor MyTur.init;
Begin
Kor.init(x,y,u);
K:=1;
End;
Procedure MyTur.koef(kk:real);
Begin
k:=kk;
End;
Procedure MyTur.dopredu(d:real);
Begin
vpravo(180/nr);
kor.dopredu(d*k);
End;
Begin
With v do Begin
init;
For i:=1 to n do Begin
Pridajkor(new(PMyTur,init(nn*i-320,0,0)));
PMyTur(k[pk])^.koef(sin(nn*rad*i));
End;
Ph;
Ukaz;
Repeat
For I:=1 to nr do Dopredu(r);
For i:=1 to 2*nr do Dopredu(r);
For i:=1 to nr do Dopredu(r);
Until false;
Koniec;
End;
End.
| 21.561644 | 70 | 0.467598 |
4715fd020ae60b1ca24712e115d02b8486ff2c34
| 17,522 |
pas
|
Pascal
|
Pixel_Biling.pas
|
zFz0000/AlgoritaLanjut
|
1a1b1ae966c71977fcd3d665dfde13db7d034e35
|
[
"MIT"
] | 1 |
2019-03-26T13:55:25.000Z
|
2019-03-26T13:55:25.000Z
|
Pixel_Biling.pas
|
zFz0000/AlgoritaLanjut
|
1a1b1ae966c71977fcd3d665dfde13db7d034e35
|
[
"MIT"
] | null | null | null |
Pixel_Biling.pas
|
zFz0000/AlgoritaLanjut
|
1a1b1ae966c71977fcd3d665dfde13db7d034e35
|
[
"MIT"
] | null | null | null |
unit Pixel_Biling;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls, ExtCtrls, jpeg, frxClass, Menus, ComCtrls,
Mask, XPMan;
type
TForm1 = class(TForm)
Image1: TImage;
Panel1: TPanel;
Panel2: TPanel;
Panel4: TPanel;
Panel5: TPanel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Label7: TLabel;
Edit4: TEdit;
Button1: TButton;
Timer1: TTimer;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
GroupBox3: TGroupBox;
GroupBox4: TGroupBox;
GroupBox5: TGroupBox;
GroupBox6: TGroupBox;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
RadioGroup1: TRadioGroup;
RadioGroup2: TRadioGroup;
RadioGroup3: TRadioGroup;
RadioGroup4: TRadioGroup;
RadioGroup5: TRadioGroup;
RadioGroup6: TRadioGroup;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
RadioButton5: TRadioButton;
RadioButton6: TRadioButton;
RadioButton7: TRadioButton;
RadioButton8: TRadioButton;
RadioButton9: TRadioButton;
RadioButton10: TRadioButton;
RadioButton11: TRadioButton;
RadioButton12: TRadioButton;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
BitBtn3: TBitBtn;
BitBtn4: TBitBtn;
BitBtn5: TBitBtn;
BitBtn6: TBitBtn;
BitBtn7: TBitBtn;
BitBtn8: TBitBtn;
BitBtn9: TBitBtn;
BitBtn10: TBitBtn;
BitBtn11: TBitBtn;
BitBtn12: TBitBtn;
Label22: TLabel;
Label23: TLabel;
frxReport1: TfrxReport;
MainMenu1: TMainMenu;
File1: TMenuItem;
Edit5: TMenuItem;
Help1: TMenuItem;
Save1: TMenuItem;
N1: TMenuItem;
Exit1: TMenuItem;
Reset1: TMenuItem;
About1: TMenuItem;
Save2: TMenuItem;
Label24: TLabel;
Label25: TLabel;
SaveDialog1: TSaveDialog;
OpenDialog1: TOpenDialog;
Memo1: TMemo;
ProgressBar1: TProgressBar;
XPManifest1: TXPManifest;
Label20: TLabel;
GroupBox7: TGroupBox;
RadioButton13: TRadioButton;
RadioButton14: TRadioButton;
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn3Click(Sender: TObject);
procedure BitBtn5Click(Sender: TObject);
procedure BitBtn7Click(Sender: TObject);
procedure BitBtn9Click(Sender: TObject);
procedure BitBtn11Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Exit1Click(Sender: TObject);
procedure About1Click(Sender: TObject);
procedure Save1Click(Sender: TObject);
procedure Save2Click(Sender: TObject);
procedure BitBtn4Click(Sender: TObject);
procedure BitBtn6Click(Sender: TObject);
procedure BitBtn8Click(Sender: TObject);
procedure BitBtn10Click(Sender: TObject);
procedure BitBtn12Click(Sender: TObject);
procedure Reset1Click(Sender: TObject);
procedure WMSyscommand(Var msg: TWmSysCommand); message WM_SYSCOMMAND;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
time1,time2,time3: TDateTime;
int1: Double;
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
var
xbiaya,xlama,biaya:real;
sbiaya,slama:string;
begin
if (BitBtn1.Caption = 'Start') then
begin
Label9.Caption := TimeToStr(Time);
BitBtn1.Kind := bkHelp;
BitBtn1.Caption := 'Check'
end
else if (BitBtn1.Caption = 'Check') then
begin
time1 := StrToTime(Label9.Caption);
time2 := (time - time1);
if (RadioButton1.Checked = True) then
Begin
biaya := 45;
RadioButton13.Checked := True;
End
else
Begin
biaya := 50;
RadioButton14.Checked := True;
End;
xlama := (time - time1)*24*60;
str(xlama:6:2,slama);
xbiaya := xlama*biaya;
str(xbiaya:8:0,sbiaya);
Edit3.Text := stringreplace(sbiaya, ' ', '',[rfReplaceAll, rfIgnoreCase]);
Edit1.Text := 'Client 1';
Edit2.Text := Label9.Caption;
Edit4.Text := TimeToStr(time2);
end;
end;
procedure TForm1.BitBtn3Click(Sender: TObject);
var
xbiaya,xlama,biaya:real;
sbiaya,slama:string;
begin
if (BitBtn3.Caption = 'Start') then
begin
Label11.Caption := TimeToStr(Time);
BitBtn3.Kind := bkHelp;
BitBtn3.Caption := 'Check'
end
else if (BitBtn3.Caption = 'Check') then
begin
time1 := StrToTime(Label11.Caption);
time2 := (time - time1);
if (RadioButton3.Checked = True) then
Begin
biaya := 45;
RadioButton13.Checked := True;
End
else
Begin
biaya := 50;
RadioButton14.Checked := True;
End;
xlama := (time - time1)*24*60;
str(xlama:6:2,slama);
xbiaya := xlama*biaya;
str(xbiaya:8:0,sbiaya);
Edit3.Text := stringreplace(sbiaya, ' ', '',[rfReplaceAll, rfIgnoreCase]);
Edit1.Text := 'Client 2';
Edit2.Text := Label11.Caption;
Edit4.Text := TimeToStr(time2);
end;
end;
procedure TForm1.BitBtn5Click(Sender: TObject);
var
xbiaya,xlama,biaya:real;
sbiaya,slama:string;
begin
if (BitBtn5.Caption = 'Start') then
begin
Label13.Caption := TimeToStr(Time);
BitBtn5.Kind := bkHelp;
BitBtn5.Caption := 'Check'
end
else if (BitBtn5.Caption = 'Check') then
begin
time1 := StrToTime(Label13.Caption);
time2 := (time - time1);
if (RadioButton5.Checked = True) then
Begin
biaya := 45;
RadioButton13.Checked := True;
End
else
Begin
biaya := 50;
RadioButton14.Checked := True;
End;
xlama := (time - time1)*24*60;
str(xlama:6:2,slama);
xbiaya := xlama*biaya;
str(xbiaya:8:0,sbiaya);
Edit3.Text := stringreplace(sbiaya, ' ', '',[rfReplaceAll, rfIgnoreCase]);
Edit1.Text := 'Client 3';
Edit2.Text := Label13.Caption;
Edit4.Text := TimeToStr(time2);
end;
end;
procedure TForm1.BitBtn7Click(Sender: TObject);
var
xbiaya,xlama,biaya:real;
sbiaya,slama:string;
begin
if (BitBtn7.Caption = 'Start') then
begin
Label15.Caption := TimeToStr(Time);
BitBtn7.Kind := bkHelp;
BitBtn7.Caption := 'Check'
end
else if (BitBtn7.Caption = 'Check') then
begin
time1 := StrToTime(Label15.Caption);
time2 := (time - time1);
if (RadioButton7.Checked = True) then
Begin
biaya := 45;
RadioButton13.Checked := True;
End
else
Begin
biaya := 50;
RadioButton14.Checked := True;
End;
xlama := (time - time1)*24*60;
str(xlama:6:2,slama);
xbiaya := xlama*biaya;
str(xbiaya:8:0,sbiaya);
Edit3.Text := stringreplace(sbiaya, ' ', '',[rfReplaceAll, rfIgnoreCase]);
Edit1.Text := 'Client 4';
Edit2.Text := Label15.Caption;
Edit4.Text := TimeToStr(time2);
end;
end;
procedure TForm1.BitBtn9Click(Sender: TObject);
var
xbiaya,xlama,biaya:real;
sbiaya,slama:string;
begin
if (BitBtn9.Caption = 'Start') then
begin
Label17.Caption := TimeToStr(Time);
BitBtn9.Kind := bkHelp;
BitBtn9.Caption := 'Check'
end
else if (BitBtn9.Caption = 'Check') then
begin
time1 := StrToTime(Label17.Caption);
time2 := (time - time1);
if (RadioButton9.Checked = True) then
Begin
biaya := 45;
RadioButton13.Checked := True;
End
else
Begin
biaya := 50;
RadioButton14.Checked := True;
End;
xlama := (time - time1)*24*60;
str(xlama:6:2,slama);
xbiaya := xlama*biaya;
str(xbiaya:8:0,sbiaya);
Edit3.Text := stringreplace(sbiaya, ' ', '',[rfReplaceAll, rfIgnoreCase]);
Edit1.Text := 'Client 5';
Edit2.Text := Label17.Caption;
Edit4.Text := TimeToStr(time2);
end;
end;
procedure TForm1.BitBtn11Click(Sender: TObject);
var
xbiaya,xlama,biaya:real;
sbiaya,slama:string;
begin
if (BitBtn11.Caption = 'Start') then
begin
Label19.Caption := TimeToStr(Time);
BitBtn11.Kind := bkHelp;
BitBtn11.Caption := 'Check'
end
else if (BitBtn11.Caption = 'Check') then
begin
time1 := StrToTime(Label19.Caption);
time2 := (time - time1);
if (RadioButton11.Checked = True) then
Begin
biaya := 45;
RadioButton13.Checked := True;
End
else
Begin
biaya := 50;
RadioButton14.Checked := True;
End;
xlama := (time - time1)*24*60;
str(xlama:6:2,slama);
xbiaya := xlama*biaya;
str(xbiaya:8:0,sbiaya);
Edit3.Text := stringreplace(sbiaya, ' ', '',[rfReplaceAll, rfIgnoreCase]);
Edit1.Text := 'Client 6';
Edit2.Text := Label19.Caption;
Edit4.Text := TimeToStr(time2);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if (application.messagebox('Yakin ingin keluar?','informasi',MB_YESNO)=IDYES) then
close;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
application.minimize;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Label3.Caption := TimeToStr(time);
end;
procedure TForm1.BitBtn2Click(Sender: TObject);
begin
if Edit1.Text = 'Client 1' then
Begin
Label9.Caption := '';
RadioButton1.Checked := False;
RadioButton2.Checked := True;
BitBtn1.Kind := bkOK;
BitBtn1.Caption := 'Start';
if (Edit1.Text = 'Client 1') then
Begin
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
RadioButton13.Checked := False;
RadioButton14.Checked := False;
end;
Label23.Caption := IntToStr(StrToInt(Label23.Caption) + 1);
Memo1.Lines.Clear;
Memo1.Lines.Add(Label23.Caption);
end
else If (Edit1.Text <> 'Client 1') and (BitBtn1.Caption = 'Check') then
Application.MessageBox('Klik Tombol Check Terlebih Dahulu', 'Pixel Billing', MB_OK or MB_ICONERROR);
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
RadioButton2.Checked := True;
RadioButton4.Checked := True;
RadioButton6.Checked := True;
RadioButton8.Checked := True;
RadioButton10.Checked := True;
RadioButton12.Checked := True;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if Edit1.Text <> '' then
Begin
Tfrxmemoview(frxReport1.FindObject('Memo9')).Memo.Text:=form1.Edit1.Text;
Tfrxmemoview(frxReport1.FindObject('Memo10')).Memo.Text:=form1.Edit2.Text;
Tfrxmemoview(frxReport1.FindObject('Memo11')).Memo.Text:='Rp '+form1.Edit3.Text+',-';
Tfrxmemoview(frxReport1.FindObject('Memo12')).Memo.Text:=form1.Edit4.Text;
if RadioButton13.Checked = True then
Tfrxmemoview(frxReport1.FindObject('Memo14')).Memo.Text:='Ya'
else
Tfrxmemoview(frxReport1.FindObject('Memo14')).Memo.Text:='Tidak';
frxReport1.ShowReport(True);
frxReport1.Print;
end;
end;
procedure TForm1.Exit1Click(Sender: TObject);
begin
if (application.messagebox('Yakin ingin keluar?','informasi',MB_YESNO)=IDYES) then
close;
end;
procedure TForm1.About1Click(Sender: TObject);
begin
Application.MessageBox('Dibuat Oleh:' + #13#10 + 'Faraaz (152018070)' + #13#10 + 'M Rauf (152018057)' + #13#10 + 'Fauzan Fathur (152018039)' + #13#10 + 'Tirtafajar (152018049)', 'Pixel Billing', MB_OK);
end;
procedure TForm1.Save1Click(Sender: TObject);
begin
if SaveDialog1.Execute = True then
Memo1.Lines.SaveToFile(SaveDialog1.FileName);
end;
procedure TForm1.Save2Click(Sender: TObject);
begin
if OpenDialog1.Execute = True then
begin
Memo1.Lines.LoadFromFile(OpenDialog1.FileName);
Label23.Caption := stringreplace(Memo1.Lines.GetText, #13#10, '',[rfReplaceAll, rfIgnoreCase]);;
end;
end;
procedure TForm1.BitBtn4Click(Sender: TObject);
begin
if Edit1.Text = 'Client 2' then
Begin
Label11.Caption := '';
RadioButton3.Checked := False;
RadioButton4.Checked := True;
BitBtn3.Kind := bkOK;
BitBtn3.Caption := 'Start';
if (Edit1.Text = 'Client 2') then
Begin
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
RadioButton13.Checked := False;
RadioButton14.Checked := False;
end;
Label23.Caption := IntToStr(StrToInt(Label23.Caption) + 1);
Memo1.Lines.Clear;
Memo1.Lines.Add(Label23.Caption);
end
else If (Edit1.Text <> 'Client 2') and (BitBtn3.Caption = 'Check') then
Application.MessageBox('Klik Tombol Check Terlebih Dahulu', 'Pixel Billing', MB_OK or MB_ICONERROR);
end;
procedure TForm1.BitBtn6Click(Sender: TObject);
begin
if Edit1.Text = 'Client 3' then
Begin
Label13.Caption := '';
RadioButton5.Checked := False;
RadioButton6.Checked := True;
BitBtn5.Kind := bkOK;
BitBtn5.Caption := 'Start';
if (Edit1.Text = 'Client 3') then
Begin
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
RadioButton13.Checked := False;
RadioButton14.Checked := False;
end;
Label23.Caption := IntToStr(StrToInt(Label23.Caption) + 1);
Memo1.Lines.Clear;
Memo1.Lines.Add(Label23.Caption);
end
else If (Edit1.Text <> 'Client 3') and (BitBtn5.Caption = 'Check') then
Application.MessageBox('Klik Tombol Check Terlebih Dahulu', 'Pixel Billing', MB_OK or MB_ICONERROR);
end;
procedure TForm1.BitBtn8Click(Sender: TObject);
begin
if Edit1.Text = 'Client 4' then
Begin
Label15.Caption := '';
RadioButton7.Checked := False;
RadioButton8.Checked := True;
BitBtn7.Kind := bkOK;
BitBtn7.Caption := 'Start';
if (Edit1.Text = 'Client 4') then
Begin
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
RadioButton13.Checked := False;
RadioButton14.Checked := False;
end;
Label23.Caption := IntToStr(StrToInt(Label23.Caption) + 1);
Memo1.Lines.Clear;
Memo1.Lines.Add(Label23.Caption);
end
else If (Edit1.Text <> 'Client 4') and (BitBtn7.Caption = 'Check') then
Application.MessageBox('Klik Tombol Check Terlebih Dahulu', 'Pixel Billing', MB_OK or MB_ICONERROR);
end;
procedure TForm1.BitBtn10Click(Sender: TObject);
begin
if Edit1.Text = 'Client 5' then
Begin
Label17.Caption := '';
RadioButton9.Checked := False;
RadioButton10.Checked := True;
BitBtn9.Kind := bkOK;
BitBtn9.Caption := 'Start';
if (Edit1.Text = 'Client 5') then
Begin
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
RadioButton13.Checked := False;
RadioButton14.Checked := False;
end;
Label23.Caption := IntToStr(StrToInt(Label23.Caption) + 1);
Memo1.Lines.Clear;
Memo1.Lines.Add(Label23.Caption);
end
else If (Edit1.Text <> 'Client 5') and (BitBtn9.Caption = 'Check') then
Application.MessageBox('Klik Tombol Check Terlebih Dahulu', 'Pixel Billing', MB_OK or MB_ICONERROR);
end;
procedure TForm1.BitBtn12Click(Sender: TObject);
begin
if Edit1.Text = 'Client 6' then
Begin
Label19.Caption := '';
RadioButton11.Checked := False;
RadioButton12.Checked := True;
BitBtn11.Kind := bkOK;
BitBtn11.Caption := 'Start';
if (Edit1.Text = 'Client 6') then
Begin
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
RadioButton13.Checked := False;
RadioButton14.Checked := False;
end;
Label23.Caption := IntToStr(StrToInt(Label23.Caption) + 1);
Memo1.Lines.Clear;
Memo1.Lines.Add(Label23.Caption);
end
else If (Edit1.Text <> 'Client 6') and (BitBtn11.Caption = 'Check') then
Application.MessageBox('Klik Tombol Check Terlebih Dahulu', 'Pixel Billing', MB_OK or MB_ICONERROR);
end;
procedure TForm1.Reset1Click(Sender: TObject);
var
i: integer;
begin
for i := 0 to 500 do begin
progressbar1.Position := i;
Sleep(1);
end;
Edit1.Clear;
Edit2.Clear;
Edit3.Clear;
Edit4.Clear;
RadioButton13.Checked := False;
RadioButton14.Checked := False;
if (BitBtn1.Caption = 'Check') then begin
BitBtn1.Click;
BitBtn2.Click;
end;
if (BitBtn3.Caption = 'Check') then begin
BitBtn3.Click;
BitBtn4.Click;
end;
if (BitBtn5.Caption = 'Check') then begin
BitBtn5.Click;
BitBtn6.Click;
end;
if (BitBtn7.Caption = 'Check') then begin
BitBtn7.Click;
BitBtn8.Click;
end;
if (BitBtn9.Caption = 'Check') then begin
BitBtn9.Click;
BitBtn10.Click;
end;
if (BitBtn11.Caption = 'Check') then begin
BitBtn11.Click;
BitBtn12.Click;
end;
Label23.Caption := '0';
Memo1.Clear;
Application.MessageBox('Berhasil Direset', 'Pixel Billing', MB_OK);
end;
procedure TForm1.WMSyscommand(Var msg: TWmSysCommand); //message WM_SYSCOMMAND;
begin
if (msg.cmdtype and $FFF0) = SC_CLOSE then
begin
if (application.messagebox('Yakin ingin keluar?','informasi',MB_YESNO)=IDYES) then
Application.Terminate;
end
else
inherited;
end;
end.
| 26.792049 | 203 | 0.644789 |
f1c6a5be0d1395e7d4751c56283fe3643c688492
| 16,299 |
pas
|
Pascal
|
src/Environment/AbstractEnvironmentImpl.pas
|
zamronypj/fano-framework
|
559e385be5e1d26beada94c46eb8e760c4d855da
|
[
"MIT"
] | 78 |
2019-01-31T13:40:48.000Z
|
2022-03-22T17:26:54.000Z
|
src/Environment/AbstractEnvironmentImpl.pas
|
zamronypj/fano-framework
|
559e385be5e1d26beada94c46eb8e760c4d855da
|
[
"MIT"
] | 24 |
2020-01-04T11:50:53.000Z
|
2022-02-17T09:55:23.000Z
|
src/Environment/AbstractEnvironmentImpl.pas
|
zamronypj/fano-framework
|
559e385be5e1d26beada94c46eb8e760c4d855da
|
[
"MIT"
] | 9 |
2018-11-05T03:43:24.000Z
|
2022-01-21T17:23:30.000Z
|
{*!
* Fano Web Framework (https://fanoframework.github.io)
*
* @link https://github.com/fanoframework/fano
* @copyright Copyright (c) 2018 - 2021 Zamrony P. Juhara
* @license https://github.com/fanoframework/fano/blob/master/LICENSE (MIT)
*}
unit AbstractEnvironmentImpl;
interface
{$MODE OBJFPC}
{$H+}
uses
DependencyIntf,
EnvironmentIntf,
EnvironmentEnumeratorIntf,
InjectableObjectImpl;
type
(*!------------------------------------------------
* base class for any class having capability to retrieve
* CGI environment variable
*
* @author Zamrony P. Juhara <zamronypj@yahoo.com>
*--------------------------------------------------*)
TAbstractCGIEnvironment = class(TInjectableObject, ICGIEnvironment, ICGIEnvironmentEnumerator)
public
(*!-----------------------------------------
* Retrieve an environment variable
*------------------------------------------
* @param key name of variable
* @return variable value
*------------------------------------------*)
function env(const keyName : string) : string; virtual; abstract;
{-----------------------------------------
Retrieve GATEWAY_INTERFACE environment variable
------------------------------------------}
function gatewayInterface() : string;
{-----------------------------------------
Retrieve REMOTE_ADDR environment variable
------------------------------------------}
function remoteAddr() : string;
{-----------------------------------------
Retrieve REMOTE_PORT environment variable
------------------------------------------}
function remotePort() : string;
{-----------------------------------------
Retrieve REMOTE_HOST environment variable
------------------------------------------}
function remoteHost() : string;
{-----------------------------------------
Retrieve REMOTE_USER environment variable
------------------------------------------}
function remoteUser() : string;
{-----------------------------------------
Retrieve REMOTE_IDENT environment variable
------------------------------------------}
function remoteIdent() : string;
{-----------------------------------------
Retrieve AUTH_TYPE environment variable
------------------------------------------}
function authType() : string;
{-----------------------------------------
Retrieve SERVER_ADDR environment variable
------------------------------------------}
function serverAddr() : string;
{-----------------------------------------
Retrieve SERVER_PORT environment variable
------------------------------------------}
function serverPort() : string;
{-----------------------------------------
Retrieve SERVER_NAME environment variable
------------------------------------------}
function serverName() : string;
{-----------------------------------------
Retrieve SERVER_SOFTWARE environment variable
------------------------------------------}
function serverSoftware() : string;
{-----------------------------------------
Retrieve SERVER_PROTOCOL environment variable
------------------------------------------}
function serverProtocol() : string;
{-----------------------------------------
Retrieve DOCUMENT_ROOT environment variable
------------------------------------------}
function documentRoot() : string;
{-----------------------------------------
Retrieve REQUEST_METHOD environment variable
------------------------------------------}
function requestMethod() : string;
{-----------------------------------------
Retrieve REQUEST_SCHEME environment variable
------------------------------------------}
function requestScheme() : string;
{-----------------------------------------
Retrieve REQUEST_URI environment variable
------------------------------------------}
function requestUri() : string;
{-----------------------------------------
Retrieve QUERY_STRING environment variable
------------------------------------------}
function queryString() : string;
{-----------------------------------------
Retrieve SCRIPT_NAME environment variable
------------------------------------------}
function scriptName() : string;
{-----------------------------------------
Retrieve PATH_INFO environment variable
------------------------------------------}
function pathInfo() : string;
{-----------------------------------------
Retrieve PATH_TRANSLATED environment variable
------------------------------------------}
function pathTranslated() : string;
{-----------------------------------------
Retrieve CONTENT_TYPE environment variable
------------------------------------------}
function contentType() : string;
{-----------------------------------------
Retrieve CONTENT_LENGTH environment variable
------------------------------------------}
function contentLength() : string;
(*-----------------------------------------
* Retrieve CONTENT_LENGTH environment variable
* as integer value
*------------------------------------------
* @return content length as integer value
*------------------------------------------*)
function intContentLength() : integer;
{-----------------------------------------
Retrieve HTTP_HOST environment variable
------------------------------------------}
function httpHost() : string;
{-----------------------------------------
Retrieve HTTP_USER_AGENT environment variable
------------------------------------------}
function httpUserAgent() : string;
{-----------------------------------------
Retrieve HTTP_ACCEPT environment variable
------------------------------------------}
function httpAccept() : string;
{-----------------------------------------
Retrieve HTTP_ACCEPT_LANGUAGE environment variable
------------------------------------------}
function httpAcceptLanguage() : string;
{-----------------------------------------
Retrieve HTTP_COOKIE environment variable
------------------------------------------}
function httpCookie() : string;
(*!------------------------------------------------
* get number of variables
*-----------------------------------------------
* @return number of variables
*-----------------------------------------------*)
function count() : integer; virtual; abstract;
(*!------------------------------------------------
* get key by index
*-----------------------------------------------
* @param index index to use
* @return key name
*-----------------------------------------------*)
function getKey(const indx : integer) : shortstring; virtual; abstract;
(*!------------------------------------------------
* get value by index
*-----------------------------------------------
* @param index index to use
* @return value name
*-----------------------------------------------*)
function getValue(const indx : integer) : string; virtual;
function getEnumerator() : ICGIEnvironmentEnumerator;
end;
implementation
uses
sysutils,
EInvalidRequestImpl;
resourcestring
sErrInvalidContentLength = 'Invalid content length';
{-----------------------------------------
Retrieve GATEWAY_INTERFACE environment variable
------------------------------------------}
function TAbstractCGIEnvironment.gatewayInterface() : string;
begin
result := env('GATEWAY_INTERFACE');
end;
{-----------------------------------------
Retrieve REMOTE_ADDR environment variable
------------------------------------------}
function TAbstractCGIEnvironment.remoteAddr() : string;
begin
result := env('REMOTE_ADDR');
end;
{-----------------------------------------
Retrieve REMOTE_PORT environment variable
------------------------------------------}
function TAbstractCGIEnvironment.remotePort() : string;
begin
result := env('REMOTE_PORT');
end;
{-----------------------------------------
Retrieve REMOTE_HOST environment variable
------------------------------------------}
function TAbstractCGIEnvironment.remoteHost() : string;
begin
result := env('REMOTE_HOST');
end;
{-----------------------------------------
Retrieve REMOTE_USER environment variable
------------------------------------------}
function TAbstractCGIEnvironment.remoteUser() : string;
begin
result := env('REMOTE_USER');
end;
{-----------------------------------------
Retrieve REMOTE_IDENT environment variable
------------------------------------------}
function TAbstractCGIEnvironment.remoteIdent() : string;
begin
result := env('REMOTE_IDENT');
end;
{-----------------------------------------
Retrieve AUTH_TYPE environment variable
------------------------------------------}
function TAbstractCGIEnvironment.authType() : string;
begin
result := env('AUTH_TYPE');
end;
{-----------------------------------------
Retrieve SERVER_ADDR environment variable
------------------------------------------}
function TAbstractCGIEnvironment.serverAddr() : string;
begin
result := env('SERVER_ADDR');
end;
{-----------------------------------------
Retrieve SERVER_PORT environment variable
------------------------------------------}
function TAbstractCGIEnvironment.serverPort() : string;
begin
result := env('SERVER_PORT');
end;
{-----------------------------------------
Retrieve SERVER_NAME environment variable
------------------------------------------}
function TAbstractCGIEnvironment.serverName() : string;
begin
result := env('SERVER_NAME');
end;
{-----------------------------------------
Retrieve SERVER_SOFTWARE environment variable
------------------------------------------}
function TAbstractCGIEnvironment.serverSoftware() : string;
begin
result := env('SERVER_SOFTWARE');
end;
{-----------------------------------------
Retrieve SERVER_PROTOCOL environment variable
------------------------------------------}
function TAbstractCGIEnvironment.serverProtocol() : string;
begin
result := env('SERVER_PROTOCOL');
end;
{-----------------------------------------
Retrieve DOCUMENT_ROOT environment variable
------------------------------------------}
function TAbstractCGIEnvironment.documentRoot() : string;
begin
result := env('DOCUMENT_ROOT');
end;
{-----------------------------------------
Retrieve REQUEST_METHOD environment variable
------------------------------------------}
function TAbstractCGIEnvironment.requestMethod() : string;
begin
result := env('REQUEST_METHOD');
end;
{-----------------------------------------
Retrieve REQUEST_SCHEME environment variable
------------------------------------------}
function TAbstractCGIEnvironment.requestScheme() : string;
begin
result := env('REQUEST_SCHEME');
end;
{-----------------------------------------
Retrieve REQUEST_URI environment variable
------------------------------------------}
function TAbstractCGIEnvironment.requestUri() : string;
begin
result := env('REQUEST_URI');
end;
{-----------------------------------------
Retrieve QUERY_STRING environment variable
------------------------------------------}
function TAbstractCGIEnvironment.queryString() : string;
begin
result := env('QUERY_STRING');
end;
{-----------------------------------------
Retrieve SCRIPT_NAME environment variable
------------------------------------------}
function TAbstractCGIEnvironment.scriptName() : string;
begin
result := env('SCRIPT_NAME');
end;
{-----------------------------------------
Retrieve PATH_INFO environment variable
------------------------------------------}
function TAbstractCGIEnvironment.pathInfo() : string;
begin
result := env('PATH_INFO');
end;
{-----------------------------------------
Retrieve PATH_TRANSLATED environment variable
------------------------------------------}
function TAbstractCGIEnvironment.pathTranslated() : string;
begin
result := env('PATH_TRANSLATED');
end;
{-----------------------------------------
Retrieve CONTENT_TYPE environment variable
------------------------------------------}
function TAbstractCGIEnvironment.contentType() : string;
begin
result := env('CONTENT_TYPE');
end;
{-----------------------------------------
Retrieve CONTENT_LENGTH environment variable
------------------------------------------}
function TAbstractCGIEnvironment.contentLength() : string;
begin
result := env('CONTENT_LENGTH');
end;
(*-----------------------------------------
* Retrieve CONTENT_LENGTH environment variable
* as integer value
*------------------------------------------
* @return content length as integer value
*------------------------------------------*)
function TAbstractCGIEnvironment.intContentLength() : integer;
begin
try
result := strToInt(contentLength());
except
on e:EConvertError do
begin
raise EInvalidRequest.create(sErrInvalidContentLength);
end;
end;
end;
{-----------------------------------------
Retrieve HTTP_HOST environment variable
------------------------------------------}
function TAbstractCGIEnvironment.httpHost() : string;
begin
result := env('HTTP_HOST');
end;
{-----------------------------------------
Retrieve HTTP_USER_AGENT environment variable
------------------------------------------}
function TAbstractCGIEnvironment.httpUserAgent() : string;
begin
result := env('HTTP_USER_AGENT');
end;
{-----------------------------------------
Retrieve HTTP_ACCEPT environment variable
------------------------------------------}
function TAbstractCGIEnvironment.httpAccept() : string;
begin
result := env('HTTP_ACCEPT');
end;
{-----------------------------------------
Retrieve HTTP_ACCEPT_LANGUAGE environment variable
------------------------------------------}
function TAbstractCGIEnvironment.httpAcceptLanguage() : string;
begin
result := env('HTTP_ACCEPT_LANGUAGE');
end;
{-----------------------------------------
Retrieve HTTP_COOKIE environment variable
------------------------------------------}
function TAbstractCGIEnvironment.httpCookie() : string;
begin
result := env('HTTP_COOKIE');
end;
(*!------------------------------------------------
* get value by index
*-----------------------------------------------
* @param index index to use
* @return key name
*-----------------------------------------------*)
function TAbstractCGIEnvironment.getValue(const indx : integer) : string;
begin
result := env(getKey(indx));
end;
function TAbstractCGIEnvironment.getEnumerator() : ICGIEnvironmentEnumerator;
begin
result := self;
end;
end.
| 34.605096 | 98 | 0.403338 |
85cb5e71201f9d357605944dd75902fc6e2fcc11
| 7,234 |
pas
|
Pascal
|
references/mORMot/SQLite3/Samples/MainDemo/FileTables.pas
|
zekiguven/alcinoe
|
e55c5368ee8bfe7cd6d92424c29ab07d8a3e844c
|
[
"Apache-2.0"
] | 2 |
2020-02-17T18:42:30.000Z
|
2020-11-14T04:57:48.000Z
|
references/mORMot/SQLite3/Samples/MainDemo/FileTables.pas
|
zekiguven/alcinoe
|
e55c5368ee8bfe7cd6d92424c29ab07d8a3e844c
|
[
"Apache-2.0"
] | 2 |
2019-06-23T00:02:43.000Z
|
2019-10-12T22:39:28.000Z
|
references/mORMot/SQLite3/Samples/MainDemo/FileTables.pas
|
zekiguven/alcinoe
|
e55c5368ee8bfe7cd6d92424c29ab07d8a3e844c
|
[
"Apache-2.0"
] | null | null | null |
/// SynFile ORM definitions shared by both client and server
unit FileTables;
interface
{$I Synopse.inc} // define HASINLINE USETYPEINFO CPU32 CPU64 OWNNORMTOUPPER
uses
SysUtils,
Classes,
SynCommons,
SynCrypto,
SynZip,
mORMot,
mORMoti18n;
type
/// the internal events/states, as used by the TSQLAuditTrail table
TFileEvent = (
feUnknownState,
feServerStarted,
feServerShutdown,
feRecordCreated,
feRecordModified,
feRecordDeleted,
feRecordDigitallySigned,
feRecordImported,
feRecordExported
);
/// the internal available actions, as used by the User Interface
TFileAction = (
faNoAction,
faMark,
faUnmarkAll,
faQuery,
faRefresh,
faCreate,
faEdit,
faCopy,
faExport,
faImport,
faDelete,
faSign,
faPrintPreview,
faExtract,
faSettings
);
/// set of available actions
TFileActions = set of TFileAction;
/// some actions to be used by the User Interface of a Preview window
TPreviewAction = (
paPrint, paAsPdf, paAsText,
paWithPicture, paDetails
);
TPreviewActions = set of TPreviewAction;
/// an abstract class, with common fields
TSQLFile = class(TSQLRecordSigned)
public
fName: RawUTF8;
fModified: TTimeLog;
fCreated: TTimeLog;
fPicture: TSQLRawBlob;
fKeyWords: RawUTF8;
published
property Name: RawUTF8 read fName write fName;
property Created: TTimeLog read fCreated write fCreated;
property Modified: TTimeLog read fModified write fModified;
property Picture: TSQLRawBlob read fPicture write fPicture;
property KeyWords: RawUTF8 read fKeyWords write fKeyWords;
property SignatureTime;
property Signature;
end;
/// an uncrypted Memo table
// - will contain some text
TSQLMemo = class(TSQLFile)
public
fContent: RawUTF8;
published
property Content: RawUTF8 read fContent write fContent;
end;
/// an uncrypted Data table
// - can contain any binary file content
// - is also used a parent for all cyphered tables (since the
// content is crypted, it should be binary, i.e. a BLOB field)
TSQLData = class(TSQLFile)
public
fData: TSQLRawBlob;
published
property Data: TSQLRawBlob read fData write fData;
end;
/// a crypted SafeMemo table
// - will contain some text after AES-256 cypher
// - just a direct sub class ot TSQLData to create the "SafeMemo" table
// with the exact same fields as the "Data" table
TSQLSafeMemo = class(TSQLData);
/// a crypted SafeData table
// - will contain some binary file content after AES-256 cypher
// - just a direct sub class ot TSQLData to create the "SafeData" table
// with the exact same fields as the "Data" table
TSQLSafeData = class(TSQLData);
/// an AuditTrail table, used to track events and status
TSQLAuditTrail = class(TSQLRecord)
protected
fStatusMessage: RawUTF8;
fStatus: TFileEvent;
fAssociatedRecord: TRecordReference;
fTime: TTimeLog;
published
property Time: TTimeLog read fTime write fTime;
property Status: TFileEvent read fStatus write fStatus;
property StatusMessage: RawUTF8 read fStatusMessage write fStatusMessage;
property AssociatedRecord: TRecordReference read fAssociatedRecord write fAssociatedRecord;
end;
/// the type of custom main User Interface description of SynFile
TFileRibbonTabParameters = object(TSQLRibbonTabParameters)
/// the SynFile actions
Actions: TFileActions;
end;
const
/// will define the first User Interface ribbon group, i.e. main tables
GROUP_MAIN = 0;
/// will define the 2nd User Interface ribbon group, i.e. uncrypted tables
GROUP_CLEAR = 1;
/// will define the 3d User Interface ribbon group, i.e. crypted tables
GROUP_SAFE = 2;
/// some default actions, available for all tables
DEF_ACTIONS = [faMark..faPrintPreview,faSettings];
/// actions available for data tables (not for TSQLAuditTrail)
DEF_ACTIONS_DATA = DEF_ACTIONS+[faExtract]-[faImport,faExport];
/// default fields available for User Interface Grid
DEF_SELECT = 'Name,Created,Modified,KeyWords,SignatureTime';
/// the TCP/IP port used for the HTTP server
// - this is shared as constant by both client and server side
// - in a production application, should be made customizable
SERVER_HTTP_PORT = '888';
const
/// this constant will define most of the User Interface property
// - the framework will create most User Interface content from the
// values stored within
FileTabs: array[0..4] of TFileRibbonTabParameters = (
(Table: TSQLAuditTrail;
Select: 'Time,Status,StatusMessage'; Group: GROUP_MAIN;
FieldWidth: 'gIZ'; ShowID: true; ReverseOrder: true; Layout: llClient;
Actions: [faDelete,faMark,faUnmarkAll,faQuery,faRefresh,faPrintPreview,faSettings]),
(Table: TSQLMemo;
Select: DEF_SELECT; Group: GROUP_CLEAR; FieldWidth: 'IddId'; Actions: DEF_ACTIONS),
(Table: TSQLData;
Select: DEF_SELECT; Group: GROUP_CLEAR; FieldWidth: 'IddId'; Actions: DEF_ACTIONS_DATA),
(Table: TSQLSafeMemo;
Select: DEF_SELECT; Group: GROUP_SAFE; FieldWidth: 'IddId'; Actions: DEF_ACTIONS),
(Table: TSQLSafeData;
Select: DEF_SELECT; Group: GROUP_SAFE; FieldWidth: 'IddId'; Actions: DEF_ACTIONS_DATA)
);
/// used to map which actions/buttons must be grouped in the toolbar
FileActionsToolbar: array[0..3] of TFileActions =
( [faRefresh,faCreate,faEdit,faCopy,faExtract], [faExport..faPrintPreview],
[faMark..faQuery], [faSettings] );
/// FileActionsToolbar[FileActionsToolbar_MARKINDEX] will be the marked actions
// i.e. [faMark..faQuery]
FileActionsToolbar_MARKINDEX = 2;
resourcestring
sFileTabsGroup = 'Main,Clear,Safe';
sFileActionsToolbar = '%%,Record Managment,Select,Settings';
sFileActionsHints =
'Mark rows'#13+ { faMark }
'UnMark all rows'#13+ { faUnmarkAll }
'Perform a custom query on the list and mark resulting rows'#13+ { faQuery }
'Refresh the current list from the database'#13+ { faRefresh }
'Create a new empty %s'#13+ { faCreate }
'Edit this %s'#13+ { faEdit }
'Create a new %s, with the same initial values as in the current selected record'#13+ { faCopy }
'Export one or more %s records report'#13+ { faExport }
'Import one or multiple files as %s records'#13+ { faImport }
'Delete the selected %s records'#13+ { faDelete }
'Digitally sign the selected %s'#13+ { faSign }
'Print one or more %s Reports'#13+ { faPrintPreview }
'Extract the embedded file into any folder'#13+ { faExtract }
'Change the Program''s settings'; { faSettings }
/// create the database model to be used
// - shared by both client and server sides
function CreateFileModel(Owner: TSQLRest): TSQLModel;
implementation
function CreateFileModel(Owner: TSQLRest): TSQLModel;
begin
result := TSQLModel.Create(Owner,
@FileTabs,length(FileTabs),sizeof(FileTabs[0]),[],
TypeInfo(TFileAction),TypeInfo(TFileEvent));
end;
initialization
SetExecutableVersion('3.1');
end.
| 34.61244 | 101 | 0.698231 |
830e64c505aabc7553db0ad3f91131a5c92bfb27
| 465 |
pas
|
Pascal
|
CAT/tests/08. types/arrays/static/global/sarray_3.pas
|
SkliarOleksandr/NextPascal
|
4dc26abba6613f64c0e6b5864b3348711eb9617a
|
[
"Apache-2.0"
] | 19 |
2018-10-22T23:45:31.000Z
|
2021-05-16T00:06:49.000Z
|
CAT/tests/08. types/arrays/static/global/sarray_3.pas
|
SkliarOleksandr/NextPascal
|
4dc26abba6613f64c0e6b5864b3348711eb9617a
|
[
"Apache-2.0"
] | 1 |
2019-06-01T06:17:08.000Z
|
2019-12-28T10:27:42.000Z
|
CAT/tests/08. types/arrays/static/global/sarray_3.pas
|
SkliarOleksandr/NextPascal
|
4dc26abba6613f64c0e6b5864b3348711eb9617a
|
[
"Apache-2.0"
] | 6 |
2018-08-30T05:16:21.000Z
|
2021-05-12T20:25:43.000Z
|
unit sarray_3;
interface
implementation
type
TRec = array[Boolean] of Int32;
var Node1, Node2: TRec;
procedure Test1;
begin
Node1[False] := 1;
Node1[True] := 2;
end;
procedure Test2(Comparison: Int32);
begin
Node2[Comparison > 0] := 1;
Node2[Comparison < 0] := 2;
end;
initialization
Test1();
Test2(5);
finalization
Assert(Node1[False] = 1);
Assert(Node1[True] = 2);
Assert(Node2[False] = 2);
Assert(Node2[True] = 1);
end.
| 13.676471 | 35 | 0.643011 |
834aa64b0f71742bf8e7851e5ebc1e9d2d64f26c
| 10,977 |
pas
|
Pascal
|
imagecleaner.pas
|
n1tehawk/PaperTiger
|
d30f1e087221b03d4d76dc589f2a669f6fd2c4b2
|
[
"MIT"
] | 1 |
2019-05-13T08:37:55.000Z
|
2019-05-13T08:37:55.000Z
|
imagecleaner.pas
|
n1tehawk/PaperTiger
|
d30f1e087221b03d4d76dc589f2a669f6fd2c4b2
|
[
"MIT"
] | null | null | null |
imagecleaner.pas
|
n1tehawk/PaperTiger
|
d30f1e087221b03d4d76dc589f2a669f6fd2c4b2
|
[
"MIT"
] | 1 |
2020-04-13T11:52:00.000Z
|
2020-04-13T11:52:00.000Z
|
unit imagecleaner;
{ Image cleaning unit; to be used to straighten up/deskew, despeckle etc images
so OCR is more accurate.
Copyright (c) 2012-2014 Reinier Olislagers
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
}
{todo: add preprocess code to CleanUpImage despeckle, deskew etc? ScanTailor?
Scantailor: more for letters/documents; unpaper more for books
scantailor new version: https://sourceforge.net/projects/scantailor/files/scantailor-devel/enhanced/
unpaper input.ppm output.ppm => perhaps more formats than ppm? use eg. exactimage's econvert for format conversion}
{$i tigerserver.inc}
{$DEFINE USE_IMAGEMAGICK}
{.$DEFINE USE_EXACTIMAGE}
interface
uses
Classes, SysUtils,
processutils, strutils, tigerutil,
ocr;
type
{ TImageCleaner }
TImageCleaner = class(TObject)
private
FLanguage: string;
// Tests page layout by running a scan.
// Returns OCR recognition score (percentage: correct/total words) as well as the
// approximate number of correctly-detected words found
// todo: dead code but could be useful perhaps when autodetecting various languages?
function CheckRecognition(ImageFile: string): integer;
// Returns degrees image needs to be turned to end right-side-up
// Currently based on Tesseract rotation detection functionality (added January 2014)
function DetectRotation(Source: string): integer;
// Convert image to black and white TIFF image
function ToBlackWhiteTIFF(SourceFile,DestinationFile: string): boolean;
public
// Cleans up before scanning:
// Converts image to black/white
// Reads image, performs OCR tests on it to figure out if it needs to be rotated.
// Rotates image if needed
// Returns number of degrees the image has been turned,
// e.g. 90: image rotated counterclockwise 90 degrees
// Returns INVALIDID if function failed.
function Clean(Source, Destination: string; AutoRotate: boolean): integer;
// Rotates source image to destination image over specified number of degrees clockwise
// Returns true if succesful
function Rotate(Degrees: integer; SourceFile, DestinationFile: string): boolean;
// Language to use for OCR, e.g. eng for English, nld for Dutch
property Language: string read FLanguage write FLanguage;
constructor Create;
destructor Destroy; override;
end;
implementation
// Common constants etc:
{$i tigercommondefs.inc}
const
{$IFDEF USE_EXACTIMAGE}
ConvertCommand='econvert'; //exactimage's econvert utility
{$ENDIF}
{$IFDEF USE_IMAGEMAGICK}
ConvertCommand='convert'; //Imagemagick's version
{$ENDIF}
NormalizeCommand='optimize2bw'; //exactimage's => black&white TIFF conversion tool
function TImageCleaner.CheckRecognition(ImageFile: string): integer;
{ Tesseract tries to output valid words in the selected language and
will often falsely detect numbers instead of gibberish when scanning rotated text.
Therefore remove all words containing only numbers before calculating statistics
}
const
DetectLog = '/tmp/detectlog.txt';
var
i: integer;
TempOCR: TOCR;
ResList: TStringList;
ResText: string;
begin
result:=-1; //Negative recognition rate: fail by default
TempOCR:=TOCR.Create;
ResList:=TStringList.Create;
try
result:=0;
TigerLog.WriteLog(etDebug,'CheckRecognition: going to call ocr for file '+ImageFile);
TempOCR.ImageFile:=ImageFile;
TempOCR.Language:=FLanguage;
TempOCR.RecognizeText;
// strip out all numbers - including gibberish misdetected as numbers
ResText:=TempOCR.Text;
for i:=length(ResText) downto 1 do
begin
if char(ResText[i]) in ['0'..'9'] then
Delete(ResText,i,1);
end;
ResList.Text:=ResText;
ResText:='';
result:=WordCount((ResList.Text),StdWordDelims);
finally
TempOCR.Free;
ResList.Free;
end;
end;
{ TImageCleaner }
function TImageCleaner.DetectRotation(Source: string): integer;
// Requires Tesseract for now
const
//todo: add support for windows
BogusFile = '/tmp/deleteme';
TesseractCommand = 'tesseract';
var
Command: string;
CommandOutput: string;
OutputList: TStringList;
begin
Result:=0;
{
Tesseract since about 3.03 will print out orientation:
Orientation: 0
Orientation in degrees: 0
Orientation confidence: 15.33
}
Command:=TesseractCommand+' "'+Source+'" "'+BogusFile+'" -l '+FLanguage + ' -psm 0';
CommandOutput:='';
if ExecuteCommand(Command,CommandOutput,false)=0 then
begin
OutputList:=TStringList.Create;
try
OutputList.Text:=CommandOutput;
OutputList.NameValueSeparator:=':';
if OutputList.Values['Orientation in degrees']<>'' then
begin
Result:=StrToIntDef(OutputList.Values['Orientation in degrees'],0);
TigerLog.WriteLog(etDebug,'DetectRotation: found rotation '+inttostr(Result));
end;
finally
OutputList.Free;
end;
end;
end;
constructor TImageCleaner.Create;
begin
FLanguage:='eng'; //default to English; tesseract format
end;
destructor TImageCleaner.Destroy;
begin
inherited Destroy;
end;
function TImageCleaner.ToBlackWhiteTIFF(SourceFile,DestinationFile: string): boolean;
var
ErrorCode: integer;
TempFile: string;
begin
result:=false;
if ExpandFileName(SourceFile)=ExpandFileName(DestinationFile) then
TempFile:=GetTempFileName('','TIF')
else
TempFile:=DestinationFile;
try
ErrorCode:=ExecuteCommand(NormalizeCommand+
' --denoise --dpi 300'+
' --input "'+SourceFile+'" --output "tiff:'+TempFile+'" ', false);
except
on E: Exception do
begin
TigerLog.WriteLog(etWarning,
'ToBlackWhiteTIFF: got exception '+E.Message+
' when calling '+NormalizeCommand+' for image '+SourceFile);
ErrorCode:=processutils.PROC_INTERNALEXCEPTION;
end;
end;
if ErrorCode=0 then
begin
result:=true;
end
else
begin
TigerLog.WriteLog(etWarning,
'ToBlackWhiteTIFF: got result code '+inttostr(ErrorCode)+
' when calling '+NormalizeCommand+' for image '+SourceFile);
end;
if (result) and (ExpandFileName(SourceFile)=ExpandFileName(DestinationFile)) then
begin
// Copy over original file as requested
result:=FileCopy(TempFile,DestinationFile);
end;
end;
function TImageCleaner.Rotate(Degrees: integer; SourceFile,
DestinationFile: string): boolean;
// Rotates uses either exactimage tools econvert or imagemagick
var
AdditionalMessage: string;
ErrorCode: integer;
Overwrite: boolean;
TempFile: string;
begin
result:=false;
if Degrees=0 then
AdditionalMessage:=' - it also selects correct compression';
TigerLog.WriteLog(etDebug,
'TImageCleaner.Rotate: going to rotate '+SourceFile+' to '+
DestinationFile+' over '+inttostr(Degrees)+' degrees'+AdditionalMessage);
Overwrite:=(ExpandFileName(SourceFile)=ExpandFileName(DestinationFile));
if Overwrite then
TempFile:=GetTempFileName('','TIFR')
else
TempFile:=DestinationFile;
// We just let the tool do the 0 degree rotations, too.
{$IFDEF USE_EXACTIMAGE}
//todo: this just doesn't seem to rotate. Command line appears correct though.
// perhaps bug in exactimage 0.8.8 which I ran.
// Rotate; indicate output should be tiff format
// Output appears to be CCIT fax T.6, but apparently tesseract 3.02.02
// can now read that
try
ErrorCode:=ExecuteCommand(ConvertCommand+
' --rotate "'+inttostr(Degrees)+'" '+
' --input "'+SourceFile+'" '+
' --output "tiff:'+TempFile+'" ', false);
except
on E: Exception do
begin
TigerLog.WriteLog(etWarning,
'TImageCleaner.Rotate: got exception '+E.Message+
' when calling '+ConvertCommand+' for rotation '+inttostr(Degrees))
ErrorCode:=PROC_INTERNALEXCEPTION;
end;
end;
{$ENDIF}
{$IFDEF USE_IMAGEMAGICK}
// Rotate; indicate output should be tiff format
// Output appears to be CCIT fax T.6, but apparently tesseract 3.02.02
// can now read that
try
ErrorCode:=ExecuteCommand(ConvertCommand+
' "'+SourceFile+'" '+
' -rotate '+inttostr(Degrees)+
' "'+TempFile+'" ', false);
except
on E: Exception do
begin
TigerLog.WriteLog(etWarning,
'TImageCleaner.Rotate: got exception '+E.Message+
' when calling '+ConvertCommand+' for rotation '+inttostr(Degrees));
ErrorCode:=PROC_INTERNALEXCEPTION;
end;
end;
{$ENDIF}
result:=(ErrorCode=0);
if not(result) then
TigerLog.WriteLog(etWarning,
'TImageCleaner.Rotate: got result code '+inttostr(ErrorCode)+
' when calling '+ConvertCommand+' for rotation '+inttostr(Degrees))
else
if Overwrite then
begin
if FileExists(TempFile) then
// Copy over original file as requested
result:=FileCopy(TempFile,DestinationFile)
else
TigerLog.WriteLog(etError,
'TImageCleaner.Rotate: rotation failed; rotated temp file '+TempFile+
' does not exist');
end;
end;
function TImageCleaner.Clean(Source, Destination: string; AutoRotate: boolean): integer;
var
TempImage: string;
Degrees:integer=0;
begin
Result:=INVALIDID;
TempImage:=GetTempFileName('','BW');
// Convert to CCIT group IV fax compression
ToBlackWhiteTIFF(Source,TempImage);
if AutoRotate then
begin
Degrees:=DetectRotation(TempImage);
if Rotate(Degrees,TempImage,Destination) then
result:=Degrees;
end
else
begin
FileCopy(TempImage,Destination);
result:=0;
end;
{$IFNDEF DEBUG}
DeleteFile(TempImage);
{$ENDIF}
end;
initialization
{$IFDEF USEMAGICK}
MagickWandGenesis;
{$ENDIF}
finalization;
{$IFDEF USEMAGICK}
MagickWandTerminus;
{$ENDIF}
end.
| 32.285294 | 116 | 0.698825 |
83c3ec5a878e45e557861de33c42a7d813e7ad83
| 272 |
dfm
|
Pascal
|
DM/UdmCadCliente.dfm
|
gabrielthinassi/ExemploCadastroTek
|
4cb011e8851bb516ebef45aa0f3093bc35531dac
|
[
"MIT"
] | null | null | null |
DM/UdmCadCliente.dfm
|
gabrielthinassi/ExemploCadastroTek
|
4cb011e8851bb516ebef45aa0f3093bc35531dac
|
[
"MIT"
] | null | null | null |
DM/UdmCadCliente.dfm
|
gabrielthinassi/ExemploCadastroTek
|
4cb011e8851bb516ebef45aa0f3093bc35531dac
|
[
"MIT"
] | null | null | null |
inherited dmCadCliente: TdmCadCliente
OldCreateOrder = True
inherited qrCadastro: TSQLQuery
BeforeOpen = qrCadastroBeforeOpen
SQL.Strings = (
'')
Top = 32
end
inherited cdsCadastro: TClientDataSet
BeforePost = cdsCadastroBeforePost
end
end
| 20.923077 | 39 | 0.731618 |
f196abd3939f4e8e6ad5014b35ffd076ab75ae81
| 107 |
pas
|
Pascal
|
Test/SimpleScripts/unicode_const.pas
|
skolkman/dwscript
|
b9f99d4b8187defac3f3713e2ae0f7b83b63d516
|
[
"Condor-1.1"
] | 79 |
2015-03-18T10:46:13.000Z
|
2022-03-17T18:05:11.000Z
|
Test/SimpleScripts/unicode_const.pas
|
skolkman/dwscript
|
b9f99d4b8187defac3f3713e2ae0f7b83b63d516
|
[
"Condor-1.1"
] | 6 |
2016-03-29T14:39:00.000Z
|
2020-09-14T10:04:14.000Z
|
Test/SimpleScripts/unicode_const.pas
|
skolkman/dwscript
|
b9f99d4b8187defac3f3713e2ae0f7b83b63d516
|
[
"Condor-1.1"
] | 25 |
2016-05-04T13:11:38.000Z
|
2021-09-29T13:34:31.000Z
|
var music : String = #$266B' Music!';
PrintLn(music);
PrintLn(UpperCase(IntToHex(Ord(music[1]), 4)));
| 21.4 | 48 | 0.64486 |
83d969212a2db571520a0c53cc8a5dd31789e227
| 1,146 |
pas
|
Pascal
|
exercises/nth-prime/uNthPrimeTest.pas
|
neoprez/delphi
|
2207cd228c4fde294f8b4c810239286f5ea50032
|
[
"MIT"
] | null | null | null |
exercises/nth-prime/uNthPrimeTest.pas
|
neoprez/delphi
|
2207cd228c4fde294f8b4c810239286f5ea50032
|
[
"MIT"
] | 2 |
2018-10-19T02:50:26.000Z
|
2018-11-03T23:06:01.000Z
|
exercises/nth-prime/uNthPrimeTest.pas
|
filiptoskovic/delphi
|
3e0fdad99efb579ac319e708be326124ae3179e0
|
[
"MIT"
] | null | null | null |
unit uNthPrimeTest;
interface
uses
DUnitX.TestFramework;
const
CanonicalVersion = '2.1.0';
type
[TestFixture]
TNthPrimeTest = class(TObject)
public
[Test]
// [Ignore('Comment the "[Ignore]" statement to run the test')]
procedure there_is_no_zeroth_prime;
[Test]
[Ignore]
procedure first_prime;
[Test]
[Ignore]
procedure second_prime;
[Test]
[Ignore]
procedure sixth_prime;
[Test]
[Ignore]
procedure big_prime;
end;
implementation
uses
System.SysUtils, uNthPrime;
procedure TNthPrimeTest.first_prime;
begin
Assert.AreEqual(2, NthPrime(1));
end;
procedure TNthPrimeTest.second_prime;
begin
Assert.AreEqual(3, NthPrime(2));
end;
procedure TNthPrimeTest.sixth_prime;
begin
Assert.AreEqual(13, NthPrime(6));
end;
procedure TNthPrimeTest.big_prime;
begin
Assert.AreEqual(104743, NthPrime(10001));
end;
procedure TNthPrimeTest.there_is_no_zeroth_prime;
begin
Assert.WillRaiseWithMessage(procedure begin NthPrime(0); end , EArgumentOutOfRangeException, 'there is no zeroth prime');
end;
initialization
TDUnitX.RegisterTestFixture(TNthPrimeTest);
end.
| 16.371429 | 123 | 0.733857 |
616dddad1d963ac3796b77b06b3ba89bc8670703
| 3,868 |
dfm
|
Pascal
|
sqlitesamples/Sample 5 (calc field and tquery)/sample05Main.dfm
|
ellotecnologia/asqlite3
|
fc81977bc8e0841fac55adcd15243836f901081d
|
[
"BSD-3-Clause"
] | null | null | null |
sqlitesamples/Sample 5 (calc field and tquery)/sample05Main.dfm
|
ellotecnologia/asqlite3
|
fc81977bc8e0841fac55adcd15243836f901081d
|
[
"BSD-3-Clause"
] | null | null | null |
sqlitesamples/Sample 5 (calc field and tquery)/sample05Main.dfm
|
ellotecnologia/asqlite3
|
fc81977bc8e0841fac55adcd15243836f901081d
|
[
"BSD-3-Clause"
] | null | null | null |
object Form1: TForm1
Left = 192
Top = 103
Width = 673
Height = 288
Caption = 'Sample 5'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object Label1: TLabel
Left = 216
Top = 184
Width = 150
Height = 13
Caption = 'Counting the number of children'
end
object DBGrid1: TDBGrid
Left = 8
Top = 40
Width = 649
Height = 120
DataSource = DataSource1
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
Columns = <
item
Expanded = False
FieldName = 'number'
Visible = True
end
item
Expanded = False
FieldName = 'name'
Width = 200
Visible = True
end
item
Expanded = False
FieldName = 'dob'
Visible = True
end
item
Expanded = False
FieldName = 'gdesc'
Visible = True
end
item
Expanded = False
FieldName = 'delta'
Title.Caption = '#Children'
Visible = True
end>
end
object DBNavigator1: TDBNavigator
Left = 8
Top = 8
Width = 240
Height = 25
DataSource = DataSource1
TabOrder = 1
end
object RGDate: TRadioGroup
Left = 8
Top = 168
Width = 185
Height = 81
Caption = ' date format '
ItemIndex = 0
Items.Strings = (
'dd-mm-yyyy'
'yyyy-mm-dd'
'mm-dd-yyyy')
TabOrder = 2
OnClick = RGDateClick
end
object ASQLite3DB1: TASQLite3DB
Database = 'demo.sqb'
DefaultExt = '.sqb'
DefaultDir = '..\'
Version = '3.4.0'
DriverDLL = '..\SQLite3.dll'
Connected = True
MustExist = False
ExecuteInlineSQL = False
Left = 32
Top = 104
end
object ASQLite3Table1: TASQLite3Table
AutoCommit = False
SQLiteDateFormat = True
Connection = ASQLite3DB1
MaxResults = 0
StartResult = 0
TypeLess = False
SQLCursor = True
ReadOnly = False
UniDirectional = False
OnCalcFields = ASQLite3Table1CalcFields
TableName = 'person'
PrimaryAutoInc = False
Left = 64
Top = 104
object ASQLite3Table1number: TIntegerField
FieldName = 'number'
end
object ASQLite3Table1name: TStringField
FieldName = 'name'
Size = 80
end
object ASQLite3Table1dob: TDateField
FieldName = 'dob'
end
object ASQLite3Table1gender: TStringField
FieldName = 'gender'
Visible = False
Size = 1
end
object ASQLite3Table1gdesc: TStringField
FieldKind = fkLookup
FieldName = 'gdesc'
LookupDataSet = TGender
LookupKeyFields = 'gid'
LookupResultField = 'desc'
KeyFields = 'gender'
Lookup = True
end
object ASQLite3Table1delta: TIntegerField
FieldKind = fkCalculated
FieldName = 'delta'
Calculated = True
end
end
object DataSource1: TDataSource
DataSet = ASQLite3Table1
Left = 96
Top = 104
end
object TGender: TASQLite3Table
AutoCommit = False
SQLiteDateFormat = True
Connection = ASQLite3DB1
MaxResults = 0
StartResult = 0
TypeLess = False
SQLCursor = True
ReadOnly = False
UniDirectional = False
TableName = 'gender'
PrimaryAutoInc = False
Left = 128
Top = 104
end
object ASQLite3Query1: TASQLite3Query
AutoCommit = False
SQLiteDateFormat = True
Connection = ASQLite3DB1
MaxResults = 0
StartResult = 0
TypeLess = False
SQLCursor = True
ReadOnly = False
UniDirectional = False
RawSQL = False
Left = 160
Top = 104
end
end
| 21.608939 | 47 | 0.611427 |
61767cbcb5e5fea09b498f6924aaa310497c1299
| 53,013 |
pas
|
Pascal
|
Source/PDFium.Control.pas
|
atkins126/TPDFiumControl
|
ac6180b4a0c6d23f4b258b6d0834e44856ad8c8c
|
[
"MIT"
] | null | null | null |
Source/PDFium.Control.pas
|
atkins126/TPDFiumControl
|
ac6180b4a0c6d23f4b258b6d0834e44856ad8c8c
|
[
"MIT"
] | null | null | null |
Source/PDFium.Control.pas
|
atkins126/TPDFiumControl
|
ac6180b4a0c6d23f4b258b6d0834e44856ad8c8c
|
[
"MIT"
] | null | null | null |
unit PDFium.Control;
{.$DEFINE USE_LOAD_FROM_URL}
interface
uses
Winapi.Messages, Winapi.Windows, System.Classes, System.Math, System.SysUtils, System.UITypes, System.Variants,
Vcl.Controls, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.Forms, Vcl.Graphics, PDFiumCore, PDFiumLib
{$IFDEF ALPHASKINS}, acSBUtils, sCommonData{$ENDIF};
type
TPDFZoomMode = (zmActualSize, zmFitHeight, zmFitWidth, zmPercent);
TPDFControlRectArray = array of TRect;
TPDFControlPDFRectArray = TArray<TPDFRect>;
TPDFControlScrollEvent = procedure(const ASender: TObject; const AScrollBar: TScrollBarKind) of object;
TPDFLoadProtectedEvent = procedure(const ASender: TObject; var APassword: UTF8String) of object;
TPageInfo = record
Height: Single;
Index: Integer;
Rect: TRect;
Rotation: TPDFPageRotation;
SearchCurrentIndex: Integer;
SearchRects: TPDFControlPDFRectArray;
Visible: Integer;
Width: Single;
end;
{ Page is not a public property in core class }
TPDFPageHelper = class helper for PDFiumCore.TPDFPage
function Page: FPDF_PAGE;
end;
TPDFiumControl = class(TScrollingWinControl)
strict private
FAllowTextSelection: Boolean;
FChanged: Boolean;
FFilename: string;
FFormFieldFocused: Boolean;
FFormOutputSelectedRects: TPDFControlPDFRectArray;
FHeight: Single;
FMouseDownPoint: TPoint;
FMousePressed: Boolean;
FOnLoadProtected: TPDFLoadProtectedEvent;
FOnPaint: TNotifyEvent;
FOnScroll: TPDFControlScrollEvent;
FPageBorderColor: TColor;
FPageCount: Integer;
FPageIndex: Integer;
FPageInfo: TArray<TPageInfo>;
FPageMargin: Integer;
FPDFDocument: TPDFDocument;
FPrintJobTitle: string;
{$IFDEF ALPHASKINS}
FScrollWnd: TacScrollWnd;
{$ENDIF}
FSearchCount: Integer;
FSearchHighlightAll: Boolean;
FSearchIndex: Integer;
FSearchMatchCase: Boolean;
FSearchText: string;
FSearchWholeWords: Boolean;
FSelectionActive: Boolean;
FSelectionStartCharIndex: Integer;
FSelectionStopCharIndex: Integer;
{$IFDEF ALPHASKINS}
FSkinData: TsScrollWndData;
{$ENDIF}
FWebLinksRects: array of TPDFControlPDFRectArray;
FWidth: Single;
FZoomMode: TPDFZoomMode;
FZoomPercent: Single;
function CreatePDFDocument: TPDFDocument;
function DeviceToPage(const X, Y: Integer): TPDFPoint;
function GetCurrentPage: TPDFPage;
function GetPageIndexAt(const APoint: TPoint): Integer;
function GetSelectionLength: Integer;
function GetSelectionRects: TPDFControlRectArray;
function GetSelectionStart: Integer;
function GetSelectionText: string;
function GetWebLinkIndex(const X, Y: Integer): Integer;
function InternPageToDevice(const APage: TPDFPage; const APageRect: TPDFRect; const ARect: TRect): TRect;
function IsPageValid: Boolean;
function IsWebLinkAt(const X, Y: Integer): Boolean; overload;
function IsWebLinkAt(const X, Y: Integer; var AURL: string): Boolean; overload;
function PageHeightZoomPercent: Single;
function PageWidthZoomPercent: Single;
function SelectWord(const ACharIndex: Integer): Boolean;
function SetSelStopCharIndex(const X, Y: Integer): Boolean;
procedure AdjustPageInfo;
procedure AdjustScrollBar(const APageIndex: Integer);
procedure AdjustZoom;
procedure AfterLoad;
procedure DoScroll(const AScrollBarKind: TScrollBarKind);
procedure DoSizeChanged;
procedure FormFieldFocus(ADocument: TPDFDocument; AValue: PWideChar; AValueLen: Integer; AFieldFocused: Boolean);
procedure FormGetCurrentPage(ADocument: TPDFDocument; var APage: TPDFPage);
procedure FormOutputSelectedRect(ADocument: TPDFDocument; APage: TPDFPage; const APageRect: TPDFRect);
procedure GetPageWebLinks;
procedure InvalidateRectDiffs(const AOldRects, ANewRects: TPDFControlRectArray);
procedure PageChanged;
procedure PaintAlphaSelection(ADC: HDC; const APage: TPDFPage; const ARects: TPDFControlPDFRectArray; const AIndex: Integer;
const AColor: TColor = TColors.SysNone);
procedure PaintPage(ADC: HDC; const APage: TPDFPage; const AIndex: Integer);
procedure PaintPageBorder(ADC: HDC; const ARect: TRect);
procedure PaintPageSearchResults(ADC: HDC; const APage: TPDFPage; const AIndex: Integer);
procedure PaintPageSelection(ADC: HDC; const APage: TPDFPage; const AIndex: Integer);
procedure SetPageCount(const AValue: Integer);
procedure SetPageIndex(const AValue: Integer);
procedure SetPageNumber(const AValue: Integer);
procedure SetScrollSize;
procedure SetSearchHighlightAll(const AValue: Boolean);
procedure SetSelection(const AActive: Boolean; const AStartIndex, AStopIndex: Integer);
procedure SetZoomMode(const AValue: TPDFZoomMode);
procedure SetZoomPercent(const AValue: Single);
procedure ShowError(const AMessage: string);
procedure UpdatePageIndex;
procedure WebLinkClick(const AURL: string);
procedure WMEraseBkGnd(var AMessage: TWMEraseBkgnd); message WM_ERASEBKGND;
procedure WMGetDlgCode(var AMessage: TWMGetDlgCode); message WM_GETDLGCODE;
procedure WMHScroll(var AMessage: TWMHScroll); message WM_HSCROLL;
procedure WMPaint(var AMessage: TWMPaint); message WM_PAINT;
procedure WMVScroll(var AMessage: TWMVScroll); message WM_VSCROLL;
protected
function DoMouseWheel(AShift: TShiftState; AWheelDelta: Integer; AMousePos: TPoint): Boolean; override;
function GetPageNumber: Integer;
function GetPageTop(const APageIndex: Integer): Integer;
function PageToScreen(const AValue: Single): Integer; inline;
function ZoomToScreen: Single;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
{$IFDEF ALPHASKINS}
procedure Loaded; override;
{$ENDIF}
procedure MouseDown(AButton: TMouseButton; AShift: TShiftState; X, Y: Integer); override;
procedure MouseMove(AShift: TShiftState; X, Y: Integer); override;
procedure MouseUp(AButton: TMouseButton; AShift: TShiftState; X, Y: Integer); override;
procedure PaintWindow(ADC: HDC); override;
procedure Resize; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
function FindNext: Integer;
function FindPrevious: Integer;
function IsTextSelected: Boolean;
function SearchAll: Integer; overload;
function SearchAll(const ASearchText: string): Integer; overload;
function SearchAll(const ASearchText: string; const AHighlightAll: Boolean; const AMatchCase: Boolean;
const AWholeWords: Boolean): Integer; overload;
{$IFDEF ALPHASKINS}
procedure AfterConstruction; override;
{$ENDIF}
procedure ClearSearch;
procedure ClearSelection;
procedure CloseDocument;
procedure CopyToClipboard;
procedure CreateParams(var AParams: TCreateParams); override;
procedure GotoNextPage;
procedure GotoPage(const AIndex: Integer; const ASetScrollBar: Boolean = True);
procedure GotoPreviousPage;
procedure LoadFromFile(const AFilename: string);
procedure LoadFromStream(const AStream: TStream);
{$IFDEF USE_LOAD_FROM_URL}
procedure LoadFromURL(const AURL: string);
{$ENDIF}
procedure Print;
procedure RotatePageClockwise;
procedure RotatePageCounterClockwise;
procedure SelectAll;
procedure SelectText(const ACharIndex: Integer; const ACount: Integer);
procedure SetFocus; override;
{$IFDEF ALPHASKINS}
procedure WndProc(var AMessage: TMessage); override;
{$ENDIF}
procedure ZoomToHeight;
procedure ZoomToWidth;
procedure Zoom(const APercent: Single);
property CurrentPage: TPDFPage read GetCurrentPage;
property Filename: string read FFilename write FFilename;
property OnPaint: TNotifyEvent read FOnPaint write FOnPaint;
property OnLoadProtected: TPDFLoadProtectedEvent read FOnLoadProtected write FOnLoadProtected;
property OnScroll: TPDFControlScrollEvent read FOnScroll write FOnScroll;
property PageCount: Integer read FPageCount;
property PageIndex: Integer read FPageIndex write SetPageIndex;
property PageNumber: Integer read GetPageNumber write SetPageNumber;
property SearchCount: Integer read FSearchCount write FSearchCount;
property SearchIndex: Integer read FSearchIndex write FSearchIndex;
property SearchText: string read FSearchText write FSearchText;
property SelectionLength: Integer read GetSelectionLength;
property SelectionStart: Integer read GetSelectionStart;
property SelectionText: string read GetSelectionText;
{$IFDEF ALPHASKINS}
property SkinData: TsScrollWndData read FSkinData write FSkinData;
{$ENDIF}
published
property AllowTextSelection: Boolean read FAllowTextSelection write FAllowTextSelection default True;
property Color;
property PageBorderColor: TColor read FPageBorderColor write FPageBorderColor default clSilver;
property PageMargin: Integer read FPageMargin write FPageMargin default 6;
property PopupMenu;
property PrintJobTitle: string read FPrintJobTitle write FPrintJobTitle;
property SearchHighlightAll: Boolean read FSearchHighlightAll write SetSearchHighlightAll;
property SearchMatchCase: Boolean read FSearchMatchCase write FSearchMatchCase;
property SearchWholeWords: Boolean read FSearchWholeWords write FSearchWholeWords;
property ZoomMode: TPDFZoomMode read FZoomMode write SetZoomMode default zmActualSize;
property ZoomPercent: Single read FZoomPercent write SetZoomPercent;
end;
TPDFDocumentVclPrinter = class(TPDFDocumentPrinter)
private
FBeginDocCalled: Boolean;
FPagePrinted: Boolean;
protected
function GetPrinterDC: HDC; override;
function PrinterStartDoc(const AJobTitle: string): Boolean; override;
procedure PrinterEndDoc; override;
procedure PrinterEndPage; override;
procedure PrinterStartPage; override;
public
class function PrintDocument(const ADocument: TPDFDocument; const AJobTitle: string;
const AShowPrintDialog: Boolean = True; const AllowPageRange: Boolean = True;
const AParentWnd: HWND = 0): Boolean; static;
end;
implementation
uses
Winapi.ShellAPI, System.Character, System.Generics.Collections, System.Generics.Defaults, System.Types, Vcl.Clipbrd,
Vcl.Printers
{$IFDEF USE_LOAD_FROM_URL}, IdHTTP, IdSSLOpenSSL{$ENDIF}
{$IFDEF ALPHASKINS}, sConst, sDialogs, sMessages, sStyleSimply, sVCLUtils{$ENDIF};
const
cDefaultScrollOffset = 50;
{ TPDFPage }
function TPDFPageHelper.Page: FPDF_PAGE;
begin
with Self do
Result := FPage;
end;
{ TPDFiumControl }
constructor TPDFiumControl.Create(AOwner: TComponent);
begin
{$IFDEF ALPHASKINS}
FSkinData := TsScrollWndData.Create(Self, True);
FSkinData.COC := COC_TsMemo;
FSkinData.CustomFont := True;
StyleElements := [seBorder];
{$ENDIF}
inherited Create(AOwner);
ControlStyle := ControlStyle + [csOpaque];
FZoomMode := zmActualSize;
FZoomPercent := 100;
FPageIndex := 0;
FPageMargin := 6;
FPrintJobTitle := 'Print PDF';
FAllowTextSelection := True;
FPDFDocument := CreatePDFDocument;
DoubleBuffered := True;
ParentBackground := False;
ParentColor := False;
Color := clWhite;
FPageBorderColor := clSilver;
TabStop := True;
Width := 200;
Height := 250;
VertScrollBar.Smooth := True;
VertScrollBar.Tracking := True;
HorzScrollBar.Smooth := True;
HorzScrollBar.Tracking := True;
end;
function TPDFiumControl.CreatePDFDocument: TPDFDocument;
begin
Result := TPDFDocument.Create;
Result.OnFormFieldFocus := FormFieldFocus;
Result.OnFormGetCurrentPage := FormGetCurrentPage;
Result.OnFormOutputSelectedRect := FormOutputSelectedRect;
end;
procedure TPDFiumControl.CreateParams(var AParams: TCreateParams);
begin
inherited CreateParams(AParams);
with AParams.WindowClass do
Style := Style and not (CS_HREDRAW or CS_VREDRAW);
end;
destructor TPDFiumControl.Destroy;
begin
{$IFDEF ALPHASKINS}
if Assigned(FScrollWnd) then
begin
FScrollWnd.Free;
FScrollWnd := nil;
end;
if Assigned(FSkinData) then
begin
FSkinData.Free;
FSkinData := nil;
end;
{$ENDIF}
FPDFDocument.Free;
inherited;
end;
{$IFDEF ALPHASKINS}
procedure TPDFiumControl.AfterConstruction;
begin
inherited AfterConstruction;
if HandleAllocated then
RefreshEditScrolls(SkinData, FScrollWnd);
UpdateData(FSkinData);
end;
{$ENDIF}
{$IFDEF ALPHASKINS}
procedure TPDFiumControl.Loaded;
begin
inherited Loaded;
FSkinData.Loaded(False);
end;
{$ENDIF}
procedure TPDFiumControl.WMEraseBkgnd(var AMessage: TWMEraseBkgnd);
begin
AMessage.Result := 1;
end;
procedure TPDFiumControl.WMGetDlgCode(var AMessage: TWMGetDlgCode);
begin
inherited;
AMessage.Result := AMessage.Result or DLGC_WANTARROWS;
end;
function TPDFiumControl.IsPageValid: Boolean;
begin
Result := FPDFDocument.Active and (PageIndex >= 0) and (PageIndex < PageCount);
end;
function TPDFiumControl.GetCurrentPage: TPDFPage;
begin
if IsPageValid then
Result := FPDFDocument.Pages[PageIndex]
else
Result := nil;
end;
procedure TPDFiumControl.DoScroll(const AScrollBarKind: TScrollBarKind);
begin
if Assigned(FOnScroll) then
FOnScroll(Self, AScrollBarKind);
end;
function TPDFiumControl.DoMouseWheel(AShift: TShiftState; AWheelDelta: Integer; AMousePos: TPoint): Boolean;
begin
FChanged := True;
VertScrollBar.Position := VertScrollBar.Position - AWheelDelta;
UpdatePageIndex;
DoScroll(sbVertical);
Result := True;
end;
procedure TPDFiumControl.WMHScroll(var AMessage: TWMHScroll);
begin
FChanged := True;
inherited;
DoScroll(sbHorizontal);
Invalidate;
end;
procedure TPDFiumControl.UpdatePageIndex;
var
LIndex: Integer;
LPageIndex: Integer;
LTop: Integer;
begin
LTop := Height div 3;
LPageIndex := FPageCount - 1;
{ Can't use binary search. Page info rect is not always up to date - see AdjustPageInfo. }
for LIndex := 0 to FPageCount - 1 do
if FPageInfo[LIndex].Rect.Top >= LTop then
begin
LPageIndex := LIndex - 1;
Break;
end;
PageIndex := Max(LPageIndex, 0);
end;
procedure TPDFiumControl.WMVScroll(var AMessage: TWMVScroll);
begin
FChanged := True;
inherited;
UpdatePageIndex;
DoScroll(sbVertical);
Invalidate;
end;
procedure TPDFiumControl.LoadFromFile(const AFilename: string);
var
LPassword: UTF8String;
begin
FFilename := AFilename;
try
FPDFDocument.LoadFromFile(AFilename);
except
on E: Exception do
if FPDF_GetLastError = FPDF_ERR_PASSWORD then
begin
LPassword := '';
if Assigned(FOnLoadProtected) then
FOnLoadProtected(Self, LPassword);
try
FPDFDocument.LoadFromFile(AFilename, LPassword);
except
on E: Exception do
ShowError(E.Message);
end;
end
else
ShowError(E.Message);
end;
AfterLoad;
end;
procedure TPDFiumControl.LoadFromStream(const AStream: TStream);
var
LPassword: UTF8String;
begin
try
FPDFDocument.LoadFromStream(AStream);
except
on E: Exception do
if FPDF_GetLastError = FPDF_ERR_PASSWORD then
begin
LPassword := '';
if Assigned(FOnLoadProtected) then
FOnLoadProtected(Self, LPassword);
try
FPDFDocument.LoadFromStream(AStream, LPassword);
except
on E: Exception do
ShowError(E.Message);
end;
end
else
ShowError(E.Message);
end;
AfterLoad;
end;
{$IFDEF USE_LOAD_FROM_URL}
procedure TPDFiumControl.LoadFromURL(const AURL: string);
var
LStream: TMemoryStream;
LHTTPClient: TIdHTTP;
begin
LHTTPClient := TIdHTTP.Create;
try
LStream := TMemoryStream.Create;
try
LHTTPClient.ReadTimeout := 60000;
if Pos('https://', AURL) = 1 then
begin
LHTTPClient.IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(LHTTPClient);
with TIdSSLIOHandlerSocketOpenSSL(LHTTPClient.IOHandler).SSLOptions do
begin
Method := sslvTLSv1_2;
SSLVersions := SSLVersions + [sslvTLSv1_2];
end;
LHTTPClient.Request.BasicAuthentication := True;
end;
LHTTPClient.Get(AURL, LStream);
LStream.Position := 0;
LoadFromStream(LStream);
finally
FreeAndNil(LStream);
end;
finally
LHTTPClient.Free;
end;
end;
{$ENDIF}
procedure TPDFiumControl.AfterLoad;
begin
SetPageCount(FPDFDocument.PageCount);
GetPageWebLinks;
FChanged := True;
Invalidate;
end;
function TPDFiumControl.ZoomToScreen: Single;
begin
Result := FZoomPercent / 100 * Screen.PixelsPerInch / 72;
end;
procedure TPDFiumControl.SetPageCount(const AValue: Integer);
var
LIndex: Integer;
LPage: TPDFPage;
begin
FPageCount := AValue;
FPageIndex := 0;
FWidth := 0;
FHeight := 0;
if FPageCount > 0 then
begin
SetLength(FPageInfo, FPageCount);
for LIndex := 0 to FPageCount - 1 do
begin
LPage := FPDFDocument.Pages[LIndex];
with FPageInfo[LIndex] do
begin
Width := LPage.Width;
Height := LPage.Height;
Rotation := prNormal;
SearchCurrentIndex := -1;
end;
if LPage.Width > FWidth then
FWidth := LPage.Width;
FHeight := FHeight + LPage.Height;
end;
end;
HorzScrollBar.Position := 0;
VertScrollBar.Position := 0;
SetScrollSize;
end;
procedure TPDFiumControl.SetPageNumber(const AValue: Integer);
var
LValue: Integer;
begin
LValue := AValue;
Dec(LValue);
if (LValue >= 0) and (LValue < FPageCount) and (FPageIndex <> LValue) then
begin
FPageIndex := LValue;
FChanged := True;
VertScrollBar.Position := GetPageTop(FPageIndex);
PageChanged;
end;
end;
procedure TPDFiumControl.SetPageIndex(const AValue: Integer);
begin
if FPageIndex <> AValue then
begin
FPageIndex := AValue;
PageChanged;
end;
end;
procedure TPDFiumControl.PageChanged;
begin
FSelectionStartCharIndex := 0;
FSelectionStopCharIndex := 0;
FSelectionActive := False;
GetPageWebLinks;
end;
procedure TPDFiumControl.SetScrollSize;
var
LZoom: Single;
begin
LZoom := FZoomPercent / 100 * Screen.PixelsPerInch / 72;
HorzScrollBar.Range := Round(FWidth * LZoom) + FPageMargin * 2;
VertScrollBar.Range := Round(FHeight * LZoom) + FPageMargin * (FPageCount + 1);
end;
procedure TPDFiumControl.SetSearchHighlightAll(const AValue: Boolean);
begin
FSearchHighlightAll := AValue;
Invalidate;
end;
procedure TPDFiumControl.SetZoomPercent(const AValue: Single);
var
LValue: Single;
begin
LValue := AValue;
if LValue < 0.65 then
LValue := 0.65
else
if LValue > 6400 then
LValue := 6400;
FZoomPercent := LValue;
SetScrollSize;
DoSizeChanged;
end;
procedure TPDFiumControl.Zoom(const APercent: Single);
begin
FZoomMode := zmPercent;
SetZoomPercent(APercent);
end;
procedure TPDFiumControl.DoSizeChanged;
begin
FChanged := True;
Invalidate;
if Assigned(OnResize) then
OnResize(Self);
end;
procedure TPDFiumControl.SetZoomMode(const AValue: TPDFZoomMode);
begin
FZoomMode := AValue;
AdjustZoom;
end;
procedure TPDFiumControl.AdjustZoom;
begin
case FZoomMode of
zmPercent:
Exit;
zmActualSize:
SetZoomPercent(100);
zmFitHeight:
SetZoomPercent(PageHeightZoomPercent);
zmFitWidth:
SetZoomPercent(PageWidthZoomPercent);
end;
end;
procedure TPDFiumControl.ClearSelection;
begin
SetSelection(False, 0, 0);
end;
function TPDFiumControl.SearchAll: Integer;
begin
Result := SearchAll(FSearchText, FSearchHighlightAll, FSearchMatchCase, FSearchWholeWords);
end;
function TPDFiumControl.SearchAll(const ASearchText: string): Integer;
begin
Result := SearchAll(ASearchText, FSearchHighlightAll, FSearchMatchCase, FSearchWholeWords);
end;
procedure TPDFiumControl.AdjustScrollBar(const APageIndex: Integer);
var
LRect: TRect;
LPageRect: TRect;
begin
with FPageInfo[APageIndex] do
begin
LPageRect := System.Types.Rect(0, 0, Round(Width), Round(Height));
LRect := InternPageToDevice(FPDFDocument.Pages[APageIndex], SearchRects[SearchCurrentIndex], LPageRect);
VertScrollBar.Position := GetPageTop(APageIndex) + Round( (VertScrollBar.Range / PageCount) *
LRect.Top / LPageRect.Height ) - 2 * LRect.Height;
end;
FChanged := True;
end;
function TPDFiumControl.SearchAll(const ASearchText: string; const AHighlightAll: Boolean; const AMatchCase: Boolean;
const AWholeWords: Boolean): Integer;
var
LCount, LRectCount: Integer;
LCharIndex, LCharCount: Integer;
LIndex, LPageIndex: Integer;
LPage: TPDFPage;
begin
Result := 0;
FSearchText := ASearchText;
FSearchHighlightAll := AHighlightAll;
FSearchMatchCase := AMatchCase;
FSearchWholeWords := AWholeWords;
ClearSearch;
FSearchIndex := 0;
if IsPageValid then
begin
for LPageIndex := 0 to FPageCount - 1 do
with FPageInfo[LPageIndex] do
begin
LPage := FPDFDocument.Pages[LPageIndex];
LCount := 0;
if not FSearchText.IsEmpty then
begin
if LPage.BeginFind(FSearchText, FSearchMatchCase, FSearchWholeWords, False) then
try
while LPage.FindNext(LCharIndex, LCharCount) do
begin
LRectCount := LPage.GetTextRectCount(LCharIndex, LCharCount);
if LCount + LRectCount > Length(SearchRects) then
SetLength(SearchRects, (LCount + LRectCount) * 2);
for LIndex := 0 to LRectCount - 1 do
begin
SearchRects[LCount] := LPage.GetTextRect(LIndex);
Inc(LCount);
end;
end;
finally
LPage.EndFind;
end;
if LCount <> Length(SearchRects) then
SetLength(SearchRects, LCount);
if Length(SearchRects) > 0 then
TArray.Sort<TPDFRect>(SearchRects, TComparer<TPDFRect>.Construct(
function (const ALeft, ARight: TPDFRect): Integer
begin
Result := Trunc(ARight.Top) - Trunc(ALeft.Top);
if Result = 0 then
Result := Trunc(ALeft.Left) - Trunc(ARight.Left);
end)
);
Inc(Result, LCount);
end;
end;
for LPageIndex := 0 to FPageCount - 1 do
with FPageInfo[LPageIndex] do
if Length(SearchRects) > 0 then
begin
SearchCurrentIndex := 0;
GotoPage(LPageIndex, False);
AdjustScrollBar(LPageIndex);
Break;
end;
end;
FSearchCount := Result;
Invalidate;
end;
function TPDFiumControl.FindNext: Integer;
var
LPageIndex: Integer;
LNextPage: Boolean;
begin
Result := FSearchIndex;
if FSearchIndex + 1 >= FSearchCount then
Exit;
Inc(FSearchIndex);
LNextPage := False;
for LPageIndex := 0 to FPageCount - 1 do
with FPageInfo[LPageIndex] do
begin
if LNextPage and (Length(SearchRects) > 0) then
begin
SearchCurrentIndex := 0;
Break;
end
else
if SearchCurrentIndex <> -1 then
begin
if SearchCurrentIndex + 1 < Length(SearchRects) then
begin
Inc(SearchCurrentIndex);
Break;
end
else
begin
SearchCurrentIndex := -1;
LNextPage := True;
end;
end;
end;
GotoPage(LPageIndex, False);
AdjustScrollBar(LPageIndex);
Result := FSearchIndex;
Invalidate;
end;
function TPDFiumControl.FindPrevious: Integer;
var
LPageIndex: Integer;
LPreviousPage: Boolean;
begin
Result := FSearchIndex;
if FSearchIndex - 1 < 0 then
Exit;
Dec(FSearchIndex);
LPreviousPage := False;
for LPageIndex := FPageCount - 1 downto 0 do
with FPageInfo[LPageIndex] do
begin
if LPreviousPage and (Length(SearchRects) > 0) then
begin
SearchCurrentIndex := Length(SearchRects) - 1;
Break;
end
else
if SearchCurrentIndex <> -1 then
begin
if SearchCurrentIndex - 1 >= 0 then
begin
Dec(SearchCurrentIndex);
Break;
end
else
begin
SearchCurrentIndex := -1;
LPreviousPage := True;
end;
end;
end;
GotoPage(LPageIndex, False);
AdjustScrollBar(LPageIndex);
Result := FSearchIndex;
Invalidate;
end;
procedure TPDFiumControl.ClearSearch;
var
LIndex: Integer;
begin
if IsPageValid then
for LIndex := 0 to FPageCount - 1 do
begin
SetLength(FPageInfo[LIndex].SearchRects, 0);
FPageInfo[LIndex].SearchCurrentIndex := -1;
end;
end;
procedure TPDFiumControl.SelectAll;
begin
SelectText(0, -1);
end;
procedure TPDFiumControl.SelectText(const ACharIndex: Integer; const ACount: Integer);
begin
if (ACount = 0) or not IsPageValid then
ClearSelection
else
begin
if ACount = -1 then
SetSelection(True, 0, CurrentPage.GetCharCount - 1)
else
SetSelection(True, ACharIndex, Min(ACharIndex + ACount - 1, CurrentPage.GetCharCount - 1));
end;
end;
procedure TPDFiumControl.CloseDocument;
begin
FPDFDocument.Close;
SetPageCount(0);
FFormFieldFocused := False;
Invalidate;
end;
procedure TPDFiumControl.CopyToClipboard;
begin
Clipboard.AsText := GetSelectionText;
end;
function TPDFiumControl.GetPageNumber: Integer;
begin
Result := FPageIndex + 1;
end;
function TPDFiumControl.PageToScreen(const AValue: Single): Integer;
begin
Result := Round(AValue * ZoomToScreen);
end;
function TPDFiumControl.GetPageTop(const APageIndex: Integer): Integer;
var
LY: Double;
LPageIndex: Integer;
begin
LPageIndex := APageIndex;
Result := LPageIndex * FPageMargin;
LY := 0;
while LPageIndex > 0 do
begin
Dec(LPageIndex);
LY := LY + FPageInfo[LPageIndex].Height;
end;
Inc(Result, PageToScreen(LY));
end;
procedure TPDFiumControl.GotoPage(const AIndex: Integer; const ASetScrollBar: Boolean = True);
begin
if FPageIndex = AIndex then
Exit;
if (AIndex >= 0) and (AIndex < FPageCount) then
begin
PageIndex := AIndex;
FChanged := True;
if ASetScrollBar then
VertScrollBar.Position := GetPageTop(AIndex);
end;
end;
procedure TPDFiumControl.AdjustPageInfo;
var
LIndex: Integer;
LTop: Double;
LScale: Double;
LClient: TRect;
LRect: TRect;
LMargin: Integer;
begin
for LIndex := 0 to FPageCount - 1 do
FPageInfo[LIndex].Visible := 0;
LClient := ClientRect;
LTop := 0;
LMargin := FPageMargin;
LScale := FZoomPercent / 100 * Screen.PixelsPerInch / 72;
for LIndex := 0 to FPageCount - 1 do
begin
LRect.Top := Round(LTop * LScale) + LMargin - VertScrollBar.Position;
LRect.Left := FPageMargin + Round((FWidth - FPageInfo[LIndex].Width) / 2 * LScale) - HorzScrollBar.Position;
LRect.Width := Round(FPageInfo[LIndex].Width * LScale);
LRect.Height := Round(FPageInfo[LIndex].Height * LScale);
if LRect.Width < LClient.Width - 2 * FPageMargin then
LRect.Offset((LClient.Width - LRect.Width) div 2 - LRect.Left, 0);
FPageInfo[LIndex].Rect := LRect;
if LRect.IntersectsWith(LClient) then
FPageInfo[LIndex].Visible := 1;
if LRect.Top > LClient.Bottom then
Break;
LTop := LTop + FPageInfo[LIndex].Height;
Inc(LMargin, FPageMargin);
end;
end;
function TPDFiumControl.GetSelectionText: string;
begin
if FSelectionActive and IsPageValid then
Result := CurrentPage.ReadText(SelectionStart, SelectionLength)
else
Result := '';
end;
function TPDFiumControl.GetSelectionLength: Integer;
begin
if FSelectionActive and IsPageValid then
Result := Abs(FSelectionStartCharIndex - FSelectionStopCharIndex) + 1
else
Result := 0;
end;
function TPDFiumControl.GetSelectionStart: Integer;
begin
if FSelectionActive and IsPageValid then
Result := Min(FSelectionStartCharIndex, FSelectionStopCharIndex)
else
Result := 0;
end;
function TPDFiumControl.GetSelectionRects: TPDFControlRectArray;
var
LCount: Integer;
LIndex: Integer;
LPage: TPDFPage;
begin
if FSelectionActive and HandleAllocated then
begin
LPage := CurrentPage;
if Assigned(LPage) then
begin
LCount := CurrentPage.GetTextRectCount(SelectionStart, SelectionLength);
SetLength(Result, LCount);
for LIndex := 0 to LCount - 1 do
Result[LIndex] := InternPageToDevice(LPage, LPage.GetTextRect(LIndex), FPageInfo[FPageIndex].Rect);
Exit;
end;
end;
Result := nil;
end;
procedure TPDFiumControl.InvalidateRectDiffs(const AOldRects, ANewRects: TPDFControlRectArray);
function ContainsRect(const Rects: TPDFControlRectArray; const ARect: TRect): Boolean;
var
LIndex: Integer;
begin
Result := True;
for LIndex := 0 to Length(Rects) - 1 do
if EqualRect(Rects[LIndex], ARect) then
Exit;
Result := False;
end;
var
LIndex: Integer;
begin
if HandleAllocated then
begin
for LIndex := 0 to Length(AOldRects) - 1 do
if not ContainsRect(ANewRects, AOldRects[LIndex]) then
InvalidateRect(Handle, @AOldRects[LIndex], True);
for LIndex := 0 to Length(ANewRects) - 1 do
if not ContainsRect(AOldRects, ANewRects[LIndex]) then
InvalidateRect(Handle, @ANewRects[LIndex], True);
end;
end;
procedure TPDFiumControl.SetSelection(const AActive: Boolean; const AStartIndex, AStopIndex: Integer);
var
LOldRects, LNewRects: TPDFControlRectArray;
begin
if (AActive <> FSelectionActive) or (AStartIndex <> FSelectionStartCharIndex) or (AStopIndex <> FSelectionStopCharIndex) then
begin
LOldRects := GetSelectionRects;
FSelectionStartCharIndex := AStartIndex;
FSelectionStopCharIndex := AStopIndex;
FSelectionActive := AActive and (FSelectionStartCharIndex >= 0) and (FSelectionStopCharIndex >= 0);
LNewRects := GetSelectionRects;
InvalidateRectDiffs(LOldRects, LNewRects);
end;
end;
function TPDFiumControl.SelectWord(const ACharIndex: Integer): Boolean;
var
LChar: Char;
LStartCharIndex, LStopCharIndex, LCharCount: Integer;
LPage: TPDFPage;
LCharIndex: Integer;
begin
Result := False;
LPage := CurrentPage;
if Assigned(LPage) then
begin
ClearSelection;
LCharCount := LPage.GetCharCount;
LCharIndex := ACharIndex;
if (LCharIndex >= 0) and (LCharIndex < LCharCount) then
begin
while (LCharIndex < LCharCount) and CurrentPage.ReadChar(LCharIndex).IsWhiteSpace do
Inc(LCharIndex);
if LCharIndex < LCharCount then
begin
LStartCharIndex := LCharIndex - 1;
while LStartCharIndex >= 0 do
begin
LChar := CurrentPage.ReadChar(LStartCharIndex);
if LChar.IsWhiteSpace then
Break;
Dec(LStartCharIndex);
end;
Inc(LStartCharIndex);
LStopCharIndex := LCharIndex + 1;
while LStopCharIndex < LCharCount do
begin
LChar := CurrentPage.ReadChar(LStopCharIndex);
if LChar.IsWhiteSpace then
Break;
Inc(LStopCharIndex);
end;
Dec(LStopCharIndex);
SetSelection(True, LStartCharIndex, LStopCharIndex);
Result := True;
end;
end;
end;
end;
procedure TPDFiumControl.MouseDown(AButton: TMouseButton; AShift: TShiftState; X, Y: Integer);
var
LPoint: TPDFPoint;
LCharIndex: Integer;
begin
inherited MouseDown(AButton, AShift, X, Y);
if AButton = mbLeft then
begin
SetFocus;
FMousePressed := True;
FMouseDownPoint := Point(X, Y); // used to find out if the selection must be cleared or not
end;
if IsPageValid and AllowTextSelection and not FFormFieldFocused then
begin
if AButton = mbLeft then
begin
LPoint := DeviceToPage(X, Y);
LCharIndex := CurrentPage.GetCharIndexAt(LPoint.X, LPoint.Y, MAXWORD, MAXWORD);
if ssDouble in AShift then
begin
FMousePressed := False;
SelectWord(LCharIndex);
end
else
SetSelection(False, LCharIndex, LCharIndex);
end;
end;
end;
function TPDFiumControl.GetPageIndexAt(const APoint: TPoint): Integer;
var
LIndex: Integer;
begin
Result := FPageIndex;
for LIndex := 0 to FPageCount - 1 do
if FPageInfo[LIndex].Rect.Contains(APoint) then
Exit(LIndex);
end;
procedure TPDFiumControl.MouseMove(AShift: TShiftState; X, Y: Integer);
var
LPoint: TPDFPoint;
LCursor: TCursor;
LPageIndex: Integer;
begin
inherited MouseMove(AShift, X, Y);
LPageIndex := GetPageIndexAt(Point(X, Y));
if LPageIndex <> FPageIndex then
PageIndex := LPageIndex;
LCursor := Cursor;
try
if AllowTextSelection and not FFormFieldFocused then
begin
if FMousePressed then
begin
if SetSelStopCharIndex(X, Y) then
if LCursor <> crIBeam then
begin
LCursor := crIBeam;
Cursor := LCursor;
SetCursor(Screen.Cursors[Cursor]); { Show the mouse cursor change immediately }
end;
end
else
if IsPageValid then
begin
LPoint := DeviceToPage(X, Y);
if IsWebLinkAt(X, Y) then
LCursor := crHandPoint
else
if CurrentPage.GetCharIndexAt(LPoint.X, LPoint.Y, 5, 5) >= 0 then
LCursor := crIBeam
else
if Cursor <> crDefault then
LCursor := crDefault;
end;
end;
finally
if LCursor <> Cursor then
Cursor := LCursor;
end;
end;
procedure TPDFiumControl.MouseUp(AButton: TMouseButton; AShift: TShiftState; X, Y: Integer);
var
LURL: string;
begin
inherited MouseUp(AButton, AShift, X, Y);
if FMousePressed and (AButton = mbLeft) then
begin
FMousePressed := False;
if AllowTextSelection and not FFormFieldFocused then
SetSelStopCharIndex(X, Y);
if not FSelectionActive and IsWebLinkAt(X, Y, LURL) then
WebLinkClick(LURL);
end;
end;
function TPDFiumControl.DeviceToPage(const X, Y: Integer): TPDFPoint;
var
LPage: TPDFPage;
begin
LPage := CurrentPage;
if Assigned(LPage) then
with FPageInfo[FPageIndex] do
Result := LPage.DeviceToPage(Rect.Left, Rect.Top, Rect.Width, Rect.Height, X, Y, Rotation)
else
Result := TPDFPoint.Empty;
end;
procedure TPDFiumControl.GetPageWebLinks;
var
LLinkIndex, LLinkCount: Integer;
LRectIndex, LRectCount: Integer;
LPage: TPDFPage;
begin
LPage := CurrentPage;
if Assigned(LPage) then
begin
LLinkCount := LPage.GetWebLinkCount;
SetLength(FWebLinksRects, LLinkCount);
for LLinkIndex := 0 to LLinkCount - 1 do
begin
LRectCount := LPage.GetWebLinkRectCount(LLinkIndex);
SetLength(FWebLinksRects[LLinkIndex], LRectCount);
for LRectIndex := 0 to LRectCount - 1 do
FWebLinksRects[LLinkIndex][LRectIndex] := LPage.GetWebLinkRect(LLinkIndex, LRectIndex);
end;
end
else
FWebLinksRects := nil;
end;
function TPDFiumControl.GetWebLinkIndex(const X, Y: Integer): Integer;
var
LRectIndex: Integer;
LPoint: TPoint;
LPage: TPDFPage;
begin
LPoint := Point(X, Y);
LPage := CurrentPage;
if Assigned(LPage) then
for Result := 0 to Length(FWebLinksRects) - 1 do
for LRectIndex := 0 to Length(FWebLinksRects[Result]) - 1 do
if PtInRect(InternPageToDevice(LPage, FWebLinksRects[Result][LRectIndex], FPageInfo[FPageIndex].Rect), LPoint) then
Exit;
Result := -1;
end;
function TPDFiumControl.IsWebLinkAt(const X, Y: Integer): Boolean;
begin
Result := GetWebLinkIndex(X, Y) <> -1;
end;
{ Note! There is an issue with multiline URLs in PDF - PDFium.dll returns the url using a hyphen as a separator.
The hyphen is a valid character in the url, so it can't just be removed. }
function TPDFiumControl.IsWebLinkAt(const X, Y: Integer; var AURL: string): Boolean;
var
LIndex: Integer;
begin
LIndex := GetWebLinkIndex(X, Y);
Result := LIndex <> -1;
if Result then
AURL := CurrentPage.GetWebLinkURL(LIndex)
else
AURL := '';
end;
procedure TPDFiumControl.GotoNextPage;
begin
GotoPage(FPageIndex + 1);
end;
procedure TPDFiumControl.WMPaint(var AMessage: TWMPaint);
begin
ControlState := ControlState + [csCustomPaint];
inherited;
ControlState := ControlState - [csCustomPaint];
end;
function TPDFiumControl.PageHeightZoomPercent: Single;
var
LScale: Single;
LZoom1, LZoom2: Single;
begin
if FPageIndex < 0 then
Exit(100);
LScale := 72 / Screen.PixelsPerInch;
LZoom1 := (ClientWidth - 2 * FPageMargin) * LScale / FPageInfo[FPageIndex].Width;
LZoom2 := (ClientHeight - 2 * FPageMargin) * LScale / FPageInfo[FPageIndex].Height;
if LZoom1 > LZoom2 then
LZoom1 := LZoom2;
Result := 100 * LZoom1;
end;
function TPDFiumControl.PageWidthZoomPercent: Single;
var
LScale: Single;
begin
if FPageIndex < 0 then
Exit(100);
LScale := 72 / Screen.PixelsPerInch;
Result := 100 * (ClientWidth - 2 * FPageMargin) * LScale / FPageInfo[FPageIndex].Width;
end;
function TPDFiumControl.SetSelStopCharIndex(const X, Y: Integer): Boolean;
var
LPoint: TPDFPoint;
LCharIndex: Integer;
LActive: Boolean;
LRect: TRect;
begin
LPoint := DeviceToPage(X, Y);
LCharIndex := CurrentPage.GetCharIndexAt(LPoint.X, LPoint.Y, MAXWORD, MAXWORD);
Result := LCharIndex >= 0;
if not Result then
LCharIndex := FSelectionStopCharIndex;
if FSelectionStartCharIndex <> LCharIndex then
LActive := True
else
begin
LRect := InternPageToDevice(CurrentPage, CurrentPage.GetCharBox(FSelectionStartCharIndex), FPageInfo[FPageIndex].Rect);
LActive := PtInRect(LRect, FMouseDownPoint) xor PtInRect(LRect, Point(X, Y));
end;
SetSelection(LActive, FSelectionStartCharIndex, LCharIndex);
end;
procedure TPDFiumControl.SetFocus;
begin
if CanFocus then
begin
Winapi.Windows.SetFocus(Handle);
inherited;
end;
end;
procedure TPDFiumControl.PaintWindow(ADC: HDC);
var
LIndex: Integer;
LPage: TPDFPage;
LBrush: HBrush;
begin
LBrush := CreateSolidBrush(Color);
try
FillRect(ADC, ClientRect, LBrush);
if FPageCount = 0 then
Exit;
if FChanged or (FPageCount = 0) then
begin
AdjustPageInfo;
FChanged := False;
end;
for LIndex := 0 to FPageCount - 1 do
with FPageInfo[LIndex] do
if Visible > 0 then
begin
LPage := FPDFDocument.Pages[LIndex];
FillRect(ADC, Rect, LBrush);
PaintPage(ADC, LPage, LIndex);
{ Selections are drawn only to selected page without rotation. }
if (LIndex = FPageIndex) and (Rotation = prNormal) then
begin
if FSelectionActive then
PaintPageSelection(ADC, LPage, LIndex);
PaintAlphaSelection(ADC, LPage, FFormOutputSelectedRects, LIndex);
end;
PaintPageSearchResults(ADC, LPage, LIndex);
{$IFDEF ALPHASKINS}
if IsLightStyleColor(Color) then
{$ENDIF}
PaintPageBorder(ADC, Rect);
end;
if Assigned(FOnPaint) then
FOnPaint(Self);
finally
DeleteObject(LBrush);
end;
end;
procedure TPDFiumControl.PaintPage(ADC: HDC; const APage: TPDFPage; const AIndex: Integer);
var
LRect: TRect;
LPoint: TPoint;
begin
with FPageInfo[AIndex] do
if (Rect.Left <> 0) or (Rect.Top <> 0) then
begin
LRect := TRect.Create(0, 0, Rect.Width, Rect.Height);
SetViewportOrgEx(ADC, Rect.Left, Rect.Top, @LPoint);
APage.Draw(ADC, LRect.Left, LRect.Top, LRect.Width, LRect.Height, Rotation, []);
SetViewportOrgEx(ADC, LPoint.X, LPoint.Y, nil);
end
else
FPDF_RenderPage(ADC, APage.Handle, Rect.Left, Rect.Top, Rect.Width, Rect.Height, Ord(Rotation), 0);
end;
procedure TPDFiumControl.PaintPageSelection(ADC: HDC; const APage: TPDFPage; const AIndex: Integer);
var
LCount: Integer;
LIndex: Integer;
LRects: TPDFControlPDFRectArray;
begin
LCount := APage.GetTextRectCount(SelectionStart, SelectionLength);
if LCount > 0 then
begin
SetLength(LRects, LCount);
for LIndex := 0 to LCount - 1 do
LRects[LIndex] := APage.GetTextRect(LIndex);
PaintAlphaSelection(ADC, APage, LRects, AIndex);
end;
end;
procedure TPDFiumControl.PaintPageSearchResults(ADC: HDC; const APage: TPDFPage; const AIndex: Integer);
begin
if Length(FPageInfo[AIndex].SearchRects) > 0 then
PaintAlphaSelection(ADC, APage, FPageInfo[AIndex].SearchRects, AIndex, RGB(204, 224, 204));
end;
function TPDFiumControl.InternPageToDevice(const APage: TPDFPage; const APageRect: TPDFRect; const ARect: TRect): TRect;
begin
Result := APage.PageToDevice(ARect.Left, ARect.Top, ARect.Width, ARect.Height, APageRect, APage.Rotation);
end;
procedure TPDFiumControl.PaintAlphaSelection(ADC: HDC; const APage: TPDFPage; const ARects: TPDFControlPDFRectArray;
const AIndex: Integer; const AColor: TColor = TColors.SysNone);
var
LCount: Integer;
LIndex: Integer;
LRect: TRect;
LDC: HDC;
LBitmap: TBitmap;
LBlendFunction: TBlendFunction;
LSearchColors: Boolean;
function SetBrushColor: Boolean;
var
LColor: TColor;
begin
Result := True;
LColor := AColor;
if not LSearchColors then
LColor := RGB(204, 204, 255)
else
if FPageInfo[AIndex].SearchCurrentIndex = LIndex then
LColor := RGB(240, 204, 238)
else
if not FSearchHighlightAll then
Result := False;
if Result and (LColor <> LBitmap.Canvas.Brush.Color) then
begin
LBitmap.Canvas.Brush.Color := LColor;
LBitmap.SetSize(100, 0);
LBitmap.SetSize(100, 50);
LDC := LBitmap.Canvas.Handle;
end;
end;
begin
LCount := Length(ARects);
if LCount > 0 then
begin
LBitmap := TBitmap.Create;
try
LSearchColors := AColor <> TColors.SysNone;
LBlendFunction.BlendOp := AC_SRC_OVER;
LBlendFunction.BlendFlags := 0;
LBlendFunction.SourceConstantAlpha := 128;
LBlendFunction.AlphaFormat := 0;
for LIndex := 0 to LCount - 1 do
begin
if not SetBrushColor then
Continue;
LRect := InternPageToDevice(APage, ARects[LIndex], FPageInfo[AIndex].Rect);
if LSearchColors then
LRect.Inflate(4, 4);
if RectVisible(ADC, LRect) then
AlphaBlend(ADC, LRect.Left, LRect.Top, LRect.Width, LRect.Height, LDC, 0, 0, LBitmap.Width, LBitmap.Height,
LBlendFunction);
end;
finally
LBitmap.Free;
end;
end;
end;
procedure TPDFiumControl.PaintPageBorder(ADC: HDC; const ARect: TRect);
var
LPen: HPen;
begin
LPen := CreatePen(PS_SOLID, 1, FPageBorderColor);
try
SelectObject(ADC, LPen);
MoveToEx(ADC, ARect.Left, ARect.Top, nil);
LineTo(ADC, ARect.Left + ARect.Width - 1, ARect.Top);
LineTo(ADC, ARect.Left + ARect.Width - 1, ARect.Top + ARect.Height - 1);
LineTo(ADC, ARect.Left, ARect.Top + ARect.Height - 1);
LineTo(ADC, ARect.Left, ARect.top);
finally
DeleteObject(LPen);
end;
end;
procedure TPDFiumControl.GotoPreviousPage;
begin
GotoPage(FPageIndex - 1);
end;
procedure TPDFiumControl.Print;
var
LIndex: Integer;
LPage: TPDFPage;
LStream: TMemoryStream;
LPDFDocument: TPDFDocument;
begin
LPDFDocument := CreatePDFDocument;
try
{ Flatten pages. Needed for form field values. }
Screen.Cursor := crHourGlass;
LStream := TMemoryStream.Create;
try
FPDFDocument.SaveToStream(LStream); { Original }
LStream.Position := 0;
LPDFDocument.LoadFromStream(LStream);
for LIndex := 0 to FPageCount - 1 do
begin
LPage := LPDFDocument.Pages[LIndex];
FPDFPage_Flatten(LPage.Page, 1);
end;
LPDFDocument.SaveToStream(LStream);
LStream.Position := 0;
LPDFDocument.LoadFromStream(LStream);
finally
LStream.Free;
Screen.Cursor := crDefault;
end;
TPDFDocumentVclPrinter.PrintDocument(LPDFDocument, PrintJobTitle);
finally
LPDFDocument.Free;
end;
end;
procedure TPDFiumControl.Resize;
begin
inherited;
AdjustZoom;
FChanged := True;
Invalidate;
end;
function TPDFiumControl.IsTextSelected: Boolean;
begin
Result := SelectionLength <> 0;
end;
procedure TPDFiumControl.RotatePageClockwise;
var
LPage: TPDFPage;
begin
if FPageIndex = -1 then
Exit;
LPage := FPDFDocument.Pages[FPageIndex];
with FPageInfo[FPageIndex] do
begin
Inc(Rotation);
if Ord(Rotation) > Ord(pr90CounterClockwide) then
Rotation := prNormal;
if Rotation in [prNormal, pr180] then
begin
Height := LPage.Height;
Width := LPage.Width;
end
else
begin
Height := LPage.Width;
Width := LPage.Height;
end;
end;
DoSizeChanged;
end;
procedure TPDFiumControl.RotatePageCounterClockwise;
var
LPage: TPDFPage;
begin
if FPageIndex = -1 then
Exit;
LPage := FPDFDocument.Pages[FPageIndex];
with FPageInfo[FPageIndex] do
begin
Dec(Rotation);
if Ord(Rotation) < Ord(prNormal) then
Rotation := pr90CounterClockwide;
if Rotation in [prNormal, pr180] then
begin
Height := LPage.Height;
Width := LPage.Width;
end
else
begin
Height := LPage.Width;
Width := LPage.Height;
end;
end;
DoSizeChanged;
end;
procedure TPDFiumControl.ZoomToHeight;
begin
ZoomMode := zmFitHeight;
DoSizeChanged;
end;
procedure TPDFiumControl.ZoomToWidth;
begin
ZoomMode := zmFitWidth;
DoSizeChanged;
end;
procedure TPDFiumControl.FormOutputSelectedRect(ADocument: TPDFDocument; APage: TPDFPage; const APageRect: TPDFRect);
begin
if HandleAllocated then
begin
SetLength(FFormOutputSelectedRects, Length(FFormOutputSelectedRects) + 1);
FFormOutputSelectedRects[Length(FFormOutputSelectedRects) - 1] := APageRect;
end;
end;
procedure TPDFiumControl.FormGetCurrentPage(ADocument: TPDFDocument; var APage: TPDFPage);
begin
APage := CurrentPage;
end;
procedure TPDFiumControl.FormFieldFocus(ADocument: TPDFDocument; AValue: PWideChar; AValueLen: Integer; AFieldFocused: Boolean);
begin
ClearSelection;
FFormFieldFocused := AFieldFocused;
end;
procedure TPDFiumControl.ShowError(const AMessage: string);
begin
{$IFDEF ALPHASKINS}
sMessageDlg(AMessage, mtError, [mbOK], 0);
{$ELSE}
MessageDlg(AMessage, mtError, [mbOK], 0);
{$ENDIF}
end;
procedure TPDFiumControl.WebLinkClick(const AURL: string);
var
LResult: Boolean;
begin
LResult := ShellExecute(0, 'open', PChar(AURL), nil, nil, SW_NORMAL) > 32;
if not LResult then
ShowError(SysErrorMessage(GetLastError));
end;
procedure TPDFiumControl.KeyDown(var Key: Word; Shift: TShiftState);
begin
inherited KeyDown(Key, Shift);
case Key of
VK_RIGHT, VK_LEFT, VK_UP, VK_DOWN:
FChanged := True;
end;
case Key of
Ord('C'), VK_INSERT:
if AllowTextSelection then
begin
if Shift = [ssCtrl] then
begin
if FSelectionActive then
CopyToClipboard;
Key := 0;
end
end;
Ord('A'):
if AllowTextSelection then
begin
if Shift = [ssCtrl] then
begin
SelectAll;
Key := 0;
end;
end;
VK_RIGHT:
HorzScrollBar.Position := HorzScrollBar.Position - cDefaultScrollOffset;
VK_LEFT:
HorzScrollBar.Position := HorzScrollBar.Position + cDefaultScrollOffset;
VK_UP:
VertScrollBar.Position := VertScrollBar.Position - cDefaultScrollOffset;
VK_DOWN:
VertScrollBar.Position := VertScrollBar.Position + cDefaultScrollOffset;
VK_PRIOR:
GotoPreviousPage;
VK_NEXT:
GotoNextPage;
VK_HOME:
GotoPage(0);
VK_END:
GotoPage(PageCount - 1);
end;
case Key of
VK_UP, VK_DOWN:
UpdatePageIndex;
end;
case Key of
VK_UP, VK_DOWN, VK_PRIOR, VK_NEXT, VK_HOME, VK_END:
if Assigned(OnScroll) then
OnScroll(Self, sbVertical);
end;
end;
{$IFDEF ALPHASKINS}
procedure TPDFiumControl.WndProc(var AMessage: TMessage);
var
LPaintStruct: TPaintStruct;
begin
if AMessage.Msg = SM_ALPHACMD then
case AMessage.WParamHi of
AC_CTRLHANDLED:
begin
AMessage.Result := 1;
Exit;
end;
AC_SETNEWSKIN:
if ACUInt(AMessage.LParam) = ACUInt(SkinData.SkinManager) then
begin
CommonMessage(AMessage, FSkinData);
Exit;
end;
AC_REMOVESKIN:
if ACUInt(AMessage.LParam) = ACUInt(SkinData.SkinManager) then
begin
if Assigned(FScrollWnd) then
begin
FreeAndNil(FScrollWnd);
RecreateWnd;
end;
Exit;
end;
AC_REFRESH:
if RefreshNeeded(SkinData, AMessage) then
begin
RefreshEditScrolls(SkinData, FScrollWnd);
CommonMessage(AMessage, FSkinData);
if HandleAllocated and Visible then
RedrawWindow(Handle, nil, 0, RDWA_REPAINT);
Exit;
end;
AC_GETDEFSECTION:
begin
AMessage.Result := 1;
Exit;
end;
AC_GETDEFINDEX:
begin
if Assigned(FSkinData.SkinManager) then
AMessage.Result := FSkinData.SkinManager.SkinCommonInfo.Sections[ssEdit] + 1;
Exit;
end;
AC_SETGLASSMODE:
begin
CommonMessage(AMessage, FSkinData);
Exit;
end;
end;
if not ControlIsReady(Self) or not Assigned(FSkinData) or not FSkinData.Skinned then
inherited
else
begin
case AMessage.Msg of
WM_ERASEBKGND:
if (SkinData.SkinIndex >= 0) and InUpdating(FSkinData) then
Exit;
WM_PAINT:
begin
if InUpdating(FSkinData) then
begin
BeginPaint(Handle, LPaintStruct);
EndPaint(Handle, LPaintStruct);
end
else
inherited;
Exit;
end;
end;
if CommonWndProc(AMessage, FSkinData) then
Exit;
inherited;
case AMessage.Msg of
CM_SHOWINGCHANGED:
RefreshEditScrolls(SkinData, FScrollWnd);
CM_VISIBLECHANGED, CM_ENABLEDCHANGED, WM_SETFONT:
FSkinData.Invalidate;
CM_TEXTCHANGED, CM_CHANGED:
if Assigned(FScrollWnd) then
UpdateScrolls(FScrollWnd, True);
end;
end;
end;
{$ENDIF}
{ TPDFDocumentVclPrinter }
function VclAbortProc(Prn: HDC; Error: Integer): Bool; stdcall;
begin
Application.ProcessMessages;
Result := not Printer.Aborted;
end;
function FastVclAbortProc(Prn: HDC; Error: Integer): Bool; stdcall;
begin
Result := not Printer.Aborted;
end;
function TPDFDocumentVclPrinter.PrinterStartDoc(const AJobTitle: string): Boolean;
begin
Result := False;
FPagePrinted := False;
if not Printer.Printing then
begin
if AJobTitle <> '' then
Printer.Title := AJobTitle;
Printer.BeginDoc;
FBeginDocCalled := Printer.Printing;
Result := FBeginDocCalled;
end;
if Result then
SetAbortProc(GetPrinterDC, @FastVclAbortProc);
end;
procedure TPDFDocumentVclPrinter.PrinterEndDoc;
begin
if Printer.Printing and FBeginDocCalled then
Printer.EndDoc;
SetAbortProc(GetPrinterDC, @VclAbortProc);
end;
procedure TPDFDocumentVclPrinter.PrinterStartPage;
begin
if (Printer.PageNumber > 1) or FPagePrinted then
Printer.NewPage;
end;
procedure TPDFDocumentVclPrinter.PrinterEndPage;
begin
FPagePrinted := True;
end;
function TPDFDocumentVclPrinter.GetPrinterDC: HDC;
begin
Result := Printer.Handle;
end;
class function TPDFDocumentVclPrinter.PrintDocument(const ADocument: TPDFDocument;
const AJobTitle: string; const AShowPrintDialog: Boolean = True; const AllowPageRange: Boolean = True;
const AParentWnd: HWND = 0): Boolean;
var
LPDFDocumentVclPrinter: TPDFDocumentVclPrinter;
LPrintDialog: TPrintDialog;
LFromPage, LToPage: Integer;
begin
Result := False;
if not Assigned(ADocument) then
Exit;
LFromPage := 1;
LToPage := ADocument.PageCount;
if AShowPrintDialog then
begin
LPrintDialog := TPrintDialog.Create(nil);
try
if AllowPageRange then
begin
LPrintDialog.Options := LPrintDialog.Options + [poPageNums];
LPrintDialog.MinPage := 1;
LPrintDialog.MaxPage := ADocument.PageCount;
LPrintDialog.ToPage := ADocument.PageCount;
end;
if (AParentWnd = 0) or not IsWindow(AParentWnd) then
Result := LPrintDialog.Execute
else
Result := LPrintDialog.Execute(AParentWnd);
if not Result then
Exit;
if AllowPageRange and (LPrintDialog.PrintRange = prPageNums) then
begin
LFromPage := LPrintDialog.FromPage;
LToPage := LPrintDialog.ToPage;
end;
{ Note! Copies and collate won't work. Andy's core class needs to be fixed to get it working.
Capture here the variables and pass them to following Print function.
LCopies := LPrintDialog.Copies;
LCollate := LPrintDialog.Collate; }
finally
LPrintDialog.Free;
end;
end;
{ Note! If the document has pages in portrait and landscape orientation, this will not work properly. The problem is
that the orientation of the printer can be changed only when outside BeginDoc and EndDoc. If there is a need for
that, then Andy's core class needs to be fixed. }
if ADocument.PageCount > 0 then
if ADocument.Pages[0].Height > ADocument.Pages[0].Width then
Printer.Orientation := poPortrait
else
Printer.Orientation := poLandscape;
LPDFDocumentVclPrinter := TPDFDocumentVclPrinter.Create;
try
if LPDFDocumentVclPrinter.BeginPrint(AJobTitle) then
try
Result := LPDFDocumentVclPrinter.Print(ADocument, LFromPage - 1, LToPage - 1);
finally
LPDFDocumentVclPrinter.EndPrint;
end;
finally
LPDFDocumentVclPrinter.Free;
end;
end;
end.
| 26.218101 | 128 | 0.705242 |
Subsets and Splits
HTML Code Excluding Scripts
The query retrieves a limited set of HTML content entries that are longer than 8 characters and do not contain script tags, offering only basic filtering with minimal analytical value.