2014-05-30 12:51:01 +00:00
|
|
|
unit X2Log.Details.Default;
|
|
|
|
|
|
|
|
interface
|
|
|
|
uses
|
|
|
|
System.Classes,
|
2016-10-10 20:17:53 +00:00
|
|
|
System.Generics.Collections,
|
2014-06-01 13:32:21 +00:00
|
|
|
Vcl.Graphics,
|
2014-05-30 12:51:01 +00:00
|
|
|
|
2014-06-01 13:32:21 +00:00
|
|
|
X2Log.Details.Intf,
|
2014-05-30 12:51:01 +00:00
|
|
|
X2Log.Intf;
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
TX2LogStringDetails = class(TInterfacedObject, IX2LogDetails, IX2LogDetailsText,
|
|
|
|
IX2LogDetailsCopyable, IX2LogDetailsStreamable)
|
|
|
|
private
|
|
|
|
FText: string;
|
|
|
|
public
|
|
|
|
class function CreateIfNotEmpty(const AText: string): TX2LogStringDetails;
|
|
|
|
|
|
|
|
constructor Create(const AText: string);
|
|
|
|
|
2014-05-31 20:10:10 +00:00
|
|
|
{ IX2LogDetails }
|
|
|
|
function GetSerializerIID: TGUID;
|
|
|
|
|
2014-05-30 12:51:01 +00:00
|
|
|
{ IX2LogDetailsText }
|
|
|
|
function GetAsString: string;
|
|
|
|
|
|
|
|
{ IX2LogDetailsCopyable }
|
|
|
|
procedure CopyToClipboard;
|
|
|
|
|
|
|
|
{ IX2LogDetailsStreamable }
|
|
|
|
procedure SaveToStream(AStream: TStream);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
TX2LogDictionaryValueClass = class of TX2LogDictionaryValue;
|
|
|
|
|
|
|
|
TX2LogDictionaryValue = class(TObject)
|
|
|
|
private
|
|
|
|
FValueType: TX2LogValueType;
|
|
|
|
protected
|
2016-10-14 14:43:53 +00:00
|
|
|
constructor Create(AValueType: TX2LogValueType; AStream: TStream = nil; ASize: Cardinal = 0); overload; virtual;
|
2016-10-13 20:58:56 +00:00
|
|
|
|
2016-10-14 14:43:53 +00:00
|
|
|
procedure LoadFromStream(AStream: TStream; ASize: Cardinal); virtual; abstract;
|
2016-10-13 20:58:56 +00:00
|
|
|
procedure SaveToStream(AStream: TStream); virtual; abstract;
|
|
|
|
|
2016-10-15 09:22:51 +00:00
|
|
|
function GetDisplayValue: string; virtual; abstract;
|
|
|
|
|
|
|
|
property DisplayValue: string read GetDisplayValue;
|
2016-10-13 20:58:56 +00:00
|
|
|
property ValueType: TX2LogValueType read FValueType;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
IX2LogDetailsDictionaryAccess = interface(IX2LogDetailsDictionary)
|
|
|
|
['{60C46488-9DBD-4596-8BE9-916C61006F0E}']
|
|
|
|
function GetValue(const Key: string): TX2LogDictionaryValue;
|
|
|
|
|
|
|
|
property Value[const Key: string]: TX2LogDictionaryValue read GetValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
TX2LogValueDictionary = TObjectDictionary<string, TX2LogDictionaryValue>;
|
|
|
|
|
|
|
|
|
2017-04-26 15:20:48 +00:00
|
|
|
IX2LogDetailsDictionaryWriter = interface(IX2LogDetailsDictionary)
|
|
|
|
procedure SetStringValue(const Key: string; const AValue: string);
|
|
|
|
procedure SetBooleanValue(const Key: string; const AValue: Boolean);
|
|
|
|
procedure SetIntValue(const Key: string; const AValue: Int64);
|
|
|
|
procedure SetFloatValue(const Key: string; const AValue: Extended);
|
|
|
|
procedure SetDateTimeValue(const Key: string; const AValue: TDateTime);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-10 20:17:53 +00:00
|
|
|
TX2LogDictionaryDetails = class(TInterfacedObject, IX2LogDetails, IX2LogDetailsDictionary,
|
2017-04-26 15:20:48 +00:00
|
|
|
IX2LogDetailsDictionaryAccess, IX2LogDetailsDictionaryWriter)
|
2016-10-10 20:17:53 +00:00
|
|
|
private
|
2016-10-13 20:58:56 +00:00
|
|
|
FValues: TX2LogValueDictionary;
|
|
|
|
protected
|
|
|
|
constructor CreateOwned(AValues: TX2LogValueDictionary);
|
|
|
|
|
|
|
|
{ IX2LogDetailsDictionaryAccess }
|
|
|
|
function GetValue(const Key: string): TX2LogDictionaryValue;
|
2016-10-10 20:17:53 +00:00
|
|
|
public
|
|
|
|
class function CreateIfNotEmpty(AValues: array of const): TX2LogDictionaryDetails;
|
|
|
|
|
|
|
|
constructor Create(AValues: array of const);
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
|
|
{ IX2LogDetails }
|
|
|
|
function GetSerializerIID: TGUID;
|
|
|
|
|
|
|
|
{ IX2LogDetailsDictionary }
|
2016-10-13 20:58:56 +00:00
|
|
|
function GetKeys: TEnumerable<string>;
|
|
|
|
function GetValueType(const Key: string): TX2LogValueType;
|
2016-10-15 09:22:51 +00:00
|
|
|
function GetDisplayValue(const Key: string): string;
|
2016-10-13 20:58:56 +00:00
|
|
|
|
|
|
|
function GetStringValue(const Key: string): string;
|
|
|
|
function GetBooleanValue(const Key: string): Boolean;
|
|
|
|
function GetIntValue(const Key: string): Int64;
|
|
|
|
function GetFloatValue(const Key: string): Extended;
|
|
|
|
function GetDateTimeValue(const Key: string): TDateTime;
|
2017-04-26 15:20:48 +00:00
|
|
|
|
|
|
|
{ IX2LogDetailsDictionaryWriter }
|
|
|
|
procedure SetStringValue(const Key: string; const AValue: string);
|
|
|
|
procedure SetBooleanValue(const Key: string; const AValue: Boolean);
|
|
|
|
procedure SetIntValue(const Key: string; const AValue: Int64);
|
|
|
|
procedure SetFloatValue(const Key: string; const AValue: Extended);
|
|
|
|
procedure SetDateTimeValue(const Key: string; const AValue: TDateTime);
|
2016-10-10 20:17:53 +00:00
|
|
|
end;
|
|
|
|
|
2014-05-30 12:51:01 +00:00
|
|
|
|
|
|
|
TX2LogBinaryDetails = class(TInterfacedObject, IX2LogDetails, IX2LogDetailsBinary,
|
|
|
|
IX2LogDetailsStreamable)
|
|
|
|
private
|
|
|
|
FData: TStream;
|
|
|
|
protected
|
|
|
|
property Data: TStream read FData;
|
|
|
|
public
|
2014-05-31 20:10:10 +00:00
|
|
|
constructor Create; overload;
|
|
|
|
constructor Create(ACopyFrom: TStream; ACount: Integer = 0); overload;
|
2014-05-30 12:51:01 +00:00
|
|
|
constructor Create(AData: RawByteString); overload;
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
2014-05-31 20:10:10 +00:00
|
|
|
{ IX2LogDetails }
|
|
|
|
function GetSerializerIID: TGUID;
|
|
|
|
|
2014-05-30 12:51:01 +00:00
|
|
|
{ IX2LogDetailsBinary }
|
|
|
|
function GetAsStream: TStream;
|
|
|
|
|
|
|
|
{ IX2LogDetailsStreamable }
|
|
|
|
procedure SaveToStream(AStream: TStream);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-06-01 13:32:21 +00:00
|
|
|
|
|
|
|
TX2LogGraphicDetails = class(TInterfacedObject, IX2LogDetails, IX2LogDetailsGraphic,
|
|
|
|
IX2LogDetailsCopyable, IX2LogDetailsStreamable)
|
|
|
|
private
|
|
|
|
FGraphic: TGraphic;
|
|
|
|
protected
|
|
|
|
{ Dummy parameter to prevent 'Duplicate constructor inaccessible from C++' warning }
|
|
|
|
constructor CreateOwned(AGraphic: TGraphic; ADummy: Integer = 0);
|
|
|
|
public
|
|
|
|
class function CreateIfNotEmpty(AGraphic: TGraphic): TX2LogGraphicDetails;
|
|
|
|
|
|
|
|
constructor Create(AGraphic: TGraphic);
|
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
|
|
{ IX2LogDetails }
|
|
|
|
function GetSerializerIID: TGUID;
|
|
|
|
|
|
|
|
{ IX2LogDetailsGraphic }
|
|
|
|
function GetAsGraphic: TGraphic;
|
|
|
|
|
|
|
|
{ IX2LogDetailsCopyable }
|
|
|
|
procedure CopyToClipboard;
|
|
|
|
|
|
|
|
{ IX2LogDetailsStreamable }
|
|
|
|
procedure SaveToStream(AStream: TStream);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-30 12:51:01 +00:00
|
|
|
implementation
|
|
|
|
uses
|
|
|
|
System.SysUtils,
|
2014-05-31 20:10:10 +00:00
|
|
|
Vcl.ClipBrd,
|
2014-06-01 13:32:21 +00:00
|
|
|
Winapi.Windows,
|
2014-05-31 20:10:10 +00:00
|
|
|
|
|
|
|
X2Log.Constants,
|
2014-06-01 13:32:21 +00:00
|
|
|
X2Log.Details.Registry,
|
|
|
|
X2Log.Util.Stream;
|
2014-05-31 20:10:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
const
|
|
|
|
StringDetailsSerializerIID: TGUID = '{4223C30E-6E80-4D66-9EDC-F8688A7413D2}';
|
2016-10-10 20:17:53 +00:00
|
|
|
DictionaryDetailsSerializerIID: TGUID = '{1D28FF6E-8AA7-41FA-96D7-0CE921D9CA2E}';
|
2014-05-31 20:10:10 +00:00
|
|
|
BinaryDetailsSerializerIID: TGUID = '{05F6E8BD-118E-41B3-B626-1F190CC2A7D3}';
|
2014-06-01 13:32:21 +00:00
|
|
|
GraphicDetailsSerializerIID: TGUID = '{BD31E42A-83DC-4947-A862-79ABAE8D5056}';
|
2014-05-31 20:10:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type
|
|
|
|
TX2LogStringDetailsSerializer = class(TInterfacedObject, IX2LogDetailsSerializer)
|
|
|
|
public
|
|
|
|
{ IX2LogDetailsSerializer }
|
|
|
|
procedure Serialize(ADetails: IX2LogDetails; AStream: TStream);
|
|
|
|
function Deserialize(AStream: TStream): IX2LogDetails;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-10 20:17:53 +00:00
|
|
|
TX2LogDictionaryDetailsSerializer = class(TInterfacedObject, IX2LogDetailsSerializer)
|
|
|
|
public
|
|
|
|
{ IX2LogDetailsSerializer }
|
|
|
|
procedure Serialize(ADetails: IX2LogDetails; AStream: TStream);
|
|
|
|
function Deserialize(AStream: TStream): IX2LogDetails;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-31 20:10:10 +00:00
|
|
|
TX2LogBinaryDetailsSerializer = class(TInterfacedObject, IX2LogDetailsSerializer)
|
|
|
|
public
|
|
|
|
{ IX2LogDetailsSerializer }
|
|
|
|
procedure Serialize(ADetails: IX2LogDetails; AStream: TStream);
|
|
|
|
function Deserialize(AStream: TStream): IX2LogDetails;
|
|
|
|
end;
|
2014-05-30 12:51:01 +00:00
|
|
|
|
|
|
|
|
2014-06-01 13:32:21 +00:00
|
|
|
TX2LogGraphicDetailsSerializer = class(TInterfacedObject, IX2LogDetailsSerializer)
|
|
|
|
public
|
|
|
|
{ IX2LogDetailsSerializer }
|
|
|
|
procedure Serialize(ADetails: IX2LogDetails; AStream: TStream);
|
|
|
|
function Deserialize(AStream: TStream): IX2LogDetails;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
TX2LogDictionaryStringValue = class(TX2LogDictionaryValue)
|
|
|
|
private
|
|
|
|
FValue: string;
|
|
|
|
protected
|
2016-10-14 14:43:53 +00:00
|
|
|
constructor Create(const AValue: string); overload;
|
|
|
|
|
|
|
|
procedure LoadFromStream(AStream: TStream; ASize: Cardinal); override;
|
2016-10-13 20:58:56 +00:00
|
|
|
procedure SaveToStream(AStream: TStream); override;
|
|
|
|
|
2016-10-15 09:22:51 +00:00
|
|
|
function GetDisplayValue: string; override;
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
property Value: string read FValue write FValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
TX2LogDictionaryBooleanValue = class(TX2LogDictionaryValue)
|
|
|
|
private
|
|
|
|
FValue: Boolean;
|
|
|
|
protected
|
2016-10-14 14:43:53 +00:00
|
|
|
constructor Create(AValue: Boolean); overload;
|
|
|
|
|
|
|
|
procedure LoadFromStream(AStream: TStream; ASize: Cardinal); override;
|
2016-10-13 20:58:56 +00:00
|
|
|
procedure SaveToStream(AStream: TStream); override;
|
|
|
|
|
2016-10-15 09:22:51 +00:00
|
|
|
function GetDisplayValue: string; override;
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
property Value: Boolean read FValue write FValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
TX2LogDictionaryIntValue = class(TX2LogDictionaryValue)
|
|
|
|
private
|
|
|
|
FValue: Int64;
|
|
|
|
protected
|
2016-10-14 14:43:53 +00:00
|
|
|
constructor Create(AValue: Int64); overload;
|
|
|
|
|
|
|
|
procedure LoadFromStream(AStream: TStream; ASize: Cardinal); override;
|
2016-10-13 20:58:56 +00:00
|
|
|
procedure SaveToStream(AStream: TStream); override;
|
|
|
|
|
2016-10-15 09:22:51 +00:00
|
|
|
function GetDisplayValue: string; override;
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
property Value: Int64 read FValue write FValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
TX2LogDictionaryFloatValue = class(TX2LogDictionaryValue)
|
|
|
|
private
|
|
|
|
FValue: Extended;
|
|
|
|
protected
|
2016-10-14 14:43:53 +00:00
|
|
|
constructor Create(AValue: Extended); overload;
|
|
|
|
|
|
|
|
procedure LoadFromStream(AStream: TStream; ASize: Cardinal); override;
|
2016-10-13 20:58:56 +00:00
|
|
|
procedure SaveToStream(AStream: TStream); override;
|
|
|
|
|
2016-10-15 09:22:51 +00:00
|
|
|
function GetDisplayValue: string; override;
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
property Value: Extended read FValue write FValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
TX2LogDictionaryDateTimeValue = class(TX2LogDictionaryValue)
|
|
|
|
private
|
|
|
|
FValue: TDateTime;
|
|
|
|
protected
|
2016-10-14 14:43:53 +00:00
|
|
|
constructor Create(AValue: TDateTime); overload;
|
|
|
|
|
|
|
|
procedure LoadFromStream(AStream: TStream; ASize: Cardinal); override;
|
2016-10-13 20:58:56 +00:00
|
|
|
procedure SaveToStream(AStream: TStream); override;
|
|
|
|
|
2016-10-15 09:22:51 +00:00
|
|
|
function GetDisplayValue: string; override;
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
property Value: TDateTime read FValue write FValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-30 12:51:01 +00:00
|
|
|
{ TX2LogStringDetails }
|
|
|
|
class function TX2LogStringDetails.CreateIfNotEmpty(const AText: string): TX2LogStringDetails;
|
|
|
|
begin
|
|
|
|
if Length(AText) > 0 then
|
|
|
|
Result := Self.Create(AText)
|
|
|
|
else
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
constructor TX2LogStringDetails.Create(const AText: string);
|
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
|
|
|
|
FText := AText;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-31 20:10:10 +00:00
|
|
|
function TX2LogStringDetails.GetSerializerIID: TGUID;
|
|
|
|
begin
|
|
|
|
Result := StringDetailsSerializerIID;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-30 12:51:01 +00:00
|
|
|
function TX2LogStringDetails.GetAsString: string;
|
|
|
|
begin
|
|
|
|
Result := FText;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2LogStringDetails.CopyToClipboard;
|
|
|
|
begin
|
|
|
|
Clipboard.AsText := GetAsString;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2LogStringDetails.SaveToStream(AStream: TStream);
|
|
|
|
var
|
2014-05-31 20:10:10 +00:00
|
|
|
writer: TStreamWriter;
|
2014-05-30 12:51:01 +00:00
|
|
|
|
|
|
|
begin
|
2014-05-31 20:10:10 +00:00
|
|
|
writer := TStreamWriter.Create(AStream, TEncoding.UTF8);
|
2014-05-30 12:51:01 +00:00
|
|
|
try
|
2014-05-31 20:10:10 +00:00
|
|
|
writer.Write(GetAsString);
|
2014-05-30 12:51:01 +00:00
|
|
|
finally
|
2014-05-31 20:10:10 +00:00
|
|
|
FreeAndNil(writer);
|
2014-05-30 12:51:01 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-10 20:17:53 +00:00
|
|
|
{ TX2LogDictionaryDetails }
|
|
|
|
class function TX2LogDictionaryDetails.CreateIfNotEmpty(AValues: array of const): TX2LogDictionaryDetails;
|
|
|
|
begin
|
|
|
|
if Length(AValues) > 0 then
|
|
|
|
Result := TX2LogDictionaryDetails.Create(AValues)
|
|
|
|
else
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
constructor TX2LogDictionaryDetails.CreateOwned(AValues: TX2LogValueDictionary);
|
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
|
|
|
|
FValues := AValues;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-10 20:17:53 +00:00
|
|
|
constructor TX2LogDictionaryDetails.Create(AValues: array of const);
|
2016-10-13 20:58:56 +00:00
|
|
|
var
|
|
|
|
paramIndex: Integer;
|
|
|
|
param: TVarRec;
|
|
|
|
key: string;
|
2016-10-14 14:43:53 +00:00
|
|
|
value: TX2LogDictionaryValue;
|
2016-10-15 07:37:58 +00:00
|
|
|
logDateTime: IX2LogDateTime;
|
2016-10-13 20:58:56 +00:00
|
|
|
|
2016-10-10 20:17:53 +00:00
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
FValues := TX2LogValueDictionary.Create([doOwnsValues]);
|
|
|
|
|
|
|
|
if Length(AValues) mod 2 = 1 then
|
|
|
|
raise Exception.Create('AParams must contains a multiple of 2 number of items');
|
|
|
|
|
|
|
|
paramIndex := 0;
|
|
|
|
while paramIndex < High(AValues) do
|
|
|
|
begin
|
|
|
|
param := AValues[paramIndex];
|
|
|
|
|
|
|
|
case param.VType of
|
|
|
|
vtChar: key := string(param.VChar);
|
|
|
|
vtString: key := string(param.VString^);
|
|
|
|
vtPChar: key := string(param.VPChar);
|
|
|
|
vtAnsiString: key := string(PChar(param.VAnsiString));
|
|
|
|
vtWideChar: key := string(param.VWideChar);
|
|
|
|
vtPWideChar: key := string(param.VPWideChar);
|
|
|
|
vtWideString: key := string(WideString(param.VWideString));
|
|
|
|
{$IF CompilerVersion >= 23}
|
|
|
|
vtUnicodeString: key := string(UnicodeString(param.VUnicodeString));
|
|
|
|
{$IFEND}
|
|
|
|
else
|
|
|
|
raise Exception.CreateFmt('Parameter name at index %d is not a string value',
|
|
|
|
[paramIndex div 2]);
|
|
|
|
end;
|
|
|
|
|
|
|
|
Inc(paramIndex);
|
|
|
|
|
|
|
|
param := AValues[paramIndex];
|
|
|
|
case param.VType of
|
2016-10-14 14:43:53 +00:00
|
|
|
vtInteger: value := TX2LogDictionaryIntValue.Create(param.VInteger);
|
|
|
|
vtBoolean: value := TX2LogDictionaryBooleanValue.Create(param.VBoolean);
|
|
|
|
vtChar: value := TX2LogDictionaryStringValue.Create(string(param.VChar));
|
|
|
|
vtExtended: value := TX2LogDictionaryFloatValue.Create(param.VExtended^);
|
|
|
|
vtString: value := TX2LogDictionaryStringValue.Create(string(param.VString^));
|
|
|
|
vtPChar: value := TX2LogDictionaryStringValue.Create(string(param.VPChar));
|
|
|
|
vtWideChar: value := TX2LogDictionaryStringValue.Create(param.VWideChar);
|
|
|
|
vtPWideChar: value := TX2LogDictionaryStringValue.Create(param.VPWideChar);
|
|
|
|
vtAnsiString: value := TX2LogDictionaryStringValue.Create(PChar(param.VAnsiString));
|
|
|
|
vtCurrency: value := TX2LogDictionaryFloatValue.Create(param.VCurrency^);
|
2016-10-15 07:37:58 +00:00
|
|
|
vtInterface:
|
|
|
|
if Supports(IInterface(param.VInterface), IX2LogDateTime, logDateTime) then
|
|
|
|
value := TX2LogDictionaryDateTimeValue.Create(logDateTime.Value)
|
|
|
|
else
|
|
|
|
raise Exception.CreateFmt('Unsupported value type %d at index %d', [param.VType, paramIndex]);
|
|
|
|
|
2016-10-14 14:43:53 +00:00
|
|
|
vtWideString: value := TX2LogDictionaryStringValue.Create(WideString(param.VWideString));
|
|
|
|
vtInt64: value := TX2LogDictionaryIntValue.Create(param.VInt64^);
|
2016-10-13 20:58:56 +00:00
|
|
|
{$IF CompilerVersion >= 23}
|
2016-10-14 14:43:53 +00:00
|
|
|
vtUnicodeString: value := TX2LogDictionaryStringValue.Create(UnicodeString(param.VUnicodeString));
|
2016-10-13 20:58:56 +00:00
|
|
|
{$IFEND}
|
|
|
|
else
|
|
|
|
raise Exception.CreateFmt('Unsupported value type %d at index %d', [param.VType, paramIndex]);
|
|
|
|
end;
|
|
|
|
|
2016-10-14 14:43:53 +00:00
|
|
|
FValues.Add(key, value);
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
Inc(paramIndex);
|
|
|
|
end;
|
2016-10-10 20:17:53 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
destructor TX2LogDictionaryDetails.Destroy;
|
|
|
|
begin
|
|
|
|
FreeAndNil(FValues);
|
|
|
|
|
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TX2LogDictionaryDetails.GetSerializerIID: TGUID;
|
|
|
|
begin
|
|
|
|
Result := DictionaryDetailsSerializerIID;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
function TX2LogDictionaryDetails.GetKeys: TEnumerable<string>;
|
|
|
|
begin
|
|
|
|
Result := FValues.Keys;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TX2LogDictionaryDetails.GetValueType(const Key: string): TX2LogValueType;
|
|
|
|
begin
|
|
|
|
Result := FValues[Key].ValueType;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-15 09:22:51 +00:00
|
|
|
function TX2LogDictionaryDetails.GetDisplayValue(const Key: string): string;
|
|
|
|
begin
|
|
|
|
Result := FValues[Key].DisplayValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
function TX2LogDictionaryDetails.GetStringValue(const Key: string): string;
|
|
|
|
begin
|
|
|
|
Result := (FValues[Key] as TX2LogDictionaryStringValue).Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TX2LogDictionaryDetails.GetBooleanValue(const Key: string): Boolean;
|
2016-10-10 20:17:53 +00:00
|
|
|
begin
|
2016-10-13 20:58:56 +00:00
|
|
|
Result := (FValues[Key] as TX2LogDictionaryBooleanValue).Value;
|
2016-10-10 20:17:53 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
function TX2LogDictionaryDetails.GetIntValue(const Key: string): Int64;
|
2016-10-10 20:17:53 +00:00
|
|
|
begin
|
2016-10-13 20:58:56 +00:00
|
|
|
Result := (FValues[Key] as TX2LogDictionaryIntValue).Value;
|
2016-10-10 20:17:53 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
function TX2LogDictionaryDetails.GetFloatValue(const Key: string): Extended;
|
2016-10-10 20:17:53 +00:00
|
|
|
begin
|
2016-10-13 20:58:56 +00:00
|
|
|
Result := (FValues[Key] as TX2LogDictionaryFloatValue).Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TX2LogDictionaryDetails.GetDateTimeValue(const Key: string): TDateTime;
|
|
|
|
begin
|
|
|
|
Result := (FValues[Key] as TX2LogDictionaryDateTimeValue).Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TX2LogDictionaryDetails.GetValue(const Key: string): TX2LogDictionaryValue;
|
|
|
|
begin
|
|
|
|
Result := FValues[Key];
|
2016-10-10 20:17:53 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2017-04-26 15:20:48 +00:00
|
|
|
procedure TX2LogDictionaryDetails.SetBooleanValue(const Key: string; const AValue: Boolean);
|
|
|
|
begin
|
|
|
|
FValues.Add(Key, TX2LogDictionaryBooleanValue.Create(AValue));
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2LogDictionaryDetails.SetDateTimeValue(const Key: string; const AValue: TDateTime);
|
|
|
|
begin
|
|
|
|
FValues.Add(Key, TX2LogDictionaryDateTimeValue.Create(AValue));
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2LogDictionaryDetails.SetFloatValue(const Key: string; const AValue: Extended);
|
|
|
|
begin
|
|
|
|
FValues.Add(Key, TX2LogDictionaryFloatValue.Create(AValue));
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2LogDictionaryDetails.SetIntValue(const Key: string; const AValue: Int64);
|
|
|
|
begin
|
|
|
|
FValues.Add(Key, TX2LogDictionaryIntValue.Create(AValue));
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2LogDictionaryDetails.SetStringValue(const Key, AValue: string);
|
|
|
|
begin
|
|
|
|
FValues.Add(Key, TX2LogDictionaryStringValue.Create(AValue));
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-30 12:51:01 +00:00
|
|
|
{ TX2LogBinaryDetails }
|
2014-05-31 20:10:10 +00:00
|
|
|
constructor TX2LogBinaryDetails.Create;
|
2014-05-30 12:51:01 +00:00
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
|
|
|
|
FData := TMemoryStream.Create;
|
2014-05-31 20:10:10 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
constructor TX2LogBinaryDetails.Create(ACopyFrom: TStream; ACount: Integer);
|
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
|
|
|
|
FData := TMemoryStream.Create;
|
|
|
|
FData.CopyFrom(ACopyFrom, ACount);
|
2014-05-30 12:51:01 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
constructor TX2LogBinaryDetails.Create(AData: RawByteString);
|
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
|
|
|
|
FData := TStringStream.Create(AData);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
destructor TX2LogBinaryDetails.Destroy;
|
|
|
|
begin
|
|
|
|
FreeAndNil(FData);
|
|
|
|
|
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-31 20:10:10 +00:00
|
|
|
function TX2LogBinaryDetails.GetSerializerIID: TGUID;
|
|
|
|
begin
|
|
|
|
Result := BinaryDetailsSerializerIID;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-30 12:51:01 +00:00
|
|
|
function TX2LogBinaryDetails.GetAsStream: TStream;
|
|
|
|
begin
|
|
|
|
Data.Position := 0;
|
|
|
|
Result := Data;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2LogBinaryDetails.SaveToStream(AStream: TStream);
|
|
|
|
begin
|
|
|
|
AStream.CopyFrom(Data, 0);
|
|
|
|
end;
|
|
|
|
|
2014-05-31 20:10:10 +00:00
|
|
|
|
2014-06-01 13:32:21 +00:00
|
|
|
{ TX2LogGraphicDetails }
|
|
|
|
class function TX2LogGraphicDetails.CreateIfNotEmpty(AGraphic: TGraphic): TX2LogGraphicDetails;
|
|
|
|
begin
|
|
|
|
if Assigned(AGraphic) and (not AGraphic.Empty) then
|
|
|
|
Result := Self.Create(AGraphic)
|
|
|
|
else
|
|
|
|
Result := nil;
|
|
|
|
end;
|
|
|
|
|
2014-05-31 20:10:10 +00:00
|
|
|
|
2014-06-01 13:32:21 +00:00
|
|
|
constructor TX2LogGraphicDetails.Create(AGraphic: TGraphic);
|
2014-05-31 20:10:10 +00:00
|
|
|
begin
|
2014-06-01 13:32:21 +00:00
|
|
|
inherited Create;
|
|
|
|
|
|
|
|
if not Assigned(AGraphic) then
|
|
|
|
raise EInvalidGraphic.Create('AGraphic can not be nil');
|
2014-05-31 20:10:10 +00:00
|
|
|
|
2014-06-01 13:32:21 +00:00
|
|
|
FGraphic := TGraphicClass(AGraphic.ClassType).Create;
|
|
|
|
FGraphic.Assign(AGraphic);
|
2014-05-31 20:10:10 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-06-01 13:32:21 +00:00
|
|
|
constructor TX2LogGraphicDetails.CreateOwned(AGraphic: TGraphic; ADummy: Integer);
|
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
|
|
|
|
FGraphic := AGraphic;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
destructor TX2LogGraphicDetails.Destroy;
|
|
|
|
begin
|
|
|
|
FreeAndNil(FGraphic);
|
|
|
|
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TX2LogGraphicDetails.GetSerializerIID: TGUID;
|
|
|
|
begin
|
|
|
|
Result := GraphicDetailsSerializerIID;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2LogGraphicDetails.CopyToClipboard;
|
2014-05-31 20:10:10 +00:00
|
|
|
var
|
2014-06-01 13:32:21 +00:00
|
|
|
format: Word;
|
|
|
|
data: NativeUInt;
|
|
|
|
palette: HPALETTE;
|
2014-05-31 20:10:10 +00:00
|
|
|
|
|
|
|
begin
|
2014-06-01 13:32:21 +00:00
|
|
|
GetAsGraphic.SaveToClipboardFormat(format, data, palette);
|
|
|
|
end;
|
2014-05-31 20:10:10 +00:00
|
|
|
|
2014-06-01 13:32:21 +00:00
|
|
|
|
|
|
|
procedure TX2LogGraphicDetails.SaveToStream(AStream: TStream);
|
|
|
|
begin
|
|
|
|
FGraphic.SaveToStream(AStream);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TX2LogGraphicDetails.GetAsGraphic: TGraphic;
|
|
|
|
begin
|
|
|
|
Result := FGraphic;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{ TX2LogStringDetailsSerializer }
|
|
|
|
procedure TX2LogStringDetailsSerializer.Serialize(ADetails: IX2LogDetails; AStream: TStream);
|
|
|
|
begin
|
|
|
|
TStreamUtil.WriteString(AStream, (ADetails as IX2LogDetailsText).AsString);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TX2LogStringDetailsSerializer.Deserialize(AStream: TStream): IX2LogDetails;
|
|
|
|
begin
|
|
|
|
Result := TX2LogStringDetails.Create(TStreamUtil.ReadString(AStream));
|
2014-05-31 20:10:10 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-10 20:17:53 +00:00
|
|
|
{ TX2LogDictionaryDetailsSerializer }
|
2016-10-13 20:58:56 +00:00
|
|
|
procedure TX2LogDictionaryDetailsSerializer.Serialize(ADetails: IX2LogDetails; AStream: TStream);
|
|
|
|
var
|
|
|
|
details: IX2LogDetailsDictionaryAccess;
|
|
|
|
key: string;
|
|
|
|
value: TX2LogDictionaryValue;
|
|
|
|
payload: TMemoryStream;
|
|
|
|
|
2016-10-10 20:17:53 +00:00
|
|
|
begin
|
2016-10-13 20:58:56 +00:00
|
|
|
details := (ADetails as IX2LogDetailsDictionaryAccess);
|
|
|
|
|
|
|
|
payload := TMemoryStream.Create;
|
|
|
|
try
|
|
|
|
for key in details.Keys do
|
|
|
|
begin
|
|
|
|
TStreamUtil.WriteString(AStream, key);
|
|
|
|
|
|
|
|
value := details.Value[key];
|
|
|
|
TStreamUtil.WriteByte(AStream, Ord(value.ValueType));
|
|
|
|
|
|
|
|
payload.Clear;
|
|
|
|
value.SaveToStream(payload);
|
|
|
|
|
|
|
|
TStreamUtil.WriteCardinal(AStream, payload.Size);
|
|
|
|
if payload.Size > 0 then
|
|
|
|
AStream.CopyFrom(payload, 0);
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
FreeAndNil(payload);
|
|
|
|
end;
|
|
|
|
|
|
|
|
TStreamUtil.WriteString(AStream, '');
|
2016-10-10 20:17:53 +00:00
|
|
|
end;
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
|
|
|
|
function TX2LogDictionaryDetailsSerializer.Deserialize(AStream: TStream): IX2LogDetails;
|
|
|
|
var
|
|
|
|
values: TX2LogValueDictionary;
|
|
|
|
key: string;
|
|
|
|
valueType: TX2LogValueType;
|
|
|
|
payloadSize: Cardinal;
|
|
|
|
valueClass: TX2LogDictionaryValueClass;
|
|
|
|
|
2016-10-10 20:17:53 +00:00
|
|
|
begin
|
2016-10-13 20:58:56 +00:00
|
|
|
Result := nil;
|
|
|
|
|
|
|
|
values := TX2LogValueDictionary.Create([doOwnsValues]);
|
|
|
|
try
|
|
|
|
while True do
|
|
|
|
begin
|
|
|
|
key := TStreamUtil.ReadString(AStream);
|
|
|
|
if Length(key) = 0 then
|
|
|
|
break;
|
|
|
|
|
|
|
|
valueType := TX2LogValueType(TStreamUtil.ReadByte(AStream));
|
|
|
|
payloadSize := TStreamUtil.ReadCardinal(AStream);
|
|
|
|
|
|
|
|
valueClass := nil;
|
|
|
|
case valueType of
|
|
|
|
StringValue: valueClass := TX2LogDictionaryStringValue;
|
|
|
|
BooleanValue: valueClass := TX2LogDictionaryBooleanValue;
|
|
|
|
IntValue: valueClass := TX2LogDictionaryIntValue;
|
|
|
|
FloatValue: valueClass := TX2LogDictionaryFloatValue;
|
|
|
|
DateTimeValue: valueClass := TX2LogDictionaryDateTimeValue;
|
|
|
|
else
|
2017-07-06 14:58:29 +00:00
|
|
|
AStream.Position := AStream.Position + payloadSize;
|
2016-10-13 20:58:56 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
if Assigned(valueClass) then
|
2017-01-09 13:48:35 +00:00
|
|
|
values.Add(key, valueClass.Create(valueType, AStream, payloadSize));
|
2016-10-13 20:58:56 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
Result := TX2LogDictionaryDetails.CreateOwned(values);
|
2017-01-09 13:48:35 +00:00
|
|
|
values := nil;
|
2016-10-13 20:58:56 +00:00
|
|
|
finally
|
|
|
|
FreeAndNil(values);
|
|
|
|
end;
|
2016-10-10 20:17:53 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-31 20:10:10 +00:00
|
|
|
{ TX2LogBinaryDetailsSerializer }
|
|
|
|
procedure TX2LogBinaryDetailsSerializer.Serialize(ADetails: IX2LogDetails; AStream: TStream);
|
|
|
|
var
|
|
|
|
stream: TStream;
|
|
|
|
|
|
|
|
begin
|
|
|
|
stream := (ADetails as IX2LogDetailsBinary).AsStream;
|
|
|
|
|
2014-06-01 13:32:21 +00:00
|
|
|
TStreamUtil.WriteCardinal(AStream, stream.Size);
|
|
|
|
if stream.Size > 0 then
|
|
|
|
AStream.CopyFrom(stream, stream.Size);
|
2014-05-31 20:10:10 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TX2LogBinaryDetailsSerializer.Deserialize(AStream: TStream): IX2LogDetails;
|
|
|
|
var
|
|
|
|
streamSize: Cardinal;
|
|
|
|
|
|
|
|
begin
|
2014-06-01 13:32:21 +00:00
|
|
|
streamSize := TStreamUtil.ReadCardinal(AStream);
|
2014-05-31 20:10:10 +00:00
|
|
|
if streamSize > 0 then
|
|
|
|
Result := TX2LogBinaryDetails.Create(AStream, streamSize)
|
|
|
|
else
|
|
|
|
{ Do not return nil; the fact that Deserialize is called means an
|
|
|
|
empty Details was serialized. }
|
|
|
|
Result := TX2LogBinaryDetails.Create;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-06-01 13:32:21 +00:00
|
|
|
{ TX2LogGraphicDetailsSerializer }
|
|
|
|
procedure TX2LogGraphicDetailsSerializer.Serialize(ADetails: IX2LogDetails; AStream: TStream);
|
|
|
|
var
|
|
|
|
graphic: TGraphic;
|
|
|
|
|
|
|
|
begin
|
|
|
|
graphic := (ADetails as IX2LogDetailsGraphic).AsGraphic;
|
|
|
|
TStreamUtil.WriteString(AStream, graphic.ClassName);
|
|
|
|
graphic.SaveToStream(AStream);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
function TX2LogGraphicDetailsSerializer.Deserialize(AStream: TStream): IX2LogDetails;
|
|
|
|
var
|
|
|
|
graphicClass: TGraphicClass;
|
|
|
|
graphic: TGraphic;
|
|
|
|
|
|
|
|
begin
|
|
|
|
Result := nil;
|
|
|
|
graphicClass := TGraphicClass(GetClass(TStreamUtil.ReadString(AStream)));
|
|
|
|
if Assigned(graphicClass) then
|
|
|
|
begin
|
|
|
|
graphic := graphicClass.Create;
|
|
|
|
try
|
|
|
|
graphic.LoadFromStream(AStream);
|
|
|
|
Result := TX2LogGraphicDetails.CreateOwned(graphic);
|
|
|
|
except
|
|
|
|
FreeAndNil(graphic);
|
|
|
|
raise;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
{ TX2LogDictionaryValue }
|
2016-10-14 14:43:53 +00:00
|
|
|
constructor TX2LogDictionaryValue.Create(AValueType: TX2LogValueType; AStream: TStream; ASize: Cardinal);
|
2016-10-13 20:58:56 +00:00
|
|
|
begin
|
2016-10-14 14:43:53 +00:00
|
|
|
inherited Create;
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
FValueType := AValueType;
|
|
|
|
|
2016-10-14 14:43:53 +00:00
|
|
|
if Assigned(AStream) then
|
|
|
|
LoadFromStream(AStream, ASize);
|
2016-10-13 20:58:56 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{ TX2LogDictionaryStringValue }
|
2016-10-14 14:43:53 +00:00
|
|
|
constructor TX2LogDictionaryStringValue.Create(const AValue: string);
|
2016-10-13 20:58:56 +00:00
|
|
|
begin
|
2016-10-14 14:43:53 +00:00
|
|
|
inherited Create(StringValue);
|
|
|
|
|
|
|
|
Value := AValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2LogDictionaryStringValue.LoadFromStream(AStream: TStream; ASize: Cardinal);
|
|
|
|
begin
|
|
|
|
Value := TStreamUtil.ReadString(AStream, nil, False, ASize);
|
2016-10-13 20:58:56 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2LogDictionaryStringValue.SaveToStream(AStream: TStream);
|
|
|
|
begin
|
2016-10-14 14:43:53 +00:00
|
|
|
TStreamUtil.WriteString(AStream, Value, nil, False);
|
2016-10-13 20:58:56 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-15 09:22:51 +00:00
|
|
|
function TX2LogDictionaryStringValue.GetDisplayValue: string;
|
|
|
|
begin
|
|
|
|
Result := Value;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
{ TX2LogDictionaryBooleanValue }
|
2016-10-14 14:43:53 +00:00
|
|
|
constructor TX2LogDictionaryBooleanValue.Create(AValue: Boolean);
|
2016-10-13 20:58:56 +00:00
|
|
|
begin
|
2016-10-14 14:43:53 +00:00
|
|
|
inherited Create(BooleanValue);
|
|
|
|
|
|
|
|
Value := AValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2LogDictionaryBooleanValue.LoadFromStream(AStream: TStream; ASize: Cardinal);
|
|
|
|
begin
|
|
|
|
if ASize <> SizeOf(Boolean) then
|
|
|
|
raise EInvalidOperation.CreateFmt('Size (%d) does not match Boolean', [ASize]);
|
|
|
|
|
|
|
|
AStream.ReadBuffer(FValue, ASize);
|
2016-10-13 20:58:56 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2LogDictionaryBooleanValue.SaveToStream(AStream: TStream);
|
|
|
|
begin
|
2016-10-14 14:43:53 +00:00
|
|
|
AStream.WriteBuffer(Value, SizeOf(Boolean));
|
2016-10-13 20:58:56 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-15 09:22:51 +00:00
|
|
|
function TX2LogDictionaryBooleanValue.GetDisplayValue: string;
|
|
|
|
begin
|
|
|
|
Result := BoolToStr(Value, True);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
{ TX2LogDictionaryIntValue }
|
2016-10-14 14:43:53 +00:00
|
|
|
constructor TX2LogDictionaryIntValue.Create(AValue: Int64);
|
|
|
|
begin
|
|
|
|
inherited Create(IntValue);
|
|
|
|
|
|
|
|
Value := AValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2LogDictionaryIntValue.LoadFromStream(AStream: TStream; ASize: Cardinal);
|
2016-10-13 20:58:56 +00:00
|
|
|
begin
|
2016-10-14 14:43:53 +00:00
|
|
|
if ASize <> SizeOf(Int64) then
|
|
|
|
raise EInvalidOperation.CreateFmt('Size (%d) does not match Int64', [ASize]);
|
|
|
|
|
|
|
|
AStream.ReadBuffer(FValue, ASize);
|
2016-10-13 20:58:56 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2LogDictionaryIntValue.SaveToStream(AStream: TStream);
|
|
|
|
begin
|
2016-10-14 14:43:53 +00:00
|
|
|
AStream.WriteBuffer(Value, SizeOf(Int64));
|
2016-10-13 20:58:56 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-15 09:22:51 +00:00
|
|
|
function TX2LogDictionaryIntValue.GetDisplayValue: string;
|
|
|
|
begin
|
|
|
|
Result := IntToStr(Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
{ TX2LogDictionaryFloatValue }
|
2016-10-14 14:43:53 +00:00
|
|
|
constructor TX2LogDictionaryFloatValue.Create(AValue: Extended);
|
2016-10-13 20:58:56 +00:00
|
|
|
begin
|
2016-10-14 14:43:53 +00:00
|
|
|
inherited Create(FloatValue);
|
|
|
|
|
|
|
|
Value := AValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2LogDictionaryFloatValue.LoadFromStream(AStream: TStream; ASize: Cardinal);
|
|
|
|
begin
|
|
|
|
if ASize <> SizeOf(Extended) then
|
|
|
|
raise EInvalidOperation.CreateFmt('Size (%d) does not match Extended', [ASize]);
|
|
|
|
|
|
|
|
AStream.ReadBuffer(FValue, ASize);
|
2016-10-13 20:58:56 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2LogDictionaryFloatValue.SaveToStream(AStream: TStream);
|
|
|
|
begin
|
2016-10-14 14:43:53 +00:00
|
|
|
AStream.WriteBuffer(Value, SizeOf(Extended));
|
2016-10-13 20:58:56 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-15 09:22:51 +00:00
|
|
|
function TX2LogDictionaryFloatValue.GetDisplayValue: string;
|
|
|
|
begin
|
|
|
|
Result := FormatFloat('0.########', Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-13 20:58:56 +00:00
|
|
|
{ TX2LogDictionaryDateTimeValue }
|
2016-10-14 14:43:53 +00:00
|
|
|
constructor TX2LogDictionaryDateTimeValue.Create(AValue: TDateTime);
|
2016-10-13 20:58:56 +00:00
|
|
|
begin
|
2016-10-14 14:43:53 +00:00
|
|
|
inherited Create(DateTimeValue);
|
|
|
|
|
|
|
|
Value := AValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2LogDictionaryDateTimeValue.LoadFromStream(AStream: TStream; ASize: Cardinal);
|
|
|
|
begin
|
|
|
|
if ASize <> SizeOf(TDateTime) then
|
|
|
|
raise EInvalidOperation.CreateFmt('Size (%d) does not match TDateTime', [ASize]);
|
|
|
|
|
|
|
|
AStream.ReadBuffer(FValue, ASize);
|
2016-10-13 20:58:56 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
procedure TX2LogDictionaryDateTimeValue.SaveToStream(AStream: TStream);
|
|
|
|
begin
|
2016-10-14 14:43:53 +00:00
|
|
|
AStream.WriteBuffer(Value, SizeOf(TDateTime));
|
2016-10-13 20:58:56 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2016-10-15 09:22:51 +00:00
|
|
|
function TX2LogDictionaryDateTimeValue.GetDisplayValue: string;
|
|
|
|
begin
|
|
|
|
Result := DateTimeToStr(Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-05-31 20:10:10 +00:00
|
|
|
initialization
|
|
|
|
TX2LogDetailsRegistry.Register(StringDetailsSerializerIID, TX2LogStringDetailsSerializer.Create);
|
2016-10-10 20:17:53 +00:00
|
|
|
TX2LogDetailsRegistry.Register(DictionaryDetailsSerializerIID, TX2LogDictionaryDetailsSerializer.Create);
|
2014-05-31 20:10:10 +00:00
|
|
|
TX2LogDetailsRegistry.Register(BinaryDetailsSerializerIID, TX2LogBinaryDetailsSerializer.Create);
|
2014-06-01 13:32:21 +00:00
|
|
|
TX2LogDetailsRegistry.Register(GraphicDetailsSerializerIID, TX2LogGraphicDetailsSerializer.Create);
|
2014-05-31 20:10:10 +00:00
|
|
|
|
2014-05-30 12:51:01 +00:00
|
|
|
end.
|
2014-05-31 20:10:10 +00:00
|
|
|
|