Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion DMsgPackHelper.pas → dmsgpackhelper.pas
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
unit DMsgPackHelper;

{$IFDEF FPC}
{$MODE Delphi}
{$I fpc.inc}
{$ENDIF}
interface

uses
Expand Down
3 changes: 3 additions & 0 deletions fpc.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{$MACRO ON}
{$define RTLVersion := 25}
{$define CompilerVersion := 18}
Binary file removed qdac_msgpackviewTools.7z
Binary file not shown.
32 changes: 31 additions & 1 deletion SimpleMsgPack.pas → simplemsgpack.pas
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,16 @@


*)
{
* add free pascal support by cpicanco
2017-08-29 13:34:00
}
unit SimpleMsgPack;

{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}

interface

uses
Expand All @@ -87,6 +95,12 @@ interface
{$IFDEF MSWINDOWS}, Windows{$ENDIF}
,Variants;

{$IFDEF FPC}
{$I fpc.inc}
type
PBOOLEAN = ^ByteBool;
{$ENDIF}

type
{$IF RTLVersion<25}
IntPtr=Integer;
Expand Down Expand Up @@ -330,7 +344,8 @@ TSimpleMsgPack = class(TObject)
property AsVariant: Variant read GetAsVariant write SetAsVariant;

property AsBytes: TBytes read GetAsBytes write SetAsBytes;

property Key : string read FName; // for Items only
property Value : string read getAsString; // alias for AsString
property O[pvPath: String]: TSimpleMsgPack read GetO write SetO;
property S[pvPath: String]: string read GetS write SetS;
property I[pvPath: String]: Int64 read GetI write SetI;
Expand Down Expand Up @@ -2097,6 +2112,20 @@ procedure TSimpleMsgPack.SetAsSingle(const Value: Single);
PSingle(FValue)^ := Value;
end;

{$IFDEF FPC}
procedure TSimpleMsgPack.setAsString(pvValue: string);
var l : SizeInt;
begin
FDataType := mptString;
if SizeOf(Char) = 2 then
l := Length(pvValue) shl 1
else
l := Length(pvValue);
SetLength(FValue, l);
if l > 0 then
Move(PChar(pvValue)^, FValue[0], l);
end;
{$ELSE}
procedure TSimpleMsgPack.setAsString(pvValue: string);
begin
FDataType := mptString;
Expand All @@ -2110,6 +2139,7 @@ procedure TSimpleMsgPack.setAsString(pvValue: string);
Move(PChar(pvValue)^, FValue[0], Length(FValue));
end;
end;
{$ENDIF}

/// <summary>
/// copy from qdac3
Expand Down